forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#72556 - matthew-mcallister:trait-alias-inhe…
…rent-impl, r=estebank Fix trait alias inherent impl resolution Fixes rust-lang#60021 and fixes rust-lang#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!
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
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
19 changes: 19 additions & 0 deletions
19
src/test/ui/traits/trait-alias/issue-60021-assoc-method-resolve.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,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); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/traits/trait-alias/issue-72415-assoc-const-resolve.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,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() {} |