-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e69fcea
commit cb40684
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//! Basic test for calling methods on generic type parameters in `const fn`. | ||
// check-pass | ||
|
||
#![feature(const_fn)] | ||
#![feature(const_trait_impl)] | ||
#![allow(incomplete_features)] | ||
|
||
struct S; | ||
|
||
impl const PartialEq for S { | ||
fn eq(&self, _: &S) -> bool { | ||
true | ||
} | ||
} | ||
|
||
const fn equals_self<T: PartialEq>(t: &T) -> bool { | ||
*t == *t | ||
} | ||
|
||
const fn equals_self_wrapper<T: PartialEq>(t: &T) -> bool { | ||
equals_self(t) | ||
} | ||
|
||
pub const EQ: bool = equals_self_wrapper(&S); | ||
|
||
fn main() {} |
24 changes: 24 additions & 0 deletions
24
src/test/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// check-pass | ||
|
||
#![feature(const_fn)] | ||
#![feature(const_trait_impl)] | ||
#![feature(const_trait_bound_opt_out)] | ||
#![allow(incomplete_features)] | ||
|
||
struct S; | ||
|
||
impl const PartialEq for S { | ||
fn eq(&self, _: &S) -> bool { | ||
true | ||
} | ||
} | ||
|
||
// This duplicate bound should not result in ambiguities. It should be equivalent to a single const | ||
// bound. | ||
const fn equals_self<T: PartialEq + ?const PartialEq>(t: &T) -> bool { | ||
*t == *t | ||
} | ||
|
||
pub const EQ: bool = equals_self(&S); | ||
|
||
fn main() {} |