diff options
Diffstat (limited to 'crates/ide/src/goto_definition.rs')
-rw-r--r-- | crates/ide/src/goto_definition.rs | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs index ca8ccb2da..a04333e63 100644 --- a/crates/ide/src/goto_definition.rs +++ b/crates/ide/src/goto_definition.rs | |||
@@ -110,6 +110,13 @@ mod tests { | |||
110 | assert_eq!(expected, FileRange { file_id: nav.file_id, range: nav.focus_or_full_range() }); | 110 | assert_eq!(expected, FileRange { file_id: nav.file_id, range: nav.focus_or_full_range() }); |
111 | } | 111 | } |
112 | 112 | ||
113 | fn check_unresolved(ra_fixture: &str) { | ||
114 | let (analysis, position) = fixture::position(ra_fixture); | ||
115 | let navs = analysis.goto_definition(position).unwrap().expect("no definition found").info; | ||
116 | |||
117 | assert!(navs.is_empty(), "didn't expect this to resolve anywhere: {:?}", navs) | ||
118 | } | ||
119 | |||
113 | #[test] | 120 | #[test] |
114 | fn goto_def_for_extern_crate() { | 121 | fn goto_def_for_extern_crate() { |
115 | check( | 122 | check( |
@@ -927,17 +934,12 @@ fn f() -> impl Iterator<Item$0 = u8> {} | |||
927 | } | 934 | } |
928 | 935 | ||
929 | #[test] | 936 | #[test] |
930 | #[should_panic = "unresolved reference"] | ||
931 | fn unknown_assoc_ty() { | 937 | fn unknown_assoc_ty() { |
932 | check( | 938 | check_unresolved( |
933 | r#" | 939 | r#" |
934 | trait Iterator { | 940 | trait Iterator { type Item; } |
935 | type Item; | ||
936 | //^^^^ | ||
937 | } | ||
938 | |||
939 | fn f() -> impl Iterator<Invalid$0 = u8> {} | 941 | fn f() -> impl Iterator<Invalid$0 = u8> {} |
940 | "#, | 942 | "#, |
941 | ) | 943 | ) |
942 | } | 944 | } |
943 | 945 | ||
@@ -1188,4 +1190,30 @@ pub fn gimme() -> theitem::TheItem { | |||
1188 | "#, | 1190 | "#, |
1189 | ); | 1191 | ); |
1190 | } | 1192 | } |
1193 | |||
1194 | #[test] | ||
1195 | fn goto_ident_from_pat_macro() { | ||
1196 | check( | ||
1197 | r#" | ||
1198 | macro_rules! pat { | ||
1199 | ($name:ident) => { Enum::Variant1($name) } | ||
1200 | } | ||
1201 | |||
1202 | enum Enum { | ||
1203 | Variant1(u8), | ||
1204 | Variant2, | ||
1205 | } | ||
1206 | |||
1207 | fn f(e: Enum) { | ||
1208 | match e { | ||
1209 | pat!(bind) => { | ||
1210 | //^^^^ | ||
1211 | bind$0 | ||
1212 | } | ||
1213 | Enum::Variant2 => {} | ||
1214 | } | ||
1215 | } | ||
1216 | "#, | ||
1217 | ); | ||
1218 | } | ||
1191 | } | 1219 | } |