diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2023-12-18 17:55:55 +0100 |
|---|---|---|
| committer | León Orell Valerian Liehr <me@fmease.dev> | 2023-12-27 12:51:32 +0100 |
| commit | 3eb48a35c8ae8335da66dc2bdb4f60e6ae22e1dd (patch) | |
| tree | eadb378f48629728c106252798e74f8faf1bf745 /tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs | |
| parent | 2fe50cd72c476ebacdedb14893e9632b4de961c2 (diff) | |
| download | rust-3eb48a35c8ae8335da66dc2bdb4f60e6ae22e1dd.tar.gz rust-3eb48a35c8ae8335da66dc2bdb4f60e6ae22e1dd.zip | |
Introduce `const Trait` (always-const trait bounds)
Diffstat (limited to 'tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs')
| -rw-r--r-- | tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs new file mode 100644 index 00000000000..2304a766aaf --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs @@ -0,0 +1,20 @@ +// Ensure that we don't consider `const Trait` and `~const Trait` to +// 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`. + +// check-pass + +macro_rules! check { + ($Type:ty) => { compile_error!("ty"); }; + (const $Trait:path) => {}; + (~const $Trait:path) => {}; +} + +check! { const Trait } +check! { ~const Trait } + +fn main() {} |
