Detect different borrowing in different sub-expressions the same expression and suggest borrowing when applicable
Open
Nobody has claimed this yet.
A-diagnostics
D-lack-of-suggestion
P-low
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
error[E0308]: mismatched types
--> compiler/rustc_middle/src/ty/context.rs:3212:73
|
3210 | match expr.kind {
| --------- this expression has type `rustc_hir::ExprKind<'_>`
3211 | hir::ExprKind::Path(qpath)
| ----- first introduced with type `rustc_hir::QPath<'_>` here
3212 | | hir::ExprKind::Call(hir::Expr { kind: hir::ExprKind::Path(qpath), .. }, []) => {
| ^^^^^ expected `QPath<'_>`, found `&QPath<'_>`
|
= note: in the same arm, a binding must have the same type in all alternatives
The above should suggest match &expr.kind.
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 at compiler/rustc_middle/src/ty/context.rs:3212 and inspect the match over expr.kind shown in the E0308 report. Use the reported example to verify the completed behavior: the compiler suggests matching on &expr.kind when alternatives bind different borrowing levels.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100