diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index d9ad335b585e2..a6e88f21ba74f 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -519,34 +519,13 @@ impl<'a> AstValidator<'a> { } fn check_decl_attrs(&self, fn_inputs: &[Param]) { - use SyntheticAttr::*; - fn_inputs - .iter() - .flat_map(|i| i.attrs.as_ref()) - .filter(|attr| match &attr.kind { - AttrKind::Normal(normal) => { - let arr = [ - sym::allow, - sym::deny, - sym::expect, - sym::forbid, - sym::rustc_splat, - sym::warn, - ]; - !attr.has_any_name(&arr) && rustc_attr_parsing::is_builtin_attr(&normal.item) - } - AttrKind::Synthetic(CfgTrace(_) | CfgAttrTrace(_)) | AttrKind::Generated(..) => { - false - } - AttrKind::DocComment(..) => true, - }) - .for_each(|attr| { + for param in fn_inputs { + for attr in ¶m.attrs { if attr.is_doc_comment() { self.dcx().emit_err(diagnostics::FnParamDocComment { span: attr.span }); - } else { - self.dcx().emit_err(diagnostics::FnParamForbiddenAttr { span: attr.span }); } - }); + } + } } fn check_decl_self_param(&self, fn_inputs: &[Param], self_semantic: SelfSemantic) { diff --git a/compiler/rustc_ast_passes/src/diagnostics.rs b/compiler/rustc_ast_passes/src/diagnostics.rs index 452a22f857455..e0efe2f91ce06 100644 --- a/compiler/rustc_ast_passes/src/diagnostics.rs +++ b/compiler/rustc_ast_passes/src/diagnostics.rs @@ -201,16 +201,6 @@ pub(crate) struct FnParamDocComment { pub span: Span, } -// FIXME(splat): add splat to the allowed built-in attributes when it is complete/stabilized -#[derive(Diagnostic)] -#[diag( - "allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters" -)] -pub(crate) struct FnParamForbiddenAttr { - #[primary_span] - pub span: Span, -} - #[derive(Diagnostic)] #[diag("`#[{$eii_name}]` is not allowed to have `#[{$attr_name}]`")] pub(crate) struct EiiImplAttributeNotSupported<'a> { diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index 0adc5751373b6..e88b1751e4b6c 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -61,6 +61,7 @@ impl NoArgsAttributeParser for ColdParser { Allow(Target::Method(MethodKind::Inherent)), Allow(Target::ForeignFn), Allow(Target::Closure), + Error(Target::Param), ]); const STABILITY: AttributeStability = AttributeStability::Stable; const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::Cold; @@ -428,6 +429,7 @@ impl NoArgsAttributeParser for NoMangleParser { Allow(Target::Method(MethodKind::TraitImpl)), AllowSilent(Target::Const), // Handled in the `InvalidNoMangleItems` pass Error(Target::Closure), + Error(Target::Param), ]); const STABILITY: AttributeStability = AttributeStability::Stable; const CREATE: fn(Span) -> AttributeKind = AttributeKind::NoMangle; diff --git a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs index 3a1c7858f030b..4f86895bbd02b 100644 --- a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs +++ b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs @@ -18,7 +18,7 @@ impl SingleAttributeParser for CrateNameParser { const ON_DUPLICATE: OnDuplicate = OnDuplicate::WarnButFutureError; const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name"); const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]); + AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]); const STABILITY: AttributeStability = AttributeStability::Stable; fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { @@ -37,7 +37,7 @@ impl CombineAttributeParser for CrateTypeParser { type Item = CrateType; const CONVERT: ConvertFn = |items, _| AttributeKind::CrateType(items); const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]); + AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]); const TEMPLATE: AttributeTemplate = template!(NameValueStr: "crate type", "https://doc.rust-lang.org/reference/linkage.html"); const STABILITY: AttributeStability = AttributeStability::Stable; @@ -81,7 +81,7 @@ impl SingleAttributeParser for RecursionLimitParser { const ON_DUPLICATE: OnDuplicate = OnDuplicate::WarnButFutureError; const TEMPLATE: AttributeTemplate = template!(NameValueStr: "N", "https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute"); const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]); + AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]); const STABILITY: AttributeStability = AttributeStability::Stable; fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { @@ -113,7 +113,7 @@ impl SingleAttributeParser for TypeLengthLimitParser { const ON_DUPLICATE: OnDuplicate = OnDuplicate::WarnButFutureError; const TEMPLATE: AttributeTemplate = template!(NameValueStr: "N"); const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]); + AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]); const STABILITY: AttributeStability = AttributeStability::Stable; fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { @@ -156,7 +156,7 @@ impl NoArgsAttributeParser for NoStdParser { const PATH: &[Symbol] = &[sym::no_std]; const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]); + AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]); const STABILITY: AttributeStability = AttributeStability::Stable; const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NoStd; } @@ -167,7 +167,7 @@ impl NoArgsAttributeParser for NoMainParser { const PATH: &[Symbol] = &[sym::no_main]; const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]); + AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]); const STABILITY: AttributeStability = AttributeStability::Stable; const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NoMain; } @@ -187,7 +187,7 @@ impl SingleAttributeParser for WindowsSubsystemParser { const PATH: &[Symbol] = &[sym::windows_subsystem]; const ON_DUPLICATE: OnDuplicate = OnDuplicate::WarnButFutureError; const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]); + AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]); const TEMPLATE: AttributeTemplate = template!(NameValueStr: ["windows", "console"], "https://doc.rust-lang.org/reference/runtime.html#the-windows_subsystem-attribute"); const STABILITY: AttributeStability = AttributeStability::Stable; @@ -243,7 +243,7 @@ impl NoArgsAttributeParser for NoBuiltinsParser { const PATH: &[Symbol] = &[sym::no_builtins]; const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]); + AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]); const STABILITY: AttributeStability = AttributeStability::Stable; const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NoBuiltins; } @@ -282,7 +282,7 @@ impl CombineAttributeParser for FeatureParser { type Item = Ident; const CONVERT: ConvertFn = AttributeKind::Feature; const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]); + AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]); const TEMPLATE: AttributeTemplate = template!(List: &["feature1, feature2, ..."]); const STABILITY: AttributeStability = AttributeStability::Stable; diff --git a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs index 084a20b74347d..da0af9496167d 100644 --- a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs +++ b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs @@ -63,6 +63,7 @@ impl SingleAttributeParser for DeprecatedParser { Allow(Target::Impl { of_trait: false }), Allow(Target::Crate), Error(Target::WherePredicate), + Error(Target::Param), ]); const TEMPLATE: AttributeTemplate = template!( Word, diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index bcc4b71b0ca23..aefbffa7a99e1 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -15,7 +15,7 @@ use super::{AcceptMapping, AttributeParser, template}; use crate::context::{AcceptContext, FinalizeContext}; use crate::diagnostics::{ DocAliasBadChar, DocAliasDuplicated, DocAliasEmpty, DocAliasMalformed, DocAliasStartEnd, - DocAttrNotCrateLevel, DocAttrNotTraitLevel, DocAttributeNotAttribute, + DocAttrNotCrateLevel, DocAttrNotParameters, DocAttrNotTraitLevel, DocAttributeNotAttribute, DocAutoCfgExpectsHideOrShow, DocAutoCfgHideShowExpectsList, DocAutoCfgHideShowNoIdentBeforeValues, DocAutoCfgHideShowUnexpectedItem, DocAutoCfgHideShowUnexpectedItemAfterValues, DocAutoCfgHideShowValuesMix, @@ -28,7 +28,7 @@ use crate::diagnostics::{ use crate::parser::{ ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser, }; -use crate::target_checking::Policy::Allow; +use crate::target_checking::Policy::{Allow, AllowSilent}; fn check_keyword(cx: &mut AcceptContext<'_, '_>, keyword: Symbol, span: Span) -> bool { // FIXME: Once rustdoc can handle URL conflicts on case insensitive file systems, we @@ -244,7 +244,10 @@ impl DocParser { cx.check_target( sym::no_crate_inject.as_str(), - &AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]), + &AllowedTargets::AllowListWarnRest(&[ + Allow(Target::Crate), + AllowSilent(Target::Param), + ]), ); self.attribute.no_crate_inject = Some(path.span()) @@ -356,7 +359,7 @@ impl DocParser { } match cx.target { - Target::Use | Target::ExternCrate => {} + Target::Use | Target::ExternCrate | Target::Param => {} // Param has a custom error _ => { let item_span = cx.target_span; cx.emit_lint( @@ -634,7 +637,10 @@ impl DocParser { let span = path.span(); cx.check_target( concat!("(", stringify!($ident), ")"), - &AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]), + &AllowedTargets::AllowListWarnRest(&[ + Allow(Target::Crate), + AllowSilent(Target::Param), // Param has a custom error + ]), ); self.attribute.$ident = Some(span); }}; @@ -653,7 +659,10 @@ impl DocParser { cx.check_target( s.as_str(), - &AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]), + &AllowedTargets::AllowListWarnRest(&[ + Allow(Target::Crate), + AllowSilent(Target::Param), // Param has a custom error + ]), ); // FIXME: It's errorring when the attribute is passed multiple times on the command @@ -814,6 +823,9 @@ impl DocParser { } fn accept_single_doc_attr(&mut self, cx: &mut AcceptContext<'_, '_>, args: &ArgParser) { + if cx.shared.target == Target::Param { + cx.emit_err(DocAttrNotParameters { span: cx.attr_span }); + } match args { ArgParser::List(items) if !items.is_empty() => { for i in items.mixed() { diff --git a/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs b/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs index 6c470f0587732..05c69c3baa180 100644 --- a/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs +++ b/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs @@ -14,6 +14,7 @@ impl SingleAttributeParser for InstructionSetParser { Allow(Target::Method(MethodKind::Inherent)), Allow(Target::Method(MethodKind::TraitImpl)), Allow(Target::Method(MethodKind::Trait { body: true })), + Error(Target::Param), ]); const TEMPLATE: AttributeTemplate = template!(List: &["set"], "https://doc.rust-lang.org/reference/attributes/codegen.html#the-instruction_set-attribute"); const STABILITY: AttributeStability = AttributeStability::Stable; diff --git a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs index d5b2f7accb621..64290871f2743 100644 --- a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs @@ -32,6 +32,7 @@ impl SingleAttributeParser for LinkNameParser { const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowListWarnRest(&[ Allow(Target::ForeignFn), Allow(Target::ForeignStatic), + Error(Target::Param), ]); const TEMPLATE: AttributeTemplate = template!( NameValueStr: "name", @@ -74,7 +75,7 @@ impl CombineAttributeParser for LinkParser { r#"name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated""#, ], "https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute"); const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::ForeignMod)]); + AllowedTargets::AllowListWarnRest(&[Allow(Target::ForeignMod), Error(Target::Param)]); const STABILITY: AttributeStability = AttributeStability::Stable; fn extend( @@ -527,6 +528,7 @@ impl SingleAttributeParser for LinkSectionParser { Allow(Target::Method(MethodKind::Inherent)), Allow(Target::Method(MethodKind::Trait { body: true })), Allow(Target::Method(MethodKind::TraitImpl)), + Error(Target::Param), ]); const TEMPLATE: AttributeTemplate = template!( NameValueStr: "name", diff --git a/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs b/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs index 10e42ced30705..a4f2e52d3f2f7 100644 --- a/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs +++ b/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs @@ -72,6 +72,7 @@ impl NoArgsAttributeParser for AutomaticallyDerivedParser { Allow(Target::Impl { of_trait: true }), Error(Target::Crate), Error(Target::WherePredicate), + Error(Target::Param), ]); const STABILITY: AttributeStability = AttributeStability::Stable; const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::AutomaticallyDerived; diff --git a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs index 8a0c31400b100..0e7e1e36faf08 100644 --- a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs @@ -39,6 +39,7 @@ const MACRO_USE_ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowListW Allow(Target::Mod), Allow(Target::ExternCrate), Error(Target::WherePredicate), + Error(Target::Param), ]); impl AttributeParser for MacroUseParser { @@ -152,6 +153,7 @@ impl SingleAttributeParser for MacroExportParser { Allow(Target::MacroDef), Error(Target::WherePredicate), Error(Target::Crate), + Error(Target::Param), ]); const STABILITY: AttributeStability = AttributeStability::Stable; diff --git a/compiler/rustc_attr_parsing/src/attributes/must_use.rs b/compiler/rustc_attr_parsing/src/attributes/must_use.rs index 62e75a2e7afd9..a093fe0ce53b2 100644 --- a/compiler/rustc_attr_parsing/src/attributes/must_use.rs +++ b/compiler/rustc_attr_parsing/src/attributes/must_use.rs @@ -21,6 +21,7 @@ impl SingleAttributeParser for MustUseParser { // `#[must_use]` Allow(Target::Trait), Error(Target::WherePredicate), + Error(Target::Param), ]); const TEMPLATE: AttributeTemplate = template!( Word, NameValueStr: "reason", diff --git a/compiler/rustc_attr_parsing/src/attributes/no_implicit_prelude.rs b/compiler/rustc_attr_parsing/src/attributes/no_implicit_prelude.rs index 34ceca9092036..807bb1202c56c 100644 --- a/compiler/rustc_attr_parsing/src/attributes/no_implicit_prelude.rs +++ b/compiler/rustc_attr_parsing/src/attributes/no_implicit_prelude.rs @@ -7,8 +7,11 @@ pub(crate) struct NoImplicitPreludeParser; impl NoArgsAttributeParser for NoImplicitPreludeParser { const PATH: &[rustc_span::Symbol] = &[sym::no_implicit_prelude]; const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; - const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Mod), Allow(Target::Crate)]); + const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowListWarnRest(&[ + Allow(Target::Mod), + Allow(Target::Crate), + Error(Target::Param), + ]); const STABILITY: AttributeStability = AttributeStability::Stable; const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NoImplicitPrelude; } diff --git a/compiler/rustc_attr_parsing/src/attributes/path.rs b/compiler/rustc_attr_parsing/src/attributes/path.rs index a44414f5aead2..9b9abdda97f5f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/path.rs +++ b/compiler/rustc_attr_parsing/src/attributes/path.rs @@ -7,8 +7,11 @@ pub(crate) struct PathParser; impl SingleAttributeParser for PathParser { const PATH: &[Symbol] = &[sym::path]; const ON_DUPLICATE: OnDuplicate = OnDuplicate::WarnButFutureError; - const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Mod), Error(Target::Crate)]); + const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowListWarnRest(&[ + Allow(Target::Mod), + Error(Target::Crate), + Error(Target::Param), + ]); const TEMPLATE: AttributeTemplate = template!( NameValueStr: "file", "https://doc.rust-lang.org/reference/items/modules.html#the-path-attribute" diff --git a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs index 9f2f7613b1c27..d9b2b38f55cc0 100644 --- a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs @@ -9,8 +9,11 @@ pub(crate) struct IgnoreParser; impl SingleAttributeParser for IgnoreParser { const PATH: &[Symbol] = &[sym::ignore]; const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; - const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Fn), Error(Target::WherePredicate)]); + const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowListWarnRest(&[ + Allow(Target::Fn), + Error(Target::WherePredicate), + Error(Target::Param), + ]); const TEMPLATE: AttributeTemplate = template!( Word, NameValueStr: "reason", "https://doc.rust-lang.org/reference/attributes/testing.html#the-ignore-attribute" @@ -51,8 +54,11 @@ pub(crate) struct ShouldPanicParser; impl SingleAttributeParser for ShouldPanicParser { const PATH: &[Symbol] = &[sym::should_panic]; const ON_DUPLICATE: OnDuplicate = OnDuplicate::WarnButFutureError; - const ALLOWED_TARGETS: AllowedTargets<'_> = - AllowedTargets::AllowListWarnRest(&[Allow(Target::Fn), Error(Target::WherePredicate)]); + const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowListWarnRest(&[ + Allow(Target::Fn), + Error(Target::WherePredicate), + Error(Target::Param), + ]); const TEMPLATE: AttributeTemplate = template!( Word, List: &[r#"expected = "reason""#], NameValueStr: "reason", "https://doc.rust-lang.org/reference/attributes/testing.html#the-should_panic-attribute" diff --git a/compiler/rustc_attr_parsing/src/diagnostics.rs b/compiler/rustc_attr_parsing/src/diagnostics.rs index 4059114456431..4f0e6312b6683 100644 --- a/compiler/rustc_attr_parsing/src/diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/diagnostics.rs @@ -1041,6 +1041,13 @@ pub(crate) struct DocAttrNotCrateLevel { pub attr_name: Symbol, } +#[derive(Diagnostic)] +#[diag("`#[doc(...)]` isn't allowed on parameters")] +pub(crate) struct DocAttrNotParameters { + #[primary_span] + pub span: Span, +} + #[derive(Diagnostic)] #[diag("nonexistent keyword `{$keyword}` used in `#[doc(keyword = \"...\")]`")] #[help("only existing keywords are allowed in core/std")] diff --git a/compiler/rustc_attr_parsing/src/target_checking.rs b/compiler/rustc_attr_parsing/src/target_checking.rs index 3f0097eab0515..58ba6d4cc717b 100644 --- a/compiler/rustc_attr_parsing/src/target_checking.rs +++ b/compiler/rustc_attr_parsing/src/target_checking.rs @@ -113,12 +113,11 @@ impl<'sess> AttributeParser<'sess> { // For crate-level attributes we emit a specific set of lints to warn // people about accidentally not using them on the crate. - if let &AllowedTargets::AllowList(&[Allow(Target::Crate)]) = allowed_targets { - Self::check_crate_level(cx, false); - return; - } - if let &AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate)]) = allowed_targets { - Self::check_crate_level(cx, true); + if let AllowedTargets::AllowList(policies) | AllowedTargets::AllowListWarnRest(policies) = allowed_targets + // If only crate is `Allow` + && policies.iter().filter(|p| matches!(p, Allow(_))).all(|p| *p == Allow(Target::Crate)) + { + Self::check_crate_level(cx, allowed_targets); return; } @@ -220,10 +219,15 @@ impl<'sess> AttributeParser<'sess> { } } - pub(crate) fn check_crate_level(cx: &mut AcceptContext<'_, 'sess>, warn: bool) { - if cx.target == Target::Crate { - return; - } + pub(crate) fn check_crate_level( + cx: &mut AcceptContext<'_, 'sess>, + allowed_targets: &AllowedTargets<'_>, + ) { + let warn = match allowed_targets.is_allowed(cx.target) { + AllowedResult::Allowed => return, + AllowedResult::Warn => true, + AllowedResult::Error => false, + }; let name = cx.attr_path.to_string(); let is_used_as_inner = cx.attr_style == AttrStyle::Inner; diff --git a/tests/ui/attributes/attrs-on-params.rs b/tests/ui/attributes/attrs-on-params.rs index e12ff906fa3f5..63a9153e3f132 100644 --- a/tests/ui/attributes/attrs-on-params.rs +++ b/tests/ui/attributes/attrs-on-params.rs @@ -2,7 +2,6 @@ fn function(#[inline] param: u32) { //~^ ERROR attribute cannot be used on - //~| ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes } trait Test { diff --git a/tests/ui/attributes/attrs-on-params.stderr b/tests/ui/attributes/attrs-on-params.stderr index 7397b0a677310..70444c26ec24d 100644 --- a/tests/ui/attributes/attrs-on-params.stderr +++ b/tests/ui/attributes/attrs-on-params.stderr @@ -1,9 +1,3 @@ -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/attrs-on-params.rs:3:13 - | -LL | fn function(#[inline] param: u32) { - | ^^^^^^^^^ - error: the `inline` attribute cannot be used on function params --> $DIR/attrs-on-params.rs:3:15 | @@ -13,7 +7,7 @@ LL | fn function(#[inline] param: u32) { = help: the `inline` attribute can only be applied to functions error[E0658]: the `rustc_splat` attribute is an experimental feature - --> $DIR/attrs-on-params.rs:10:11 + --> $DIR/attrs-on-params.rs:9:11 | LL | #[rustc_splat] a1: u32, | ^^^^^^^^^^^ @@ -23,7 +17,7 @@ LL | #[rustc_splat] a1: u32, = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the `rustc_splat` attribute is an experimental feature - --> $DIR/attrs-on-params.rs:14:11 + --> $DIR/attrs-on-params.rs:13:11 | LL | #[rustc_splat(invalid)] a4: u32, | ^^^^^^^^^^^ @@ -33,7 +27,7 @@ LL | #[rustc_splat(invalid)] a4: u32, = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0565]: malformed `rustc_splat` attribute input - --> $DIR/attrs-on-params.rs:14:11 + --> $DIR/attrs-on-params.rs:13:11 | LL | #[rustc_splat(invalid)] a4: u32, | ^^^^^^^^^^^--------- @@ -47,7 +41,7 @@ LL + #[rustc_splat] a4: u32, | error[E0658]: the `rustc_splat` attribute is an experimental feature - --> $DIR/attrs-on-params.rs:21:7 + --> $DIR/attrs-on-params.rs:20:7 | LL | #[rustc_splat] a1: u32, | ^^^^^^^^^^^ @@ -57,7 +51,7 @@ LL | #[rustc_splat] a1: u32, = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the `rustc_splat` attribute is an experimental feature - --> $DIR/attrs-on-params.rs:27:11 + --> $DIR/attrs-on-params.rs:26:11 | LL | #[rustc_splat] a1: u32, | ^^^^^^^^^^^ @@ -66,7 +60,7 @@ LL | #[rustc_splat] a1: u32, = help: add `#![feature(splat)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0565, E0658. For more information about an error, try `rustc --explain E0565`. diff --git a/tests/ui/fn/fn-trait-use-named-params-issue-140169.rs b/tests/ui/fn/fn-trait-use-named-params-issue-140169.rs index cc189bfec26eb..6dfb810806388 100644 --- a/tests/ui/fn/fn-trait-use-named-params-issue-140169.rs +++ b/tests/ui/fn/fn-trait-use-named-params-issue-140169.rs @@ -11,7 +11,6 @@ fn f6(f: impl Fn(#[cfg(false)] u8)) { f() } //~ ERROR parameters in parenthesize fn f7(_: impl Fn(#[inline] u8)) {} //~^ ERROR parameters in parenthesized generic argument lists with names, attributes, or c-variadics are experimental //~| ERROR the `inline` attribute cannot be used on function params -//~| ERROR: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters fn f8(_: impl Fn(u8, #[allow(unused_attributes)] u8)) {} //~^ ERROR parameters in parenthesized generic argument lists with names, attributes, or c-variadics are experimental diff --git a/tests/ui/fn/fn-trait-use-named-params-issue-140169.stderr b/tests/ui/fn/fn-trait-use-named-params-issue-140169.stderr index a494f8adfb7fc..77fe260d62d4c 100644 --- a/tests/ui/fn/fn-trait-use-named-params-issue-140169.stderr +++ b/tests/ui/fn/fn-trait-use-named-params-issue-140169.stderr @@ -4,12 +4,6 @@ error: C-variadic parameters aren't allowed in parenthesized argument lists LL | fn f5(_: impl Fn(u8, ...)) {} | ^^^ help: remove the C-variadics -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/fn-trait-use-named-params-issue-140169.rs:11:18 - | -LL | fn f7(_: impl Fn(#[inline] u8)) {} - | ^^^^^^^^^ - error[E0658]: parameters in parenthesized generic argument lists with names, attributes, or c-variadics are experimental --> $DIR/fn-trait-use-named-params-issue-140169.rs:2:22 | @@ -81,7 +75,7 @@ LL | fn f7(_: impl Fn(#[inline] u8)) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: parameters in parenthesized generic argument lists with names, attributes, or c-variadics are experimental - --> $DIR/fn-trait-use-named-params-issue-140169.rs:15:22 + --> $DIR/fn-trait-use-named-params-issue-140169.rs:14:22 | LL | fn f8(_: impl Fn(u8, #[allow(unused_attributes)] u8)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -98,6 +92,6 @@ LL | fn f7(_: impl Fn(#[inline] u8)) {} | = help: the `inline` attribute can only be applied to functions -error: aborting due to 11 previous errors +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/fn/fn-trait-use-named-params.rs b/tests/ui/fn/fn-trait-use-named-params.rs index 0f1e1a73cb1d2..85588f67d18d7 100644 --- a/tests/ui/fn/fn-trait-use-named-params.rs +++ b/tests/ui/fn/fn-trait-use-named-params.rs @@ -3,10 +3,8 @@ fn f1(f: impl Fn(#[cfg(false)] x: u8)) { f() } fn f2(_: impl Fn(#[inline] x: u8)) {} //~^ ERROR the `inline` attribute cannot be used on function params -//~| ERROR: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters fn f3(_: impl Fn(#[cfg_attr(true, inline)] a1: usize)) {} //~^ ERROR the `inline` attribute cannot be used on function params -//~| ERROR: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters fn f4(_: impl Fn(/** */ x: u8)) {} //~^ ERROR documentation comments cannot be applied to function parameters diff --git a/tests/ui/fn/fn-trait-use-named-params.stderr b/tests/ui/fn/fn-trait-use-named-params.stderr index 0942516aa72d9..f184ca8cbf7ed 100644 --- a/tests/ui/fn/fn-trait-use-named-params.stderr +++ b/tests/ui/fn/fn-trait-use-named-params.stderr @@ -1,5 +1,5 @@ error: `gen` is a keyword in the 2024 edition - --> $DIR/fn-trait-use-named-params.rs:14:49 + --> $DIR/fn-trait-use-named-params.rs:12:49 | LL | fn f6(_: impl Fn(#[forbid(keyword_idents_2024)] gen: u8)) {} | ^^^ help: you can use a raw identifier to stay compatible: `r#gen` @@ -7,25 +7,13 @@ LL | fn f6(_: impl Fn(#[forbid(keyword_idents_2024)] gen: u8)) {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! = note: for more information, see note: the lint level is defined here - --> $DIR/fn-trait-use-named-params.rs:14:27 + --> $DIR/fn-trait-use-named-params.rs:12:27 | LL | fn f6(_: impl Fn(#[forbid(keyword_idents_2024)] gen: u8)) {} | ^^^^^^^^^^^^^^^^^^^ -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/fn-trait-use-named-params.rs:4:18 - | -LL | fn f2(_: impl Fn(#[inline] x: u8)) {} - | ^^^^^^^^^ - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/fn-trait-use-named-params.rs:7:35 - | -LL | fn f3(_: impl Fn(#[cfg_attr(true, inline)] a1: usize)) {} - | ^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/fn-trait-use-named-params.rs:10:18 + --> $DIR/fn-trait-use-named-params.rs:8:18 | LL | fn f4(_: impl Fn(/** */ x: u8)) {} | ^^^^^^ doc comments are not allowed here @@ -39,7 +27,7 @@ LL | fn f2(_: impl Fn(#[inline] x: u8)) {} = help: the `inline` attribute can only be applied to functions error: the `inline` attribute cannot be used on function params - --> $DIR/fn-trait-use-named-params.rs:7:35 + --> $DIR/fn-trait-use-named-params.rs:6:35 | LL | fn f3(_: impl Fn(#[cfg_attr(true, inline)] a1: usize)) {} | ^^^^^^ @@ -47,7 +35,7 @@ LL | fn f3(_: impl Fn(#[cfg_attr(true, inline)] a1: usize)) {} = help: the `inline` attribute can only be applied to functions error[E0658]: the `rustc_splat` attribute is an experimental feature - --> $DIR/fn-trait-use-named-params.rs:18:15 + --> $DIR/fn-trait-use-named-params.rs:16:15 | LL | fn f8(_: fn(#[rustc_splat] a: usize)) {} | ^^^^^^^^^^^ @@ -56,6 +44,6 @@ LL | fn f8(_: fn(#[rustc_splat] a: usize)) {} = help: add `#![feature(splat)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/force-inlining/invalid.rs b/tests/ui/force-inlining/invalid.rs index eaacbb502090c..eba31aaef1377 100644 --- a/tests/ui/force-inlining/invalid.rs +++ b/tests/ui/force-inlining/invalid.rs @@ -129,8 +129,7 @@ impl FooBaz for Bar { macro_rules! barqux { ($foo:tt) => { $foo }; } fn barqux(#[rustc_force_inline] _x: u32) {} -//~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters -//~^^ ERROR attribute cannot be used on +//~^ ERROR attribute cannot be used on #[rustc_force_inline] //~^ ERROR attribute cannot be applied to a `async`, `gen` or `async gen` function diff --git a/tests/ui/force-inlining/invalid.stderr b/tests/ui/force-inlining/invalid.stderr index 148df5ddde938..491a6463469b3 100644 --- a/tests/ui/force-inlining/invalid.stderr +++ b/tests/ui/force-inlining/invalid.stderr @@ -1,9 +1,3 @@ -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/invalid.rs:131:11 - | -LL | fn barqux(#[rustc_force_inline] _x: u32) {} - | ^^^^^^^^^^^^^^^^^^^^^ - error[E0805]: malformed `rustc_force_inline` attribute input --> $DIR/invalid.rs:15:3 | @@ -311,7 +305,7 @@ LL | fn barqux(#[rustc_force_inline] _x: u32) {} = help: the `rustc_force_inline` attribute can only be applied to functions error: the `rustc_force_inline` attribute cannot be used on closures - --> $DIR/invalid.rs:148:16 + --> $DIR/invalid.rs:147:16 | LL | let _x = #[rustc_force_inline] || { }; | ^^^^^^^^^^^^^^^^^^ @@ -319,7 +313,7 @@ LL | let _x = #[rustc_force_inline] || { }; = help: the `rustc_force_inline` attribute can be applied to functions and inherent methods error: the `rustc_force_inline` attribute cannot be used on expressions - --> $DIR/invalid.rs:150:16 + --> $DIR/invalid.rs:149:16 | LL | let _y = #[rustc_force_inline] 3 + 4; | ^^^^^^^^^^^^^^^^^^ @@ -327,7 +321,7 @@ LL | let _y = #[rustc_force_inline] 3 + 4; = help: the `rustc_force_inline` attribute can only be applied to functions error: the `rustc_force_inline` attribute cannot be used on statements - --> $DIR/invalid.rs:152:7 + --> $DIR/invalid.rs:151:7 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^ @@ -337,7 +331,7 @@ LL | let _z = 3; = help: the `rustc_force_inline` attribute can only be applied to functions error: the `rustc_force_inline` attribute cannot be used on match arms - --> $DIR/invalid.rs:157:11 + --> $DIR/invalid.rs:156:11 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^ @@ -347,7 +341,7 @@ LL | 1 => (), = help: the `rustc_force_inline` attribute can only be applied to functions error: attribute cannot be applied to a `async`, `gen` or `async gen` function - --> $DIR/invalid.rs:135:1 + --> $DIR/invalid.rs:134:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ @@ -356,7 +350,7 @@ LL | async fn async_foo() {} | -------------------- `async`, `gen` or `async gen` function error: attribute cannot be applied to a `async`, `gen` or `async gen` function - --> $DIR/invalid.rs:139:1 + --> $DIR/invalid.rs:138:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ @@ -365,7 +359,7 @@ LL | gen fn gen_foo() {} | ---------------- `async`, `gen` or `async gen` function error: attribute cannot be applied to a `async`, `gen` or `async gen` function - --> $DIR/invalid.rs:143:1 + --> $DIR/invalid.rs:142:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ @@ -373,7 +367,7 @@ LL | LL | async gen fn async_gen_foo() {} | ---------------------------- `async`, `gen` or `async gen` function -error: aborting due to 36 previous errors +error: aborting due to 35 previous errors Some errors have detailed explanations: E0539, E0805. For more information about an error, try `rustc --explain E0539`. diff --git a/tests/ui/pin-ergonomics/pin_v2-attr.rs b/tests/ui/pin-ergonomics/pin_v2-attr.rs index 588ea014d4533..0b6b33ae2e923 100644 --- a/tests/ui/pin-ergonomics/pin_v2-attr.rs +++ b/tests/ui/pin-ergonomics/pin_v2-attr.rs @@ -83,7 +83,6 @@ const CONST: () = (); #[pin_v2] //~ ERROR the `pin_v2` attribute cannot be used on functions fn f(#[pin_v2] param: Foo) //~^ ERROR the `pin_v2` attribute cannot be used on function params -//~| ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters where #[pin_v2] //~^ ERROR the `pin_v2` attribute cannot be used on where predicates diff --git a/tests/ui/pin-ergonomics/pin_v2-attr.stderr b/tests/ui/pin-ergonomics/pin_v2-attr.stderr index dc7e76081abb7..3550ad8212c15 100644 --- a/tests/ui/pin-ergonomics/pin_v2-attr.stderr +++ b/tests/ui/pin-ergonomics/pin_v2-attr.stderr @@ -1,5 +1,5 @@ error: the `pin_v2` attribute cannot be used on macro calls - --> $DIR/pin_v2-attr.rs:135:3 + --> $DIR/pin_v2-attr.rs:134:3 | LL | #[pin_v2] | ^^^^^^ @@ -8,12 +8,6 @@ LL | macro_def!(); = help: the `pin_v2` attribute can only be applied to data types = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/pin_v2-attr.rs:84:12 - | -LL | fn f(#[pin_v2] param: Foo) - | ^^^^^^^^^ - error: the `pin_v2` attribute cannot be used on crates --> $DIR/pin_v2-attr.rs:10:4 | @@ -217,7 +211,7 @@ LL | fn f(#[pin_v2] param: Foo) = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on closures - --> $DIR/pin_v2-attr.rs:92:7 + --> $DIR/pin_v2-attr.rs:91:7 | LL | #[pin_v2] | ^^^^^^ @@ -226,7 +220,7 @@ LL | || (); = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on expressions - --> $DIR/pin_v2-attr.rs:94:7 + --> $DIR/pin_v2-attr.rs:93:7 | LL | #[pin_v2] | ^^^^^^ @@ -235,7 +229,7 @@ LL | [(), (), ()]; = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on struct fields - --> $DIR/pin_v2-attr.rs:98:11 + --> $DIR/pin_v2-attr.rs:97:11 | LL | #[pin_v2] | ^^^^^^ @@ -244,7 +238,7 @@ LL | field: (), = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on statements - --> $DIR/pin_v2-attr.rs:96:7 + --> $DIR/pin_v2-attr.rs:95:7 | LL | #[pin_v2] | ^^^^^^ @@ -253,7 +247,7 @@ LL | let _: Foo<(), ()> = Foo::StructVariant { = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on match arms - --> $DIR/pin_v2-attr.rs:102:11 + --> $DIR/pin_v2-attr.rs:101:11 | LL | #[pin_v2] | ^^^^^^ @@ -262,7 +256,7 @@ LL | Foo::UnitVariant => {} = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on pattern fields - --> $DIR/pin_v2-attr.rs:106:15 + --> $DIR/pin_v2-attr.rs:105:15 | LL | #[pin_v2] | ^^^^^^ @@ -271,7 +265,7 @@ LL | field, = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on where predicates - --> $DIR/pin_v2-attr.rs:88:7 + --> $DIR/pin_v2-attr.rs:87:7 | LL | #[pin_v2] | ^^^^^^ @@ -281,7 +275,7 @@ LL | T:, = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on modules - --> $DIR/pin_v2-attr.rs:112:3 + --> $DIR/pin_v2-attr.rs:111:3 | LL | #[pin_v2] | ^^^^^^ @@ -290,7 +284,7 @@ LL | mod m {} = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on foreign modules - --> $DIR/pin_v2-attr.rs:115:3 + --> $DIR/pin_v2-attr.rs:114:3 | LL | #[pin_v2] | ^^^^^^ @@ -299,7 +293,7 @@ LL | extern "C" { = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on foreign types - --> $DIR/pin_v2-attr.rs:117:7 + --> $DIR/pin_v2-attr.rs:116:7 | LL | #[pin_v2] | ^^^^^^ @@ -308,7 +302,7 @@ LL | type ForeignTy; = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on foreign statics - --> $DIR/pin_v2-attr.rs:120:7 + --> $DIR/pin_v2-attr.rs:119:7 | LL | #[pin_v2] | ^^^^^^ @@ -317,7 +311,7 @@ LL | static EXTERN_STATIC: (); = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on foreign functions - --> $DIR/pin_v2-attr.rs:123:7 + --> $DIR/pin_v2-attr.rs:122:7 | LL | #[pin_v2] | ^^^^^^ @@ -326,7 +320,7 @@ LL | fn extern_fn(); = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on type aliases - --> $DIR/pin_v2-attr.rs:127:3 + --> $DIR/pin_v2-attr.rs:126:3 | LL | #[pin_v2] | ^^^^^^ @@ -335,7 +329,7 @@ LL | type Type = (); = help: the `pin_v2` attribute can only be applied to data types error: the `pin_v2` attribute cannot be used on macro defs - --> $DIR/pin_v2-attr.rs:130:3 + --> $DIR/pin_v2-attr.rs:129:3 | LL | #[pin_v2] | ^^^^^^ @@ -343,5 +337,5 @@ LL | macro_rules! macro_def { | = help: the `pin_v2` attribute can only be applied to data types -error: aborting due to 39 previous errors +error: aborting due to 38 previous errors diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs index 7f1d5c849ebe6..a63b419dcf150 100644 --- a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs @@ -7,15 +7,11 @@ extern "C" { /// Bar //~^ ERROR documentation comments cannot be applied to function #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN cannot be used on function params - //~| WARN previously accepted + //~^ ERROR cannot be used on function params /// Baz //~^ ERROR documentation comments cannot be applied to function #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN cannot be used on function params - //~| WARN previously accepted + //~^ ERROR cannot be used on function params ); } @@ -27,15 +23,11 @@ type FnType = fn( /// Bar //~^ ERROR documentation comments cannot be applied to function #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN cannot be used on function params - //~| WARN previously accepted + //~^ ERROR cannot be used on function params /// Baz //~^ ERROR documentation comments cannot be applied to function #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN cannot be used on function params - //~| WARN previously accepted + //~^ ERROR cannot be used on function params ); pub fn foo( @@ -46,15 +38,11 @@ pub fn foo( /// Bar //~^ ERROR documentation comments cannot be applied to function #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on /// Baz //~^ ERROR documentation comments cannot be applied to function #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on ) {} struct SelfStruct {} @@ -70,15 +58,11 @@ impl SelfStruct { /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on /// Qux //~^ ERROR documentation comments cannot be applied to function #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on ) {} fn issue_64682_associated_fn( @@ -89,15 +73,11 @@ impl SelfStruct { /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on /// Qux //~^ ERROR documentation comments cannot be applied to function #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on ) {} } @@ -114,15 +94,11 @@ impl RefStruct { /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on /// Qux //~^ ERROR documentation comments cannot be applied to function #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on ) {} } trait RefTrait { @@ -137,15 +113,11 @@ trait RefTrait { /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on /// Qux //~^ ERROR documentation comments cannot be applied to function #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on ) {} fn issue_64682_associated_fn( @@ -156,15 +128,11 @@ trait RefTrait { /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on /// Qux //~^ ERROR documentation comments cannot be applied to function #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on ) {} } @@ -180,15 +148,11 @@ impl RefTrait for RefStruct { /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on /// Qux //~^ ERROR documentation comments cannot be applied to function #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on ) {} } @@ -201,14 +165,10 @@ fn main() { /// Bar //~^ ERROR documentation comments cannot be applied to function #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on /// Baz //~^ ERROR documentation comments cannot be applied to function #[no_mangle] b: i32 - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - //~| WARN attribute cannot be used on - //~| WARN previously accepted + //~^ ERROR attribute cannot be used on | {}; } diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr index 54bf349194741..c3fa2b6bfeaa0 100644 --- a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr @@ -5,55 +5,55 @@ LL | #[test] a: i32, | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:25:7 + --> $DIR/param-attrs-builtin-attrs.rs:21:7 | LL | #[test] a: u32, | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:44:7 + --> $DIR/param-attrs-builtin-attrs.rs:36:7 | LL | #[test] a: u32, | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:68:11 + --> $DIR/param-attrs-builtin-attrs.rs:56:11 | LL | #[test] a: i32, | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:87:11 + --> $DIR/param-attrs-builtin-attrs.rs:71:11 | LL | #[test] a: i32, | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:112:11 + --> $DIR/param-attrs-builtin-attrs.rs:92:11 | LL | #[test] a: i32, | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:135:11 + --> $DIR/param-attrs-builtin-attrs.rs:111:11 | LL | #[test] a: i32, | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:154:11 + --> $DIR/param-attrs-builtin-attrs.rs:126:11 | LL | #[test] a: i32, | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:178:11 + --> $DIR/param-attrs-builtin-attrs.rs:146:11 | LL | #[test] a: i32, | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:199:11 + --> $DIR/param-attrs-builtin-attrs.rs:163:11 | LL | #[test] a: u32, | ^^^^ not a non-macro attribute @@ -70,343 +70,220 @@ error: documentation comments cannot be applied to function parameters LL | /// Bar | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:9:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:13:9 + --> $DIR/param-attrs-builtin-attrs.rs:11:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:15:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:23:5 + --> $DIR/param-attrs-builtin-attrs.rs:19:5 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:27:5 + --> $DIR/param-attrs-builtin-attrs.rs:23:5 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:29:5 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:33:5 + --> $DIR/param-attrs-builtin-attrs.rs:27:5 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:35:5 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:42:5 + --> $DIR/param-attrs-builtin-attrs.rs:34:5 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:46:5 + --> $DIR/param-attrs-builtin-attrs.rs:38:5 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:48:5 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:52:5 + --> $DIR/param-attrs-builtin-attrs.rs:42:5 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:54:5 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:63:9 + --> $DIR/param-attrs-builtin-attrs.rs:51:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:66:9 + --> $DIR/param-attrs-builtin-attrs.rs:54:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:70:9 + --> $DIR/param-attrs-builtin-attrs.rs:58:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:72:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:76:9 + --> $DIR/param-attrs-builtin-attrs.rs:62:9 | LL | /// Qux | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:78:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:85:9 + --> $DIR/param-attrs-builtin-attrs.rs:69:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:89:9 + --> $DIR/param-attrs-builtin-attrs.rs:73:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:91:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:95:9 + --> $DIR/param-attrs-builtin-attrs.rs:77:9 | LL | /// Qux | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:97:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:107:9 + --> $DIR/param-attrs-builtin-attrs.rs:87:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:110:9 + --> $DIR/param-attrs-builtin-attrs.rs:90:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:114:9 + --> $DIR/param-attrs-builtin-attrs.rs:94:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:116:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:120:9 + --> $DIR/param-attrs-builtin-attrs.rs:98:9 | LL | /// Qux | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:122:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:130:9 + --> $DIR/param-attrs-builtin-attrs.rs:106:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:133:9 + --> $DIR/param-attrs-builtin-attrs.rs:109:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:137:9 + --> $DIR/param-attrs-builtin-attrs.rs:113:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:139:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:143:9 + --> $DIR/param-attrs-builtin-attrs.rs:117:9 | LL | /// Qux | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:145:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:152:9 + --> $DIR/param-attrs-builtin-attrs.rs:124:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:156:9 + --> $DIR/param-attrs-builtin-attrs.rs:128:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:158:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:162:9 + --> $DIR/param-attrs-builtin-attrs.rs:132:9 | LL | /// Qux | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:164:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:173:9 + --> $DIR/param-attrs-builtin-attrs.rs:141:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:176:9 + --> $DIR/param-attrs-builtin-attrs.rs:144:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:180:9 + --> $DIR/param-attrs-builtin-attrs.rs:148:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:182:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:186:9 + --> $DIR/param-attrs-builtin-attrs.rs:152:9 | LL | /// Qux | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:188:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:197:9 + --> $DIR/param-attrs-builtin-attrs.rs:161:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:201:9 + --> $DIR/param-attrs-builtin-attrs.rs:165:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:203:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:207:9 + --> $DIR/param-attrs-builtin-attrs.rs:169:9 | LL | /// Baz | ^^^^^^^ doc comments are not allowed here -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:209:9 - | -LL | #[no_mangle] b: i32 - | ^^^^^^^^^^^^ - -warning: the `must_use` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:29:7 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:9:11 | -LL | /// Bar +LL | /// Bar LL | -LL | #[must_use] - | ^^^^^^^^ +LL | #[must_use] + | ^^^^^^^^ | = help: the `must_use` attribute can be applied to data types, functions, and traits - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: requested on the command line with `-W unused-attributes` -warning: the `no_mangle` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:35:7 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:13:11 | -LL | /// Bar +LL | /// Bar ... -LL | #[no_mangle] b: i32, - | ^^^^^^^^^ +LL | #[no_mangle] b: i32, + | ^^^^^^^^^ | = help: the `no_mangle` attribute can be applied to functions and statics - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `must_use` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:48:7 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:25:7 | LL | /// Bar LL | @@ -414,10 +291,9 @@ LL | #[must_use] | ^^^^^^^^ | = help: the `must_use` attribute can be applied to data types, functions, and traits - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `no_mangle` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:54:7 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:29:7 | LL | /// Bar ... @@ -425,32 +301,29 @@ LL | #[no_mangle] b: i32, | ^^^^^^^^^ | = help: the `no_mangle` attribute can be applied to functions and statics - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `must_use` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:203:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:40:7 | -LL | /// Bar +LL | /// Bar LL | -LL | #[must_use] - | ^^^^^^^^ +LL | #[must_use] + | ^^^^^^^^ | = help: the `must_use` attribute can be applied to data types, functions, and traits - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `no_mangle` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:209:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:44:7 | -LL | /// Bar +LL | /// Bar ... -LL | #[no_mangle] b: i32 - | ^^^^^^^^^ +LL | #[no_mangle] b: i32, + | ^^^^^^^^^ | = help: the `no_mangle` attribute can be applied to functions and statics - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `must_use` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:139:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:60:11 | LL | /// Baz LL | @@ -458,10 +331,9 @@ LL | #[must_use] | ^^^^^^^^ | = help: the `must_use` attribute can be applied to data types, functions, and traits - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `no_mangle` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:145:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:64:11 | LL | /// Baz ... @@ -469,10 +341,9 @@ LL | #[no_mangle] b: i32, | ^^^^^^^^^ | = help: the `no_mangle` attribute can be applied to functions and statics - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `must_use` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:158:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:75:11 | LL | /// Baz LL | @@ -480,10 +351,9 @@ LL | #[must_use] | ^^^^^^^^ | = help: the `must_use` attribute can be applied to data types, functions, and traits - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `no_mangle` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:164:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:79:11 | LL | /// Baz ... @@ -491,10 +361,9 @@ LL | #[no_mangle] b: i32, | ^^^^^^^^^ | = help: the `no_mangle` attribute can be applied to functions and statics - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `must_use` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:72:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:96:11 | LL | /// Baz LL | @@ -502,10 +371,9 @@ LL | #[must_use] | ^^^^^^^^ | = help: the `must_use` attribute can be applied to data types, functions, and traits - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `no_mangle` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:78:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:100:11 | LL | /// Baz ... @@ -513,10 +381,9 @@ LL | #[no_mangle] b: i32, | ^^^^^^^^^ | = help: the `no_mangle` attribute can be applied to functions and statics - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `must_use` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:91:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:115:11 | LL | /// Baz LL | @@ -524,10 +391,9 @@ LL | #[must_use] | ^^^^^^^^ | = help: the `must_use` attribute can be applied to data types, functions, and traits - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `no_mangle` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:97:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:119:11 | LL | /// Baz ... @@ -535,10 +401,9 @@ LL | #[no_mangle] b: i32, | ^^^^^^^^^ | = help: the `no_mangle` attribute can be applied to functions and statics - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `must_use` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:116:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:130:11 | LL | /// Baz LL | @@ -546,10 +411,9 @@ LL | #[must_use] | ^^^^^^^^ | = help: the `must_use` attribute can be applied to data types, functions, and traits - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `no_mangle` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:122:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:134:11 | LL | /// Baz ... @@ -557,10 +421,9 @@ LL | #[no_mangle] b: i32, | ^^^^^^^^^ | = help: the `no_mangle` attribute can be applied to functions and statics - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `must_use` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:182:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:150:11 | LL | /// Baz LL | @@ -568,10 +431,9 @@ LL | #[must_use] | ^^^^^^^^ | = help: the `must_use` attribute can be applied to data types, functions, and traits - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `no_mangle` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:188:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:154:11 | LL | /// Baz ... @@ -579,10 +441,9 @@ LL | #[no_mangle] b: i32, | ^^^^^^^^^ | = help: the `no_mangle` attribute can be applied to functions and statics - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `must_use` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:9:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:167:11 | LL | /// Bar LL | @@ -590,18 +451,16 @@ LL | #[must_use] | ^^^^^^^^ | = help: the `must_use` attribute can be applied to data types, functions, and traits - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: the `no_mangle` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:15:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:171:11 | LL | /// Bar ... -LL | #[no_mangle] b: i32, +LL | #[no_mangle] b: i32 | ^^^^^^^^^ | = help: the `no_mangle` attribute can be applied to functions and statics - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -error: aborting due to 64 previous errors; 20 warnings emitted +error: aborting due to 64 previous errors diff --git a/tests/ui/rustdoc/check-doc-alias-attr-location.stderr b/tests/ui/rustdoc/check-doc-alias-attr-location.stderr index f587c17c1f3e9..815bec9f184a9 100644 --- a/tests/ui/rustdoc/check-doc-alias-attr-location.stderr +++ b/tests/ui/rustdoc/check-doc-alias-attr-location.stderr @@ -1,4 +1,4 @@ -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters +error: `#[doc(...)]` isn't allowed on parameters --> $DIR/check-doc-alias-attr-location.rs:22:12 | LL | fn foo(#[doc(alias = "qux")] _x: u32) -> Self::X { diff --git a/tests/ui/scalable-vectors/invalid.rs b/tests/ui/scalable-vectors/invalid.rs index 4bbe11e019a62..c7aa5a7c445ad 100644 --- a/tests/ui/scalable-vectors/invalid.rs +++ b/tests/ui/scalable-vectors/invalid.rs @@ -109,7 +109,6 @@ macro_rules! barqux { ($foo:tt) => { $foo }; } //~^ ERROR: the `rustc_scalable_vector` attribute cannot be used on functions fn barqux(#[rustc_scalable_vector(4)] _x: u32) {} //~^ ERROR: the `rustc_scalable_vector` attribute cannot be used on function params -//~^^ ERROR: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters #[rustc_scalable_vector(4)] //~^ ERROR: the `rustc_scalable_vector` attribute cannot be used on functions diff --git a/tests/ui/scalable-vectors/invalid.stderr b/tests/ui/scalable-vectors/invalid.stderr index 6f47f94806a03..e01e0cffdc768 100644 --- a/tests/ui/scalable-vectors/invalid.stderr +++ b/tests/ui/scalable-vectors/invalid.stderr @@ -1,9 +1,3 @@ -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/invalid.rs:110:11 - | -LL | fn barqux(#[rustc_scalable_vector(4)] _x: u32) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: the `rustc_scalable_vector` attribute cannot be used on extern crates --> $DIR/invalid.rs:10:3 | @@ -261,7 +255,7 @@ LL | fn barqux(#[rustc_scalable_vector(4)] _x: u32) {} = help: the `rustc_scalable_vector` attribute can only be applied to structs error: the `rustc_scalable_vector` attribute cannot be used on functions - --> $DIR/invalid.rs:114:3 + --> $DIR/invalid.rs:113:3 | LL | #[rustc_scalable_vector(4)] | ^^^^^^^^^^^^^^^^^^^^^ @@ -271,7 +265,7 @@ LL | async fn async_foo() {} = help: the `rustc_scalable_vector` attribute can only be applied to structs error: the `rustc_scalable_vector` attribute cannot be used on functions - --> $DIR/invalid.rs:118:3 + --> $DIR/invalid.rs:117:3 | LL | #[rustc_scalable_vector(4)] | ^^^^^^^^^^^^^^^^^^^^^ @@ -281,7 +275,7 @@ LL | gen fn gen_foo() {} = help: the `rustc_scalable_vector` attribute can only be applied to structs error: the `rustc_scalable_vector` attribute cannot be used on functions - --> $DIR/invalid.rs:122:3 + --> $DIR/invalid.rs:121:3 | LL | #[rustc_scalable_vector(4)] | ^^^^^^^^^^^^^^^^^^^^^ @@ -291,7 +285,7 @@ LL | async gen fn async_gen_foo() {} = help: the `rustc_scalable_vector` attribute can only be applied to structs error: the `rustc_scalable_vector` attribute cannot be used on closures - --> $DIR/invalid.rs:127:16 + --> $DIR/invalid.rs:126:16 | LL | let _x = #[rustc_scalable_vector(4)] || { }; | ^^^^^^^^^^^^^^^^^^^^^ @@ -299,7 +293,7 @@ LL | let _x = #[rustc_scalable_vector(4)] || { }; = help: the `rustc_scalable_vector` attribute can only be applied to structs error: the `rustc_scalable_vector` attribute cannot be used on expressions - --> $DIR/invalid.rs:129:16 + --> $DIR/invalid.rs:128:16 | LL | let _y = #[rustc_scalable_vector(4)] 3 + 4; | ^^^^^^^^^^^^^^^^^^^^^ @@ -307,7 +301,7 @@ LL | let _y = #[rustc_scalable_vector(4)] 3 + 4; = help: the `rustc_scalable_vector` attribute can only be applied to structs error: the `rustc_scalable_vector` attribute cannot be used on statements - --> $DIR/invalid.rs:131:7 + --> $DIR/invalid.rs:130:7 | LL | #[rustc_scalable_vector(4)] | ^^^^^^^^^^^^^^^^^^^^^ @@ -317,7 +311,7 @@ LL | let _z = 3; = help: the `rustc_scalable_vector` attribute can only be applied to structs error: the `rustc_scalable_vector` attribute cannot be used on match arms - --> $DIR/invalid.rs:136:11 + --> $DIR/invalid.rs:135:11 | LL | #[rustc_scalable_vector(4)] | ^^^^^^^^^^^^^^^^^^^^^ @@ -327,7 +321,7 @@ LL | 1 => (), = help: the `rustc_scalable_vector` attribute can only be applied to structs error[E0539]: malformed `rustc_scalable_vector` attribute input - --> $DIR/invalid.rs:143:3 + --> $DIR/invalid.rs:142:3 | LL | #[rustc_scalable_vector("4")] | ^^^^^^^^^^^^^^^^^^^^^^---^ @@ -344,7 +338,7 @@ LL + #[rustc_scalable_vector(count)] | error[E0805]: malformed `rustc_scalable_vector` attribute input - --> $DIR/invalid.rs:147:3 + --> $DIR/invalid.rs:146:3 | LL | #[rustc_scalable_vector(4, 2)] | ^^^^^^^^^^^^^^^^^^^^^------ @@ -361,7 +355,7 @@ LL + #[rustc_scalable_vector(count)] | error[E0539]: malformed `rustc_scalable_vector` attribute input - --> $DIR/invalid.rs:151:3 + --> $DIR/invalid.rs:150:3 | LL | #[rustc_scalable_vector(count = "4")] | ^^^^^^^^^^^^^^^^^^^^^^-----------^ @@ -378,7 +372,7 @@ LL + #[rustc_scalable_vector(count)] | error: element count in `rustc_scalable_vector` is too large: `65536` - --> $DIR/invalid.rs:155:1 + --> $DIR/invalid.rs:154:1 | LL | #[rustc_scalable_vector(65536)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -386,12 +380,12 @@ LL | #[rustc_scalable_vector(65536)] = note: the value may not exceed `u16::MAX` error: scalable vector structs can only have scalable vector fields - --> $DIR/invalid.rs:163:18 + --> $DIR/invalid.rs:162:18 | LL | struct OkayNoArg(f32); | ^^^ -error: aborting due to 39 previous errors +error: aborting due to 38 previous errors Some errors have detailed explanations: E0539, E0805. For more information about an error, try `rustc --explain E0539`.