When creating an empty trait object using the dyn syntax, the error message is misleading. Example:
fn main() {
let _x: &dyn = &0;
}
This is rejected, with this message:
error[E0224]: at least one non-builtin trait is required for an object type
--> src/main.rs:2:14
|
2 | let _x: &dyn = &0;
| ^^^
The error message here implies that at least one trait that is not an auto trait (Send/Sync) has to be specified. However, &dyn Send is accepted, and &Send has worked since 1.0.0, so the message is clearly wrong. Should be pretty easy to fix in the code below:
|
if regular_traits.is_empty() && auto_traits.is_empty() { |
|
span_err!(tcx.sess, span, E0224, |
|
"at least one non-builtin trait is required for an object type"); |
|
return tcx.types.err; |
|
} |
When creating an empty trait object using the
dynsyntax, the error message is misleading. Example:This is rejected, with this message:
The error message here implies that at least one trait that is not an auto trait (
Send/Sync) has to be specified. However,&dyn Sendis accepted, and&Sendhas worked since 1.0.0, so the message is clearly wrong. Should be pretty easy to fix in the code below:rust/src/librustc_typeck/astconv.rs
Lines 1247 to 1251 in c8865d8