rust-lang / rust-lang/rust-analyzer
`return` statements in inlined functions just get moved over and try to return out of the outer function + generic types are discarded
Open
Nobody has claimed this yet.
A-assists
C-bug
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
title,
code example
fn none<T>() -> Option<T> {
return None;
}
pub fn main() {
let a = none::<u32>();
}
- inlining the
nonefunction replaces it withlet a = { return None; };, which tries to returnNoneinmain - the generic type param
Tofnonewas first known to beu32, to preserve this information (and not end up with "type annotations needed forOption<T>")let a = None::<u32>;would work
rust-analyzer version: 0.4.1625-standalone
rustc version: rustc 1.71.1 (eb26296b5 2023-08-03)
relevant settings: none
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 reported Rust example with rust-analyzer's function-inlining feature. Trace the inlining implementation and its existing tests, if present; done means an inlined return remains valid within the replacement expression and the known generic type is preserved without a type-inference error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100