attr parsing: make sure we pass the right target when errors could be emitted

This commit is contained in:
Sasha Pourcelot
2026-04-06 07:31:34 +00:00
parent c2efcc4ae0
commit 6be1404216
2 changed files with 7 additions and 2 deletions
+3 -1
View File
@@ -64,6 +64,7 @@ pub fn parse_limited(
sym,
target_span,
target_node_id,
Target::Crate, // Does not matter, we're not going to emit errors anyways
features,
ShouldEmit::Nothing,
)
@@ -79,6 +80,7 @@ pub fn parse_limited_should_emit(
sym: Symbol,
target_span: Span,
target_node_id: NodeId,
target: Target,
features: Option<&'sess Features>,
should_emit: ShouldEmit,
) -> Option<Attribute> {
@@ -86,7 +88,7 @@ pub fn parse_limited_should_emit(
sess,
attrs,
Some(sym),
Target::Crate, // Does not matter, we're not going to emit errors anyways
target,
target_span,
target_node_id,
features,
+4 -1
View File
@@ -22,7 +22,7 @@
use rustc_hir::definitions::Definitions;
use rustc_hir::limit::Limit;
use rustc_hir::lints::DelayedLint;
use rustc_hir::{Attribute, MaybeOwner, find_attr};
use rustc_hir::{Attribute, MaybeOwner, Target, find_attr};
use rustc_incremental::setup_dep_graph;
use rustc_lint::{
BufferedEarlyLint, DecorateAttrLint, EarlyCheckNode, LintStore, unerased_lint_store,
@@ -1372,6 +1372,7 @@ pub(crate) fn parse_crate_name(
sym::crate_name,
DUMMY_SP,
rustc_ast::node_id::CRATE_NODE_ID,
Target::Crate,
None,
emit_errors,
)?
@@ -1421,6 +1422,7 @@ pub fn collect_crate_types(
sym::crate_type,
crate_span,
CRATE_NODE_ID,
Target::Crate,
None,
ShouldEmit::EarlyFatal { also_emit_lints: false },
)
@@ -1477,6 +1479,7 @@ fn get_recursion_limit(krate_attrs: &[ast::Attribute], sess: &Session) -> Limit
sym::recursion_limit,
DUMMY_SP,
rustc_ast::node_id::CRATE_NODE_ID,
Target::Crate,
None,
// errors are fatal here, but lints aren't.
// If things aren't fatal we continue, and will parse this again.