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

Add 'consider using' message to overflowing_literals #79981

Merged
merged 2 commits into from
Feb 17, 2021

Conversation

camelid
Copy link
Member

@camelid camelid commented Dec 12, 2020

Fixes #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

@camelid camelid added A-diagnostics Area: Messages for errors, warnings, and lints A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. labels Dec 12, 2020
@rust-highfive
Copy link
Collaborator

r? @lcnr

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 12, 2020
@camelid camelid added the A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. label Dec 12, 2020
@camelid
Copy link
Member Author

camelid commented Dec 12, 2020

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 :)
@camelid camelid force-pushed the overflowing_literals-inference-error branch from 9712401 to d00ca11 Compare December 12, 2020 23:00
Copy link
Contributor

@lcnr lcnr left a 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

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));
Copy link
Contributor

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

Suggested change
err.help(&format!("consider using `{}` instead", sugg_ty));
err.help(&format!("consider changing its type to `{}`", sugg_ty));

Copy link
Member Author

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.

Copy link
Contributor

@lcnr lcnr Dec 15, 2020

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about

Suggested change
err.help(&format!("consider using `{}` instead", sugg_ty));
err.help(&format!("consider using the `{}` type instead", sugg_ty));

or something like that?

Copy link
Contributor

@lcnr lcnr Jan 25, 2021

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

Suggested change
err.help(&format!("consider using `{}` instead", sugg_ty));
err.help(&format!("consider using the type `{}` instead", sugg_ty));

Copy link
Member Author

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.

@camelid camelid added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 28, 2021
@camelid camelid removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 14, 2021
@camelid camelid marked this pull request as ready for review February 14, 2021 05:43
@lcnr
Copy link
Contributor

lcnr commented Feb 16, 2021

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 16, 2021

📌 Commit a9b16c6 has been approved by lcnr

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 16, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 16, 2021
…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`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 17, 2021
…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``
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 17, 2021
…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
@bors bors merged commit ec00784 into rust-lang:master Feb 17, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 17, 2021
@camelid camelid deleted the overflowing_literals-inference-error branch February 18, 2021 03:25
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 A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

overflowing_literals error is confusing because of type inference
5 participants