2024-10-04 16:10:28 +02:00
error[E0782]: expected a type, found a trait
--> $DIR/avoid-ice-on-warning-3.rs:14:19
2024-01-23 18:24:40 +00:00
|
2024-10-04 16:10:28 +02:00
LL | trait A { fn g(b: B) -> B; }
| ^
2024-01-23 18:24:40 +00:00
|
2025-03-14 20:19:38 +00:00
= note: `B` is dyn-incompatible, otherwise a trait object could be used
2024-10-04 16:10:28 +02:00
help: use a new generic type parameter, constrained by `B`
|
2024-07-09 22:30:26 +00:00
LL - trait A { fn g(b: B) -> B; }
LL + trait A { fn g<T: B>(b: T) -> B; }
|
2024-10-04 16:10:28 +02:00
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
LL | trait A { fn g(b: impl B) -> B; }
| ++++
error[E0782]: expected a type, found a trait
--> $DIR/avoid-ice-on-warning-3.rs:14:25
2024-01-23 18:24:40 +00:00
|
LL | trait A { fn g(b: B) -> B; }
2024-10-04 16:10:28 +02:00
| ^
2024-01-23 18:24:40 +00:00
|
2024-10-04 16:10:28 +02:00
help: `B` is dyn-incompatible, use `impl B` to return an opaque type, as long as you return a single underlying type
2024-01-23 18:24:40 +00:00
|
2024-10-04 16:10:28 +02:00
LL | trait A { fn g(b: B) -> impl B; }
| ++++
2024-01-23 18:24:40 +00:00
2024-10-04 16:10:28 +02:00
error[E0782]: expected a type, found a trait
--> $DIR/avoid-ice-on-warning-3.rs:4:19
2024-01-23 18:24:40 +00:00
|
2024-10-04 16:10:28 +02:00
LL | trait B { fn f(a: A) -> A; }
| ^
2024-01-23 18:24:40 +00:00
|
2025-03-14 20:19:38 +00:00
= note: `A` is dyn-incompatible, otherwise a trait object could be used
2024-10-04 16:10:28 +02:00
help: use a new generic type parameter, constrained by `A`
|
2024-07-09 22:30:26 +00:00
LL - trait B { fn f(a: A) -> A; }
LL + trait B { fn f<T: A>(a: T) -> A; }
|
2024-10-04 16:10:28 +02:00
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
LL | trait B { fn f(a: impl A) -> A; }
| ++++
error[E0782]: expected a type, found a trait
--> $DIR/avoid-ice-on-warning-3.rs:4:25
2024-01-23 18:24:40 +00:00
|
LL | trait B { fn f(a: A) -> A; }
2024-10-04 16:10:28 +02:00
| ^
2024-01-23 18:24:40 +00:00
|
2024-10-04 16:10:28 +02:00
help: `A` is dyn-incompatible, use `impl A` to return an opaque type, as long as you return a single underlying type
2024-01-23 18:24:40 +00:00
|
2024-10-04 16:10:28 +02:00
LL | trait B { fn f(a: A) -> impl A; }
| ++++
2024-01-23 18:24:40 +00:00
2024-10-04 16:10:28 +02:00
error: aborting due to 4 previous errors
2024-01-23 18:24:40 +00:00
2024-10-04 16:10:28 +02:00
For more information about this error, try `rustc --explain E0782`.