From 4f2c25a998ec39a86871d228342fa2ea7a2e6270 Mon Sep 17 00:00:00 2001 From: JohnTitor Date: Tue, 30 Mar 2021 17:02:23 +0900 Subject: [PATCH] Add a regression test for issue-75801 --- .../ui/proc-macro/auxiliary/issue-75801.rs | 13 +++++++++++++ src/test/ui/proc-macro/issue-75801.rs | 19 +++++++++++++++++++ src/test/ui/proc-macro/issue-75801.stderr | 12 ++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 src/test/ui/proc-macro/auxiliary/issue-75801.rs create mode 100644 src/test/ui/proc-macro/issue-75801.rs create mode 100644 src/test/ui/proc-macro/issue-75801.stderr diff --git a/src/test/ui/proc-macro/auxiliary/issue-75801.rs b/src/test/ui/proc-macro/auxiliary/issue-75801.rs new file mode 100644 index 00000000000..d6c031d7d4f --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/issue-75801.rs @@ -0,0 +1,13 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn foo(_args: TokenStream, item: TokenStream) -> TokenStream { + item +} diff --git a/src/test/ui/proc-macro/issue-75801.rs b/src/test/ui/proc-macro/issue-75801.rs new file mode 100644 index 00000000000..b07cde0fabd --- /dev/null +++ b/src/test/ui/proc-macro/issue-75801.rs @@ -0,0 +1,19 @@ +// aux-build: issue-75801.rs + +// Regression test for #75801. + +#[macro_use] +extern crate issue_75801; + +macro_rules! foo { + ($arg:expr) => { + #[foo] + fn bar() { + let _bar: u32 = $arg; + } + }; +} + +foo!("baz"); //~ ERROR: mismatched types [E0308] + +fn main() {} diff --git a/src/test/ui/proc-macro/issue-75801.stderr b/src/test/ui/proc-macro/issue-75801.stderr new file mode 100644 index 00000000000..ee0a9bd7783 --- /dev/null +++ b/src/test/ui/proc-macro/issue-75801.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/issue-75801.rs:17:6 + | +LL | let _bar: u32 = $arg; + | --- expected due to this +... +LL | foo!("baz"); + | ^^^^^ expected `u32`, found `&str` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`.