diff options
| author | Ralf Jung <post@ralfj.de> | 2020-06-15 09:57:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-15 09:57:24 +0200 |
| commit | 3d41252fcc28d9da1005f3207462e95006c232e4 (patch) | |
| tree | 30de705d5f79e6e99519322c18caaeffbbc26f2e /src/test | |
| parent | 372cb9b69c76a042d0b9d4b48ff6084f64c84a2c (diff) | |
| parent | 98eb29cbba66561cf184f2d7f4277b38bd6b2aad (diff) | |
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!
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/traits/trait-alias/issue-60021-assoc-method-resolve.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/traits/trait-alias/issue-72415-assoc-const-resolve.rs | 14 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/test/ui/traits/trait-alias/issue-60021-assoc-method-resolve.rs b/src/test/ui/traits/trait-alias/issue-60021-assoc-method-resolve.rs new file mode 100644 index 00000000000..5e27ed3c646 --- /dev/null +++ b/src/test/ui/traits/trait-alias/issue-60021-assoc-method-resolve.rs @@ -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); +} diff --git a/src/test/ui/traits/trait-alias/issue-72415-assoc-const-resolve.rs b/src/test/ui/traits/trait-alias/issue-72415-assoc-const-resolve.rs new file mode 100644 index 00000000000..e49125d1024 --- /dev/null +++ b/src/test/ui/traits/trait-alias/issue-72415-assoc-const-resolve.rs @@ -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() {} |
