wherein we suggest float for integer literals where a float was expected#53283
Conversation
|
This is awesome! Thank you for doing this so fast! 😄 Will this code work if the integer literal has underscores in it? What about negative numbers? The full spec of integer literals is here: https://doc.rust-lang.org/reference/tokens.html#integer-literals My personal opinion is that you don't need to support all forms of integers, but we should at least support literals in the format Thanks again! This seems like a small thing, but I think it's a big quality of life improvement for people who are new to Rust! 😃 |
|
@zackmdavis Please add tests for all cases that @sunjay gave. 😆 |
Sunjay Varma pointed out that this is a nice thing that we could do. Resolves rust-lang#53280.
585793e to
58f660f
Compare
|
Updated and added UI test. |
estebank
left a comment
There was a problem hiding this comment.
Love the change.
r=me once travis is happy.
| db.note("no two closures, even if identical, have the same type"); | ||
| db.help("consider boxing your closure and/or using it as a trait object"); | ||
| } | ||
| match (&values.found.sty, &values.expected.sty) { // Issue #53280 |
There was a problem hiding this comment.
It's nice to provide a bit of context in the comments without the need to open a browser :)
As a rule, I add a one sentence long description of what the code is doing (or rather, why), with the issue number at the end for extra context.
There was a problem hiding this comment.
I agree that issue numbers are merely an extra reference for the curious software-archeologist and not a substitute for explanatory comments where explanatory comments are merited, but I feel like "use a float literal" is pretty self-explanatory? I do write explanatory comments where I think it necessary (recent examples: 1 2).
|
@bors r+ rollup |
|
📌 Commit 58f660f has been approved by |
…ation_device, r=estebank wherein we suggest float for integer literals where a float was expected @sunjay pointed out that this is a nice thing that we could do. Resolves rust-lang#53280. r? @estebank
Rollup of 15 pull requests Successful merges: - #52955 (Update compiler test documentation) - #53019 (Don't collect() when size_hint is useless) - #53025 (Consider changing assert! to debug_assert! when it calls visit_with) - #53059 (Remove explicit returns where unnecessary) - #53165 ( Add aarch64-unknown-netbsd target) - #53210 (Deny future duplication of rustc-ap-syntax) - #53223 (A few cleanups for rustc_data_structures) - #53230 ([nll] enable feature(nll) on various crates for bootstrap: part 4) - #53231 (Add let keyword doc) - #53240 (Add individual documentation for <integer>`.swap_bytes`/.`reverse_bits`) - #53253 (Remove unwanted console log) - #53264 (Show that Command can be reused and remodified) - #53267 (Fix styles) - #53273 (Add links to std::char::REPLACEMENT_CHARACTER from docs.) - #53283 (wherein we suggest float for integer literals where a float was expected) Failed merges: r? @ghost
@sunjay pointed out that this is a nice thing that we could do.
Resolves #53280.
r? @estebank