Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions tests/ui/traits/unhandled-crate-mod-issue-144888.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Regression test for <https://github.com/rust-lang/rust/issues/144888>.
// This used to ICE with `unhandled node Crate(Mod)`.

#![crate_type = "lib"]

struct ActuallySuper;

trait Super<Q> {
type Assoc;
}

trait Dyn {}
impl<T, U> Dyn for dyn Foo<T, U> + '_ {}
//~^ ERROR the trait `Foo` is not dyn compatible

trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
where
<Self as Mirror>::Assoc: Super,
//~^ ERROR missing generics for trait `Super`
{
fn transmute(&self, t: T) -> <Self as Super>::Assoc;
//~^ ERROR missing generics for trait `Super`
}

trait Mirror {
type Assoc: ?Sized;
}

impl<T: Super<ActuallySuper, Assoc = T>> Mirror for T {}
//~^ ERROR not all trait items implemented
62 changes: 62 additions & 0 deletions tests/ui/traits/unhandled-crate-mod-issue-144888.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
error[E0107]: missing generics for trait `Super`
--> $DIR/unhandled-crate-mod-issue-144888.rs:18:30
|
LL | <Self as Mirror>::Assoc: Super,
| ^^^^^ expected 1 generic argument
|
note: trait defined here, with 1 generic parameter: `Q`
--> $DIR/unhandled-crate-mod-issue-144888.rs:8:7
|
LL | trait Super<Q> {
| ^^^^^ -
help: add missing generic argument
|
LL | <Self as Mirror>::Assoc: Super<Q>,
| +++

error[E0107]: missing generics for trait `Super`
--> $DIR/unhandled-crate-mod-issue-144888.rs:21:43
|
LL | fn transmute(&self, t: T) -> <Self as Super>::Assoc;
| ^^^^^ expected 1 generic argument
|
note: trait defined here, with 1 generic parameter: `Q`
--> $DIR/unhandled-crate-mod-issue-144888.rs:8:7
|
LL | trait Super<Q> {
| ^^^^^ -
help: add missing generic argument
|
LL | fn transmute(&self, t: T) -> <Self as Super<Q>>::Assoc;
| +++

error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/unhandled-crate-mod-issue-144888.rs:13:20
|
LL | impl<T, U> Dyn for dyn Foo<T, U> + '_ {}
| ^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/unhandled-crate-mod-issue-144888.rs:21:34
|
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
| --- this trait is not dyn compatible...
...
LL | fn transmute(&self, t: T) -> <Self as Super>::Assoc;
| ^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type
= help: consider moving `transmute` to another trait

error[E0046]: not all trait items implemented, missing: `Assoc`
--> $DIR/unhandled-crate-mod-issue-144888.rs:29:1
|
LL | type Assoc: ?Sized;
| ------------------ `Assoc` from trait
...
LL | impl<T: Super<ActuallySuper, Assoc = T>> Mirror for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Assoc` in implementation

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0038, E0046, E0107.
For more information about an error, try `rustc --explain E0038`.
Loading