Skip to content

Commit e71f9a9

Browse files
committed
Auto merge of #136158 - cuviper:stable-next, r=cuviper
[stable] Prepare Rust 1.84.1 point release - [Fix ICE 132920 in duplicate-crate diagnostics.](#133304) - [Fix errors for overlapping impls in incremental rebuilds.](#133828) - [Fix slow compilation related to the next-generation trait solver.](#135618) - [Fix debuginfo when LLVM's location discriminator value limit is exceeded.](#135643) - Fixes for building Rust from source: - [Only try to distribute `llvm-objcopy` if llvm tools are enabled.](#134240) - [Add Profile Override for Non-Git Sources.](#135433) - [Resolve symlinks of LLVM tool binaries before copying them.](#135585) - [Make it possible to use ci-rustc on tarball sources.](#135722) cc `@rust-lang/release` r? ghost
2 parents 9fc6b43 + 690f433 commit e71f9a9

File tree

32 files changed

+422
-134
lines changed

32 files changed

+422
-134
lines changed

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

compiler/rustc_codegen_gcc/src/debuginfo.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ fn make_mir_scope<'gcc, 'tcx>(
113113
let scope_data = &mir.source_scopes[scope];
114114
let parent_scope = if let Some(parent) = scope_data.parent_scope {
115115
make_mir_scope(cx, _instance, mir, variables, debug_context, instantiated, parent);
116-
debug_context.scopes[parent].unwrap()
116+
debug_context.scopes[parent]
117117
} else {
118118
// The root is the function itself.
119119
let file = cx.sess().source_map().lookup_source_file(mir.span.lo());
120-
debug_context.scopes[scope] = Some(DebugScope {
120+
debug_context.scopes[scope] = DebugScope {
121121
file_start_pos: file.start_pos,
122122
file_end_pos: file.end_position(),
123-
..debug_context.scopes[scope].unwrap()
124-
});
123+
..debug_context.scopes[scope]
124+
};
125125
instantiated.insert(scope);
126126
return;
127127
};
@@ -130,7 +130,7 @@ fn make_mir_scope<'gcc, 'tcx>(
130130
if !vars.contains(scope) && scope_data.inlined.is_none() {
131131
// Do not create a DIScope if there are no variables defined in this
132132
// MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat.
133-
debug_context.scopes[scope] = Some(parent_scope);
133+
debug_context.scopes[scope] = parent_scope;
134134
instantiated.insert(scope);
135135
return;
136136
}
@@ -157,12 +157,12 @@ fn make_mir_scope<'gcc, 'tcx>(
157157
// TODO(tempdragon): dbg_scope: Add support for scope extension here.
158158
inlined_at.or(p_inlined_at);
159159

160-
debug_context.scopes[scope] = Some(DebugScope {
160+
debug_context.scopes[scope] = DebugScope {
161161
dbg_scope,
162162
inlined_at,
163163
file_start_pos: loc.file.start_pos,
164164
file_end_pos: loc.file.end_position(),
165-
});
165+
};
166166
instantiated.insert(scope);
167167
}
168168

@@ -232,12 +232,12 @@ impl<'gcc, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
232232
}
233233

234234
// Initialize fn debug context (including scopes).
235-
let empty_scope = Some(DebugScope {
235+
let empty_scope = DebugScope {
236236
dbg_scope: self.dbg_scope_fn(instance, fn_abi, Some(llfn)),
237237
inlined_at: None,
238238
file_start_pos: BytePos(0),
239239
file_end_pos: BytePos(0),
240-
});
240+
};
241241
let mut fn_debug_context = FunctionDebugContext {
242242
scopes: IndexVec::from_elem(empty_scope, mir.source_scopes.as_slice()),
243243
inlined_function_scopes: Default::default(),

compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs

+22-37
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::mir::{Body, SourceScope};
99
use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv};
1010
use rustc_middle::ty::{self, Instance};
1111
use rustc_session::config::DebugInfo;
12-
use rustc_span::{BytePos, hygiene};
12+
use rustc_span::{BytePos, DUMMY_SP, hygiene};
1313

1414
use super::metadata::file_metadata;
1515
use super::utils::DIB;
@@ -85,23 +85,15 @@ fn make_mir_scope<'ll, 'tcx>(
8585
discriminators,
8686
parent,
8787
);
88-
if let Some(parent_scope) = debug_context.scopes[parent] {
89-
parent_scope
90-
} else {
91-
// If the parent scope could not be represented then no children
92-
// can be either.
93-
debug_context.scopes[scope] = None;
94-
instantiated.insert(scope);
95-
return;
96-
}
88+
debug_context.scopes[parent]
9789
} else {
9890
// The root is the function itself.
9991
let file = cx.sess().source_map().lookup_source_file(mir.span.lo());
100-
debug_context.scopes[scope] = Some(DebugScope {
92+
debug_context.scopes[scope] = DebugScope {
10193
file_start_pos: file.start_pos,
10294
file_end_pos: file.end_position(),
103-
..debug_context.scopes[scope].unwrap()
104-
});
95+
..debug_context.scopes[scope]
96+
};
10597
instantiated.insert(scope);
10698
return;
10799
};
@@ -112,7 +104,7 @@ fn make_mir_scope<'ll, 'tcx>(
112104
{
113105
// Do not create a DIScope if there are no variables defined in this
114106
// MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat.
115-
debug_context.scopes[scope] = Some(parent_scope);
107+
debug_context.scopes[scope] = parent_scope;
116108
instantiated.insert(scope);
117109
return;
118110
}
@@ -145,14 +137,7 @@ fn make_mir_scope<'ll, 'tcx>(
145137
},
146138
};
147139

148-
let mut debug_scope = Some(DebugScope {
149-
dbg_scope,
150-
inlined_at: parent_scope.inlined_at,
151-
file_start_pos: loc.file.start_pos,
152-
file_end_pos: loc.file.end_position(),
153-
});
154-
155-
if let Some((_, callsite_span)) = scope_data.inlined {
140+
let inlined_at = scope_data.inlined.map(|(_, callsite_span)| {
156141
let callsite_span = hygiene::walk_chain_collapsed(callsite_span, mir.span);
157142
let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span);
158143
let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span);
@@ -175,29 +160,29 @@ fn make_mir_scope<'ll, 'tcx>(
175160
// Note further that we can't key this hashtable on the span itself,
176161
// because these spans could have distinct SyntaxContexts. We have
177162
// to key on exactly what we're giving to LLVM.
178-
let inlined_at = match discriminators.entry(callsite_span.lo()) {
163+
match discriminators.entry(callsite_span.lo()) {
179164
Entry::Occupied(mut o) => {
180165
*o.get_mut() += 1;
166+
// NB: We have to emit *something* here or we'll fail LLVM IR verification
167+
// in at least some circumstances (see issue #135322) so if the required
168+
// discriminant cannot be encoded fall back to the dummy location.
181169
unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) }
170+
.unwrap_or_else(|| {
171+
cx.dbg_loc(callsite_scope, parent_scope.inlined_at, DUMMY_SP)
172+
})
182173
}
183174
Entry::Vacant(v) => {
184175
v.insert(0);
185-
Some(loc)
186-
}
187-
};
188-
match inlined_at {
189-
Some(inlined_at) => {
190-
debug_scope.as_mut().unwrap().inlined_at = Some(inlined_at);
191-
}
192-
None => {
193-
// LLVM has a maximum discriminator that it can encode (currently
194-
// it uses 12 bits for 4096 possible values). If we exceed that
195-
// there is little we can do but drop the debug info.
196-
debug_scope = None;
176+
loc
197177
}
198178
}
199-
}
179+
});
200180

201-
debug_context.scopes[scope] = debug_scope;
181+
debug_context.scopes[scope] = DebugScope {
182+
dbg_scope,
183+
inlined_at: inlined_at.or(parent_scope.inlined_at),
184+
file_start_pos: loc.file.start_pos,
185+
file_end_pos: loc.file.end_position(),
186+
};
202187
instantiated.insert(scope);
203188
}

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,12 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
294294
}
295295

296296
// Initialize fn debug context (including scopes).
297-
let empty_scope = Some(DebugScope {
297+
let empty_scope = DebugScope {
298298
dbg_scope: self.dbg_scope_fn(instance, fn_abi, Some(llfn)),
299299
inlined_at: None,
300300
file_start_pos: BytePos(0),
301301
file_end_pos: BytePos(0),
302-
});
302+
};
303303
let mut fn_debug_context = FunctionDebugContext {
304304
scopes: IndexVec::from_elem(empty_scope, &mir.source_scopes),
305305
inlined_function_scopes: Default::default(),

compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ use crate::traits::*;
2020

2121
pub struct FunctionDebugContext<'tcx, S, L> {
2222
/// Maps from source code to the corresponding debug info scope.
23-
/// May be None if the backend is not capable of representing the scope for
24-
/// some reason.
25-
pub scopes: IndexVec<mir::SourceScope, Option<DebugScope<S, L>>>,
23+
pub scopes: IndexVec<mir::SourceScope, DebugScope<S, L>>,
2624

2725
/// Maps from an inlined function to its debug info declaration.
2826
pub inlined_function_scopes: FxHashMap<Instance<'tcx>, S>,
@@ -233,7 +231,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
233231
&self,
234232
source_info: mir::SourceInfo,
235233
) -> Option<(Bx::DIScope, Option<Bx::DILocation>, Span)> {
236-
let scope = &self.debug_context.as_ref()?.scopes[source_info.scope]?;
234+
let scope = &self.debug_context.as_ref()?.scopes[source_info.scope];
237235
let span = hygiene::walk_chain_collapsed(source_info.span, self.mir.span);
238236
Some((scope.adjust_dbg_scope_for_span(self.cx, span), scope.inlined_at, span))
239237
}

compiler/rustc_query_system/src/dep_graph/graph.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ impl<D: Deps> DepGraph<D> {
302302
OP: FnOnce() -> R,
303303
{
304304
match self.data() {
305-
Some(data) => data.with_anon_task(cx, dep_kind, op),
305+
Some(data) => {
306+
let (result, index) = data.with_anon_task_inner(cx, dep_kind, op);
307+
self.read_index(index);
308+
(result, index)
309+
}
306310
None => (op(), self.next_virtual_depnode_index()),
307311
}
308312
}
@@ -397,7 +401,16 @@ impl<D: Deps> DepGraphData<D> {
397401

398402
/// Executes something within an "anonymous" task, that is, a task the
399403
/// `DepNode` of which is determined by the list of inputs it read from.
400-
pub(crate) fn with_anon_task<Tcx: DepContext<Deps = D>, OP, R>(
404+
///
405+
/// NOTE: this does not actually count as a read of the DepNode here.
406+
/// Using the result of this task without reading the DepNode will result
407+
/// in untracked dependencies which may lead to ICEs as nodes are
408+
/// incorrectly marked green.
409+
///
410+
/// FIXME: This could perhaps return a `WithDepNode` to ensure that the
411+
/// user of this function actually performs the read; we'll have to see
412+
/// how to make that work with `anon` in `execute_job_incr`, though.
413+
pub(crate) fn with_anon_task_inner<Tcx: DepContext<Deps = D>, OP, R>(
401414
&self,
402415
cx: Tcx,
403416
dep_kind: DepKind,

compiler/rustc_query_system/src/query/plumbing.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,11 @@ where
520520
let (result, dep_node_index) =
521521
qcx.start_query(job_id, query.depth_limit(), Some(&diagnostics), || {
522522
if query.anon() {
523-
return dep_graph_data.with_anon_task(*qcx.dep_context(), query.dep_kind(), || {
524-
query.compute(qcx, key)
525-
});
523+
return dep_graph_data.with_anon_task_inner(
524+
*qcx.dep_context(),
525+
query.dep_kind(),
526+
|| query.compute(qcx, key),
527+
);
526528
}
527529

528530
// `to_dep_node` is expensive for some `DepKind`s.

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

-18
Original file line numberDiff line numberDiff line change
@@ -1808,24 +1808,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
18081808
StringPart::highlighted("cargo tree".to_string()),
18091809
StringPart::normal("` to explore your dependency tree".to_string()),
18101810
]);
1811-
1812-
// FIXME: this is a giant hack for the benefit of this specific diagnostic. Because
1813-
// we're so nested in method calls before the error gets emitted, bubbling a single bit
1814-
// flag informing the top level caller to stop adding extra detail to the diagnostic,
1815-
// would actually be harder to follow. So we do something naughty here: we consume the
1816-
// diagnostic, emit it and leave in its place a "delayed bug" that will continue being
1817-
// modified but won't actually be printed to end users. This *is not ideal*, but allows
1818-
// us to reduce the verbosity of an error that is already quite verbose and increase its
1819-
// specificity. Below we modify the main message as well, in a way that *could* break if
1820-
// the implementation of Diagnostics change significantly, but that would be caught with
1821-
// a make test failure when this diagnostic is tested.
1822-
err.primary_message(format!(
1823-
"{} because the trait comes from a different crate version",
1824-
err.messages[0].0.as_str().unwrap(),
1825-
));
1826-
let diag = err.clone();
1827-
err.downgrade_to_delayed_bug();
1828-
self.tcx.dcx().emit_diagnostic(diag);
18291811
return true;
18301812
}
18311813

compiler/rustc_trait_selection/src/traits/coherence.rs

+45-24
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
use std::fmt::Debug;
88

9-
use rustc_data_structures::fx::FxIndexSet;
9+
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
1010
use rustc_errors::{Diag, EmissionGuarantee};
1111
use rustc_hir::def::DefKind;
1212
use rustc_hir::def_id::DefId;
@@ -117,28 +117,39 @@ pub fn overlapping_impls(
117117
return None;
118118
}
119119

120-
let _overlap_with_bad_diagnostics = overlap(
121-
tcx,
122-
TrackAmbiguityCauses::No,
123-
skip_leak_check,
124-
impl1_def_id,
125-
impl2_def_id,
126-
overlap_mode,
127-
)?;
128-
129-
// In the case where we detect an error, run the check again, but
130-
// this time tracking intercrate ambiguity causes for better
131-
// diagnostics. (These take time and can lead to false errors.)
132-
let overlap = overlap(
133-
tcx,
134-
TrackAmbiguityCauses::Yes,
135-
skip_leak_check,
136-
impl1_def_id,
137-
impl2_def_id,
138-
overlap_mode,
139-
)
140-
.unwrap();
141-
Some(overlap)
120+
if tcx.next_trait_solver_in_coherence() {
121+
overlap(
122+
tcx,
123+
TrackAmbiguityCauses::Yes,
124+
skip_leak_check,
125+
impl1_def_id,
126+
impl2_def_id,
127+
overlap_mode,
128+
)
129+
} else {
130+
let _overlap_with_bad_diagnostics = overlap(
131+
tcx,
132+
TrackAmbiguityCauses::No,
133+
skip_leak_check,
134+
impl1_def_id,
135+
impl2_def_id,
136+
overlap_mode,
137+
)?;
138+
139+
// In the case where we detect an error, run the check again, but
140+
// this time tracking intercrate ambiguity causes for better
141+
// diagnostics. (These take time and can lead to false errors.)
142+
let overlap = overlap(
143+
tcx,
144+
TrackAmbiguityCauses::Yes,
145+
skip_leak_check,
146+
impl1_def_id,
147+
impl2_def_id,
148+
overlap_mode,
149+
)
150+
.unwrap();
151+
Some(overlap)
152+
}
142153
}
143154

144155
fn fresh_impl_header<'tcx>(infcx: &InferCtxt<'tcx>, impl_def_id: DefId) -> ty::ImplHeader<'tcx> {
@@ -616,6 +627,7 @@ fn compute_intercrate_ambiguity_causes<'tcx>(
616627
}
617628

618629
struct AmbiguityCausesVisitor<'a, 'tcx> {
630+
cache: FxHashSet<Goal<'tcx, ty::Predicate<'tcx>>>,
619631
causes: &'a mut FxIndexSet<IntercrateAmbiguityCause<'tcx>>,
620632
}
621633

@@ -625,6 +637,10 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for AmbiguityCausesVisitor<'a, 'tcx> {
625637
}
626638

627639
fn visit_goal(&mut self, goal: &InspectGoal<'_, 'tcx>) {
640+
if !self.cache.insert(goal.goal()) {
641+
return;
642+
}
643+
628644
let infcx = goal.infcx();
629645
for cand in goal.candidates() {
630646
cand.visit_nested_in_probe(self);
@@ -749,5 +765,10 @@ fn search_ambiguity_causes<'tcx>(
749765
goal: Goal<'tcx, ty::Predicate<'tcx>>,
750766
causes: &mut FxIndexSet<IntercrateAmbiguityCause<'tcx>>,
751767
) {
752-
infcx.probe(|_| infcx.visit_proof_tree(goal, &mut AmbiguityCausesVisitor { causes }));
768+
infcx.probe(|_| {
769+
infcx.visit_proof_tree(goal, &mut AmbiguityCausesVisitor {
770+
cache: Default::default(),
771+
causes,
772+
})
773+
});
753774
}

0 commit comments

Comments
 (0)