diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-01-12 11:33:31 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-12 11:33:31 +0000 |
commit | 8bb2a50ce6adda4d3d8dfb66cd67d302ec108d45 (patch) | |
tree | f856e09f543a391916907fd9a19257924eb2bfaf /crates/ra_ide | |
parent | 21be386db8e8019d25c2529313d0371f91a15cb3 (diff) | |
parent | db5f73d261413f03e4e3a4a374f8306fe8ae5578 (diff) |
Merge #2807
2807: Use attr location for builtin derive in goto-implementation r=matklad a=edwin0cheng
This PR is use attribute location for builtin derive in `ImplBlock`'s NavigationTarget such that the goto-implementation will goto to a correct position.
Related to #2531
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/src/display/navigation_target.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide/src/impls.rs | 12 |
2 files changed, 17 insertions, 1 deletions
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index f2e45fa31..b2af3479c 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs | |||
@@ -251,7 +251,11 @@ impl ToNav for hir::Module { | |||
251 | impl ToNav for hir::ImplBlock { | 251 | impl ToNav for hir::ImplBlock { |
252 | fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { | 252 | fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { |
253 | let src = self.source(db); | 253 | let src = self.source(db); |
254 | let frange = original_range(db, src.as_ref().map(|it| it.syntax())); | 254 | let frange = if let Some(item) = self.is_builtin_derive(db) { |
255 | original_range(db, item.syntax()) | ||
256 | } else { | ||
257 | original_range(db, src.as_ref().map(|it| it.syntax())) | ||
258 | }; | ||
255 | 259 | ||
256 | NavigationTarget::from_syntax( | 260 | NavigationTarget::from_syntax( |
257 | frange.file_id, | 261 | frange.file_id, |
diff --git a/crates/ra_ide/src/impls.rs b/crates/ra_ide/src/impls.rs index 9b165ee2a..31195036e 100644 --- a/crates/ra_ide/src/impls.rs +++ b/crates/ra_ide/src/impls.rs | |||
@@ -203,4 +203,16 @@ mod tests { | |||
203 | ], | 203 | ], |
204 | ); | 204 | ); |
205 | } | 205 | } |
206 | |||
207 | #[test] | ||
208 | fn goto_implementation_to_builtin_derive() { | ||
209 | check_goto( | ||
210 | " | ||
211 | //- /lib.rs | ||
212 | #[derive(Copy)] | ||
213 | struct Foo<|>; | ||
214 | ", | ||
215 | &["impl IMPL_BLOCK FileId(1) [0; 15)"], | ||
216 | ); | ||
217 | } | ||
206 | } | 218 | } |