forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
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#137631 - TaKO8Ki:issue-137508, r=compiler-errors Avoid collecting associated types for undefined trait Fixes rust-lang#137508 Fixes rust-lang#137554
- Loading branch information
Showing
5 changed files
with
78 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
8 changes: 8 additions & 0 deletions
8
tests/ui/associated-item/missing-associated_item_or_field_def_ids.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,8 @@ | ||
// Regression test for <https://github.com/rust-lang/rust/issues/137554>. | ||
|
||
fn main() -> dyn Iterator + ?Iterator::advance_by(usize) { | ||
//~^ ERROR `?Trait` is not permitted in trait object types | ||
//~| ERROR expected trait, found associated function `Iterator::advance_by` | ||
//~| ERROR the value of the associated type `Item` in `Iterator` must be specified | ||
todo!() | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/ui/associated-item/missing-associated_item_or_field_def_ids.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,25 @@ | ||
error[E0658]: `?Trait` is not permitted in trait object types | ||
--> $DIR/missing-associated_item_or_field_def_ids.rs:3:29 | ||
| | ||
LL | fn main() -> dyn Iterator + ?Iterator::advance_by(usize) { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0404]: expected trait, found associated function `Iterator::advance_by` | ||
--> $DIR/missing-associated_item_or_field_def_ids.rs:3:30 | ||
| | ||
LL | fn main() -> dyn Iterator + ?Iterator::advance_by(usize) { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a trait | ||
|
||
error[E0191]: the value of the associated type `Item` in `Iterator` must be specified | ||
--> $DIR/missing-associated_item_or_field_def_ids.rs:3:18 | ||
| | ||
LL | fn main() -> dyn Iterator + ?Iterator::advance_by(usize) { | ||
| ^^^^^^^^ help: specify the associated type: `Iterator<Item = Type>` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0191, E0404, E0658. | ||
For more information about an error, try `rustc --explain E0191`. |
12 changes: 12 additions & 0 deletions
12
tests/ui/associated-types/avoid-getting-associated-items-of-undefined-trait.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,12 @@ | ||
// Fix for <https://github.com/rust-lang/rust/issues/137508>. | ||
|
||
trait Tr { | ||
type Item; | ||
} | ||
|
||
fn main() { | ||
let _: dyn Tr + ?Foo<Assoc = ()>; | ||
//~^ ERROR: `?Trait` is not permitted in trait object types | ||
//~| ERROR: cannot find trait `Foo` in this scope | ||
//~| ERROR: the value of the associated type `Item` in `Tr` must be specified | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/ui/associated-types/avoid-getting-associated-items-of-undefined-trait.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,28 @@ | ||
error[E0658]: `?Trait` is not permitted in trait object types | ||
--> $DIR/avoid-getting-associated-items-of-undefined-trait.rs:8:21 | ||
| | ||
LL | let _: dyn Tr + ?Foo<Assoc = ()>; | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0405]: cannot find trait `Foo` in this scope | ||
--> $DIR/avoid-getting-associated-items-of-undefined-trait.rs:8:22 | ||
| | ||
LL | let _: dyn Tr + ?Foo<Assoc = ()>; | ||
| ^^^ not found in this scope | ||
|
||
error[E0191]: the value of the associated type `Item` in `Tr` must be specified | ||
--> $DIR/avoid-getting-associated-items-of-undefined-trait.rs:8:16 | ||
| | ||
LL | type Item; | ||
| --------- `Item` defined here | ||
... | ||
LL | let _: dyn Tr + ?Foo<Assoc = ()>; | ||
| ^^ help: specify the associated type: `Tr<Item = Type>` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0191, E0405, E0658. | ||
For more information about an error, try `rustc --explain E0191`. |