I'm not sure if this is a bug or not.
The following code does not compile:
trait Super<'a, T> {}
trait Sub<'a, 'b>: Super<'a, i32> + Super<'b, i32> {}
Error output:
error[E0283]: type annotations needed: cannot satisfy `Self: Super<'a, i32>`
--> src/lib.rs:2:20
|
2 | trait Sub<'a, 'b>: Super<'a, i32> + Super<'b, i32> {}
| ^^^^^^^^^^^^^^
|
note: multiple `impl`s or `where` clauses satisfying `Self: Super<'a, i32>` found
--> src/lib.rs:2:20
|
2 | trait Sub<'a, 'b>: Super<'a, i32> + Super<'b, i32> {}
| ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0283`.
The following code doesn't compile:
trait Super<'a, T> {}
trait Sub<'a, 'b, T, U>: Super<'a, T> + Super<'b, U> {}
trait Lol<'a, 'b>: Sub<'a, 'b, i32, i32> {}
Error output:
error[E0283]: type annotations needed: cannot satisfy `Self: Super<'a, i32>`
--> src/lib.rs:3:20
|
3 | trait Lol<'a, 'b>: Sub<'a, 'b, i32, i32> {}
| ^^^^^^^^^^^^^^^^^^^^^
|
note: multiple `impl`s or `where` clauses satisfying `Self: Super<'a, i32>` found
--> src/lib.rs:3:20
|
3 | trait Lol<'a, 'b>: Sub<'a, 'b, i32, i32> {}
| ^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `Sub`
--> src/lib.rs:2:26
|
2 | trait Sub<'a, 'b, T, U>: Super<'a, T> + Super<'b, U> {}
| ^^^^^^^^^^^^ required by this bound in `Sub`
For more information about this error, try `rustc --explain E0283`.
The following code compiles
trait Super<'a, T> {}
trait Sub<'a, 'b, T, U>: Super<'a, T> + Super<'b, U> {}
trait Lol: for<'a, 'b> Sub<'a, 'b, i32, i32> {}
fn wut(_: &dyn Lol) {}
The following code also compiles:
trait Super<'a, T> {}
trait Sub<'a, 'b, T, U>: Super<'a, T> + Super<'b, U> {}
trait Lol: Sub<'static, 'static, i32, i32> {}
fn wut(_: &dyn Lol) {}
The following code does NOT compile:
trait Super<'a, T> {}
trait Sub<'a, 'b, T, U>: Super<'a, T> + Super<'b, U> {}
trait Lol: for<'a> Sub<'a, 'static, i32, i32> {}
fn wut(_: &dyn Lol) {}
Error output:
error[E0283]: type annotations needed: cannot satisfy `Self: Super<'static, i32>`
--> src/lib.rs:3:12
|
3 | trait Lol: for<'a> Sub<'a, 'static, i32, i32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: multiple `impl`s or `where` clauses satisfying `Self: Super<'static, i32>` found
--> src/lib.rs:3:12
|
3 | trait Lol: for<'a> Sub<'a, 'static, i32, i32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `Sub`
--> src/lib.rs:2:41
|
2 | trait Sub<'a, 'b, T, U>: Super<'a, T> + Super<'b, U> {}
| ^^^^^^^^^^^^ required by this bound in `Sub`
For more information about this error, try `rustc --explain E0283`.
I don't understand what the compiler is doing.
Discovered while investigating #154662.
Meta
Reproducible on the playground with rust 1.96.0.
I'm not sure if this is a bug or not.
The following code does not compile:
Error output:
The following code doesn't compile:
Error output:
The following code compiles
The following code also compiles:
The following code does NOT compile:
Error output:
I don't understand what the compiler is doing.
Discovered while investigating #154662.
Meta
Reproducible on the playground with rust 1.96.0.