Fix trait alias inherent impl resolution

Fixes #60021 and #72415.
This commit is contained in:
Matthew McAllister 2020-05-24 17:54:30 -07:00
parent 963bf52829
commit 98eb29cbba
3 changed files with 35 additions and 1 deletions

View file

@ -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);
}

View file

@ -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() {}