Skip to content

Commit bcda892

Browse files
authored
Merge pull request #4166 from rust-lang/rustup-2025-01-31
Automatic Rustup
2 parents e1d0507 + 74ca1cf commit bcda892

File tree

196 files changed

+3718
-1309
lines changed

Some content is hidden

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

196 files changed

+3718
-1309
lines changed

Diff for: RELEASES.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
Version 1.84.1 (2025-01-30)
2+
==========================
3+
4+
<a id="1.84.1"></a>
5+
6+
- [Fix ICE 132920 in duplicate-crate diagnostics.](https://github.com/rust-lang/rust/pull/133304/)
7+
- [Fix errors for overlapping impls in incremental rebuilds.](https://github.com/rust-lang/rust/pull/133828/)
8+
- [Fix slow compilation related to the next-generation trait solver.](https://github.com/rust-lang/rust/pull/135618/)
9+
- [Fix debuginfo when LLVM's location discriminator value limit is exceeded.](https://github.com/rust-lang/rust/pull/135643/)
10+
- Fixes for building Rust from source:
11+
- [Only try to distribute `llvm-objcopy` if llvm tools are enabled.](https://github.com/rust-lang/rust/pull/134240/)
12+
- [Add Profile Override for Non-Git Sources.](https://github.com/rust-lang/rust/pull/135433/)
13+
- [Resolve symlinks of LLVM tool binaries before copying them.](https://github.com/rust-lang/rust/pull/135585/)
14+
- [Make it possible to use ci-rustc on tarball sources.](https://github.com/rust-lang/rust/pull/135722/)
15+
116
Version 1.84.0 (2025-01-09)
217
==========================
318

Diff for: REUSE.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ SPDX-FileCopyrightText = "2015 Anders Kaseorg <[email protected]>"
9292
SPDX-License-Identifier = "MIT"
9393

9494
[[annotations]]
95-
path = "src/librustdoc/html/static/fonts/FiraSans**"
95+
path = "src/librustdoc/html/static/fonts/Fira**"
9696
precedence = "override"
9797
SPDX-FileCopyrightText = ["2014, Mozilla Foundation", "2014, Telefonica S.A."]
9898
SPDX-License-Identifier = "OFL-1.1"

Diff for: compiler/rustc_ast/src/token.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -527,13 +527,13 @@ impl TokenKind {
527527

528528
/// Returns tokens that are likely to be typed accidentally instead of the current token.
529529
/// Enables better error recovery when the wrong token is found.
530-
pub fn similar_tokens(&self) -> Option<Vec<TokenKind>> {
531-
match *self {
532-
Comma => Some(vec![Dot, Lt, Semi]),
533-
Semi => Some(vec![Colon, Comma]),
534-
Colon => Some(vec![Semi]),
535-
FatArrow => Some(vec![Eq, RArrow, Ge, Gt]),
536-
_ => None,
530+
pub fn similar_tokens(&self) -> &[TokenKind] {
531+
match self {
532+
Comma => &[Dot, Lt, Semi],
533+
Semi => &[Colon, Comma],
534+
Colon => &[Semi],
535+
FatArrow => &[Eq, RArrow, Ge, Gt],
536+
_ => &[],
537537
}
538538
}
539539

Diff for: compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use rustc_data_structures::fx::FxIndexMap;
22
use rustc_errors::ErrorGuaranteed;
3+
use rustc_hir::OpaqueTyOrigin;
34
use rustc_hir::def_id::LocalDefId;
5+
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
46
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, TyCtxtInferExt as _};
57
use rustc_macros::extension;
68
use rustc_middle::ty::fold::fold_regions;
@@ -10,6 +12,7 @@ use rustc_middle::ty::{
1012
TypingMode,
1113
};
1214
use rustc_span::Span;
15+
use rustc_trait_selection::regions::OutlivesEnvironmentBuildExt;
1316
use rustc_trait_selection::traits::ObligationCtxt;
1417
use tracing::{debug, instrument};
1518

@@ -406,20 +409,16 @@ impl<'tcx> LazyOpaqueTyEnv<'tcx> {
406409
}
407410

408411
fn get_canonical_args(&self) -> ty::GenericArgsRef<'tcx> {
409-
use rustc_hir as hir;
410-
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
411-
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
412-
413412
if let Some(&canonical_args) = self.canonical_args.get() {
414413
return canonical_args;
415414
}
416415

417416
let &Self { tcx, def_id, .. } = self;
418417
let origin = tcx.local_opaque_ty_origin(def_id);
419418
let parent = match origin {
420-
hir::OpaqueTyOrigin::FnReturn { parent, .. }
421-
| hir::OpaqueTyOrigin::AsyncFn { parent, .. }
422-
| hir::OpaqueTyOrigin::TyAlias { parent, .. } => parent,
419+
OpaqueTyOrigin::FnReturn { parent, .. }
420+
| OpaqueTyOrigin::AsyncFn { parent, .. }
421+
| OpaqueTyOrigin::TyAlias { parent, .. } => parent,
423422
};
424423
let param_env = tcx.param_env(parent);
425424
let args = GenericArgs::identity_for_item(tcx, parent).extend_to(
@@ -439,8 +438,7 @@ impl<'tcx> LazyOpaqueTyEnv<'tcx> {
439438
tcx.dcx().span_delayed_bug(tcx.def_span(def_id), "error getting implied bounds");
440439
Default::default()
441440
});
442-
let implied_bounds = infcx.implied_bounds_tys(param_env, parent, &wf_tys);
443-
let outlives_env = OutlivesEnvironment::with_bounds(param_env, implied_bounds);
441+
let outlives_env = OutlivesEnvironment::new(&infcx, parent, param_env, wf_tys);
444442

445443
let mut seen = vec![tcx.lifetimes.re_static];
446444
let canonical_args = fold_regions(tcx, args, |r1, _| {

Diff for: compiler/rustc_builtin_macros/src/format.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,14 @@ fn parse_args<'a>(ecx: &ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a,
101101

102102
match p.expect(exp!(Comma)) {
103103
Err(err) => {
104-
match token::TokenKind::Comma.similar_tokens() {
105-
Some(tks) if tks.contains(&p.token.kind) => {
106-
// If a similar token is found, then it may be a typo. We
107-
// consider it as a comma, and continue parsing.
108-
err.emit();
109-
p.bump();
110-
}
104+
if token::TokenKind::Comma.similar_tokens().contains(&p.token.kind) {
105+
// If a similar token is found, then it may be a typo. We
106+
// consider it as a comma, and continue parsing.
107+
err.emit();
108+
p.bump();
109+
} else {
111110
// Otherwise stop the parsing and return the error.
112-
_ => return Err(err),
111+
return Err(err);
113112
}
114113
}
115114
Ok(Recovered::Yes(_)) => (),

Diff for: compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
129129
return;
130130
}
131131

132-
let idx = generic_args[2]
133-
.expect_const()
134-
.try_to_valtree()
135-
.expect("expected monomorphic const in codegen")
136-
.0
137-
.unwrap_branch();
132+
let idx = generic_args[2].expect_const().to_value().valtree.unwrap_branch();
138133

139134
assert_eq!(x.layout(), y.layout());
140135
let layout = x.layout();

Diff for: compiler/rustc_codegen_llvm/src/builder.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,9 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
13251325
impl<'ll> StaticBuilderMethods for Builder<'_, 'll, '_> {
13261326
fn get_static(&mut self, def_id: DefId) -> &'ll Value {
13271327
// Forward to the `get_static` method of `CodegenCx`
1328-
self.cx().get_static(def_id)
1328+
let s = self.cx().get_static(def_id);
1329+
// Cast to default address space if globals are in a different addrspace
1330+
self.cx().const_pointercast(s, self.type_ptr())
13291331
}
13301332
}
13311333

Diff for: compiler/rustc_codegen_llvm/src/common.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
225225
llvm::LLVMSetUnnamedAddress(g, llvm::UnnamedAddr::Global);
226226
}
227227
llvm::set_linkage(g, llvm::Linkage::InternalLinkage);
228+
// Cast to default address space if globals are in a different addrspace
229+
let g = self.const_pointercast(g, self.type_ptr());
228230
(s.to_owned(), g)
229231
})
230232
.1;
@@ -289,7 +291,7 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
289291
let alloc = alloc.inner();
290292
let value = match alloc.mutability {
291293
Mutability::Mut => self.static_addr_of_mut(init, alloc.align, None),
292-
_ => self.static_addr_of(init, alloc.align, None),
294+
_ => self.static_addr_of_impl(init, alloc.align, None),
293295
};
294296
if !self.sess().fewer_names() && llvm::get_value_name(value).is_empty()
295297
{
@@ -315,7 +317,7 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
315317
.global_alloc(self.tcx.vtable_allocation((ty, dyn_ty.principal())))
316318
.unwrap_memory();
317319
let init = const_alloc_to_llvm(self, alloc, /*static*/ false);
318-
let value = self.static_addr_of(init, alloc.inner().align, None);
320+
let value = self.static_addr_of_impl(init, alloc.inner().align, None);
319321
(value, AddressSpace::DATA)
320322
}
321323
GlobalAlloc::Static(def_id) => {
@@ -327,7 +329,8 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
327329
let llval = unsafe {
328330
llvm::LLVMConstInBoundsGEP2(
329331
self.type_i8(),
330-
self.const_bitcast(base_addr, self.type_ptr_ext(base_addr_space)),
332+
// Cast to the required address space if necessary
333+
self.const_pointercast(base_addr, self.type_ptr_ext(base_addr_space)),
331334
&self.const_usize(offset.bytes()),
332335
1,
333336
)

Diff for: compiler/rustc_codegen_llvm/src/consts.rs

+44-17
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ impl<'ll> CodegenCx<'ll, '_> {
210210
unsafe { llvm::LLVMConstBitCast(val, ty) }
211211
}
212212

213+
pub(crate) fn const_pointercast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value {
214+
unsafe { llvm::LLVMConstPointerCast(val, ty) }
215+
}
216+
217+
/// Create a global variable.
218+
///
219+
/// The returned global variable is a pointer in the default address space for globals.
220+
/// Fails if a symbol with the given name already exists.
213221
pub(crate) fn static_addr_of_mut(
214222
&self,
215223
cv: &'ll Value,
@@ -233,6 +241,34 @@ impl<'ll> CodegenCx<'ll, '_> {
233241
gv
234242
}
235243

244+
/// Create a global constant.
245+
///
246+
/// The returned global variable is a pointer in the default address space for globals.
247+
pub(crate) fn static_addr_of_impl(
248+
&self,
249+
cv: &'ll Value,
250+
align: Align,
251+
kind: Option<&str>,
252+
) -> &'ll Value {
253+
if let Some(&gv) = self.const_globals.borrow().get(&cv) {
254+
unsafe {
255+
// Upgrade the alignment in cases where the same constant is used with different
256+
// alignment requirements
257+
let llalign = align.bytes() as u32;
258+
if llalign > llvm::LLVMGetAlignment(gv) {
259+
llvm::LLVMSetAlignment(gv, llalign);
260+
}
261+
}
262+
return gv;
263+
}
264+
let gv = self.static_addr_of_mut(cv, align, kind);
265+
unsafe {
266+
llvm::LLVMSetGlobalConstant(gv, True);
267+
}
268+
self.const_globals.borrow_mut().insert(cv, gv);
269+
gv
270+
}
271+
236272
#[instrument(level = "debug", skip(self))]
237273
pub(crate) fn get_static(&self, def_id: DefId) -> &'ll Value {
238274
let instance = Instance::mono(self.tcx, def_id);
@@ -505,24 +541,15 @@ impl<'ll> CodegenCx<'ll, '_> {
505541
}
506542

507543
impl<'ll> StaticCodegenMethods for CodegenCx<'ll, '_> {
544+
/// Get a pointer to a global variable.
545+
///
546+
/// The pointer will always be in the default address space. If global variables default to a
547+
/// different address space, an addrspacecast is inserted.
508548
fn static_addr_of(&self, cv: &'ll Value, align: Align, kind: Option<&str>) -> &'ll Value {
509-
if let Some(&gv) = self.const_globals.borrow().get(&cv) {
510-
unsafe {
511-
// Upgrade the alignment in cases where the same constant is used with different
512-
// alignment requirements
513-
let llalign = align.bytes() as u32;
514-
if llalign > llvm::LLVMGetAlignment(gv) {
515-
llvm::LLVMSetAlignment(gv, llalign);
516-
}
517-
}
518-
return gv;
519-
}
520-
let gv = self.static_addr_of_mut(cv, align, kind);
521-
unsafe {
522-
llvm::LLVMSetGlobalConstant(gv, True);
523-
}
524-
self.const_globals.borrow_mut().insert(cv, gv);
525-
gv
549+
let gv = self.static_addr_of_impl(cv, align, kind);
550+
// static_addr_of_impl returns the bare global variable, which might not be in the default
551+
// address space. Cast to the default address space if necessary.
552+
self.const_pointercast(gv, self.type_ptr())
526553
}
527554

528555
fn codegen_static(&self, def_id: DefId) {

Diff for: compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+26-2
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,7 @@ pub(crate) fn build_compile_unit_di_node<'ll, 'tcx>(
919919
.unwrap_or_default();
920920
let kind = DebugEmissionKind::from_generic(tcx.sess.opts.debuginfo);
921921

922-
let dwarf_version =
923-
tcx.sess.opts.unstable_opts.dwarf_version.unwrap_or(tcx.sess.target.default_dwarf_version);
922+
let dwarf_version = tcx.sess.dwarf_version();
924923
let is_dwarf_kind =
925924
matches!(tcx.sess.target.debuginfo_kind, DebuginfoKind::Dwarf | DebuginfoKind::DwarfDsym);
926925
// Don't emit `.debug_pubnames` and `.debug_pubtypes` on DWARFv4 or lower.
@@ -1488,6 +1487,26 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
14881487
.di_node
14891488
}
14901489

1490+
/// Get the global variable for the vtable.
1491+
///
1492+
/// When using global variables, we may have created an addrspacecast to get a pointer to the
1493+
/// default address space if global variables are created in a different address space.
1494+
/// For modifying the vtable, we need the real global variable. This function accepts either a
1495+
/// global variable (which is simply returned), or an addrspacecast constant expression.
1496+
/// If the given value is an addrspacecast, the cast is removed and the global variable behind
1497+
/// the cast is returned.
1498+
fn find_vtable_behind_cast<'ll>(vtable: &'ll Value) -> &'ll Value {
1499+
// The vtable is a global variable, which may be behind an addrspacecast.
1500+
unsafe {
1501+
if let Some(c) = llvm::LLVMIsAConstantExpr(vtable) {
1502+
if llvm::LLVMGetConstOpcode(c) == llvm::Opcode::AddrSpaceCast {
1503+
return llvm::LLVMGetOperand(c, 0).unwrap();
1504+
}
1505+
}
1506+
}
1507+
vtable
1508+
}
1509+
14911510
pub(crate) fn apply_vcall_visibility_metadata<'ll, 'tcx>(
14921511
cx: &CodegenCx<'ll, 'tcx>,
14931512
ty: Ty<'tcx>,
@@ -1508,6 +1527,8 @@ pub(crate) fn apply_vcall_visibility_metadata<'ll, 'tcx>(
15081527

15091528
let Some(trait_ref) = trait_ref else { return };
15101529

1530+
// Unwrap potential addrspacecast
1531+
let vtable = find_vtable_behind_cast(vtable);
15111532
let trait_ref_self = trait_ref.with_self_ty(cx.tcx, ty);
15121533
let trait_ref_self = cx.tcx.erase_regions(trait_ref_self);
15131534
let trait_def_id = trait_ref_self.def_id();
@@ -1581,6 +1602,9 @@ pub(crate) fn create_vtable_di_node<'ll, 'tcx>(
15811602
return;
15821603
}
15831604

1605+
// Unwrap potential addrspacecast
1606+
let vtable = find_vtable_behind_cast(vtable);
1607+
15841608
// When full debuginfo is enabled, we want to try and prevent vtables from being
15851609
// merged. Otherwise debuggers will have a hard time mapping from dyn pointer
15861610
// to concrete type.

Diff for: compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+26-23
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustc_session::config::{self, DebugInfo};
2222
use rustc_span::{
2323
BytePos, Pos, SourceFile, SourceFileAndLine, SourceFileHash, Span, StableSourceFileId, Symbol,
2424
};
25+
use rustc_target::spec::DebuginfoKind;
2526
use smallvec::SmallVec;
2627
use tracing::debug;
2728

@@ -93,29 +94,31 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
9394

9495
pub(crate) fn finalize(&self, sess: &Session) {
9596
unsafe { llvm::LLVMRustDIBuilderFinalize(self.builder) };
96-
if !sess.target.is_like_msvc {
97-
// Debuginfo generation in LLVM by default uses a higher
98-
// version of dwarf than macOS currently understands. We can
99-
// instruct LLVM to emit an older version of dwarf, however,
100-
// for macOS to understand. For more info see #11352
101-
// This can be overridden using --llvm-opts -dwarf-version,N.
102-
// Android has the same issue (#22398)
103-
let dwarf_version =
104-
sess.opts.unstable_opts.dwarf_version.unwrap_or(sess.target.default_dwarf_version);
105-
llvm::add_module_flag_u32(
106-
self.llmod,
107-
llvm::ModuleFlagMergeBehavior::Warning,
108-
"Dwarf Version",
109-
dwarf_version,
110-
);
111-
} else {
112-
// Indicate that we want CodeView debug information on MSVC
113-
llvm::add_module_flag_u32(
114-
self.llmod,
115-
llvm::ModuleFlagMergeBehavior::Warning,
116-
"CodeView",
117-
1,
118-
);
97+
98+
match sess.target.debuginfo_kind {
99+
DebuginfoKind::Dwarf | DebuginfoKind::DwarfDsym => {
100+
// Debuginfo generation in LLVM by default uses a higher
101+
// version of dwarf than macOS currently understands. We can
102+
// instruct LLVM to emit an older version of dwarf, however,
103+
// for macOS to understand. For more info see #11352
104+
// This can be overridden using --llvm-opts -dwarf-version,N.
105+
// Android has the same issue (#22398)
106+
llvm::add_module_flag_u32(
107+
self.llmod,
108+
llvm::ModuleFlagMergeBehavior::Warning,
109+
"Dwarf Version",
110+
sess.dwarf_version(),
111+
);
112+
}
113+
DebuginfoKind::Pdb => {
114+
// Indicate that we want CodeView debug information
115+
llvm::add_module_flag_u32(
116+
self.llmod,
117+
llvm::ModuleFlagMergeBehavior::Warning,
118+
"CodeView",
119+
1,
120+
);
121+
}
119122
}
120123

121124
// Prevent bitcode readers from deleting the debug info.

Diff for: compiler/rustc_codegen_llvm/src/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
13291329
}
13301330

13311331
if name == sym::simd_shuffle_generic {
1332-
let idx = fn_args[2].expect_const().try_to_valtree().unwrap().0.unwrap_branch();
1332+
let idx = fn_args[2].expect_const().to_value().valtree.unwrap_branch();
13331333
let n = idx.len() as u64;
13341334

13351335
let (out_len, out_ty) = require_simd!(ret_ty, SimdReturn);

0 commit comments

Comments
 (0)