Skip to content

Commit 090a38c

Browse files
committed
Auto merge of rust-lang#18028 - Veykril:lifetime-hints-panic, r=Veykril
fix: lifetime hint panic in non generic defs
2 parents 86c6382 + 011a1fc commit 090a38c

File tree

1 file changed

+19
-1
lines changed
  • src/tools/rust-analyzer/crates/ide/src/inlay_hints

1 file changed

+19
-1
lines changed

src/tools/rust-analyzer/crates/ide/src/inlay_hints/lifetime.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,9 @@ fn hints_(
389389
}
390390
(None, allocated_lifetimes) => on_missing_gpl(acc, allocated_lifetimes),
391391
}
392-
ctx.lifetime_stacks.last_mut().unwrap().extend(allocated_lifetimes);
392+
if let Some(stack) = ctx.lifetime_stacks.last_mut() {
393+
stack.extend(allocated_lifetimes);
394+
}
393395
Some(())
394396
}
395397

@@ -542,6 +544,22 @@ fn fn_trait(a: &impl Fn(&()) -> &()) {}
542544
// ^^ for<'1>
543545
//^'1
544546
// ^'1
547+
"#,
548+
);
549+
}
550+
551+
#[test]
552+
fn hints_in_non_gen_defs() {
553+
check_with_config(
554+
InlayHintsConfig {
555+
lifetime_elision_hints: LifetimeElisionHints::Always,
556+
..TEST_CONFIG
557+
},
558+
r#"
559+
const _: fn(&()) -> &();
560+
//^^ for<'0>
561+
//^'0
562+
//^'0
545563
"#,
546564
);
547565
}

0 commit comments

Comments
 (0)