Skip to content

Improve node upmapping into macro inputs #16235

Closed
@Veykril

Description

@Veykril

Noticed in #16229

Taking async-trait as an example, given:

#[async_trait]
trait Advertisement {
    async fn run(&self);
}

fn f<T: Advertisement>(t: T) {
    t.run()
}

and the expansion of the attribute as:

trait Advertisement {
    #[must_use]
    #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)]
    fn run<'life0, 'async_trait>(
        &'life0 self,
    ) -> ::core::pin::Pin<
        Box<dyn ::core::future::Future<Output = ()> + ::core::marker::Send + 'async_trait>,
    >
    where
        'life0: 'async_trait,
        Self: 'async_trait;
}

When we are trying to upmap the run function node from the expansion, we will fail due to all the new tokens that have been added that have varying spans and more importantly a differing syntax context from the input name (differing syntax context is an immediate bail currently). Ideally we'd still map the signature out of this, the question is how.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions