rust-lang / rust-lang/rust-analyzer
Type inference recovery can infer unsized locals
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Bit of a weird one and might be pointless to think about but in the following erroneous snippet
trait DynT {}
fn f(_: &dyn DynT) {}
fn main() {
let unresolved = unresolved;
f(&unresolved);
unresolved.foo();
}
we assign dyn DynT to unresolved. I feel like this is a bad recovery, since we can't have unsized locals, imo it would be better in this case to fallback to an error type? Interestingly enough if we assign an error type reference to unresolved we also fall back to the same type instead of assigning an error type to the local, probably because unification takes over still.
cc @ChayimFriedman2 idk if you have opinions on this, if you think this is fine as is feel free to close :)
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 reproducing the erroneous Rust snippet from the issue and tracing type inference recovery around the unresolved local, trait-object argument, and later method call. No source file or test is named; done means reaching an agreed recovery behavior and adding coverage for the demonstrated case.
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