diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-07-01 02:45:14 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-07-01 02:45:14 +0500 |
| commit | 9a7db566d7b7bb534c5dc3bcfbd2ddd51d99a8d5 (patch) | |
| tree | 41a15423391873b07894d2abb4c9ae994bfd0340 /tests/ui/macros | |
| parent | 5ca574e85b67cec0a6fc3fddfe398cbe676c9c69 (diff) | |
| download | rust-9a7db566d7b7bb534c5dc3bcfbd2ddd51d99a8d5.tar.gz rust-9a7db566d7b7bb534c5dc3bcfbd2ddd51d99a8d5.zip | |
moved tests
Diffstat (limited to 'tests/ui/macros')
| -rw-r--r-- | tests/ui/macros/macro-paren-span-diagnostic.rs | 21 | ||||
| -rw-r--r-- | tests/ui/macros/macro-paren-span-diagnostic.stderr | 9 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/macros/macro-paren-span-diagnostic.rs b/tests/ui/macros/macro-paren-span-diagnostic.rs new file mode 100644 index 00000000000..c8cb63d5190 --- /dev/null +++ b/tests/ui/macros/macro-paren-span-diagnostic.rs @@ -0,0 +1,21 @@ +// Be smart about span of parenthesized expression in macro. + +macro_rules! paren { + ($e:expr) => (($e)) + // ^^^^ do not highlight here +} + +mod m { + pub struct S { + x: i32 + } + pub fn make() -> S { + S { x: 0 } + } +} + +fn main() { + let s = m::make(); + paren!(s.x); //~ ERROR field `x` of struct `S` is private + // ^^^ highlight here +} diff --git a/tests/ui/macros/macro-paren-span-diagnostic.stderr b/tests/ui/macros/macro-paren-span-diagnostic.stderr new file mode 100644 index 00000000000..da2f57033a4 --- /dev/null +++ b/tests/ui/macros/macro-paren-span-diagnostic.stderr @@ -0,0 +1,9 @@ +error[E0616]: field `x` of struct `S` is private + --> $DIR/paren-span.rs:19:14 + | +LL | paren!(s.x); + | ^ private field + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0616`. |
