Skip to content

Commit 78e2794

Browse files
committed
Auto merge of #162089 - JonathanBrouwer:rollup-C05CNwv, r=<try>
Rollup of 12 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple-1 try-job: aarch64-apple-2 try-job: x86_64-mingw-1 try-job: i686-msvc-1 try-job: i686-msvc-2
2 parents 0dfb098 + dca4e59 commit 78e2794

234 files changed

Lines changed: 4102 additions & 1902 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3634,6 +3634,7 @@ version = "0.0.0"
36343634
dependencies = [
36353635
"rustc_abi",
36363636
"rustc_ast",
3637+
"rustc_attr_ir",
36373638
"rustc_attr_parsing",
36383639
"rustc_data_structures",
36393640
"rustc_errors",
@@ -4068,6 +4069,7 @@ name = "rustc_feature"
40684069
version = "0.0.0"
40694070
dependencies = [
40704071
"rustc_data_structures",
4072+
"rustc_macros",
40714073
"rustc_span",
40724074
"serde",
40734075
"serde_json",

compiler/rustc_ast_lowering/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ doctest = false
1010
# tidy-alphabetical-start
1111
rustc_abi = { path = "../rustc_abi" }
1212
rustc_ast = { path = "../rustc_ast" }
13+
rustc_attr_ir = { path = "../rustc_attr_ir" }
1314
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
1415
rustc_data_structures = { path = "../rustc_data_structures" }
1516
rustc_errors = { path = "../rustc_errors" }

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ use std::ops::ControlFlow;
33
use std::sync::Arc;
44

55
use rustc_ast::node_id::NodeMap;
6+
use rustc_ast::visit::{Visitor, walk_expr};
67
use rustc_ast::*;
8+
use rustc_attr_ir::lang_items::LangItem;
9+
use rustc_attr_ir::target::Target;
710
use rustc_errors::msg;
811
use rustc_hir as hir;
9-
use rustc_hir::attrs::lang_items::LangItem;
12+
use rustc_hir::HirId;
1013
use rustc_hir::def::{DefKind, Res};
11-
use rustc_hir::{HirId, Target, find_attr};
1214
use rustc_middle::span_bug;
1315
use rustc_middle::ty::TyCtxt;
1416
use rustc_session::diagnostics::report_lit_error;
1517
use rustc_span::{ByteSymbol, DUMMY_SP, DesugaringKind, Ident, Span, Spanned, Symbol, respan, sym};
1618
use thin_vec::{ThinVec, thin_vec};
17-
use visit::{Visitor, walk_expr};
18-
1919
mod closure;
2020

2121
use crate::diagnostics::{
@@ -882,35 +882,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
882882

883883
/// Forwards a possible `#[track_caller]` annotation from `outer_hir_id` to
884884
/// `inner_hir_id` in case the `async_fn_track_caller` feature is enabled.
885-
pub(super) fn maybe_forward_track_caller(
886-
&mut self,
887-
span: Span,
888-
outer_hir_id: HirId,
889-
inner_hir_id: HirId,
890-
) {
885+
pub(super) fn maybe_forward_track_caller(&mut self, outer_hir_id: HirId, inner_hir_id: HirId) {
891886
if self.tcx.features().async_fn_track_caller()
892887
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
893-
&& find_attr!(*attrs, TrackCaller(_))
888+
&& let Some(t) = attrs.iter().find(|a| {
889+
matches!(
890+
a,
891+
rustc_attr_ir::Attribute::Parsed(rustc_attr_ir::AttributeKind::TrackCaller(_))
892+
)
893+
})
894894
{
895-
let unstable_span = self.mark_span_with_reason(
896-
DesugaringKind::Async,
897-
span,
898-
Some(Arc::clone(&self.allow_gen_future)),
899-
);
900-
self.lower_attrs(
901-
inner_hir_id,
902-
&[Attribute {
903-
kind: AttrKind::Normal(Box::new(NormalAttr::from_ident(Ident::new(
904-
sym::track_caller,
905-
span,
906-
)))),
907-
id: self.tcx.sess.psess.attr_id_generator.mk_attr_id(),
908-
style: AttrStyle::Outer,
909-
span: unstable_span,
910-
}],
911-
span,
912-
Target::Fn,
913-
);
895+
self.attrs.insert(inner_hir_id.local_id, std::slice::from_ref(t));
914896
}
915897
}
916898

compiler/rustc_ast_lowering/src/expr/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
343343
)
344344
});
345345

346-
this.maybe_forward_track_caller(body.span, closure_hir_id, expr.hir_id);
346+
this.maybe_forward_track_caller(closure_hir_id, expr.hir_id);
347347

348348
(parameters, expr)
349349
});

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14621462

14631463
// FIXME(async_fn_track_caller): Can this be moved above?
14641464
let hir_id = expr.hir_id;
1465-
this.maybe_forward_track_caller(body.span, fn_id, hir_id);
1465+
this.maybe_forward_track_caller(fn_id, hir_id);
14661466

14671467
(parameters, expr)
14681468
})

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ fn parse_cfg_attr_internal<'a>(
436436
}
437437

438438
fn try_gate_cfg(name: Symbol, span: Span, sess: &Session, features: Option<&Features>) {
439-
let gate = find_gated_cfg(|sym| sym == name);
439+
let gate = find_gated_cfg(name);
440440
if let (Some(feats), Some(gated_cfg)) = (features, gate) {
441441
gate_cfg(gated_cfg, span, sess, feats);
442442
}

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,15 @@ impl NoArgsAttributeParser for TrackCallerParser {
364364
});
365365
}
366366
}
367+
Target::Closure if !cx.features().closure_track_caller() => {
368+
feature_err(
369+
cx.sess(),
370+
sym::closure_track_caller,
371+
attr_span,
372+
"`#[track_caller]` on closures is currently unstable",
373+
)
374+
.emit();
375+
}
367376
_ => {}
368377
}
369378
}

compiler/rustc_attr_parsing/src/attributes/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn check_keyword(cx: &mut AcceptContext<'_, '_>, keyword: Symbol, span: Span) ->
4343

4444
fn check_attribute(cx: &mut AcceptContext<'_, '_>, attribute: Symbol, span: Span) -> bool {
4545
// FIXME: This should support attributes with namespace like `diagnostic::do_not_recommend`.
46-
if rustc_feature::BUILTIN_ATTRIBUTE_MAP.contains(&attribute) {
46+
if rustc_feature::BUILTIN_ATTRIBUTE_SET.contains(&attribute) {
4747
return true;
4848
}
4949
cx.emit_err(DocAttributeNotAttribute { span, attribute });

compiler/rustc_attr_parsing/src/interface.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_attr_ir::target::Target;
1010
use rustc_attr_ir::{AttrArgs, AttrItem, AttrPath, Attribute, AttributeKind, HashIgnoredAttrId};
1111
use rustc_data_structures::sync::{DynSend, DynSync};
1212
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, MultiSpan};
13-
use rustc_feature::{BUILTIN_ATTRIBUTE_MAP, Features};
13+
use rustc_feature::{BUILTIN_ATTRIBUTE_SET, Features};
1414
use rustc_lint_defs::{LintId, RegisteredTools};
1515
use rustc_session::Session;
1616
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
@@ -376,7 +376,7 @@ impl<'sess> AttributeParser<'sess> {
376376
);
377377
self.check_attribute_stability(&attr_path, attr_span, accept.stability);
378378
if let [part] = parts.as_slice() {
379-
debug_assert!(BUILTIN_ATTRIBUTE_MAP.contains(part));
379+
debug_assert!(BUILTIN_ATTRIBUTE_SET.contains(part));
380380
}
381381

382382
let Some(args) = ArgParser::from_attr_args(

compiler/rustc_attr_parsing/src/validate_attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_ast::{
1111
};
1212
use rustc_attr_ir::AttrPath;
1313
use rustc_errors::{Applicability, Diagnostic, PResult};
14-
use rustc_feature::BUILTIN_ATTRIBUTE_MAP;
14+
use rustc_feature::BUILTIN_ATTRIBUTE_SET;
1515
use rustc_lint_defs::builtin::ILL_FORMED_ATTRIBUTE_INPUT;
1616
use rustc_parse::parse_in;
1717
use rustc_session::diagnostics::report_lit_error;
@@ -27,7 +27,7 @@ pub fn check_attr(psess: &ParseSess, attr: &Attribute) {
2727
AttrKind::Synthetic(CfgTrace(_) | CfgAttrTrace(_)) | AttrKind::DocComment(..) => return,
2828
}
2929

30-
let builtin_attr_info = attr.name().and_then(|name| BUILTIN_ATTRIBUTE_MAP.get(&name));
30+
let builtin_attr_info = attr.name().and_then(|name| BUILTIN_ATTRIBUTE_SET.get(&name));
3131

3232
// Check input tokens for built-in and key-value attributes.
3333
if let Some(name) = builtin_attr_info {

0 commit comments

Comments
 (0)