Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect error message for empty object types #61634

Closed
jonas-schievink opened this issue Jun 7, 2019 · 2 comments · Fixed by #61681
Closed

Incorrect error message for empty object types #61634

jonas-schievink opened this issue Jun 7, 2019 · 2 comments · Fixed by #61681
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jonas-schievink
Copy link
Contributor

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;
}

@jonas-schievink jonas-schievink added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-help-wanted Call for participation: Help is requested to fix this issue. C-bug Category: This is a bug. labels Jun 7, 2019
Centril added a commit to Centril/rust that referenced this issue Jun 21, 2019
Changed the error message to more clearly explain what is allowed

This is in regard to rust-lang#61634. I changed the language to make it more clear what is allowed.
Centril added a commit to Centril/rust that referenced this issue Jun 21, 2019
Changed the error message to more clearly explain what is allowed

This is in regard to rust-lang#61634. I changed the language to make it more clear what is allowed.
@bjorn3
Copy link
Member

bjorn3 commented Jun 22, 2019

#61681 has been merged.

@jonas-schievink
Copy link
Contributor Author

Closing as fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants