Skip to content

Commit 4c8fb89

Browse files
authored
Merge pull request #20382 from ChayimFriedman2/goto-def-from-macro
fix: Correctly goto `From` impl when on `into()` even when the call is inside a macro
2 parents 8d75311 + 1a6f7c2 commit 4c8fb89

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

crates/ide/src/goto_definition.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ pub(crate) fn goto_definition(
8383
return Some(RangeInfo::new(original_token.text_range(), navs));
8484
}
8585

86-
if let Some(navs) = find_definition_for_known_blanket_dual_impls(sema, &original_token) {
87-
return Some(RangeInfo::new(original_token.text_range(), navs));
88-
}
89-
9086
let navs = sema
9187
.descend_into_macros_no_opaque(original_token.clone(), false)
9288
.into_iter()
9389
.filter_map(|token| {
90+
if let Some(navs) = find_definition_for_known_blanket_dual_impls(sema, &token.value) {
91+
return Some(navs);
92+
}
93+
9494
let parent = token.value.parent()?;
9595

9696
let token_file_id = token.file_id;
@@ -3275,6 +3275,32 @@ impl From<A> for B {
32753275
}
32763276
}
32773277
3278+
fn f() {
3279+
let a = A;
3280+
let b: B = a.into$0();
3281+
}
3282+
"#,
3283+
);
3284+
}
3285+
3286+
#[test]
3287+
fn into_call_to_from_definition_within_macro() {
3288+
check(
3289+
r#"
3290+
//- proc_macros: identity
3291+
//- minicore: from
3292+
struct A;
3293+
3294+
struct B;
3295+
3296+
impl From<A> for B {
3297+
fn from(value: A) -> Self {
3298+
//^^^^
3299+
B
3300+
}
3301+
}
3302+
3303+
#[proc_macros::identity]
32783304
fn f() {
32793305
let a = A;
32803306
let b: B = a.into$0();

0 commit comments

Comments
 (0)