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#76940 - Aaron1011:fix/trait-on-tait, r=oli-obk
Don't allow implementing trait directly on type-alias-impl-trait This is specifically disallowed by the RFC, but we never added a check for it. Fixes rust-lang#76202
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 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
23 changes: 23 additions & 0 deletions
23
src/test/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.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,23 @@ | ||
// Regression test for issue #76202 | ||
// Tests that we don't ICE when we have a trait impl on a TAIT. | ||
|
||
#![feature(type_alias_impl_trait)] | ||
|
||
trait Dummy {} | ||
impl Dummy for () {} | ||
|
||
type F = impl Dummy; | ||
fn f() -> F {} | ||
|
||
trait Test { | ||
fn test(self); | ||
} | ||
|
||
impl Test for F { //~ ERROR cannot implement trait | ||
fn test(self) {} | ||
} | ||
|
||
fn main() { | ||
let x: F = f(); | ||
x.test(); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.stderr
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 @@ | ||
error: cannot implement trait on type alias impl trait | ||
--> $DIR/issue-76202-trait-impl-for-tait.rs:16:1 | ||
| | ||
LL | impl Test for F { | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
note: type alias impl trait defined here | ||
--> $DIR/issue-76202-trait-impl-for-tait.rs:9:10 | ||
| | ||
LL | type F = impl Dummy; | ||
| ^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|