Lint on (nearly) all `{integer}`/`{float}` fallback
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Note: this is currently at the phase of a lang vibe check, not an approved proposal. I personally currently think I like it, but if you're interested in working on it beware that the answer might end up being "no, we don't want a lint for that".
The integer fallback to i32 and float fallback to f64 is very important for beginner friendliness. We absolutely want a simple thing like
println!("{}", 123.456);
or
for x in 0..10 {
println!("{}", x);
}
to compile, because we don't want to add extra friction to the "my first rust program" examples.
That said, it's not obvious that fallback is what you want in "real" code, and you'd much prefer it be unified to something the vast majority of the time. Like for i in 0..10 { a[i] = 0; } ends up constrained by the indexing, and similar. And any time something is derived from an argument or returned that unifies the integer/float type as well.
See for example #139087 where there's no type to unify with, just a trait bound, and not having the type annotation causes evolution problems.
We'll probably find some examples where it turns out that we need to allow it -- maybe x << 4 for example will need to continue to allow fallback, for example, since it's a heterogeneous RHS -- but what would people think about this general direction?
(It feels like at very least it should exist for the "I'm a popular crate who really wants to make sure I'm not broken by updates to things" group we keep talking about.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or compiler entry points are named. Begin by reviewing the fallback examples and the discussion in #139087, then determine whether a general lint is wanted and which cases must remain allowed; the issue has no settled acceptance criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100