Go to declaration goes to field declaration in pattern and expression shorthands
This commit is contained in:
parent
3c794a34da
commit
ae0bdffcc9
@ -36,11 +36,11 @@ pub(crate) fn goto_declaration(
|
|||||||
match parent {
|
match parent {
|
||||||
ast::NameRef(name_ref) => match NameRefClass::classify(&sema, &name_ref)? {
|
ast::NameRef(name_ref) => match NameRefClass::classify(&sema, &name_ref)? {
|
||||||
NameRefClass::Definition(it) => Some(it),
|
NameRefClass::Definition(it) => Some(it),
|
||||||
_ => None
|
NameRefClass::FieldShorthand { field_ref, .. } => return field_ref.try_to_nav(db),
|
||||||
},
|
},
|
||||||
ast::Name(name) => match NameClass::classify(&sema, &name)? {
|
ast::Name(name) => match NameClass::classify(&sema, &name)? {
|
||||||
NameClass::Definition(it) => Some(it),
|
NameClass::Definition(it) | NameClass::ConstReference(it) => Some(it),
|
||||||
_ => None
|
NameClass::PatFieldShorthand { field_ref, .. } => return field_ref.try_to_nav(db),
|
||||||
},
|
},
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
@ -180,6 +180,33 @@ trait Trait {
|
|||||||
impl Trait for () {
|
impl Trait for () {
|
||||||
const C$0: () = ();
|
const C$0: () = ();
|
||||||
}
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn goto_decl_field_pat_shorthand() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
struct Foo { field: u32 }
|
||||||
|
//^^^^^
|
||||||
|
fn main() {
|
||||||
|
let Foo { field$0 };
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn goto_decl_constructor_shorthand() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
struct Foo { field: u32 }
|
||||||
|
//^^^^^
|
||||||
|
fn main() {
|
||||||
|
let field = 0;
|
||||||
|
Foo { field$0 };
|
||||||
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user