Move query-dep-graph opt check to attr parsing
This commit is contained in:
parent
de7067938d
commit
522778e348
5 changed files with 21 additions and 27 deletions
|
|
@ -10,7 +10,7 @@ use rustc_span::Symbol;
|
|||
|
||||
use super::prelude::*;
|
||||
use super::util::parse_single_integer;
|
||||
use crate::session_diagnostics::RustcScalableVectorCountOutOfRange;
|
||||
use crate::session_diagnostics::{AttributeRequiresOpt, RustcScalableVectorCountOutOfRange};
|
||||
|
||||
pub(crate) struct RustcMainParser;
|
||||
|
||||
|
|
@ -543,6 +543,9 @@ impl<S: Stage> CombineAttributeParser<S> for RustcCleanParser {
|
|||
cx: &mut AcceptContext<'_, '_, S>,
|
||||
args: &ArgParser,
|
||||
) -> impl IntoIterator<Item = Self::Item> {
|
||||
if !cx.cx.sess.opts.unstable_opts.query_dep_graph {
|
||||
cx.emit_err(AttributeRequiresOpt { span: cx.attr_span, opt: "-Z query-dep-graph" });
|
||||
}
|
||||
let Some(list) = args.list() else {
|
||||
cx.expected_list(cx.attr_span, args);
|
||||
return None;
|
||||
|
|
@ -641,6 +644,9 @@ impl<S: Stage> SingleAttributeParser<S> for RustcIfThisChangedParser {
|
|||
const TEMPLATE: AttributeTemplate = template!(Word, List: &["DepNode"]);
|
||||
|
||||
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
|
||||
if !cx.cx.sess.opts.unstable_opts.query_dep_graph {
|
||||
cx.emit_err(AttributeRequiresOpt { span: cx.attr_span, opt: "-Z query-dep-graph" });
|
||||
}
|
||||
match args {
|
||||
ArgParser::NoArgs => Some(AttributeKind::RustcIfThisChanged(cx.attr_span, None)),
|
||||
ArgParser::List(list) => {
|
||||
|
|
@ -701,6 +707,9 @@ impl<S: Stage> CombineAttributeParser<S> for RustcThenThisWouldNeedParser {
|
|||
cx: &mut AcceptContext<'_, '_, S>,
|
||||
args: &ArgParser,
|
||||
) -> impl IntoIterator<Item = Self::Item> {
|
||||
if !cx.cx.sess.opts.unstable_opts.query_dep_graph {
|
||||
cx.emit_err(AttributeRequiresOpt { span: cx.attr_span, opt: "-Z query-dep-graph" });
|
||||
}
|
||||
let Some(item) = args.list().and_then(|l| l.single()) else {
|
||||
cx.expected_single_argument(cx.inner_span);
|
||||
return None;
|
||||
|
|
|
|||
|
|
@ -532,6 +532,14 @@ pub(crate) struct RustcScalableVectorCountOutOfRange {
|
|||
pub n: u128,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("attribute requires {$opt} to be enabled")]
|
||||
pub(crate) struct AttributeRequiresOpt {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub opt: &'static str,
|
||||
}
|
||||
|
||||
pub(crate) enum AttributeParseErrorReason<'a> {
|
||||
ExpectedNoArgs,
|
||||
ExpectedStringLiteral {
|
||||
|
|
|
|||
|
|
@ -439,9 +439,6 @@ passes_rustc_allow_const_fn_unstable =
|
|||
attribute should be applied to `const fn`
|
||||
.label = not a `const fn`
|
||||
|
||||
passes_rustc_clean =
|
||||
attribute requires -Z query-dep-graph to be enabled
|
||||
|
||||
passes_rustc_const_stable_indirect_pairing =
|
||||
`const_stable_indirect` attribute does not make sense on `rustc_const_stable` function, its behavior is already implied
|
||||
|
||||
|
|
|
|||
|
|
@ -231,14 +231,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
self.check_rustc_must_implement_one_of(*attr_span, fn_names, hir_id,target)
|
||||
},
|
||||
Attribute::Parsed(AttributeKind::DoNotRecommend{attr_span}) => {self.check_do_not_recommend(*attr_span, hir_id, target, item)},
|
||||
Attribute::Parsed(AttributeKind::RustcClean(attrs)) => {
|
||||
for attr in attrs {
|
||||
self.check_rustc_clean(attr.span);
|
||||
}
|
||||
},
|
||||
Attribute::Parsed(AttributeKind::RustcIfThisChanged(span, _) | AttributeKind::RustcThenThisWouldNeed(span, _)) => {
|
||||
self.check_rustc_clean(*span);
|
||||
}
|
||||
Attribute::Parsed(
|
||||
// tidy-alphabetical-start
|
||||
AttributeKind::RustcAllowIncoherentImpl(..)
|
||||
|
|
@ -300,6 +292,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
| AttributeKind::RustcAsPtr(..)
|
||||
| AttributeKind::RustcBodyStability { .. }
|
||||
| AttributeKind::RustcBuiltinMacro { .. }
|
||||
| AttributeKind::RustcClean(..)
|
||||
| AttributeKind::RustcCoherenceIsCore(..)
|
||||
| AttributeKind::RustcCoinductive(..)
|
||||
| AttributeKind::RustcConfusables { .. }
|
||||
|
|
@ -315,6 +308,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
| AttributeKind::RustcDynIncompatibleTrait(..)
|
||||
| AttributeKind::RustcHasIncoherentInherentImpls
|
||||
| AttributeKind::RustcHiddenTypeOfOpaques
|
||||
| AttributeKind::RustcIfThisChanged(..)
|
||||
| AttributeKind::RustcLayout(..)
|
||||
| AttributeKind::RustcLayoutScalarValidRangeEnd(..)
|
||||
| AttributeKind::RustcLayoutScalarValidRangeStart(..)
|
||||
|
|
@ -343,6 +337,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
| AttributeKind::RustcSkipDuringMethodDispatch { .. }
|
||||
| AttributeKind::RustcSpecializationTrait(..)
|
||||
| AttributeKind::RustcStdInternalSymbol (..)
|
||||
| AttributeKind::RustcThenThisWouldNeed(..)
|
||||
| AttributeKind::RustcUnsafeSpecializationMarker(..)
|
||||
| AttributeKind::RustcVariance
|
||||
| AttributeKind::RustcVarianceOfOpaques
|
||||
|
|
@ -1264,14 +1259,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Checks that the dep-graph debugging attributes are only present when the query-dep-graph
|
||||
/// option is passed to the compiler.
|
||||
fn check_rustc_clean(&self, span: Span) {
|
||||
if !self.tcx.sess.opts.unstable_opts.query_dep_graph {
|
||||
self.dcx().emit_err(errors::RustcClean { span });
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if the `#[repr]` attributes on `item` are valid.
|
||||
fn check_repr(
|
||||
&self,
|
||||
|
|
|
|||
|
|
@ -217,13 +217,6 @@ pub(crate) struct RustcLegacyConstGenericsIndexExceed {
|
|||
pub arg_count: usize,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes_rustc_clean)]
|
||||
pub(crate) struct RustcClean {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes_repr_conflicting, code = E0566)]
|
||||
pub(crate) struct ReprConflicting {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue