diff options
| author | bors <bors@rust-lang.org> | 2024-09-02 16:05:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-02 16:05:36 +0000 |
| commit | 090a38cd94487d1808e1232b1d736047feb11d8d (patch) | |
| tree | 176094e3703f395d2c70822b8d6bc3541a25ee00 | |
| parent | 86c6382a5384acfeac5574ec2527137ad4d5f2e2 (diff) | |
| parent | 011a1fc41f22a2b07062bb8b94656dd3acc756fa (diff) | |
| download | rust-090a38cd94487d1808e1232b1d736047feb11d8d.tar.gz rust-090a38cd94487d1808e1232b1d736047feb11d8d.zip | |
Auto merge of #18028 - Veykril:lifetime-hints-panic, r=Veykril
fix: lifetime hint panic in non generic defs
| -rw-r--r-- | src/tools/rust-analyzer/crates/ide/src/inlay_hints/lifetime.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/lifetime.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/lifetime.rs index 653e3a6ef1d..2163c959b18 100644 --- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/lifetime.rs +++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/lifetime.rs @@ -389,7 +389,9 @@ fn hints_( } (None, allocated_lifetimes) => on_missing_gpl(acc, allocated_lifetimes), } - ctx.lifetime_stacks.last_mut().unwrap().extend(allocated_lifetimes); + if let Some(stack) = ctx.lifetime_stacks.last_mut() { + stack.extend(allocated_lifetimes); + } Some(()) } @@ -545,4 +547,20 @@ fn fn_trait(a: &impl Fn(&()) -> &()) {} "#, ); } + + #[test] + fn hints_in_non_gen_defs() { + check_with_config( + InlayHintsConfig { + lifetime_elision_hints: LifetimeElisionHints::Always, + ..TEST_CONFIG + }, + r#" +const _: fn(&()) -> &(); + //^^ for<'0> + //^'0 + //^'0 +"#, + ); + } } |
