This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +30
-3
lines changed Expand file tree Collapse file tree 1 file changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,11 @@ pub(crate) fn goto_declaration(
3636 match parent {
3737 ast:: NameRef ( name_ref) => match NameRefClass :: classify( & sema, & name_ref) ? {
3838 NameRefClass :: Definition ( it) => Some ( it) ,
39- _ => None
39+ NameRefClass :: FieldShorthand { field_ref , .. } => return field_ref . try_to_nav ( db ) ,
4040 } ,
4141 ast:: Name ( name) => match NameClass :: classify( & sema, & name) ? {
42- NameClass :: Definition ( it) => Some ( it) ,
43- _ => None
42+ NameClass :: Definition ( it) | NameClass :: ConstReference ( it ) => Some ( it) ,
43+ NameClass :: PatFieldShorthand { field_ref , .. } => return field_ref . try_to_nav ( db ) ,
4444 } ,
4545 _ => None
4646 }
@@ -180,6 +180,33 @@ trait Trait {
180180impl Trait for () {
181181 const C$0: () = ();
182182}
183+ "# ,
184+ ) ;
185+ }
186+
187+ #[ test]
188+ fn goto_decl_field_pat_shorthand ( ) {
189+ check (
190+ r#"
191+ struct Foo { field: u32 }
192+ //^^^^^
193+ fn main() {
194+ let Foo { field$0 };
195+ }
196+ "# ,
197+ ) ;
198+ }
199+
200+ #[ test]
201+ fn goto_decl_constructor_shorthand ( ) {
202+ check (
203+ r#"
204+ struct Foo { field: u32 }
205+ //^^^^^
206+ fn main() {
207+ let field = 0;
208+ Foo { field$0 };
209+ }
183210"# ,
184211 ) ;
185212 }
You can’t perform that action at this time.
0 commit comments