Skip to content

Commit

Permalink
Auto merge of #18028 - Veykril:lifetime-hints-panic, r=Veykril
Browse files Browse the repository at this point in the history
fix: lifetime hint panic in non generic defs
  • Loading branch information
bors committed Sep 2, 2024
2 parents 86c6382 + 011a1fc commit 090a38c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/tools/rust-analyzer/crates/ide/src/inlay_hints/lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down Expand Up @@ -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
"#,
);
}
Expand Down

0 comments on commit 090a38c

Please sign in to comment.