Skip to content

Jump from into to from definitions from within methods with macro atributes #20377

@rafamerlin

Description

@rafamerlin

This PR made jumping into the proper definition of a from method when from the into() which made things much much easier.

I'm working in a project where I'm using a lot of #[Instrument] attributes in most my functions to have it working with opentelemetry/application insights.

There I noticed that if the method has a macro attribute it won't find the proper From declaration, I'm not sure if this would be an easy fix but I'm just raising this, raising it as a feature as I'm not sure if it can be considered a bug or not.

Here's an code example:

pub struct Test {
    pub test: String,
}

impl From<String> for Test {
    fn from(value: String) -> Self {
        Self {
            test: value.clone(),
        }
    }
}

#[tokio::main]
async fn main() {
    //Any function that has an atribute macro won't find the From on the .into(), this one goes to the Std definition o Into
    let test: Test = "test".to_string().into(); 
}

fn test() {
    //This goes to the from on this file properly
    let test: Test = "test".to_string().into();
}

async fn test_async() {
    //This goes to the from on this file properly
    let test: Test = "test".to_string().into();
}

Metadata

Metadata

Labels

C-featureCategory: feature request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions