checked_add() can't infer type from its argument
Open
Nobody has claimed this yet.
needs-triage
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
fn main() {
let mut n = Some(0);
match n {
Some(s) => n = s.checked_add(1u8),
None => println!("None"),
}
}
Compiler can't infer type for n. Although (1u8) specifies type u8, but compiler can't infer type from (1u8).
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
Start by compiling the minimal Rust example in the issue and inspecting the type-inference diagnostic. Trace the compiler's handling of the checked_add call and the u8 argument; done when the example infers n's type consistently with the argument and the relevant compiler tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100