Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 04bafec

Browse files
committedFeb 27, 2025··
add test to reproduce #137687 and fix it
1 parent 96cfc75 commit 04bafec

36 files changed

+340
-170
lines changed
 

‎compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ pub enum AttributeKind {
175175
span: Span,
176176
},
177177
ConstStabilityIndirect,
178+
CrateName {
179+
name: Symbol,
180+
name_span: Span,
181+
style: AttrStyle,
182+
},
178183
Deprecation {
179184
deprecation: Deprecation,
180185
span: Span,
@@ -195,3 +200,23 @@ pub enum AttributeKind {
195200
},
196201
// tidy-alphabetical-end
197202
}
203+
204+
impl AttributeKind {
205+
pub fn crate_level(&self) -> Option<(AttrStyle, Span)> {
206+
match self {
207+
AttributeKind::AllowConstFnUnstable(..) | AttributeKind::AllowInternalUnstable(..) |
208+
AttributeKind::BodyStability {..} |
209+
AttributeKind::Confusables {..} |
210+
AttributeKind::ConstStability {..} |
211+
AttributeKind::ConstStabilityIndirect |
212+
AttributeKind::Deprecation {..} |
213+
AttributeKind::Diagnostic(..) |
214+
AttributeKind::DocComment {..} |
215+
AttributeKind::MacroTransparency(..) |
216+
AttributeKind::Repr(..)|
217+
AttributeKind::Stability { .. } => None,
218+
219+
AttributeKind::CrateName { style, name_span, .. } => Some((*style, *name_span)),
220+
}
221+
}
222+
}

‎compiler/rustc_attr_parsing/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,6 @@ attr_parsing_unused_multiple =
135135
multiple `{$name}` attributes
136136
.suggestion = remove this attribute
137137
.note = attribute also specified here
138+
139+
attr_parsing_name_value = malformed `{$name}` attribute: expected to be of the form `#[{$name} = ...]`
140+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
use rustc_attr_data_structures::AttributeKind;
2+
use rustc_span::{sym, Span, Symbol};
3+
4+
use crate::{context::AcceptContext, parser::ArgParser, session_diagnostics::{ExpectedNameValue, IncorrectMetaItem, UnusedMultiple}};
5+
6+
use super::SingleAttributeParser;
7+
8+
9+
pub(crate) struct CratenameParser;
10+
11+
impl SingleAttributeParser for CratenameParser {
12+
const PATH: &'static [Symbol] = &[sym::crate_name];
13+
14+
fn on_duplicate(cx: &AcceptContext<'_>, first_span: Span) {
15+
// FIXME(jdonszelmann): better duplicate reporting (WIP)
16+
cx.emit_err(UnusedMultiple {
17+
this: cx.attr_span,
18+
other: first_span,
19+
name: sym::crate_name,
20+
});
21+
}
22+
23+
fn convert(cx: &AcceptContext<'_>, args: &ArgParser<'_>) -> Option<AttributeKind> {
24+
if let ArgParser::NameValue(n) = args {
25+
if let Some(name) = n.value_as_str() {
26+
Some(AttributeKind::CrateName {
27+
name,
28+
name_span: n.value_span,
29+
style: cx.attr_style
30+
})
31+
} else {
32+
cx.emit_err(IncorrectMetaItem {
33+
span: cx.attr_span,
34+
suggestion: None
35+
});
36+
37+
None
38+
}
39+
} else {
40+
cx.emit_err(ExpectedNameValue {
41+
span: cx.attr_span,
42+
name: sym::crate_name,
43+
});
44+
45+
None
46+
}
47+
}
48+
}

‎compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub(crate) mod deprecation;
3030
pub(crate) mod repr;
3131
pub(crate) mod stability;
3232
pub(crate) mod transparency;
33+
pub(crate) mod crate_name;
3334
pub(crate) mod util;
3435

3536
type AcceptFn<T> = fn(&mut T, &AcceptContext<'_>, &ArgParser<'_>);

‎compiler/rustc_attr_parsing/src/attributes/util.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use rustc_ast::attr::{AttributeExt, first_attr_value_str_by_name};
1+
use rustc_ast::attr::AttributeExt;
22
use rustc_attr_data_structures::RustcVersion;
33
use rustc_feature::is_builtin_attr_name;
4-
use rustc_span::{Symbol, sym};
4+
use rustc_span::Symbol;
55

66
/// Parse a rustc version number written inside string literal in an attribute,
77
/// like appears in `since = "1.0.0"`. Suffixes like "-dev" and "-nightly" are
@@ -22,7 +22,3 @@ pub fn parse_version(s: Symbol) -> Option<RustcVersion> {
2222
pub fn is_builtin_attr(attr: &impl AttributeExt) -> bool {
2323
attr.is_doc_comment() || attr.ident().is_some_and(|ident| is_builtin_attr_name(ident.name))
2424
}
25-
26-
pub fn find_crate_name(attrs: &[impl AttributeExt]) -> Option<Symbol> {
27-
first_attr_value_str_by_name(attrs, sym::crate_name)
28-
}

‎compiler/rustc_attr_parsing/src/context.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::collections::BTreeMap;
33
use std::ops::Deref;
44
use std::sync::LazyLock;
55

6-
use rustc_ast::{self as ast, DelimArgs};
6+
use rustc_ast::{self as ast, AttrStyle, DelimArgs};
77
use rustc_attr_data_structures::AttributeKind;
88
use rustc_errors::{DiagCtxtHandle, Diagnostic};
99
use rustc_feature::Features;
@@ -14,6 +14,7 @@ use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
1414

1515
use crate::attributes::allow_unstable::{AllowConstFnUnstableParser, AllowInternalUnstableParser};
1616
use crate::attributes::confusables::ConfusablesParser;
17+
use crate::attributes::crate_name::CratenameParser;
1718
use crate::attributes::deprecation::DeprecationParser;
1819
use crate::attributes::repr::ReprParser;
1920
use crate::attributes::stability::{
@@ -76,6 +77,7 @@ attribute_groups!(
7677

7778
// tidy-alphabetical-start
7879
Single<ConstStabilityIndirectParser>,
80+
Single<CratenameParser>,
7981
Single<DeprecationParser>,
8082
Single<TransparencyParser>,
8183
// tidy-alphabetical-end
@@ -89,6 +91,7 @@ pub(crate) struct AcceptContext<'a> {
8991
pub(crate) group_cx: &'a FinalizeContext<'a>,
9092
/// The span of the attribute currently being parsed
9193
pub(crate) attr_span: Span,
94+
pub(crate) attr_style: AttrStyle,
9295
}
9396

9497
impl<'a> AcceptContext<'a> {
@@ -269,6 +272,7 @@ impl<'sess> AttributeParser<'sess> {
269272
let cx = AcceptContext {
270273
group_cx: &group_cx,
271274
attr_span: lower_span(attr.span),
275+
attr_style: attr.style,
272276
};
273277

274278
f(&cx, &args)

‎compiler/rustc_attr_parsing/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub mod parser;
9090
mod session_diagnostics;
9191

9292
pub use attributes::cfg::*;
93-
pub use attributes::util::{find_crate_name, is_builtin_attr, parse_version};
93+
pub use attributes::util::{is_builtin_attr, parse_version};
9494
pub use context::{AttributeParser, OmitDoc};
9595
pub use rustc_attr_data_structures::*;
9696

‎compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,3 +479,11 @@ pub(crate) struct UnrecognizedReprHint {
479479
#[primary_span]
480480
pub span: Span,
481481
}
482+
483+
#[derive(Diagnostic)]
484+
#[diag(attr_parsing_name_value, code = E0539)]
485+
pub(crate) struct ExpectedNameValue {
486+
#[primary_span]
487+
pub span: Span,
488+
pub name: Symbol,
489+
}

‎compiler/rustc_driver_impl/src/lib.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use rustc_session::getopts::{self, Matches};
5959
use rustc_session::lint::{Lint, LintId};
6060
use rustc_session::output::collect_crate_types;
6161
use rustc_session::{EarlyDiagCtxt, Session, config, filesearch};
62-
use rustc_span::FileName;
62+
use rustc_span::{FileName, Symbol};
6363
use rustc_target::json::ToJson;
6464
use rustc_target::spec::{Target, TargetTuple};
6565
use time::OffsetDateTime;
@@ -290,7 +290,8 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
290290
return early_exit();
291291
}
292292

293-
if print_crate_info(codegen_backend, sess, has_input) == Compilation::Stop {
293+
let (c, crate_name) = print_crate_info(codegen_backend, sess, has_input);
294+
if c == Compilation::Stop {
294295
return early_exit();
295296
}
296297

@@ -316,7 +317,7 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
316317
// If pretty printing is requested: Figure out the representation, print it and exit
317318
if let Some(pp_mode) = sess.opts.pretty {
318319
if pp_mode.needs_ast_map() {
319-
create_and_enter_global_ctxt(compiler, krate, |tcx| {
320+
create_and_enter_global_ctxt(compiler, krate, crate_name, |tcx| {
320321
tcx.ensure_ok().early_lint_checks(());
321322
pretty::print(sess, pp_mode, pretty::PrintExtra::NeedsAstMap { tcx });
322323
passes::write_dep_info(tcx);
@@ -336,7 +337,7 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
336337
return early_exit();
337338
}
338339

339-
let linker = create_and_enter_global_ctxt(compiler, krate, |tcx| {
340+
let linker = create_and_enter_global_ctxt(compiler, krate, crate_name, |tcx| {
340341
let early_exit = || {
341342
sess.dcx().abort_if_errors();
342343
None
@@ -607,18 +608,23 @@ fn print_crate_info(
607608
codegen_backend: &dyn CodegenBackend,
608609
sess: &Session,
609610
parse_attrs: bool,
610-
) -> Compilation {
611+
) -> (Compilation, Option<Symbol>) {
611612
use rustc_session::config::PrintKind::*;
612613
// This import prevents the following code from using the printing macros
613614
// used by the rest of the module. Within this function, we only write to
614615
// the output specified by `sess.io.output_file`.
615616
#[allow(unused_imports)]
616617
use {do_not_use_safe_print as safe_print, do_not_use_safe_print as safe_println};
617618

619+
let mut crate_name = None;
620+
let mut get_crate_name = |attrs| {
621+
*crate_name.get_or_insert_with(|| passes::get_crate_name(sess, attrs))
622+
};
623+
618624
// NativeStaticLibs and LinkArgs are special - printed during linking
619625
// (empty iterator returns true)
620626
if sess.opts.prints.iter().all(|p| p.kind == NativeStaticLibs || p.kind == LinkArgs) {
621-
return Compilation::Continue;
627+
return (Compilation::Continue, crate_name);
622628
}
623629

624630
let attrs = if parse_attrs {
@@ -627,7 +633,7 @@ fn print_crate_info(
627633
Ok(attrs) => Some(attrs),
628634
Err(parse_error) => {
629635
parse_error.emit();
630-
return Compilation::Stop;
636+
return (Compilation::Stop, crate_name);
631637
}
632638
}
633639
} else {
@@ -664,24 +670,23 @@ fn print_crate_info(
664670
FileNames => {
665671
let Some(attrs) = attrs.as_ref() else {
666672
// no crate attributes, print out an error and exit
667-
return Compilation::Continue;
673+
return (Compilation::Continue, crate_name);
668674
};
669675
let t_outputs = rustc_interface::util::build_output_filenames(attrs, sess);
670-
let crate_name = passes::get_crate_name(sess, attrs);
671676
let crate_types = collect_crate_types(sess, attrs);
672677
for &style in &crate_types {
673678
let fname = rustc_session::output::filename_for_input(
674-
sess, style, crate_name, &t_outputs,
679+
sess, style, get_crate_name(attrs), &t_outputs,
675680
);
676681
println_info!("{}", fname.as_path().file_name().unwrap().to_string_lossy());
677682
}
678683
}
679684
CrateName => {
680685
let Some(attrs) = attrs.as_ref() else {
681686
// no crate attributes, print out an error and exit
682-
return Compilation::Continue;
687+
return (Compilation::Continue, crate_name);
683688
};
684-
println_info!("{}", passes::get_crate_name(sess, attrs));
689+
println_info!("{}", get_crate_name(attrs));
685690
}
686691
Cfg => {
687692
let mut cfgs = sess
@@ -786,7 +791,7 @@ fn print_crate_info(
786791

787792
req.out.overwrite(&crate_info, sess);
788793
}
789-
Compilation::Stop
794+
(Compilation::Stop, crate_name)
790795
}
791796

792797
/// Prints version information

‎compiler/rustc_interface/src/passes.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::sync::{Arc, LazyLock};
66
use std::{env, fs, iter};
77

88
use rustc_ast as ast;
9+
use rustc_attr_parsing::{AttributeKind, AttributeParser};
910
use rustc_codegen_ssa::traits::CodegenBackend;
1011
use rustc_data_structures::parallel;
1112
use rustc_data_structures::steal::Steal;
@@ -32,7 +33,7 @@ use rustc_session::output::{collect_crate_types, filename_for_input};
3233
use rustc_session::search_paths::PathKind;
3334
use rustc_session::{Limit, Session};
3435
use rustc_span::{
35-
ErrorGuaranteed, FileName, SourceFileHash, SourceFileHashAlgorithm, Span, Symbol, sym,
36+
sym, ErrorGuaranteed, FileName, SourceFileHash, SourceFileHashAlgorithm, Span, Symbol, DUMMY_SP
3637
};
3738
use rustc_target::spec::PanicStrategy;
3839
use rustc_trait_selection::traits;
@@ -753,6 +754,7 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
753754
pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>(
754755
compiler: &Compiler,
755756
mut krate: rustc_ast::Crate,
757+
crate_name: Option<Symbol>,
756758
f: F,
757759
) -> T {
758760
let sess = &compiler.sess;
@@ -765,7 +767,7 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>(
765767

766768
let pre_configured_attrs = rustc_expand::config::pre_configure_attrs(sess, &krate.attrs);
767769

768-
let crate_name = get_crate_name(sess, &pre_configured_attrs);
770+
let crate_name = crate_name.unwrap_or_else(|| get_crate_name(sess, &pre_configured_attrs));
769771
let crate_types = collect_crate_types(sess, &pre_configured_attrs);
770772
let stable_crate_id = StableCrateId::new(
771773
crate_name,
@@ -1119,6 +1121,14 @@ pub(crate) fn start_codegen<'tcx>(
11191121
codegen
11201122
}
11211123

1124+
pub(crate) fn parse_crate_name(sess: &Session, attrs: &[ast::Attribute], limit_diagnostics: bool) -> Option<(Symbol, Span)> {
1125+
let rustc_hir::Attribute::Parsed(AttributeKind::CrateName {name, name_span, ..}) = AttributeParser::parse_limited(sess, &attrs, sym::crate_name, DUMMY_SP, limit_diagnostics)? else {
1126+
unreachable!("crate_name is the only attr we could've parsed here");
1127+
};
1128+
1129+
Some((name, name_span))
1130+
}
1131+
11221132
/// Compute and validate the crate name.
11231133
pub fn get_crate_name(sess: &Session, krate_attrs: &[ast::Attribute]) -> Symbol {
11241134
// We validate *all* occurrences of `#![crate_name]`, pick the first find and
@@ -1128,8 +1138,7 @@ pub fn get_crate_name(sess: &Session, krate_attrs: &[ast::Attribute]) -> Symbol
11281138
// in all code paths that require the crate name very early on, namely before
11291139
// macro expansion.
11301140

1131-
let attr_crate_name =
1132-
validate_and_find_value_str_builtin_attr(sym::crate_name, sess, krate_attrs);
1141+
let attr_crate_name = parse_crate_name(sess, krate_attrs, false);
11331142

11341143
let validate = |name, span| {
11351144
rustc_session::output::validate_crate_name(sess, name, span);

‎compiler/rustc_interface/src/util.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ use rustc_session::{EarlyDiagCtxt, Session, filesearch};
1818
use rustc_span::edit_distance::find_best_match_for_name;
1919
use rustc_span::edition::Edition;
2020
use rustc_span::source_map::SourceMapInputs;
21-
use rustc_span::{Symbol, sym};
21+
use rustc_span::{sym, Symbol};
2222
use rustc_target::spec::Target;
2323
use tracing::info;
2424

2525
use crate::errors;
26+
use crate::passes::parse_crate_name;
2627

2728
/// Function pointer type that constructs a new CodegenBackend.
2829
type MakeBackendFn = fn() -> Box<dyn CodegenBackend>;
@@ -481,11 +482,9 @@ pub fn build_output_filenames(attrs: &[ast::Attribute], sess: &Session) -> Outpu
481482
sess.dcx().emit_fatal(errors::MultipleOutputTypesToStdout);
482483
}
483484

484-
let crate_name = sess
485-
.opts
486-
.crate_name
485+
let crate_name = sess.opts.crate_name
487486
.clone()
488-
.or_else(|| rustc_attr_parsing::find_crate_name(attrs).map(|n| n.to_string()));
487+
.or_else(|| parse_crate_name(sess, attrs, true).map(|i| i.0.to_string()));
489488

490489
match sess.io.output_file {
491490
None => {

‎compiler/rustc_lint/src/nonstandard_style.rs

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use rustc_abi::ExternAbi;
2-
use rustc_attr_parsing::{AttributeKind, AttributeParser, ReprAttr};
2+
use rustc_attr_parsing::{find_attr, AttributeKind, AttributeParser, ReprAttr};
33
use rustc_hir::def::{DefKind, Res};
44
use rustc_hir::intravisit::FnKind;
5-
use rustc_hir::{AttrArgs, AttrItem, Attribute, GenericParamKind, PatExprKind, PatKind};
5+
use rustc_hir::{Attribute, GenericParamKind, PatExprKind, PatKind};
66
use rustc_middle::ty;
77
use rustc_session::config::CrateType;
88
use rustc_session::{declare_lint, declare_lint_pass};
@@ -342,35 +342,27 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
342342
let crate_ident = if let Some(name) = &cx.tcx.sess.opts.crate_name {
343343
Some(Ident::from_str(name))
344344
} else {
345-
ast::attr::find_by_name(cx.tcx.hir().attrs(hir::CRATE_HIR_ID), sym::crate_name)
346-
.and_then(|attr| {
347-
if let Attribute::Unparsed(n) = attr
348-
&& let AttrItem { args: AttrArgs::Eq { eq_span: _, expr: lit }, .. } =
349-
n.as_ref()
350-
&& let ast::LitKind::Str(name, ..) = lit.kind
351-
{
352-
// Discard the double quotes surrounding the literal.
353-
let sp = cx
354-
.sess()
355-
.source_map()
356-
.span_to_snippet(lit.span)
357-
.ok()
358-
.and_then(|snippet| {
359-
let left = snippet.find('"')?;
360-
let right = snippet.rfind('"').map(|pos| snippet.len() - pos)?;
361-
362-
Some(
363-
lit.span
364-
.with_lo(lit.span.lo() + BytePos(left as u32 + 1))
365-
.with_hi(lit.span.hi() - BytePos(right as u32)),
366-
)
367-
})
368-
.unwrap_or(lit.span);
369-
370-
Some(Ident::new(name, sp))
371-
} else {
372-
None
373-
}
345+
find_attr!(cx.tcx.hir().attrs(hir::CRATE_HIR_ID), AttributeKind::CrateName{name, name_span,..} => (name, name_span))
346+
.and_then(|(&name, &span)| {
347+
// Discard the double quotes surrounding the literal.
348+
let sp = cx
349+
.sess()
350+
.source_map()
351+
.span_to_snippet(span)
352+
.ok()
353+
.and_then(|snippet| {
354+
let left = snippet.find('"')?;
355+
let right = snippet.rfind('"').map(|pos| snippet.len() - pos)?;
356+
357+
Some(
358+
span
359+
.with_lo(span.lo() + BytePos(left as u32 + 1))
360+
.with_hi(span.hi() - BytePos(right as u32)),
361+
)
362+
})
363+
.unwrap_or(span);
364+
365+
Some(Ident::new(name, sp))
374366
})
375367
};
376368

‎compiler/rustc_parse/src/validate_attr.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ pub fn check_builtin_meta_item(
217217
) {
218218
// Some special attributes like `cfg` must be checked
219219
// before the generic check, so we skip them here.
220-
let should_skip = |name| name == sym::cfg;
220+
//
221+
// Also, attributes that have a new-style parser don't need to be checked here anymore
222+
let should_skip = |name| name == sym::cfg || name == sym::crate_name;
221223

222224
if !should_skip(name) && !is_attr_template_compatible(&template, &meta.kind) {
223225
emit_malformed_attribute(psess, style, meta.span, name, template);

‎compiler/rustc_passes/src/check_attr.rs

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::cell::Cell;
99
use std::collections::hash_map::Entry;
1010

1111
use rustc_abi::{Align, ExternAbi, Size};
12-
use rustc_ast::{AttrStyle, LitKind, MetaItemInner, MetaItemKind, MetaItemLit, ast};
12+
use rustc_ast::{ast, AttrStyle, LitKind, MetaItemInner, MetaItemKind, MetaItemLit};
1313
use rustc_attr_parsing::{AttributeKind, ReprAttr, find_attr};
1414
use rustc_data_structures::fx::FxHashMap;
1515
use rustc_errors::{Applicability, DiagCtxtHandle, IntoDiagArg, MultiSpan, StashKey};
@@ -315,22 +315,44 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
315315
let builtin = attr.ident().and_then(|ident| BUILTIN_ATTRIBUTE_MAP.get(&ident.name));
316316

317317
if hir_id != CRATE_HIR_ID {
318-
if let Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) =
319-
attr.ident().and_then(|ident| BUILTIN_ATTRIBUTE_MAP.get(&ident.name))
320-
{
321-
match attr.style() {
322-
ast::AttrStyle::Outer => self.tcx.emit_node_span_lint(
323-
UNUSED_ATTRIBUTES,
324-
hir_id,
325-
attr.span(),
326-
errors::OuterCrateLevelAttr,
327-
),
328-
ast::AttrStyle::Inner => self.tcx.emit_node_span_lint(
329-
UNUSED_ATTRIBUTES,
330-
hir_id,
331-
attr.span(),
332-
errors::InnerCrateLevelAttr,
333-
),
318+
if let Attribute::Parsed(attr) = attr {
319+
if let Some((style, span)) = attr.crate_level() {
320+
match style {
321+
ast::AttrStyle::Outer => self.tcx.emit_node_span_lint(
322+
UNUSED_ATTRIBUTES,
323+
hir_id,
324+
span,
325+
errors::OuterCrateLevelAttr,
326+
),
327+
ast::AttrStyle::Inner => self.tcx.emit_node_span_lint(
328+
UNUSED_ATTRIBUTES,
329+
hir_id,
330+
span,
331+
errors::InnerCrateLevelAttr,
332+
),
333+
}
334+
335+
}
336+
} else {
337+
// FIXME(jdonszelmann): remove once all crate-level attrs are parsed and caught by
338+
// the above
339+
if let Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) =
340+
attr.ident().and_then(|ident| BUILTIN_ATTRIBUTE_MAP.get(&ident.name))
341+
{
342+
match attr.style() {
343+
ast::AttrStyle::Outer => self.tcx.emit_node_span_lint(
344+
UNUSED_ATTRIBUTES,
345+
hir_id,
346+
attr.span(),
347+
errors::OuterCrateLevelAttr,
348+
),
349+
ast::AttrStyle::Inner => self.tcx.emit_node_span_lint(
350+
UNUSED_ATTRIBUTES,
351+
hir_id,
352+
attr.span(),
353+
errors::InnerCrateLevelAttr,
354+
),
355+
}
334356
}
335357
}
336358
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// issue: rust-lang/rust#122001
22
// Ensure we reject macro calls inside `#![crate_name]` as their result wouldn't get honored anyway.
33

4-
#![crate_name = concat!("my", "crate")] //~ ERROR malformed `crate_name` attribute input
4+
#![crate_name = concat!("my", "crate")] //~ ERROR expected a quoted string literal
55

66
fn main() {}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error: malformed `crate_name` attribute input
1+
error[E0539]: expected a quoted string literal
22
--> $DIR/crate-name-macro-call.rs:4:1
33
|
44
LL | #![crate_name = concat!("my", "crate")]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error: aborting due to 1 previous error
88

9+
For more information about this error, try `rustc --explain E0539`.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@compile-flags: --crate-type=lib
2+
// reproduces #137687
3+
#[crate_name = concat!("Cloneb")] //~ ERROR expected a quoted string literal
4+
5+
6+
macro_rules! inline {
7+
() => {};
8+
}
9+
10+
#[crate_name] //~ ERROR malformed `crate_name` attribute: expected to be of the form `#[crate_name = ...]`
11+
mod foo {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0539]: expected a quoted string literal
2+
--> $DIR/crate_name_on_other_items.rs:3:1
3+
|
4+
LL | #[crate_name = concat!("Cloneb")]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error[E0539]: malformed `crate_name` attribute: expected to be of the form `#[crate_name = ...]`
8+
--> $DIR/crate_name_on_other_items.rs:10:1
9+
|
10+
LL | #[crate_name]
11+
| ^^^^^^^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0539`.

‎tests/ui/crate-name-mismatch.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: `--crate-name` and `#[crate_name]` are required to match, but `foo` != `bar`
2-
--> $DIR/crate-name-mismatch.rs:3:1
2+
--> $DIR/crate-name-mismatch.rs:3:17
33
|
44
LL | #![crate_name = "bar"]
5-
| ^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^
66

77
error: aborting due to 1 previous error
88

‎tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,10 @@ LL | #[windows_subsystem = "windows"]
320320
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
321321

322322
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
323-
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:629:1
323+
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:629:16
324324
|
325325
LL | #[crate_name = "0900"]
326-
| ^^^^^^^^^^^^^^^^^^^^^^
326+
| ^^^^^^
327327

328328
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
329329
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:648:1
@@ -940,34 +940,34 @@ LL | #[windows_subsystem = "windows"] impl S { }
940940
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
941941

942942
warning: crate-level attribute should be in the root module
943-
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:632:17
943+
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:632:31
944944
|
945945
LL | mod inner { #![crate_name="0900"] }
946-
| ^^^^^^^^^^^^^^^^^^^^^
946+
| ^^^^^^
947947

948948
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
949-
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:635:5
949+
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:635:20
950950
|
951951
LL | #[crate_name = "0900"] fn f() { }
952-
| ^^^^^^^^^^^^^^^^^^^^^^
952+
| ^^^^^^
953953

954954
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
955-
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:638:5
955+
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:638:20
956956
|
957957
LL | #[crate_name = "0900"] struct S;
958-
| ^^^^^^^^^^^^^^^^^^^^^^
958+
| ^^^^^^
959959

960960
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
961-
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:641:5
961+
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:641:20
962962
|
963963
LL | #[crate_name = "0900"] type T = S;
964-
| ^^^^^^^^^^^^^^^^^^^^^^
964+
| ^^^^^^
965965

966966
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
967-
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:644:5
967+
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:644:20
968968
|
969969
LL | #[crate_name = "0900"] impl S { }
970-
| ^^^^^^^^^^^^^^^^^^^^^^
970+
| ^^^^^^
971971

972972
warning: crate-level attribute should be in the root module
973973
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:651:17

‎tests/ui/invalid-compile-flags/print-crate-name-request-malformed-crate-name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
// See also <https://github.com/rust-lang/rust/issues/122001>.
33

44
//@ compile-flags: --print=crate-name
5-
#![crate_name = concat!("wrapped")] //~ ERROR malformed `crate_name` attribute input
5+
#![crate_name = concat!("wrapped")] //~ ERROR expected a quoted string literal
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error: malformed `crate_name` attribute input
1+
error[E0539]: expected a quoted string literal
22
--> $DIR/print-crate-name-request-malformed-crate-name.rs:5:1
33
|
44
LL | #![crate_name = concat!("wrapped")]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error: aborting due to 1 previous error
88

9+
For more information about this error, try `rustc --explain E0539`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print_crate_name_request_malformed_crate_name
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Ensure we validate `#![crate_name]` on print requests.
22

33
//@ compile-flags: --print=file-names
4-
#![crate_name] //~ ERROR malformed `crate_name` attribute input
4+
#![crate_name] //~ ERROR malformed `crate_name` attribute: expected to be of the form `#[crate_name = ...]`
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error: malformed `crate_name` attribute input
1+
error[E0539]: malformed `crate_name` attribute: expected to be of the form `#[crate_name = ...]`
22
--> $DIR/print-file-names-request-malformed-crate-name-1.rs:4:1
33
|
44
LL | #![crate_name]
5-
| ^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]`
5+
| ^^^^^^^^^^^^^^
66

77
error: aborting due to 1 previous error
88

9+
For more information about this error, try `rustc --explain E0539`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print-file-names-request-malformed-crate-name-1

‎tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-2.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
// See also <https://github.com/rust-lang/rust/issues/122001>.
44

55
//@ compile-flags: --print=file-names
6-
#![crate_name = "this_one_is_okay"]
7-
#![crate_name = concat!("this_one_is_not")] //~ ERROR malformed `crate_name` attribute input
6+
#![crate_name = concat!("this_one_is_not")] //~ ERROR expected a quoted string literal
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error: malformed `crate_name` attribute input
2-
--> $DIR/print-file-names-request-malformed-crate-name-2.rs:7:1
1+
error[E0539]: expected a quoted string literal
2+
--> $DIR/print-file-names-request-malformed-crate-name-2.rs:6:1
33
|
44
LL | #![crate_name = concat!("this_one_is_not")]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error: aborting due to 1 previous error
88

9+
For more information about this error, try `rustc --explain E0539`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print-file-names-request-malformed-crate-name-2
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Ensure that we validate *all* `#![crate_name]`s on print requests, not just the first,
2+
// and that we reject macro calls inside of them.
3+
// See also <https://github.com/rust-lang/rust/issues/122001>.
4+
5+
//@check-pass
6+
//@ compile-flags: --print=file-names
7+
#![crate_name = "this_one_is_okay"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
this_one_is_okay

‎tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
// See also <https://github.com/rust-lang/rust/issues/122001>.
33

44
//@ compile-flags: --print=file-names
5-
#![crate_name = concat!("wrapped")] //~ ERROR malformed `crate_name` attribute input
5+
#![crate_name = concat!("wrapped")] //~ ERROR expected a quoted string literal
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error: malformed `crate_name` attribute input
1+
error[E0539]: expected a quoted string literal
22
--> $DIR/print-file-names-request-malformed-crate-name.rs:5:1
33
|
44
LL | #![crate_name = concat!("wrapped")]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error: aborting due to 1 previous error
88

9+
For more information about this error, try `rustc --explain E0539`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print-file-names-request-malformed-crate-name

‎tests/ui/lint/unused/unused-attr-duplicate.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
// - no_main: extra setup
1212
#![deny(unused_attributes)]
1313
#![crate_name = "unused_attr_duplicate"]
14-
#![crate_name = "unused_attr_duplicate2"] //~ ERROR unused attribute
15-
//~^ WARN this was previously accepted
14+
#![crate_name = "unused_attr_duplicate2"] //~ ERROR multiple `crate_name` attributes
15+
//~^ ERROR multiple `crate_name` attributes
16+
// FIXME(jdonszelmann) this error is given twice now. I'll fix this in the near future redoing how
17+
// duplicates are checked.
1618
#![recursion_limit = "128"]
1719
#![recursion_limit = "256"] //~ ERROR unused attribute
1820
//~^ WARN this was previously accepted
Lines changed: 70 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
1+
error: multiple `crate_name` attributes
2+
--> $DIR/unused-attr-duplicate.rs:14:1
3+
|
4+
LL | #![crate_name = "unused_attr_duplicate2"]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
6+
|
7+
note: attribute also specified here
8+
--> $DIR/unused-attr-duplicate.rs:13:1
9+
|
10+
LL | #![crate_name = "unused_attr_duplicate"]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: multiple `crate_name` attributes
14+
--> $DIR/unused-attr-duplicate.rs:14:1
15+
|
16+
LL | #![crate_name = "unused_attr_duplicate2"]
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
18+
|
19+
note: attribute also specified here
20+
--> $DIR/unused-attr-duplicate.rs:13:1
21+
|
22+
LL | #![crate_name = "unused_attr_duplicate"]
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
25+
126
error: unused attribute
2-
--> $DIR/unused-attr-duplicate.rs:33:1
27+
--> $DIR/unused-attr-duplicate.rs:35:1
328
|
429
LL | #[no_link]
530
| ^^^^^^^^^^ help: remove this attribute
631
|
732
note: attribute also specified here
8-
--> $DIR/unused-attr-duplicate.rs:32:1
33+
--> $DIR/unused-attr-duplicate.rs:34:1
934
|
1035
LL | #[no_link]
1136
| ^^^^^^^^^^
@@ -16,278 +41,265 @@ LL | #![deny(unused_attributes)]
1641
| ^^^^^^^^^^^^^^^^^
1742

1843
error: unused attribute
19-
--> $DIR/unused-attr-duplicate.rs:37:1
44+
--> $DIR/unused-attr-duplicate.rs:39:1
2045
|
2146
LL | #[macro_use]
2247
| ^^^^^^^^^^^^ help: remove this attribute
2348
|
2449
note: attribute also specified here
25-
--> $DIR/unused-attr-duplicate.rs:36:1
50+
--> $DIR/unused-attr-duplicate.rs:38:1
2651
|
2752
LL | #[macro_use]
2853
| ^^^^^^^^^^^^
2954

3055
error: unused attribute
31-
--> $DIR/unused-attr-duplicate.rs:47:1
56+
--> $DIR/unused-attr-duplicate.rs:49:1
3257
|
3358
LL | #[path = "bar.rs"]
3459
| ^^^^^^^^^^^^^^^^^^ help: remove this attribute
3560
|
3661
note: attribute also specified here
37-
--> $DIR/unused-attr-duplicate.rs:46:1
62+
--> $DIR/unused-attr-duplicate.rs:48:1
3863
|
3964
LL | #[path = "auxiliary/lint_unused_extern_crate.rs"]
4065
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4166
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4267

4368
error: unused attribute
44-
--> $DIR/unused-attr-duplicate.rs:53:1
69+
--> $DIR/unused-attr-duplicate.rs:55:1
4570
|
4671
LL | #[ignore = "some text"]
4772
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
4873
|
4974
note: attribute also specified here
50-
--> $DIR/unused-attr-duplicate.rs:52:1
75+
--> $DIR/unused-attr-duplicate.rs:54:1
5176
|
5277
LL | #[ignore]
5378
| ^^^^^^^^^
5479

5580
error: unused attribute
56-
--> $DIR/unused-attr-duplicate.rs:55:1
81+
--> $DIR/unused-attr-duplicate.rs:57:1
5782
|
5883
LL | #[should_panic(expected = "values don't match")]
5984
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
6085
|
6186
note: attribute also specified here
62-
--> $DIR/unused-attr-duplicate.rs:54:1
87+
--> $DIR/unused-attr-duplicate.rs:56:1
6388
|
6489
LL | #[should_panic]
6590
| ^^^^^^^^^^^^^^^
6691
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
6792

6893
error: unused attribute
69-
--> $DIR/unused-attr-duplicate.rs:60:1
94+
--> $DIR/unused-attr-duplicate.rs:62:1
7095
|
7196
LL | #[must_use = "some message"]
7297
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
7398
|
7499
note: attribute also specified here
75-
--> $DIR/unused-attr-duplicate.rs:59:1
100+
--> $DIR/unused-attr-duplicate.rs:61:1
76101
|
77102
LL | #[must_use]
78103
| ^^^^^^^^^^^
79104
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
80105

81106
error: unused attribute
82-
--> $DIR/unused-attr-duplicate.rs:66:1
107+
--> $DIR/unused-attr-duplicate.rs:68:1
83108
|
84109
LL | #[non_exhaustive]
85110
| ^^^^^^^^^^^^^^^^^ help: remove this attribute
86111
|
87112
note: attribute also specified here
88-
--> $DIR/unused-attr-duplicate.rs:65:1
113+
--> $DIR/unused-attr-duplicate.rs:67:1
89114
|
90115
LL | #[non_exhaustive]
91116
| ^^^^^^^^^^^^^^^^^
92117

93118
error: unused attribute
94-
--> $DIR/unused-attr-duplicate.rs:70:1
119+
--> $DIR/unused-attr-duplicate.rs:72:1
95120
|
96121
LL | #[automatically_derived]
97122
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
98123
|
99124
note: attribute also specified here
100-
--> $DIR/unused-attr-duplicate.rs:69:1
125+
--> $DIR/unused-attr-duplicate.rs:71:1
101126
|
102127
LL | #[automatically_derived]
103128
| ^^^^^^^^^^^^^^^^^^^^^^^^
104129

105130
error: unused attribute
106-
--> $DIR/unused-attr-duplicate.rs:74:1
131+
--> $DIR/unused-attr-duplicate.rs:76:1
107132
|
108133
LL | #[inline(never)]
109134
| ^^^^^^^^^^^^^^^^ help: remove this attribute
110135
|
111136
note: attribute also specified here
112-
--> $DIR/unused-attr-duplicate.rs:73:1
137+
--> $DIR/unused-attr-duplicate.rs:75:1
113138
|
114139
LL | #[inline(always)]
115140
| ^^^^^^^^^^^^^^^^^
116141
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
117142

118143
error: unused attribute
119-
--> $DIR/unused-attr-duplicate.rs:77:1
144+
--> $DIR/unused-attr-duplicate.rs:79:1
120145
|
121146
LL | #[cold]
122147
| ^^^^^^^ help: remove this attribute
123148
|
124149
note: attribute also specified here
125-
--> $DIR/unused-attr-duplicate.rs:76:1
150+
--> $DIR/unused-attr-duplicate.rs:78:1
126151
|
127152
LL | #[cold]
128153
| ^^^^^^^
129154

130155
error: unused attribute
131-
--> $DIR/unused-attr-duplicate.rs:79:1
156+
--> $DIR/unused-attr-duplicate.rs:81:1
132157
|
133158
LL | #[track_caller]
134159
| ^^^^^^^^^^^^^^^ help: remove this attribute
135160
|
136161
note: attribute also specified here
137-
--> $DIR/unused-attr-duplicate.rs:78:1
162+
--> $DIR/unused-attr-duplicate.rs:80:1
138163
|
139164
LL | #[track_caller]
140165
| ^^^^^^^^^^^^^^^
141166

142167
error: unused attribute
143-
--> $DIR/unused-attr-duplicate.rs:92:1
168+
--> $DIR/unused-attr-duplicate.rs:94:1
144169
|
145170
LL | #[export_name = "exported_symbol_name"]
146171
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
147172
|
148173
note: attribute also specified here
149-
--> $DIR/unused-attr-duplicate.rs:94:1
174+
--> $DIR/unused-attr-duplicate.rs:96:1
150175
|
151176
LL | #[export_name = "exported_symbol_name2"]
152177
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
153178
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
154179

155180
error: unused attribute
156-
--> $DIR/unused-attr-duplicate.rs:98:1
181+
--> $DIR/unused-attr-duplicate.rs:100:1
157182
|
158183
LL | #[no_mangle]
159184
| ^^^^^^^^^^^^ help: remove this attribute
160185
|
161186
note: attribute also specified here
162-
--> $DIR/unused-attr-duplicate.rs:97:1
187+
--> $DIR/unused-attr-duplicate.rs:99:1
163188
|
164189
LL | #[no_mangle]
165190
| ^^^^^^^^^^^^
166191

167192
error: unused attribute
168-
--> $DIR/unused-attr-duplicate.rs:102:1
193+
--> $DIR/unused-attr-duplicate.rs:104:1
169194
|
170195
LL | #[used]
171196
| ^^^^^^^ help: remove this attribute
172197
|
173198
note: attribute also specified here
174-
--> $DIR/unused-attr-duplicate.rs:101:1
199+
--> $DIR/unused-attr-duplicate.rs:103:1
175200
|
176201
LL | #[used]
177202
| ^^^^^^^
178203

179204
error: unused attribute
180-
--> $DIR/unused-attr-duplicate.rs:86:5
205+
--> $DIR/unused-attr-duplicate.rs:88:5
181206
|
182207
LL | #[link_name = "this_does_not_exist"]
183208
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
184209
|
185210
note: attribute also specified here
186-
--> $DIR/unused-attr-duplicate.rs:88:5
211+
--> $DIR/unused-attr-duplicate.rs:90:5
187212
|
188213
LL | #[link_name = "rust_dbg_extern_identity_u32"]
189214
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
190215
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
191216

192217
error: unused attribute
193-
--> $DIR/unused-attr-duplicate.rs:14:1
194-
|
195-
LL | #![crate_name = "unused_attr_duplicate2"]
196-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
197-
|
198-
note: attribute also specified here
199-
--> $DIR/unused-attr-duplicate.rs:13:1
200-
|
201-
LL | #![crate_name = "unused_attr_duplicate"]
202-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
203-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
204-
205-
error: unused attribute
206-
--> $DIR/unused-attr-duplicate.rs:17:1
218+
--> $DIR/unused-attr-duplicate.rs:19:1
207219
|
208220
LL | #![recursion_limit = "256"]
209221
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
210222
|
211223
note: attribute also specified here
212-
--> $DIR/unused-attr-duplicate.rs:16:1
224+
--> $DIR/unused-attr-duplicate.rs:18:1
213225
|
214226
LL | #![recursion_limit = "128"]
215227
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
216228
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
217229

218230
error: unused attribute
219-
--> $DIR/unused-attr-duplicate.rs:20:1
231+
--> $DIR/unused-attr-duplicate.rs:22:1
220232
|
221233
LL | #![type_length_limit = "1"]
222234
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
223235
|
224236
note: attribute also specified here
225-
--> $DIR/unused-attr-duplicate.rs:19:1
237+
--> $DIR/unused-attr-duplicate.rs:21:1
226238
|
227239
LL | #![type_length_limit = "1048576"]
228240
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
229241
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
230242

231243
error: unused attribute
232-
--> $DIR/unused-attr-duplicate.rs:23:1
244+
--> $DIR/unused-attr-duplicate.rs:25:1
233245
|
234246
LL | #![no_std]
235247
| ^^^^^^^^^^ help: remove this attribute
236248
|
237249
note: attribute also specified here
238-
--> $DIR/unused-attr-duplicate.rs:22:1
250+
--> $DIR/unused-attr-duplicate.rs:24:1
239251
|
240252
LL | #![no_std]
241253
| ^^^^^^^^^^
242254

243255
error: unused attribute
244-
--> $DIR/unused-attr-duplicate.rs:25:1
256+
--> $DIR/unused-attr-duplicate.rs:27:1
245257
|
246258
LL | #![no_implicit_prelude]
247259
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
248260
|
249261
note: attribute also specified here
250-
--> $DIR/unused-attr-duplicate.rs:24:1
262+
--> $DIR/unused-attr-duplicate.rs:26:1
251263
|
252264
LL | #![no_implicit_prelude]
253265
| ^^^^^^^^^^^^^^^^^^^^^^^
254266

255267
error: unused attribute
256-
--> $DIR/unused-attr-duplicate.rs:27:1
268+
--> $DIR/unused-attr-duplicate.rs:29:1
257269
|
258270
LL | #![windows_subsystem = "windows"]
259271
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
260272
|
261273
note: attribute also specified here
262-
--> $DIR/unused-attr-duplicate.rs:26:1
274+
--> $DIR/unused-attr-duplicate.rs:28:1
263275
|
264276
LL | #![windows_subsystem = "console"]
265277
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
266278
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
267279

268280
error: unused attribute
269-
--> $DIR/unused-attr-duplicate.rs:30:1
281+
--> $DIR/unused-attr-duplicate.rs:32:1
270282
|
271283
LL | #![no_builtins]
272284
| ^^^^^^^^^^^^^^^ help: remove this attribute
273285
|
274286
note: attribute also specified here
275-
--> $DIR/unused-attr-duplicate.rs:29:1
287+
--> $DIR/unused-attr-duplicate.rs:31:1
276288
|
277289
LL | #![no_builtins]
278290
| ^^^^^^^^^^^^^^^
279291

280292
error: unused attribute
281-
--> $DIR/unused-attr-duplicate.rs:40:5
293+
--> $DIR/unused-attr-duplicate.rs:42:5
282294
|
283295
LL | #[macro_export]
284296
| ^^^^^^^^^^^^^^^ help: remove this attribute
285297
|
286298
note: attribute also specified here
287-
--> $DIR/unused-attr-duplicate.rs:39:5
299+
--> $DIR/unused-attr-duplicate.rs:41:5
288300
|
289301
LL | #[macro_export]
290302
| ^^^^^^^^^^^^^^^
291303

292-
error: aborting due to 23 previous errors
304+
error: aborting due to 24 previous errors
293305

0 commit comments

Comments
 (0)
Please sign in to comment.