Skip to content

Commit 2973fd5

Browse files
Rollup merge of #154876 - scrabsha:push-ymvvtywqttlq, r=JonathanBrouwer
attr parsing: make sure we pass the right target when errors could be emitted
2 parents cb3b8ff + 6be1404 commit 2973fd5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

compiler/rustc_attr_parsing/src/interface.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ impl<'sess> AttributeParser<'sess, Early> {
6464
sym,
6565
target_span,
6666
target_node_id,
67+
Target::Crate, // Does not matter, we're not going to emit errors anyways
6768
features,
6869
ShouldEmit::Nothing,
6970
)
@@ -79,14 +80,15 @@ impl<'sess> AttributeParser<'sess, Early> {
7980
sym: Symbol,
8081
target_span: Span,
8182
target_node_id: NodeId,
83+
target: Target,
8284
features: Option<&'sess Features>,
8385
should_emit: ShouldEmit,
8486
) -> Option<Attribute> {
8587
let mut parsed = Self::parse_limited_all(
8688
sess,
8789
attrs,
8890
Some(sym),
89-
Target::Crate, // Does not matter, we're not going to emit errors anyways
91+
target,
9092
target_span,
9193
target_node_id,
9294
features,

compiler/rustc_interface/src/passes.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_hir::def_id::{LOCAL_CRATE, StableCrateId, StableCrateIdMap};
2222
use rustc_hir::definitions::Definitions;
2323
use rustc_hir::limit::Limit;
2424
use rustc_hir::lints::DelayedLint;
25-
use rustc_hir::{Attribute, MaybeOwner, find_attr};
25+
use rustc_hir::{Attribute, MaybeOwner, Target, find_attr};
2626
use rustc_incremental::setup_dep_graph;
2727
use rustc_lint::{
2828
BufferedEarlyLint, DecorateAttrLint, EarlyCheckNode, LintStore, unerased_lint_store,
@@ -1372,6 +1372,7 @@ pub(crate) fn parse_crate_name(
13721372
sym::crate_name,
13731373
DUMMY_SP,
13741374
rustc_ast::node_id::CRATE_NODE_ID,
1375+
Target::Crate,
13751376
None,
13761377
emit_errors,
13771378
)?
@@ -1421,6 +1422,7 @@ pub fn collect_crate_types(
14211422
sym::crate_type,
14221423
crate_span,
14231424
CRATE_NODE_ID,
1425+
Target::Crate,
14241426
None,
14251427
ShouldEmit::EarlyFatal { also_emit_lints: false },
14261428
)
@@ -1477,6 +1479,7 @@ fn get_recursion_limit(krate_attrs: &[ast::Attribute], sess: &Session) -> Limit
14771479
sym::recursion_limit,
14781480
DUMMY_SP,
14791481
rustc_ast::node_id::CRATE_NODE_ID,
1482+
Target::Crate,
14801483
None,
14811484
// errors are fatal here, but lints aren't.
14821485
// If things aren't fatal we continue, and will parse this again.

0 commit comments

Comments
 (0)