Skip to content

Instantly share code, notes, and snippets.

@tyilo
Created May 23, 2025 12:56
Show Gist options
  • Save tyilo/45335858301a40e92e203058bd281fc4 to your computer and use it in GitHub Desktop.
Save tyilo/45335858301a40e92e203058bd281fc4 to your computer and use it in GitHub Desktop.
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