You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of #131239 - VulnBandit:trait-vulnerability, r=lcnr
Don't assume traits used as type are trait objs in 2021 edition
Fixes#127548
When you use a trait as a type, the compiler automatically assumes you meant to use a trait object, which is not always the case.
This PR fixes the bug where you don't need a trait object, so the error message was changed to:
```
error[E0782]: expected a type, found a trait
```
Also fixes some ICEs:
Fixes#120241Fixes#120482Fixes#125512
= note: the trait cannot be made into an object because it requires `Self: Sized`
8
-
= note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
9
-
10
-
error[E0225]: only auto traits can be used as additional traits in a trait object
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Debug + Eq {}`
19
-
= note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
20
-
21
-
error[E0038]: the trait `Eq` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^ `Eq` cannot be made into an object
26
-
|
27
-
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
28
-
--> $SRC_DIR/core/src/cmp.rs:LL:COL
29
-
|
30
-
= note: the trait cannot be made into an object because it uses `Self` as a type parameter
31
-
32
-
error[E0782]: trait objects must include the `dyn` keyword
Copy file name to clipboardexpand all lines: tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs
+1-3
Original file line number
Diff line number
Diff line change
@@ -14,10 +14,8 @@ fn f<T>(
14
14
1
15
15
}],
16
16
) -> implIterator<Item = SubAssign>{
17
-
//~^ ERROR the type parameter `Rhs` must be explicitly specified
17
+
//~^ ERROR expected a type, found a trait
18
18
//~| ERROR `()` is not an iterator
19
-
//~| ERROR trait objects must include the `dyn` keyword
20
-
//~| ERROR the type parameter `Rhs` must be explicitly specified [E0393]
0 commit comments