Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 4 pull requests #122676

Merged
merged 9 commits into from
Mar 18, 2024
2 changes: 2 additions & 0 deletions compiler/rustc_const_eval/src/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
/// Runs the close in "validation" mode, which means the machine's memory read hooks will be
/// suppressed. Needless to say, this must only be set with great care! Cannot be nested.
pub(super) fn run_for_validation<R>(&self, f: impl FnOnce() -> R) -> R {
// This deliberately uses `==` on `bool` to follow the pattern
// `assert!(val.replace(new) == old)`.
assert!(
self.memory.validation_in_progress.replace(true) == false,
"`validation_in_progress` was already set"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
}
}

/// Determine if the associated item withe the given DefId matches
/// Determine if the associated item with the given DefId matches
/// the desired name via a doc alias.
fn matches_by_doc_alias(&self, def_id: DefId) -> bool {
let Some(name) = self.method_name else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/build/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let (current_root, parent_root) =
if self.tcx.sess.opts.unstable_opts.maximal_hir_to_mir_coverage {
// Some consumers of rustc need to map MIR locations back to HIR nodes. Currently
// the the only part of rustc that tracks MIR -> HIR is the
// the only part of rustc that tracks MIR -> HIR is the
// `SourceScopeLocalData::lint_root` field that tracks lint levels for MIR
// locations. Normally the number of source scopes is limited to the set of nodes
// with lint annotations. The -Zmaximal-hir-to-mir-coverage flag changes this
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ fn run_analysis_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let passes: &[&dyn MirPass<'tcx>] = &[
&cleanup_post_borrowck::CleanupPostBorrowck,
&remove_noop_landing_pads::RemoveNoopLandingPads,
&simplify::SimplifyCfg::EarlyOpt,
&simplify::SimplifyCfg::PostAnalysis,
&deref_separator::Derefer,
];

Expand Down Expand Up @@ -544,7 +544,7 @@ fn run_runtime_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let passes: &[&dyn MirPass<'tcx>] = &[
&lower_intrinsics::LowerIntrinsics,
&remove_place_mention::RemovePlaceMention,
&simplify::SimplifyCfg::ElaborateDrops,
&simplify::SimplifyCfg::PreOptimizations,
];

pm::run_passes(tcx, body, passes, Some(MirPhase::Runtime(RuntimePhase::PostCleanup)));
Expand Down
11 changes: 7 additions & 4 deletions compiler/rustc_mir_transform/src/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ pub enum SimplifyCfg {
Initial,
PromoteConsts,
RemoveFalseEdges,
EarlyOpt,
ElaborateDrops,
/// Runs at the beginning of "analysis to runtime" lowering, *before* drop elaboration.
PostAnalysis,
/// Runs at the end of "analysis to runtime" lowering, *after* drop elaboration.
/// This is before the main optimization passes on runtime MIR kick in.
PreOptimizations,
Final,
MakeShim,
AfterUninhabitedEnumBranching,
Expand All @@ -50,8 +53,8 @@ impl SimplifyCfg {
SimplifyCfg::Initial => "SimplifyCfg-initial",
SimplifyCfg::PromoteConsts => "SimplifyCfg-promote-consts",
SimplifyCfg::RemoveFalseEdges => "SimplifyCfg-remove-false-edges",
SimplifyCfg::EarlyOpt => "SimplifyCfg-early-opt",
SimplifyCfg::ElaborateDrops => "SimplifyCfg-elaborate-drops",
SimplifyCfg::PostAnalysis => "SimplifyCfg-post-analysis",
SimplifyCfg::PreOptimizations => "SimplifyCfg-pre-optimizations",
SimplifyCfg::Final => "SimplifyCfg-final",
SimplifyCfg::MakeShim => "SimplifyCfg-make_shim",
SimplifyCfg::AfterUninhabitedEnumBranching => {
Expand Down
2 changes: 0 additions & 2 deletions src/tools/tidy/src/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,6 @@
"ui/errors/issue-89280-emitter-overflow-splice-lines.rs",
"ui/errors/issue-99572-impl-trait-on-pointer.rs",
"ui/expr/if/issue-4201.rs",
"ui/extenv/issue-110547.rs",
"ui/extenv/issue-55897.rs",
"ui/extern/auxiliary/issue-80074-macro-2.rs",
"ui/extern/auxiliary/issue-80074-macro.rs",
"ui/extern/issue-10025.rs",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ENTRY_LIMIT: usize = 900;
// FIXME: The following limits should be reduced eventually.

const ISSUES_ENTRY_LIMIT: usize = 1750;
const ROOT_ENTRY_LIMIT: usize = 866;
const ROOT_ENTRY_LIMIT: usize = 859;

const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
"rs", // test source files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `main` after SimplifyCfg-elaborate-drops
// MIR for `main` after SimplifyCfg-pre-optimizations

fn main() -> () {
let mut _0: ();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `main` after SimplifyCfg-elaborate-drops
// MIR for `main` after SimplifyCfg-pre-optimizations

fn main() -> () {
let mut _0: ();
Expand Down
4 changes: 2 additions & 2 deletions tests/mir-opt/array_index_is_temporary.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ unit-test: SimplifyCfg-elaborate-drops
//@ unit-test: SimplifyCfg-pre-optimizations
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// Retagging (from Stacked Borrows) relies on the array index being a fresh
// temporary, so that side-effects cannot change it.
Expand All @@ -10,7 +10,7 @@ unsafe fn foo(z: *mut usize) -> u32 {
}


// EMIT_MIR array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir
// EMIT_MIR array_index_is_temporary.main.SimplifyCfg-pre-optimizations.after.mir
fn main() {
// CHECK-LABEL: fn main(
// CHECK: debug x => [[x:_.*]];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `main` after SimplifyCfg-elaborate-drops
// MIR for `main` after SimplifyCfg-pre-optimizations

fn main() -> () {
let mut _0: ();
Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/byte_slice.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// skip-filecheck
//@ compile-flags: -Z mir-opt-level=0

// EMIT_MIR byte_slice.main.SimplifyCfg-elaborate-drops.after.mir
// EMIT_MIR byte_slice.main.SimplifyCfg-pre-optimizations.after.mir
fn main() {
let x = b"foo";
let y = [5u8, b'x'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `BAR::promoted[0]` after SimplifyCfg-elaborate-drops
// MIR for `BAR::promoted[0]` after SimplifyCfg-pre-optimizations

const BAR::promoted[0]: &[&i32; 1] = {
let mut _0: &[&i32; 1];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `FOO::promoted[0]` after SimplifyCfg-elaborate-drops
// MIR for `FOO::promoted[0]` after SimplifyCfg-pre-optimizations

const FOO::promoted[0]: &[&i32; 1] = {
let mut _0: &[&i32; 1];
Expand Down
4 changes: 2 additions & 2 deletions tests/mir-opt/const_promotion_extern_static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ extern "C" {
static Y: i32 = 42;

// EMIT_MIR const_promotion_extern_static.BAR.PromoteTemps.diff
// EMIT_MIR const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir
// EMIT_MIR const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-pre-optimizations.after.mir
static mut BAR: *const &i32 = [&Y].as_ptr();

// EMIT_MIR const_promotion_extern_static.FOO.PromoteTemps.diff
// EMIT_MIR const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir
// EMIT_MIR const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-pre-optimizations.after.mir
static mut FOO: *const &i32 = [unsafe { &X }].as_ptr();

// EMIT_MIR const_promotion_extern_static.BOP.built.after.mir
Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/no_drop_for_inactive_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Ensure that there are no drop terminators in `unwrap<T>` (except the one along the cleanup
// path).

// EMIT_MIR no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir
// EMIT_MIR no_drop_for_inactive_variant.unwrap.SimplifyCfg-pre-optimizations.after.mir
fn unwrap<T>(opt: Option<T>) -> T {
match opt {
Some(x) => x,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `unwrap` after SimplifyCfg-elaborate-drops
// MIR for `unwrap` after SimplifyCfg-pre-optimizations

fn unwrap(_1: Option<T>) -> T {
debug opt => _1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `unwrap` after SimplifyCfg-elaborate-drops
// MIR for `unwrap` after SimplifyCfg-pre-optimizations

fn unwrap(_1: Option<T>) -> T {
debug opt => _1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `main` after SimplifyCfg-elaborate-drops
// MIR for `main` after SimplifyCfg-pre-optimizations

fn main() -> () {
let mut _0: ();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `main` after SimplifyCfg-elaborate-drops
// MIR for `main` after SimplifyCfg-pre-optimizations

fn main() -> () {
let mut _0: ();
Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/packed_struct_drop_aligned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY


// EMIT_MIR packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir
// EMIT_MIR packed_struct_drop_aligned.main.SimplifyCfg-pre-optimizations.after.mir
fn main() {
let mut x = Packed(Aligned(Droppy(0)));
x.0 = Aligned(Droppy(0));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `array_casts` after SimplifyCfg-elaborate-drops
// MIR for `array_casts` after SimplifyCfg-pre-optimizations

fn array_casts() -> () {
let mut _0: ();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `array_casts` after SimplifyCfg-elaborate-drops
// MIR for `array_casts` after SimplifyCfg-pre-optimizations

fn array_casts() -> () {
let mut _0: ();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `main::{closure#0}` after SimplifyCfg-elaborate-drops
// MIR for `main::{closure#0}` after SimplifyCfg-pre-optimizations

fn main::{closure#0}(_1: &{closure@main::{closure#0}}, _2: &i32) -> &i32 {
debug x => _2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `main::{closure#0}` after SimplifyCfg-elaborate-drops
// MIR for `main::{closure#0}` after SimplifyCfg-pre-optimizations

fn main::{closure#0}(_1: &{closure@main::{closure#0}}, _2: &i32) -> &i32 {
debug x => _2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `main` after SimplifyCfg-elaborate-drops
// MIR for `main` after SimplifyCfg-pre-optimizations

fn main() -> () {
let mut _0: ();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `main` after SimplifyCfg-elaborate-drops
// MIR for `main` after SimplifyCfg-pre-optimizations

fn main() -> () {
let mut _0: ();
Expand Down
10 changes: 5 additions & 5 deletions tests/mir-opt/retag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

struct Test(i32);

// EMIT_MIR retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.mir
// EMIT_MIR retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.mir
// EMIT_MIR retag.{impl#0}-foo.SimplifyCfg-pre-optimizations.after.mir
// EMIT_MIR retag.{impl#0}-foo_shr.SimplifyCfg-pre-optimizations.after.mir
impl Test {
// Make sure we run the pass on a method, not just on bare functions.
fn foo<'x>(&self, x: &'x mut i32) -> &'x mut i32 {
Expand All @@ -26,8 +26,8 @@ impl Drop for Test {
fn drop(&mut self) {}
}

// EMIT_MIR retag.main.SimplifyCfg-elaborate-drops.after.mir
// EMIT_MIR retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir
// EMIT_MIR retag.main.SimplifyCfg-pre-optimizations.after.mir
// EMIT_MIR retag.main-{closure#0}.SimplifyCfg-pre-optimizations.after.mir
pub fn main() {
let mut x = 0;
{
Expand Down Expand Up @@ -55,7 +55,7 @@ pub fn main() {
}

/// Casting directly to an array should also go through `&raw` and thus add appropriate retags.
// EMIT_MIR retag.array_casts.SimplifyCfg-elaborate-drops.after.mir
// EMIT_MIR retag.array_casts.SimplifyCfg-pre-optimizations.after.mir
fn array_casts() {
let mut x: [usize; 2] = [0, 0];
let p = &mut x as *mut usize;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `<impl at $DIR/retag.rs:13:1: 13:10>::foo` after SimplifyCfg-elaborate-drops
// MIR for `<impl at $DIR/retag.rs:13:1: 13:10>::foo` after SimplifyCfg-pre-optimizations

fn <impl at $DIR/retag.rs:13:1: 13:10>::foo(_1: &Test, _2: &mut i32) -> &mut i32 {
debug self => _1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `<impl at $DIR/retag.rs:13:1: 13:10>::foo` after SimplifyCfg-elaborate-drops
// MIR for `<impl at $DIR/retag.rs:13:1: 13:10>::foo` after SimplifyCfg-pre-optimizations

fn <impl at $DIR/retag.rs:13:1: 13:10>::foo(_1: &Test, _2: &mut i32) -> &mut i32 {
debug self => _1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `<impl at $DIR/retag.rs:13:1: 13:10>::foo_shr` after SimplifyCfg-elaborate-drops
// MIR for `<impl at $DIR/retag.rs:13:1: 13:10>::foo_shr` after SimplifyCfg-pre-optimizations

fn <impl at $DIR/retag.rs:13:1: 13:10>::foo_shr(_1: &Test, _2: &i32) -> &i32 {
debug self => _1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `<impl at $DIR/retag.rs:13:1: 13:10>::foo_shr` after SimplifyCfg-elaborate-drops
// MIR for `<impl at $DIR/retag.rs:13:1: 13:10>::foo_shr` after SimplifyCfg-pre-optimizations

fn <impl at $DIR/retag.rs:13:1: 13:10>::foo_shr(_1: &Test, _2: &i32) -> &i32 {
debug self => _1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- // MIR for `main` before SimplifyCfg-early-opt
+ // MIR for `main` after SimplifyCfg-early-opt
- // MIR for `main` before SimplifyCfg-post-analysis
+ // MIR for `main` after SimplifyCfg-post-analysis

fn main() -> () {
let mut _0: ();
Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/simplify_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//@ no-prefer-dynamic

// EMIT_MIR simplify_cfg.main.SimplifyCfg-initial.diff
// EMIT_MIR simplify_cfg.main.SimplifyCfg-early-opt.diff
// EMIT_MIR simplify_cfg.main.SimplifyCfg-post-analysis.diff
fn main() {
loop {
if bar() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected string literal
--> $DIR/extenv-arg-2-not-string-literal.rs:1:25
--> $DIR/env-arg-2-not-string-literal.rs:1:25
|
LL | fn main() { env!("one", 10); }
| ^^
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: environment variable `\t` not defined at compile time
--> $DIR/extenv-escaped-var.rs:2:5
--> $DIR/env-escaped-var.rs:2:5
|
LL | env!("\t");
| ^^^^^^^^^^
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `env!()` takes 1 or 2 arguments
--> $DIR/extenv-no-args.rs:1:13
--> $DIR/env-no-args.rs:1:13
|
LL | fn main() { env!(); }
| ^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: my error message
--> $DIR/extenv-not-defined-custom.rs:1:13
--> $DIR/env-not-defined-custom.rs:1:13
|
LL | fn main() { env!("__HOPEFULLY_NOT_DEFINED__", "my error message"); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: environment variable `CARGO__HOPEFULLY_NOT_DEFINED__` not defined at compile time
--> $DIR/extenv-not-defined-default.rs:2:5
--> $DIR/env-not-defined-default.rs:2:5
|
LL | env!("CARGO__HOPEFULLY_NOT_DEFINED__");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected string literal
--> $DIR/extenv-not-string-literal.rs:1:18
--> $DIR/env-not-string-literal.rs:1:18
|
LL | fn main() { env!(10, "two"); }
| ^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `env!()` takes 1 or 2 arguments
--> $DIR/extenv-too-many-args.rs:1:13
--> $DIR/env-too-many-args.rs:1:13
|
LL | fn main() { env!("one", "two", "three"); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: environment variable `NON_EXISTENT` not defined at compile time
--> $DIR/issue-55897.rs:10:22
--> $DIR/error-recovery-issue-55897.rs:10:22
|
LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs"));
| ^^^^^^^^^^^^^^^^^^^^
Expand All @@ -8,13 +8,13 @@ LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs"));
= note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)

error: suffixes on string literals are invalid
--> $DIR/issue-55897.rs:15:22
--> $DIR/error-recovery-issue-55897.rs:15:22
|
LL | include!(concat!("NON_EXISTENT"suffix, "/data.rs"));
| ^^^^^^^^^^^^^^^^^^^^ invalid suffix `suffix`

error[E0432]: unresolved import `prelude`
--> $DIR/issue-55897.rs:1:5
--> $DIR/error-recovery-issue-55897.rs:1:5
|
LL | use prelude::*;
| ^^^^^^^
Expand All @@ -23,7 +23,7 @@ LL | use prelude::*;
| help: a similar path exists: `std::prelude`

error[E0432]: unresolved import `env`
--> $DIR/issue-55897.rs:4:9
--> $DIR/error-recovery-issue-55897.rs:4:9
|
LL | use env;
| ^^^ no `env` in the root
Expand Down
Loading
Loading