Skip to content

Commit 3186d17

Browse files
committed
Auto merge of rust-lang#126679 - fmease:rollup-njrv2py, r=fmease
Rollup of 6 pull requests Successful merges: - rust-lang#125447 (Allow constraining opaque types during subtyping in the trait system) - rust-lang#125766 (MCDC Coverage: instrument last boolean RHS operands from condition coverage) - rust-lang#125880 (Remove `src/tools/rust-demangler`) - rust-lang#126154 (StorageLive: refresh storage (instead of UB) when local is already live) - rust-lang#126572 (override user defined channel when using precompiled rustc) - rust-lang#126662 (Unconditionally warn on usage of `wasm32-wasi`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5978f35 + ca61d74 commit 3186d17

35 files changed

+677
-590
lines changed

Cargo.lock

-8
Original file line numberDiff line numberDiff line change
@@ -3479,14 +3479,6 @@ dependencies = [
34793479
"wasmparser",
34803480
]
34813481

3482-
[[package]]
3483-
name = "rust-demangler"
3484-
version = "0.0.1"
3485-
dependencies = [
3486-
"regex",
3487-
"rustc-demangle",
3488-
]
3489-
34903482
[[package]]
34913483
name = "rustbook"
34923484
version = "0.1.0"

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ members = [
2323
"src/tools/remote-test-client",
2424
"src/tools/remote-test-server",
2525
"src/tools/rust-installer",
26-
"src/tools/rust-demangler",
2726
"src/tools/rustdoc",
2827
"src/tools/rls",
2928
"src/tools/rustfmt",

compiler/rustc_const_eval/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ const_eval_division_by_zero =
7373
dividing by zero
7474
const_eval_division_overflow =
7575
overflow in signed division (dividing MIN by -1)
76-
const_eval_double_storage_live =
77-
StorageLive on a local that was already live
7876
7977
const_eval_dyn_call_not_a_method =
8078
`dyn` call trying to call something that is not a method

compiler/rustc_const_eval/src/interpret/eval_context.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1100,11 +1100,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
11001100
Operand::Immediate(Immediate::Uninit)
11011101
});
11021102

1103-
// StorageLive expects the local to be dead, and marks it live.
1103+
// If the local is already live, deallocate its old memory.
11041104
let old = mem::replace(&mut self.frame_mut().locals[local].value, local_val);
1105-
if !matches!(old, LocalValue::Dead) {
1106-
throw_ub_custom!(fluent::const_eval_double_storage_live);
1107-
}
1105+
self.deallocate_local(old)?;
11081106
Ok(())
11091107
}
11101108

@@ -1118,7 +1116,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
11181116
assert!(local != mir::RETURN_PLACE, "Cannot make return place dead");
11191117
trace!("{:?} is now dead", local);
11201118

1121-
// It is entirely okay for this local to be already dead (at least that's how we currently generate MIR)
1119+
// If the local is already dead, this is a NOP.
11221120
let old = mem::replace(&mut self.frame_mut().locals[local].value, LocalValue::Dead);
11231121
self.deallocate_local(old)?;
11241122
Ok(())

compiler/rustc_infer/src/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,9 @@ impl<'tcx> InferCtxt<'tcx> {
878878

879879
self.enter_forall(predicate, |ty::SubtypePredicate { a_is_expected, a, b }| {
880880
if a_is_expected {
881-
Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::No, a, b))
881+
Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::Yes, a, b))
882882
} else {
883-
Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::No, b, a))
883+
Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::Yes, b, a))
884884
}
885885
})
886886
}

compiler/rustc_middle/src/mir/syntax.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -361,16 +361,19 @@ pub enum StatementKind<'tcx> {
361361
/// At any point during the execution of a function, each local is either allocated or
362362
/// unallocated. Except as noted below, all locals except function parameters are initially
363363
/// unallocated. `StorageLive` statements cause memory to be allocated for the local while
364-
/// `StorageDead` statements cause the memory to be freed. Using a local in any way (not only
365-
/// reading/writing from it) while it is unallocated is UB.
364+
/// `StorageDead` statements cause the memory to be freed. In other words,
365+
/// `StorageLive`/`StorageDead` act like the heap operations `allocate`/`deallocate`, but for
366+
/// stack-allocated local variables. Using a local in any way (not only reading/writing from it)
367+
/// while it is unallocated is UB.
366368
///
367369
/// Some locals have no `StorageLive` or `StorageDead` statements within the entire MIR body.
368370
/// These locals are implicitly allocated for the full duration of the function. There is a
369371
/// convenience method at `rustc_mir_dataflow::storage::always_storage_live_locals` for
370372
/// computing these locals.
371373
///
372-
/// If the local is already allocated, calling `StorageLive` again is UB. However, for an
373-
/// unallocated local an additional `StorageDead` all is simply a nop.
374+
/// If the local is already allocated, calling `StorageLive` again will implicitly free the
375+
/// local and then allocate fresh uninitilized memory. If a local is already deallocated,
376+
/// calling `StorageDead` again is a NOP.
374377
StorageLive(Local),
375378

376379
/// See `StorageLive` above.

compiler/rustc_mir_build/src/build/coverageinfo.rs

+45-23
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,35 @@ impl BranchInfoBuilder {
118118
}
119119
}
120120

121-
fn add_two_way_branch<'tcx>(
121+
fn register_two_way_branch<'tcx>(
122122
&mut self,
123+
tcx: TyCtxt<'tcx>,
123124
cfg: &mut CFG<'tcx>,
124125
source_info: SourceInfo,
125126
true_block: BasicBlock,
126127
false_block: BasicBlock,
127128
) {
128-
let true_marker = self.markers.inject_block_marker(cfg, source_info, true_block);
129-
let false_marker = self.markers.inject_block_marker(cfg, source_info, false_block);
130-
131-
self.branch_spans.push(BranchSpan { span: source_info.span, true_marker, false_marker });
129+
// Separate path for handling branches when MC/DC is enabled.
130+
if let Some(mcdc_info) = self.mcdc_info.as_mut() {
131+
let inject_block_marker =
132+
|source_info, block| self.markers.inject_block_marker(cfg, source_info, block);
133+
mcdc_info.visit_evaluated_condition(
134+
tcx,
135+
source_info,
136+
true_block,
137+
false_block,
138+
inject_block_marker,
139+
);
140+
} else {
141+
let true_marker = self.markers.inject_block_marker(cfg, source_info, true_block);
142+
let false_marker = self.markers.inject_block_marker(cfg, source_info, false_block);
143+
144+
self.branch_spans.push(BranchSpan {
145+
span: source_info.span,
146+
true_marker,
147+
false_marker,
148+
});
149+
}
132150
}
133151

134152
pub(crate) fn into_done(self) -> Option<Box<mir::coverage::BranchInfo>> {
@@ -205,7 +223,14 @@ impl<'tcx> Builder<'_, 'tcx> {
205223
mir::TerminatorKind::if_(mir::Operand::Copy(place), true_block, false_block),
206224
);
207225

208-
branch_info.add_two_way_branch(&mut self.cfg, source_info, true_block, false_block);
226+
// Separate path for handling branches when MC/DC is enabled.
227+
branch_info.register_two_way_branch(
228+
self.tcx,
229+
&mut self.cfg,
230+
source_info,
231+
true_block,
232+
false_block,
233+
);
209234

210235
let join_block = self.cfg.start_new_block();
211236
self.cfg.goto(true_block, source_info, join_block);
@@ -236,22 +261,13 @@ impl<'tcx> Builder<'_, 'tcx> {
236261

237262
let source_info = SourceInfo { span: self.thir[expr_id].span, scope: self.source_scope };
238263

239-
// Separate path for handling branches when MC/DC is enabled.
240-
if let Some(mcdc_info) = branch_info.mcdc_info.as_mut() {
241-
let inject_block_marker = |source_info, block| {
242-
branch_info.markers.inject_block_marker(&mut self.cfg, source_info, block)
243-
};
244-
mcdc_info.visit_evaluated_condition(
245-
self.tcx,
246-
source_info,
247-
then_block,
248-
else_block,
249-
inject_block_marker,
250-
);
251-
return;
252-
}
253-
254-
branch_info.add_two_way_branch(&mut self.cfg, source_info, then_block, else_block);
264+
branch_info.register_two_way_branch(
265+
self.tcx,
266+
&mut self.cfg,
267+
source_info,
268+
then_block,
269+
else_block,
270+
);
255271
}
256272

257273
/// If branch coverage is enabled, inject marker statements into `true_block`
@@ -270,6 +286,12 @@ impl<'tcx> Builder<'_, 'tcx> {
270286
// FIXME(#124144) This may need special handling when MC/DC is enabled.
271287

272288
let source_info = SourceInfo { span: pattern.span, scope: self.source_scope };
273-
branch_info.add_two_way_branch(&mut self.cfg, source_info, true_block, false_block);
289+
branch_info.register_two_way_branch(
290+
self.tcx,
291+
&mut self.cfg,
292+
source_info,
293+
true_block,
294+
false_block,
295+
);
274296
}
275297
}

compiler/rustc_mir_build/src/build/expr/into.rs

+3
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
150150
ExprKind::LogicalOp { op, lhs, rhs } => {
151151
let condition_scope = this.local_scope();
152152
let source_info = this.source_info(expr.span);
153+
154+
this.visit_coverage_branch_operation(op, expr.span);
155+
153156
// We first evaluate the left-hand side of the predicate ...
154157
let (then_block, else_block) =
155158
this.in_if_then_scope(condition_scope, expr.span, |this| {

compiler/rustc_session/src/config.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,20 @@ pub fn build_target_config(early_dcx: &EarlyDiagCtxt, opts: &Options, sysroot: &
13111311
for warning in warnings.warning_messages() {
13121312
early_dcx.early_warn(warning)
13131313
}
1314+
1315+
// The `wasm32-wasi` target is being renamed to `wasm32-wasip1` as
1316+
// part of rust-lang/compiler-team#607 and
1317+
// rust-lang/compiler-team#695. Warn unconditionally on usage to
1318+
// raise awareness of the renaming. This code will be deleted in
1319+
// October 2024.
1320+
if opts.target_triple.triple() == "wasm32-wasi" {
1321+
early_dcx.early_warn(
1322+
"the `wasm32-wasi` target is being renamed to \
1323+
`wasm32-wasip1` and the `wasm32-wasi` target will be \
1324+
removed from nightly in October 2024 and removed from \
1325+
stable Rust in January 2025",
1326+
)
1327+
}
13141328
if !matches!(target.pointer_width, 16 | 32 | 64) {
13151329
early_dcx.early_fatal(format!(
13161330
"target specification was invalid: unrecognized target-pointer-width {}",

config.example.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,7 @@
321321
#
322322
# If `extended = false`, the only one of these built by default is rustdoc.
323323
#
324-
# If `extended = true`, they're all included, with the exception of
325-
# rust-demangler which additionally requires `profiler = true` to be set.
324+
# If `extended = true`, they are all included.
326325
#
327326
# If any enabled tool fails to build, the installation fails.
328327
#tools = [
@@ -334,7 +333,6 @@
334333
# "rust-analyzer-proc-macro-srv",
335334
# "analysis",
336335
# "src",
337-
# "rust-demangler", # if profiler = true
338336
#]
339337

340338
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose, 3 == print environment variables on each rustc invocation

src/bootstrap/src/core/build_steps/clippy.rs

-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ lint_any!(
322322
RemoteTestServer, "src/tools/remote-test-server", "remote-test-server";
323323
Rls, "src/tools/rls", "rls";
324324
RustAnalyzer, "src/tools/rust-analyzer", "rust-analyzer";
325-
RustDemangler, "src/tools/rust-demangler", "rust-demangler";
326325
Rustdoc, "src/tools/rustdoc", "clippy";
327326
Rustfmt, "src/tools/rustfmt", "rustfmt";
328327
RustInstaller, "src/tools/rust-installer", "rust-installer";

0 commit comments

Comments
 (0)