mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-03 02:23:20 +00:00
Add goto def for enum variant field
This commit is contained in:
parent
d4a92b4fef
commit
73684a4ae2
@ -886,4 +886,23 @@ mod tests {
|
||||
"x",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn goto_def_for_enum_variant_field() {
|
||||
check_goto(
|
||||
"
|
||||
//- /lib.rs
|
||||
enum Foo {
|
||||
Bar { x: i32 }
|
||||
}
|
||||
fn baz(foo: Foo) {
|
||||
match foo {
|
||||
Foo::Bar { x<|> } => x
|
||||
};
|
||||
}
|
||||
",
|
||||
"x RECORD_FIELD_DEF FileId(1) 21..27 21..22",
|
||||
"x: i32|x",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -126,6 +126,12 @@ fn classify_name_inner(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Opti
|
||||
Some(name_ref_class.definition())
|
||||
},
|
||||
ast::BindPat(it) => {
|
||||
if let Some(record_field_pat) = it.syntax().parent().and_then(ast::RecordFieldPat::cast) {
|
||||
return Some(Definition::Field(
|
||||
sema.resolve_record_field_pat(&record_field_pat)?
|
||||
));
|
||||
}
|
||||
|
||||
let local = sema.to_def(&it)?;
|
||||
Some(Definition::Local(local))
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user