Skip to content

Commit 6db15c9

Browse files
authored
Merge branch 'rust-lang:main' into mcga
2 parents 5ec1865 + a3f2d5a commit 6db15c9

250 files changed

Lines changed: 3265 additions & 1964 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.

.github/workflows/post-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
sleep 60
3030
3131
# Get closest bors merge commit
32-
PARENT_COMMIT=`git rev-list --author='bors <bors@rust-lang.org>' -n1 --first-parent HEAD^1`
32+
PARENT_COMMIT=`git rev-list --author='122020455+rust-bors\[bot\]@users.noreply.github.com' -n1 --first-parent HEAD^1`
3333
echo "Parent: ${PARENT_COMMIT}"
3434
3535
# Find PR for the current commit

Cargo.lock

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,9 +3412,9 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
34123412

34133413
[[package]]
34143414
name = "rustc-literal-escaper"
3415-
version = "0.0.5"
3415+
version = "0.0.7"
34163416
source = "registry+https://github.com/rust-lang/crates.io-index"
3417-
checksum = "e4ee29da77c5a54f42697493cd4c9b9f31b74df666a6c04dfc4fde77abe0438b"
3417+
checksum = "8be87abb9e40db7466e0681dc8ecd9dcfd40360cb10b4c8fe24a7c4c3669b198"
34183418

34193419
[[package]]
34203420
name = "rustc-main"
@@ -4421,6 +4421,7 @@ dependencies = [
44214421
"rustc_errors",
44224422
"rustc_fluent_macro",
44234423
"rustc_hir",
4424+
"rustc_index",
44244425
"rustc_macros",
44254426
"rustc_middle",
44264427
"rustc_session",
@@ -5658,6 +5659,7 @@ dependencies = [
56585659
"build_helper",
56595660
"cargo_metadata 0.21.0",
56605661
"fluent-syntax",
5662+
"globset",
56615663
"ignore",
56625664
"miropt-test-tools",
56635665
"regex",

compiler/rustc_arena/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ impl DroplessArena {
618618
/// - Types that are `!Copy` and `Drop`: these must be specified in the
619619
/// arguments. The `TypedArena` will be used for them.
620620
///
621-
#[rustc_macro_transparency = "semitransparent"]
621+
#[rustc_macro_transparency = "semiopaque"]
622622
pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
623623
#[derive(Default)]
624624
pub struct Arena<'tcx> {

compiler/rustc_ast/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2024"
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
99
memchr = "2.7.6"
10-
rustc-literal-escaper = "0.0.5"
10+
rustc-literal-escaper = "0.0.7"
1111
rustc_ast_ir = { path = "../rustc_ast_ir" }
1212
rustc_data_structures = { path = "../rustc_data_structures" }
1313
rustc_index = { path = "../rustc_index" }

compiler/rustc_ast/src/attr/mod.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,34 @@ impl AttributeExt for Attribute {
235235
}
236236
}
237237

238+
fn deprecation_note(&self) -> Option<Symbol> {
239+
match &self.kind {
240+
AttrKind::Normal(normal) if normal.item.path == sym::deprecated => {
241+
let meta = &normal.item;
242+
243+
// #[deprecated = "..."]
244+
if let Some(s) = meta.value_str() {
245+
return Some(s);
246+
}
247+
248+
// #[deprecated(note = "...")]
249+
if let Some(list) = meta.meta_item_list() {
250+
for nested in list {
251+
if let Some(mi) = nested.meta_item()
252+
&& mi.path == sym::note
253+
&& let Some(s) = mi.value_str()
254+
{
255+
return Some(s);
256+
}
257+
}
258+
}
259+
260+
None
261+
}
262+
_ => None,
263+
}
264+
}
265+
238266
fn doc_resolution_scope(&self) -> Option<AttrStyle> {
239267
match &self.kind {
240268
AttrKind::DocComment(..) => Some(self.style),
@@ -277,6 +305,7 @@ impl Attribute {
277305

278306
pub fn may_have_doc_links(&self) -> bool {
279307
self.doc_str().is_some_and(|s| comments::may_have_doc_links(s.as_str()))
308+
|| self.deprecation_note().is_some_and(|s| comments::may_have_doc_links(s.as_str()))
280309
}
281310

282311
/// Extracts the MetaItem from inside this Attribute.
@@ -873,6 +902,11 @@ pub trait AttributeExt: Debug {
873902
/// * `#[doc(...)]` returns `None`.
874903
fn doc_str(&self) -> Option<Symbol>;
875904

905+
/// Returns the deprecation note if this is deprecation attribute.
906+
/// * `#[deprecated = "note"]` returns `Some("note")`.
907+
/// * `#[deprecated(note = "note", ...)]` returns `Some("note")`.
908+
fn deprecation_note(&self) -> Option<Symbol>;
909+
876910
fn is_proc_macro_attr(&self) -> bool {
877911
[sym::proc_macro, sym::proc_macro_attribute, sym::proc_macro_derive]
878912
.iter()

compiler/rustc_ast_lowering/src/index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
312312

313313
fn visit_const_arg(&mut self, const_arg: &'hir ConstArg<'hir, AmbigArg>) {
314314
self.insert(
315-
const_arg.as_unambig_ct().span(),
315+
const_arg.as_unambig_ct().span,
316316
const_arg.hir_id,
317317
Node::ConstArg(const_arg.as_unambig_ct()),
318318
);

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,8 +1986,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19861986
let (name, kind) = self.lower_generic_param_kind(param, source);
19871987

19881988
let hir_id = self.lower_node_id(param.id);
1989-
self.lower_attrs(hir_id, &param.attrs, param.span(), Target::Param);
1990-
hir::GenericParam {
1989+
let param_attrs = &param.attrs;
1990+
let param_span = param.span();
1991+
let param = hir::GenericParam {
19911992
hir_id,
19921993
def_id: self.local_def_id(param.id),
19931994
name,
@@ -1996,7 +1997,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19961997
kind,
19971998
colon_span: param.colon_span.map(|s| self.lower_span(s)),
19981999
source,
1999-
}
2000+
};
2001+
self.lower_attrs(hir_id, param_attrs, param_span, Target::from_generic_param(&param));
2002+
param
20002003
}
20012004

20022005
fn lower_generic_param_kind(
@@ -2285,8 +2288,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22852288
// `ExprKind::Paren(ExprKind::Underscore)` and should also be lowered to `GenericArg::Infer`
22862289
match c.value.peel_parens().kind {
22872290
ExprKind::Underscore => {
2288-
let ct_kind = hir::ConstArgKind::Infer(self.lower_span(c.value.span), ());
2289-
self.arena.alloc(hir::ConstArg { hir_id: self.lower_node_id(c.id), kind: ct_kind })
2291+
let ct_kind = hir::ConstArgKind::Infer(());
2292+
self.arena.alloc(hir::ConstArg {
2293+
hir_id: self.lower_node_id(c.id),
2294+
kind: ct_kind,
2295+
span: self.lower_span(c.value.span),
2296+
})
22902297
}
22912298
_ => self.lower_anon_const_to_const_arg_and_alloc(c),
22922299
}
@@ -2356,7 +2363,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23562363
hir::ConstArgKind::Anon(ct)
23572364
};
23582365

2359-
self.arena.alloc(hir::ConstArg { hir_id: self.next_id(), kind: ct_kind })
2366+
self.arena.alloc(hir::ConstArg {
2367+
hir_id: self.next_id(),
2368+
kind: ct_kind,
2369+
span: self.lower_span(span),
2370+
})
23602371
}
23612372

23622373
fn lower_const_item_rhs(
@@ -2373,9 +2384,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23732384
let const_arg = ConstArg {
23742385
hir_id: self.next_id(),
23752386
kind: hir::ConstArgKind::Error(
2376-
DUMMY_SP,
23772387
self.dcx().span_delayed_bug(DUMMY_SP, "no block"),
23782388
),
2389+
span: DUMMY_SP,
23792390
};
23802391
hir::ConstItemRhs::TypeConst(self.arena.alloc(const_arg))
23812392
}
@@ -2388,13 +2399,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23882399

23892400
#[instrument(level = "debug", skip(self), ret)]
23902401
fn lower_expr_to_const_arg_direct(&mut self, expr: &Expr) -> hir::ConstArg<'hir> {
2402+
let span = self.lower_span(expr.span);
2403+
23912404
let overly_complex_const = |this: &mut Self| {
23922405
let e = this.dcx().struct_span_err(
23932406
expr.span,
23942407
"complex const arguments must be placed inside of a `const` block",
23952408
);
23962409

2397-
ConstArg { hir_id: this.next_id(), kind: hir::ConstArgKind::Error(expr.span, e.emit()) }
2410+
ConstArg { hir_id: this.next_id(), kind: hir::ConstArgKind::Error(e.emit()), span }
23982411
};
23992412

24002413
match &expr.kind {
@@ -2425,8 +2438,26 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24252438
ConstArg {
24262439
hir_id: self.next_id(),
24272440
kind: hir::ConstArgKind::TupleCall(qpath, lowered_args),
2441+
span,
24282442
}
24292443
}
2444+
ExprKind::Tup(exprs) => {
2445+
let exprs = self.arena.alloc_from_iter(exprs.iter().map(|expr| {
2446+
let expr = if let ExprKind::ConstBlock(anon_const) = &expr.kind {
2447+
let def_id = self.local_def_id(anon_const.id);
2448+
let def_kind = self.tcx.def_kind(def_id);
2449+
assert_eq!(DefKind::AnonConst, def_kind);
2450+
2451+
self.lower_anon_const_to_const_arg(anon_const)
2452+
} else {
2453+
self.lower_expr_to_const_arg_direct(&expr)
2454+
};
2455+
2456+
&*self.arena.alloc(expr)
2457+
}));
2458+
2459+
ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Tup(exprs), span }
2460+
}
24302461
ExprKind::Path(qself, path) => {
24312462
let qpath = self.lower_qpath(
24322463
expr.id,
@@ -2439,7 +2470,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24392470
None,
24402471
);
24412472

2442-
ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Path(qpath) }
2473+
ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Path(qpath), span }
24432474
}
24442475
ExprKind::Struct(se) => {
24452476
let path = self.lower_qpath(
@@ -2480,11 +2511,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24802511
})
24812512
}));
24822513

2483-
ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Struct(path, fields) }
2514+
ConstArg {
2515+
hir_id: self.next_id(),
2516+
kind: hir::ConstArgKind::Struct(path, fields),
2517+
span,
2518+
}
24842519
}
24852520
ExprKind::Underscore => ConstArg {
24862521
hir_id: self.lower_node_id(expr.id),
2487-
kind: hir::ConstArgKind::Infer(expr.span, ()),
2522+
kind: hir::ConstArgKind::Infer(()),
2523+
span,
24882524
},
24892525
ExprKind::Block(block, _) => {
24902526
if let [stmt] = block.stmts.as_slice()
@@ -2495,13 +2531,24 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24952531
| ExprKind::Path(..)
24962532
| ExprKind::Struct(..)
24972533
| ExprKind::Call(..)
2534+
| ExprKind::Tup(..)
24982535
)
24992536
{
25002537
return self.lower_expr_to_const_arg_direct(expr);
25012538
}
25022539

25032540
overly_complex_const(self)
25042541
}
2542+
ExprKind::Lit(literal) => {
2543+
let span = expr.span;
2544+
let literal = self.lower_lit(literal, span);
2545+
2546+
ConstArg {
2547+
hir_id: self.lower_node_id(expr.id),
2548+
kind: hir::ConstArgKind::Literal(literal.node),
2549+
span,
2550+
}
2551+
}
25052552
_ => overly_complex_const(self),
25062553
}
25072554
}
@@ -2528,7 +2575,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25282575
return match anon.mgca_disambiguation {
25292576
MgcaDisambiguation::AnonConst => {
25302577
let lowered_anon = self.lower_anon_const_to_anon_const(anon);
2531-
ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Anon(lowered_anon) }
2578+
ConstArg {
2579+
hir_id: self.next_id(),
2580+
kind: hir::ConstArgKind::Anon(lowered_anon),
2581+
span: lowered_anon.span,
2582+
}
25322583
}
25332584
MgcaDisambiguation::Direct => self.lower_expr_to_const_arg_direct(&anon.value),
25342585
};
@@ -2565,11 +2616,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25652616
return ConstArg {
25662617
hir_id: self.lower_node_id(anon.id),
25672618
kind: hir::ConstArgKind::Path(qpath),
2619+
span: self.lower_span(expr.span),
25682620
};
25692621
}
25702622

25712623
let lowered_anon = self.lower_anon_const_to_anon_const(anon);
2572-
ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Anon(lowered_anon) }
2624+
ConstArg {
2625+
hir_id: self.next_id(),
2626+
kind: hir::ConstArgKind::Anon(lowered_anon),
2627+
span: self.lower_span(expr.span),
2628+
}
25732629
}
25742630

25752631
/// See [`hir::ConstArg`] for when to use this function vs

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
513513
self.arena.alloc(hir::ConstArg {
514514
hir_id: self.next_id(),
515515
kind: hir::ConstArgKind::Anon(self.arena.alloc(anon_const)),
516+
span,
516517
})
517518
}
518519

@@ -557,6 +558,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
557558
})
558559
});
559560
let hir_id = self.next_id();
560-
self.arena.alloc(hir::ConstArg { kind: hir::ConstArgKind::Anon(ct), hir_id })
561+
self.arena.alloc(hir::ConstArg { kind: hir::ConstArgKind::Anon(ct), hir_id, span })
561562
}
562563
}

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::num::NonZero;
22

33
use rustc_errors::ErrorGuaranteed;
4+
use rustc_hir::target::GenericParamKind;
45
use rustc_hir::{
56
DefaultBodyStability, MethodKind, PartialConstStability, Stability, StabilityLevel,
67
StableSince, Target, UnstableReason, VERSION_PLACEHOLDER,
@@ -43,7 +44,7 @@ const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
4344
Allow(Target::TyAlias),
4445
Allow(Target::Variant),
4546
Allow(Target::Field),
46-
Allow(Target::Param),
47+
Allow(Target::GenericParam { kind: GenericParamKind::Type, has_default: true }),
4748
Allow(Target::Static),
4849
Allow(Target::ForeignFn),
4950
Allow(Target::ForeignStatic),

compiler/rustc_attr_parsing/src/attributes/transparency.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl<S: Stage> SingleAttributeParser<S> for TransparencyParser {
1515
});
1616
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::MacroDef)]);
1717
const TEMPLATE: AttributeTemplate =
18-
template!(NameValueStr: ["transparent", "semitransparent", "opaque"]);
18+
template!(NameValueStr: ["transparent", "semiopaque", "opaque"]);
1919

2020
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
2121
let Some(nv) = args.name_value() else {
@@ -24,12 +24,12 @@ impl<S: Stage> SingleAttributeParser<S> for TransparencyParser {
2424
};
2525
match nv.value_as_str() {
2626
Some(sym::transparent) => Some(Transparency::Transparent),
27-
Some(sym::semiopaque | sym::semitransparent) => Some(Transparency::SemiOpaque),
27+
Some(sym::semiopaque) => Some(Transparency::SemiOpaque),
2828
Some(sym::opaque) => Some(Transparency::Opaque),
2929
Some(_) => {
3030
cx.expected_specific_argument_strings(
3131
nv.value_span,
32-
&[sym::transparent, sym::semitransparent, sym::opaque],
32+
&[sym::transparent, sym::semiopaque, sym::opaque],
3333
);
3434
None
3535
}

0 commit comments

Comments
 (0)