Created
May 23, 2025 12:56
-
-
Save tyilo/45335858301a40e92e203058bd281fc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::marker::PhantomData; | |
#[allow(non_snake_case)] | |
struct A<'A, A = ()>(PhantomData<&'A A>); | |
macro_rules! A { | |
() => { | |
PhantomData | |
}; | |
} | |
#[allow(non_snake_case)] | |
#[allow(clippy::extra_unused_lifetimes)] | |
pub fn f<'A>() { | |
'A: { | |
// All 5 A's are in different namespaces. | |
// See https://doc.rust-lang.org/reference/names/namespaces.html | |
// In order: | |
// - `A - label namespace | |
// - A - type namespace | |
// - 'A - lifetime namespace | |
// - A - value namespace | |
// - A! - macro namespace | |
// All 5 namespaces | |
break 'A A::<'A, A>(A!()); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment