-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefer lower TraitUpcasting candidates
- Loading branch information
1 parent
2ae9916
commit bf545ce
Showing
6 changed files
with
54 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
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
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
29 changes: 29 additions & 0 deletions
29
tests/ui/traits/trait-upcasting/prefer-lower-candidates.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,29 @@ | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
//@ check-pass | ||
|
||
// Ensure we don't have ambiguity when upcasting to two supertraits | ||
// that are identical modulo normalization. | ||
|
||
#![feature(trait_upcasting)] | ||
|
||
trait Supertrait<T> { | ||
fn method(&self) {} | ||
} | ||
impl<T> Supertrait<T> for () {} | ||
|
||
trait Identity { | ||
type Selff; | ||
} | ||
impl<Selff> Identity for Selff { | ||
type Selff = Selff; | ||
} | ||
trait Trait<P>: Supertrait<()> + Supertrait<<P as Identity>::Selff> {} | ||
|
||
impl<P> Trait<P> for () {} | ||
|
||
fn main() { | ||
let x: &dyn Trait<()> = &(); | ||
let x: &dyn Supertrait<()> = x; | ||
} |