-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add error explanation for E0038 #26163
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@@ -284,6 +284,30 @@ This error indicates that an attempt was made to divide by zero (or take the | |||
remainder of a zero divisor) in a static or constant expression. | |||
"##, | |||
|
|||
E0038: r##" | |||
This trait is not object safe, but the coercion of an implementation to a trait |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is perhaps a nitpick, but technically there are two ways to get a trait object value: casting and coercion. Instead of saying "coercion", it might be better to be vague here, something like "It is not allowed to create a trait object value for a trait that is not object safe"
Do you think it'd be useful to link to RFC 255 here? That RFC is a bit technical, but it does discuss the object safety rules in detail. |
@nham, Thanks for that; I've added both suggestions. While yes, RFC 255 is a bit technical, it is (with my 'user' hat on) reasonably clear to understand, and there is a precedent for pointing to an RFC for more details. |
@bors: r+ 7578947982b656053ced7891068bd8a6a3a66058 Thanks! |
⌛ Testing commit 7578947 with merge 4133fde... |
💔 Test failed - auto-mac-64-opt |
(Just made a few minor suggestions for improvement; the current text is also good. And the link to the RFC mitigates some of my concerns about details, I guess.) |
@nikomatsakis: I think what I was trying to say there was how
as an explanation (inspired by huonw's description of (Also, do I prefer With regards to the rationale for (e.g.) restricting generic type parameters to create the vtable, duplicates detail from The Book, or RFC 255, and IMHO is a bit beyond the scope of |
Additionally, the build failure on
---appears to be entirely because of the RFC URL. Any suggestions about how to make that be a non-issue? (edit: see rust-lang/prev.rust-lang.org#147) |
@jashank: I'll tweak the lint so that it allows URLs to go over the 80 character line limit. |
The plugin that enforces error explanation line-length is a bit restrictive, particularly when attempting to use URLs in explanations (cf #26163). Jashank will still have to do some mucking around with `#[cfg(not(stage0))]` attributes or else wait until a snapshot with this commit lands.
@jashank sounds good to me! |
☔ The latest upstream changes (presumably #26649) made this pull request unmergeable. Please resolve the merge conflicts. |
... do I have any regrets after rebasing and updating this? (Also, still blocked by the as-yet-unlanded-in-a-snapshot #26290.) |
@@ -1089,6 +1116,8 @@ register_diagnostics! { | |||
E0017, | |||
E0022, | |||
E0038, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I comment here again: this line should be removed.
Ooops, sorry about that, @GuillaumeGomez. Rebasing again. As for the Markdown, all of |
I use |
cc @Manishearth |
☔ The latest upstream changes (presumably #26770) made this pull request unmergeable. Please resolve the merge conflicts. |
Rebasing, and hopefully I haven't completely screwed up this time. (I wonder if 26290 has landed yet, which would make this safe to merge.) |
You just have to squash now I guess. |
There's no new snapshot but there is a workaround - you can register a single error with // Some error that the stage0 compiler doesn't like (E0038 for now)
#[cfg(stage0)]
register_diagnostic! { E0038 }
#[cfg(not(stage0))]
register_diagnostic! { E0038, r##"
Blah blah blah
"##
} |
In terms of bootstrapping, this is fine, as it only excludes the error from the |
I'd like to have added examples for each case but the overall error explanation started getting uncomfortably long. Instead, I've lifted and rewritten notes from src/librustc/middle/traits/object_safety.rs to be (somewhat) clearer. Various suggestions for the wording came from @nham and @nikomatsakis. cc #24407
I'm happy to wait for a new snapshot to land, because this isn't exactly a big change, and this is one less thing for the next snapshot wrangler to fix. (Also, apparently, there's a new snapshot coming Real Soon Now.) Squashing this down to one commit, then Waiting for Snapshot. |
I wrote a more comprehensive version of this: #26963 Sorry for taking your PR over, let me know if there's something from here I should pick up :) |
Nope, I don't see anything that hasn't been covered. Closing in favour of #26963. |
I'd like to have added examples for each case but the overall error explanation started getting uncomfortably long. Instead, I've lifted and rewritten notes from
src/librustc/middle/traits/object_safety.rs
to be (somewhat) clearer.Personally, I feel this should become five separate error codes for each
ObjectSafetyViolation
case, also countingMethodViolationCode
s.cc #24407