Rollup merge of #72556 - matthew-mcallister:trait-alias-inherent-impl, r=estebank
Fix trait alias inherent impl resolution Fixes #60021 and fixes #72415. Obviously, the fix was very easy, but getting started with the testing and debugging rust compiler was an interesting experience. Now I can cross it off my bucket list!
This commit is contained in:
commit
3d41252fcc
3 changed files with 35 additions and 1 deletions
|
|
@ -0,0 +1,19 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(trait_alias)]
|
||||
|
||||
trait SomeTrait {
|
||||
fn map(&self) {}
|
||||
}
|
||||
|
||||
impl<T> SomeTrait for Option<T> {}
|
||||
|
||||
trait SomeAlias = SomeTrait;
|
||||
|
||||
fn main() {
|
||||
let x = Some(123);
|
||||
// This should resolve to the trait impl for Option
|
||||
Option::map(x, |z| z);
|
||||
// This should resolve to the trait impl for SomeTrait
|
||||
SomeTrait::map(&x);
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(trait_alias)]
|
||||
|
||||
trait Bounded { const MAX: Self; }
|
||||
|
||||
impl Bounded for u32 {
|
||||
// This should correctly resolve to the associated const in the inherent impl of u32.
|
||||
const MAX: Self = u32::MAX;
|
||||
}
|
||||
|
||||
trait Num = Bounded + Copy;
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue