-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix adt_const_params
leaking {type error}
in error msg
#131038
Conversation
r? @wesleywiser rustbot has assigned @wesleywiser. Use |
This comment has been minimized.
This comment has been minimized.
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.
Please also squash this into one commit.
4756b2f
to
081a8a8
Compare
if ty.references_error() { | ||
return Ok(()); | ||
} |
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.
Actually, this should just return Err(ErrorGuaranteed)
here, rather than Ok(())
, I think.
You can use the alternative error_reported
function which is like references_error
, but returns a Result<(), ErrorGuaranteed>
for ease of ?
operator:
if ty.references_error() { | |
return Ok(()); | |
} | |
ty.error_reported()?; |
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.
That makes sense! I guess it kinda depends on if we're checking if the parameters are well-formed, or if it's all well-formed... while checking the const parameters.
Tests don't seem to mind either way, and there are no docs for any of these methods, so I'll go with this. 😄
(by the way, is there any reason behind the lack of docs on most rustc
modules/items? would well-researched docs be appreciated?)
avoid `{type error}` being leaked in user-facing messages, particularly when using the `adt_const_params` feature
081a8a8
to
c5598d6
Compare
@bors r+ rollup |
}; | ||
|
||
diag.note("the only supported types are integers, `bool` and `char`"); | ||
diag.note("the only supported types are integers, `bool`, and `char`"); |
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.
comma before and
looks wrong to me.
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.
It's called the oxford comma.
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.
Hmm, okay, looking at *.stderr there used both cases with and w\o comma with enumerations.
One more wtf styling case. Probably exist somewhere in rust style guide for errors.
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.
Found only 2 mentions: rust-lang/rustc-dev-guide#1087 (comment), rust-lang/rustc-dev-guide#1139 (comment); should be added to the guide?
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#131023 (Copy correct path to clipboard for modules/keywords/primitives) - rust-lang#131035 (Preserve brackets around if-lets and skip while-lets) - rust-lang#131038 (Fix `adt_const_params` leaking `{type error}` in error msg) - rust-lang#131053 (Improve `--print=check-cfg` documentation) - rust-lang#131056 (enable compiler fingerprint logs in verbose mode) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#131038 - onkoe:fix/adt_const_params_leak_118179, r=compiler-errors Fix `adt_const_params` leaking `{type error}` in error msg Fixes the confusing diagnostic described in rust-lang#118179. (users would see `{type error}` in some situations, which is pretty weird) `adt_const_params` tracking issue: rust-lang#95174
we encountered this in rust-lang/rust#131038 kinda felt like an unspoken rule so here's a more concrete clarification.
we encountered this in rust-lang/rust#131038 kinda felt like an unspoken rule so here's a more concrete clarification.
Fixes the confusing diagnostic described in #118179. (users would see
{type error}
in some situations, which is pretty weird)Fixes #118179.
adt_const_params
tracking issue: #95174