Skip to content

fix: Correctly goto From impl when on into() even when the call is inside a macro #20382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions crates/ide/src/goto_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ pub(crate) fn goto_definition(
return Some(RangeInfo::new(original_token.text_range(), navs));
}

if let Some(navs) = find_definition_for_known_blanket_dual_impls(sema, &original_token) {
return Some(RangeInfo::new(original_token.text_range(), navs));
}

let navs = sema
.descend_into_macros_no_opaque(original_token.clone(), false)
.into_iter()
.filter_map(|token| {
if let Some(navs) = find_definition_for_known_blanket_dual_impls(sema, &token.value) {
return Some(navs);
}

let parent = token.value.parent()?;

let token_file_id = token.file_id;
Expand Down Expand Up @@ -3275,6 +3275,32 @@ impl From<A> for B {
}
}

fn f() {
let a = A;
let b: B = a.into$0();
}
"#,
);
}

#[test]
fn into_call_to_from_definition_within_macro() {
check(
r#"
//- proc_macros: identity
//- minicore: from
struct A;

struct B;

impl From<A> for B {
fn from(value: A) -> Self {
//^^^^
B
}
}

#[proc_macros::identity]
fn f() {
let a = A;
let b: B = a.into$0();
Expand Down
Loading