Skip to content

Commit

Permalink
Auto merge of rust-lang#126679 - fmease:rollup-njrv2py, r=fmease
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jun 19, 2024
2 parents 5978f35 + ca61d74 commit 3186d17
Show file tree
Hide file tree
Showing 35 changed files with 677 additions and 590 deletions.
8 changes: 0 additions & 8 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3479,14 +3479,6 @@ dependencies = [
"wasmparser",
]

[[package]]
name = "rust-demangler"
version = "0.0.1"
dependencies = [
"regex",
"rustc-demangle",
]

[[package]]
name = "rustbook"
version = "0.1.0"
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ members = [
"src/tools/remote-test-client",
"src/tools/remote-test-server",
"src/tools/rust-installer",
"src/tools/rust-demangler",
"src/tools/rustdoc",
"src/tools/rls",
"src/tools/rustfmt",
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_const_eval/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ const_eval_division_by_zero =
dividing by zero
const_eval_division_overflow =
overflow in signed division (dividing MIN by -1)
const_eval_double_storage_live =
StorageLive on a local that was already live
const_eval_dyn_call_not_a_method =
`dyn` call trying to call something that is not a method
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_const_eval/src/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,11 +1100,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
Operand::Immediate(Immediate::Uninit)
});

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

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

// It is entirely okay for this local to be already dead (at least that's how we currently generate MIR)
// If the local is already dead, this is a NOP.
let old = mem::replace(&mut self.frame_mut().locals[local].value, LocalValue::Dead);
self.deallocate_local(old)?;
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,9 @@ impl<'tcx> InferCtxt<'tcx> {

self.enter_forall(predicate, |ty::SubtypePredicate { a_is_expected, a, b }| {
if a_is_expected {
Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::No, a, b))
Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::Yes, a, b))
} else {
Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::No, b, a))
Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::Yes, b, a))
}
})
}
Expand Down
11 changes: 7 additions & 4 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,16 +361,19 @@ pub enum StatementKind<'tcx> {
/// At any point during the execution of a function, each local is either allocated or
/// unallocated. Except as noted below, all locals except function parameters are initially
/// unallocated. `StorageLive` statements cause memory to be allocated for the local while
/// `StorageDead` statements cause the memory to be freed. Using a local in any way (not only
/// reading/writing from it) while it is unallocated is UB.
/// `StorageDead` statements cause the memory to be freed. In other words,
/// `StorageLive`/`StorageDead` act like the heap operations `allocate`/`deallocate`, but for
/// stack-allocated local variables. Using a local in any way (not only reading/writing from it)
/// while it is unallocated is UB.
///
/// Some locals have no `StorageLive` or `StorageDead` statements within the entire MIR body.
/// These locals are implicitly allocated for the full duration of the function. There is a
/// convenience method at `rustc_mir_dataflow::storage::always_storage_live_locals` for
/// computing these locals.
///
/// If the local is already allocated, calling `StorageLive` again is UB. However, for an
/// unallocated local an additional `StorageDead` all is simply a nop.
/// If the local is already allocated, calling `StorageLive` again will implicitly free the
/// local and then allocate fresh uninitilized memory. If a local is already deallocated,
/// calling `StorageDead` again is a NOP.
StorageLive(Local),

/// See `StorageLive` above.
Expand Down
68 changes: 45 additions & 23 deletions compiler/rustc_mir_build/src/build/coverageinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,35 @@ impl BranchInfoBuilder {
}
}

fn add_two_way_branch<'tcx>(
fn register_two_way_branch<'tcx>(
&mut self,
tcx: TyCtxt<'tcx>,
cfg: &mut CFG<'tcx>,
source_info: SourceInfo,
true_block: BasicBlock,
false_block: BasicBlock,
) {
let true_marker = self.markers.inject_block_marker(cfg, source_info, true_block);
let false_marker = self.markers.inject_block_marker(cfg, source_info, false_block);

self.branch_spans.push(BranchSpan { span: source_info.span, true_marker, false_marker });
// Separate path for handling branches when MC/DC is enabled.
if let Some(mcdc_info) = self.mcdc_info.as_mut() {
let inject_block_marker =
|source_info, block| self.markers.inject_block_marker(cfg, source_info, block);
mcdc_info.visit_evaluated_condition(
tcx,
source_info,
true_block,
false_block,
inject_block_marker,
);
} else {
let true_marker = self.markers.inject_block_marker(cfg, source_info, true_block);
let false_marker = self.markers.inject_block_marker(cfg, source_info, false_block);

self.branch_spans.push(BranchSpan {
span: source_info.span,
true_marker,
false_marker,
});
}
}

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

branch_info.add_two_way_branch(&mut self.cfg, source_info, true_block, false_block);
// Separate path for handling branches when MC/DC is enabled.
branch_info.register_two_way_branch(
self.tcx,
&mut self.cfg,
source_info,
true_block,
false_block,
);

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

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

// Separate path for handling branches when MC/DC is enabled.
if let Some(mcdc_info) = branch_info.mcdc_info.as_mut() {
let inject_block_marker = |source_info, block| {
branch_info.markers.inject_block_marker(&mut self.cfg, source_info, block)
};
mcdc_info.visit_evaluated_condition(
self.tcx,
source_info,
then_block,
else_block,
inject_block_marker,
);
return;
}

branch_info.add_two_way_branch(&mut self.cfg, source_info, then_block, else_block);
branch_info.register_two_way_branch(
self.tcx,
&mut self.cfg,
source_info,
then_block,
else_block,
);
}

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

let source_info = SourceInfo { span: pattern.span, scope: self.source_scope };
branch_info.add_two_way_branch(&mut self.cfg, source_info, true_block, false_block);
branch_info.register_two_way_branch(
self.tcx,
&mut self.cfg,
source_info,
true_block,
false_block,
);
}
}
3 changes: 3 additions & 0 deletions compiler/rustc_mir_build/src/build/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
ExprKind::LogicalOp { op, lhs, rhs } => {
let condition_scope = this.local_scope();
let source_info = this.source_info(expr.span);

this.visit_coverage_branch_operation(op, expr.span);

// We first evaluate the left-hand side of the predicate ...
let (then_block, else_block) =
this.in_if_then_scope(condition_scope, expr.span, |this| {
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,20 @@ pub fn build_target_config(early_dcx: &EarlyDiagCtxt, opts: &Options, sysroot: &
for warning in warnings.warning_messages() {
early_dcx.early_warn(warning)
}

// The `wasm32-wasi` target is being renamed to `wasm32-wasip1` as
// part of rust-lang/compiler-team#607 and
// rust-lang/compiler-team#695. Warn unconditionally on usage to
// raise awareness of the renaming. This code will be deleted in
// October 2024.
if opts.target_triple.triple() == "wasm32-wasi" {
early_dcx.early_warn(
"the `wasm32-wasi` target is being renamed to \
`wasm32-wasip1` and the `wasm32-wasi` target will be \
removed from nightly in October 2024 and removed from \
stable Rust in January 2025",
)
}
if !matches!(target.pointer_width, 16 | 32 | 64) {
early_dcx.early_fatal(format!(
"target specification was invalid: unrecognized target-pointer-width {}",
Expand Down
4 changes: 1 addition & 3 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@
#
# If `extended = false`, the only one of these built by default is rustdoc.
#
# If `extended = true`, they're all included, with the exception of
# rust-demangler which additionally requires `profiler = true` to be set.
# If `extended = true`, they are all included.
#
# If any enabled tool fails to build, the installation fails.
#tools = [
Expand All @@ -334,7 +333,6 @@
# "rust-analyzer-proc-macro-srv",
# "analysis",
# "src",
# "rust-demangler", # if profiler = true
#]

# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose, 3 == print environment variables on each rustc invocation
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/src/core/build_steps/clippy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ lint_any!(
RemoteTestServer, "src/tools/remote-test-server", "remote-test-server";
Rls, "src/tools/rls", "rls";
RustAnalyzer, "src/tools/rust-analyzer", "rust-analyzer";
RustDemangler, "src/tools/rust-demangler", "rust-demangler";
Rustdoc, "src/tools/rustdoc", "clippy";
Rustfmt, "src/tools/rustfmt", "rustfmt";
RustInstaller, "src/tools/rust-installer", "rust-installer";
Expand Down
Loading

0 comments on commit 3186d17

Please sign in to comment.