diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index fe5c604544448..5708a42c2caa2 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -538,8 +538,6 @@ impl<'a> AstValidator<'a> { .for_each(|attr| { if attr.is_doc_comment() { self.dcx().emit_err(diagnostics::FnParamDocComment { span: attr.span }); - } else { - self.dcx().emit_err(diagnostics::FnParamForbiddenAttr { span: attr.span }); } }); } diff --git a/compiler/rustc_ast_passes/src/diagnostics.rs b/compiler/rustc_ast_passes/src/diagnostics.rs index 5ab905b5df52b..29c103f988798 100644 --- a/compiler/rustc_ast_passes/src/diagnostics.rs +++ b/compiler/rustc_ast_passes/src/diagnostics.rs @@ -192,16 +192,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/cfi_encoding.rs b/compiler/rustc_attr_parsing/src/attributes/cfi_encoding.rs index 8a9102a78e25b..fc75f0285bda1 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfi_encoding.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfi_encoding.rs @@ -4,7 +4,7 @@ use super::prelude::*; pub(crate) struct CfiEncodingParser; impl SingleAttributeParser for CfiEncodingParser { const PATH: &[Symbol] = &[sym::cfi_encoding]; - const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowListWarnRest(&[ + const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[ Allow(Target::Struct), Allow(Target::ForeignTy), Allow(Target::Enum), diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index bff7d7ad81cb9..79c124ff5830b 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -60,6 +60,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; @@ -393,6 +394,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 b68042c39670c..cd9eac9a242f2 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 7aeedc1493027..671a7cc7a9295 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -15,13 +15,13 @@ use super::{AcceptMapping, AttributeParser, template}; use crate::context::{AcceptContext, FinalizeContext}; use crate::diagnostics::{ AttrCrateLevelOnly, DocAliasBadChar, DocAliasDuplicated, DocAliasEmpty, DocAliasMalformed, - DocAliasStartEnd, DocAttrNotCrateLevel, DocAttributeNotAttribute, DocAutoCfgExpectsHideOrShow, - DocAutoCfgHideShowExpectsList, DocAutoCfgHideShowNoIdentBeforeValues, - DocAutoCfgHideShowUnexpectedItem, DocAutoCfgHideShowUnexpectedItemAfterValues, - DocAutoCfgHideShowValuesMix, DocAutoCfgWrongLiteral, DocKeywordNotKeyword, DocTestLiteral, - DocTestTakesList, DocTestUnknown, DocUnknownAny, DocUnknownInclude, DocUnknownPasses, - DocUnknownPlugins, DocUnknownSpotlight, ExpectedNameValue, ExpectedNoArgs, - IllFormedAttributeInput, MalformedDoc, UnusedDuplicate, + DocAliasStartEnd, DocAttrNotCrateLevel, DocAttrNotParameters, DocAttributeNotAttribute, + DocAutoCfgExpectsHideOrShow, DocAutoCfgHideShowExpectsList, + DocAutoCfgHideShowNoIdentBeforeValues, DocAutoCfgHideShowUnexpectedItem, + DocAutoCfgHideShowUnexpectedItemAfterValues, DocAutoCfgHideShowValuesMix, + DocAutoCfgWrongLiteral, DocKeywordNotKeyword, DocTestLiteral, DocTestTakesList, DocTestUnknown, + DocUnknownAny, DocUnknownInclude, DocUnknownPasses, DocUnknownPlugins, DocUnknownSpotlight, + ExpectedNameValue, ExpectedNoArgs, IllFormedAttributeInput, MalformedDoc, UnusedDuplicate, }; use crate::parser::{ ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser, @@ -60,6 +60,10 @@ fn check_attr_not_crate_level( cx.emit_err(DocAttrNotCrateLevel { span, attr_name }); return false; } + if cx.shared.target == Target::Param { + cx.emit_err(DocAttrNotParameters { span, attr_name }); + return false; + } true } 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 a00e5af00c2eb..78e1fb42143bb 100644 --- a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs @@ -30,6 +30,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", @@ -72,7 +73,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( @@ -506,6 +507,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 4ead90af8d630..76e47ae0dd2cf 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 c9625521aec44..c7465f83edfdd 100644 --- a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs @@ -38,6 +38,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 { @@ -155,6 +156,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 aeaada0e61409..f46abbfc59592 100644 --- a/compiler/rustc_attr_parsing/src/diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/diagnostics.rs @@ -964,6 +964,14 @@ pub(crate) struct DocAttrNotCrateLevel { pub attr_name: Symbol, } +#[derive(Diagnostic)] +#[diag("`#![doc({$attr_name} = \"...\")]` isn't allowed on parameters")] +pub(crate) struct DocAttrNotParameters { + #[primary_span] + pub span: Span, + pub attr_name: Symbol, +} + #[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 1e272b9674dab..176d8c715238d 100644 --- a/compiler/rustc_attr_parsing/src/target_checking.rs +++ b/compiler/rustc_attr_parsing/src/target_checking.rs @@ -15,7 +15,6 @@ use crate::diagnostics::{ InvalidAttrAtCrateLevel, InvalidTarget, InvalidTargetHelp, ItemFollowingInnerAttr, UnsupportedAttributesInWhere, }; -use crate::target_checking::Policy::Allow; use crate::{AttributeParser, ShouldEmit}; #[derive(Debug)] @@ -35,6 +34,19 @@ pub(crate) enum AllowedResult { } impl AllowedTargets<'_> { + pub(crate) fn is_only_crate_level_allowed(&self) -> bool { + let (AllowedTargets::AllowList(policies) | AllowedTargets::AllowListWarnRest(policies)) = + self + else { + return false; + }; + policies.iter().all(|p| match p { + Policy::Allow(Target::Crate) => true, + Policy::Allow(_) => false, + _ => true, + }) + } + pub(crate) fn is_allowed(&self, target: Target) -> AllowedResult { match self { AllowedTargets::AllowList(list) => { @@ -113,12 +125,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 allowed_targets.is_only_crate_level_allowed() { + Self::check_crate_level( + cx, + matches!(allowed_targets, AllowedTargets::AllowListWarnRest(..)), + ); return; } diff --git a/tests/ui/attributes/attrs-on-params.rs b/tests/ui/attributes/attrs-on-params.rs index c8e9810327c2a..73551f70a8ea9 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 } fn main() {} diff --git a/tests/ui/attributes/attrs-on-params.stderr b/tests/ui/attributes/attrs-on-params.stderr index b38c590a19a5c..e4772bd3c51f3 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 | @@ -12,5 +6,5 @@ LL | fn function(#[inline] param: u32) { | = help: the `inline` attribute can only be applied to functions -error: aborting due to 2 previous errors +error: aborting due to 1 previous error 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 686c105286b31..0e8cad2b7b07d 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 | @@ -265,7 +259,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] || { }; | ^^^^^^^^^^^^^^^^^^ @@ -273,7 +267,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; | ^^^^^^^^^^^^^^^^^^ @@ -281,7 +275,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] | ^^^^^^^^^^^^^^^^^^ @@ -289,7 +283,7 @@ LL | #[rustc_force_inline] = 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] | ^^^^^^^^^^^^^^^^^^ @@ -297,7 +291,7 @@ LL | #[rustc_force_inline] = 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] | ^^^^^^^^^^^^^^^^^^^^^ @@ -306,7 +300,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] | ^^^^^^^^^^^^^^^^^^^^^ @@ -315,7 +309,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] | ^^^^^^^^^^^^^^^^^^^^^ @@ -323,7 +317,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 d58fce5e282b2..c0e8395cbab34 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] | ^^^^^^ @@ -7,12 +7,6 @@ LL | #[pin_v2] = 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 | @@ -198,7 +192,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] | ^^^^^^ @@ -206,7 +200,7 @@ LL | #[pin_v2] = 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] | ^^^^^^ @@ -214,7 +208,7 @@ LL | #[pin_v2] = 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] | ^^^^^^ @@ -222,7 +216,7 @@ LL | #[pin_v2] = 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] | ^^^^^^ @@ -230,7 +224,7 @@ LL | #[pin_v2] = 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] | ^^^^^^ @@ -238,7 +232,7 @@ LL | #[pin_v2] = 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] | ^^^^^^ @@ -246,7 +240,7 @@ LL | #[pin_v2] = 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] | ^^^^^^ @@ -254,7 +248,7 @@ LL | #[pin_v2] = 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] | ^^^^^^ @@ -262,7 +256,7 @@ LL | #[pin_v2] = 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] | ^^^^^^ @@ -270,7 +264,7 @@ LL | #[pin_v2] = 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] | ^^^^^^ @@ -278,7 +272,7 @@ LL | #[pin_v2] = 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] | ^^^^^^ @@ -286,7 +280,7 @@ LL | #[pin_v2] = 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] | ^^^^^^ @@ -294,7 +288,7 @@ LL | #[pin_v2] = 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] | ^^^^^^ @@ -302,12 +296,12 @@ LL | #[pin_v2] = 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] | ^^^^^^ | = 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 bb6e7705a29d6..d57cfc0555470 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,11 +7,9 @@ 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 /// 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 ); } @@ -23,11 +21,9 @@ 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 /// 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 ); pub fn foo( @@ -38,15 +34,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 {} @@ -62,15 +54,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( @@ -81,15 +69,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 ) {} } @@ -106,15 +90,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 { @@ -129,15 +109,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( @@ -148,15 +124,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 ) {} } @@ -172,15 +144,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 ) {} } @@ -193,14 +161,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 cee602a274bb3..281373d56d3d2 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:21:7 + --> $DIR/param-attrs-builtin-attrs.rs:19: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:36:7 + --> $DIR/param-attrs-builtin-attrs.rs:32: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:60:11 + --> $DIR/param-attrs-builtin-attrs.rs:52: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:79:11 + --> $DIR/param-attrs-builtin-attrs.rs:67: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:104:11 + --> $DIR/param-attrs-builtin-attrs.rs:88: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:127:11 + --> $DIR/param-attrs-builtin-attrs.rs:107: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:146:11 + --> $DIR/param-attrs-builtin-attrs.rs:122: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:170:11 + --> $DIR/param-attrs-builtin-attrs.rs:142: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:191:11 + --> $DIR/param-attrs-builtin-attrs.rs:159:11 | LL | #[test] a: u32, | ^^^^ not a non-macro attribute @@ -70,462 +70,325 @@ 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:11:9 + --> $DIR/param-attrs-builtin-attrs.rs:10: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:13:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:19:5 + --> $DIR/param-attrs-builtin-attrs.rs:17:5 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:23:5 + --> $DIR/param-attrs-builtin-attrs.rs:21: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:25:5 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:27:5 + --> $DIR/param-attrs-builtin-attrs.rs:24: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:29:5 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:34:5 + --> $DIR/param-attrs-builtin-attrs.rs:30:5 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:38:5 + --> $DIR/param-attrs-builtin-attrs.rs:34: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:40:5 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:44:5 + --> $DIR/param-attrs-builtin-attrs.rs:38: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:46:5 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:55:9 + --> $DIR/param-attrs-builtin-attrs.rs:47:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:58:9 + --> $DIR/param-attrs-builtin-attrs.rs:50:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:62:9 + --> $DIR/param-attrs-builtin-attrs.rs:54: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:64:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:68:9 + --> $DIR/param-attrs-builtin-attrs.rs:58: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:70:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:77:9 + --> $DIR/param-attrs-builtin-attrs.rs:65:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:81:9 + --> $DIR/param-attrs-builtin-attrs.rs:69: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:83:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:87:9 + --> $DIR/param-attrs-builtin-attrs.rs:73: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:89:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:99:9 + --> $DIR/param-attrs-builtin-attrs.rs:83:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:102:9 + --> $DIR/param-attrs-builtin-attrs.rs:86:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:106:9 + --> $DIR/param-attrs-builtin-attrs.rs:90: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:108:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:112:9 + --> $DIR/param-attrs-builtin-attrs.rs:94: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:114:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:122:9 + --> $DIR/param-attrs-builtin-attrs.rs:102:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:125:9 + --> $DIR/param-attrs-builtin-attrs.rs:105:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:129:9 + --> $DIR/param-attrs-builtin-attrs.rs:109: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:131:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:135:9 + --> $DIR/param-attrs-builtin-attrs.rs:113: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:137:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:144:9 + --> $DIR/param-attrs-builtin-attrs.rs:120:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:148:9 + --> $DIR/param-attrs-builtin-attrs.rs:124: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:150:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:154:9 + --> $DIR/param-attrs-builtin-attrs.rs:128: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:156:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:165:9 + --> $DIR/param-attrs-builtin-attrs.rs:137:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:168:9 + --> $DIR/param-attrs-builtin-attrs.rs:140:9 | LL | /// Bar | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:172:9 + --> $DIR/param-attrs-builtin-attrs.rs:144: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:174:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:178:9 + --> $DIR/param-attrs-builtin-attrs.rs:148: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:180:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:189:9 + --> $DIR/param-attrs-builtin-attrs.rs:157:9 | LL | /// Foo | ^^^^^^^ doc comments are not allowed here error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:193:9 + --> $DIR/param-attrs-builtin-attrs.rs:161: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:195:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:199:9 + --> $DIR/param-attrs-builtin-attrs.rs:165: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:201:9 - | -LL | #[no_mangle] b: i32 - | ^^^^^^^^^^^^ - -warning: the `must_use` attribute cannot be used on function params - --> $DIR/param-attrs-builtin-attrs.rs:40:7 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:36:7 | 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:46:7 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:40:7 | 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:195:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:56:11 | 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:201:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:60:11 | -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:131:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:71:11 | 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:137:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:75:11 | 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:150:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:92:11 | 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:156:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:96:11 | 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:64:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:111:11 | 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:70:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:115:11 | 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:83:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:126:11 | 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:89:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:130:11 | 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:108:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:146:11 | 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:114:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:150:11 | 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:174:11 +error: the `must_use` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:163:11 | 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:180:11 +error: the `no_mangle` attribute cannot be used on function params + --> $DIR/param-attrs-builtin-attrs.rs:167:11 | -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; 16 warnings emitted +error: aborting due to 60 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..ac2e07a841457 100644 --- a/tests/ui/rustdoc/check-doc-alias-attr-location.stderr +++ b/tests/ui/rustdoc/check-doc-alias-attr-location.stderr @@ -1,8 +1,8 @@ -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/check-doc-alias-attr-location.rs:22:12 +error: `#![doc(alias = "...")]` isn't allowed on parameters + --> $DIR/check-doc-alias-attr-location.rs:22:26 | LL | fn foo(#[doc(alias = "qux")] _x: u32) -> Self::X { - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ error: `#[doc(alias = "...")]` isn't allowed on foreign module --> $DIR/check-doc-alias-attr-location.rs:9:15