mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Auto merge of #18028 - Veykril:lifetime-hints-panic, r=Veykril
fix: lifetime hint panic in non generic defs
This commit is contained in:
commit
5461f494e6
1 changed files with 19 additions and 1 deletions
|
@ -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(())
|
||||
}
|
||||
|
||||
|
@ -542,6 +544,22 @@ fn fn_trait(a: &impl Fn(&()) -> &()) {}
|
|||
// ^^ for<'1>
|
||||
//^'1
|
||||
// ^'1
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[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
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue