-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add 'consider using' message to overflowing_literals #79981
Add 'consider using' message to overflowing_literals #79981
Conversation
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
Note that this doesn't produce a suggestion yet; that's next. |
Ironically, the overflowing_literals handler for binary or hex already had this message! You would think it would be the other way around :)
9712401
to
d00ca11
Compare
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.
Is there something I can do here rn? I don't think that a suggestion is strictly necessary and would be fine with landing it as is if you are also fine with doing so
compiler/rustc_lint/src/types.rs
Outdated
if let Some(sugg_ty) = | ||
get_type_suggestion(&cx.typeck_results().node_type(e.hir_id), v, negative) | ||
{ | ||
err.help(&format!("consider using `{}` instead", sugg_ty)); |
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.
"using i8
" sounds weird to me, maybe something like
err.help(&format!("consider using `{}` instead", sugg_ty)); | |
err.help(&format!("consider changing its type to `{}`", sugg_ty)); |
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 just copied-and-pasted this from the binary/hexadecimal error. If we change this one, we should probably change the other one too.
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, yeah I would prefer us to change this as well. Do you have a preference here?
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.
What about
err.help(&format!("consider using `{}` instead", sugg_ty)); | |
err.help(&format!("consider using the `{}` type instead", sugg_ty)); |
or something like that?
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.
somehow deleted my original message. edit: that seems fine to me ^^ though I would slightly adjust the wording here
err.help(&format!("consider using `{}` instead", sugg_ty)); | |
err.help(&format!("consider using the type `{}` instead", sugg_ty)); |
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.
There are things like:
ty::Char => FfiUnsafe {
ty,
reason: "the `char` type has no C equivalent".into(),
help: Some("consider using `u32` or `libc::wchar_t` instead".into()),
},
and
ty::Str => FfiUnsafe {
ty,
reason: "string slices have no C equivalent".into(),
help: Some("consider using `*const u8` and a length instead".into()),
},
but those are for a different error so leaving them be.
@bors r+ rollup |
📌 Commit a9b16c6 has been approved by |
…nce-error, r=lcnr Add 'consider using' message to overflowing_literals Fixes rust-lang#79744. Ironically, the `overflowing_literals` handler for binary or hex already had this message! You would think it would be the other way around :) cc `@scottmcm`
…nce-error, r=lcnr Add 'consider using' message to overflowing_literals Fixes rust-lang#79744. Ironically, the `overflowing_literals` handler for binary or hex already had this message! You would think it would be the other way around :) cc ``@scottmcm``
…laumeGomez Rollup of 11 pull requests Successful merges: - rust-lang#79981 (Add 'consider using' message to overflowing_literals) - rust-lang#82094 (To digit simplification) - rust-lang#82105 (Don't fail to remove files if they are missing) - rust-lang#82136 (Fix ICE: Use delay_span_bug for mismatched subst/hir arg) - rust-lang#82169 (Document that `assert!` format arguments are evaluated lazily) - rust-lang#82174 (Replace File::create and write_all with fs::write) - rust-lang#82196 (Add caveat to Path::display() about lossiness) - rust-lang#82198 (Use internal iteration in Iterator::is_sorted_by) - rust-lang#82204 (Update books) - rust-lang#82207 (rustdoc: treat edition 2021 as unstable) - rust-lang#82231 (Add long explanation for E0543) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #79744.
Ironically, the
overflowing_literals
handler for binary or hex alreadyhad this message! You would think it would be the other way around :)
cc @scottmcm