diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index 40aa39711d3e2..a40bac2d53ca4 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -13,7 +13,7 @@ use rustc_ast_pretty::pprust; use rustc_errors::DiagCtxtHandle; use rustc_hir::{self as hir, AttrPath}; use rustc_span::symbol::{Ident, kw, sym}; -use rustc_span::{ErrorGuaranteed, Span, Symbol}; +use rustc_span::{Span, Symbol}; pub struct SegmentIterator<'a> { offset: usize, @@ -176,7 +176,7 @@ impl<'a> ArgParser<'a> { pub enum MetaItemOrLitParser<'a> { MetaItemParser(MetaItemParser<'a>), Lit(MetaItemLit), - Err(Span, ErrorGuaranteed), + Err(Span), } impl<'a> MetaItemOrLitParser<'a> { @@ -186,7 +186,7 @@ impl<'a> MetaItemOrLitParser<'a> { generic_meta_item_parser.span() } MetaItemOrLitParser::Lit(meta_item_lit) => meta_item_lit.span, - MetaItemOrLitParser::Err(span, _) => *span, + MetaItemOrLitParser::Err(span) => *span, } } diff --git a/tests/ui/attributes/auxiliary/bar_derive.rs b/tests/ui/attributes/auxiliary/bar_derive.rs new file mode 100644 index 0000000000000..bfb38e3fcfb7f --- /dev/null +++ b/tests/ui/attributes/auxiliary/bar_derive.rs @@ -0,0 +1,8 @@ +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Bar, attributes(arg))] +pub fn derive_bar(_: proc_macro::TokenStream) -> proc_macro::TokenStream { + TokenStream::new() +} diff --git a/tests/ui/attributes/crate_name_on_other_items.rs b/tests/ui/attributes/crate_name_on_other_items.rs new file mode 100644 index 0000000000000..445e678f0d3d4 --- /dev/null +++ b/tests/ui/attributes/crate_name_on_other_items.rs @@ -0,0 +1,12 @@ +//@compile-flags: --crate-type=lib +// reproduces #137687 +// FIXME(jdonszelmann): should ERROR malformed `crate_name` attribute input but now still ignored. +// This is for the beta backport of 1.87 +#[crate_name = concat!("Cloneb")] + +macro_rules! inline { + () => {}; +} + +#[crate_name] //~ ERROR malformed `crate_name` attribute input +mod foo {} diff --git a/tests/ui/attributes/crate_name_on_other_items.stderr b/tests/ui/attributes/crate_name_on_other_items.stderr new file mode 100644 index 0000000000000..adc562ff3085f --- /dev/null +++ b/tests/ui/attributes/crate_name_on_other_items.stderr @@ -0,0 +1,8 @@ +error: malformed `crate_name` attribute input + --> $DIR/crate_name_on_other_items.rs:11:1 + | +LL | #[crate_name] + | ^^^^^^^^^^^^^ help: must be of the form: `#[crate_name = "name"]` + +error: aborting due to 1 previous error + diff --git a/tests/ui/attributes/proc_macro_in_macro.rs b/tests/ui/attributes/proc_macro_in_macro.rs new file mode 100644 index 0000000000000..28a1aa10b13e3 --- /dev/null +++ b/tests/ui/attributes/proc_macro_in_macro.rs @@ -0,0 +1,17 @@ +//@ proc-macro: bar_derive.rs +//@ check-pass + +extern crate bar_derive; +use bar_derive as bar; + +macro_rules! call_macro { + ($text:expr) => { + #[derive(bar::Bar)] + #[arg($text)] + pub struct Foo; + }; +} + +call_macro!(1 + 1); + +fn main() {} diff --git a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-3.rs b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-3.rs new file mode 100644 index 0000000000000..78784bd464a3f --- /dev/null +++ b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-3.rs @@ -0,0 +1,8 @@ +//@check-pass +//@ compile-flags: --print=file-names + +#[crate_name = concat!("wrapped")] + +macro_rules! inline { + () => {}; +} diff --git a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-3.stdout b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-3.stdout new file mode 100644 index 0000000000000..53ac8e2025b3d --- /dev/null +++ b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-3.stdout @@ -0,0 +1 @@ +print-file-names-request-malformed-crate-name-3