mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Update rustc_attr_parsing::SharedContext::target type from Option<Target> to Target
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
};
|
||||
use rustc_hir::attrs::CfgEntry;
|
||||
use rustc_hir::lints::AttributeLintKind;
|
||||
use rustc_hir::{AttrPath, RustcVersion};
|
||||
use rustc_hir::{AttrPath, RustcVersion, Target};
|
||||
use rustc_parse::parser::{ForceCollect, Parser};
|
||||
use rustc_parse::{exp, parse_in};
|
||||
use rustc_session::Session;
|
||||
@@ -374,6 +374,7 @@ fn parse_cfg_attr_internal<'a>(
|
||||
ParsedDescription::Attribute,
|
||||
pred_span,
|
||||
CRATE_NODE_ID,
|
||||
Target::Crate,
|
||||
features,
|
||||
ShouldEmit::ErrorsAndLints,
|
||||
&meta,
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast::{AttrStyle, NodeId, token};
|
||||
use rustc_feature::{AttributeTemplate, Features};
|
||||
use rustc_hir::AttrPath;
|
||||
use rustc_hir::attrs::CfgEntry;
|
||||
use rustc_hir::{AttrPath, Target};
|
||||
use rustc_parse::exp;
|
||||
use rustc_parse::parser::Parser;
|
||||
use rustc_session::Session;
|
||||
@@ -91,6 +91,8 @@ pub fn parse_cfg_select(
|
||||
ParsedDescription::Macro,
|
||||
cfg_span,
|
||||
lint_node_id,
|
||||
// Doesn't matter what the target actually is here.
|
||||
Target::Crate,
|
||||
features,
|
||||
ShouldEmit::ErrorsAndLints,
|
||||
&meta,
|
||||
|
||||
@@ -50,7 +50,7 @@ fn check_attr_not_crate_level<S: Stage>(
|
||||
span: Span,
|
||||
attr_name: Symbol,
|
||||
) -> bool {
|
||||
if cx.shared.target.is_some_and(|target| target == Target::Crate) {
|
||||
if cx.shared.target == Target::Crate {
|
||||
cx.emit_err(DocAttrNotCrateLevel { span, attr_name });
|
||||
return false;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ fn check_attr_not_crate_level<S: Stage>(
|
||||
|
||||
/// Checks that an attribute is used at the crate level. Returns `true` if valid.
|
||||
fn check_attr_crate_level<S: Stage>(cx: &mut AcceptContext<'_, '_, S>, span: Span) -> bool {
|
||||
if cx.shared.target.is_some_and(|target| target != Target::Crate) {
|
||||
if cx.shared.target != Target::Crate {
|
||||
cx.emit_lint(
|
||||
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
|
||||
AttributeLintKind::AttrCrateLevelOnly,
|
||||
|
||||
@@ -665,7 +665,7 @@ pub struct SharedContext<'p, 'sess, S: Stage> {
|
||||
pub(crate) target_span: Span,
|
||||
/// The id ([`NodeId`] if `S` is `Early`, [`HirId`] if `S` is `Late`) of the syntactical component this attribute was applied to
|
||||
pub(crate) target_id: S::Id,
|
||||
pub(crate) target: Option<rustc_hir::Target>,
|
||||
pub(crate) target: rustc_hir::Target,
|
||||
|
||||
pub(crate) emit_lint: &'p mut dyn FnMut(AttributeLint<S::Id>),
|
||||
}
|
||||
|
||||
@@ -135,6 +135,7 @@ pub fn parse_single<T>(
|
||||
attr: &ast::Attribute,
|
||||
target_span: Span,
|
||||
target_node_id: NodeId,
|
||||
target: Target,
|
||||
features: Option<&'sess Features>,
|
||||
emit_errors: ShouldEmit,
|
||||
parse_fn: fn(cx: &mut AcceptContext<'_, '_, Early>, item: &ArgParser) -> Option<T>,
|
||||
@@ -163,6 +164,7 @@ pub fn parse_single<T>(
|
||||
ParsedDescription::Attribute,
|
||||
target_span,
|
||||
target_node_id,
|
||||
target,
|
||||
features,
|
||||
emit_errors,
|
||||
&args,
|
||||
@@ -183,6 +185,7 @@ pub fn parse_single_args<T, I>(
|
||||
parsed_description: ParsedDescription,
|
||||
target_span: Span,
|
||||
target_node_id: NodeId,
|
||||
target: Target,
|
||||
features: Option<&'sess Features>,
|
||||
emit_errors: ShouldEmit,
|
||||
args: &I,
|
||||
@@ -218,7 +221,7 @@ pub fn parse_single_args<T, I>(
|
||||
cx: &mut parser,
|
||||
target_span,
|
||||
target_id: target_node_id,
|
||||
target: None,
|
||||
target,
|
||||
emit_lint: &mut emit_lint,
|
||||
},
|
||||
attr_span,
|
||||
@@ -379,7 +382,7 @@ pub fn parse_attribute_list(
|
||||
cx: self,
|
||||
target_span,
|
||||
target_id,
|
||||
target: Some(target),
|
||||
target,
|
||||
emit_lint: &mut emit_lint,
|
||||
},
|
||||
attr_span,
|
||||
@@ -431,7 +434,7 @@ pub fn parse_attribute_list(
|
||||
cx: self,
|
||||
target_span,
|
||||
target_id,
|
||||
target: Some(target),
|
||||
target,
|
||||
emit_lint: &mut emit_lint,
|
||||
},
|
||||
all_attrs: &attr_paths,
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
AttributeParser, CFG_TEMPLATE, ParsedDescription, ShouldEmit, parse_cfg_entry,
|
||||
};
|
||||
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
|
||||
use rustc_hir::AttrPath;
|
||||
use rustc_hir::attrs::CfgEntry;
|
||||
use rustc_hir::{AttrPath, Target};
|
||||
use rustc_parse::exp;
|
||||
use rustc_span::{ErrorGuaranteed, Span, sym};
|
||||
|
||||
@@ -52,6 +52,8 @@ fn parse_cfg(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream) -> Result<CfgEntry,
|
||||
ParsedDescription::Macro,
|
||||
span,
|
||||
cx.current_expansion.lint_node_id,
|
||||
// Doesn't matter what the target actually is here.
|
||||
Target::Crate,
|
||||
Some(cx.ecfg.features),
|
||||
ShouldEmit::ErrorsAndLints,
|
||||
&meta,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
ACCEPTED_LANG_FEATURES, EnabledLangFeature, EnabledLibFeature, Features, REMOVED_LANG_FEATURES,
|
||||
UNSTABLE_LANG_FEATURES,
|
||||
};
|
||||
use rustc_hir::Target;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::{STDLIB_STABLE_CRATES, Span, Symbol, sym};
|
||||
@@ -403,6 +404,8 @@ pub(crate) fn cfg_true(&self, attr: &Attribute, emit_errors: ShouldEmit) -> Eval
|
||||
attr,
|
||||
attr.span,
|
||||
self.lint_node_id,
|
||||
// Doesn't matter what the target actually is here.
|
||||
Target::Crate,
|
||||
self.features,
|
||||
emit_errors,
|
||||
parse_cfg,
|
||||
|
||||
@@ -2218,6 +2218,8 @@ fn expand_cfg_true(
|
||||
&attr,
|
||||
attr.span,
|
||||
self.cfg().lint_node_id,
|
||||
// Target doesn't matter for `cfg` parsing.
|
||||
Target::Crate,
|
||||
self.cfg().features,
|
||||
ShouldEmit::ErrorsAndLints,
|
||||
parse_cfg,
|
||||
|
||||
Reference in New Issue
Block a user