Skip to content

Commit db16a09

Browse files
committed
Auto merge of #146409 - matthiaskrgr:rollup-thju381, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #144765 (inclusive `Range`s: change `end` to `last`) - #146178 (Implement `#[rustc_align_static(N)]` on `static`s) - #146368 (CI: rfl: move job forward to Linux v6.17-rc5 to remove temporary commits) - #146378 (Update wasm-component-ld to 0.5.17) - #146391 (Trim paths less in MIR dumping) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7ad23f4 + 212baec commit db16a09

File tree

49 files changed

+530
-97
lines changed

Some content is hidden

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

49 files changed

+530
-97
lines changed

Cargo.lock

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5984,19 +5984,19 @@ dependencies = [
59845984

59855985
[[package]]
59865986
name = "wasm-component-ld"
5987-
version = "0.5.16"
5987+
version = "0.5.17"
59885988
source = "registry+https://github.com/rust-lang/crates.io-index"
5989-
checksum = "14cd35d6cae91109a0ffd207b573cf3c741cab7e921dd376ea7aaf2c52a3408c"
5989+
checksum = "1c9208f87cac2332fd80dcf36d54e9163d3446e28301e0c6e424984425738984"
59905990
dependencies = [
59915991
"anyhow",
59925992
"clap",
59935993
"lexopt",
59945994
"libc",
59955995
"tempfile",
59965996
"wasi-preview1-component-adapter-provider",
5997-
"wasmparser 0.237.0",
5997+
"wasmparser 0.239.0",
59985998
"wat",
5999-
"windows-sys 0.59.0",
5999+
"windows-sys 0.60.2",
60006000
"winsplit",
60016001
"wit-component",
60026002
"wit-parser",
@@ -6021,24 +6021,24 @@ dependencies = [
60216021

60226022
[[package]]
60236023
name = "wasm-encoder"
6024-
version = "0.237.0"
6024+
version = "0.239.0"
60256025
source = "registry+https://github.com/rust-lang/crates.io-index"
6026-
checksum = "efe92d1321afa53ffc88a57c497bb7330c3cf84c98ffdba4a4caf6a0684fad3c"
6026+
checksum = "5be00faa2b4950c76fe618c409d2c3ea5a3c9422013e079482d78544bb2d184c"
60276027
dependencies = [
60286028
"leb128fmt",
6029-
"wasmparser 0.237.0",
6029+
"wasmparser 0.239.0",
60306030
]
60316031

60326032
[[package]]
60336033
name = "wasm-metadata"
6034-
version = "0.237.0"
6034+
version = "0.239.0"
60356035
source = "registry+https://github.com/rust-lang/crates.io-index"
6036-
checksum = "4cc0b0a0c4f35ca6efa7a797671372915d4e9659dba2d59edc6fafc931d19997"
6036+
checksum = "20b3ec880a9ac69ccd92fbdbcf46ee833071cf09f82bb005b2327c7ae6025ae2"
60376037
dependencies = [
60386038
"anyhow",
60396039
"indexmap",
6040-
"wasm-encoder 0.237.0",
6041-
"wasmparser 0.237.0",
6040+
"wasm-encoder 0.239.0",
6041+
"wasmparser 0.239.0",
60426042
]
60436043

60446044
[[package]]
@@ -6063,9 +6063,9 @@ dependencies = [
60636063

60646064
[[package]]
60656065
name = "wasmparser"
6066-
version = "0.237.0"
6066+
version = "0.239.0"
60676067
source = "registry+https://github.com/rust-lang/crates.io-index"
6068-
checksum = "7d2a40ca0d2bdf4b0bf36c13a737d0b2c58e4c8aaefe1c57f336dd75369ca250"
6068+
checksum = "8c9d90bb93e764f6beabf1d02028c70a2156a6583e63ac4218dd07ef733368b0"
60696069
dependencies = [
60706070
"bitflags",
60716071
"hashbrown",
@@ -6076,22 +6076,22 @@ dependencies = [
60766076

60776077
[[package]]
60786078
name = "wast"
6079-
version = "237.0.0"
6079+
version = "239.0.0"
60806080
source = "registry+https://github.com/rust-lang/crates.io-index"
6081-
checksum = "fcf66f545acbd55082485cb9a6daab54579cb8628a027162253e8e9f5963c767"
6081+
checksum = "9139176fe8a2590e0fb174cdcaf373b224cb93c3dde08e4297c1361d2ba1ea5d"
60826082
dependencies = [
60836083
"bumpalo",
60846084
"leb128fmt",
60856085
"memchr",
60866086
"unicode-width 0.2.1",
6087-
"wasm-encoder 0.237.0",
6087+
"wasm-encoder 0.239.0",
60886088
]
60896089

60906090
[[package]]
60916091
name = "wat"
6092-
version = "1.237.0"
6092+
version = "1.239.0"
60936093
source = "registry+https://github.com/rust-lang/crates.io-index"
6094-
checksum = "27975186f549e4b8d6878b627be732863883c72f7bf4dcf8f96e5f8242f73da9"
6094+
checksum = "3e1c941927d34709f255558166f8901a2005f8ab4a9650432e9281b7cc6f3b75"
60956095
dependencies = [
60966096
"wast",
60976097
]
@@ -6580,9 +6580,9 @@ dependencies = [
65806580

65816581
[[package]]
65826582
name = "wit-component"
6583-
version = "0.237.0"
6583+
version = "0.239.0"
65846584
source = "registry+https://github.com/rust-lang/crates.io-index"
6585-
checksum = "bfb7674f76c10e82fe00b256a9d4ffb2b8d037d42ab8e9a83ebb3be35c9d0bf6"
6585+
checksum = "88a866b19dba2c94d706ec58c92a4c62ab63e482b4c935d2a085ac94caecb136"
65866586
dependencies = [
65876587
"anyhow",
65886588
"bitflags",
@@ -6591,17 +6591,17 @@ dependencies = [
65916591
"serde",
65926592
"serde_derive",
65936593
"serde_json",
6594-
"wasm-encoder 0.237.0",
6594+
"wasm-encoder 0.239.0",
65956595
"wasm-metadata",
6596-
"wasmparser 0.237.0",
6596+
"wasmparser 0.239.0",
65976597
"wit-parser",
65986598
]
65996599

66006600
[[package]]
66016601
name = "wit-parser"
6602-
version = "0.237.0"
6602+
version = "0.239.0"
66036603
source = "registry+https://github.com/rust-lang/crates.io-index"
6604-
checksum = "ce2596a5bc7c24cc965b56ad6ff9e32394c4e401764f89620a888519c6e849ab"
6604+
checksum = "55c92c939d667b7bf0c6bf2d1f67196529758f99a2a45a3355cc56964fd5315d"
66056605
dependencies = [
66066606
"anyhow",
66076607
"id-arena",
@@ -6612,7 +6612,7 @@ dependencies = [
66126612
"serde_derive",
66136613
"serde_json",
66146614
"unicode-xid",
6615-
"wasmparser 0.237.0",
6615+
"wasmparser 0.239.0",
66166616
]
66176617

66186618
[[package]]

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
15361536
hir::LangItem::Range
15371537
}
15381538
}
1539-
(None, Some(..), Closed) => hir::LangItem::RangeToInclusive,
1539+
(None, Some(..), Closed) => {
1540+
if self.tcx.features().new_range() {
1541+
hir::LangItem::RangeToInclusiveCopy
1542+
} else {
1543+
hir::LangItem::RangeToInclusive
1544+
}
1545+
}
15401546
(Some(e1), Some(e2), Closed) => {
15411547
if self.tcx.features().new_range() {
15421548
hir::LangItem::RangeInclusiveCopy
@@ -1560,13 +1566,26 @@ impl<'hir> LoweringContext<'_, 'hir> {
15601566
};
15611567

15621568
let fields = self.arena.alloc_from_iter(
1563-
e1.iter().map(|e| (sym::start, e)).chain(e2.iter().map(|e| (sym::end, e))).map(
1564-
|(s, e)| {
1569+
e1.iter()
1570+
.map(|e| (sym::start, e))
1571+
.chain(e2.iter().map(|e| {
1572+
(
1573+
if matches!(
1574+
lang_item,
1575+
hir::LangItem::RangeInclusiveCopy | hir::LangItem::RangeToInclusiveCopy
1576+
) {
1577+
sym::last
1578+
} else {
1579+
sym::end
1580+
},
1581+
e,
1582+
)
1583+
}))
1584+
.map(|(s, e)| {
15651585
let expr = self.lower_expr(e);
15661586
let ident = Ident::new(s, self.lower_span(e.span));
15671587
self.expr_field(ident, expr, e.span)
1568-
},
1569-
),
1588+
}),
15701589
);
15711590

15721591
hir::ExprKind::Struct(

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ impl<S: Stage> AttributeParser<S> for NakedParser {
218218
sym::rustc_std_internal_symbol,
219219
// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity
220220
sym::rustc_align,
221+
sym::rustc_align_static,
221222
// obviously compatible with self
222223
sym::naked,
223224
// documentation

compiler/rustc_attr_parsing/src/attributes/repr.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,30 @@ impl<S: Stage> AttributeParser<S> for AlignParser {
331331
Some(AttributeKind::Align { align, span })
332332
}
333333
}
334+
335+
#[derive(Default)]
336+
pub(crate) struct AlignStaticParser(AlignParser);
337+
338+
impl AlignStaticParser {
339+
const PATH: &'static [Symbol] = &[sym::rustc_align_static];
340+
const TEMPLATE: AttributeTemplate = AlignParser::TEMPLATE;
341+
342+
fn parse<'c, S: Stage>(
343+
&mut self,
344+
cx: &'c mut AcceptContext<'_, '_, S>,
345+
args: &'c ArgParser<'_>,
346+
) {
347+
self.0.parse(cx, args)
348+
}
349+
}
350+
351+
impl<S: Stage> AttributeParser<S> for AlignStaticParser {
352+
const ATTRIBUTES: AcceptMapping<Self, S> = &[(Self::PATH, Self::TEMPLATE, Self::parse)];
353+
const ALLOWED_TARGETS: AllowedTargets =
354+
AllowedTargets::AllowList(&[Allow(Target::Static), Allow(Target::ForeignStatic)]);
355+
356+
fn finalize(self, _cx: &FinalizeContext<'_, '_, S>) -> Option<AttributeKind> {
357+
let (align, span) = self.0.0?;
358+
Some(AttributeKind::Align { align, span })
359+
}
360+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use crate::attributes::proc_macro_attrs::{
5050
ProcMacroAttributeParser, ProcMacroDeriveParser, ProcMacroParser, RustcBuiltinMacroParser,
5151
};
5252
use crate::attributes::prototype::CustomMirParser;
53-
use crate::attributes::repr::{AlignParser, ReprParser};
53+
use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser};
5454
use crate::attributes::rustc_internal::{
5555
RustcLayoutScalarValidRangeEnd, RustcLayoutScalarValidRangeStart,
5656
RustcObjectLifetimeDefaultParser,
@@ -152,6 +152,7 @@ attribute_parsers!(
152152
pub(crate) static ATTRIBUTE_PARSERS = [
153153
// tidy-alphabetical-start
154154
AlignParser,
155+
AlignStaticParser,
155156
BodyStabilityParser,
156157
ConfusablesParser,
157158
ConstStabilityParser,

compiler/rustc_codegen_gcc/src/consts.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
8181
if global.to_rvalue().get_type() != val_llty {
8282
global.to_rvalue().set_type(val_llty);
8383
}
84+
85+
// NOTE: Alignment from attributes has already been applied to the allocation.
8486
set_global_alignment(self, global, alloc.align);
8587

8688
global.global_set_initializer_rvalue(value);

compiler/rustc_codegen_llvm/src/consts.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ impl<'ll> CodegenCx<'ll, '_> {
452452
self.statics_to_rauw.borrow_mut().push((g, new_g));
453453
new_g
454454
};
455+
456+
// NOTE: Alignment from attributes has already been applied to the allocation.
455457
set_global_alignment(self, g, alloc.align);
456458
llvm::set_initializer(g, v);
457459

compiler/rustc_const_eval/src/interpret/memory.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
953953

954954
// # Global allocations
955955
if let Some(global_alloc) = self.tcx.try_get_global_alloc(id) {
956+
// NOTE: `static` alignment from attributes has already been applied to the allocation.
956957
let (size, align) = global_alloc.size_and_align(*self.tcx, self.typing_env);
957958
let mutbl = global_alloc.mutability(*self.tcx, self.typing_env);
958959
let kind = match global_alloc {

compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_hir::def_id::LocalDefId;
22
use rustc_middle::mir;
3-
use rustc_middle::mir::interpret::{AllocInit, Allocation, InterpResult, Pointer};
3+
use rustc_middle::mir::interpret::{AllocInit, Allocation, GlobalAlloc, InterpResult, Pointer};
44
use rustc_middle::ty::layout::TyAndLayout;
55
use rustc_middle::ty::{TyCtxt, TypeVisitable, TypeVisitableExt};
66
use tracing::debug;
@@ -38,7 +38,14 @@ pub(crate) fn create_static_alloc<'tcx>(
3838
static_def_id: LocalDefId,
3939
layout: TyAndLayout<'tcx>,
4040
) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
41-
let alloc = Allocation::try_new(layout.size, layout.align.abi, AllocInit::Uninit, ())?;
41+
// Inherit size and align from the `GlobalAlloc::Static` so we can avoid duplicating
42+
// the alignment attribute logic.
43+
let (size, align) =
44+
GlobalAlloc::Static(static_def_id.into()).size_and_align(*ecx.tcx, ecx.typing_env);
45+
assert_eq!(size, layout.size);
46+
assert!(align >= layout.align.abi);
47+
48+
let alloc = Allocation::try_new(size, align, AllocInit::Uninit, ())?;
4249
let alloc_id = ecx.tcx.reserve_and_set_static_alloc(static_def_id.into());
4350
assert_eq!(ecx.machine.static_root_ids, None);
4451
ecx.machine.static_root_ids = Some((alloc_id, static_def_id));

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
621621
),
622622
// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity
623623
gated!(rustc_align, Normal, template!(List: &["alignment"]), DuplicatesOk, EncodeCrossCrate::No, fn_align, experimental!(rustc_align)),
624+
gated!(rustc_align_static, Normal, template!(List: &["alignment"]), DuplicatesOk, EncodeCrossCrate::No, static_align, experimental!(rustc_align_static)),
624625
ungated!(
625626
unsafe(Edition2024) export_name, Normal,
626627
template!(NameValueStr: "name", "https://doc.rust-lang.org/reference/abi.html#the-export_name-attribute"),

0 commit comments

Comments
 (0)