Skip to content

Commit d0e7772

Browse files
committed
Auto merge of rust-lang#3561 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 7eda989 + a040df7 commit d0e7772

File tree

351 files changed

+2497
-1460
lines changed

Some content is hidden

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

351 files changed

+2497
-1460
lines changed

Cargo.lock

-4
Original file line numberDiff line numberDiff line change
@@ -3824,7 +3824,6 @@ dependencies = [
38243824
"rustc_session",
38253825
"rustc_smir",
38263826
"rustc_span",
3827-
"rustc_symbol_mangling",
38283827
"rustc_target",
38293828
"rustc_trait_selection",
38303829
"rustc_ty_utils",
@@ -4008,7 +4007,6 @@ dependencies = [
40084007
"rustc_data_structures",
40094008
"rustc_errors",
40104009
"rustc_fluent_macro",
4011-
"rustc_graphviz",
40124010
"rustc_hir",
40134011
"rustc_hir_analysis",
40144012
"rustc_hir_pretty",
@@ -4468,7 +4466,6 @@ dependencies = [
44684466
"rustc_errors",
44694467
"rustc_fluent_macro",
44704468
"rustc_hir",
4471-
"rustc_hir_analysis",
44724469
"rustc_macros",
44734470
"rustc_middle",
44744471
"rustc_session",
@@ -4515,7 +4512,6 @@ dependencies = [
45154512
"rustc_session",
45164513
"rustc_span",
45174514
"rustc_target",
4518-
"rustc_type_ir",
45194515
"smallvec",
45204516
"thin-vec",
45214517
"tracing",

RELEASES.md

+4
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ Compatibility Notes
102102
- [Change equality of higher ranked types to not rely on subtyping](https://github.com/rust-lang/rust/pull/118247)
103103
- [When called, additionally check bounds on normalized function return type](https://github.com/rust-lang/rust/pull/118882)
104104
- [Expand coverage for `arithmetic_overflow` lint](https://github.com/rust-lang/rust/pull/119432/)
105+
- [Fix detection of potential interior mutability in `const` initializers](https://github.com/rust-lang/rust/issues/121250)
106+
This code was accidentally accepted. The fix can break generic code that borrows a value of unknown type,
107+
as there is currently no way to declare "this type has no interior mutability". In the future, stabilizing
108+
the [`Freeze` trait](https://github.com/rust-lang/rust/issues/121675) will allow proper support for such code.
105109

106110
<a id="1.78.0-Internal-Changes"></a>
107111

compiler/rustc/src/main.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(unix_sigpipe)]
2-
31
// A note about jemalloc: rustc uses jemalloc when built for CI and
42
// distribution. The obvious way to do this is with the `#[global_allocator]`
53
// mechanism. However, for complicated reasons (see
@@ -34,7 +32,6 @@
3432
// https://github.com/rust-lang/rust/commit/b90cfc887c31c3e7a9e6d462e2464db1fe506175#diff-43914724af6e464c1da2171e4a9b6c7e607d5bc1203fa95c0ab85be4122605ef
3533
// for an example of how to do so.
3634

37-
#[unix_sigpipe = "sig_dfl"]
3835
fn main() {
3936
// See the comment at the top of this file for an explanation of this.
4037
#[cfg(feature = "jemalloc-sys")]

compiler/rustc_abi/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ use rustc_macros::{Decodable_Generic, Encodable_Generic};
2121
use std::iter::Step;
2222

2323
mod layout;
24+
#[cfg(test)]
25+
mod tests;
2426

2527
pub use layout::LayoutCalculator;
2628

compiler/rustc_abi/src/tests.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use super::*;
2+
3+
#[test]
4+
fn align_constants() {
5+
assert_eq!(Align::ONE, Align::from_bytes(1).unwrap());
6+
assert_eq!(Align::EIGHT, Align::from_bytes(8).unwrap());
7+
}

compiler/rustc_ast_lowering/src/index.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub(super) fn index_hir<'hir>(
6262
if let Node::Err(span) = node.node {
6363
let hir_id = HirId { owner: item.def_id(), local_id };
6464
let msg = format!("ID {hir_id} not encountered when visiting item HIR");
65-
tcx.dcx().span_delayed_bug(*span, msg);
65+
tcx.dcx().span_delayed_bug(span, msg);
6666
}
6767
}
6868

@@ -376,7 +376,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
376376
}
377377
}
378378

379-
fn visit_array_length(&mut self, len: &'hir ArrayLen) {
379+
fn visit_array_length(&mut self, len: &'hir ArrayLen<'hir>) {
380380
match len {
381381
ArrayLen::Infer(inf) => self.insert(inf.span, inf.hir_id, Node::ArrayLenInfer(inf)),
382382
ArrayLen::Body(..) => intravisit::walk_array_len(self, len),

compiler/rustc_ast_lowering/src/item.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1589,11 +1589,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
15891589
}),
15901590
)),
15911591
)),
1592-
default: Some(hir::AnonConst {
1592+
default: Some(self.arena.alloc(hir::AnonConst {
15931593
def_id: anon_const,
15941594
hir_id: const_id,
15951595
body: const_body,
1596-
}),
1596+
span,
1597+
})),
15971598
is_host_effect: true,
15981599
},
15991600
colon_span: None,

compiler/rustc_ast_lowering/src/lib.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -1178,14 +1178,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11781178
tokens: None,
11791179
};
11801180

1181-
let ct = self.with_new_scopes(span, |this| hir::AnonConst {
1182-
def_id,
1183-
hir_id: this.lower_node_id(node_id),
1184-
body: this.lower_const_body(path_expr.span, Some(&path_expr)),
1181+
let ct = self.with_new_scopes(span, |this| {
1182+
self.arena.alloc(hir::AnonConst {
1183+
def_id,
1184+
hir_id: this.lower_node_id(node_id),
1185+
body: this
1186+
.lower_const_body(path_expr.span, Some(&path_expr)),
1187+
span,
1188+
})
11851189
});
11861190
return GenericArg::Const(ConstArg {
11871191
value: ct,
1188-
span,
11891192
is_desugared_from_effects: false,
11901193
});
11911194
}
@@ -1197,7 +1200,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11971200
}
11981201
ast::GenericArg::Const(ct) => GenericArg::Const(ConstArg {
11991202
value: self.lower_anon_const(ct),
1200-
span: self.lower_span(ct.value.span),
12011203
is_desugared_from_effects: false,
12021204
}),
12031205
}
@@ -2315,7 +2317,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23152317
}
23162318

23172319
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
2318-
fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen {
2320+
fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen<'hir> {
23192321
match c.value.kind {
23202322
ExprKind::Underscore => {
23212323
if self.tcx.features().generic_arg_infer {
@@ -2338,12 +2340,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23382340
}
23392341
}
23402342

2341-
fn lower_anon_const(&mut self, c: &AnonConst) -> hir::AnonConst {
2342-
self.with_new_scopes(c.value.span, |this| hir::AnonConst {
2343+
fn lower_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst {
2344+
self.arena.alloc(self.with_new_scopes(c.value.span, |this| hir::AnonConst {
23432345
def_id: this.local_def_id(c.id),
23442346
hir_id: this.lower_node_id(c.id),
23452347
body: this.lower_const_body(c.value.span, Some(&c.value)),
2346-
})
2348+
span: this.lower_span(c.value.span),
2349+
}))
23472350
}
23482351

23492352
fn lower_unsafe_source(&mut self, u: UnsafeSource) -> hir::UnsafeSource {
@@ -2650,8 +2653,7 @@ impl<'hir> GenericArgsCtor<'hir> {
26502653

26512654
lcx.children.push((def_id, hir::MaybeOwner::NonOwner(hir_id)));
26522655
self.args.push(hir::GenericArg::Const(hir::ConstArg {
2653-
value: hir::AnonConst { def_id, hir_id, body },
2654-
span,
2656+
value: lcx.arena.alloc(hir::AnonConst { def_id, hir_id, body, span }),
26552657
is_desugared_from_effects: true,
26562658
}))
26572659
}

compiler/rustc_builtin_macros/src/format.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ fn make_format_args(
307307
return ExpandResult::Ready(Err(guar));
308308
}
309309

310-
let to_span = |inner_span: rustc_parse_format::InnerSpan| {
310+
let to_span = |inner_span: parse::InnerSpan| {
311311
is_source_literal.then(|| {
312312
fmt_span.from_inner(InnerSpan { start: inner_span.start, end: inner_span.end })
313313
})
@@ -577,7 +577,7 @@ fn make_format_args(
577577
fn invalid_placeholder_type_error(
578578
ecx: &ExtCtxt<'_>,
579579
ty: &str,
580-
ty_span: Option<rustc_parse_format::InnerSpan>,
580+
ty_span: Option<parse::InnerSpan>,
581581
fmt_span: Span,
582582
) {
583583
let sp = ty_span.map(|sp| fmt_span.from_inner(InnerSpan::new(sp.start, sp.end)));

compiler/rustc_codegen_gcc/src/context.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use gccjit::{
66
use rustc_codegen_ssa::base::wants_msvc_seh;
77
use rustc_codegen_ssa::errors as ssa_errors;
88
use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeMethods, MiscMethods};
9-
use rustc_data_structures::base_n;
9+
use rustc_data_structures::base_n::ToBaseN;
10+
use rustc_data_structures::base_n::ALPHANUMERIC_ONLY;
1011
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1112
use rustc_middle::mir::mono::CodegenUnit;
1213
use rustc_middle::span_bug;
@@ -621,7 +622,7 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
621622
let mut name = String::with_capacity(prefix.len() + 6);
622623
name.push_str(prefix);
623624
name.push_str(".");
624-
base_n::push_str(idx as u128, base_n::ALPHANUMERIC_ONLY, &mut name);
625+
name.push_str(&(idx as u64).to_base(ALPHANUMERIC_ONLY));
625626
name
626627
}
627628
}

compiler/rustc_codegen_llvm/src/builder.rs

+12-24
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_data_structures::small_c_str::SmallCStr;
1717
use rustc_hir::def_id::DefId;
1818
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
1919
use rustc_middle::ty::layout::{
20-
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTyCtxt, LayoutError, LayoutOfHelpers, TyAndLayout,
20+
FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers, TyAndLayout,
2121
};
2222
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
2323
use rustc_sanitizers::{cfi, kcfi};
@@ -27,7 +27,6 @@ use rustc_target::abi::{self, call::FnAbi, Align, Size, WrappingRange};
2727
use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target};
2828
use smallvec::SmallVec;
2929
use std::borrow::Cow;
30-
use std::ffi::CString;
3130
use std::iter;
3231
use std::ops::Deref;
3332
use std::ptr;
@@ -1705,13 +1704,21 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17051704
kcfi_bundle
17061705
}
17071706

1707+
/// Emits a call to `llvm.instrprof.mcdc.parameters`.
1708+
///
1709+
/// This doesn't produce any code directly, but is used as input by
1710+
/// the LLVM pass that handles coverage instrumentation.
1711+
///
1712+
/// (See clang's [`CodeGenPGO::emitMCDCParameters`] for comparison.)
1713+
///
1714+
/// [`CodeGenPGO::emitMCDCParameters`]:
1715+
/// https://github.com/rust-lang/llvm-project/blob/5399a24/clang/lib/CodeGen/CodeGenPGO.cpp#L1124
17081716
pub(crate) fn mcdc_parameters(
17091717
&mut self,
17101718
fn_name: &'ll Value,
17111719
hash: &'ll Value,
17121720
bitmap_bytes: &'ll Value,
1713-
max_decision_depth: u32,
1714-
) -> Vec<&'ll Value> {
1721+
) {
17151722
debug!("mcdc_parameters() with args ({:?}, {:?}, {:?})", fn_name, hash, bitmap_bytes);
17161723

17171724
assert!(llvm_util::get_version() >= (18, 0, 0), "MCDC intrinsics require LLVM 18 or later");
@@ -1724,8 +1731,6 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17241731
let args = &[fn_name, hash, bitmap_bytes];
17251732
let args = self.check_call("call", llty, llfn, args);
17261733

1727-
let mut cond_bitmaps = vec![];
1728-
17291734
unsafe {
17301735
let _ = llvm::LLVMRustBuildCall(
17311736
self.llbuilder,
@@ -1736,23 +1741,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17361741
[].as_ptr(),
17371742
0 as c_uint,
17381743
);
1739-
// Create condition bitmap named `mcdc.addr`.
1740-
for i in 0..=max_decision_depth {
1741-
let mut bx = Builder::with_cx(self.cx);
1742-
bx.position_at_start(llvm::LLVMGetFirstBasicBlock(self.llfn()));
1743-
1744-
let name = CString::new(format!("mcdc.addr.{i}")).unwrap();
1745-
let cond_bitmap = {
1746-
let alloca =
1747-
llvm::LLVMBuildAlloca(bx.llbuilder, bx.cx.type_i32(), name.as_ptr());
1748-
llvm::LLVMSetAlignment(alloca, 4);
1749-
alloca
1750-
};
1751-
bx.store(self.const_i32(0), cond_bitmap, self.tcx().data_layout.i32_align.abi);
1752-
cond_bitmaps.push(cond_bitmap);
1753-
}
17541744
}
1755-
cond_bitmaps
17561745
}
17571746

17581747
pub(crate) fn mcdc_tvbitmap_update(
@@ -1794,8 +1783,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17941783
0 as c_uint,
17951784
);
17961785
}
1797-
let i32_align = self.tcx().data_layout.i32_align.abi;
1798-
self.store(self.const_i32(0), mcdc_temp, i32_align);
1786+
self.store(self.const_i32(0), mcdc_temp, self.tcx.data_layout.i32_align.abi);
17991787
}
18001788

18011789
pub(crate) fn mcdc_condbitmap_update(

compiler/rustc_codegen_llvm/src/context.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use crate::value::Value;
1111
use rustc_codegen_ssa::base::{wants_msvc_seh, wants_wasm_eh};
1212
use rustc_codegen_ssa::errors as ssa_errors;
1313
use rustc_codegen_ssa::traits::*;
14-
use rustc_data_structures::base_n;
14+
use rustc_data_structures::base_n::ToBaseN;
15+
use rustc_data_structures::base_n::ALPHANUMERIC_ONLY;
1516
use rustc_data_structures::fx::FxHashMap;
1617
use rustc_data_structures::small_c_str::SmallCStr;
1718
use rustc_hir::def_id::DefId;
@@ -1015,7 +1016,7 @@ impl CodegenCx<'_, '_> {
10151016
let mut name = String::with_capacity(prefix.len() + 6);
10161017
name.push_str(prefix);
10171018
name.push('.');
1018-
base_n::push_str(idx as u128, base_n::ALPHANUMERIC_ONLY, &mut name);
1019+
name.push_str(&(idx as u64).to_base(ALPHANUMERIC_ONLY));
10191020
name
10201021
}
10211022
}

0 commit comments

Comments
 (0)