2025-03-11 12:08:45 +00:00
|
|
|
// Ensure that we don't consider `const Trait` to
|
2023-12-18 17:55:55 +01:00
|
|
|
// match the macro fragment specifier `ty` as that would be a breaking
|
|
|
|
|
// change theoretically speaking. Syntactically trait object types can
|
|
|
|
|
// be "bare", i.e., lack the prefix `dyn`.
|
|
|
|
|
// By contrast, `?Trait` *does* match `ty` and therefore an arm like
|
|
|
|
|
// `?$Trait:path` would never be reached.
|
|
|
|
|
// See `parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs`.
|
2025-03-11 12:08:45 +00:00
|
|
|
// `[const] Trait` is already an error for a `ty` fragment,
|
|
|
|
|
// so we do not need to prevent that.
|
2023-12-18 17:55:55 +01:00
|
|
|
|
|
|
|
|
macro_rules! check {
|
2025-03-11 12:08:45 +00:00
|
|
|
($Type:ty) => {
|
|
|
|
|
compile_error!("ty");
|
|
|
|
|
};
|
2023-12-18 17:55:55 +01:00
|
|
|
(const $Trait:path) => {};
|
2025-03-11 12:08:45 +00:00
|
|
|
([const] $Trait:path) => {};
|
2023-12-18 17:55:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
check! { const Trait }
|
2025-03-11 12:08:45 +00:00
|
|
|
check! { [const] Trait }
|
|
|
|
|
//~^ ERROR: expected identifier, found `]`
|
|
|
|
|
//~| ERROR: const trait impls are experimental
|
2023-12-18 17:55:55 +01:00
|
|
|
|
|
|
|
|
fn main() {}
|