diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/macros/macro-pub-matcher.rs | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/macros/macro-pub-matcher.rs')
-rw-r--r-- | src/test/ui/macros/macro-pub-matcher.rs | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/src/test/ui/macros/macro-pub-matcher.rs b/src/test/ui/macros/macro-pub-matcher.rs deleted file mode 100644 index 7b02a70be..000000000 --- a/src/test/ui/macros/macro-pub-matcher.rs +++ /dev/null @@ -1,117 +0,0 @@ -// run-pass -#![allow(dead_code, unused_imports, unused_macro_rules)] - -/** -Ensure that `:vis` matches can be captured in existing positions, and passed -through without the need for reparse tricks. -*/ -macro_rules! vis_passthru { - ($vis:vis const $name:ident: $ty:ty = $e:expr;) => { $vis const $name: $ty = $e; }; - ($vis:vis enum $name:ident {}) => { $vis struct $name {} }; - ($vis:vis extern "C" fn $name:ident() {}) => { $vis extern "C" fn $name() {} }; - ($vis:vis fn $name:ident() {}) => { $vis fn $name() {} }; - ($vis:vis mod $name:ident {}) => { $vis mod $name {} }; - ($vis:vis static $name:ident: $ty:ty = $e:expr;) => { $vis static $name: $ty = $e; }; - ($vis:vis struct $name:ident;) => { $vis struct $name; }; - ($vis:vis trait $name:ident {}) => { $vis trait $name {} }; - ($vis:vis type $name:ident = $ty:ty;) => { $vis type $name = $ty; }; - ($vis:vis use $path:ident as $name:ident;) => { $vis use self::$path as $name; }; -} - -mod with_pub { - vis_passthru! { pub const A: i32 = 0; } - vis_passthru! { pub enum B {} } - vis_passthru! { pub extern "C" fn c() {} } - vis_passthru! { pub mod d {} } - vis_passthru! { pub static E: i32 = 0; } - vis_passthru! { pub struct F; } - vis_passthru! { pub trait G {} } - vis_passthru! { pub type H = i32; } - vis_passthru! { pub use A as I; } -} - -mod without_pub { - vis_passthru! { const A: i32 = 0; } - vis_passthru! { enum B {} } - vis_passthru! { extern "C" fn c() {} } - vis_passthru! { mod d {} } - vis_passthru! { static E: i32 = 0; } - vis_passthru! { struct F; } - vis_passthru! { trait G {} } - vis_passthru! { type H = i32; } - vis_passthru! { use A as I; } -} - -mod with_pub_restricted { - vis_passthru! { pub(crate) const A: i32 = 0; } - vis_passthru! { pub(crate) enum B {} } - vis_passthru! { pub(crate) extern "C" fn c() {} } - vis_passthru! { pub(crate) mod d {} } - vis_passthru! { pub(crate) static E: i32 = 0; } - vis_passthru! { pub(crate) struct F; } - vis_passthru! { pub(crate) trait G {} } - vis_passthru! { pub(crate) type H = i32; } - vis_passthru! { pub(crate) use A as I; } -} - -mod with_crate { - vis_passthru! { pub(crate) const A: i32 = 0; } - vis_passthru! { pub(crate) enum B {} } - vis_passthru! { pub(crate) extern "C" fn c() {} } - vis_passthru! { pub(crate) mod d {} } - vis_passthru! { pub(crate) static E: i32 = 0; } - vis_passthru! { pub(crate) struct F; } - vis_passthru! { pub(crate) trait G {} } - vis_passthru! { pub(crate) type H = i32; } - vis_passthru! { pub(crate) use A as I; } -} - -mod garden { - mod with_pub_restricted_path { - vis_passthru! { pub(in garden) const A: i32 = 0; } - vis_passthru! { pub(in garden) enum B {} } - vis_passthru! { pub(in garden) extern "C" fn c() {} } - vis_passthru! { pub(in garden) mod d {} } - vis_passthru! { pub(in garden) static E: i32 = 0; } - vis_passthru! { pub(in garden) struct F; } - vis_passthru! { pub(in garden) trait G {} } - vis_passthru! { pub(in garden) type H = i32; } - vis_passthru! { pub(in garden) use A as I; } - } -} - -/* -Ensure that the `:vis` matcher works in a more complex situation: parsing a -struct definition. -*/ -macro_rules! vis_parse_struct { - ($(#[$($attrs:tt)*])* $vis:vis struct $name:ident {$($body:tt)*}) => { - vis_parse_struct! { @parse_fields $(#[$($attrs)*])*, $vis, $name, $($body)* } - }; - - ($(#[$($attrs:tt)*])* $vis:vis struct $name:ident ($($body:tt)*);) => { - vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, $vis, $name, $($body)* } - }; - - (@parse_fields - $(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fname:ident: $fty:ty),* $(,)*) => { - $(#[$attrs])* $vis struct $name { $($fvis $fname: $fty,)* } - }; - - (@parse_tuple - $(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fty:ty),* $(,)*) => { - $(#[$attrs])* $vis struct $name ( $($fvis $fty,)* ); - }; -} - -mod test_struct { - vis_parse_struct! { pub(crate) struct A { pub a: i32, b: i32, pub(crate) c: i32 } } - vis_parse_struct! { pub struct B { a: i32, pub(crate) b: i32, pub c: i32 } } - vis_parse_struct! { struct C { pub(crate) a: i32, pub b: i32, c: i32 } } - - vis_parse_struct! { pub(crate) struct D (pub i32, i32, pub(crate) i32); } - vis_parse_struct! { pub struct E (i32, pub(crate) i32, pub i32); } - vis_parse_struct! { struct F (pub(crate) i32, pub i32, i32); } -} - -fn main() {} |