Skip to content

Lifetimes are not hygenic #55744

Closed
Closed
@RalfJung

Description

@RalfJung

I would expect the following to not compile (Playground):

trait Trait {}

macro_rules! impl_trait_for {
    ($name:path) => { impl<'tcx> Trait for $name {} }
}

impl_trait_for!(Option<i32>);
impl_trait_for!(Option<&'tcx i32>);

The lifetime 'tcx is bound in the macro, and used in a macro argument. This violates hygiene.

I am sure this has already been reported but I cannot find an issue that matches...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions