Skip to content

Commit 7df7db5

Browse files
committed
fix: navigate to label directly when perform 'goto-def' on control-flow kw
See rust-lang/rust-analyzer#17542 (comment)
1 parent 7a14800 commit 7df7db5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/tools/rust-analyzer/crates/ide/src/goto_definition.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ fn try_find_loop(
351351
if blk.label().is_some() && label_matches(blk.label()) =>
352352
{
353353
let expr = ast::Expr::BlockExpr(blk.clone());
354-
let lbl_tok = blk.label().unwrap().lifetime()?.lifetime_ident_token()?.into();
355-
let nav = NavigationTarget::from_expr(db, InFile::new(file_id, expr), lbl_tok);
354+
let lbl = blk.label().unwrap().syntax().clone().into();
355+
let nav = NavigationTarget::from_expr(db, InFile::new(file_id, expr), lbl);
356356
return Some(nav);
357357
}
358358
_ => {}
@@ -2618,7 +2618,7 @@ fn main() {
26182618
r#"
26192619
fn main() {
26202620
'a:{
2621-
// ^^
2621+
// ^^^
26222622
break$0 'a;
26232623
}
26242624
}

0 commit comments

Comments
 (0)