-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #77720 - matthewjasper:fix-trait-ices, r=nikomatsakis
Fix trait solving ICEs - Selection candidates that are known to be applicable are preferred over candidates that are not. - Don't ICE if a projection/object candidate is no longer applicable (this can happen due to cycles in normalization) - Normalize supertraits when finding trait object candidates Closes #77653 Closes #77656 r? `@nikomatsakis`
- Loading branch information
Showing
6 changed files
with
141 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Regression test for #77656 | ||
|
||
// check-pass | ||
|
||
trait Value: PartialOrd {} | ||
|
||
impl<T: PartialOrd> Value for T {} | ||
|
||
trait Distance | ||
where | ||
Self: PartialOrd<<Self as Distance>::Value>, | ||
Self: PartialOrd, | ||
{ | ||
type Value: Value; | ||
} | ||
|
||
impl<T: Value> Distance for T { | ||
type Value = T; | ||
} | ||
|
||
trait Proximity<T = Self> { | ||
type Distance: Distance; | ||
} | ||
|
||
fn main() {} |
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,37 @@ | ||
// Regression test for #77653 | ||
// When monomorphizing `f` we need to prove `dyn Derived<()>: Base<()>`. This | ||
// requires us to normalize the `Base<<() as Proj>::S>` to `Base<()>` when | ||
// comparing the supertrait `Derived<()>` to the expected trait. | ||
|
||
// build-pass | ||
|
||
trait Proj { | ||
type S; | ||
} | ||
|
||
impl Proj for () { | ||
type S = (); | ||
} | ||
|
||
impl Proj for i32 { | ||
type S = i32; | ||
} | ||
|
||
trait Base<T> { | ||
fn is_base(&self); | ||
} | ||
|
||
trait Derived<B: Proj>: Base<B::S> + Base<()> { | ||
fn is_derived(&self); | ||
} | ||
|
||
fn f<P: Proj>(obj: &dyn Derived<P>) { | ||
obj.is_derived(); | ||
Base::<P::S>::is_base(obj); | ||
Base::<()>::is_base(obj); | ||
} | ||
|
||
fn main() { | ||
let x: fn(_) = f::<()>; | ||
let x: fn(_) = f::<i32>; | ||
} |