diff options
| author | Oneirical <manchot@videotron.ca> | 2025-07-13 16:39:45 -0400 |
|---|---|---|
| committer | Oneirical <manchot@videotron.ca> | 2025-08-10 11:54:15 -0400 |
| commit | aa543963c68061d9ca46037071d66a028626ff3f (patch) | |
| tree | 2d6e7de7e1b2fe2176d81f48a456a05ef1b06dff /tests/ui/macros | |
| parent | f8e355c230c6eb7b78ffce6a92fd81f78c890524 (diff) | |
| download | rust-aa543963c68061d9ca46037071d66a028626ff3f.tar.gz rust-aa543963c68061d9ca46037071d66a028626ff3f.zip | |
Rehome tests/ui/issues/ tests [4/?]
Diffstat (limited to 'tests/ui/macros')
4 files changed, 70 insertions, 0 deletions
diff --git a/tests/ui/macros/macro-expansion-module-structure-9110.rs b/tests/ui/macros/macro-expansion-module-structure-9110.rs new file mode 100644 index 00000000000..b6241a7c18e --- /dev/null +++ b/tests/ui/macros/macro-expansion-module-structure-9110.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/9110 +//@ check-pass +#![allow(dead_code)] +#![allow(non_snake_case)] + +macro_rules! silly_macro { + () => ( + pub mod Qux { + pub struct Foo { x : u8 } + pub fn bar(_foo : Foo) {} + } + ); +} + +silly_macro!(); + +pub fn main() {} diff --git a/tests/ui/macros/macro-invocation-with-variable-in-scope-9737.rs b/tests/ui/macros/macro-invocation-with-variable-in-scope-9737.rs new file mode 100644 index 00000000000..957c2e3f103 --- /dev/null +++ b/tests/ui/macros/macro-invocation-with-variable-in-scope-9737.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/9737 +//@ run-pass +#![allow(unused_variables)] +macro_rules! f { + (v: $x:expr) => ( println!("{}", $x) ) +} + +fn main () { + let v = 5; + f!(v: 3); +} diff --git a/tests/ui/macros/private-struct-member-macro-access-25386.rs b/tests/ui/macros/private-struct-member-macro-access-25386.rs new file mode 100644 index 00000000000..88e5a22a699 --- /dev/null +++ b/tests/ui/macros/private-struct-member-macro-access-25386.rs @@ -0,0 +1,28 @@ +// https://github.com/rust-lang/rust/issues/25386 +mod stuff { + pub struct Item { + c_object: Box<CObj>, + } + pub struct CObj { + name: Option<String>, + } + impl Item { + pub fn new() -> Item { + Item { + c_object: Box::new(CObj { name: None }), + } + } + } +} + +macro_rules! check_ptr_exist { + ($var:expr, $member:ident) => ( + (*$var.c_object).$member.is_some() + //~^ ERROR field `c_object` of struct `Item` is private + ); +} + +fn main() { + let item = stuff::Item::new(); + println!("{}", check_ptr_exist!(item, name)); +} diff --git a/tests/ui/macros/private-struct-member-macro-access-25386.stderr b/tests/ui/macros/private-struct-member-macro-access-25386.stderr new file mode 100644 index 00000000000..d02a41848f4 --- /dev/null +++ b/tests/ui/macros/private-struct-member-macro-access-25386.stderr @@ -0,0 +1,14 @@ +error[E0616]: field `c_object` of struct `Item` is private + --> $DIR/private-struct-member-macro-access-25386.rs:20:16 + | +LL | (*$var.c_object).$member.is_some() + | ^^^^^^^^ private field +... +LL | println!("{}", check_ptr_exist!(item, name)); + | ---------------------------- in this macro invocation + | + = note: this error originates in the macro `check_ptr_exist` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0616`. |
