From 1e264abf795540a46fb14aa1f0ed717e4f22ecff Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 11 Sep 2022 18:02:54 -0400 Subject: [PATCH 001/219] Add QEMU test for x86_64-unknown-uefi The UEFI targets don't have std support yet, so the normal tests don't work. However, we can compile a simple no-std program and run it under QEMU to at least check that the target compiles, links, and runs. Tested locally with: src/ci/docker/run.sh test-various --- .../host-x86_64/test-various/Dockerfile | 11 ++- .../test-various/uefi_qemu_test/Cargo.toml | 9 ++ .../test-various/uefi_qemu_test/run.py | 96 +++++++++++++++++++ .../test-various/uefi_qemu_test/src/main.rs | 45 +++++++++ 4 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 src/ci/docker/host-x86_64/test-various/uefi_qemu_test/Cargo.toml create mode 100644 src/ci/docker/host-x86_64/test-various/uefi_qemu_test/run.py create mode 100644 src/ci/docker/host-x86_64/test-various/uefi_qemu_test/src/main.rs diff --git a/src/ci/docker/host-x86_64/test-various/Dockerfile b/src/ci/docker/host-x86_64/test-various/Dockerfile index b75e2f085cd..b0f35bcb9cc 100644 --- a/src/ci/docker/host-x86_64/test-various/Dockerfile +++ b/src/ci/docker/host-x86_64/test-various/Dockerfile @@ -16,7 +16,9 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins pkg-config \ xz-utils \ wget \ - patch + patch \ + ovmf \ + qemu-system-x86 RUN curl -sL https://nodejs.org/dist/v15.14.0/node-v15.14.0-linux-x64.tar.xz | \ tar -xJ @@ -64,4 +66,9 @@ ENV MUSL_TARGETS=x86_64-unknown-linux-musl \ CXX_x86_64_unknown_linux_musl=x86_64-linux-musl-g++ ENV MUSL_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $MUSL_TARGETS -ENV SCRIPT $WASM_SCRIPT && $NVPTX_SCRIPT && $MUSL_SCRIPT +COPY host-x86_64/test-various/uefi_qemu_test /uefi_qemu_test +ENV UEFI_TARGETS=x86_64-unknown-uefi +ENV UEFI_SCRIPT python3 /checkout/x.py --stage 2 build --host='' --target $UEFI_TARGETS && \ + python3 -u /uefi_qemu_test/run.py + +ENV SCRIPT $WASM_SCRIPT && $NVPTX_SCRIPT && $MUSL_SCRIPT && $UEFI_SCRIPT diff --git a/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/Cargo.toml b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/Cargo.toml new file mode 100644 index 00000000000..fa8e5b3d080 --- /dev/null +++ b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "uefi_qemu_test" +version = "0.0.0" +edition = "2021" + +[workspace] + +[dependencies] +r-efi = "4.1.0" diff --git a/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/run.py b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/run.py new file mode 100644 index 00000000000..46793ce3afa --- /dev/null +++ b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/run.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 + +import os +import shutil +import subprocess +import sys +import tempfile + +from pathlib import Path + + +def run(*cmd, capture=False, check=True, env=None): + """Print and run a command, optionally capturing the output.""" + cmd = [str(p) for p in cmd] + print(' '.join(cmd)) + return subprocess.run(cmd, + capture_output=capture, + check=check, + env=env, + text=True) + + +def build_and_run(tmp_dir): + host_artifacts = Path('/checkout/obj/build/x86_64-unknown-linux-gnu') + stage0 = host_artifacts / 'stage0/bin' + stage2 = host_artifacts / 'stage2/bin' + + env = dict(os.environ) + env['PATH'] = '{}:{}:{}'.format(stage2, stage0, env['PATH']) + + # Copy the test create into `tmp_dir`. + test_crate = Path(tmp_dir) / 'uefi_qemu_test' + shutil.copytree('/uefi_qemu_test', test_crate) + + # Build the UEFI executable. + target = 'x86_64-unknown-uefi' + run('cargo', + 'build', + '--manifest-path', + test_crate / 'Cargo.toml', + '--target', + target, + env=env) + + # Create a mock EFI System Partition in a subdirectory. + esp = test_crate / 'esp' + boot = esp / 'efi/boot' + os.makedirs(boot, exist_ok=True) + + # Copy the executable into the ESP. + src_exe_path = test_crate / 'target' / target / 'debug/uefi_qemu_test.efi' + shutil.copy(src_exe_path, boot / 'bootx64.efi') + + # Run the executable in QEMU and capture the output. + qemu = 'qemu-system-x86_64' + ovmf_dir = Path('/usr/share/OVMF') + ovmf_code = ovmf_dir / 'OVMF_CODE.fd' + ovmf_vars = ovmf_dir / 'OVMF_VARS.fd' + output = run(qemu, + '-display', + 'none', + '-serial', + 'stdio', + '-drive', + f'if=pflash,format=raw,readonly=on,file={ovmf_code}', + '-drive', + f'if=pflash,format=raw,readonly=on,file={ovmf_vars}', + '-drive', + f'format=raw,file=fat:rw:{esp}', + capture=True, + # Ubuntu 20.04 (which is what the Dockerfile currently + # uses) provides QEMU 4.2.1, which segfaults on + # shutdown under some circumstances. That has been + # fixed in newer versions of QEMU, but for now just + # don't check the exit status. + check=False).stdout + + if 'Hello World!' in output: + print('VM produced expected output') + else: + print('unexpected VM output:') + print('---start---') + print(output) + print('---end---') + sys.exit(1) + + +def main(): + # Create a temporary directory so that we have a writeable + # workspace. + with tempfile.TemporaryDirectory() as tmp_dir: + build_and_run(tmp_dir) + + +if __name__ == "__main__": + main() diff --git a/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/src/main.rs b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/src/main.rs new file mode 100644 index 00000000000..2ec554c140b --- /dev/null +++ b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/src/main.rs @@ -0,0 +1,45 @@ +// Code is adapted from this hello world example: +// https://doc.rust-lang.org/nightly/rustc/platform-support/unknown-uefi.html + +#![no_main] +#![no_std] + +use core::{panic, ptr}; +use r_efi::efi::{Char16, Handle, Status, SystemTable, RESET_SHUTDOWN}; + +#[panic_handler] +fn panic_handler(_info: &panic::PanicInfo) -> ! { + loop {} +} + +#[export_name = "efi_main"] +pub extern "C" fn main(_h: Handle, st: *mut SystemTable) -> Status { + let s = [ + 0x0048u16, 0x0065u16, 0x006cu16, 0x006cu16, 0x006fu16, // "Hello" + 0x0020u16, // " " + 0x0057u16, 0x006fu16, 0x0072u16, 0x006cu16, 0x0064u16, // "World" + 0x0021u16, // "!" + 0x000au16, // "\n" + 0x0000u16, // NUL + ]; + + // Print "Hello World!". + let r = unsafe { ((*(*st).con_out).output_string)((*st).con_out, s.as_ptr() as *mut Char16) }; + if r.is_error() { + return r; + } + + // Shut down. + unsafe { + ((*((*st).runtime_services)).reset_system)( + RESET_SHUTDOWN, + Status::SUCCESS, + 0, + ptr::null_mut(), + ); + } + + // This should never be reached because `reset_system` should never + // return, so fail with an error if we get here. + Status::UNSUPPORTED +} From d03185ed98b4ff022a111993d138923dbc8d5052 Mon Sep 17 00:00:00 2001 From: Ayrton Date: Tue, 4 Oct 2022 21:37:30 -0400 Subject: [PATCH 002/219] Add Sony PlayStation 1 tier 3 target --- .../rustc_target/src/spec/mipsel_sony_psx.rs | 37 ++++++++++++++ compiler/rustc_target/src/spec/mod.rs | 1 + src/doc/rustc/src/SUMMARY.md | 1 + src/doc/rustc/src/platform-support.md | 1 + .../src/platform-support/mipsel-sony-psx.md | 49 +++++++++++++++++++ 5 files changed, 89 insertions(+) create mode 100644 compiler/rustc_target/src/spec/mipsel_sony_psx.rs create mode 100644 src/doc/rustc/src/platform-support/mipsel-sony-psx.md diff --git a/compiler/rustc_target/src/spec/mipsel_sony_psx.rs b/compiler/rustc_target/src/spec/mipsel_sony_psx.rs new file mode 100644 index 00000000000..12a66efdd46 --- /dev/null +++ b/compiler/rustc_target/src/spec/mipsel_sony_psx.rs @@ -0,0 +1,37 @@ +use crate::spec::{cvs, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mipsel-sony-psx".into(), + pointer_width: 32, + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + + options: TargetOptions { + os: "none".into(), + env: "psx".into(), + vendor: "sony".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + cpu: "mips1".into(), + executables: true, + linker: Some("rust-lld".into()), + relocation_model: RelocModel::Static, + exe_suffix: ".exe".into(), + + // PSX doesn't natively support floats. + features: "+soft-float".into(), + + // This should be 16 bits, but LLVM incorrectly tries emitting MIPS-II SYNC instructions + // for atomic loads and stores. This crashes rustc so we have to disable the Atomic* API + // until this is fixed upstream. See https://reviews.llvm.org/D122427#3420144 for more + // info. + max_atomic_width: Some(0), + + // PSX does not support trap-on-condition instructions. + llvm_args: cvs!["-mno-check-zero-division"], + llvm_abiname: "o32".into(), + panic_strategy: PanicStrategy::Abort, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 9396d769dc7..3ddabe84395 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1222,6 +1222,7 @@ supported_targets! { ("armv7a-kmc-solid_asp3-eabihf", armv7a_kmc_solid_asp3_eabihf), ("mipsel-sony-psp", mipsel_sony_psp), + ("mipsel-sony-psx", mipsel_sony_psx), ("mipsel-unknown-none", mipsel_unknown_none), ("thumbv4t-none-eabi", thumbv4t_none_eabi), ("armv4t-none-eabi", armv4t_none_eabi), diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index 06883ddd58b..86bb2c0d381 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -29,6 +29,7 @@ - [\*-kmc-solid_\*](platform-support/kmc-solid.md) - [m68k-unknown-linux-gnu](platform-support/m68k-unknown-linux-gnu.md) - [mips64-openwrt-linux-musl](platform-support/mips64-openwrt-linux-musl.md) + - [mipsel-sony-psx](platform-support/mipsel-sony-psx.md) - [nvptx64-nvidia-cuda](platform-support/nvptx64-nvidia-cuda.md) - [riscv32imac-unknown-xous-elf](platform-support/riscv32imac-unknown-xous-elf.md) - [*-pc-windows-gnullvm](platform-support/pc-windows-gnullvm.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index a36518cc8ce..3ae9872cf62 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -260,6 +260,7 @@ target | std | host | notes `mips-unknown-linux-uclibc` | ✓ | | MIPS Linux with uClibc [`mips64-openwrt-linux-musl`](platform-support/mips64-openwrt-linux-musl.md) | ? | | MIPS64 for OpenWrt Linux MUSL `mipsel-sony-psp` | * | | MIPS (LE) Sony PlayStation Portable (PSP) +[`mipsel-sony-psx`](platform-support/mipsel-sony-psx.md) | * | | MIPS (LE) Sony PlayStation 1 (PSX) `mipsel-unknown-linux-uclibc` | ✓ | | MIPS (LE) Linux with uClibc `mipsel-unknown-none` | * | | Bare MIPS (LE) softfloat `mipsisa32r6-unknown-linux-gnu` | ? | | diff --git a/src/doc/rustc/src/platform-support/mipsel-sony-psx.md b/src/doc/rustc/src/platform-support/mipsel-sony-psx.md new file mode 100644 index 00000000000..589100e8888 --- /dev/null +++ b/src/doc/rustc/src/platform-support/mipsel-sony-psx.md @@ -0,0 +1,49 @@ +# mipsel-sony-psx + +**Tier: 3** + +Sony PlayStation 1 (psx) + +## Designated Developer + +* [@ayrtonm](https://github.com/ayrtonm) + +## Requirements + +This target is cross-compiled. +It has no special requirements for the host. + +## Building + +The target can be built by enabling it for a `rustc` build: + +```toml +[build] +build-stage = 1 +target = ["mipsel-sony-psx"] +``` + +## Cross-compilation + +This target can be cross-compiled from any host. + +## Testing + +Currently there is no support to run the rustc test suite for this target. + +## Building Rust programs + +Since it is Tier 3, rust doesn't ship pre-compiled artifacts for this target. + +Just use the `build-std` nightly cargo feature to build the `core` and `alloc` libraries: +```shell +cargo build -Zbuild-std=core,alloc --target mipsel-sony-psx +``` + +The command above generates an ELF. To generate binaries in the PSEXE format that emulators run, you can use [cargo-psx](https://github.com/ayrtonm/psx-sdk-rs#readme): + +```shell +cargo psx build +``` + +or use `-Clink-arg=--oformat=binary` to produce a flat binary. From 0227d8d55512d9fee22532f10459b4dc96de1b1e Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 12 Oct 2022 08:28:14 +0000 Subject: [PATCH 003/219] Enable `x.py check` for miri --- src/bootstrap/check.rs | 6 ++---- src/bootstrap/doc.rs | 35 ++++++----------------------------- src/bootstrap/test.rs | 4 ++-- src/bootstrap/tool.rs | 23 +++++++++-------------- 4 files changed, 19 insertions(+), 49 deletions(-) diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 229851238f1..d553dd4e042 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -451,14 +451,12 @@ macro_rules! tool_check_step { } tool_check_step!(Rustdoc, "src/tools/rustdoc", "src/librustdoc", SourceType::InTree); -// Clippy and Rustfmt are hybrids. They are external tools, but use a git subtree instead +// Clippy, miri and Rustfmt are hybrids. They are external tools, but use a git subtree instead // of a submodule. Since the SourceType only drives the deny-warnings // behavior, treat it as in-tree so that any new warnings in clippy will be // rejected. tool_check_step!(Clippy, "src/tools/clippy", SourceType::InTree); -// Miri on the other hand is treated as out of tree, since InTree also causes it to -// be run as part of `check`, which can fail on platforms which libffi-sys has no support for. -tool_check_step!(Miri, "src/tools/miri", SourceType::Submodule); +tool_check_step!(Miri, "src/tools/miri", SourceType::InTree); tool_check_step!(Rls, "src/tools/rls", SourceType::InTree); tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree); diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 819af658748..eaeb5674d7d 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -734,7 +734,7 @@ impl Step for Rustc { } macro_rules! tool_doc { - ($tool: ident, $should_run: literal, $path: literal, [$($krate: literal),+ $(,)?], in_tree = $in_tree:expr $(,)?) => { + ($tool: ident, $should_run: literal, $path: literal, [$($krate: literal),+ $(,)?] $(,)?) => { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct $tool { target: TargetSelection, @@ -790,12 +790,6 @@ macro_rules! tool_doc { t!(fs::create_dir_all(&out_dir)); t!(symlink_dir_force(&builder.config, &out, &out_dir)); - let source_type = if $in_tree == true { - SourceType::InTree - } else { - SourceType::Submodule - }; - // Build cargo command. let mut cargo = prepare_tool_cargo( builder, @@ -804,7 +798,7 @@ macro_rules! tool_doc { target, "doc", $path, - source_type, + SourceType::InTree, &[], ); @@ -820,38 +814,21 @@ macro_rules! tool_doc { cargo.rustdocflag("--show-type-layout"); cargo.rustdocflag("--generate-link-to-definition"); cargo.rustdocflag("-Zunstable-options"); - if $in_tree == true { - builder.run(&mut cargo.into()); - } else { - // Allow out-of-tree docs to fail (since the tool might be in a broken state). - if !builder.try_run(&mut cargo.into()) { - builder.info(&format!( - "WARNING: tool {} failed to document; ignoring failure because it is an out-of-tree tool", - stringify!($tool).to_lowercase(), - )); - } - } + builder.run(&mut cargo.into()); } } } } -tool_doc!( - Rustdoc, - "rustdoc-tool", - "src/tools/rustdoc", - ["rustdoc", "rustdoc-json-types"], - in_tree = true -); +tool_doc!(Rustdoc, "rustdoc-tool", "src/tools/rustdoc", ["rustdoc", "rustdoc-json-types"],); tool_doc!( Rustfmt, "rustfmt-nightly", "src/tools/rustfmt", ["rustfmt-nightly", "rustfmt-config_proc_macro"], - in_tree = true ); -tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"], in_tree = true); -tool_doc!(Miri, "miri", "src/tools/miri", ["miri"], in_tree = false); +tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"]); +tool_doc!(Miri, "miri", "src/tools/miri", ["miri"]); #[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ErrorIndex { diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 8d491409778..45d46f57d6e 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -503,7 +503,7 @@ impl Step for Miri { host, "run", "src/tools/miri/cargo-miri", - SourceType::Submodule, + SourceType::InTree, &[], ); cargo.add_rustc_lib_path(builder, compiler); @@ -550,7 +550,7 @@ impl Step for Miri { host, "test", "src/tools/miri", - SourceType::Submodule, + SourceType::InTree, &[], ); cargo.add_rustc_lib_path(builder, compiler); diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index d6e7f787270..d2d5a3be5ed 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -795,7 +795,6 @@ macro_rules! tool_extended { $path:expr, $tool_name:expr, stable = $stable:expr, - $(in_tree = $in_tree:expr,)? $(tool_std = $tool_std:literal,)? $extra_deps:block;)+) => { $( @@ -848,11 +847,7 @@ macro_rules! tool_extended { path: $path, extra_features: $sel.extra_features, is_optional_tool: true, - source_type: if false $(|| $in_tree)* { - SourceType::InTree - } else { - SourceType::Submodule - }, + source_type: SourceType::InTree, }) } } @@ -865,17 +860,17 @@ macro_rules! tool_extended { // Note: Most submodule updates for tools are handled by bootstrap.py, since they're needed just to // invoke Cargo to build bootstrap. See the comment there for more details. tool_extended!((self, builder), - Cargofmt, "src/tools/rustfmt", "cargo-fmt", stable=true, in_tree=true, {}; - CargoClippy, "src/tools/clippy", "cargo-clippy", stable=true, in_tree=true, {}; - Clippy, "src/tools/clippy", "clippy-driver", stable=true, in_tree=true, {}; - Miri, "src/tools/miri", "miri", stable=false, in_tree=true, {}; - CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=false, in_tree=true, {}; + Cargofmt, "src/tools/rustfmt", "cargo-fmt", stable=true, {}; + CargoClippy, "src/tools/clippy", "cargo-clippy", stable=true, {}; + Clippy, "src/tools/clippy", "clippy-driver", stable=true, {}; + Miri, "src/tools/miri", "miri", stable=false, {}; + CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=true, {}; // FIXME: tool_std is not quite right, we shouldn't allow nightly features. // But `builder.cargo` doesn't know how to handle ToolBootstrap in stages other than 0, // and this is close enough for now. - Rls, "src/tools/rls", "rls", stable=true, in_tree=true, tool_std=true, {}; - RustDemangler, "src/tools/rust-demangler", "rust-demangler", stable=false, in_tree=true, tool_std=true, {}; - Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, in_tree=true, {}; + Rls, "src/tools/rls", "rls", stable=true, tool_std=true, {}; + RustDemangler, "src/tools/rust-demangler", "rust-demangler", stable=false, tool_std=true, {}; + Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, {}; ); impl<'a> Builder<'a> { From c4b9b6532bb7742f97863f59629c8b797654ceea Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 13 Oct 2022 07:38:29 +0000 Subject: [PATCH 004/219] Remove unused macro argument --- src/bootstrap/tool.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index d2d5a3be5ed..27dccf7938a 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -794,9 +794,9 @@ macro_rules! tool_extended { $($name:ident, $path:expr, $tool_name:expr, - stable = $stable:expr, - $(tool_std = $tool_std:literal,)? - $extra_deps:block;)+) => { + stable = $stable:expr + $(,tool_std = $tool_std:literal)? + ;)+) => { $( #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct $name { @@ -838,7 +838,6 @@ macro_rules! tool_extended { #[allow(unused_mut)] fn run(mut $sel, $builder: &Builder<'_>) -> Option { - $extra_deps $builder.ensure(ToolBuild { compiler: $sel.compiler, target: $sel.target, @@ -860,17 +859,17 @@ macro_rules! tool_extended { // Note: Most submodule updates for tools are handled by bootstrap.py, since they're needed just to // invoke Cargo to build bootstrap. See the comment there for more details. tool_extended!((self, builder), - Cargofmt, "src/tools/rustfmt", "cargo-fmt", stable=true, {}; - CargoClippy, "src/tools/clippy", "cargo-clippy", stable=true, {}; - Clippy, "src/tools/clippy", "clippy-driver", stable=true, {}; - Miri, "src/tools/miri", "miri", stable=false, {}; - CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=true, {}; + Cargofmt, "src/tools/rustfmt", "cargo-fmt", stable=true; + CargoClippy, "src/tools/clippy", "cargo-clippy", stable=true; + Clippy, "src/tools/clippy", "clippy-driver", stable=true; + Miri, "src/tools/miri", "miri", stable=false; + CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=true; // FIXME: tool_std is not quite right, we shouldn't allow nightly features. // But `builder.cargo` doesn't know how to handle ToolBootstrap in stages other than 0, // and this is close enough for now. - Rls, "src/tools/rls", "rls", stable=true, tool_std=true, {}; - RustDemangler, "src/tools/rust-demangler", "rust-demangler", stable=false, tool_std=true, {}; - Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, {}; + Rls, "src/tools/rls", "rls", stable=true, tool_std=true; + RustDemangler, "src/tools/rust-demangler", "rust-demangler", stable=false, tool_std=true; + Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true; ); impl<'a> Builder<'a> { From 6bfe7f01dce5a9c4d1711dc3f30a1f9c13d9eecb Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Sat, 15 Oct 2022 22:46:59 +0100 Subject: [PATCH 005/219] asm: Match clang behavior for inlateout fixed register operands We have 2 options for representing LLVM constraints for `inlateout` operands on a fixed register (e.g. `r0`): `={r0},0` or `={r0},{r0}`. This PR changes the behavior to the latter, which matches the behavior of Clang since https://reviews.llvm.org/D87279. --- compiler/rustc_codegen_llvm/src/asm.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index e723187ff1f..0254f982948 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -130,7 +130,7 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { op_idx.insert(idx, constraints.len()); constraints.push(reg_to_llvm(reg, Some(&value.layout))); } - InlineAsmOperandRef::InOut { reg, late: _, in_value, out_place: _ } => { + InlineAsmOperandRef::InOut { reg, late, in_value, out_place: _ } => { let value = llvm_fixup_input( self, in_value.immediate(), @@ -138,7 +138,16 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { &in_value.layout, ); inputs.push(value); - constraints.push(format!("{}", op_idx[&idx])); + + // In the case of fixed registers, we have the choice of + // either using a tied operand or duplicating the constraint. + // We prefer the latter because it matches the behavior of + // Clang. + if late && matches!(reg, InlineAsmRegOrRegClass::Reg(_)) { + constraints.push(format!("{}", reg_to_llvm(reg, Some(&in_value.layout)))); + } else { + constraints.push(format!("{}", op_idx[&idx])); + } } InlineAsmOperandRef::SymFn { instance } => { inputs.push(self.cx.get_fn(instance)); From 406e1dc8ebdeb509515c0c8be7cfe015c5eced30 Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Wed, 19 Oct 2022 00:08:20 +0200 Subject: [PATCH 006/219] Implement -Ztrack-diagnostics --- compiler/rustc_driver/src/lib.rs | 1 + compiler/rustc_errors/src/diagnostic.rs | 29 +++++++++++++++ .../rustc_errors/src/diagnostic_builder.rs | 5 +++ compiler/rustc_errors/src/emitter.rs | 36 ++++++++++++++++--- compiler/rustc_errors/src/json.rs | 8 +++++ compiler/rustc_errors/src/json/tests.rs | 1 + compiler/rustc_errors/src/lib.rs | 30 ++++++++++++++++ compiler/rustc_expand/src/tests.rs | 1 + compiler/rustc_session/src/config.rs | 1 + compiler/rustc_session/src/options.rs | 2 ++ compiler/rustc_session/src/session.rs | 30 ++++++++++++++-- src/librustdoc/core.rs | 2 ++ src/librustdoc/doctest.rs | 3 ++ src/test/ui/track-diagnostics/track.rs | 6 ++++ src/test/ui/track-diagnostics/track.stderr | 26 ++++++++++++++ src/tools/clippy/clippy_lints/src/doc.rs | 1 + src/tools/clippy/src/driver.rs | 1 + src/tools/rustfmt/src/parse/session.rs | 1 + 18 files changed, 176 insertions(+), 8 deletions(-) create mode 100644 src/test/ui/track-diagnostics/track.rs create mode 100644 src/test/ui/track-diagnostics/track.stderr diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index f268d50e96e..b92a3289fa2 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1211,6 +1211,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { false, None, false, + false, )); let handler = rustc_errors::Handler::with_emitter(true, None, emitter); diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 518c59dba53..1ea6d82891f 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -12,6 +12,7 @@ use rustc_span::{Span, DUMMY_SP}; use std::borrow::Cow; use std::fmt; use std::hash::{Hash, Hasher}; +use std::panic::Location; /// Error type for `Diagnostic`'s `suggestions` field, indicating that /// `.disable_suggestions()` was called on the `Diagnostic`. @@ -107,6 +108,31 @@ pub struct Diagnostic { /// If diagnostic is from Lint, custom hash function ignores notes /// otherwise hash is based on the all the fields pub is_lint: bool, + + /// With `-Ztrack_diagnostics` enabled, + /// we print where in rustc this error was emitted. + pub emitted_at: DiagnosticLocation, +} + +#[derive(Clone, Debug, Encodable, Decodable)] +pub struct DiagnosticLocation { + file: Cow<'static, str>, + line: u32, + col: u32, +} + +impl DiagnosticLocation { + #[track_caller] + fn caller() -> Self { + let loc = Location::caller(); + DiagnosticLocation { file: loc.file().into(), line: loc.line(), col: loc.column() } + } +} + +impl fmt::Display for DiagnosticLocation { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}:{}:{}", self.file, self.line, self.col) + } } #[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)] @@ -173,10 +199,12 @@ impl StringPart { } impl Diagnostic { + #[track_caller] pub fn new>(level: Level, message: M) -> Self { Diagnostic::new_with_code(level, None, message) } + #[track_caller] pub fn new_with_code>( level: Level, code: Option, @@ -192,6 +220,7 @@ impl Diagnostic { args: Default::default(), sort_span: DUMMY_SP, is_lint: false, + emitted_at: DiagnosticLocation::caller(), } } diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index 9b41234dcfb..ecf8570e81f 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -133,6 +133,7 @@ mod sealed_level_is_error { impl<'a> DiagnosticBuilder<'a, ErrorGuaranteed> { /// Convenience function for internal use, clients should use one of the /// `struct_*` methods on [`Handler`]. + #[track_caller] pub(crate) fn new_guaranteeing_error, const L: Level>( handler: &'a Handler, message: M, @@ -196,6 +197,7 @@ impl EmissionGuarantee for ErrorGuaranteed { } } + #[track_caller] fn make_diagnostic_builder( handler: &Handler, msg: impl Into, @@ -209,6 +211,7 @@ impl EmissionGuarantee for ErrorGuaranteed { impl<'a> DiagnosticBuilder<'a, ()> { /// Convenience function for internal use, clients should use one of the /// `struct_*` methods on [`Handler`]. + #[track_caller] pub(crate) fn new>( handler: &'a Handler, level: Level, @@ -220,6 +223,7 @@ impl<'a> DiagnosticBuilder<'a, ()> { /// Creates a new `DiagnosticBuilder` with an already constructed /// diagnostic. + #[track_caller] pub(crate) fn new_diagnostic(handler: &'a Handler, diagnostic: Diagnostic) -> Self { debug!("Created new diagnostic"); Self { @@ -308,6 +312,7 @@ impl EmissionGuarantee for Noted { impl<'a> DiagnosticBuilder<'a, !> { /// Convenience function for internal use, clients should use one of the /// `struct_*` methods on [`Handler`]. + #[track_caller] pub(crate) fn new_fatal(handler: &'a Handler, message: impl Into) -> Self { let diagnostic = Diagnostic::new_with_code(Level::Fatal, None, message); Self::new_diagnostic_fatal(handler, diagnostic) diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index cd6413bc3ec..b9b9a59e354 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -16,10 +16,10 @@ use crate::snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, Styl use crate::styled_buffer::StyledBuffer; use crate::translation::{to_fluent_args, Translate}; use crate::{ - CodeSuggestion, Diagnostic, DiagnosticId, DiagnosticMessage, FluentBundle, Handler, - LazyFallbackBundle, Level, MultiSpan, SubDiagnostic, SubstitutionHighlight, SuggestionStyle, + diagnostic::DiagnosticLocation, CodeSuggestion, Diagnostic, DiagnosticId, DiagnosticMessage, + FluentBundle, Handler, LazyFallbackBundle, Level, MultiSpan, SubDiagnostic, + SubstitutionHighlight, SuggestionStyle, }; - use rustc_lint_defs::pluralize; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; @@ -64,6 +64,7 @@ impl HumanReadableErrorType { teach: bool, diagnostic_width: Option, macro_backtrace: bool, + track_diagnostics: bool, ) -> EmitterWriter { let (short, color_config) = self.unzip(); let color = color_config.suggests_using_colors(); @@ -77,6 +78,7 @@ impl HumanReadableErrorType { color, diagnostic_width, macro_backtrace, + track_diagnostics, ) } } @@ -557,6 +559,7 @@ impl Emitter for EmitterWriter { &primary_span, &children, &suggestions, + Some(&diag.emitted_at), ); } @@ -650,6 +653,7 @@ pub struct EmitterWriter { diagnostic_width: Option, macro_backtrace: bool, + track_diagnostics: bool, } #[derive(Debug)] @@ -669,6 +673,7 @@ impl EmitterWriter { teach: bool, diagnostic_width: Option, macro_backtrace: bool, + track_diagnostics: bool, ) -> EmitterWriter { let dst = Destination::from_stderr(color_config); EmitterWriter { @@ -681,6 +686,7 @@ impl EmitterWriter { ui_testing: false, diagnostic_width, macro_backtrace, + track_diagnostics, } } @@ -694,6 +700,7 @@ impl EmitterWriter { colored: bool, diagnostic_width: Option, macro_backtrace: bool, + track_diagnostics: bool, ) -> EmitterWriter { EmitterWriter { dst: Raw(dst, colored), @@ -705,6 +712,7 @@ impl EmitterWriter { ui_testing: false, diagnostic_width, macro_backtrace, + track_diagnostics, } } @@ -1327,6 +1335,7 @@ impl EmitterWriter { level: &Level, max_line_num_len: usize, is_secondary: bool, + emitted_at: Option<&DiagnosticLocation>, ) -> io::Result<()> { let mut buffer = StyledBuffer::new(); @@ -1377,7 +1386,6 @@ impl EmitterWriter { } } } - let mut annotated_files = FileWithAnnotatedLines::collect_annotations(self, args, msp); // Make sure our primary file comes first @@ -1653,6 +1661,12 @@ impl EmitterWriter { } } + if self.track_diagnostics && let Some(tracked) = emitted_at { + let track = format!("-Ztrack-diagnostics: created at {tracked}"); + let len = buffer.num_lines(); + buffer.append(len, &track, Style::NoStyle); + } + // final step: take our styled buffer, render it, then output it emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?; @@ -1977,6 +1991,7 @@ impl EmitterWriter { span: &MultiSpan, children: &[SubDiagnostic], suggestions: &[CodeSuggestion], + emitted_at: Option<&DiagnosticLocation>, ) { let max_line_num_len = if self.ui_testing { ANONYMIZED_LINE_NUM.len() @@ -1985,7 +2000,16 @@ impl EmitterWriter { num_decimal_digits(n) }; - match self.emit_message_default(span, message, args, code, level, max_line_num_len, false) { + match self.emit_message_default( + span, + message, + args, + code, + level, + max_line_num_len, + false, + emitted_at, + ) { Ok(()) => { if !children.is_empty() || suggestions.iter().any(|s| s.style != SuggestionStyle::CompletelyHidden) @@ -2014,6 +2038,7 @@ impl EmitterWriter { &child.level, max_line_num_len, true, + None, ) { panic!("failed to emit error: {}", err); } @@ -2030,6 +2055,7 @@ impl EmitterWriter { &Level::Help, max_line_num_len, true, + None, ) { panic!("failed to emit error: {}", e); } diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 4cc7be47fc2..c4498eafa4e 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -45,6 +45,7 @@ pub struct JsonEmitter { json_rendered: HumanReadableErrorType, diagnostic_width: Option, macro_backtrace: bool, + track_diagnostics: bool, } impl JsonEmitter { @@ -57,6 +58,7 @@ impl JsonEmitter { json_rendered: HumanReadableErrorType, diagnostic_width: Option, macro_backtrace: bool, + track_diagnostics: bool, ) -> JsonEmitter { JsonEmitter { dst: Box::new(io::BufWriter::new(io::stderr())), @@ -69,6 +71,7 @@ impl JsonEmitter { json_rendered, diagnostic_width, macro_backtrace, + track_diagnostics, } } @@ -79,6 +82,7 @@ impl JsonEmitter { fallback_bundle: LazyFallbackBundle, diagnostic_width: Option, macro_backtrace: bool, + track_diagnostics: bool, ) -> JsonEmitter { let file_path_mapping = FilePathMapping::empty(); JsonEmitter::stderr( @@ -90,6 +94,7 @@ impl JsonEmitter { json_rendered, diagnostic_width, macro_backtrace, + track_diagnostics, ) } @@ -103,6 +108,7 @@ impl JsonEmitter { json_rendered: HumanReadableErrorType, diagnostic_width: Option, macro_backtrace: bool, + track_diagnostics: bool, ) -> JsonEmitter { JsonEmitter { dst, @@ -115,6 +121,7 @@ impl JsonEmitter { json_rendered, diagnostic_width, macro_backtrace, + track_diagnostics, } } @@ -350,6 +357,7 @@ impl Diagnostic { false, je.diagnostic_width, je.macro_backtrace, + je.track_diagnostics, ) .ui_testing(je.ui_testing) .emit_diagnostic(diag); diff --git a/compiler/rustc_errors/src/json/tests.rs b/compiler/rustc_errors/src/json/tests.rs index d940d14e1db..f131468971b 100644 --- a/compiler/rustc_errors/src/json/tests.rs +++ b/compiler/rustc_errors/src/json/tests.rs @@ -59,6 +59,7 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) { HumanReadableErrorType::Short(ColorConfig::Never), None, false, + false, ); let span = Span::with_root_ctxt(BytePos(span.0), BytePos(span.1)); diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 9fafbe4bd40..e3bb50c3d22 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -489,6 +489,8 @@ pub struct HandlerFlags { pub macro_backtrace: bool, /// If true, identical diagnostics are reported only once. pub deduplicate_diagnostics: bool, + /// Track where errors are created. Enabled with `-Ztrack-diagnostics`. + pub track_diagnostics: bool, } impl Drop for HandlerInner { @@ -556,6 +558,7 @@ impl Handler { false, None, flags.macro_backtrace, + flags.track_diagnostics, )); Self::with_emitter_and_flags(emitter, flags) } @@ -661,6 +664,7 @@ impl Handler { /// Construct a builder with the `msg` at the level appropriate for the specific `EmissionGuarantee`. #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_diagnostic( &self, msg: impl Into, @@ -674,6 +678,7 @@ impl Handler { /// * `can_emit_warnings` is `true` /// * `is_force_warn` was set in `DiagnosticId::Lint` #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_warn( &self, span: impl Into, @@ -690,6 +695,7 @@ impl Handler { /// Attempting to `.emit()` the builder will only emit if either: /// * `can_emit_warnings` is `true` /// * `is_force_warn` was set in `DiagnosticId::Lint` + #[track_caller] pub fn struct_span_warn_with_expectation( &self, span: impl Into, @@ -703,6 +709,7 @@ impl Handler { /// Construct a builder at the `Allow` level at the given `span` and with the `msg`. #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_allow( &self, span: impl Into, @@ -716,6 +723,7 @@ impl Handler { /// Construct a builder at the `Warning` level at the given `span` and with the `msg`. /// Also include a code. #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_warn_with_code( &self, span: impl Into, @@ -733,6 +741,7 @@ impl Handler { /// * `can_emit_warnings` is `true` /// * `is_force_warn` was set in `DiagnosticId::Lint` #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_warn(&self, msg: impl Into) -> DiagnosticBuilder<'_, ()> { DiagnosticBuilder::new(self, Level::Warning(None), msg) } @@ -743,6 +752,7 @@ impl Handler { /// Attempting to `.emit()` the builder will only emit if either: /// * `can_emit_warnings` is `true` /// * `is_force_warn` was set in `DiagnosticId::Lint` + #[track_caller] pub fn struct_warn_with_expectation( &self, msg: impl Into, @@ -759,6 +769,7 @@ impl Handler { /// Construct a builder at the `Expect` level with the `msg`. #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_expect( &self, msg: impl Into, @@ -769,6 +780,7 @@ impl Handler { /// Construct a builder at the `Error` level at the given `span` and with the `msg`. #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_err( &self, span: impl Into, @@ -781,6 +793,7 @@ impl Handler { /// Construct a builder at the `Error` level at the given `span`, with the `msg`, and `code`. #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_err_with_code( &self, span: impl Into, @@ -795,6 +808,7 @@ impl Handler { /// Construct a builder at the `Error` level with the `msg`. // FIXME: This method should be removed (every error should have an associated error code). #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_err( &self, msg: impl Into, @@ -804,12 +818,14 @@ impl Handler { /// This should only be used by `rustc_middle::lint::struct_lint_level`. Do not use it for hard errors. #[doc(hidden)] + #[track_caller] pub fn struct_err_lint(&self, msg: impl Into) -> DiagnosticBuilder<'_, ()> { DiagnosticBuilder::new(self, Level::Error { lint: true }, msg) } /// Construct a builder at the `Error` level with the `msg` and the `code`. #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_err_with_code( &self, msg: impl Into, @@ -822,6 +838,7 @@ impl Handler { /// Construct a builder at the `Warn` level with the `msg` and the `code`. #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_warn_with_code( &self, msg: impl Into, @@ -834,6 +851,7 @@ impl Handler { /// Construct a builder at the `Fatal` level at the given `span` and with the `msg`. #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_fatal( &self, span: impl Into, @@ -871,6 +889,7 @@ impl Handler { /// Construct a builder at the `Note` level with the `msg`. #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_note_without_error( &self, msg: impl Into, @@ -885,6 +904,7 @@ impl Handler { } #[rustc_lint_diagnostics] + #[track_caller] pub fn span_fatal_with_code( &self, span: impl Into, @@ -896,6 +916,7 @@ impl Handler { } #[rustc_lint_diagnostics] + #[track_caller] pub fn span_err( &self, span: impl Into, @@ -905,6 +926,7 @@ impl Handler { } #[rustc_lint_diagnostics] + #[track_caller] pub fn span_err_with_code( &self, span: impl Into, @@ -918,11 +940,13 @@ impl Handler { } #[rustc_lint_diagnostics] + #[track_caller] pub fn span_warn(&self, span: impl Into, msg: impl Into) { self.emit_diag_at_span(Diagnostic::new(Warning(None), msg), span); } #[rustc_lint_diagnostics] + #[track_caller] pub fn span_warn_with_code( &self, span: impl Into, @@ -932,6 +956,7 @@ impl Handler { self.emit_diag_at_span(Diagnostic::new_with_code(Warning(None), Some(code), msg), span); } + #[track_caller] pub fn span_bug(&self, span: impl Into, msg: impl Into) -> ! { self.inner.borrow_mut().span_bug(span, msg) } @@ -947,14 +972,17 @@ impl Handler { // FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`, that's // where the explanation of what "good path" is (also, it should be renamed). + #[track_caller] pub fn delay_good_path_bug(&self, msg: impl Into) { self.inner.borrow_mut().delay_good_path_bug(msg) } + #[track_caller] pub fn span_bug_no_panic(&self, span: impl Into, msg: impl Into) { self.emit_diag_at_span(Diagnostic::new(Bug, msg), span); } + #[track_caller] pub fn span_note_without_error( &self, span: impl Into, @@ -963,6 +991,7 @@ impl Handler { self.emit_diag_at_span(Diagnostic::new(Note, msg), span); } + #[track_caller] pub fn span_note_diag( &self, span: Span, @@ -1449,6 +1478,7 @@ impl HandlerInner { } } + #[track_caller] fn span_bug(&mut self, sp: impl Into, msg: impl Into) -> ! { self.emit_diag_at_span(Diagnostic::new(Bug, msg), sp); panic::panic_any(ExplicitBug); diff --git a/compiler/rustc_expand/src/tests.rs b/compiler/rustc_expand/src/tests.rs index e44f0608196..d82a7a54030 100644 --- a/compiler/rustc_expand/src/tests.rs +++ b/compiler/rustc_expand/src/tests.rs @@ -151,6 +151,7 @@ fn test_harness(file_text: &str, span_labels: Vec, expected_output: & false, None, false, + false, ); let handler = Handler::with_emitter(true, None, Box::new(emitter)); handler.span_err(msp, "foo"); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index f2ee52262ad..856ff3d4150 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -794,6 +794,7 @@ impl UnstableOptions { report_delayed_bugs: self.report_delayed_bugs, macro_backtrace: self.macro_backtrace, deduplicate_diagnostics: self.deduplicate_diagnostics, + track_diagnostics: self.track_diagnostics, } } } diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index a8be318dea8..af290931850 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1585,6 +1585,8 @@ options! { "choose the TLS model to use (`rustc --print tls-models` for details)"), trace_macros: bool = (false, parse_bool, [UNTRACKED], "for every macro invocation, print its name and arguments (default: no)"), + track_diagnostics: bool = (false, parse_bool, [TRACKED], + "Tracks where in rustc a diagnostic was emitted"), // Diagnostics are considered side-effects of a query (see `QuerySideEffects`) and are saved // alongside query results and changes to translation options can affect diagnostics - so // translation options should be tracked. diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index b5e25f45fa7..0c04a2f2449 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -287,6 +287,7 @@ impl Session { } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_warn>( &self, sp: S, @@ -295,6 +296,7 @@ impl Session { self.diagnostic().struct_span_warn(sp, msg) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_warn_with_expectation>( &self, sp: S, @@ -304,6 +306,7 @@ impl Session { self.diagnostic().struct_span_warn_with_expectation(sp, msg, id) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_warn_with_code>( &self, sp: S, @@ -313,10 +316,12 @@ impl Session { self.diagnostic().struct_span_warn_with_code(sp, msg, code) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_warn(&self, msg: impl Into) -> DiagnosticBuilder<'_, ()> { self.diagnostic().struct_warn(msg) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_warn_with_expectation( &self, msg: impl Into, @@ -345,6 +350,7 @@ impl Session { self.diagnostic().struct_expect(msg, id) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_err>( &self, sp: S, @@ -353,6 +359,7 @@ impl Session { self.diagnostic().struct_span_err(sp, msg) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_err_with_code>( &self, sp: S, @@ -363,12 +370,14 @@ impl Session { } // FIXME: This method should be removed (every error should have an associated error code). #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_err( &self, msg: impl Into, ) -> DiagnosticBuilder<'_, ErrorGuaranteed> { self.parse_sess.struct_err(msg) } + #[track_caller] #[rustc_lint_diagnostics] pub fn struct_err_with_code( &self, @@ -378,6 +387,7 @@ impl Session { self.diagnostic().struct_err_with_code(msg, code) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_warn_with_code( &self, msg: impl Into, @@ -425,6 +435,7 @@ impl Session { self.diagnostic().fatal(msg).raise() } #[rustc_lint_diagnostics] + #[track_caller] pub fn span_err_or_warn>( &self, is_warning: bool, @@ -438,6 +449,7 @@ impl Session { } } #[rustc_lint_diagnostics] + #[track_caller] pub fn span_err>( &self, sp: S, @@ -458,12 +470,14 @@ impl Session { pub fn err(&self, msg: impl Into) -> ErrorGuaranteed { self.diagnostic().err(msg) } + #[track_caller] pub fn create_err<'a>( &'a self, err: impl IntoDiagnostic<'a>, ) -> DiagnosticBuilder<'a, ErrorGuaranteed> { self.parse_sess.create_err(err) } + #[track_caller] pub fn create_feature_err<'a>( &'a self, err: impl IntoDiagnostic<'a>, @@ -1214,6 +1228,7 @@ fn default_emitter( fallback_bundle: LazyFallbackBundle, ) -> Box { let macro_backtrace = sopts.unstable_opts.macro_backtrace; + let track_diagnostics = sopts.unstable_opts.track_diagnostics; match sopts.error_format { config::ErrorOutputType::HumanReadable(kind) => { let (short, color_config) = kind.unzip(); @@ -1237,6 +1252,7 @@ fn default_emitter( sopts.unstable_opts.teach, sopts.diagnostic_width, macro_backtrace, + track_diagnostics, ); Box::new(emitter.ui_testing(sopts.unstable_opts.ui_testing)) } @@ -1251,6 +1267,7 @@ fn default_emitter( json_rendered, sopts.diagnostic_width, macro_backtrace, + track_diagnostics, ) .ui_testing(sopts.unstable_opts.ui_testing), ), @@ -1553,11 +1570,18 @@ fn early_error_handler(output: config::ErrorOutputType) -> rustc_errors::Handler false, None, false, + false, )) } - config::ErrorOutputType::Json { pretty, json_rendered } => { - Box::new(JsonEmitter::basic(pretty, json_rendered, None, fallback_bundle, None, false)) - } + config::ErrorOutputType::Json { pretty, json_rendered } => Box::new(JsonEmitter::basic( + pretty, + json_rendered, + None, + fallback_bundle, + None, + false, + false, + )), }; rustc_errors::Handler::with_emitter(true, None, emitter) } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 858e939bd96..2a61c2451b6 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -172,6 +172,7 @@ pub(crate) fn new_handler( unstable_opts.teach, diagnostic_width, false, + false, ) .ui_testing(unstable_opts.ui_testing), ) @@ -190,6 +191,7 @@ pub(crate) fn new_handler( json_rendered, diagnostic_width, false, + false, ) .ui_testing(unstable_opts.ui_testing), ) diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index ac8b5211878..7bd7fc5ea75 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -551,6 +551,7 @@ pub(crate) fn make_test( false, Some(80), false, + false, ) .supports_color(); @@ -564,6 +565,7 @@ pub(crate) fn make_test( false, None, false, + false, ); // FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser @@ -748,6 +750,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool { false, None, false, + false, ); let handler = Handler::with_emitter(false, None, Box::new(emitter)); diff --git a/src/test/ui/track-diagnostics/track.rs b/src/test/ui/track-diagnostics/track.rs new file mode 100644 index 00000000000..3427c593e85 --- /dev/null +++ b/src/test/ui/track-diagnostics/track.rs @@ -0,0 +1,6 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + +fn main() { + break rust +} diff --git a/src/test/ui/track-diagnostics/track.stderr b/src/test/ui/track-diagnostics/track.stderr new file mode 100644 index 00000000000..83ff935dbab --- /dev/null +++ b/src/test/ui/track-diagnostics/track.stderr @@ -0,0 +1,26 @@ +error[E0425]: cannot find value `rust` in this scope + --> $DIR/track.rs:5:11 + | +LL | break rust + | ^^^^ not found in this scope +-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:289:28 + +error[E0268]: `break` outside of a loop + --> $DIR/track.rs:5:5 + | +LL | break rust + | ^^^^^^^^^^ cannot `break` outside of a loop +-Ztrack-diagnostics: created at compiler/rustc_passes/src/errors.rs:957:10 + +error: internal compiler error: It looks like you're trying to break rust; would you like some ICE? + +note: the compiler expectedly panicked. this is a feature. + +note: we would appreciate a joke overview: https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675 + +note: rustc 1.66.0-dev running on x86_64-pc-windows-msvc + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0268, E0425. +For more information about an error, try `rustc --explain E0268`. diff --git a/src/tools/clippy/clippy_lints/src/doc.rs b/src/tools/clippy/clippy_lints/src/doc.rs index 36dc7e3396b..9e2facf0f63 100644 --- a/src/tools/clippy/clippy_lints/src/doc.rs +++ b/src/tools/clippy/clippy_lints/src/doc.rs @@ -691,6 +691,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) { false, None, false, + false, ); let handler = Handler::with_emitter(false, None, Box::new(emitter)); let sess = ParseSess::with_span_handler(handler, sm); diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index b12208ac62a..ae54b2078a6 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -179,6 +179,7 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { false, None, false, + false, )); let handler = rustc_errors::Handler::with_emitter(true, None, emitter); diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs index 6efeee98fea..6bfec79cd70 100644 --- a/src/tools/rustfmt/src/parse/session.rs +++ b/src/tools/rustfmt/src/parse/session.rs @@ -134,6 +134,7 @@ fn default_handler( false, None, false, + false, )) }; Handler::with_emitter( From 4a92cf61568b6be22a38d2c14bec41a271bbb571 Mon Sep 17 00:00:00 2001 From: inquisitivecrystal <22333129+inquisitivecrystal@users.noreply.github.com> Date: Sat, 15 Oct 2022 02:50:17 -0700 Subject: [PATCH 007/219] Derive `Eq` and `Hash` for `ControlFlow` --- library/core/src/ops/control_flow.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/core/src/ops/control_flow.rs b/library/core/src/ops/control_flow.rs index 72ebe653caf..cd183540cd5 100644 --- a/library/core/src/ops/control_flow.rs +++ b/library/core/src/ops/control_flow.rs @@ -79,7 +79,9 @@ use crate::{convert, ops}; /// [`Break`]: ControlFlow::Break /// [`Continue`]: ControlFlow::Continue #[stable(feature = "control_flow_enum_type", since = "1.55.0")] -#[derive(Debug, Clone, Copy, PartialEq)] +// ControlFlow should not implement PartialOrd or Ord, per RFC 3058: +// https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#traits-for-controlflow +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ControlFlow { /// Move on to the next phase of the operation as normal. #[stable(feature = "control_flow_enum_type", since = "1.55.0")] From 288194ec8801be9c2c2d047d71a5e7ea4d46b883 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 19 Oct 2022 16:24:42 -0700 Subject: [PATCH 008/219] Update tinystr --- Cargo.lock | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5acab8139c..a450fc3d5b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1153,6 +1153,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "displaydoc" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "dlmalloc" version = "0.2.3" @@ -1833,11 +1844,10 @@ dependencies = [ [[package]] name = "intl_pluralrules" -version = "7.0.1" +version = "7.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b18f988384267d7066cc2be425e6faf352900652c046b6971d2e228d3b1c5ecf" +checksum = "078ea7b7c29a2b4df841a7f6ac8775ff6074020c6776d48491ce2268e068f972" dependencies = [ - "tinystr", "unic-langid", ] @@ -4912,9 +4922,12 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.3.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29738eedb4388d9ea620eeab9384884fc3f06f586a2eddb56bedc5885126c7c1" +checksum = "f8aeafdfd935e4a7fe16a91ab711fa52d54df84f9c8f7ca5837a9d1d902ef4c2" +dependencies = [ + "displaydoc", +] [[package]] name = "tinyvec" @@ -5140,9 +5153,9 @@ dependencies = [ [[package]] name = "unic-langid" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73328fcd730a030bdb19ddf23e192187a6b01cd98be6d3140622a89129459ce5" +checksum = "398f9ad7239db44fd0f80fe068d12ff22d78354080332a5077dc6f52f14dcf2f" dependencies = [ "unic-langid-impl", "unic-langid-macros", @@ -5150,18 +5163,18 @@ dependencies = [ [[package]] name = "unic-langid-impl" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a4a8eeaf0494862c1404c95ec2f4c33a2acff5076f64314b465e3ddae1b934d" +checksum = "e35bfd2f2b8796545b55d7d3fd3e89a0613f68a0d1c8bc28cb7ff96b411a35ff" dependencies = [ "tinystr", ] [[package]] name = "unic-langid-macros" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18f980d6d87e8805f2836d64b4138cc95aa7986fa63b1f51f67d5fbff64dd6e5" +checksum = "055e618bf694161ffff0466d95cef3e1a5edc59f6ba1888e97801f2b4ebdc4fe" dependencies = [ "proc-macro-hack", "tinystr", @@ -5171,9 +5184,9 @@ dependencies = [ [[package]] name = "unic-langid-macros-impl" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29396ffd97e27574c3e01368b1a64267d3064969e4848e2e130ff668be9daa9f" +checksum = "1f5cdec05b907f4e2f6843f4354f4ce6a5bebe1a56df320a49134944477ce4d8" dependencies = [ "proc-macro-hack", "quote", From e4f56b9d16a408c5046f3c3531c7fdd0569759d1 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 19 Oct 2022 16:43:02 -0700 Subject: [PATCH 009/219] Update license --- src/tools/tidy/src/deps.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index b9e0d48c9bc..f8afb44e75b 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -23,6 +23,7 @@ const LICENSES: &[&str] = &[ "MIT OR Apache-2.0 OR Zlib", // tinyvec_macros "MIT OR Zlib OR Apache-2.0", // miniz_oxide "(MIT OR Apache-2.0) AND Unicode-DFS-2016", // unicode_ident + "Unicode-DFS-2016", // tinystr and icu4x ]; /// These are exceptions to Rust's permissive licensing policy, and From 2aff1e67b516c6c4b336b9588f34fc80fc3b136e Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 19 Oct 2022 16:43:48 -0700 Subject: [PATCH 010/219] allowlist displaydoc --- src/tools/tidy/src/deps.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index f8afb44e75b..a046e0acdde 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -110,6 +110,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "datafrog", "difference", "digest", + "displaydoc", "dlmalloc", "either", "ena", From aad709b7ac2e35d364875c7ec151fb24df1ff46e Mon Sep 17 00:00:00 2001 From: Tatsuyuki Ishi Date: Thu, 20 Oct 2022 18:09:24 +0900 Subject: [PATCH 011/219] ci: Bring back ninja for dist builders The primary reason for this is that make can result in a substantial under utilization of parallelism, mostly due to the submake structure preventing good dependency tracking and scheduling. In f758c7b2a78 (Debian 6 doesn't have ninja, so use make for the dist builds) llvm.ninja was disabled due to lack of distro package. This is no longer the case with the CentOS 7 base, so bring ninja back for a performance boost. --- src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile | 2 +- src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile index cd86d9fb584..bff3f8f2192 100644 --- a/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile @@ -23,6 +23,7 @@ RUN yum upgrade -y && \ libstdc++-devel.x86_64 \ make \ ncurses-devel \ + ninja-build \ openssl-devel \ patch \ perl \ @@ -64,7 +65,6 @@ ENV RUST_CONFIGURE_ARGS \ --enable-profiler \ --set target.i686-unknown-linux-gnu.linker=clang \ --build=i686-unknown-linux-gnu \ - --set llvm.ninja=false \ --set rust.jemalloc ENV SCRIPT python3 ../x.py dist --build $HOSTS --host $HOSTS --target $HOSTS ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=clang diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile index b960239807a..84877320eca 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile @@ -23,6 +23,7 @@ RUN yum upgrade -y && \ libstdc++-devel.x86_64 \ make \ ncurses-devel \ + ninja-build \ openssl-devel \ patch \ perl \ @@ -76,7 +77,6 @@ ENV RUST_CONFIGURE_ARGS \ --set target.x86_64-unknown-linux-gnu.ar=/rustroot/bin/llvm-ar \ --set target.x86_64-unknown-linux-gnu.ranlib=/rustroot/bin/llvm-ranlib \ --set llvm.thin-lto=true \ - --set llvm.ninja=false \ --set rust.jemalloc \ --set rust.use-lld=true ENV SCRIPT ../src/ci/pgo.sh python3 ../x.py dist \ From 354e95ac62333102465426a772852bf62443192d Mon Sep 17 00:00:00 2001 From: Tatsuyuki Ishi Date: Thu, 20 Oct 2022 18:09:52 +0900 Subject: [PATCH 012/219] ci: Use ninja in build-clang.sh Now that we have brought ninja back to the installed base packages, we can use it for the initial Clang build as well. --- src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh index 9abfd4e9731..15ab3e5bd6e 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh @@ -25,6 +25,7 @@ INC="/rustroot/include:/usr/include" # disable them. BOLT is used for optimizing LLVM. hide_output \ cmake ../llvm \ + -GNinja \ -DCMAKE_C_COMPILER=/rustroot/bin/gcc \ -DCMAKE_CXX_COMPILER=/rustroot/bin/g++ \ -DCMAKE_BUILD_TYPE=Release \ @@ -39,8 +40,8 @@ hide_output \ -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt;bolt" \ -DC_INCLUDE_DIRS="$INC" -hide_output make -j$(nproc) -hide_output make install +hide_output ninja +hide_output ninja install cd ../.. rm -rf llvm-project From 783301298f1e151b82c1be21bc6a214b9ef525bd Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 20 Oct 2022 12:28:31 +0200 Subject: [PATCH 013/219] Don't use usub.with.overflow intrinsic The canonical form of a usub.with.overflow check in LLVM are separate sub + icmp instructions, rather than a usub.with.overflow intrinsic. Using usub.with.overflow will generally result in worse optimization potential. The backend will attempt to form usub.with.overflow when it comes to actual instruction selection. This is not fully reliable, but I believe this is a better tradeoff than using the intrinsic in IR. Fixes #103285. --- compiler/rustc_codegen_llvm/src/builder.rs | 13 ++++++++----- .../issue-103285-ptr-addr-overflow-check.rs | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 src/test/codegen/issue-103285-ptr-addr-overflow-check.rs diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index fca43a0d86d..9cb36ce7f18 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -365,11 +365,14 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { Int(I64) => "llvm.ssub.with.overflow.i64", Int(I128) => "llvm.ssub.with.overflow.i128", - Uint(U8) => "llvm.usub.with.overflow.i8", - Uint(U16) => "llvm.usub.with.overflow.i16", - Uint(U32) => "llvm.usub.with.overflow.i32", - Uint(U64) => "llvm.usub.with.overflow.i64", - Uint(U128) => "llvm.usub.with.overflow.i128", + Uint(_) => { + // Emit sub and icmp instead of llvm.usub.with.overflow. LLVM considers these + // to be the canonical form. It will attempt to reform llvm.usub.with.overflow + // in the backend if profitable. + let sub = self.sub(lhs, rhs); + let cmp = self.icmp(IntPredicate::IntULT, lhs, rhs); + return (sub, cmp); + } _ => unreachable!(), }, diff --git a/src/test/codegen/issue-103285-ptr-addr-overflow-check.rs b/src/test/codegen/issue-103285-ptr-addr-overflow-check.rs new file mode 100644 index 00000000000..a3499babea2 --- /dev/null +++ b/src/test/codegen/issue-103285-ptr-addr-overflow-check.rs @@ -0,0 +1,16 @@ +// compile-flags: -O -C debug-assertions=yes + +#![crate_type = "lib"] +#![feature(strict_provenance)] + +#[no_mangle] +pub fn test(src: *const u8, dst: *const u8) -> usize { + // CHECK-LABEL: @test( + // CHECK-NOT: panic + let src_usize = src.addr(); + let dst_usize = dst.addr(); + if src_usize > dst_usize { + return src_usize - dst_usize; + } + return 0; +} From 6a065f78c43c8ee8f0a9a0607eb33f8e23ed69f9 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Fri, 21 Oct 2022 12:50:28 +0300 Subject: [PATCH 014/219] Fix unreachable_pub suggestion for enum with fields --- compiler/rustc_lint/src/builtin.rs | 8 ++++++-- src/test/ui/lint/issue-103317.rs | 13 +++++++++++++ src/test/ui/lint/issue-103317.stderr | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/lint/issue-103317.rs create mode 100644 src/test/ui/lint/issue-103317.stderr diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 886e25f2d78..dfd66452189 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -40,7 +40,7 @@ use rustc_feature::{deprecated_attributes, AttributeGate, BuiltinAttribute, Gate use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, LocalDefId, LocalDefIdSet, CRATE_DEF_ID}; -use rustc_hir::{ForeignItemKind, GenericParamKind, HirId, PatKind, PredicateOrigin}; +use rustc_hir::{ForeignItemKind, GenericParamKind, HirId, Node, PatKind, PredicateOrigin}; use rustc_index::vec::Idx; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::layout::{LayoutError, LayoutOf}; @@ -1430,7 +1430,11 @@ impl<'tcx> LateLintPass<'tcx> for UnreachablePub { } fn check_field_def(&mut self, cx: &LateContext<'_>, field: &hir::FieldDef<'_>) { - let def_id = cx.tcx.hir().local_def_id(field.hir_id); + let map = cx.tcx.hir(); + let def_id = map.local_def_id(field.hir_id); + if matches!(map.get(map.get_parent_node(field.hir_id)), Node::Variant(_)) { + return; + } self.perform_lint(cx, "field", def_id, field.vis_span, false); } diff --git a/src/test/ui/lint/issue-103317.rs b/src/test/ui/lint/issue-103317.rs new file mode 100644 index 00000000000..b39b441a0cf --- /dev/null +++ b/src/test/ui/lint/issue-103317.rs @@ -0,0 +1,13 @@ +// check-pass + +#[warn(unreachable_pub)] +#[allow(unused)] +mod inner { + pub enum T { + //~^ WARN unreachable `pub` item + A(u8), + X { a: f32, b: () }, + } +} + +fn main() {} diff --git a/src/test/ui/lint/issue-103317.stderr b/src/test/ui/lint/issue-103317.stderr new file mode 100644 index 00000000000..9fdd6a570e6 --- /dev/null +++ b/src/test/ui/lint/issue-103317.stderr @@ -0,0 +1,17 @@ +warning: unreachable `pub` item + --> $DIR/issue-103317.rs:6:5 + | +LL | pub enum T { + | ---^^^^^^^ + | | + | help: consider restricting its visibility: `pub(crate)` + | + = help: or consider exporting it for use by other crates +note: the lint level is defined here + --> $DIR/issue-103317.rs:3:8 + | +LL | #[warn(unreachable_pub)] + | ^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + From 79eedef984cb0a4e703e6c2398319d4e818f41e9 Mon Sep 17 00:00:00 2001 From: BlackHoleFox Date: Sun, 23 Oct 2022 15:23:04 -0500 Subject: [PATCH 015/219] Fix x86_64-apple-ios target to use the correct target_abi --- compiler/rustc_target/src/spec/apple/tests.rs | 15 ++++++++++++++ .../rustc_target/src/spec/apple_sdk_base.rs | 20 +++++++++++++------ .../rustc_target/src/spec/x86_64_apple_ios.rs | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 compiler/rustc_target/src/spec/apple/tests.rs diff --git a/compiler/rustc_target/src/spec/apple/tests.rs b/compiler/rustc_target/src/spec/apple/tests.rs new file mode 100644 index 00000000000..23bfb95c198 --- /dev/null +++ b/compiler/rustc_target/src/spec/apple/tests.rs @@ -0,0 +1,15 @@ +use crate::spec::{aarch64_apple_ios_sim, aarch64_apple_watchos_sim, x86_64_apple_ios}; + +#[test] +fn simulator_targets_set_abi() { + let all_sim_targets = [ + x86_64_apple_ios::target(), + aarch64_apple_ios_sim::target(), + aarch64_apple_watchos_sim::target(), + // TODO: x86_64-apple-tvos and x86_64-apple-watchos-sim + ]; + + for target in all_sim_targets { + assert_eq!(target.abi, "sim") + } +} diff --git a/compiler/rustc_target/src/spec/apple_sdk_base.rs b/compiler/rustc_target/src/spec/apple_sdk_base.rs index 49e302676a7..f920ce8444f 100644 --- a/compiler/rustc_target/src/spec/apple_sdk_base.rs +++ b/compiler/rustc_target/src/spec/apple_sdk_base.rs @@ -1,6 +1,10 @@ use crate::spec::{cvs, TargetOptions}; use std::borrow::Cow; +#[cfg(test)] +#[path = "apple/tests.rs"] +mod tests; + use Arch::*; #[allow(non_camel_case_types)] #[derive(Copy, Clone)] @@ -12,6 +16,7 @@ pub enum Arch { Arm64_32, I386, X86_64, + X86_64_sim, X86_64_macabi, Arm64_macabi, Arm64_sim, @@ -25,7 +30,7 @@ fn target_arch_name(arch: Arch) -> &'static str { Arm64 | Arm64_macabi | Arm64_sim => "arm64", Arm64_32 => "arm64_32", I386 => "i386", - X86_64 | X86_64_macabi => "x86_64", + X86_64 | X86_64_sim | X86_64_macabi => "x86_64", } } @@ -33,7 +38,9 @@ fn target_abi(arch: Arch) -> &'static str { match arch { Armv7 | Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | X86_64 => "", X86_64_macabi | Arm64_macabi => "macabi", - Arm64_sim => "sim", + // x86_64-apple-ios is a simulator target, even though it isn't + // declared that way in the target like the other ones... + Arm64_sim | X86_64_sim => "sim", } } @@ -45,7 +52,7 @@ fn target_cpu(arch: Arch) -> &'static str { Arm64 => "apple-a7", Arm64_32 => "apple-s4", I386 => "yonah", - X86_64 => "core2", + X86_64 | X86_64_sim => "core2", X86_64_macabi => "core2", Arm64_macabi => "apple-a12", Arm64_sim => "apple-a12", @@ -54,7 +61,7 @@ fn target_cpu(arch: Arch) -> &'static str { fn link_env_remove(arch: Arch) -> Cow<'static, [Cow<'static, str>]> { match arch { - Armv7 | Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | X86_64 | Arm64_sim => { + Armv7 | Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | X86_64 | X86_64_sim | Arm64_sim => { cvs!["MACOSX_DEPLOYMENT_TARGET"] } X86_64_macabi | Arm64_macabi => cvs!["IPHONEOS_DEPLOYMENT_TARGET"], @@ -62,11 +69,12 @@ fn link_env_remove(arch: Arch) -> Cow<'static, [Cow<'static, str>]> { } pub fn opts(os: &'static str, arch: Arch) -> TargetOptions { + let abi = target_abi(arch); TargetOptions { - abi: target_abi(arch).into(), + abi: abi.into(), cpu: target_cpu(arch).into(), link_env_remove: link_env_remove(arch), has_thread_local: false, - ..super::apple_base::opts(os, target_arch_name(arch), target_abi(arch)) + ..super::apple_base::opts(os, target_arch_name(arch), abi) } } diff --git a/compiler/rustc_target/src/spec/x86_64_apple_ios.rs b/compiler/rustc_target/src/spec/x86_64_apple_ios.rs index e6143025d6d..db23f01c233 100644 --- a/compiler/rustc_target/src/spec/x86_64_apple_ios.rs +++ b/compiler/rustc_target/src/spec/x86_64_apple_ios.rs @@ -2,7 +2,7 @@ use super::apple_sdk_base::{opts, Arch}; use crate::spec::{StackProbeType, Target, TargetOptions}; pub fn target() -> Target { - let base = opts("ios", Arch::X86_64); + let base = opts("ios", Arch::X86_64_sim); let llvm_target = super::apple_base::ios_sim_llvm_target("x86_64"); Target { From d2a37847809bc3df86afb4c65b5fe5f06d99ce20 Mon Sep 17 00:00:00 2001 From: BlackHoleFox Date: Sun, 23 Oct 2022 15:33:01 -0500 Subject: [PATCH 016/219] Fix x86_64-apple-tvos target to use the correct target_abi --- compiler/rustc_target/src/spec/apple/tests.rs | 8 ++++++-- compiler/rustc_target/src/spec/x86_64_apple_tvos.rs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_target/src/spec/apple/tests.rs b/compiler/rustc_target/src/spec/apple/tests.rs index 23bfb95c198..b45e6e309c1 100644 --- a/compiler/rustc_target/src/spec/apple/tests.rs +++ b/compiler/rustc_target/src/spec/apple/tests.rs @@ -1,12 +1,16 @@ -use crate::spec::{aarch64_apple_ios_sim, aarch64_apple_watchos_sim, x86_64_apple_ios}; +use crate::spec::{ + aarch64_apple_ios_sim, aarch64_apple_watchos_sim, x86_64_apple_ios, x86_64_apple_tvos, +}; #[test] fn simulator_targets_set_abi() { let all_sim_targets = [ x86_64_apple_ios::target(), + x86_64_apple_tvos::target(), aarch64_apple_ios_sim::target(), + // Note: There is currently no ARM64 tvOS simulator target aarch64_apple_watchos_sim::target(), - // TODO: x86_64-apple-tvos and x86_64-apple-watchos-sim + // TODO: x86_64-apple-watchos-sim ]; for target in all_sim_targets { diff --git a/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs b/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs index 3d54da0867c..c1fd8e1c8b9 100644 --- a/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs +++ b/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs @@ -2,7 +2,7 @@ use super::apple_sdk_base::{opts, Arch}; use crate::spec::{StackProbeType, Target, TargetOptions}; pub fn target() -> Target { - let base = opts("tvos", Arch::X86_64); + let base = opts("tvos", Arch::X86_64_sim); Target { llvm_target: "x86_64-apple-tvos".into(), pointer_width: 64, From ffccfa1eedd049c87b1ad828297ae4c4121b2e40 Mon Sep 17 00:00:00 2001 From: BlackHoleFox Date: Sun, 23 Oct 2022 15:41:07 -0500 Subject: [PATCH 017/219] Fix x86_64-apple-watchos-sim target to use the correct target_abi --- compiler/rustc_target/src/spec/apple/tests.rs | 3 ++- compiler/rustc_target/src/spec/apple_sdk_base.rs | 1 + compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_target/src/spec/apple/tests.rs b/compiler/rustc_target/src/spec/apple/tests.rs index b45e6e309c1..d062b36742d 100644 --- a/compiler/rustc_target/src/spec/apple/tests.rs +++ b/compiler/rustc_target/src/spec/apple/tests.rs @@ -1,5 +1,6 @@ use crate::spec::{ aarch64_apple_ios_sim, aarch64_apple_watchos_sim, x86_64_apple_ios, x86_64_apple_tvos, + x86_64_apple_watchos_sim, }; #[test] @@ -7,10 +8,10 @@ fn simulator_targets_set_abi() { let all_sim_targets = [ x86_64_apple_ios::target(), x86_64_apple_tvos::target(), + x86_64_apple_watchos_sim::target(), aarch64_apple_ios_sim::target(), // Note: There is currently no ARM64 tvOS simulator target aarch64_apple_watchos_sim::target(), - // TODO: x86_64-apple-watchos-sim ]; for target in all_sim_targets { diff --git a/compiler/rustc_target/src/spec/apple_sdk_base.rs b/compiler/rustc_target/src/spec/apple_sdk_base.rs index f920ce8444f..148031b1569 100644 --- a/compiler/rustc_target/src/spec/apple_sdk_base.rs +++ b/compiler/rustc_target/src/spec/apple_sdk_base.rs @@ -15,6 +15,7 @@ pub enum Arch { Arm64, Arm64_32, I386, + #[allow(dead_code)] // Some targets don't use this enum... X86_64, X86_64_sim, X86_64_macabi, diff --git a/compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs b/compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs index e499b1985e7..550566b2aa7 100644 --- a/compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs +++ b/compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs @@ -2,7 +2,7 @@ use super::apple_sdk_base::{opts, Arch}; use crate::spec::{StackProbeType, Target, TargetOptions}; pub fn target() -> Target { - let base = opts("watchos", Arch::X86_64); + let base = opts("watchos", Arch::X86_64_sim); let arch = "x86_64"; let llvm_target = super::apple_base::watchos_sim_llvm_target(arch); From ba847cad6d1403feed2bba8b501c69d0a749f6de Mon Sep 17 00:00:00 2001 From: Soveu Date: Mon, 8 Aug 2022 15:31:32 +0200 Subject: [PATCH 018/219] Enable varargs support for calling conventions other than C or cdecl This patch makes it possible to use varargs for calling conventions, which are either based on C (like efiapi) or C is based on them (for example sysv64 and win64). --- compiler/rustc_feature/src/active.rs | 3 ++ compiler/rustc_hir_analysis/src/lib.rs | 48 ++++++++++++------ compiler/rustc_span/src/symbol.rs | 1 + compiler/rustc_target/src/spec/abi.rs | 22 +++++++++ .../extended-varargs-abi-support.md | 10 ++++ ...ature-gate-extended_varargs_abi_support.rs | 19 +++++++ ...e-gate-extended_varargs_abi_support.stderr | 49 +++++++++++++++++++ src/test/ui/c-variadic/variadic-ffi-1.rs | 4 +- src/test/ui/c-variadic/variadic-ffi-1.stderr | 28 +++++------ src/test/ui/c-variadic/variadic-ffi-2.rs | 15 +++++- src/test/ui/c-variadic/variadic-ffi-2.stderr | 6 +-- src/test/ui/error-codes/E0045.stderr | 4 +- 12 files changed, 174 insertions(+), 35 deletions(-) create mode 100644 src/doc/unstable-book/src/language-features/extended-varargs-abi-support.md create mode 100644 src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs create mode 100644 src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 1b8d683b133..0f6561b04c0 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -390,6 +390,9 @@ declare_features! ( (active, exclusive_range_pattern, "1.11.0", Some(37854), None), /// Allows exhaustive pattern matching on types that contain uninhabited types. (active, exhaustive_patterns, "1.13.0", Some(51085), None), + /// Allows using `efiapi`, `sysv64` and `win64` as calling convention + /// for functions with varargs. + (active, extended_varargs_abi_support, "1.65.0", Some(100189), None), /// Allows defining `extern type`s. (active, extern_types, "1.23.0", Some(43467), None), /// Allows the use of `#[ffi_const]` on foreign functions. diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index dba505149de..782c95d6335 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -106,7 +106,7 @@ use rustc_middle::middle; use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::util; -use rustc_session::config::EntryFnType; +use rustc_session::{config::EntryFnType, parse::feature_err}; use rustc_span::{symbol::sym, Span, DUMMY_SP}; use rustc_target::spec::abi::Abi; use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt as _; @@ -118,20 +118,40 @@ use astconv::AstConv; use bounds::Bounds; fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) { - match (decl.c_variadic, abi) { - // The function has the correct calling convention, or isn't a "C-variadic" function. - (false, _) | (true, Abi::C { .. }) | (true, Abi::Cdecl { .. }) => {} - // The function is a "C-variadic" function with an incorrect calling convention. - (true, _) => { - let mut err = struct_span_err!( - tcx.sess, - span, - E0045, - "C-variadic function must have C or cdecl calling convention" - ); - err.span_label(span, "C-variadics require C or cdecl calling convention").emit(); - } + const ERROR_HEAD: &str = "C-variadic function must have a compatible calling convention"; + const CONVENTIONS_UNSTABLE: &str = "C, cdecl, win64, sysv64 or efiapi"; + const CONVENTIONS_STABLE: &str = "C or cdecl"; + const UNSTABLE_EXPLAIN: &str = + "using different calling convention than C or cdecl for varargs functions is unstable"; + + if !decl.c_variadic || matches!(abi, Abi::C { .. } | Abi::Cdecl { .. }) { + return; } + + let extended_abi_support = tcx.features().extended_varargs_abi_support; + let conventions = match (extended_abi_support, abi.supports_varargs()) { + // User enabled additional ABI support for varargs and function ABI matches those ones. + (true, true) => return, + + // Using this ABI would be ok, if the feature for additional ABI support was enabled. + // Return CONVENTIONS_STABLE, because we want the other error to look the same. + (false, true) => { + feature_err( + &tcx.sess.parse_sess, + sym::extended_varargs_abi_support, + span, + UNSTABLE_EXPLAIN, + ) + .emit(); + CONVENTIONS_STABLE + } + + (false, false) => CONVENTIONS_STABLE, + (true, false) => CONVENTIONS_UNSTABLE, + }; + + let mut err = struct_span_err!(tcx.sess, span, E0045, "{}, like {}", ERROR_HEAD, conventions); + err.span_label(span, ERROR_HEAD).emit(); } fn require_same_types<'tcx>( diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 3fe79370c37..4a1b20297d9 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -694,6 +694,7 @@ symbols! { export_name, expr, extended_key_value_attributes, + extended_varargs_abi_support, extern_absolute_paths, extern_crate_item_prelude, extern_crate_self, diff --git a/compiler/rustc_target/src/spec/abi.rs b/compiler/rustc_target/src/spec/abi.rs index ce45fa13970..cb2a0c04c6a 100644 --- a/compiler/rustc_target/src/spec/abi.rs +++ b/compiler/rustc_target/src/spec/abi.rs @@ -40,6 +40,28 @@ pub enum Abi { RustCold, } +impl Abi { + pub fn supports_varargs(self) -> bool { + // * C and Cdecl obviously support varargs. + // * C can be based on SysV64 or Win64, so they must support varargs. + // * EfiApi is based on Win64 or C, so it also supports it. + // + // * Stdcall does not, because it would be impossible for the callee to clean + // up the arguments. (callee doesn't know how many arguments are there) + // * Same for Fastcall, Vectorcall and Thiscall. + // * System can become Stdcall, so is also a no-no. + // * Other calling conventions are related to hardware or the compiler itself. + match self { + Self::C { .. } + | Self::Cdecl { .. } + | Self::Win64 { .. } + | Self::SysV64 { .. } + | Self::EfiApi => true, + _ => false, + } + } +} + #[derive(Copy, Clone)] pub struct AbiData { abi: Abi, diff --git a/src/doc/unstable-book/src/language-features/extended-varargs-abi-support.md b/src/doc/unstable-book/src/language-features/extended-varargs-abi-support.md new file mode 100644 index 00000000000..b20c30ec8f1 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/extended-varargs-abi-support.md @@ -0,0 +1,10 @@ +# `extended_varargs_abi_support` + +The tracking issue for this feature is: [#100189] + +[#100189]: https://github.com/rust-lang/rust/issues/100189 + +------------------------ + +This feature adds the possibility of using `sysv64`, `win64` or `efiapi` calling +conventions on functions with varargs. diff --git a/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs b/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs new file mode 100644 index 00000000000..e391ee8a0b1 --- /dev/null +++ b/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs @@ -0,0 +1,19 @@ +#![feature(abi_efiapi)] + +fn efiapi(f: extern "efiapi" fn(usize, ...)) { + //~^ ERROR: C-variadic function must have a compatible calling convention, like C or cdecl + //~^^ ERROR: using different calling convention than C or cdecl for varargs functions is unstable + f(22, 44); +} +fn sysv(f: extern "sysv64" fn(usize, ...)) { + //~^ ERROR: C-variadic function must have a compatible calling convention, like C or cdecl + //~^^ ERROR: using different calling convention than C or cdecl for varargs functions is unstable + f(22, 44); +} +fn win(f: extern "win64" fn(usize, ...)) { + //~^ ERROR: C-variadic function must have a compatible calling convention, like C or cdecl + //~^^ ERROR: using different calling convention than C or cdecl for varargs functions is unstable + f(22, 44); +} + +fn main() {} diff --git a/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr b/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr new file mode 100644 index 00000000000..3442d53c1b5 --- /dev/null +++ b/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr @@ -0,0 +1,49 @@ +error[E0658]: using different calling convention than C or cdecl for varargs functions is unstable + --> $DIR/feature-gate-extended_varargs_abi_support.rs:3:14 + | +LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #100189 for more information + = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable + +error[E0045]: C-variadic function must have a compatible calling convention, like C or cdecl + --> $DIR/feature-gate-extended_varargs_abi_support.rs:3:14 + | +LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention + +error[E0658]: using different calling convention than C or cdecl for varargs functions is unstable + --> $DIR/feature-gate-extended_varargs_abi_support.rs:8:12 + | +LL | fn sysv(f: extern "sysv64" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #100189 for more information + = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable + +error[E0045]: C-variadic function must have a compatible calling convention, like C or cdecl + --> $DIR/feature-gate-extended_varargs_abi_support.rs:8:12 + | +LL | fn sysv(f: extern "sysv64" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention + +error[E0658]: using different calling convention than C or cdecl for varargs functions is unstable + --> $DIR/feature-gate-extended_varargs_abi_support.rs:13:11 + | +LL | fn win(f: extern "win64" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #100189 for more information + = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable + +error[E0045]: C-variadic function must have a compatible calling convention, like C or cdecl + --> $DIR/feature-gate-extended_varargs_abi_support.rs:13:11 + | +LL | fn win(f: extern "win64" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0045, E0658. +For more information about an error, try `rustc --explain E0045`. diff --git a/src/test/ui/c-variadic/variadic-ffi-1.rs b/src/test/ui/c-variadic/variadic-ffi-1.rs index a76efd9a205..24407a71ce6 100644 --- a/src/test/ui/c-variadic/variadic-ffi-1.rs +++ b/src/test/ui/c-variadic/variadic-ffi-1.rs @@ -6,7 +6,9 @@ trait Sized { } extern "stdcall" { - fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C or cdecl calling + fn printf(_: *const u8, ...); + //~^ ERROR: C-variadic function must have a compatible calling convention, + // like C, cdecl, win64, sysv64 or efiapi } extern "C" { diff --git a/src/test/ui/c-variadic/variadic-ffi-1.stderr b/src/test/ui/c-variadic/variadic-ffi-1.stderr index 2ffb80f7ef6..f9d6928b3df 100644 --- a/src/test/ui/c-variadic/variadic-ffi-1.stderr +++ b/src/test/ui/c-variadic/variadic-ffi-1.stderr @@ -1,17 +1,17 @@ -error[E0045]: C-variadic function must have C or cdecl calling convention +error[E0045]: C-variadic function must have a compatible calling convention, like C or cdecl --> $DIR/variadic-ffi-1.rs:9:5 | LL | fn printf(_: *const u8, ...); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error[E0060]: this function takes at least 2 arguments but 0 arguments were supplied - --> $DIR/variadic-ffi-1.rs:20:9 + --> $DIR/variadic-ffi-1.rs:22:9 | LL | foo(); | ^^^-- two arguments of type `isize` and `u8` are missing | note: function defined here - --> $DIR/variadic-ffi-1.rs:13:8 + --> $DIR/variadic-ffi-1.rs:15:8 | LL | fn foo(f: isize, x: u8, ...); | ^^^ @@ -21,13 +21,13 @@ LL | foo(/* isize */, /* u8 */); | ~~~~~~~~~~~~~~~~~~~~~~~ error[E0060]: this function takes at least 2 arguments but 1 argument was supplied - --> $DIR/variadic-ffi-1.rs:21:9 + --> $DIR/variadic-ffi-1.rs:23:9 | LL | foo(1); | ^^^--- an argument of type `u8` is missing | note: function defined here - --> $DIR/variadic-ffi-1.rs:13:8 + --> $DIR/variadic-ffi-1.rs:15:8 | LL | fn foo(f: isize, x: u8, ...); | ^^^ @@ -37,7 +37,7 @@ LL | foo(1, /* u8 */); | ~~~~~~~~~~~~~ error[E0308]: mismatched types - --> $DIR/variadic-ffi-1.rs:23:56 + --> $DIR/variadic-ffi-1.rs:25:56 | LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo; | ------------------------------------- ^^^ expected non-variadic fn, found variadic function @@ -48,7 +48,7 @@ LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo; found fn item `unsafe extern "C" fn(_, _, ...) {foo}` error[E0308]: mismatched types - --> $DIR/variadic-ffi-1.rs:24:54 + --> $DIR/variadic-ffi-1.rs:26:54 | LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar; | ----------------------------------- ^^^ expected variadic fn, found non-variadic function @@ -59,37 +59,37 @@ LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar; found fn item `extern "C" fn(_, _) {bar}` error[E0617]: can't pass `f32` to variadic function - --> $DIR/variadic-ffi-1.rs:26:19 + --> $DIR/variadic-ffi-1.rs:28:19 | LL | foo(1, 2, 3f32); | ^^^^ help: cast the value to `c_double`: `3f32 as c_double` error[E0617]: can't pass `bool` to variadic function - --> $DIR/variadic-ffi-1.rs:27:19 + --> $DIR/variadic-ffi-1.rs:29:19 | LL | foo(1, 2, true); | ^^^^ help: cast the value to `c_int`: `true as c_int` error[E0617]: can't pass `i8` to variadic function - --> $DIR/variadic-ffi-1.rs:28:19 + --> $DIR/variadic-ffi-1.rs:30:19 | LL | foo(1, 2, 1i8); | ^^^ help: cast the value to `c_int`: `1i8 as c_int` error[E0617]: can't pass `u8` to variadic function - --> $DIR/variadic-ffi-1.rs:29:19 + --> $DIR/variadic-ffi-1.rs:31:19 | LL | foo(1, 2, 1u8); | ^^^ help: cast the value to `c_uint`: `1u8 as c_uint` error[E0617]: can't pass `i16` to variadic function - --> $DIR/variadic-ffi-1.rs:30:19 + --> $DIR/variadic-ffi-1.rs:32:19 | LL | foo(1, 2, 1i16); | ^^^^ help: cast the value to `c_int`: `1i16 as c_int` error[E0617]: can't pass `u16` to variadic function - --> $DIR/variadic-ffi-1.rs:31:19 + --> $DIR/variadic-ffi-1.rs:33:19 | LL | foo(1, 2, 1u16); | ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint` diff --git a/src/test/ui/c-variadic/variadic-ffi-2.rs b/src/test/ui/c-variadic/variadic-ffi-2.rs index 224ac16f458..96cea87546e 100644 --- a/src/test/ui/c-variadic/variadic-ffi-2.rs +++ b/src/test/ui/c-variadic/variadic-ffi-2.rs @@ -1,7 +1,20 @@ // ignore-arm stdcall isn't supported +#![feature(extended_varargs_abi_support)] +#![feature(abi_efiapi)] fn baz(f: extern "stdcall" fn(usize, ...)) { - //~^ ERROR: variadic function must have C or cdecl calling convention + //~^ ERROR: C-variadic function must have a compatible calling convention, + // like C, cdecl, win64, sysv64 or efiapi + f(22, 44); +} + +fn sysv(f: extern "sysv64" fn(usize, ...)) { + f(22, 44); +} +fn win(f: extern "win64" fn(usize, ...)) { + f(22, 44); +} +fn efiapi(f: extern "efiapi" fn(usize, ...)) { f(22, 44); } diff --git a/src/test/ui/c-variadic/variadic-ffi-2.stderr b/src/test/ui/c-variadic/variadic-ffi-2.stderr index 4c8b8d2b2e1..117d75301fb 100644 --- a/src/test/ui/c-variadic/variadic-ffi-2.stderr +++ b/src/test/ui/c-variadic/variadic-ffi-2.stderr @@ -1,8 +1,8 @@ -error[E0045]: C-variadic function must have C or cdecl calling convention - --> $DIR/variadic-ffi-2.rs:3:11 +error[E0045]: C-variadic function must have a compatible calling convention, like C, cdecl, win64, sysv64 or efiapi + --> $DIR/variadic-ffi-2.rs:5:11 | LL | fn baz(f: extern "stdcall" fn(usize, ...)) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0045.stderr b/src/test/ui/error-codes/E0045.stderr index d163128bc8b..ecb916d02df 100644 --- a/src/test/ui/error-codes/E0045.stderr +++ b/src/test/ui/error-codes/E0045.stderr @@ -1,8 +1,8 @@ -error[E0045]: C-variadic function must have C or cdecl calling convention +error[E0045]: C-variadic function must have a compatible calling convention, like C or cdecl --> $DIR/E0045.rs:1:17 | LL | extern "Rust" { fn foo(x: u8, ...); } - | ^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention + | ^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error: aborting due to previous error From 65ef62597b82778a1cb7b295932663671a0156c8 Mon Sep 17 00:00:00 2001 From: Jack Huey <31162821+jackh726@users.noreply.github.com> Date: Tue, 16 Aug 2022 14:29:19 -0400 Subject: [PATCH 019/219] Apply suggestions from code review Use ticks around abis. Co-authored-by: Esteban Kuber --- compiler/rustc_hir_analysis/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 782c95d6335..46d57563a4f 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -119,10 +119,10 @@ use bounds::Bounds; fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) { const ERROR_HEAD: &str = "C-variadic function must have a compatible calling convention"; - const CONVENTIONS_UNSTABLE: &str = "C, cdecl, win64, sysv64 or efiapi"; - const CONVENTIONS_STABLE: &str = "C or cdecl"; + const CONVENTIONS_UNSTABLE: &str = "`C`, `cdecl`, `win64`, `sysv64` or `efiapi`"; + const CONVENTIONS_STABLE: &str = "`C` or `cdecl`"; const UNSTABLE_EXPLAIN: &str = - "using different calling convention than C or cdecl for varargs functions is unstable"; + "using different calling convention than `C` or `cdecl` for varargs functions is unstable"; if !decl.c_variadic || matches!(abi, Abi::C { .. } | Abi::Cdecl { .. }) { return; From de78c32b854d6f76167bb6fcf76fc2760c8b7d2a Mon Sep 17 00:00:00 2001 From: Jack Huey <31162821+jackh726@users.noreply.github.com> Date: Sun, 23 Oct 2022 19:11:25 -0400 Subject: [PATCH 020/219] Cleanup message and bless tests --- compiler/rustc_hir_analysis/src/lib.rs | 2 +- .../feature-gate-extended_varargs_abi_support.rs | 12 ++++++------ .../feature-gate-extended_varargs_abi_support.stderr | 12 ++++++------ src/test/ui/c-variadic/variadic-ffi-1.stderr | 2 +- src/test/ui/c-variadic/variadic-ffi-2.stderr | 2 +- src/test/ui/error-codes/E0045.stderr | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 46d57563a4f..3f51005a5f0 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -122,7 +122,7 @@ fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi const CONVENTIONS_UNSTABLE: &str = "`C`, `cdecl`, `win64`, `sysv64` or `efiapi`"; const CONVENTIONS_STABLE: &str = "`C` or `cdecl`"; const UNSTABLE_EXPLAIN: &str = - "using different calling convention than `C` or `cdecl` for varargs functions is unstable"; + "using calling conventions other than `C` or `cdecl` for varargs functions is unstable"; if !decl.c_variadic || matches!(abi, Abi::C { .. } | Abi::Cdecl { .. }) { return; diff --git a/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs b/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs index e391ee8a0b1..087743e505d 100644 --- a/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs +++ b/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs @@ -1,18 +1,18 @@ #![feature(abi_efiapi)] fn efiapi(f: extern "efiapi" fn(usize, ...)) { - //~^ ERROR: C-variadic function must have a compatible calling convention, like C or cdecl - //~^^ ERROR: using different calling convention than C or cdecl for varargs functions is unstable + //~^ ERROR: C-variadic function must have a compatible calling convention, like `C` or `cdecl` + //~^^ ERROR: using calling conventions other than `C` or `cdecl` for varargs functions is unstable f(22, 44); } fn sysv(f: extern "sysv64" fn(usize, ...)) { - //~^ ERROR: C-variadic function must have a compatible calling convention, like C or cdecl - //~^^ ERROR: using different calling convention than C or cdecl for varargs functions is unstable + //~^ ERROR: C-variadic function must have a compatible calling convention, like `C` or `cdecl` + //~^^ ERROR: using calling conventions other than `C` or `cdecl` for varargs functions is unstable f(22, 44); } fn win(f: extern "win64" fn(usize, ...)) { - //~^ ERROR: C-variadic function must have a compatible calling convention, like C or cdecl - //~^^ ERROR: using different calling convention than C or cdecl for varargs functions is unstable + //~^ ERROR: C-variadic function must have a compatible calling convention, like `C` or `cdecl` + //~^^ ERROR: using calling conventions other than `C` or `cdecl` for varargs functions is unstable f(22, 44); } diff --git a/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr b/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr index 3442d53c1b5..007d7d7953c 100644 --- a/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr +++ b/src/test/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr @@ -1,4 +1,4 @@ -error[E0658]: using different calling convention than C or cdecl for varargs functions is unstable +error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable --> $DIR/feature-gate-extended_varargs_abi_support.rs:3:14 | LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) { @@ -7,13 +7,13 @@ LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) { = note: see issue #100189 for more information = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable -error[E0045]: C-variadic function must have a compatible calling convention, like C or cdecl +error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl` --> $DIR/feature-gate-extended_varargs_abi_support.rs:3:14 | LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention -error[E0658]: using different calling convention than C or cdecl for varargs functions is unstable +error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable --> $DIR/feature-gate-extended_varargs_abi_support.rs:8:12 | LL | fn sysv(f: extern "sysv64" fn(usize, ...)) { @@ -22,13 +22,13 @@ LL | fn sysv(f: extern "sysv64" fn(usize, ...)) { = note: see issue #100189 for more information = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable -error[E0045]: C-variadic function must have a compatible calling convention, like C or cdecl +error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl` --> $DIR/feature-gate-extended_varargs_abi_support.rs:8:12 | LL | fn sysv(f: extern "sysv64" fn(usize, ...)) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention -error[E0658]: using different calling convention than C or cdecl for varargs functions is unstable +error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable --> $DIR/feature-gate-extended_varargs_abi_support.rs:13:11 | LL | fn win(f: extern "win64" fn(usize, ...)) { @@ -37,7 +37,7 @@ LL | fn win(f: extern "win64" fn(usize, ...)) { = note: see issue #100189 for more information = help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable -error[E0045]: C-variadic function must have a compatible calling convention, like C or cdecl +error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl` --> $DIR/feature-gate-extended_varargs_abi_support.rs:13:11 | LL | fn win(f: extern "win64" fn(usize, ...)) { diff --git a/src/test/ui/c-variadic/variadic-ffi-1.stderr b/src/test/ui/c-variadic/variadic-ffi-1.stderr index f9d6928b3df..4beea83d8a5 100644 --- a/src/test/ui/c-variadic/variadic-ffi-1.stderr +++ b/src/test/ui/c-variadic/variadic-ffi-1.stderr @@ -1,4 +1,4 @@ -error[E0045]: C-variadic function must have a compatible calling convention, like C or cdecl +error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl` --> $DIR/variadic-ffi-1.rs:9:5 | LL | fn printf(_: *const u8, ...); diff --git a/src/test/ui/c-variadic/variadic-ffi-2.stderr b/src/test/ui/c-variadic/variadic-ffi-2.stderr index 117d75301fb..4e74c9d9227 100644 --- a/src/test/ui/c-variadic/variadic-ffi-2.stderr +++ b/src/test/ui/c-variadic/variadic-ffi-2.stderr @@ -1,4 +1,4 @@ -error[E0045]: C-variadic function must have a compatible calling convention, like C, cdecl, win64, sysv64 or efiapi +error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `win64`, `sysv64` or `efiapi` --> $DIR/variadic-ffi-2.rs:5:11 | LL | fn baz(f: extern "stdcall" fn(usize, ...)) { diff --git a/src/test/ui/error-codes/E0045.stderr b/src/test/ui/error-codes/E0045.stderr index ecb916d02df..fcc613b11b8 100644 --- a/src/test/ui/error-codes/E0045.stderr +++ b/src/test/ui/error-codes/E0045.stderr @@ -1,4 +1,4 @@ -error[E0045]: C-variadic function must have a compatible calling convention, like C or cdecl +error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl` --> $DIR/E0045.rs:1:17 | LL | extern "Rust" { fn foo(x: u8, ...); } From 113e8dfb7293cc070214b42541781b2eeac25ae1 Mon Sep 17 00:00:00 2001 From: Charles Lew Date: Sat, 22 Oct 2022 18:48:20 +0800 Subject: [PATCH 021/219] Port `dead_code` lints to be translatable. --- .../locales/en-US/passes.ftl | 34 ++++ compiler/rustc_errors/src/diagnostic_impls.rs | 32 ++++ compiler/rustc_errors/src/lib.rs | 2 +- compiler/rustc_passes/src/dead.rs | 175 +++++++++--------- compiler/rustc_passes/src/errors.rs | 80 +++++++- ...lone-debug-dead-code-in-the-same-struct.rs | 2 +- ...-debug-dead-code-in-the-same-struct.stderr | 2 +- .../multiple-dead-codes-in-the-same-struct.rs | 2 +- ...tiple-dead-codes-in-the-same-struct.stderr | 2 +- .../ui/lint/dead-code/tuple-struct-field.rs | 2 +- .../lint/dead-code/tuple-struct-field.stderr | 2 +- 11 files changed, 236 insertions(+), 99 deletions(-) diff --git a/compiler/rustc_error_messages/locales/en-US/passes.ftl b/compiler/rustc_error_messages/locales/en-US/passes.ftl index 4bc6bd9fb22..a5b002fa357 100644 --- a/compiler/rustc_error_messages/locales/en-US/passes.ftl +++ b/compiler/rustc_error_messages/locales/en-US/passes.ftl @@ -671,3 +671,37 @@ passes_missing_const_err = attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` .help = make the function or method const .label = attribute specified here + +passes_dead_codes = + { $multiple -> + *[true] multiple {$descr}s are + [false] { $num -> + [one] {$descr} {$name_list} is + *[other] {$descr}s {$name_list} are + } + } never {$participle} + +passes_change_fields_to_be_of_unit_type = + consider changing the { $num -> + [one] field + *[other] fields + } to be of unit type to suppress this warning + while preserving the field numbering, or remove the { $num -> + [one] field + *[other] fields + } + +passes_parent_info = + {$num -> + [one] {$descr} + *[other] {$descr}s + } in this {$parent_descr} + +passes_ignored_derived_impls = + `{$name}` has {$trait_list_len -> + [one] a derived impl + *[other] derived impls + } for the {$trait_list_len -> + [one] trait {$trait_list}, but this is + *[other] traits {$trait_list}, but these are + } intentionally ignored during dead code analysis diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index 7640b2919f7..f6fe9192b45 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -11,6 +11,7 @@ use rustc_target::abi::TargetDataLayoutErrors; use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTriple}; use std::borrow::Cow; use std::fmt; +use std::fmt::Write; use std::num::ParseIntError; use std::path::{Path, PathBuf}; @@ -170,6 +171,37 @@ impl IntoDiagnosticArg for Level { } } +#[derive(Clone)] +pub struct DiagnosticSymbolList(Vec); + +impl From> for DiagnosticSymbolList { + fn from(v: Vec) -> Self { + DiagnosticSymbolList(v) + } +} + +impl IntoDiagnosticArg for DiagnosticSymbolList { + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { + // FIXME: replace the logic here with a real list formatter + let symbols = match &self.0[..] { + [symbol] => format!("`{symbol}`"), + [symbol, last] => { + format!("`{symbol}` and `{last}`",) + } + [symbols @ .., last] => { + let mut result = String::new(); + for symbol in symbols { + write!(result, "`{symbol}`, ").unwrap(); + } + write!(result, "and `{last}`").unwrap(); + result + } + [] => unreachable!(), + }; + DiagnosticArgValue::Str(Cow::Owned(symbols)) + } +} + impl IntoDiagnostic<'_, !> for TargetDataLayoutErrors<'_> { fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> { let mut diag; diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 0963ea71f80..2c8a70981bc 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -376,7 +376,7 @@ pub use diagnostic::{ DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic, }; pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee, Noted}; -pub use diagnostic_impls::DiagnosticArgFromDisplay; +pub use diagnostic_impls::{DiagnosticArgFromDisplay, DiagnosticSymbolList}; use std::backtrace::Backtrace; /// A handler deals with errors and other compiler output. diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 6a97ad3fe86..9157c8279a5 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -4,7 +4,7 @@ use itertools::Itertools; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_errors::{pluralize, Applicability, MultiSpan}; +use rustc_errors::MultiSpan; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::{DefId, LocalDefId}; @@ -18,7 +18,10 @@ use rustc_session::lint; use rustc_span::symbol::{sym, Symbol}; use std::mem; -use crate::errors::UselessAssignment; +use crate::errors::{ + ChangeFieldsToBeOfUnitType, IgnoredDerivedImpls, MultipleDeadCodes, ParentInfo, + UselessAssignment, +}; // Any local node that may call something in its body block should be // explored. For example, if it's a live Node::Item that is a @@ -698,99 +701,89 @@ impl<'tcx> DeadVisitor<'tcx> { parent_item: Option, is_positional: bool, ) { - if let Some(&first_id) = dead_codes.first() { - let tcx = self.tcx; - let names: Vec<_> = dead_codes - .iter() - .map(|&def_id| tcx.item_name(def_id.to_def_id()).to_string()) - .collect(); - let spans: Vec<_> = dead_codes - .iter() - .map(|&def_id| match tcx.def_ident_span(def_id) { - Some(s) => s.with_ctxt(tcx.def_span(def_id).ctxt()), - None => tcx.def_span(def_id), + let Some(&first_id) = dead_codes.first() else { + return; + }; + let tcx = self.tcx; + let names: Vec<_> = + dead_codes.iter().map(|&def_id| tcx.item_name(def_id.to_def_id())).collect(); + let spans: Vec<_> = dead_codes + .iter() + .map(|&def_id| match tcx.def_ident_span(def_id) { + Some(s) => s.with_ctxt(tcx.def_span(def_id).ctxt()), + None => tcx.def_span(def_id), + }) + .collect(); + + let descr = tcx.def_kind(first_id).descr(first_id.to_def_id()); + let num = dead_codes.len(); + let multiple = num > 6; + let name_list = names.into(); + + let lint = if is_positional { + lint::builtin::UNUSED_TUPLE_STRUCT_FIELDS + } else { + lint::builtin::DEAD_CODE + }; + + let parent_info = if let Some(parent_item) = parent_item { + let parent_descr = tcx.def_kind(parent_item).descr(parent_item.to_def_id()); + Some(ParentInfo { + num, + descr, + parent_descr, + span: tcx.def_ident_span(parent_item).unwrap(), + }) + } else { + None + }; + + let encl_def_id = parent_item.unwrap_or(first_id); + let ignored_derived_impls = + if let Some(ign_traits) = self.ignored_derived_traits.get(&encl_def_id) { + let trait_list = ign_traits + .iter() + .map(|(trait_id, _)| self.tcx.item_name(*trait_id)) + .collect::>(); + let trait_list_len = trait_list.len(); + Some(IgnoredDerivedImpls { + name: self.tcx.item_name(encl_def_id.to_def_id()), + trait_list: trait_list.into(), + trait_list_len, }) - .collect(); - - let descr = tcx.def_kind(first_id).descr(first_id.to_def_id()); - let span_len = dead_codes.len(); - let names = match &names[..] { - _ if span_len > 6 => String::new(), - [name] => format!("`{name}` "), - [names @ .., last] => { - format!( - "{} and `{last}` ", - names.iter().map(|name| format!("`{name}`")).join(", ") - ) - } - [] => unreachable!(), + } else { + None }; - let msg = format!( - "{these}{descr}{s} {names}{are} never {participle}", - these = if span_len > 6 { "multiple " } else { "" }, - s = pluralize!(span_len), - are = pluralize!("is", span_len), - ); - tcx.struct_span_lint_hir( - if is_positional { - lint::builtin::UNUSED_TUPLE_STRUCT_FIELDS - } else { - lint::builtin::DEAD_CODE - }, - tcx.hir().local_def_id_to_hir_id(first_id), - MultiSpan::from_spans(spans.clone()), - msg, - |err| { - if is_positional { - err.multipart_suggestion( - &format!( - "consider changing the field{s} to be of unit type to \ - suppress this warning while preserving the field \ - numbering, or remove the field{s}", - s = pluralize!(span_len) - ), - spans.iter().map(|sp| (*sp, "()".to_string())).collect(), - // "HasPlaceholders" because applying this fix by itself isn't - // enough: All constructor calls have to be adjusted as well - Applicability::HasPlaceholders, - ); - } + let diag = if is_positional { + MultipleDeadCodes::UnusedTupleStructFields { + multiple, + num, + descr, + participle, + name_list, + change_fields_suggestion: ChangeFieldsToBeOfUnitType { num, spans: spans.clone() }, + parent_info, + ignored_derived_impls, + } + } else { + MultipleDeadCodes::DeadCodes { + multiple, + num, + descr, + participle, + name_list, + parent_info, + ignored_derived_impls, + } + }; - if let Some(parent_item) = parent_item { - let parent_descr = tcx.def_kind(parent_item).descr(parent_item.to_def_id()); - err.span_label( - tcx.def_ident_span(parent_item).unwrap(), - format!("{descr}{s} in this {parent_descr}", s = pluralize!(span_len)), - ); - } - - let encl_def_id = parent_item.unwrap_or(first_id); - if let Some(ign_traits) = self.ignored_derived_traits.get(&encl_def_id) { - let traits_str = ign_traits - .iter() - .map(|(trait_id, _)| format!("`{}`", self.tcx.item_name(*trait_id))) - .collect::>() - .join(" and "); - let plural_s = pluralize!(ign_traits.len()); - let article = if ign_traits.len() > 1 { "" } else { "a " }; - let is_are = if ign_traits.len() > 1 { "these are" } else { "this is" }; - let msg = format!( - "`{}` has {}derived impl{} for the trait{} {}, but {} \ - intentionally ignored during dead code analysis", - self.tcx.item_name(encl_def_id.to_def_id()), - article, - plural_s, - plural_s, - traits_str, - is_are - ); - err.note(&msg); - } - err - }, - ); - } + self.tcx.emit_spanned_lint( + lint, + tcx.hir().local_def_id_to_hir_id(first_id), + MultiSpan::from_spans(spans.clone()), + diag, + ); } fn warn_dead_fields_and_variants( diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index adaaf539242..d39d7629b28 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -4,12 +4,16 @@ use std::{ }; use rustc_ast::Label; -use rustc_errors::{error_code, Applicability, ErrorGuaranteed, IntoDiagnostic, MultiSpan}; +use rustc_errors::{ + error_code, Applicability, DiagnosticSymbolList, ErrorGuaranteed, IntoDiagnostic, MultiSpan, +}; use rustc_hir::{self as hir, ExprKind, Target}; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_middle::ty::{MainDefinition, Ty}; use rustc_span::{Span, Symbol, DUMMY_SP}; +use rustc_errors::{pluralize, AddToDiagnostic, Diagnostic, SubdiagnosticMessage}; + use crate::lang_items::Duplicate; #[derive(LintDiagnostic)] @@ -1449,3 +1453,77 @@ pub struct MissingConstErr { #[label] pub const_span: Span, } + +#[derive(LintDiagnostic)] +pub enum MultipleDeadCodes<'tcx> { + #[diag(passes_dead_codes)] + DeadCodes { + multiple: bool, + num: usize, + descr: &'tcx str, + participle: &'tcx str, + name_list: DiagnosticSymbolList, + #[subdiagnostic] + parent_info: Option>, + #[subdiagnostic] + ignored_derived_impls: Option, + }, + #[diag(passes_dead_codes)] + UnusedTupleStructFields { + multiple: bool, + num: usize, + descr: &'tcx str, + participle: &'tcx str, + name_list: DiagnosticSymbolList, + #[subdiagnostic] + change_fields_suggestion: ChangeFieldsToBeOfUnitType, + #[subdiagnostic] + parent_info: Option>, + #[subdiagnostic] + ignored_derived_impls: Option, + }, +} + +#[derive(Subdiagnostic)] +#[label(passes_parent_info)] +pub struct ParentInfo<'tcx> { + pub num: usize, + pub descr: &'tcx str, + pub parent_descr: &'tcx str, + #[primary_span] + pub span: Span, +} + +#[derive(Subdiagnostic)] +#[note(passes_ignored_derived_impls)] +pub struct IgnoredDerivedImpls { + pub name: Symbol, + pub trait_list: DiagnosticSymbolList, + pub trait_list_len: usize, +} + +pub struct ChangeFieldsToBeOfUnitType { + pub num: usize, + pub spans: Vec, +} + +// FIXME: Replace this impl with a derive. +impl AddToDiagnostic for ChangeFieldsToBeOfUnitType { + fn add_to_diagnostic_with(self, diag: &mut Diagnostic, _: F) + where + F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage, + { + diag.multipart_suggestion( + &format!( + "consider changing the field{s} to be of unit type to \ + suppress this warning while preserving the field \ + numbering, or remove the field{s}", + s = pluralize!(self.num) + ), + self.spans.iter().map(|sp| (*sp, "()".to_string())).collect(), + // "HasPlaceholders" because applying this fix by itself isn't + // enough: All constructor calls have to be adjusted as well + Applicability::HasPlaceholders, + ); + } +} diff --git a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs index 15d06817577..6ab1fb7b039 100644 --- a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs +++ b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs @@ -3,7 +3,7 @@ #[derive(Debug)] pub struct Whatever { pub field0: (), - field1: (), //~ ERROR fields `field1`, `field2`, `field3` and `field4` are never read + field1: (), //~ ERROR fields `field1`, `field2`, `field3`, and `field4` are never read field2: (), field3: (), field4: (), diff --git a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr index 512b870fa4b..7f4f78cebc9 100644 --- a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr +++ b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr @@ -1,4 +1,4 @@ -error: fields `field1`, `field2`, `field3` and `field4` are never read +error: fields `field1`, `field2`, `field3`, and `field4` are never read --> $DIR/clone-debug-dead-code-in-the-same-struct.rs:6:5 | LL | pub struct Whatever { diff --git a/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs b/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs index e3935cf9149..2003e1e293a 100644 --- a/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs +++ b/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs @@ -7,7 +7,7 @@ struct Bar { b: usize, //~ ERROR field `b` is never read #[deny(dead_code)] c: usize, //~ ERROR fields `c` and `e` are never read - d: usize, //~ WARN fields `d`, `f` and `g` are never read + d: usize, //~ WARN fields `d`, `f`, and `g` are never read #[deny(dead_code)] e: usize, f: usize, diff --git a/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr b/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr index c0f1ed38f6d..0e5c78a7167 100644 --- a/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr +++ b/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr @@ -1,4 +1,4 @@ -warning: fields `d`, `f` and `g` are never read +warning: fields `d`, `f`, and `g` are never read --> $DIR/multiple-dead-codes-in-the-same-struct.rs:10:5 | LL | struct Bar { diff --git a/src/test/ui/lint/dead-code/tuple-struct-field.rs b/src/test/ui/lint/dead-code/tuple-struct-field.rs index b15d7063686..14fb30be949 100644 --- a/src/test/ui/lint/dead-code/tuple-struct-field.rs +++ b/src/test/ui/lint/dead-code/tuple-struct-field.rs @@ -11,7 +11,7 @@ struct SingleUnused(i32, [u8; LEN], String); //~| HELP: consider changing the field to be of unit type struct MultipleUnused(i32, f32, String, u8); -//~^ ERROR: fields `0`, `1`, `2` and `3` are never read +//~^ ERROR: fields `0`, `1`, `2`, and `3` are never read //~| NOTE: fields in this struct //~| HELP: consider changing the fields to be of unit type diff --git a/src/test/ui/lint/dead-code/tuple-struct-field.stderr b/src/test/ui/lint/dead-code/tuple-struct-field.stderr index ca0989f5b98..b8ad5cbe4e9 100644 --- a/src/test/ui/lint/dead-code/tuple-struct-field.stderr +++ b/src/test/ui/lint/dead-code/tuple-struct-field.stderr @@ -16,7 +16,7 @@ help: consider changing the field to be of unit type to suppress this warning wh LL | struct SingleUnused(i32, (), String); | ~~ -error: fields `0`, `1`, `2` and `3` are never read +error: fields `0`, `1`, `2`, and `3` are never read --> $DIR/tuple-struct-field.rs:13:23 | LL | struct MultipleUnused(i32, f32, String, u8); From 6afd0f57eb97306e677caa2e072f7537a2b314a3 Mon Sep 17 00:00:00 2001 From: Ryo Yoshida Date: Mon, 24 Oct 2022 19:38:16 +0900 Subject: [PATCH 022/219] Refactor: unwrap `Option` once in the beginning of closure --- crates/hir/src/source_analyzer.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index 07bae2b38c7..9ec52282829 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -487,9 +487,9 @@ impl SourceAnalyzer { let mut prefer_value_ns = false; let resolved = (|| { + let infer = self.infer.as_deref()?; if let Some(path_expr) = parent().and_then(ast::PathExpr::cast) { let expr_id = self.expr_id(db, &path_expr.into())?; - let infer = self.infer.as_ref()?; if let Some(assoc) = infer.assoc_resolutions_for_expr(expr_id) { let assoc = match assoc { AssocItemId::FunctionId(f_in_trait) => { @@ -520,18 +520,18 @@ impl SourceAnalyzer { prefer_value_ns = true; } else if let Some(path_pat) = parent().and_then(ast::PathPat::cast) { let pat_id = self.pat_id(&path_pat.into())?; - if let Some(assoc) = self.infer.as_ref()?.assoc_resolutions_for_pat(pat_id) { + if let Some(assoc) = infer.assoc_resolutions_for_pat(pat_id) { return Some(PathResolution::Def(AssocItem::from(assoc).into())); } if let Some(VariantId::EnumVariantId(variant)) = - self.infer.as_ref()?.variant_resolution_for_pat(pat_id) + infer.variant_resolution_for_pat(pat_id) { return Some(PathResolution::Def(ModuleDef::Variant(variant.into()))); } } else if let Some(rec_lit) = parent().and_then(ast::RecordExpr::cast) { let expr_id = self.expr_id(db, &rec_lit.into())?; if let Some(VariantId::EnumVariantId(variant)) = - self.infer.as_ref()?.variant_resolution_for_expr(expr_id) + infer.variant_resolution_for_expr(expr_id) { return Some(PathResolution::Def(ModuleDef::Variant(variant.into()))); } @@ -541,8 +541,7 @@ impl SourceAnalyzer { || parent().and_then(ast::TupleStructPat::cast).map(ast::Pat::from); if let Some(pat) = record_pat.or_else(tuple_struct_pat) { let pat_id = self.pat_id(&pat)?; - let variant_res_for_pat = - self.infer.as_ref()?.variant_resolution_for_pat(pat_id); + let variant_res_for_pat = infer.variant_resolution_for_pat(pat_id); if let Some(VariantId::EnumVariantId(variant)) = variant_res_for_pat { return Some(PathResolution::Def(ModuleDef::Variant(variant.into()))); } From 3f19fa496baa0cad3787f4d666c1eb13c9c0c7cc Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 24 Oct 2022 14:49:18 +0200 Subject: [PATCH 023/219] Update LLVM submodule --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 4b852557721..2a2ea6b49e7 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 4b85255772114ca4946d95fe591933dae7d61991 +Subproject commit 2a2ea6b49e79325e0d10d33fac2b10ea3bebcc7c From 6a00e14c7aba6851d921db2053d4b11dcc514528 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 24 Oct 2022 14:56:58 +0200 Subject: [PATCH 024/219] fix: Don't respond with an error when requesting a shutdown while starting --- crates/rust-analyzer/src/main_loop.rs | 48 +++++++++++++++------------ 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 2c928a58040..7d10dc5d15b 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -607,30 +607,34 @@ impl GlobalState { /// Handles a request. fn on_request(&mut self, req: Request) { - if self.shutdown_requested { - self.respond(lsp_server::Response::new_err( - req.id, - lsp_server::ErrorCode::InvalidRequest as i32, - "Shutdown already requested.".to_owned(), - )); - return; + let mut dispatcher = RequestDispatcher { req: Some(req), global_state: self }; + dispatcher.on_sync_mut::(|s, ()| { + s.shutdown_requested = true; + Ok(()) + }); + + if let RequestDispatcher { req: Some(req), global_state: this } = &mut dispatcher { + if this.shutdown_requested { + this.respond(lsp_server::Response::new_err( + req.id.clone(), + lsp_server::ErrorCode::InvalidRequest as i32, + "Shutdown already requested.".to_owned(), + )); + return; + } + + // Avoid flashing a bunch of unresolved references during initial load. + if this.workspaces.is_empty() && !this.is_quiescent() { + this.respond(lsp_server::Response::new_err( + req.id.clone(), + lsp_server::ErrorCode::ContentModified as i32, + "waiting for cargo metadata or cargo check".to_owned(), + )); + return; + } } - // Avoid flashing a bunch of unresolved references during initial load. - if self.workspaces.is_empty() && !self.is_quiescent() { - self.respond(lsp_server::Response::new_err( - req.id, - lsp_server::ErrorCode::ContentModified as i32, - "waiting for cargo metadata or cargo check".to_owned(), - )); - return; - } - - RequestDispatcher { req: Some(req), global_state: self } - .on_sync_mut::(|s, ()| { - s.shutdown_requested = true; - Ok(()) - }) + dispatcher .on_sync_mut::(handlers::handle_workspace_reload) .on_sync_mut::(handlers::handle_memory_usage) .on_sync_mut::(handlers::handle_shuffle_crate_graph) From fbae83acd0f7e6ddc7002774451e4e8df6b94286 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 24 Oct 2022 16:07:42 +0200 Subject: [PATCH 025/219] fix: Fix standard flycheck command not being executed in the workspace it is being invoked for --- crates/flycheck/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 73c3a48b4c5..8a91d606661 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -295,7 +295,9 @@ impl FlycheckActor { } => { let mut cmd = Command::new(toolchain::cargo()); cmd.arg(command); - cmd.args(&["--workspace", "--message-format=json"]); + cmd.current_dir(&self.root); + cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]) + .arg(self.root.join("Cargo.toml").as_os_str()); if let Some(target) = target_triple { cmd.args(&["--target", target.as_str()]); From 15d4383053307a983ea81197ec2a313bc9a471d9 Mon Sep 17 00:00:00 2001 From: Ryo Yoshida Date: Mon, 24 Oct 2022 23:28:53 +0900 Subject: [PATCH 026/219] Let `InferenceTable::unify()` relate `Zip` values --- crates/hir-ty/src/infer/unify.rs | 12 ++++++++---- crates/hir-ty/src/method_resolution.rs | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/hir-ty/src/infer/unify.rs b/crates/hir-ty/src/infer/unify.rs index b00e3216b2d..12f45f00f9c 100644 --- a/crates/hir-ty/src/infer/unify.rs +++ b/crates/hir-ty/src/infer/unify.rs @@ -340,8 +340,8 @@ impl<'a> InferenceTable<'a> { self.resolve_with_fallback(t, &|_, _, d, _| d) } - /// Unify two types and register new trait goals that arise from that. - pub(crate) fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool { + /// Unify two relatable values (e.g. `Ty`) and register new trait goals that arise from that. + pub(crate) fn unify>(&mut self, ty1: &T, ty2: &T) -> bool { let result = match self.try_unify(ty1, ty2) { Ok(r) => r, Err(_) => return false, @@ -350,9 +350,13 @@ impl<'a> InferenceTable<'a> { true } - /// Unify two types and return new trait goals arising from it, so the + /// Unify two relatable values (e.g. `Ty`) and return new trait goals arising from it, so the /// caller needs to deal with them. - pub(crate) fn try_unify>(&mut self, t1: &T, t2: &T) -> InferResult<()> { + pub(crate) fn try_unify>( + &mut self, + t1: &T, + t2: &T, + ) -> InferResult<()> { match self.var_unification_table.relate( Interner, &self.db, diff --git a/crates/hir-ty/src/method_resolution.rs b/crates/hir-ty/src/method_resolution.rs index 5998680dcd3..6d3df34746e 100644 --- a/crates/hir-ty/src/method_resolution.rs +++ b/crates/hir-ty/src/method_resolution.rs @@ -1214,7 +1214,7 @@ fn is_valid_fn_candidate( let expected_receiver = sig.map(|s| s.params()[0].clone()).substitute(Interner, &fn_subst); - check_that!(table.unify(&receiver_ty, &expected_receiver)); + check_that!(table.unify(receiver_ty, &expected_receiver)); } if let ItemContainerId::ImplId(impl_id) = container { From ac732b62dd823a669628ca8a54655c18ea269c7d Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sat, 17 Sep 2022 09:38:57 -0700 Subject: [PATCH 027/219] rustdoc: clean up `#toggle-all-docs` This change converts the element from an `` link to a button. It's pretty much directly trading slightly more CSS for slightly less HTML, and it's also semantically correct (so you don't get a broken "bookmark" option when you right click on it). While doing this, I also got rid of the unnecessary `class="inner"` attribute on the inner span. There was a style targeting `.collapse-toggle > .inner`, but no CSS ever targeted the `#toggle-all-docs > .inner`. --- src/librustdoc/html/static/css/rustdoc.css | 12 ++++++++---- src/librustdoc/html/templates/print_item.html | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 293c9787609..f49176e7201 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -163,9 +163,6 @@ h1.fqn { padding-bottom: 6px; margin-bottom: 15px; } -#toggle-all-docs { - text-decoration: none; -} /* The only headings that get underlines are: Markdown-generated headings within the top-doc Rustdoc-generated h2 section headings (e.g. "Implementations", "Required Methods", etc) @@ -209,7 +206,7 @@ ul.all-items { font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif; } -a#toggle-all-docs, +#toggle-all-docs, a.anchor, .small-section-header a, #source-sidebar a, @@ -303,6 +300,13 @@ button { padding: 1px 6px; } +button#toggle-all-docs { + padding: 0; + background: none; + border: none; + cursor: pointer; +} + /* end tweaks for normalize.css 8 */ .rustdoc { diff --git a/src/librustdoc/html/templates/print_item.html b/src/librustdoc/html/templates/print_item.html index b6ce3ea3dee..e497b619366 100644 --- a/src/librustdoc/html/templates/print_item.html +++ b/src/librustdoc/html/templates/print_item.html @@ -21,8 +21,8 @@ source · {# -#} {%- else -%} {%- endmatch -%} - {#- -#} - [] {#- -#} - {#- -#} + {#- -#} {#- -#} {#- -#} From bdbc9772c61cc2941caafe97139203b5821f38e2 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sat, 17 Sep 2022 09:53:31 -0700 Subject: [PATCH 028/219] rustdoc: fix weird toggle-all-docs style in iOS --- src/librustdoc/html/static/css/rustdoc.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index f49176e7201..6be8333a399 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -305,6 +305,9 @@ button#toggle-all-docs { background: none; border: none; cursor: pointer; + /* iOS button gradient: https://stackoverflow.com/q/5438567 */ + -webkit-appearance: none; + opacity: 1; } /* end tweaks for normalize.css 8 */ From 7d82cadd97acc66993b69304c5a1a04ef7d1fa36 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Tue, 4 Oct 2022 19:02:13 -0500 Subject: [PATCH 029/219] Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard error --- compiler/rustc_lint_defs/src/builtin.rs | 68 ---------- compiler/rustc_resolve/src/diagnostics.rs | 2 +- compiler/rustc_resolve/src/ident.rs | 75 ++--------- compiler/rustc_resolve/src/lib.rs | 6 +- src/test/ui/proc-macro/generate-mod.rs | 7 +- src/test/ui/proc-macro/generate-mod.stderr | 139 ++++++--------------- 6 files changed, 54 insertions(+), 243 deletions(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 61ee467f595..389f3ccf72a 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1982,73 +1982,6 @@ declare_lint! { }; } -declare_lint! { - /// The `proc_macro_derive_resolution_fallback` lint detects proc macro - /// derives using inaccessible names from parent modules. - /// - /// ### Example - /// - /// ```rust,ignore (proc-macro) - /// // foo.rs - /// #![crate_type = "proc-macro"] - /// - /// extern crate proc_macro; - /// - /// use proc_macro::*; - /// - /// #[proc_macro_derive(Foo)] - /// pub fn foo1(a: TokenStream) -> TokenStream { - /// drop(a); - /// "mod __bar { static mut BAR: Option = None; }".parse().unwrap() - /// } - /// ``` - /// - /// ```rust,ignore (needs-dependency) - /// // bar.rs - /// #[macro_use] - /// extern crate foo; - /// - /// struct Something; - /// - /// #[derive(Foo)] - /// struct Another; - /// - /// fn main() {} - /// ``` - /// - /// This will produce: - /// - /// ```text - /// warning: cannot find type `Something` in this scope - /// --> src/main.rs:8:10 - /// | - /// 8 | #[derive(Foo)] - /// | ^^^ names from parent modules are not accessible without an explicit import - /// | - /// = note: `#[warn(proc_macro_derive_resolution_fallback)]` on by default - /// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - /// = note: for more information, see issue #50504 - /// ``` - /// - /// ### Explanation - /// - /// If a proc-macro generates a module, the compiler unintentionally - /// allowed items in that module to refer to items in the crate root - /// without importing them. This is a [future-incompatible] lint to - /// transition this to a hard error in the future. See [issue #50504] for - /// more details. - /// - /// [issue #50504]: https://github.com/rust-lang/rust/issues/50504 - /// [future-incompatible]: ../index.md#future-incompatible-lints - pub PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, - Deny, - "detects proc macro derives using inaccessible names from parent modules", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #83583 ", - reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, - }; -} - declare_lint! { /// The `macro_use_extern_crate` lint detects the use of the /// [`macro_use` attribute]. @@ -3287,7 +3220,6 @@ declare_lint_pass! { UNSTABLE_NAME_COLLISIONS, IRREFUTABLE_LET_PATTERNS, WHERE_CLAUSES_OBJECT_SAFETY, - PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, MACRO_USE_EXTERN_CRATE, MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS, ILL_FORMED_ATTRIBUTE_INPUT, diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 5d868ebec94..5e4d88b9fdc 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1186,7 +1186,7 @@ impl<'a> Resolver<'a> { let root_module = this.resolve_crate_root(root_ident); this.add_module_candidates(root_module, &mut suggestions, filter_fn, None); } - Scope::Module(module, _) => { + Scope::Module(module) => { this.add_module_candidates(module, &mut suggestions, filter_fn, None); } Scope::MacroUsePrelude => { diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index e0542d5479f..a24ee7db008 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -1,11 +1,9 @@ -use rustc_ast::{self as ast, NodeId}; +use rustc_ast as ast; use rustc_feature::is_builtin_attr_name; use rustc_hir::def::{DefKind, Namespace, NonMacroAttrKind, PartialRes, PerNS}; use rustc_hir::PrimTy; use rustc_middle::bug; use rustc_middle::ty; -use rustc_session::lint::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK; -use rustc_session::lint::BuiltinLintDiagnostics; use rustc_span::def_id::LocalDefId; use rustc_span::edition::Edition; use rustc_span::hygiene::{ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext}; @@ -101,7 +99,7 @@ impl<'a> Resolver<'a> { }; let mut scope = match ns { _ if is_absolute_path => Scope::CrateRoot, - TypeNS | ValueNS => Scope::Module(module, None), + TypeNS | ValueNS => Scope::Module(module), MacroNS => Scope::DeriveHelpers(parent_scope.expansion), }; let mut ctxt = ctxt.normalize_to_macros_2_0(); @@ -165,7 +163,7 @@ impl<'a> Resolver<'a> { MacroRulesScope::Invocation(invoc_id) => { Scope::MacroRules(self.invocation_parent_scopes[&invoc_id].macro_rules) } - MacroRulesScope::Empty => Scope::Module(module, None), + MacroRulesScope::Empty => Scope::Module(module), }, Scope::CrateRoot => match ns { TypeNS => { @@ -174,16 +172,10 @@ impl<'a> Resolver<'a> { } ValueNS | MacroNS => break, }, - Scope::Module(module, prev_lint_id) => { + Scope::Module(module) => { use_prelude = !module.no_implicit_prelude; - let derive_fallback_lint_id = match scope_set { - ScopeSet::Late(.., lint_id) => lint_id, - _ => None, - }; - match self.hygienic_lexical_parent(module, &mut ctxt, derive_fallback_lint_id) { - Some((parent_module, lint_id)) => { - Scope::Module(parent_module, lint_id.or(prev_lint_id)) - } + match self.hygienic_lexical_parent(module, &mut ctxt) { + Some(parent_module) => Scope::Module(parent_module), None => { ctxt.adjust(ExpnId::root()); match ns { @@ -215,45 +207,13 @@ impl<'a> Resolver<'a> { &mut self, module: Module<'a>, ctxt: &mut SyntaxContext, - derive_fallback_lint_id: Option, - ) -> Option<(Module<'a>, Option)> { + ) -> Option> { if !module.expansion.outer_expn_is_descendant_of(*ctxt) { - return Some((self.expn_def_scope(ctxt.remove_mark()), None)); + return Some(self.expn_def_scope(ctxt.remove_mark())); } if let ModuleKind::Block = module.kind { - return Some((module.parent.unwrap().nearest_item_scope(), None)); - } - - // We need to support the next case under a deprecation warning - // ``` - // struct MyStruct; - // ---- begin: this comes from a proc macro derive - // mod implementation_details { - // // Note that `MyStruct` is not in scope here. - // impl SomeTrait for MyStruct { ... } - // } - // ---- end - // ``` - // So we have to fall back to the module's parent during lexical resolution in this case. - if derive_fallback_lint_id.is_some() { - if let Some(parent) = module.parent { - // Inner module is inside the macro, parent module is outside of the macro. - if module.expansion != parent.expansion - && module.expansion.is_descendant_of(parent.expansion) - { - // The macro is a proc macro derive - if let Some(def_id) = module.expansion.expn_data().macro_def_id { - let ext = self.get_macro_by_def_id(def_id).ext; - if ext.builtin_name.is_none() - && ext.macro_kind() == MacroKind::Derive - && parent.expansion.outer_expn_is_descendant_of(*ctxt) - { - return Some((parent, derive_fallback_lint_id)); - } - } - } - } + return Some(module.parent.unwrap().nearest_item_scope()); } None @@ -510,7 +470,7 @@ impl<'a> Resolver<'a> { Err((Determinacy::Determined, _)) => Err(Determinacy::Determined), } } - Scope::Module(module, derive_fallback_lint_id) => { + Scope::Module(module) => { let adjusted_parent_scope = &ParentScope { module, ..*parent_scope }; let binding = this.resolve_ident_in_module_unadjusted_ext( ModuleOrUniformRoot::Module(module), @@ -523,21 +483,6 @@ impl<'a> Resolver<'a> { ); match binding { Ok(binding) => { - if let Some(lint_id) = derive_fallback_lint_id { - this.lint_buffer.buffer_lint_with_diagnostic( - PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, - lint_id, - orig_ident.span, - &format!( - "cannot find {} `{}` in this scope", - ns.descr(), - ident - ), - BuiltinLintDiagnostics::ProcMacroDeriveResolutionFallback( - orig_ident.span, - ), - ); - } let misc_flags = if ptr::eq(module, this.graph_root) { Flags::MISC_SUGGEST_CRATE } else if module.is_normal() { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 1c1976af505..cf008dabacf 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -102,9 +102,7 @@ enum Scope<'a> { DeriveHelpersCompat, MacroRules(MacroRulesScopeRef<'a>), CrateRoot, - // The node ID is for reporting the `PROC_MACRO_DERIVE_RESOLUTION_FALLBACK` - // lint if it should be reported. - Module(Module<'a>, Option), + Module(Module<'a>), MacroUsePrelude, BuiltinAttrs, ExternPrelude, @@ -1551,7 +1549,7 @@ impl<'a> Resolver<'a> { self.visit_scopes(ScopeSet::All(TypeNS, false), parent_scope, ctxt, |this, scope, _, _| { match scope { - Scope::Module(module, _) => { + Scope::Module(module) => { this.traits_in_module(module, assoc_item, &mut found_traits); } Scope::StdLibPrelude => { diff --git a/src/test/ui/proc-macro/generate-mod.rs b/src/test/ui/proc-macro/generate-mod.rs index 471f317edf9..9eea630c310 100644 --- a/src/test/ui/proc-macro/generate-mod.rs +++ b/src/test/ui/proc-macro/generate-mod.rs @@ -15,19 +15,16 @@ struct S; #[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in this scope //~| ERROR cannot find type `OuterDerive` in this scope - //~| WARN this was previously accepted - //~| WARN this was previously accepted struct Z; fn inner_block() { #[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in this scope //~| ERROR cannot find type `OuterDerive` in this scope - //~| WARN this was previously accepted - //~| WARN this was previously accepted struct InnerZ; } -#[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed +#[derive(generate_mod::CheckDeriveLint)] //~ ERROR cannot find type `OuterDeriveLint` in this scope + //~| ERROR cannot find type `FromOutside` in this scope struct W; fn main() {} diff --git a/src/test/ui/proc-macro/generate-mod.stderr b/src/test/ui/proc-macro/generate-mod.stderr index 39bf28dba96..64042ca0ecd 100644 --- a/src/test/ui/proc-macro/generate-mod.stderr +++ b/src/test/ui/proc-macro/generate-mod.stderr @@ -38,127 +38,66 @@ LL | #[generate_mod::check_attr] OuterAttr = note: this error originates in the attribute macro `generate_mod::check_attr` (in Nightly builds, run with -Z macro-backtrace for more info) -error: cannot find type `FromOutside` in this scope +error[E0412]: cannot find type `FromOutside` in this scope --> $DIR/generate-mod.rs:16:10 | LL | #[derive(generate_mod::CheckDerive)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #83583 - = note: `#[deny(proc_macro_derive_resolution_fallback)]` on by default + = note: consider importing this struct: + FromOutside = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) -error: cannot find type `OuterDerive` in this scope +error[E0412]: cannot find type `OuterDerive` in this scope --> $DIR/generate-mod.rs:16:10 | LL | #[derive(generate_mod::CheckDerive)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #83583 + = note: consider importing this struct: + OuterDerive = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) -error: cannot find type `FromOutside` in this scope - --> $DIR/generate-mod.rs:23:14 +error[E0412]: cannot find type `FromOutside` in this scope + --> $DIR/generate-mod.rs:21:14 | LL | #[derive(generate_mod::CheckDerive)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #83583 + = note: consider importing this struct: + FromOutside = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) -error: cannot find type `OuterDerive` in this scope - --> $DIR/generate-mod.rs:23:14 +error[E0412]: cannot find type `OuterDerive` in this scope + --> $DIR/generate-mod.rs:21:14 | LL | #[derive(generate_mod::CheckDerive)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #83583 + = note: consider importing this struct: + OuterDerive = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 8 previous errors +error[E0412]: cannot find type `FromOutside` in this scope + --> $DIR/generate-mod.rs:26:10 + | +LL | #[derive(generate_mod::CheckDeriveLint)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | + = note: consider importing this struct: + FromOutside + = note: this error originates in the derive macro `generate_mod::CheckDeriveLint` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0412]: cannot find type `OuterDeriveLint` in this scope + --> $DIR/generate-mod.rs:26:10 + | +LL | #[derive(generate_mod::CheckDeriveLint)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | + = note: consider importing this struct: + OuterDeriveLint + = note: this error originates in the derive macro `generate_mod::CheckDeriveLint` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0412`. -Future incompatibility report: Future breakage diagnostic: -error: cannot find type `FromOutside` in this scope - --> $DIR/generate-mod.rs:16:10 - | -LL | #[derive(generate_mod::CheckDerive)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #83583 - = note: `#[deny(proc_macro_derive_resolution_fallback)]` on by default - = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) - -Future breakage diagnostic: -error: cannot find type `OuterDerive` in this scope - --> $DIR/generate-mod.rs:16:10 - | -LL | #[derive(generate_mod::CheckDerive)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #83583 - = note: `#[deny(proc_macro_derive_resolution_fallback)]` on by default - = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) - -Future breakage diagnostic: -error: cannot find type `FromOutside` in this scope - --> $DIR/generate-mod.rs:23:14 - | -LL | #[derive(generate_mod::CheckDerive)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #83583 - = note: `#[deny(proc_macro_derive_resolution_fallback)]` on by default - = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) - -Future breakage diagnostic: -error: cannot find type `OuterDerive` in this scope - --> $DIR/generate-mod.rs:23:14 - | -LL | #[derive(generate_mod::CheckDerive)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #83583 - = note: `#[deny(proc_macro_derive_resolution_fallback)]` on by default - = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) - -Future breakage diagnostic: -warning: cannot find type `FromOutside` in this scope - --> $DIR/generate-mod.rs:30:10 - | -LL | #[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #83583 -note: the lint level is defined here - --> $DIR/generate-mod.rs:30:10 - | -LL | #[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this warning originates in the derive macro `generate_mod::CheckDeriveLint` (in Nightly builds, run with -Z macro-backtrace for more info) - -Future breakage diagnostic: -warning: cannot find type `OuterDeriveLint` in this scope - --> $DIR/generate-mod.rs:30:10 - | -LL | #[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #83583 -note: the lint level is defined here - --> $DIR/generate-mod.rs:30:10 - | -LL | #[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this warning originates in the derive macro `generate_mod::CheckDeriveLint` (in Nightly builds, run with -Z macro-backtrace for more info) - From 854b3166a05916f01b6a7cb9c09fc7c8d26697ad Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Mon, 24 Oct 2022 20:52:51 +0200 Subject: [PATCH 030/219] Address some comments --- compiler/rustc_errors/src/emitter.rs | 4 ++-- compiler/rustc_interface/src/tests.rs | 1 + compiler/rustc_session/src/options.rs | 4 ++-- src/librustdoc/core.rs | 4 ++-- src/test/rustdoc-ui/track-diagnostics.rs | 6 ++++++ src/test/rustdoc-ui/track-diagnostics.stderr | 10 ++++++++++ src/test/rustdoc-ui/z-help.stdout | 1 + src/tools/clippy/tests/ui/track-diagnostics.rs | 8 ++++++++ src/tools/clippy/tests/ui/track-diagnostics.stderr | 10 ++++++++++ 9 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 src/test/rustdoc-ui/track-diagnostics.rs create mode 100644 src/test/rustdoc-ui/track-diagnostics.stderr create mode 100644 src/tools/clippy/tests/ui/track-diagnostics.rs create mode 100644 src/tools/clippy/tests/ui/track-diagnostics.stderr diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index b9b9a59e354..b7b8fe3f25a 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -559,7 +559,7 @@ impl Emitter for EmitterWriter { &primary_span, &children, &suggestions, - Some(&diag.emitted_at), + self.track_diagnostics.then_some(&diag.emitted_at), ); } @@ -1661,7 +1661,7 @@ impl EmitterWriter { } } - if self.track_diagnostics && let Some(tracked) = emitted_at { + if let Some(tracked) = emitted_at { let track = format!("-Ztrack-diagnostics: created at {tracked}"); let len = buffer.num_lines(); buffer.append(len, &track, Style::NoStyle); diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index da3102ba7b0..0f7220f9f7a 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -689,6 +689,7 @@ fn test_unstable_options_tracking_hash() { untracked!(time_llvm_passes, true); untracked!(time_passes, true); untracked!(trace_macros, true); + untracked!(track_diagnostics, false); untracked!(trim_diagnostic_paths, false); untracked!(ui_testing, true); untracked!(unpretty, Some("expanded".to_string())); diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index af290931850..5327dea8804 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1585,8 +1585,8 @@ options! { "choose the TLS model to use (`rustc --print tls-models` for details)"), trace_macros: bool = (false, parse_bool, [UNTRACKED], "for every macro invocation, print its name and arguments (default: no)"), - track_diagnostics: bool = (false, parse_bool, [TRACKED], - "Tracks where in rustc a diagnostic was emitted"), + track_diagnostics: bool = (false, parse_bool, [UNTRACKED], + "tracks where in rustc a diagnostic was emitted"), // Diagnostics are considered side-effects of a query (see `QuerySideEffects`) and are saved // alongside query results and changes to translation options can affect diagnostics - so // translation options should be tracked. diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 2a61c2451b6..37d934a540b 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -172,7 +172,7 @@ pub(crate) fn new_handler( unstable_opts.teach, diagnostic_width, false, - false, + unstable_opts.track_diagnostics, ) .ui_testing(unstable_opts.ui_testing), ) @@ -191,7 +191,7 @@ pub(crate) fn new_handler( json_rendered, diagnostic_width, false, - false, + unstable_opts.track_diagnostics, ) .ui_testing(unstable_opts.ui_testing), ) diff --git a/src/test/rustdoc-ui/track-diagnostics.rs b/src/test/rustdoc-ui/track-diagnostics.rs new file mode 100644 index 00000000000..fc5343a982e --- /dev/null +++ b/src/test/rustdoc-ui/track-diagnostics.rs @@ -0,0 +1,6 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + +struct A; +struct B; +const S: A = B; diff --git a/src/test/rustdoc-ui/track-diagnostics.stderr b/src/test/rustdoc-ui/track-diagnostics.stderr new file mode 100644 index 00000000000..76453cfe220 --- /dev/null +++ b/src/test/rustdoc-ui/track-diagnostics.stderr @@ -0,0 +1,10 @@ +error[E0308]: mismatched types + --> $DIR/track-diagnostics.rs:6:14 + | +LL | const S: A = B; + | ^ expected struct `A`, found struct `B` +-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:2275:31 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/rustdoc-ui/z-help.stdout b/src/test/rustdoc-ui/z-help.stdout index dbf3a8f00ee..07c8793c08b 100644 --- a/src/test/rustdoc-ui/z-help.stdout +++ b/src/test/rustdoc-ui/z-help.stdout @@ -170,6 +170,7 @@ -Z time-passes=val -- measure time of each rustc pass (default: no) -Z tls-model=val -- choose the TLS model to use (`rustc --print tls-models` for details) -Z trace-macros=val -- for every macro invocation, print its name and arguments (default: no) + -Z track-diagnostics=val -- Tracks where in rustc a diagnostic was emitted -Z translate-additional-ftl=val -- additional fluent translation to preferentially use (for testing translation) -Z translate-directionality-markers=val -- emit directionality isolation markers in translated diagnostics -Z translate-lang=val -- language identifier for diagnostic output diff --git a/src/tools/clippy/tests/ui/track-diagnostics.rs b/src/tools/clippy/tests/ui/track-diagnostics.rs new file mode 100644 index 00000000000..8c96f46d57a --- /dev/null +++ b/src/tools/clippy/tests/ui/track-diagnostics.rs @@ -0,0 +1,8 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + +struct A; +struct B; +const S: A = B; + +fn main() {} diff --git a/src/tools/clippy/tests/ui/track-diagnostics.stderr b/src/tools/clippy/tests/ui/track-diagnostics.stderr new file mode 100644 index 00000000000..76453cfe220 --- /dev/null +++ b/src/tools/clippy/tests/ui/track-diagnostics.stderr @@ -0,0 +1,10 @@ +error[E0308]: mismatched types + --> $DIR/track-diagnostics.rs:6:14 + | +LL | const S: A = B; + | ^ expected struct `A`, found struct `B` +-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:2275:31 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. From 447d57f03669a551d395f8e9a77fac8316480e92 Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Mon, 24 Oct 2022 23:19:48 +0200 Subject: [PATCH 031/219] Add more normalization and tests --- src/test/rustdoc-ui/track-diagnostics.rs | 4 ++++ src/test/rustdoc-ui/track-diagnostics.stderr | 4 ++-- src/test/rustdoc-ui/z-help.stdout | 2 +- src/test/ui/track-diagnostics/track.rs | 5 +++++ src/test/ui/track-diagnostics/track.stderr | 10 +++++----- src/test/ui/track-diagnostics/track2.rs | 10 ++++++++++ src/test/ui/track-diagnostics/track2.stderr | 13 +++++++++++++ src/test/ui/track-diagnostics/track3.rs | 10 ++++++++++ src/test/ui/track-diagnostics/track3.stderr | 18 ++++++++++++++++++ src/test/ui/track-diagnostics/track4.rs | 13 +++++++++++++ src/test/ui/track-diagnostics/track4.stderr | 14 ++++++++++++++ src/tools/clippy/tests/ui/track-diagnostics.rs | 4 ++++ .../clippy/tests/ui/track-diagnostics.stderr | 4 ++-- 13 files changed, 101 insertions(+), 10 deletions(-) create mode 100644 src/test/ui/track-diagnostics/track2.rs create mode 100644 src/test/ui/track-diagnostics/track2.stderr create mode 100644 src/test/ui/track-diagnostics/track3.rs create mode 100644 src/test/ui/track-diagnostics/track3.stderr create mode 100644 src/test/ui/track-diagnostics/track4.rs create mode 100644 src/test/ui/track-diagnostics/track4.stderr diff --git a/src/test/rustdoc-ui/track-diagnostics.rs b/src/test/rustdoc-ui/track-diagnostics.rs index fc5343a982e..3da80adbf44 100644 --- a/src/test/rustdoc-ui/track-diagnostics.rs +++ b/src/test/rustdoc-ui/track-diagnostics.rs @@ -1,6 +1,10 @@ // compile-flags: -Z track-diagnostics // error-pattern: created at +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" + struct A; struct B; const S: A = B; diff --git a/src/test/rustdoc-ui/track-diagnostics.stderr b/src/test/rustdoc-ui/track-diagnostics.stderr index 76453cfe220..5a0982ff731 100644 --- a/src/test/rustdoc-ui/track-diagnostics.stderr +++ b/src/test/rustdoc-ui/track-diagnostics.stderr @@ -1,9 +1,9 @@ error[E0308]: mismatched types - --> $DIR/track-diagnostics.rs:6:14 + --> $DIR/track-diagnostics.rs:$LINE::$COL | LL | const S: A = B; | ^ expected struct `A`, found struct `B` --Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:2275:31 +-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:$LINE::$COL error: aborting due to previous error diff --git a/src/test/rustdoc-ui/z-help.stdout b/src/test/rustdoc-ui/z-help.stdout index 07c8793c08b..d9d19651456 100644 --- a/src/test/rustdoc-ui/z-help.stdout +++ b/src/test/rustdoc-ui/z-help.stdout @@ -170,7 +170,7 @@ -Z time-passes=val -- measure time of each rustc pass (default: no) -Z tls-model=val -- choose the TLS model to use (`rustc --print tls-models` for details) -Z trace-macros=val -- for every macro invocation, print its name and arguments (default: no) - -Z track-diagnostics=val -- Tracks where in rustc a diagnostic was emitted + -Z track-diagnostics=val -- tracks where in rustc a diagnostic was emitted -Z translate-additional-ftl=val -- additional fluent translation to preferentially use (for testing translation) -Z translate-directionality-markers=val -- emit directionality isolation markers in translated diagnostics -Z translate-lang=val -- language identifier for diagnostic output diff --git a/src/test/ui/track-diagnostics/track.rs b/src/test/ui/track-diagnostics/track.rs index 3427c593e85..23c0c8c4ed8 100644 --- a/src/test/ui/track-diagnostics/track.rs +++ b/src/test/ui/track-diagnostics/track.rs @@ -1,6 +1,11 @@ // compile-flags: -Z track-diagnostics // error-pattern: created at +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" +// normalize-stderr-test "note: rustc .+ running on .+" -> "note: rustc $$VERSION running on $$TARGET" + fn main() { break rust } diff --git a/src/test/ui/track-diagnostics/track.stderr b/src/test/ui/track-diagnostics/track.stderr index 83ff935dbab..ed5c70b5a06 100644 --- a/src/test/ui/track-diagnostics/track.stderr +++ b/src/test/ui/track-diagnostics/track.stderr @@ -1,16 +1,16 @@ error[E0425]: cannot find value `rust` in this scope - --> $DIR/track.rs:5:11 + --> $DIR/track.rs:$LINE::$COL | LL | break rust | ^^^^ not found in this scope --Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:289:28 +-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:$LINE::$COL error[E0268]: `break` outside of a loop - --> $DIR/track.rs:5:5 + --> $DIR/track.rs:$LINE::$COL | LL | break rust | ^^^^^^^^^^ cannot `break` outside of a loop --Ztrack-diagnostics: created at compiler/rustc_passes/src/errors.rs:957:10 +-Ztrack-diagnostics: created at compiler/rustc_passes/src/errors.rs:$LINE::$COL error: internal compiler error: It looks like you're trying to break rust; would you like some ICE? @@ -18,7 +18,7 @@ note: the compiler expectedly panicked. this is a feature. note: we would appreciate a joke overview: https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675 -note: rustc 1.66.0-dev running on x86_64-pc-windows-msvc +note: rustc $VERSION running on $TARGET error: aborting due to 3 previous errors diff --git a/src/test/ui/track-diagnostics/track2.rs b/src/test/ui/track-diagnostics/track2.rs new file mode 100644 index 00000000000..45afd081566 --- /dev/null +++ b/src/test/ui/track-diagnostics/track2.rs @@ -0,0 +1,10 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" + +fn main() { + let _moved @ _from = String::from("foo"); +} diff --git a/src/test/ui/track-diagnostics/track2.stderr b/src/test/ui/track-diagnostics/track2.stderr new file mode 100644 index 00000000000..28d17f1e141 --- /dev/null +++ b/src/test/ui/track-diagnostics/track2.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value + --> $DIR/track2.rs:$LINE::$COL + | +LL | let _moved @ _from = String::from("foo"); + | ^^^^^^ ----- ------------------- move occurs because value has type `String`, which does not implement the `Copy` trait + | | | + | | value moved here + | value used here after move +-Ztrack-diagnostics: created at compiler/rustc_borrowck/src/borrowck_errors.rs:$LINE::$COL + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/track-diagnostics/track3.rs b/src/test/ui/track-diagnostics/track3.rs new file mode 100644 index 00000000000..e9316a42189 --- /dev/null +++ b/src/test/ui/track-diagnostics/track3.rs @@ -0,0 +1,10 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" + +fn main() { + let _unimported = Blah { field: u8 }; +} diff --git a/src/test/ui/track-diagnostics/track3.stderr b/src/test/ui/track-diagnostics/track3.stderr new file mode 100644 index 00000000000..005380df430 --- /dev/null +++ b/src/test/ui/track-diagnostics/track3.stderr @@ -0,0 +1,18 @@ +error[E0422]: cannot find struct, variant or union type `Blah` in this scope + --> $DIR/track3.rs:$LINE::$COL + | +LL | let _unimported = Blah { field: u8 }; + | ^^^^ not found in this scope +-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:$LINE::$COL + +error[E0423]: expected value, found builtin type `u8` + --> $DIR/track3.rs:$LINE::$COL + | +LL | let _unimported = Blah { field: u8 }; + | ^^ not a value +-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:$LINE::$COL + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0422, E0423. +For more information about an error, try `rustc --explain E0422`. diff --git a/src/test/ui/track-diagnostics/track4.rs b/src/test/ui/track-diagnostics/track4.rs new file mode 100644 index 00000000000..065cc604604 --- /dev/null +++ b/src/test/ui/track-diagnostics/track4.rs @@ -0,0 +1,13 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" + +pub onion { + Owo(u8), + Uwu(i8), +} + +fn main() {} diff --git a/src/test/ui/track-diagnostics/track4.stderr b/src/test/ui/track-diagnostics/track4.stderr new file mode 100644 index 00000000000..e0cedcee0d3 --- /dev/null +++ b/src/test/ui/track-diagnostics/track4.stderr @@ -0,0 +1,14 @@ +error: missing `struct` for struct definition + --> $DIR/track4.rs:$LINE::$COL + | +LL | pub onion { + | ^ +-Ztrack-diagnostics: created at compiler/rustc_parse/src/parser/diagnostics.rs:$LINE::$COL + | +help: add `struct` here to parse `onion` as a public struct + | +LL | pub struct onion { + | ++++++ + +error: aborting due to previous error + diff --git a/src/tools/clippy/tests/ui/track-diagnostics.rs b/src/tools/clippy/tests/ui/track-diagnostics.rs index 8c96f46d57a..550ccd7b3d3 100644 --- a/src/tools/clippy/tests/ui/track-diagnostics.rs +++ b/src/tools/clippy/tests/ui/track-diagnostics.rs @@ -1,6 +1,10 @@ // compile-flags: -Z track-diagnostics // error-pattern: created at +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" + struct A; struct B; const S: A = B; diff --git a/src/tools/clippy/tests/ui/track-diagnostics.stderr b/src/tools/clippy/tests/ui/track-diagnostics.stderr index 76453cfe220..5a0982ff731 100644 --- a/src/tools/clippy/tests/ui/track-diagnostics.stderr +++ b/src/tools/clippy/tests/ui/track-diagnostics.stderr @@ -1,9 +1,9 @@ error[E0308]: mismatched types - --> $DIR/track-diagnostics.rs:6:14 + --> $DIR/track-diagnostics.rs:$LINE::$COL | LL | const S: A = B; | ^ expected struct `A`, found struct `B` --Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:2275:31 +-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:$LINE::$COL error: aborting due to previous error From 6457df3d4b945f2b56ada653e30116bb2267c004 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Thu, 20 Oct 2022 11:35:28 +0200 Subject: [PATCH 032/219] ensure that compile-flags arguments are the last in ui tests Before this commit, compiletest would add `-L path/to/aux` at the end of the rustc flags, even after the custom ones set with the compile-flags header comment. This made it impossible to check how rustc would behave when a flag requiring an argument was passed without the argument, because the argument would become `-L`. This PR fixes that by adding the `-L path/to/aux` before the arguments defined in compile-flags, at least for UI tests. Other test suites might either be fixed as well by this change, or still present the old behavior. --- src/tools/compiletest/src/runtest.rs | 60 +++++++++++++++++++--------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 8f289876f73..ab0d568ffa7 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1499,10 +1499,13 @@ impl<'test> TestCx<'test> { _ => AllowUnused::No, }; - let mut rustc = - self.make_compile_args(&self.testpaths.file, output_file, emit_metadata, allow_unused); - - rustc.arg("-L").arg(&self.aux_output_dir_name()); + let rustc = self.make_compile_args( + &self.testpaths.file, + output_file, + emit_metadata, + allow_unused, + LinkToAux::Yes, + ); self.compose_and_run_compiler(rustc, None) } @@ -1729,8 +1732,13 @@ impl<'test> TestCx<'test> { // Create the directory for the stdout/stderr files. create_dir_all(aux_cx.output_base_dir()).unwrap(); let input_file = &aux_testpaths.file; - let mut aux_rustc = - aux_cx.make_compile_args(input_file, aux_output, EmitMetadata::No, AllowUnused::No); + let mut aux_rustc = aux_cx.make_compile_args( + input_file, + aux_output, + EmitMetadata::No, + AllowUnused::No, + LinkToAux::No, + ); for key in &aux_props.unset_rustc_env { aux_rustc.env_remove(key); @@ -1869,6 +1877,7 @@ impl<'test> TestCx<'test> { output_file: TargetLocation, emit_metadata: EmitMetadata, allow_unused: AllowUnused, + link_to_aux: LinkToAux, ) -> Command { let is_aux = input_file.components().map(|c| c.as_os_str()).any(|c| c == "auxiliary"); let is_rustdoc = self.is_rustdoc() && !is_aux; @@ -2056,6 +2065,10 @@ impl<'test> TestCx<'test> { rustc.arg("-Ctarget-feature=-crt-static"); } + if let LinkToAux::Yes = link_to_aux { + rustc.arg("-L").arg(self.aux_output_dir_name()); + } + rustc.args(&self.props.compile_flags); rustc @@ -2247,13 +2260,16 @@ impl<'test> TestCx<'test> { // codegen tests (using FileCheck) fn compile_test_and_save_ir(&self) -> ProcRes { - let aux_dir = self.aux_output_dir_name(); - let output_file = TargetLocation::ThisDirectory(self.output_base_dir()); let input_file = &self.testpaths.file; - let mut rustc = - self.make_compile_args(input_file, output_file, EmitMetadata::No, AllowUnused::No); - rustc.arg("-L").arg(aux_dir).arg("--emit=llvm-ir"); + let mut rustc = self.make_compile_args( + input_file, + output_file, + EmitMetadata::No, + AllowUnused::No, + LinkToAux::Yes, + ); + rustc.arg("--emit=llvm-ir"); self.compose_and_run_compiler(rustc, None) } @@ -2265,10 +2281,13 @@ impl<'test> TestCx<'test> { let output_file = TargetLocation::ThisFile(output_path.clone()); let input_file = &self.testpaths.file; - let mut rustc = - self.make_compile_args(input_file, output_file, EmitMetadata::No, AllowUnused::No); - - rustc.arg("-L").arg(self.aux_output_dir_name()); + let mut rustc = self.make_compile_args( + input_file, + output_file, + EmitMetadata::No, + AllowUnused::No, + LinkToAux::Yes, + ); match self.props.assembly_output.as_ref().map(AsRef::as_ref) { Some("emit-asm") => { @@ -2409,8 +2428,8 @@ impl<'test> TestCx<'test> { output_file, EmitMetadata::No, AllowUnused::Yes, + LinkToAux::Yes, ); - rustc.arg("-L").arg(&new_rustdoc.aux_output_dir_name()); new_rustdoc.build_all_auxiliary(&mut rustc); let proc_res = new_rustdoc.document(&compare_dir); @@ -3354,13 +3373,13 @@ impl<'test> TestCx<'test> { if self.props.run_rustfix && self.config.compare_mode.is_none() { // And finally, compile the fixed code and make sure it both // succeeds and has no diagnostics. - let mut rustc = self.make_compile_args( + let rustc = self.make_compile_args( &self.testpaths.file.with_extension(UI_FIXED), TargetLocation::ThisFile(self.make_exe_name()), emit_metadata, AllowUnused::No, + LinkToAux::Yes, ); - rustc.arg("-L").arg(&self.aux_output_dir_name()); let res = self.compose_and_run_compiler(rustc, None); if !res.status.success() { self.fatal_proc_rec("failed to compile fixed code", &res); @@ -3948,3 +3967,8 @@ enum AllowUnused { Yes, No, } + +enum LinkToAux { + Yes, + No, +} From 954649069ffe4a9d42bc0a83e07e6af4732300ea Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 24 Oct 2022 09:56:05 +0200 Subject: [PATCH 033/219] add a test to verify that compile-flags are provided last --- src/test/ui/compiletest-compile-flags-last.rs | 6 ++++++ src/test/ui/compiletest-compile-flags-last.stderr | 2 ++ src/tools/tidy/src/ui_tests.rs | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/compiletest-compile-flags-last.rs create mode 100644 src/test/ui/compiletest-compile-flags-last.stderr diff --git a/src/test/ui/compiletest-compile-flags-last.rs b/src/test/ui/compiletest-compile-flags-last.rs new file mode 100644 index 00000000000..9c78e4c5e9d --- /dev/null +++ b/src/test/ui/compiletest-compile-flags-last.rs @@ -0,0 +1,6 @@ +// Check that the arguments provided through `// compile-flags` are added last to the command line +// in UI tests. To ensure that we invoke rustc with a flag that expects an argument withut actually +// providing it. If the compile-flags are not last, the test will fail as rustc will interpret the +// next flag as the argument of this flag. +// +// compile-flags: --cap-lints diff --git a/src/test/ui/compiletest-compile-flags-last.stderr b/src/test/ui/compiletest-compile-flags-last.stderr new file mode 100644 index 00000000000..d8d40a7d9f1 --- /dev/null +++ b/src/test/ui/compiletest-compile-flags-last.stderr @@ -0,0 +1,2 @@ +error: Argument to option 'cap-lints' missing + diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index c600f99c2c4..d307d6f43b1 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -7,7 +7,7 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. -const ROOT_ENTRY_LIMIT: usize = 948; +const ROOT_ENTRY_LIMIT: usize = 949; const ISSUES_ENTRY_LIMIT: usize = 2117; fn check_entries(path: &Path, bad: &mut bool) { From 956b96a19d83ffd9feb920c053f0ea31e8dad46e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 25 Oct 2022 14:43:26 +0300 Subject: [PATCH 034/219] Switch to upstream positionEncoding --- Cargo.lock | 4 ++-- crates/rust-analyzer/Cargo.toml | 2 +- crates/rust-analyzer/src/bin/main.rs | 8 ++------ crates/rust-analyzer/src/caps.rs | 14 ++++++++++---- crates/rust-analyzer/src/cli/lsif.rs | 6 +++--- crates/rust-analyzer/src/cli/scip.rs | 4 ++-- crates/rust-analyzer/src/config.rs | 8 ++++---- crates/rust-analyzer/src/diagnostics/to_proto.rs | 16 ++++++++-------- crates/rust-analyzer/src/from_proto.rs | 6 +++--- crates/rust-analyzer/src/global_state.rs | 2 +- crates/rust-analyzer/src/line_index.rs | 4 ++-- crates/rust-analyzer/src/lsp_ext.rs | 11 ++++++++++- crates/rust-analyzer/src/lsp_utils.rs | 4 ++-- crates/rust-analyzer/src/to_proto.rs | 8 ++++---- docs/dev/lsp-extensions.md | 8 +------- lib/lsp-server/Cargo.toml | 2 +- 16 files changed, 56 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0ddea2f728d..8931c17bbdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -872,9 +872,9 @@ dependencies = [ [[package]] name = "lsp-types" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3bcfee315dde785ba887edb540b08765fd7df75a7d948844be6bf5712246734" +checksum = "9be6e9c7e2d18f651974370d7aff703f9513e0df6e464fd795660edc77e6ca51" dependencies = [ "bitflags", "serde", diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 5445028536c..37e1cf663fc 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -23,7 +23,7 @@ crossbeam-channel = "0.5.5" dissimilar = "1.0.4" itertools = "0.10.5" scip = "0.1.1" -lsp-types = { version = "0.93.1", features = ["proposed"] } +lsp-types = { version = "0.93.2", features = ["proposed"] } parking_lot = "0.12.1" xflags = "0.3.0" oorandom = "11.1.3" diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index eabfcf1944d..7bf595d2a45 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs @@ -11,7 +11,7 @@ use std::{env, fs, path::Path, process}; use lsp_server::Connection; use project_model::ProjectManifest; -use rust_analyzer::{cli::flags, config::Config, from_json, lsp_ext::supports_utf8, Result}; +use rust_analyzer::{cli::flags, config::Config, from_json, Result}; use vfs::AbsPathBuf; #[cfg(all(feature = "mimalloc"))] @@ -191,11 +191,7 @@ fn run_server() -> Result<()> { name: String::from("rust-analyzer"), version: Some(rust_analyzer::version().to_string()), }), - offset_encoding: if supports_utf8(config.caps()) { - Some("utf-8".to_string()) - } else { - None - }, + offset_encoding: None, }; let initialize_result = serde_json::to_value(initialize_result).unwrap(); diff --git a/crates/rust-analyzer/src/caps.rs b/crates/rust-analyzer/src/caps.rs index cda95cd8626..723b888d9ab 100644 --- a/crates/rust-analyzer/src/caps.rs +++ b/crates/rust-analyzer/src/caps.rs @@ -6,19 +6,25 @@ use lsp_types::{ FileOperationFilter, FileOperationPattern, FileOperationPatternKind, FileOperationRegistrationOptions, FoldingRangeProviderCapability, HoverProviderCapability, ImplementationProviderCapability, InlayHintOptions, InlayHintServerCapabilities, OneOf, - RenameOptions, SaveOptions, SelectionRangeProviderCapability, SemanticTokensFullOptions, - SemanticTokensLegend, SemanticTokensOptions, ServerCapabilities, SignatureHelpOptions, - TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, - TypeDefinitionProviderCapability, WorkDoneProgressOptions, + PositionEncodingKind, RenameOptions, SaveOptions, SelectionRangeProviderCapability, + SemanticTokensFullOptions, SemanticTokensLegend, SemanticTokensOptions, ServerCapabilities, + SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, + TextDocumentSyncOptions, TypeDefinitionProviderCapability, WorkDoneProgressOptions, WorkspaceFileOperationsServerCapabilities, WorkspaceServerCapabilities, }; use serde_json::json; use crate::config::{Config, RustfmtConfig}; +use crate::lsp_ext::supports_utf8; use crate::semantic_tokens; pub fn server_capabilities(config: &Config) -> ServerCapabilities { ServerCapabilities { + position_encoding: if supports_utf8(config.caps()) { + Some(PositionEncodingKind::UTF8) + } else { + None + }, text_document_sync: Some(TextDocumentSyncCapability::Options(TextDocumentSyncOptions { open_close: Some(true), change: Some(TextDocumentSyncKind::INCREMENTAL), diff --git a/crates/rust-analyzer/src/cli/lsif.rs b/crates/rust-analyzer/src/cli/lsif.rs index 748306ea57d..5ff347b9bd7 100644 --- a/crates/rust-analyzer/src/cli/lsif.rs +++ b/crates/rust-analyzer/src/cli/lsif.rs @@ -20,7 +20,7 @@ use crate::cli::{ load_cargo::{load_workspace, LoadCargoConfig}, Result, }; -use crate::line_index::{LineEndings, LineIndex, OffsetEncoding}; +use crate::line_index::{LineEndings, LineIndex, PositionEncoding}; use crate::to_proto; use crate::version::version; @@ -126,7 +126,7 @@ impl LsifManager<'_> { let line_index = self.db.line_index(file_id); let line_index = LineIndex { index: line_index, - encoding: OffsetEncoding::Utf16, + encoding: PositionEncoding::Utf16, endings: LineEndings::Unix, }; let range_id = self.add_vertex(lsif::Vertex::Range { @@ -248,7 +248,7 @@ impl LsifManager<'_> { let line_index = self.db.line_index(file_id); let line_index = LineIndex { index: line_index, - encoding: OffsetEncoding::Utf16, + encoding: PositionEncoding::Utf16, endings: LineEndings::Unix, }; let result = folds diff --git a/crates/rust-analyzer/src/cli/scip.rs b/crates/rust-analyzer/src/cli/scip.rs index 8b77ccde0ee..16298862b50 100644 --- a/crates/rust-analyzer/src/cli/scip.rs +++ b/crates/rust-analyzer/src/cli/scip.rs @@ -5,7 +5,7 @@ use std::{ time::Instant, }; -use crate::line_index::{LineEndings, LineIndex, OffsetEncoding}; +use crate::line_index::{LineEndings, LineIndex, PositionEncoding}; use hir::Name; use ide::{ LineCol, MonikerDescriptorKind, StaticIndex, StaticIndexedFile, TextRange, TokenId, @@ -91,7 +91,7 @@ impl flags::Scip { let line_index = LineIndex { index: db.line_index(file_id), - encoding: OffsetEncoding::Utf8, + encoding: PositionEncoding::Utf8, endings: LineEndings::Unix, }; diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 85322f12a83..1ed8f2bb5f3 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -32,7 +32,7 @@ use vfs::AbsPathBuf; use crate::{ caps::completion_item_edit_resolve, diagnostics::DiagnosticsMapConfig, - line_index::OffsetEncoding, + line_index::PositionEncoding, lsp_ext::{self, supports_utf8, WorkspaceSymbolSearchKind, WorkspaceSymbolSearchScope}, }; @@ -948,11 +948,11 @@ impl Config { .is_some() } - pub fn offset_encoding(&self) -> OffsetEncoding { + pub fn position_encoding(&self) -> PositionEncoding { if supports_utf8(&self.caps) { - OffsetEncoding::Utf8 + PositionEncoding::Utf8 } else { - OffsetEncoding::Utf16 + PositionEncoding::Utf16 } } diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 74689fd8757..189ac2fbf53 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs @@ -8,7 +8,7 @@ use stdx::format_to; use vfs::{AbsPath, AbsPathBuf}; use crate::{ - global_state::GlobalStateSnapshot, line_index::OffsetEncoding, lsp_ext, + global_state::GlobalStateSnapshot, line_index::PositionEncoding, lsp_ext, to_proto::url_from_abs_path, }; @@ -66,17 +66,17 @@ fn location( let uri = url_from_abs_path(&file_name); let range = { - let offset_encoding = snap.config.offset_encoding(); + let position_encoding = snap.config.position_encoding(); lsp_types::Range::new( - position(&offset_encoding, span, span.line_start, span.column_start), - position(&offset_encoding, span, span.line_end, span.column_end), + position(&position_encoding, span, span.line_start, span.column_start), + position(&position_encoding, span, span.line_end, span.column_end), ) }; lsp_types::Location::new(uri, range) } fn position( - offset_encoding: &OffsetEncoding, + position_encoding: &PositionEncoding, span: &DiagnosticSpan, line_offset: usize, column_offset: usize, @@ -93,9 +93,9 @@ fn position( }; } let mut char_offset = 0; - let len_func = match offset_encoding { - OffsetEncoding::Utf8 => char::len_utf8, - OffsetEncoding::Utf16 => char::len_utf16, + let len_func = match position_encoding { + PositionEncoding::Utf8 => char::len_utf8, + PositionEncoding::Utf16 => char::len_utf16, }; for c in line.text.chars() { char_offset += 1; diff --git a/crates/rust-analyzer/src/from_proto.rs b/crates/rust-analyzer/src/from_proto.rs index f2db9a27334..936957bab48 100644 --- a/crates/rust-analyzer/src/from_proto.rs +++ b/crates/rust-analyzer/src/from_proto.rs @@ -8,7 +8,7 @@ use vfs::AbsPathBuf; use crate::{ from_json, global_state::GlobalStateSnapshot, - line_index::{LineIndex, OffsetEncoding}, + line_index::{LineIndex, PositionEncoding}, lsp_ext, lsp_utils::invalid_params_error, Result, @@ -25,10 +25,10 @@ pub(crate) fn vfs_path(url: &lsp_types::Url) -> Result { pub(crate) fn offset(line_index: &LineIndex, position: lsp_types::Position) -> Result { let line_col = match line_index.encoding { - OffsetEncoding::Utf8 => { + PositionEncoding::Utf8 => { LineCol { line: position.line as u32, col: position.character as u32 } } - OffsetEncoding::Utf16 => { + PositionEncoding::Utf16 => { let line_col = LineColUtf16 { line: position.line as u32, col: position.character as u32 }; line_index.index.to_utf8(line_col) diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 3fb06c31f7c..74277ff2e57 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -383,7 +383,7 @@ impl GlobalStateSnapshot { pub(crate) fn file_line_index(&self, file_id: FileId) -> Cancellable { let endings = self.vfs.read().1[&file_id]; let index = self.analysis.file_line_index(file_id)?; - let res = LineIndex { index, endings, encoding: self.config.offset_encoding() }; + let res = LineIndex { index, endings, encoding: self.config.position_encoding() }; Ok(res) } diff --git a/crates/rust-analyzer/src/line_index.rs b/crates/rust-analyzer/src/line_index.rs index c116414da01..0d424b91570 100644 --- a/crates/rust-analyzer/src/line_index.rs +++ b/crates/rust-analyzer/src/line_index.rs @@ -7,7 +7,7 @@ use std::sync::Arc; -pub enum OffsetEncoding { +pub enum PositionEncoding { Utf8, Utf16, } @@ -15,7 +15,7 @@ pub enum OffsetEncoding { pub(crate) struct LineIndex { pub(crate) index: Arc, pub(crate) endings: LineEndings, - pub(crate) encoding: OffsetEncoding, + pub(crate) encoding: PositionEncoding, } #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index e61c8b643d2..8cc5648f3ce 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs @@ -3,6 +3,7 @@ use std::{collections::HashMap, path::PathBuf}; use lsp_types::request::Request; +use lsp_types::PositionEncodingKind; use lsp_types::{ notification::Notification, CodeActionKind, DocumentOnTypeFormattingParams, PartialResultParams, Position, Range, TextDocumentIdentifier, WorkDoneProgressParams, @@ -455,7 +456,15 @@ pub(crate) enum CodeLensResolveData { } pub fn supports_utf8(caps: &lsp_types::ClientCapabilities) -> bool { - caps.offset_encoding.as_deref().unwrap_or_default().iter().any(|it| it == "utf-8") + match &caps.general { + Some(general) => general + .position_encodings + .as_deref() + .unwrap_or_default() + .iter() + .any(|it| it == &PositionEncodingKind::UTF8), + _ => false, + } } pub enum MoveItem {} diff --git a/crates/rust-analyzer/src/lsp_utils.rs b/crates/rust-analyzer/src/lsp_utils.rs index b3cea64d417..c6a4db9a453 100644 --- a/crates/rust-analyzer/src/lsp_utils.rs +++ b/crates/rust-analyzer/src/lsp_utils.rs @@ -6,7 +6,7 @@ use lsp_server::Notification; use crate::{ from_proto, global_state::GlobalState, - line_index::{LineEndings, LineIndex, OffsetEncoding}, + line_index::{LineEndings, LineIndex, PositionEncoding}, LspError, }; @@ -140,7 +140,7 @@ pub(crate) fn apply_document_changes( index: Arc::new(ide::LineIndex::new(old_text)), // We don't care about line endings or offset encoding here. endings: LineEndings::Unix, - encoding: OffsetEncoding::Utf16, + encoding: PositionEncoding::Utf16, }; // The changes we got must be applied sequentially, but can cross lines so we diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 5936454a7c5..6c84a2069cd 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -21,7 +21,7 @@ use crate::{ cargo_target_spec::CargoTargetSpec, config::{CallInfoConfig, Config}, global_state::GlobalStateSnapshot, - line_index::{LineEndings, LineIndex, OffsetEncoding}, + line_index::{LineEndings, LineIndex, PositionEncoding}, lsp_ext, lsp_utils::invalid_params_error, semantic_tokens, Result, @@ -30,8 +30,8 @@ use crate::{ pub(crate) fn position(line_index: &LineIndex, offset: TextSize) -> lsp_types::Position { let line_col = line_index.index.line_col(offset); match line_index.encoding { - OffsetEncoding::Utf8 => lsp_types::Position::new(line_col.line, line_col.col), - OffsetEncoding::Utf16 => { + PositionEncoding::Utf8 => lsp_types::Position::new(line_col.line, line_col.col), + PositionEncoding::Utf16 => { let line_col = line_index.index.to_utf16(line_col); lsp_types::Position::new(line_col.line, line_col.col) } @@ -1394,7 +1394,7 @@ fn main() { let line_index = LineIndex { index: Arc::new(ide::LineIndex::new(text)), endings: LineEndings::Unix, - encoding: OffsetEncoding::Utf16, + encoding: PositionEncoding::Utf16, }; let converted: Vec = folds.into_iter().map(|it| folding_range(text, &line_index, true, it)).collect(); diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 6d2c7d7b063..fe316fcae9b 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -1,5 +1,5 @@ $DIR/nested_impl_trait.rs:27:42 - | -LL | fn allowed_in_ret_type() -> impl Fn() -> impl Into { - | ^^^^^^^^^^^^^^ - error[E0277]: the trait bound `impl Debug: From>` is not satisfied --> $DIR/nested_impl_trait.rs:5:46 | @@ -64,7 +58,7 @@ LL | fn bad(x: impl Into) -> impl Into { x } = help: the trait `Into` is implemented for `T` = note: required for `impl Into` to implement `Into` -error: aborting due to 8 previous errors +error: aborting due to 7 previous errors Some errors have detailed explanations: E0277, E0562, E0666. For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/impl-trait/where-allowed.rs b/src/test/ui/impl-trait/where-allowed.rs index c1dd46c7ff7..d337ab422d7 100644 --- a/src/test/ui/impl-trait/where-allowed.rs +++ b/src/test/ui/impl-trait/where-allowed.rs @@ -39,9 +39,8 @@ fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } //~^ ERROR `impl Trait` only allowed in function and inherent method return types -// Disallowed +// Allowed fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types // Disallowed fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } @@ -57,9 +56,8 @@ fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } //~^ ERROR `impl Trait` only allowed in function and inherent method return types //~| ERROR nested `impl Trait` is not allowed -// Disallowed +// Allowed fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types // Disallowed fn in_Fn_parameter_in_generics (_: F) { panic!() } diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index 2e7c7ca40dd..1b704d0d924 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -1,5 +1,5 @@ error[E0666]: nested `impl Trait` is not allowed - --> $DIR/where-allowed.rs:47:51 + --> $DIR/where-allowed.rs:46:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | --------^^^^^^^^^^- @@ -8,7 +8,7 @@ LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/where-allowed.rs:56:57 + --> $DIR/where-allowed.rs:55:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | --------^^^^^^^^^^- @@ -17,7 +17,7 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic | outer `impl Trait` error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:119:16 + --> $DIR/where-allowed.rs:117:16 | LL | type Out = impl Debug; | ^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | type Out = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:154:23 + --> $DIR/where-allowed.rs:152:23 | LL | type InTypeAlias = impl Debug; | ^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | type InTypeAlias = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:157:39 + --> $DIR/where-allowed.rs:155:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ @@ -85,80 +85,68 @@ error[E0562]: `impl Trait` only allowed in function and inherent method return t LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:43:57 - | -LL | fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } - | ^^^^^^^^^^ - error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:47:51 + --> $DIR/where-allowed.rs:46:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:52:53 + --> $DIR/where-allowed.rs:51:53 | LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:56:57 + --> $DIR/where-allowed.rs:55:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:61:59 - | -LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } - | ^^^^^^^^^^ - error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:65:38 + --> $DIR/where-allowed.rs:63:38 | LL | fn in_Fn_parameter_in_generics (_: F) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:69:40 + --> $DIR/where-allowed.rs:67:40 | LL | fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:82:32 + --> $DIR/where-allowed.rs:80:32 | LL | struct InBraceStructField { x: impl Debug } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in path - --> $DIR/where-allowed.rs:86:41 + --> $DIR/where-allowed.rs:84:41 | LL | struct InAdtInBraceStructField { x: Vec } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:90:27 + --> $DIR/where-allowed.rs:88:27 | LL | struct InTupleStructField(impl Debug); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:95:25 + --> $DIR/where-allowed.rs:93:25 | LL | InBraceVariant { x: impl Debug }, | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:97:20 + --> $DIR/where-allowed.rs:95:20 | LL | InTupleVariant(impl Debug), | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return - --> $DIR/where-allowed.rs:108:23 + --> $DIR/where-allowed.rs:106:23 | LL | fn in_return() -> impl Debug; | ^^^^^^^^^^ @@ -167,7 +155,7 @@ LL | fn in_return() -> impl Debug; = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return - --> $DIR/where-allowed.rs:125:34 + --> $DIR/where-allowed.rs:123:34 | LL | fn in_trait_impl_return() -> impl Debug { () } | ^^^^^^^^^^ @@ -176,127 +164,127 @@ LL | fn in_trait_impl_return() -> impl Debug { () } = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` param - --> $DIR/where-allowed.rs:138:33 + --> $DIR/where-allowed.rs:136:33 | LL | fn in_foreign_parameters(_: impl Debug); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` return - --> $DIR/where-allowed.rs:141:31 + --> $DIR/where-allowed.rs:139:31 | LL | fn in_foreign_return() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return - --> $DIR/where-allowed.rs:157:39 + --> $DIR/where-allowed.rs:155:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait - --> $DIR/where-allowed.rs:162:16 + --> $DIR/where-allowed.rs:160:16 | LL | impl PartialEq for () { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:167:24 + --> $DIR/where-allowed.rs:165:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:172:6 + --> $DIR/where-allowed.rs:170:6 | LL | impl impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:178:24 + --> $DIR/where-allowed.rs:176:24 | LL | impl InInherentImplAdt { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:184:11 + --> $DIR/where-allowed.rs:182:11 | LL | where impl Debug: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:191:15 + --> $DIR/where-allowed.rs:189:15 | LL | where Vec: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bound - --> $DIR/where-allowed.rs:198:24 + --> $DIR/where-allowed.rs:196:24 | LL | where T: PartialEq | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:205:17 + --> $DIR/where-allowed.rs:203:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:212:22 + --> $DIR/where-allowed.rs:210:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:218:40 + --> $DIR/where-allowed.rs:216:40 | LL | struct InStructGenericParamDefault(T); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:222:36 + --> $DIR/where-allowed.rs:220:36 | LL | enum InEnumGenericParamDefault { Variant(T) } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:226:38 + --> $DIR/where-allowed.rs:224:38 | LL | trait InTraitGenericParamDefault {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:230:41 + --> $DIR/where-allowed.rs:228:41 | LL | type InTypeAliasGenericParamDefault = T; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:234:11 + --> $DIR/where-allowed.rs:232:11 | LL | impl T {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:241:40 + --> $DIR/where-allowed.rs:239:40 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding - --> $DIR/where-allowed.rs:247:29 + --> $DIR/where-allowed.rs:245:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in closure return - --> $DIR/where-allowed.rs:249:46 + --> $DIR/where-allowed.rs:247:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:234:7 + --> $DIR/where-allowed.rs:232:7 | LL | impl T {} | ^^^^^^^^^^^^^^ @@ -306,7 +294,7 @@ LL | impl T {} = note: `#[deny(invalid_type_param_default)]` on by default error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:241:36 + --> $DIR/where-allowed.rs:239:36 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^^^^^ @@ -315,14 +303,14 @@ LL | fn in_method_generic_param_default(_: T) {} = note: for more information, see issue #36887 error[E0118]: no nominal type found for inherent implementation - --> $DIR/where-allowed.rs:234:23 + --> $DIR/where-allowed.rs:232:23 | LL | impl T {} | ^ impl requires a nominal type | = note: either implement a trait on it or create a newtype to wrap it instead -error: aborting due to 49 previous errors +error: aborting due to 47 previous errors Some errors have detailed explanations: E0118, E0562, E0658, E0666. For more information about an error, try `rustc --explain E0118`. From 7a4ba2ffdee0e63fe62f7543589faec9ad29fb9c Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 23 Jun 2022 19:00:03 +0400 Subject: [PATCH 037/219] Add more tests for `impl Fn() -> impl Trait` --- .../ui/impl-trait/impl-fn-hrtb-bounds-2.rs | 7 +++++ .../impl-trait/impl-fn-hrtb-bounds-2.stderr | 11 ++++++++ src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs | 13 ++++++++++ .../ui/impl-trait/impl-fn-hrtb-bounds.stderr | 26 +++++++++++++++++++ .../impl-trait/impl-fn-parsing-ambiguities.rs | 14 ++++++++++ .../impl-fn-parsing-ambiguities.stderr | 26 +++++++++++++++++++ .../ui/impl-trait/impl_fn_associativity.rs | 9 +++++++ 7 files changed, 106 insertions(+) create mode 100644 src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.rs create mode 100644 src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr create mode 100644 src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs create mode 100644 src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr create mode 100644 src/test/ui/impl-trait/impl-fn-parsing-ambiguities.rs create mode 100644 src/test/ui/impl-trait/impl-fn-parsing-ambiguities.stderr diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.rs b/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.rs new file mode 100644 index 00000000000..688ae1da5e3 --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.rs @@ -0,0 +1,7 @@ +use std::fmt::Debug; + +fn a() -> impl Fn(&u8) -> impl Debug { + |x| x //~ ERROR lifetime may not live long enough +} + +fn main() {} diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr b/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr new file mode 100644 index 00000000000..57f618d11f9 --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr @@ -0,0 +1,11 @@ +error: lifetime may not live long enough + --> $DIR/impl-fn-hrtb-bounds-2.rs:4:9 + | +LL | |x| x + | -- ^ returning this value requires that `'1` must outlive `'2` + | || + | |return type of closure is &'2 u8 + | has type `&'1 u8` + +error: aborting due to previous error + diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs new file mode 100644 index 00000000000..f7d9430a226 --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs @@ -0,0 +1,13 @@ +use std::fmt::Debug; + +fn a() -> impl Fn(&u8) -> (impl Debug + '_) { + //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + |x| x +} + +fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { + //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + |x| x +} + +fn main() {} diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr new file mode 100644 index 00000000000..6fe4534d928 --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr @@ -0,0 +1,26 @@ +error: higher kinded lifetime bounds on nested opaque types are not supported yet + --> $DIR/impl-fn-hrtb-bounds.rs:3:41 + | +LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) { + | ^^ + | +note: lifetime declared here + --> $DIR/impl-fn-hrtb-bounds.rs:3:19 + | +LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) { + | ^ + +error: higher kinded lifetime bounds on nested opaque types are not supported yet + --> $DIR/impl-fn-hrtb-bounds.rs:8:52 + | +LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { + | ^^ + | +note: lifetime declared here + --> $DIR/impl-fn-hrtb-bounds.rs:8:20 + | +LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { + | ^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.rs b/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.rs new file mode 100644 index 00000000000..053912aa816 --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.rs @@ -0,0 +1,14 @@ +use std::fmt::Debug; + +fn a() -> impl Fn(&u8) -> impl Debug + '_ { + //~^ ERROR ambiguous `+` in a type + //~^^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + |x| x +} + +fn b() -> impl Fn() -> impl Debug + Send { + //~^ ERROR ambiguous `+` in a type + || () +} + +fn main() {} diff --git a/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.stderr b/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.stderr new file mode 100644 index 00000000000..e54864443ae --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.stderr @@ -0,0 +1,26 @@ +error: ambiguous `+` in a type + --> $DIR/impl-fn-parsing-ambiguities.rs:3:27 + | +LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { + | ^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + '_)` + +error: ambiguous `+` in a type + --> $DIR/impl-fn-parsing-ambiguities.rs:9:24 + | +LL | fn b() -> impl Fn() -> impl Debug + Send { + | ^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + Send)` + +error: higher kinded lifetime bounds on nested opaque types are not supported yet + --> $DIR/impl-fn-parsing-ambiguities.rs:3:40 + | +LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { + | ^^ + | +note: lifetime declared here + --> $DIR/impl-fn-parsing-ambiguities.rs:3:19 + | +LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { + | ^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/impl-trait/impl_fn_associativity.rs b/src/test/ui/impl-trait/impl_fn_associativity.rs index f5f1909cf58..6accaed98c9 100644 --- a/src/test/ui/impl-trait/impl_fn_associativity.rs +++ b/src/test/ui/impl-trait/impl_fn_associativity.rs @@ -9,8 +9,17 @@ fn ff_debug() -> impl Fn() -> impl Fn() -> impl Debug { || f_debug() } +fn multi() -> impl Fn() -> (impl Debug + Send) { + || () +} + fn main() { // Check that `ff_debug` is `() -> (() -> Debug)` and not `(() -> ()) -> Debug` let debug = ff_debug()()(); assert_eq!(format!("{:?}", debug), "()"); + + let x = multi()(); + assert_eq!(format!("{:?}", x), "()"); + fn assert_send(_: &impl Send) {} + assert_send(&x); } From 00f22771f6fb625fd66122fded49d5bee7083707 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 23 Jun 2022 19:12:13 +0400 Subject: [PATCH 038/219] Add even more tests for `impl Fn() -> impl Trait` --- src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs | 10 ++++++ .../ui/impl-trait/impl-fn-hrtb-bounds.stderr | 32 ++++++++++++++++++- .../impl-fn-predefined-lifetimes.rs | 12 +++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs index f7d9430a226..25144c09048 100644 --- a/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs @@ -10,4 +10,14 @@ fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { |x| x } +fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { + //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + |x| x +} + +fn d() -> impl Fn() -> (impl Debug + '_) { + //~^ ERROR missing lifetime specifier + || () +} + fn main() {} diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr index 6fe4534d928..6985c66df87 100644 --- a/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr @@ -22,5 +22,35 @@ note: lifetime declared here LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { | ^^ -error: aborting due to 2 previous errors +error: higher kinded lifetime bounds on nested opaque types are not supported yet + --> $DIR/impl-fn-hrtb-bounds.rs:13:52 + | +LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { + | ^^ + | +note: lifetime declared here + --> $DIR/impl-fn-hrtb-bounds.rs:13:20 + | +LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { + | ^^ +error[E0106]: missing lifetime specifier + --> $DIR/impl-fn-hrtb-bounds.rs:18:38 + | +LL | fn d() -> impl Fn() -> (impl Debug + '_) { + | ^^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | fn d() -> impl for<'a> Fn() -> (impl Debug + 'a) { + | +++++++ ~~ +help: consider using the `'static` lifetime + | +LL | fn d() -> impl Fn() -> (impl Debug + 'static) { + | ~~~~~~~ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs new file mode 100644 index 00000000000..e2f6e600da4 --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs @@ -0,0 +1,12 @@ +// check-pass +use std::fmt::Debug; + +fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { + |x| x +} + +fn _b<'a>() -> impl Fn(&'a u8) -> (impl Debug + 'a) { + a() +} + +fn main() {} From cc752f56650c123d702d027aeb154eafbe3fdd50 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Mon, 25 Jul 2022 01:54:47 +0400 Subject: [PATCH 039/219] Feature gate `impl_trait_in_fn_trait_return` --- compiler/rustc_ast_lowering/src/path.rs | 5 ++++- compiler/rustc_feature/src/active.rs | 2 ++ compiler/rustc_span/src/symbol.rs | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index 4b7ef960d4b..b7cda13fa4b 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -363,7 +363,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { // fn f(_: impl Fn() -> impl Debug) -> impl Fn() -> impl Debug // // disallowed --^^^^^^^^^^ allowed --^^^^^^^^^^ // ``` - FnRetTy::Ty(ty) if matches!(itctx, ImplTraitContext::ReturnPositionOpaqueTy { .. }) => { + FnRetTy::Ty(ty) + if matches!(itctx, ImplTraitContext::ReturnPositionOpaqueTy { .. }) + && self.tcx.features().impl_trait_in_fn_trait_return => + { self.lower_ty(&ty, itctx) } FnRetTy::Ty(ty) => { diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 1b8d683b133..5656409c0d4 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -414,6 +414,8 @@ declare_features! ( (active, half_open_range_patterns_in_slices, "CURRENT_RUSTC_VERSION", Some(67264), None), /// Allows `if let` guard in match arms. (active, if_let_guard, "1.47.0", Some(51114), None), + /// Allows `impl Trait` as output type in `Fn` traits in return position of functions. + (active, impl_trait_in_fn_trait_return, "1.64.0", Some(99697), None), /// Allows using imported `main` function (active, imported_main, "1.53.0", Some(28937), None), /// Allows associated types in inherent impls. diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 3fe79370c37..21016602ff8 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -813,6 +813,7 @@ symbols! { impl_lint_pass, impl_macros, impl_trait_in_bindings, + impl_trait_in_fn_trait_return, implied_by, import, import_name_type, From d116859ad78efa743726acd91d05d5a0bc64c0fe Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Fri, 29 Jul 2022 00:18:32 +0400 Subject: [PATCH 040/219] --bless --- .../ui/impl-trait/impl-fn-hrtb-bounds-2.rs | 3 +- .../impl-trait/impl-fn-hrtb-bounds-2.stderr | 12 +-- src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs | 1 + .../ui/impl-trait/impl-fn-hrtb-bounds.stderr | 79 ++++++++-------- .../impl-trait/impl-fn-parsing-ambiguities.rs | 1 + .../impl-fn-parsing-ambiguities.stderr | 8 +- .../impl-fn-predefined-lifetimes.rs | 3 +- .../impl-fn-predefined-lifetimes.stderr | 15 +++ .../ui/impl-trait/impl_fn_associativity.rs | 1 + src/test/ui/impl-trait/nested_impl_trait.rs | 1 + .../ui/impl-trait/nested_impl_trait.stderr | 14 +-- src/test/ui/impl-trait/where-allowed.rs | 1 + src/test/ui/impl-trait/where-allowed.stderr | 94 +++++++++---------- 13 files changed, 125 insertions(+), 108 deletions(-) create mode 100644 src/test/ui/impl-trait/impl-fn-predefined-lifetimes.stderr diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.rs b/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.rs index 688ae1da5e3..b0aeded0ef7 100644 --- a/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.rs +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.rs @@ -1,7 +1,8 @@ +#![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; fn a() -> impl Fn(&u8) -> impl Debug { - |x| x //~ ERROR lifetime may not live long enough + |x| x //~ ERROR hidden type for `impl Debug` captures lifetime that does not appear in bounds } fn main() {} diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr b/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr index 57f618d11f9..433b76b7afa 100644 --- a/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr @@ -1,11 +1,11 @@ -error: lifetime may not live long enough - --> $DIR/impl-fn-hrtb-bounds-2.rs:4:9 +error[E0700]: hidden type for `impl Debug` captures lifetime that does not appear in bounds + --> $DIR/impl-fn-hrtb-bounds-2.rs:5:9 | LL | |x| x - | -- ^ returning this value requires that `'1` must outlive `'2` - | || - | |return type of closure is &'2 u8 - | has type `&'1 u8` + | --- ^ + | | + | hidden type `&u8` captures the anonymous lifetime #1 defined here error: aborting due to previous error +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs index 25144c09048..527a4586fd7 100644 --- a/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs @@ -1,3 +1,4 @@ +#![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; fn a() -> impl Fn(&u8) -> (impl Debug + '_) { diff --git a/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr index 6985c66df87..443ffeb55cd 100644 --- a/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr +++ b/src/test/ui/impl-trait/impl-fn-hrtb-bounds.stderr @@ -1,56 +1,51 @@ -error: higher kinded lifetime bounds on nested opaque types are not supported yet - --> $DIR/impl-fn-hrtb-bounds.rs:3:41 - | -LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) { - | ^^ - | -note: lifetime declared here - --> $DIR/impl-fn-hrtb-bounds.rs:3:19 - | -LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) { - | ^ - -error: higher kinded lifetime bounds on nested opaque types are not supported yet - --> $DIR/impl-fn-hrtb-bounds.rs:8:52 - | -LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { - | ^^ - | -note: lifetime declared here - --> $DIR/impl-fn-hrtb-bounds.rs:8:20 - | -LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { - | ^^ - -error: higher kinded lifetime bounds on nested opaque types are not supported yet - --> $DIR/impl-fn-hrtb-bounds.rs:13:52 - | -LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { - | ^^ - | -note: lifetime declared here - --> $DIR/impl-fn-hrtb-bounds.rs:13:20 - | -LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { - | ^^ - error[E0106]: missing lifetime specifier - --> $DIR/impl-fn-hrtb-bounds.rs:18:38 + --> $DIR/impl-fn-hrtb-bounds.rs:19:38 | LL | fn d() -> impl Fn() -> (impl Debug + '_) { | ^^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from - = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html -help: consider making the bound lifetime-generic with a new `'a` lifetime - | -LL | fn d() -> impl for<'a> Fn() -> (impl Debug + 'a) { - | +++++++ ~~ help: consider using the `'static` lifetime | LL | fn d() -> impl Fn() -> (impl Debug + 'static) { | ~~~~~~~ +error: higher kinded lifetime bounds on nested opaque types are not supported yet + --> $DIR/impl-fn-hrtb-bounds.rs:4:41 + | +LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) { + | ^^ + | +note: lifetime declared here + --> $DIR/impl-fn-hrtb-bounds.rs:4:19 + | +LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) { + | ^ + +error: higher kinded lifetime bounds on nested opaque types are not supported yet + --> $DIR/impl-fn-hrtb-bounds.rs:9:52 + | +LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { + | ^^ + | +note: lifetime declared here + --> $DIR/impl-fn-hrtb-bounds.rs:9:20 + | +LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { + | ^^ + +error: higher kinded lifetime bounds on nested opaque types are not supported yet + --> $DIR/impl-fn-hrtb-bounds.rs:14:52 + | +LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { + | ^^ + | +note: lifetime declared here + --> $DIR/impl-fn-hrtb-bounds.rs:14:20 + | +LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { + | ^^ + error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.rs b/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.rs index 053912aa816..3e760710797 100644 --- a/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.rs +++ b/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.rs @@ -1,3 +1,4 @@ +#![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; fn a() -> impl Fn(&u8) -> impl Debug + '_ { diff --git a/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.stderr b/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.stderr index e54864443ae..cf6e5ef7bac 100644 --- a/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.stderr +++ b/src/test/ui/impl-trait/impl-fn-parsing-ambiguities.stderr @@ -1,23 +1,23 @@ error: ambiguous `+` in a type - --> $DIR/impl-fn-parsing-ambiguities.rs:3:27 + --> $DIR/impl-fn-parsing-ambiguities.rs:4:27 | LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { | ^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + '_)` error: ambiguous `+` in a type - --> $DIR/impl-fn-parsing-ambiguities.rs:9:24 + --> $DIR/impl-fn-parsing-ambiguities.rs:10:24 | LL | fn b() -> impl Fn() -> impl Debug + Send { | ^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + Send)` error: higher kinded lifetime bounds on nested opaque types are not supported yet - --> $DIR/impl-fn-parsing-ambiguities.rs:3:40 + --> $DIR/impl-fn-parsing-ambiguities.rs:4:40 | LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { | ^^ | note: lifetime declared here - --> $DIR/impl-fn-parsing-ambiguities.rs:3:19 + --> $DIR/impl-fn-parsing-ambiguities.rs:4:19 | LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { | ^ diff --git a/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs index e2f6e600da4..5e2379b2f9a 100644 --- a/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs +++ b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs @@ -1,7 +1,8 @@ -// check-pass +#![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { + //~^ ERROR hidden type for `impl Debug` captures lifetime that does not appear in bounds |x| x } diff --git a/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.stderr b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.stderr new file mode 100644 index 00000000000..1247ffad7c3 --- /dev/null +++ b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.stderr @@ -0,0 +1,15 @@ +error[E0700]: hidden type for `impl Debug` captures lifetime that does not appear in bounds + --> $DIR/impl-fn-predefined-lifetimes.rs:4:35 + | +LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { + | ^^^^^^^^^^^^^^^ + | +note: hidden type `&' u8` captures lifetime smaller than the function body + --> $DIR/impl-fn-predefined-lifetimes.rs:4:35 + | +LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/impl-trait/impl_fn_associativity.rs b/src/test/ui/impl-trait/impl_fn_associativity.rs index 6accaed98c9..71a8f9c7796 100644 --- a/src/test/ui/impl-trait/impl_fn_associativity.rs +++ b/src/test/ui/impl-trait/impl_fn_associativity.rs @@ -1,4 +1,5 @@ // run-pass +#![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; fn f_debug() -> impl Fn() -> impl Debug { diff --git a/src/test/ui/impl-trait/nested_impl_trait.rs b/src/test/ui/impl-trait/nested_impl_trait.rs index 9b0dbacaded..e95fab3b650 100644 --- a/src/test/ui/impl-trait/nested_impl_trait.rs +++ b/src/test/ui/impl-trait/nested_impl_trait.rs @@ -1,3 +1,4 @@ +#![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; fn fine(x: impl Into) -> impl Into { x } diff --git a/src/test/ui/impl-trait/nested_impl_trait.stderr b/src/test/ui/impl-trait/nested_impl_trait.stderr index e2ce7d15a06..9a8f5a34068 100644 --- a/src/test/ui/impl-trait/nested_impl_trait.stderr +++ b/src/test/ui/impl-trait/nested_impl_trait.stderr @@ -1,5 +1,5 @@ error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:5:56 + --> $DIR/nested_impl_trait.rs:6:56 | LL | fn bad_in_ret_position(x: impl Into) -> impl Into { x } | ----------^^^^^^^^^^- @@ -8,7 +8,7 @@ LL | fn bad_in_ret_position(x: impl Into) -> impl Into { x } | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:9:42 + --> $DIR/nested_impl_trait.rs:10:42 | LL | fn bad_in_fn_syntax(x: fn() -> impl Into) {} | ----------^^^^^^^^^^- @@ -17,7 +17,7 @@ LL | fn bad_in_fn_syntax(x: fn() -> impl Into) {} | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:13:37 + --> $DIR/nested_impl_trait.rs:14:37 | LL | fn bad_in_arg_position(_: impl Into) { } | ----------^^^^^^^^^^- @@ -26,7 +26,7 @@ LL | fn bad_in_arg_position(_: impl Into) { } | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:18:44 + --> $DIR/nested_impl_trait.rs:19:44 | LL | fn bad(x: impl Into) -> impl Into { x } | ----------^^^^^^^^^^- @@ -35,13 +35,13 @@ LL | fn bad(x: impl Into) -> impl Into { x } | outer `impl Trait` error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return - --> $DIR/nested_impl_trait.rs:9:32 + --> $DIR/nested_impl_trait.rs:10:32 | LL | fn bad_in_fn_syntax(x: fn() -> impl Into) {} | ^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `impl Debug: From>` is not satisfied - --> $DIR/nested_impl_trait.rs:5:46 + --> $DIR/nested_impl_trait.rs:6:46 | LL | fn bad_in_ret_position(x: impl Into) -> impl Into { x } | ^^^^^^^^^^^^^^^^^^^^^ the trait `From>` is not implemented for `impl Debug` @@ -50,7 +50,7 @@ LL | fn bad_in_ret_position(x: impl Into) -> impl Into { x } = note: required for `impl Into` to implement `Into` error[E0277]: the trait bound `impl Debug: From>` is not satisfied - --> $DIR/nested_impl_trait.rs:18:34 + --> $DIR/nested_impl_trait.rs:19:34 | LL | fn bad(x: impl Into) -> impl Into { x } | ^^^^^^^^^^^^^^^^^^^^^ the trait `From>` is not implemented for `impl Debug` diff --git a/src/test/ui/impl-trait/where-allowed.rs b/src/test/ui/impl-trait/where-allowed.rs index d337ab422d7..ff63b04c268 100644 --- a/src/test/ui/impl-trait/where-allowed.rs +++ b/src/test/ui/impl-trait/where-allowed.rs @@ -1,5 +1,6 @@ //! A simple test for testing many permutations of allowedness of //! impl Trait +#![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; // Allowed diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index 1b704d0d924..3ad0a9f9d5c 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -1,5 +1,5 @@ error[E0666]: nested `impl Trait` is not allowed - --> $DIR/where-allowed.rs:46:51 + --> $DIR/where-allowed.rs:47:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | --------^^^^^^^^^^- @@ -8,7 +8,7 @@ LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/where-allowed.rs:55:57 + --> $DIR/where-allowed.rs:56:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | --------^^^^^^^^^^- @@ -17,7 +17,7 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic | outer `impl Trait` error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:117:16 + --> $DIR/where-allowed.rs:118:16 | LL | type Out = impl Debug; | ^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | type Out = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:152:23 + --> $DIR/where-allowed.rs:153:23 | LL | type InTypeAlias = impl Debug; | ^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | type InTypeAlias = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:155:39 + --> $DIR/where-allowed.rs:156:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ @@ -44,109 +44,109 @@ LL | type InReturnInTypeAlias = fn() -> impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer param - --> $DIR/where-allowed.rs:15:40 + --> $DIR/where-allowed.rs:16:40 | LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return - --> $DIR/where-allowed.rs:19:42 + --> $DIR/where-allowed.rs:20:42 | LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer param - --> $DIR/where-allowed.rs:23:38 + --> $DIR/where-allowed.rs:24:38 | LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return - --> $DIR/where-allowed.rs:27:40 + --> $DIR/where-allowed.rs:28:40 | LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:31:49 + --> $DIR/where-allowed.rs:32:49 | LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:35:51 + --> $DIR/where-allowed.rs:36:51 | LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:39:55 + --> $DIR/where-allowed.rs:40:55 | LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:46:51 + --> $DIR/where-allowed.rs:47:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:51:53 + --> $DIR/where-allowed.rs:52:53 | LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:55:57 + --> $DIR/where-allowed.rs:56:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:63:38 + --> $DIR/where-allowed.rs:64:38 | LL | fn in_Fn_parameter_in_generics (_: F) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:67:40 + --> $DIR/where-allowed.rs:68:40 | LL | fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:80:32 + --> $DIR/where-allowed.rs:81:32 | LL | struct InBraceStructField { x: impl Debug } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in path - --> $DIR/where-allowed.rs:84:41 + --> $DIR/where-allowed.rs:85:41 | LL | struct InAdtInBraceStructField { x: Vec } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:88:27 + --> $DIR/where-allowed.rs:89:27 | LL | struct InTupleStructField(impl Debug); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:93:25 + --> $DIR/where-allowed.rs:94:25 | LL | InBraceVariant { x: impl Debug }, | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:95:20 + --> $DIR/where-allowed.rs:96:20 | LL | InTupleVariant(impl Debug), | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return - --> $DIR/where-allowed.rs:106:23 + --> $DIR/where-allowed.rs:107:23 | LL | fn in_return() -> impl Debug; | ^^^^^^^^^^ @@ -155,7 +155,7 @@ LL | fn in_return() -> impl Debug; = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return - --> $DIR/where-allowed.rs:123:34 + --> $DIR/where-allowed.rs:124:34 | LL | fn in_trait_impl_return() -> impl Debug { () } | ^^^^^^^^^^ @@ -164,127 +164,127 @@ LL | fn in_trait_impl_return() -> impl Debug { () } = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` param - --> $DIR/where-allowed.rs:136:33 + --> $DIR/where-allowed.rs:137:33 | LL | fn in_foreign_parameters(_: impl Debug); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` return - --> $DIR/where-allowed.rs:139:31 + --> $DIR/where-allowed.rs:140:31 | LL | fn in_foreign_return() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return - --> $DIR/where-allowed.rs:155:39 + --> $DIR/where-allowed.rs:156:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait - --> $DIR/where-allowed.rs:160:16 + --> $DIR/where-allowed.rs:161:16 | LL | impl PartialEq for () { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:165:24 + --> $DIR/where-allowed.rs:166:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:170:6 + --> $DIR/where-allowed.rs:171:6 | LL | impl impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:176:24 + --> $DIR/where-allowed.rs:177:24 | LL | impl InInherentImplAdt { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:182:11 + --> $DIR/where-allowed.rs:183:11 | LL | where impl Debug: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:189:15 + --> $DIR/where-allowed.rs:190:15 | LL | where Vec: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bound - --> $DIR/where-allowed.rs:196:24 + --> $DIR/where-allowed.rs:197:24 | LL | where T: PartialEq | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:203:17 + --> $DIR/where-allowed.rs:204:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:210:22 + --> $DIR/where-allowed.rs:211:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:216:40 + --> $DIR/where-allowed.rs:217:40 | LL | struct InStructGenericParamDefault(T); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:220:36 + --> $DIR/where-allowed.rs:221:36 | LL | enum InEnumGenericParamDefault { Variant(T) } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:224:38 + --> $DIR/where-allowed.rs:225:38 | LL | trait InTraitGenericParamDefault {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:228:41 + --> $DIR/where-allowed.rs:229:41 | LL | type InTypeAliasGenericParamDefault = T; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:232:11 + --> $DIR/where-allowed.rs:233:11 | LL | impl T {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:239:40 + --> $DIR/where-allowed.rs:240:40 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding - --> $DIR/where-allowed.rs:245:29 + --> $DIR/where-allowed.rs:246:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in closure return - --> $DIR/where-allowed.rs:247:46 + --> $DIR/where-allowed.rs:248:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:232:7 + --> $DIR/where-allowed.rs:233:7 | LL | impl T {} | ^^^^^^^^^^^^^^ @@ -294,7 +294,7 @@ LL | impl T {} = note: `#[deny(invalid_type_param_default)]` on by default error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:239:36 + --> $DIR/where-allowed.rs:240:36 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^^^^^ @@ -303,7 +303,7 @@ LL | fn in_method_generic_param_default(_: T) {} = note: for more information, see issue #36887 error[E0118]: no nominal type found for inherent implementation - --> $DIR/where-allowed.rs:232:23 + --> $DIR/where-allowed.rs:233:23 | LL | impl T {} | ^ impl requires a nominal type From 690e0370081d39c2a4c459e5fd74a6e3728b73a9 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Fri, 29 Jul 2022 02:28:36 +0400 Subject: [PATCH 041/219] add a test for gate `impl_trait_in_fn_trait_return` --- .../feature-gate-impl_trait_in_fn_trait_return.rs | 6 ++++++ ...ture-gate-impl_trait_in_fn_trait_return.stderr | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs create mode 100644 src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr diff --git a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs new file mode 100644 index 00000000000..0db8088f7ee --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs @@ -0,0 +1,6 @@ +fn f() -> impl Fn() -> impl Sized { || () } +//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +fn g() -> &'static dyn Fn() -> impl Sized { &|| () } +//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr new file mode 100644 index 00000000000..c485bc5c3ab --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr @@ -0,0 +1,15 @@ +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return + --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:1:24 + | +LL | fn f() -> impl Fn() -> impl Sized { || () } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return + --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:3:32 + | +LL | fn g() -> &'static dyn Fn() -> impl Sized { &|| () } + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0562`. From e93982a78fc7725f4fd01c39b2c48b6a2028893f Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Tue, 25 Oct 2022 13:47:43 +0000 Subject: [PATCH 042/219] adopt to compiler changes --- compiler/rustc_ast_lowering/src/path.rs | 2 +- .../impl-fn-predefined-lifetimes.rs | 4 ++- .../impl-fn-predefined-lifetimes.stderr | 29 ++++++++++++------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index b7cda13fa4b..c6955741fd4 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -346,7 +346,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { fn lower_parenthesized_parameter_data( &mut self, data: &ParenthesizedArgs, - itctx: ImplTraitContext, + itctx: &ImplTraitContext, ) -> (GenericArgsCtor<'hir>, bool) { // Switch to `PassThrough` mode for anonymous lifetimes; this // means that we permit things like `&Ref`, where `Ref` has diff --git a/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs index 5e2379b2f9a..15778662375 100644 --- a/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs +++ b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs @@ -2,8 +2,10 @@ use std::fmt::Debug; fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { - //~^ ERROR hidden type for `impl Debug` captures lifetime that does not appear in bounds + //~^ ERROR cannot resolve opaque type + |x| x + //~^ ERROR concrete type differs from previous defining opaque type use } fn _b<'a>() -> impl Fn(&'a u8) -> (impl Debug + 'a) { diff --git a/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.stderr b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.stderr index 1247ffad7c3..7747319c153 100644 --- a/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.stderr +++ b/src/test/ui/impl-trait/impl-fn-predefined-lifetimes.stderr @@ -1,15 +1,24 @@ -error[E0700]: hidden type for `impl Debug` captures lifetime that does not appear in bounds +error: concrete type differs from previous defining opaque type use + --> $DIR/impl-fn-predefined-lifetimes.rs:7:9 + | +LL | |x| x + | ^ expected `impl Debug + '_`, got `&u8` + | +note: previous use here + --> $DIR/impl-fn-predefined-lifetimes.rs:7:5 + | +LL | |x| x + | ^^^^^ + +error[E0720]: cannot resolve opaque type --> $DIR/impl-fn-predefined-lifetimes.rs:4:35 | LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { - | ^^^^^^^^^^^^^^^ - | -note: hidden type `&' u8` captures lifetime smaller than the function body - --> $DIR/impl-fn-predefined-lifetimes.rs:4:35 - | -LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ recursive opaque type +... +LL | |x| x + | ----- returning here with type `[closure@$DIR/impl-fn-predefined-lifetimes.rs:7:5: 7:8]` -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0700`. +For more information about this error, try `rustc --explain E0720`. From 67f1d8fe2cfc3da4170cd031e835404811734df5 Mon Sep 17 00:00:00 2001 From: Ryo Yoshida Date: Tue, 25 Oct 2022 21:20:16 +0900 Subject: [PATCH 043/219] Test all generic args for trait when finding matching impl --- crates/hir-ty/src/method_resolution.rs | 82 +++++++++++++++++--------- crates/hir/src/source_analyzer.rs | 58 ++++++++---------- crates/ide/src/goto_definition.rs | 82 ++++++++++++++++++++++++++ 3 files changed, 158 insertions(+), 64 deletions(-) diff --git a/crates/hir-ty/src/method_resolution.rs b/crates/hir-ty/src/method_resolution.rs index 6d3df34746e..b1178ba0d2a 100644 --- a/crates/hir-ty/src/method_resolution.rs +++ b/crates/hir-ty/src/method_resolution.rs @@ -22,10 +22,10 @@ use crate::{ from_foreign_def_id, infer::{unify::InferenceTable, Adjust, Adjustment, AutoBorrow, OverloadedDeref, PointerCast}, primitive::{FloatTy, IntTy, UintTy}, - static_lifetime, + static_lifetime, to_chalk_trait_id, utils::all_super_traits, AdtId, Canonical, CanonicalVarKinds, DebruijnIndex, ForeignDefId, InEnvironment, Interner, - Scalar, TraitEnvironment, TraitRefExt, Ty, TyBuilder, TyExt, TyKind, + Scalar, Substitution, TraitEnvironment, TraitRef, TraitRefExt, Ty, TyBuilder, TyExt, TyKind, }; /// This is used as a key for indexing impls. @@ -624,52 +624,76 @@ pub(crate) fn iterate_method_candidates( slot } +/// Looks up the impl method that actually runs for the trait method `func`. +/// +/// Returns `func` if it's not a method defined in a trait or the lookup failed. pub fn lookup_impl_method( - self_ty: &Ty, db: &dyn HirDatabase, env: Arc, - trait_: TraitId, + func: FunctionId, + fn_subst: Substitution, +) -> FunctionId { + let trait_id = match func.lookup(db.upcast()).container { + ItemContainerId::TraitId(id) => id, + _ => return func, + }; + let trait_params = db.generic_params(trait_id.into()).type_or_consts.len(); + let fn_params = fn_subst.len(Interner) - trait_params; + let trait_ref = TraitRef { + trait_id: to_chalk_trait_id(trait_id), + substitution: Substitution::from_iter(Interner, fn_subst.iter(Interner).skip(fn_params)), + }; + + let name = &db.function_data(func).name; + lookup_impl_method_for_trait_ref(trait_ref, db, env, name).unwrap_or(func) +} + +fn lookup_impl_method_for_trait_ref( + trait_ref: TraitRef, + db: &dyn HirDatabase, + env: Arc, name: &Name, ) -> Option { - let self_ty_fp = TyFingerprint::for_trait_impl(self_ty)?; - let trait_impls = db.trait_impls_in_deps(env.krate); - let impls = trait_impls.for_trait_and_self_ty(trait_, self_ty_fp); - let mut table = InferenceTable::new(db, env.clone()); - find_matching_impl(impls, &mut table, &self_ty).and_then(|data| { - data.items.iter().find_map(|it| match it { - AssocItemId::FunctionId(f) => (db.function_data(*f).name == *name).then(|| *f), - _ => None, - }) + let self_ty = trait_ref.self_type_parameter(Interner); + let self_ty_fp = TyFingerprint::for_trait_impl(&self_ty)?; + let impls = db.trait_impls_in_deps(env.krate); + let impls = impls.for_trait_and_self_ty(trait_ref.hir_trait_id(), self_ty_fp); + + let table = InferenceTable::new(db, env); + + let impl_data = find_matching_impl(impls, table, trait_ref)?; + impl_data.items.iter().find_map(|it| match it { + AssocItemId::FunctionId(f) => (db.function_data(*f).name == *name).then(|| *f), + _ => None, }) } fn find_matching_impl( mut impls: impl Iterator, - table: &mut InferenceTable<'_>, - self_ty: &Ty, + mut table: InferenceTable<'_>, + actual_trait_ref: TraitRef, ) -> Option> { let db = table.db; loop { let impl_ = impls.next()?; let r = table.run_in_snapshot(|table| { let impl_data = db.impl_data(impl_); - let substs = + let impl_substs = TyBuilder::subst_for_def(db, impl_, None).fill_with_inference_vars(table).build(); - let impl_ty = db.impl_self_ty(impl_).substitute(Interner, &substs); + let trait_ref = db + .impl_trait(impl_) + .expect("non-trait method in find_matching_impl") + .substitute(Interner, &impl_substs); - table - .unify(self_ty, &impl_ty) - .then(|| { - let wh_goals = - crate::chalk_db::convert_where_clauses(db, impl_.into(), &substs) - .into_iter() - .map(|b| b.cast(Interner)); + if !table.unify(&trait_ref, &actual_trait_ref) { + return None; + } - let goal = crate::Goal::all(Interner, wh_goals); - - table.try_obligation(goal).map(|_| impl_data) - }) - .flatten() + let wcs = crate::chalk_db::convert_where_clauses(db, impl_.into(), &impl_substs) + .into_iter() + .map(|b| b.cast(Interner)); + let goal = crate::Goal::all(Interner, wcs); + table.try_obligation(goal).map(|_| impl_data) }); if r.is_some() { break r; diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index 9ec52282829..f86c5710053 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -270,7 +270,7 @@ impl SourceAnalyzer { let expr_id = self.expr_id(db, &call.clone().into())?; let (f_in_trait, substs) = self.infer.as_ref()?.method_resolution(expr_id)?; - Some(self.resolve_impl_method_or_trait_def(db, f_in_trait, &substs)) + Some(self.resolve_impl_method_or_trait_def(db, f_in_trait, substs)) } pub(crate) fn resolve_await_to_poll( @@ -311,7 +311,7 @@ impl SourceAnalyzer { // HACK: subst for `poll()` coincides with that for `Future` because `poll()` itself // doesn't have any generic parameters, so we skip building another subst for `poll()`. let substs = hir_ty::TyBuilder::subst_for_def(db, future_trait, None).push(ty).build(); - Some(self.resolve_impl_method_or_trait_def(db, poll_fn, &substs)) + Some(self.resolve_impl_method_or_trait_def(db, poll_fn, substs)) } pub(crate) fn resolve_prefix_expr( @@ -331,7 +331,7 @@ impl SourceAnalyzer { // don't have any generic parameters, so we skip building another subst for the methods. let substs = hir_ty::TyBuilder::subst_for_def(db, op_trait, None).push(ty.clone()).build(); - Some(self.resolve_impl_method_or_trait_def(db, op_fn, &substs)) + Some(self.resolve_impl_method_or_trait_def(db, op_fn, substs)) } pub(crate) fn resolve_index_expr( @@ -351,7 +351,7 @@ impl SourceAnalyzer { .push(base_ty.clone()) .push(index_ty.clone()) .build(); - Some(self.resolve_impl_method_or_trait_def(db, op_fn, &substs)) + Some(self.resolve_impl_method_or_trait_def(db, op_fn, substs)) } pub(crate) fn resolve_bin_expr( @@ -372,7 +372,7 @@ impl SourceAnalyzer { .push(rhs.clone()) .build(); - Some(self.resolve_impl_method_or_trait_def(db, op_fn, &substs)) + Some(self.resolve_impl_method_or_trait_def(db, op_fn, substs)) } pub(crate) fn resolve_try_expr( @@ -392,7 +392,7 @@ impl SourceAnalyzer { // doesn't have any generic parameters, so we skip building another subst for `branch()`. let substs = hir_ty::TyBuilder::subst_for_def(db, op_trait, None).push(ty.clone()).build(); - Some(self.resolve_impl_method_or_trait_def(db, op_fn, &substs)) + Some(self.resolve_impl_method_or_trait_def(db, op_fn, substs)) } pub(crate) fn resolve_field( @@ -497,9 +497,12 @@ impl SourceAnalyzer { None => assoc, Some(func_ty) => { if let TyKind::FnDef(_fn_def, subs) = func_ty.kind(Interner) { - self.resolve_impl_method(db, f_in_trait, subs) - .map(AssocItemId::FunctionId) - .unwrap_or(assoc) + self.resolve_impl_method_or_trait_def( + db, + f_in_trait, + subs.clone(), + ) + .into() } else { assoc } @@ -779,37 +782,22 @@ impl SourceAnalyzer { false } - fn resolve_impl_method( - &self, - db: &dyn HirDatabase, - func: FunctionId, - substs: &Substitution, - ) -> Option { - let impled_trait = match func.lookup(db.upcast()).container { - ItemContainerId::TraitId(trait_id) => trait_id, - _ => return None, - }; - if substs.is_empty(Interner) { - return None; - } - let self_ty = substs.at(Interner, 0).ty(Interner)?; - let krate = self.resolver.krate(); - let trait_env = self.resolver.body_owner()?.as_generic_def_id().map_or_else( - || Arc::new(hir_ty::TraitEnvironment::empty(krate)), - |d| db.trait_environment(d), - ); - - let fun_data = db.function_data(func); - method_resolution::lookup_impl_method(self_ty, db, trait_env, impled_trait, &fun_data.name) - } - fn resolve_impl_method_or_trait_def( &self, db: &dyn HirDatabase, func: FunctionId, - substs: &Substitution, + substs: Substitution, ) -> FunctionId { - self.resolve_impl_method(db, func, substs).unwrap_or(func) + let krate = self.resolver.krate(); + let owner = match self.resolver.body_owner() { + Some(it) => it, + None => return func, + }; + let env = owner.as_generic_def_id().map_or_else( + || Arc::new(hir_ty::TraitEnvironment::empty(krate)), + |d| db.trait_environment(d), + ); + method_resolution::lookup_impl_method(db, env, func, substs) } fn lang_trait_fn( diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs index d0be1b3f404..f97c67b144a 100644 --- a/crates/ide/src/goto_definition.rs +++ b/crates/ide/src/goto_definition.rs @@ -1834,4 +1834,86 @@ fn f() { "#, ); } + + #[test] + fn goto_bin_op_multiple_impl() { + check( + r#" +//- minicore: add +struct S; +impl core::ops::Add for S { + fn add( + //^^^ + ) {} +} +impl core::ops::Add for S { + fn add( + ) {} +} + +fn f() { + S +$0 S +} +"#, + ); + + check( + r#" +//- minicore: add +struct S; +impl core::ops::Add for S { + fn add( + ) {} +} +impl core::ops::Add for S { + fn add( + //^^^ + ) {} +} + +fn f() { + S +$0 0usize +} +"#, + ); + } + + #[test] + fn path_call_multiple_trait_impl() { + check( + r#" +trait Trait { + fn f(_: T); +} +impl Trait for usize { + fn f(_: i32) {} + //^ +} +impl Trait for usize { + fn f(_: i64) {} +} +fn main() { + usize::f$0(0i32); +} +"#, + ); + + check( + r#" +trait Trait { + fn f(_: T); +} +impl Trait for usize { + fn f(_: i32) {} +} +impl Trait for usize { + fn f(_: i64) {} + //^ +} +fn main() { + usize::f$0(0i64); +} +"#, + ) + } } From be61f0237b95083d26ce32fb0934dd42caf6ea07 Mon Sep 17 00:00:00 2001 From: Byron Zhong Date: Tue, 25 Oct 2022 01:14:39 -0500 Subject: [PATCH 044/219] Add Span in TypoSuggestion and TypoCandidate --- compiler/rustc_resolve/src/diagnostics.rs | 45 +++++++++++++------ .../rustc_resolve/src/late/diagnostics.rs | 24 ++++------ 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 5d868ebec94..5029c339963 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -58,16 +58,32 @@ pub(crate) enum SuggestionTarget { #[derive(Debug)] pub(crate) struct TypoSuggestion { pub candidate: Symbol, + /// The source location where the name is defined; None if the name is not defined + /// in source e.g. primitives + pub span: Option, pub res: Res, pub target: SuggestionTarget, } impl TypoSuggestion { - pub(crate) fn typo_from_res(candidate: Symbol, res: Res) -> TypoSuggestion { - Self { candidate, res, target: SuggestionTarget::SimilarlyNamed } + pub(crate) fn typo_from_ident(ident: Ident, res: Res) -> TypoSuggestion { + Self { + candidate: ident.name, + span: Some(ident.span), + res, + target: SuggestionTarget::SimilarlyNamed, + } } - pub(crate) fn single_item_from_res(candidate: Symbol, res: Res) -> TypoSuggestion { - Self { candidate, res, target: SuggestionTarget::SingleItem } + pub(crate) fn typo_from_name(candidate: Symbol, res: Res) -> TypoSuggestion { + Self { candidate, span: None, res, target: SuggestionTarget::SimilarlyNamed } + } + pub(crate) fn single_item_from_ident(ident: Ident, res: Res) -> TypoSuggestion { + Self { + candidate: ident.name, + span: Some(ident.span), + res, + target: SuggestionTarget::SingleItem, + } } } @@ -490,7 +506,7 @@ impl<'a> Resolver<'a> { if let Some(binding) = resolution.borrow().binding { let res = binding.res(); if filter_fn(res) && ctxt.map_or(true, |ctxt| ctxt == key.ident.span.ctxt()) { - names.push(TypoSuggestion::typo_from_res(key.ident.name, res)); + names.push(TypoSuggestion::typo_from_ident(key.ident, res)); } } } @@ -1145,7 +1161,7 @@ impl<'a> Resolver<'a> { .get(&expn_id) .into_iter() .flatten() - .map(|ident| TypoSuggestion::typo_from_res(ident.name, res)), + .map(|ident| TypoSuggestion::typo_from_ident(*ident, res)), ); } } @@ -1164,7 +1180,7 @@ impl<'a> Resolver<'a> { suggestions.extend( ext.helper_attrs .iter() - .map(|name| TypoSuggestion::typo_from_res(*name, res)), + .map(|name| TypoSuggestion::typo_from_name(*name, res)), ); } } @@ -1174,8 +1190,8 @@ impl<'a> Resolver<'a> { if let MacroRulesScope::Binding(macro_rules_binding) = macro_rules_scope.get() { let res = macro_rules_binding.binding.res(); if filter_fn(res) { - suggestions.push(TypoSuggestion::typo_from_res( - macro_rules_binding.ident.name, + suggestions.push(TypoSuggestion::typo_from_ident( + macro_rules_binding.ident, res, )) } @@ -1193,7 +1209,7 @@ impl<'a> Resolver<'a> { suggestions.extend(this.macro_use_prelude.iter().filter_map( |(name, binding)| { let res = binding.res(); - filter_fn(res).then_some(TypoSuggestion::typo_from_res(*name, res)) + filter_fn(res).then_some(TypoSuggestion::typo_from_name(*name, res)) }, )); } @@ -1203,14 +1219,14 @@ impl<'a> Resolver<'a> { suggestions.extend( BUILTIN_ATTRIBUTES .iter() - .map(|attr| TypoSuggestion::typo_from_res(attr.name, res)), + .map(|attr| TypoSuggestion::typo_from_name(attr.name, res)), ); } } Scope::ExternPrelude => { suggestions.extend(this.extern_prelude.iter().filter_map(|(ident, _)| { let res = Res::Def(DefKind::Mod, CRATE_DEF_ID.to_def_id()); - filter_fn(res).then_some(TypoSuggestion::typo_from_res(ident.name, res)) + filter_fn(res).then_some(TypoSuggestion::typo_from_ident(*ident, res)) })); } Scope::ToolPrelude => { @@ -1218,7 +1234,7 @@ impl<'a> Resolver<'a> { suggestions.extend( this.registered_tools .iter() - .map(|ident| TypoSuggestion::typo_from_res(ident.name, res)), + .map(|ident| TypoSuggestion::typo_from_ident(*ident, res)), ); } Scope::StdLibPrelude => { @@ -1235,7 +1251,8 @@ impl<'a> Resolver<'a> { Scope::BuiltinTypes => { suggestions.extend(PrimTy::ALL.iter().filter_map(|prim_ty| { let res = Res::PrimTy(*prim_ty); - filter_fn(res).then_some(TypoSuggestion::typo_from_res(prim_ty.name(), res)) + filter_fn(res) + .then_some(TypoSuggestion::typo_from_name(prim_ty.name(), res)) })) } } diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 850f023b1c1..8da09489b1f 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -150,7 +150,7 @@ struct BaseError { #[derive(Debug)] enum TypoCandidate { Typo(TypoSuggestion), - Shadowed(Res), + Shadowed(Res, Option), None, } @@ -158,7 +158,7 @@ impl TypoCandidate { fn to_opt_suggestion(self) -> Option { match self { TypoCandidate::Typo(sugg) => Some(sugg), - TypoCandidate::Shadowed(_) | TypoCandidate::None => None, + TypoCandidate::Shadowed(_, _) | TypoCandidate::None => None, } } } @@ -691,10 +691,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { let is_expected = &|res| source.is_expected(res); let ident_span = path.last().map_or(span, |ident| ident.ident.span); let typo_sugg = self.lookup_typo_candidate(path, source.namespace(), is_expected); - if let TypoCandidate::Shadowed(res) = typo_sugg - && let Some(id) = res.opt_def_id() - && let Some(sugg_span) = self.r.opt_span(id) - { + if let TypoCandidate::Shadowed(res, Some(sugg_span)) = typo_sugg { err.span_label( sugg_span, format!("you might have meant to refer to this {}", res.descr()), @@ -973,10 +970,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { .collect(); if targets.len() == 1 { let target = targets[0]; - return Some(TypoSuggestion::single_item_from_res( - target.0.ident.name, - target.1, - )); + return Some(TypoSuggestion::single_item_from_ident(target.0.ident, target.1)); } } } @@ -1618,7 +1612,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { // Locals and type parameters for (ident, &res) in &rib.bindings { if filter_fn(res) && ident.span.ctxt() == rib_ctxt { - names.push(TypoSuggestion::typo_from_res(ident.name, res)); + names.push(TypoSuggestion::typo_from_ident(*ident, res)); } } @@ -1647,9 +1641,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { Res::Def(DefKind::Mod, crate_id.as_def_id()); if filter_fn(crate_mod) { - Some(TypoSuggestion::typo_from_res( - ident.name, crate_mod, - )) + Some(TypoSuggestion::typo_from_ident(*ident, crate_mod)) } else { None } @@ -1668,7 +1660,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { // Add primitive types to the mix if filter_fn(Res::PrimTy(PrimTy::Bool)) { names.extend(PrimTy::ALL.iter().map(|prim_ty| { - TypoSuggestion::typo_from_res(prim_ty.name(), Res::PrimTy(*prim_ty)) + TypoSuggestion::typo_from_name(prim_ty.name(), Res::PrimTy(*prim_ty)) })) } } else { @@ -1695,7 +1687,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { return TypoCandidate::None; }; if found == name { - TypoCandidate::Shadowed(sugg.res) + TypoCandidate::Shadowed(sugg.res, sugg.span) } else { TypoCandidate::Typo(sugg) } From 0b936d2da702848a4d537e745921636490e93060 Mon Sep 17 00:00:00 2001 From: Byron Zhong Date: Tue, 25 Oct 2022 12:35:04 -0500 Subject: [PATCH 045/219] Add check to only output 'you might have meant' when the candidate name is in the same crate --- compiler/rustc_resolve/src/late/diagnostics.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 8da09489b1f..dfbd982bb7c 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -691,7 +691,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { let is_expected = &|res| source.is_expected(res); let ident_span = path.last().map_or(span, |ident| ident.ident.span); let typo_sugg = self.lookup_typo_candidate(path, source.namespace(), is_expected); - if let TypoCandidate::Shadowed(res, Some(sugg_span)) = typo_sugg { + let is_local = &|res: Res| res.opt_def_id().map_or(false, |id| id.is_local()); + if let TypoCandidate::Shadowed(res, Some(sugg_span)) = typo_sugg && is_local(res) { err.span_label( sugg_span, format!("you might have meant to refer to this {}", res.descr()), From 775328c290599a05f42ee2fd7ed0a414847995fc Mon Sep 17 00:00:00 2001 From: Byron Zhong Date: Tue, 25 Oct 2022 17:29:29 -0500 Subject: [PATCH 046/219] Modify check to output 'you might have meant' for indirect reference --- compiler/rustc_resolve/src/late/diagnostics.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index dfbd982bb7c..dea025310d3 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -691,8 +691,21 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { let is_expected = &|res| source.is_expected(res); let ident_span = path.last().map_or(span, |ident| ident.ident.span); let typo_sugg = self.lookup_typo_candidate(path, source.namespace(), is_expected); - let is_local = &|res: Res| res.opt_def_id().map_or(false, |id| id.is_local()); - if let TypoCandidate::Shadowed(res, Some(sugg_span)) = typo_sugg && is_local(res) { + let is_in_same_file = &|sp1, sp2| { + let source_map = self.r.session.source_map(); + let file1 = source_map.span_to_filename(sp1); + let file2 = source_map.span_to_filename(sp2); + file1 == file2 + }; + // print 'you might have meant' if the candidate is (1) is a shadowed name with + // accessible definition and (2) either defined in the same crate as the typo + // (could be in a different file) or introduced in the same file as the typo + // (could belong to a different crate) + if let TypoCandidate::Shadowed(res, Some(sugg_span)) = typo_sugg + && res + .opt_def_id() + .map_or(false, |id| id.is_local() || is_in_same_file(span, sugg_span)) + { err.span_label( sugg_span, format!("you might have meant to refer to this {}", res.descr()), From 0eaf6d518026ccc4bd97444cd6a485accdc79878 Mon Sep 17 00:00:00 2001 From: Byron Zhong Date: Tue, 25 Oct 2022 17:50:11 -0500 Subject: [PATCH 047/219] Modify ui tests to reflect the change --- src/test/ui/lexical-scopes.stderr | 2 +- ...-type-parameter-shadowing-another-type.stderr | 16 +++++++--------- src/test/ui/span/issue-35987.stderr | 3 +++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/test/ui/lexical-scopes.stderr b/src/test/ui/lexical-scopes.stderr index 53598545223..f0eaa1a5c64 100644 --- a/src/test/ui/lexical-scopes.stderr +++ b/src/test/ui/lexical-scopes.stderr @@ -2,7 +2,7 @@ error[E0574]: expected struct, variant or union type, found type parameter `T` --> $DIR/lexical-scopes.rs:3:13 | LL | struct T { i: i32 } - | ------------------- you might have meant to refer to this struct + | - you might have meant to refer to this struct LL | fn f() { | - found this type parameter LL | let t = T { i: 0 }; diff --git a/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr b/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr index eb26cd9cabb..5790e425c0a 100644 --- a/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr +++ b/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr @@ -1,16 +1,14 @@ error[E0574]: expected struct, variant or union type, found type parameter `Baz` --> $DIR/point-at-type-parameter-shadowing-another-type.rs:16:13 | -LL | / struct Baz { -LL | | num: usize, -LL | | } - | |_- you might have meant to refer to this struct -LL | -LL | impl Foo for Bar { - | --- found this type parameter +LL | struct Baz { + | --- you might have meant to refer to this struct ... -LL | Baz { num } => num, - | ^^^ not a struct, variant or union type +LL | impl Foo for Bar { + | --- found this type parameter +... +LL | Baz { num } => num, + | ^^^ not a struct, variant or union type error: aborting due to previous error diff --git a/src/test/ui/span/issue-35987.stderr b/src/test/ui/span/issue-35987.stderr index d8fddc8007f..057d40ac0cb 100644 --- a/src/test/ui/span/issue-35987.stderr +++ b/src/test/ui/span/issue-35987.stderr @@ -1,6 +1,9 @@ error[E0404]: expected trait, found type parameter `Add` --> $DIR/issue-35987.rs:5:21 | +LL | use std::ops::Add; + | --- you might have meant to refer to this trait +LL | LL | impl Add for Foo { | --- ^^^ not a trait | | From 0c4a01af392d3c7b6206ae9726ac481a87ef1cdc Mon Sep 17 00:00:00 2001 From: Daniil Belov <70999565+BelovDV@users.noreply.github.com> Date: Wed, 21 Sep 2022 13:59:03 +0300 Subject: [PATCH 048/219] check lld version to choose correct flag for tests --- src/bootstrap/bin/rustdoc.rs | 8 ++------ src/bootstrap/lib.rs | 4 ++-- src/bootstrap/test.rs | 5 ++++- src/bootstrap/util.rs | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs index e69cab956c5..23828f4758d 100644 --- a/src/bootstrap/bin/rustdoc.rs +++ b/src/bootstrap/bin/rustdoc.rs @@ -55,13 +55,9 @@ fn main() { arg.push(&linker); cmd.arg(arg); } - if env::var_os("RUSTDOC_FUSE_LD_LLD").is_some() { + if let Ok(no_threads) = env::var("RUSTDOC_LLD_NO_THREADS") { cmd.arg("-Clink-arg=-fuse-ld=lld"); - if cfg!(windows) { - cmd.arg("-Clink-arg=-Wl,/threads:1"); - } else { - cmd.arg("-Clink-arg=-Wl,--threads=1"); - } + cmd.arg(format!("-Clink-arg=-Wl,{}", no_threads)); } // Cargo doesn't pass RUSTDOCFLAGS to proc_macros: // https://github.com/rust-lang/cargo/issues/4423 diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 7e70e99bb8c..f5def8ba834 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1152,8 +1152,8 @@ impl Build { options[0] = Some("-Clink-arg=-fuse-ld=lld".to_string()); } - let threads = if target.contains("windows") { "/threads:1" } else { "--threads=1" }; - options[1] = Some(format!("-Clink-arg=-Wl,{}", threads)); + let no_threads = util::lld_flag_no_threads(target.contains("windows")); + options[1] = Some(format!("-Clink-arg=-Wl,{}", no_threads)); } IntoIterator::into_iter(options).flatten() diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 8d491409778..f336f0496a1 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -727,7 +727,10 @@ impl Step for RustdocTheme { cmd.env("RUSTDOC_LINKER", linker); } if builder.is_fuse_ld_lld(self.compiler.host) { - cmd.env("RUSTDOC_FUSE_LD_LLD", "1"); + cmd.env( + "RUSTDOC_LLD_NO_THREADS", + util::lld_flag_no_threads(self.compiler.host.contains("windows")), + ); } try_run(builder, &mut cmd); } diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 0ebabbd5ca5..20c3801f0a5 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -13,6 +13,7 @@ use std::time::{Instant, SystemTime, UNIX_EPOCH}; use crate::builder::Builder; use crate::config::{Config, TargetSelection}; +use crate::OnceCell; /// A helper macro to `unwrap` a result except also print out details like: /// @@ -607,3 +608,16 @@ pub fn get_clang_cl_resource_dir(clang_cl_path: &str) -> PathBuf { let clang_rt_dir = clang_rt_builtins.parent().expect("The clang lib folder should exist"); clang_rt_dir.to_path_buf() } + +pub fn lld_flag_no_threads(is_windows: bool) -> &'static str { + static LLD_NO_THREADS: OnceCell<(&'static str, &'static str)> = OnceCell::new(); + let (windows, other) = LLD_NO_THREADS.get_or_init(|| { + let out = output(Command::new("lld").arg("-flavor").arg("ld").arg("--version")); + let newer = match (out.find(char::is_numeric), out.find('.')) { + (Some(b), Some(e)) => out.as_str()[b..e].parse::().ok().unwrap_or(14) > 10, + _ => true, + }; + if newer { ("/threads:1", "--threads=1") } else { ("/no-threads", "--no-threads") } + }); + if is_windows { windows } else { other } +} From f882309f4df08410982c67b8232358115fce0d3e Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 26 Oct 2022 10:28:27 +0000 Subject: [PATCH 049/219] Add cargo miri to x.py check --- src/bootstrap/builder.rs | 1 + src/bootstrap/check.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 415774d7255..1efc3f152b8 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -621,6 +621,7 @@ impl<'a> Builder<'a> { check::CodegenBackend, check::Clippy, check::Miri, + check::CargoMiri, check::Rls, check::RustAnalyzer, check::Rustfmt, diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index d553dd4e042..4450dd7e80f 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -457,6 +457,7 @@ tool_check_step!(Rustdoc, "src/tools/rustdoc", "src/librustdoc", SourceType::InT // rejected. tool_check_step!(Clippy, "src/tools/clippy", SourceType::InTree); tool_check_step!(Miri, "src/tools/miri", SourceType::InTree); +tool_check_step!(CargoMiri, "src/tools/miri/cargo-miri", SourceType::InTree); tool_check_step!(Rls, "src/tools/rls", SourceType::InTree); tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree); From 60dbffba294492427a00d6878a13f0ac3dae78d0 Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Wed, 26 Oct 2022 13:41:57 +0200 Subject: [PATCH 050/219] Adjust normalization --- src/test/rustdoc-ui/track-diagnostics.rs | 2 +- src/test/rustdoc-ui/track-diagnostics.stderr | 4 ++-- src/test/ui/track-diagnostics/track.rs | 2 +- src/test/ui/track-diagnostics/track.stderr | 8 ++++---- src/test/ui/track-diagnostics/track2.rs | 2 +- src/test/ui/track-diagnostics/track2.stderr | 4 ++-- src/test/ui/track-diagnostics/track3.rs | 2 +- src/test/ui/track-diagnostics/track3.stderr | 8 ++++---- src/test/ui/track-diagnostics/track4.rs | 2 +- src/test/ui/track-diagnostics/track4.stderr | 4 ++-- src/tools/clippy/tests/ui/track-diagnostics.rs | 2 +- src/tools/clippy/tests/ui/track-diagnostics.stderr | 4 ++-- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/test/rustdoc-ui/track-diagnostics.rs b/src/test/rustdoc-ui/track-diagnostics.rs index 3da80adbf44..fcc50a7aba0 100644 --- a/src/test/rustdoc-ui/track-diagnostics.rs +++ b/src/test/rustdoc-ui/track-diagnostics.rs @@ -3,7 +3,7 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. -// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" struct A; struct B; diff --git a/src/test/rustdoc-ui/track-diagnostics.stderr b/src/test/rustdoc-ui/track-diagnostics.stderr index 5a0982ff731..ec303186253 100644 --- a/src/test/rustdoc-ui/track-diagnostics.stderr +++ b/src/test/rustdoc-ui/track-diagnostics.stderr @@ -1,9 +1,9 @@ error[E0308]: mismatched types - --> $DIR/track-diagnostics.rs:$LINE::$COL + --> $DIR/track-diagnostics.rs:LL:CC | LL | const S: A = B; | ^ expected struct `A`, found struct `B` --Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:$LINE::$COL +-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:LL:CC error: aborting due to previous error diff --git a/src/test/ui/track-diagnostics/track.rs b/src/test/ui/track-diagnostics/track.rs index 23c0c8c4ed8..61b9137eadd 100644 --- a/src/test/ui/track-diagnostics/track.rs +++ b/src/test/ui/track-diagnostics/track.rs @@ -3,7 +3,7 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. -// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" // normalize-stderr-test "note: rustc .+ running on .+" -> "note: rustc $$VERSION running on $$TARGET" fn main() { diff --git a/src/test/ui/track-diagnostics/track.stderr b/src/test/ui/track-diagnostics/track.stderr index ed5c70b5a06..d23f625c2d1 100644 --- a/src/test/ui/track-diagnostics/track.stderr +++ b/src/test/ui/track-diagnostics/track.stderr @@ -1,16 +1,16 @@ error[E0425]: cannot find value `rust` in this scope - --> $DIR/track.rs:$LINE::$COL + --> $DIR/track.rs:LL:CC | LL | break rust | ^^^^ not found in this scope --Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:$LINE::$COL +-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC error[E0268]: `break` outside of a loop - --> $DIR/track.rs:$LINE::$COL + --> $DIR/track.rs:LL:CC | LL | break rust | ^^^^^^^^^^ cannot `break` outside of a loop --Ztrack-diagnostics: created at compiler/rustc_passes/src/errors.rs:$LINE::$COL +-Ztrack-diagnostics: created at compiler/rustc_passes/src/errors.rs:LL:CC error: internal compiler error: It looks like you're trying to break rust; would you like some ICE? diff --git a/src/test/ui/track-diagnostics/track2.rs b/src/test/ui/track-diagnostics/track2.rs index 45afd081566..dc105c61d72 100644 --- a/src/test/ui/track-diagnostics/track2.rs +++ b/src/test/ui/track-diagnostics/track2.rs @@ -3,7 +3,7 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. -// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" fn main() { let _moved @ _from = String::from("foo"); diff --git a/src/test/ui/track-diagnostics/track2.stderr b/src/test/ui/track-diagnostics/track2.stderr index 28d17f1e141..38a621da816 100644 --- a/src/test/ui/track-diagnostics/track2.stderr +++ b/src/test/ui/track-diagnostics/track2.stderr @@ -1,12 +1,12 @@ error[E0382]: use of moved value - --> $DIR/track2.rs:$LINE::$COL + --> $DIR/track2.rs:LL:CC | LL | let _moved @ _from = String::from("foo"); | ^^^^^^ ----- ------------------- move occurs because value has type `String`, which does not implement the `Copy` trait | | | | | value moved here | value used here after move --Ztrack-diagnostics: created at compiler/rustc_borrowck/src/borrowck_errors.rs:$LINE::$COL +-Ztrack-diagnostics: created at compiler/rustc_borrowck/src/borrowck_errors.rs:LL:CC error: aborting due to previous error diff --git a/src/test/ui/track-diagnostics/track3.rs b/src/test/ui/track-diagnostics/track3.rs index e9316a42189..0699239503a 100644 --- a/src/test/ui/track-diagnostics/track3.rs +++ b/src/test/ui/track-diagnostics/track3.rs @@ -3,7 +3,7 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. -// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" fn main() { let _unimported = Blah { field: u8 }; diff --git a/src/test/ui/track-diagnostics/track3.stderr b/src/test/ui/track-diagnostics/track3.stderr index 005380df430..dc468d7e8ee 100644 --- a/src/test/ui/track-diagnostics/track3.stderr +++ b/src/test/ui/track-diagnostics/track3.stderr @@ -1,16 +1,16 @@ error[E0422]: cannot find struct, variant or union type `Blah` in this scope - --> $DIR/track3.rs:$LINE::$COL + --> $DIR/track3.rs:LL:CC | LL | let _unimported = Blah { field: u8 }; | ^^^^ not found in this scope --Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:$LINE::$COL +-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC error[E0423]: expected value, found builtin type `u8` - --> $DIR/track3.rs:$LINE::$COL + --> $DIR/track3.rs:LL:CC | LL | let _unimported = Blah { field: u8 }; | ^^ not a value --Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:$LINE::$COL +-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC error: aborting due to 2 previous errors diff --git a/src/test/ui/track-diagnostics/track4.rs b/src/test/ui/track-diagnostics/track4.rs index 065cc604604..35eec799bba 100644 --- a/src/test/ui/track-diagnostics/track4.rs +++ b/src/test/ui/track-diagnostics/track4.rs @@ -3,7 +3,7 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. -// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" pub onion { Owo(u8), diff --git a/src/test/ui/track-diagnostics/track4.stderr b/src/test/ui/track-diagnostics/track4.stderr index e0cedcee0d3..c4668444c4b 100644 --- a/src/test/ui/track-diagnostics/track4.stderr +++ b/src/test/ui/track-diagnostics/track4.stderr @@ -1,9 +1,9 @@ error: missing `struct` for struct definition - --> $DIR/track4.rs:$LINE::$COL + --> $DIR/track4.rs:LL:CC | LL | pub onion { | ^ --Ztrack-diagnostics: created at compiler/rustc_parse/src/parser/diagnostics.rs:$LINE::$COL +-Ztrack-diagnostics: created at compiler/rustc_parse/src/parser/diagnostics.rs:LL:CC | help: add `struct` here to parse `onion` as a public struct | diff --git a/src/tools/clippy/tests/ui/track-diagnostics.rs b/src/tools/clippy/tests/ui/track-diagnostics.rs index 550ccd7b3d3..fa9221ed02d 100644 --- a/src/tools/clippy/tests/ui/track-diagnostics.rs +++ b/src/tools/clippy/tests/ui/track-diagnostics.rs @@ -3,7 +3,7 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. -// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" struct A; struct B; diff --git a/src/tools/clippy/tests/ui/track-diagnostics.stderr b/src/tools/clippy/tests/ui/track-diagnostics.stderr index 5a0982ff731..ec303186253 100644 --- a/src/tools/clippy/tests/ui/track-diagnostics.stderr +++ b/src/tools/clippy/tests/ui/track-diagnostics.stderr @@ -1,9 +1,9 @@ error[E0308]: mismatched types - --> $DIR/track-diagnostics.rs:$LINE::$COL + --> $DIR/track-diagnostics.rs:LL:CC | LL | const S: A = B; | ^ expected struct `A`, found struct `B` --Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:$LINE::$COL +-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:LL:CC error: aborting due to previous error From fae0be5d50f604b33b27e676a59cdc984a160e0b Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Wed, 26 Oct 2022 13:42:41 +0200 Subject: [PATCH 051/219] fix tracking hash test --- compiler/rustc_interface/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 0f7220f9f7a..5e6edd6c9af 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -689,7 +689,7 @@ fn test_unstable_options_tracking_hash() { untracked!(time_llvm_passes, true); untracked!(time_passes, true); untracked!(trace_macros, true); - untracked!(track_diagnostics, false); + untracked!(track_diagnostics, true); untracked!(trim_diagnostic_paths, false); untracked!(ui_testing, true); untracked!(unpretty, Some("expanded".to_string())); From 368c4a35b9acd7c66400855b9d2d4dfff016220b Mon Sep 17 00:00:00 2001 From: Xiretza Date: Thu, 20 Oct 2022 20:28:24 +0200 Subject: [PATCH 052/219] Add style= parameter to suggestion attributes --- .../rustc_macros/src/diagnostics/utils.rs | 87 ++++++++++++++++--- .../session-diagnostic/diagnostic-derive.rs | 7 ++ .../diagnostic-derive.stderr | 4 +- .../subdiagnostic-derive.rs | 78 +++++++++++++++++ .../subdiagnostic-derive.stderr | 56 +++++++++++- 5 files changed, 214 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_macros/src/diagnostics/utils.rs b/compiler/rustc_macros/src/diagnostics/utils.rs index 374c795d0a6..aaeb0e1aba9 100644 --- a/compiler/rustc_macros/src/diagnostics/utils.rs +++ b/compiler/rustc_macros/src/diagnostics/utils.rs @@ -472,7 +472,7 @@ pub(super) fn build_suggestion_code( } /// Possible styles for suggestion subdiagnostics. -#[derive(Clone, Copy)] +#[derive(Clone, Copy, PartialEq)] pub(super) enum SuggestionKind { /// `#[suggestion]` Normal, @@ -489,10 +489,10 @@ impl FromStr for SuggestionKind { fn from_str(s: &str) -> Result { match s { - "" => Ok(SuggestionKind::Normal), - "_short" => Ok(SuggestionKind::Short), - "_hidden" => Ok(SuggestionKind::Hidden), - "_verbose" => Ok(SuggestionKind::Verbose), + "normal" => Ok(SuggestionKind::Normal), + "short" => Ok(SuggestionKind::Short), + "hidden" => Ok(SuggestionKind::Hidden), + "verbose" => Ok(SuggestionKind::Verbose), _ => Err(()), } } @@ -515,6 +515,16 @@ impl SuggestionKind { } } } + + fn from_suffix(s: &str) -> Option { + match s { + "" => Some(SuggestionKind::Normal), + "_short" => Some(SuggestionKind::Short), + "_hidden" => Some(SuggestionKind::Hidden), + "_verbose" => Some(SuggestionKind::Verbose), + _ => None, + } + } } /// Types of subdiagnostics that can be created using attributes @@ -565,6 +575,8 @@ impl SubdiagnosticKind { let name = name.as_str(); let meta = attr.parse_meta()?; + + let mut opt_suggestion_kind = None; let mut kind = match name { "label" => SubdiagnosticKind::Label, "note" => SubdiagnosticKind::Note, @@ -572,18 +584,31 @@ impl SubdiagnosticKind { "warning" => SubdiagnosticKind::Warn, _ => { if let Some(suggestion_kind) = - name.strip_prefix("suggestion").and_then(|s| s.parse().ok()) + name.strip_prefix("suggestion").and_then(SuggestionKind::from_suffix) { + if suggestion_kind != SuggestionKind::Normal { + // Plain `#[suggestion]` can have a `style = "..."` attribute later, so don't set it here + opt_suggestion_kind.set_once(suggestion_kind, attr.path.span().unwrap()); + } + SubdiagnosticKind::Suggestion { - suggestion_kind, + suggestion_kind: SuggestionKind::Normal, applicability: None, code_field: new_code_ident(), code_init: TokenStream::new(), } } else if let Some(suggestion_kind) = - name.strip_prefix("multipart_suggestion").and_then(|s| s.parse().ok()) + name.strip_prefix("multipart_suggestion").and_then(SuggestionKind::from_suffix) { - SubdiagnosticKind::MultipartSuggestion { suggestion_kind, applicability: None } + if suggestion_kind != SuggestionKind::Normal { + // Plain `#[multipart_suggestion]` can have a `style = "..."` attribute later, so don't set it here + opt_suggestion_kind.set_once(suggestion_kind, attr.path.span().unwrap()); + } + + SubdiagnosticKind::MultipartSuggestion { + suggestion_kind: SuggestionKind::Normal, + applicability: None, + } } else { throw_invalid_attr!(attr, &meta); } @@ -682,16 +707,37 @@ impl SubdiagnosticKind { }); applicability.set_once(value, span); } + ( + "style", + SubdiagnosticKind::Suggestion { .. } + | SubdiagnosticKind::MultipartSuggestion { .. }, + ) => { + let Some(value) = string_value else { + invalid_nested_attr(attr, &nested_attr).emit(); + continue; + }; + + let value = value.value().parse().unwrap_or_else(|()| { + span_err(value.span().unwrap(), "invalid suggestion style") + .help("valid styles are `normal`, `short`, `hidden` and `verbose`") + .emit(); + SuggestionKind::Normal + }); + + opt_suggestion_kind.set_once(value, span); + } // Invalid nested attribute (_, SubdiagnosticKind::Suggestion { .. }) => { invalid_nested_attr(attr, &nested_attr) - .help("only `code` and `applicability` are valid nested attributes") + .help( + "only `style`, `code` and `applicability` are valid nested attributes", + ) .emit(); } (_, SubdiagnosticKind::MultipartSuggestion { .. }) => { invalid_nested_attr(attr, &nested_attr) - .help("only `applicability` is a valid nested attributes") + .help("only `style` and `applicability` are valid nested attributes") .emit() } _ => { @@ -701,7 +747,16 @@ impl SubdiagnosticKind { } match kind { - SubdiagnosticKind::Suggestion { ref code_field, ref mut code_init, .. } => { + SubdiagnosticKind::Suggestion { + ref code_field, + ref mut code_init, + ref mut suggestion_kind, + .. + } => { + if let Some(kind) = opt_suggestion_kind.value() { + *suggestion_kind = kind; + } + *code_init = if let Some(init) = code.value() { init } else { @@ -709,11 +764,15 @@ impl SubdiagnosticKind { quote! { let #code_field = std::iter::empty(); } }; } + SubdiagnosticKind::MultipartSuggestion { ref mut suggestion_kind, .. } => { + if let Some(kind) = opt_suggestion_kind.value() { + *suggestion_kind = kind; + } + } SubdiagnosticKind::Label | SubdiagnosticKind::Note | SubdiagnosticKind::Help - | SubdiagnosticKind::Warn - | SubdiagnosticKind::MultipartSuggestion { .. } => {} + | SubdiagnosticKind::Warn => {} } Ok(Some((kind, slug))) diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index ca77e483d6f..6cd76582795 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -796,3 +796,10 @@ struct SuggestionsInvalidLiteral { //~^ ERROR `code = "..."`/`code(...)` must contain only string literals sub: Span, } + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SuggestionStyleGood { + #[suggestion(code = "", style = "hidden")] + sub: Span, +} diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 859c272b6ba..5a0948e4dcb 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -272,7 +272,7 @@ error: `#[suggestion(nonsense = ...)]` is not a valid attribute LL | #[suggestion(nonsense = "bar")] | ^^^^^^^^^^^^^^^^ | - = help: only `code` and `applicability` are valid nested attributes + = help: only `style`, `code` and `applicability` are valid nested attributes error: suggestion without `code = "..."` --> $DIR/diagnostic-derive.rs:231:5 @@ -286,7 +286,7 @@ error: `#[suggestion(msg = ...)]` is not a valid attribute LL | #[suggestion(msg = "bar")] | ^^^^^^^^^^^ | - = help: only `code` and `applicability` are valid nested attributes + = help: only `style`, `code` and `applicability` are valid nested attributes error: suggestion without `code = "..."` --> $DIR/diagnostic-derive.rs:240:5 diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index efec85eb52c..9a1a57e2eaf 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -706,3 +706,81 @@ struct BQ { span: Span, r#type: String, } + +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "")] +struct SuggestionStyleDefault { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "", style = "short")] +struct SuggestionStyleShort { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "", style = "hidden")] +struct SuggestionStyleHidden { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "", style = "verbose")] +struct SuggestionStyleVerbose { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "", style = "hidden", style = "normal")] +//~^ ERROR specified multiple times +//~| NOTE previously specified here +struct SuggestionStyleTwice { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion_hidden(parser_add_paren, code = "", style = "normal")] +//~^ ERROR specified multiple times +//~| NOTE previously specified here +struct SuggestionStyleTwiceExplicit { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "", style = "foo")] +//~^ ERROR invalid suggestion style +struct SuggestionStyleInvalid1 { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "", style = 42)] +//~^ ERROR `#[suggestion(style = ...)]` is not a valid attribute +struct SuggestionStyleInvalid2 { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "", style)] +//~^ ERROR `#[suggestion(style)]` is not a valid attribute +struct SuggestionStyleInvalid3 { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "", style("foo"))] +//~^ ERROR `#[suggestion(style(...))]` is not a valid attribute +struct SuggestionStyleInvalid4 { + #[primary_span] + sub: Span, +} diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index a85a8711eac..d5e136fa40c 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -320,7 +320,7 @@ error: `#[multipart_suggestion(code = ...)]` is not a valid attribute LL | #[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] | ^^^^^^^^^^^^ | - = help: only `applicability` is a valid nested attributes + = help: only `style` and `applicability` are valid nested attributes error: multipart suggestion without any `#[suggestion_part(...)]` fields --> $DIR/subdiagnostic-derive.rs:536:1 @@ -445,6 +445,58 @@ error: `code = "..."`/`code(...)` must contain only string literals LL | #[suggestion_part(code = 3)] | ^^^^^^^^ +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:739:61 + | +LL | #[suggestion(parser_add_paren, code = "", style = "hidden", style = "normal")] + | ^^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:739:43 + | +LL | #[suggestion(parser_add_paren, code = "", style = "hidden", style = "normal")] + | ^^^^^^^^^^^^^^^^ + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:748:50 + | +LL | #[suggestion_hidden(parser_add_paren, code = "", style = "normal")] + | ^^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:748:3 + | +LL | #[suggestion_hidden(parser_add_paren, code = "", style = "normal")] + | ^^^^^^^^^^^^^^^^^ + +error: invalid suggestion style + --> $DIR/subdiagnostic-derive.rs:757:51 + | +LL | #[suggestion(parser_add_paren, code = "", style = "foo")] + | ^^^^^ + | + = help: valid styles are `normal`, `short`, `hidden` and `verbose` + +error: `#[suggestion(style = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:765:43 + | +LL | #[suggestion(parser_add_paren, code = "", style = 42)] + | ^^^^^^^^^^ + +error: `#[suggestion(style)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:773:43 + | +LL | #[suggestion(parser_add_paren, code = "", style)] + | ^^^^^ + | + = help: a diagnostic slug must be the first argument to the attribute + +error: `#[suggestion(style(...))]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:781:43 + | +LL | #[suggestion(parser_add_paren, code = "", style("foo"))] + | ^^^^^^^^^^^^ + error: cannot find attribute `foo` in this scope --> $DIR/subdiagnostic-derive.rs:63:3 | @@ -505,6 +557,6 @@ error[E0425]: cannot find value `slug` in module `rustc_errors::fluent` LL | #[label(slug)] | ^^^^ not found in `rustc_errors::fluent` -error: aborting due to 72 previous errors +error: aborting due to 78 previous errors For more information about this error, try `rustc --explain E0425`. From 29334b951a6ab997d63d72a496454a0455ce5ee2 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Thu, 20 Oct 2022 21:09:54 +0200 Subject: [PATCH 053/219] rustfmt diagnostic derive tests --- .../session-diagnostic/diagnostic-derive.rs | 23 +++--- .../diagnostic-derive.stderr | 70 +++++++++---------- .../subdiagnostic-derive.rs | 52 +++++++------- .../subdiagnostic-derive.stderr | 20 +++--- 4 files changed, 80 insertions(+), 85 deletions(-) diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index 6cd76582795..b998f71e3aa 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -40,9 +40,9 @@ struct HelloWarn {} //~^ ERROR unsupported type attribute for diagnostic derive enum enum DiagnosticOnEnum { Foo, -//~^ ERROR diagnostic slug not specified + //~^ ERROR diagnostic slug not specified Bar, -//~^ ERROR diagnostic slug not specified + //~^ ERROR diagnostic slug not specified } #[derive(Diagnostic)] @@ -536,8 +536,7 @@ struct LabelWithTrailingList { #[derive(LintDiagnostic)] #[diag(compiletest_example)] -struct LintsGood { -} +struct LintsGood {} #[derive(LintDiagnostic)] #[diag(compiletest_example)] @@ -683,7 +682,7 @@ struct RawIdentDiagnosticArg { #[diag(compiletest_example)] struct SubdiagnosticBad { #[subdiagnostic(bad)] -//~^ ERROR `#[subdiagnostic(bad)]` is not a valid attribute + //~^ ERROR `#[subdiagnostic(bad)]` is not a valid attribute note: Note, } @@ -691,7 +690,7 @@ struct SubdiagnosticBad { #[diag(compiletest_example)] struct SubdiagnosticBadStr { #[subdiagnostic = "bad"] -//~^ ERROR `#[subdiagnostic = ...]` is not a valid attribute + //~^ ERROR `#[subdiagnostic = ...]` is not a valid attribute note: Note, } @@ -699,7 +698,7 @@ struct SubdiagnosticBadStr { #[diag(compiletest_example)] struct SubdiagnosticBadTwice { #[subdiagnostic(bad, bad)] -//~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute + //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute note: Note, } @@ -707,7 +706,7 @@ struct SubdiagnosticBadTwice { #[diag(compiletest_example)] struct SubdiagnosticBadLitStr { #[subdiagnostic("bad")] -//~^ ERROR `#[subdiagnostic("...")]` is not a valid attribute + //~^ ERROR `#[subdiagnostic("...")]` is not a valid attribute note: Note, } @@ -715,7 +714,7 @@ struct SubdiagnosticBadLitStr { #[diag(compiletest_example)] struct SubdiagnosticEagerLint { #[subdiagnostic(eager)] -//~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute + //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute note: Note, } @@ -731,11 +730,7 @@ struct SubdiagnosticEagerCorrect { // after the `span_suggestion` call - which breaks eager translation. #[derive(Subdiagnostic)] -#[suggestion_short( - use_instead, - applicability = "machine-applicable", - code = "{correct}" -)] +#[suggestion_short(use_instead, applicability = "machine-applicable", code = "{correct}")] pub(crate) struct SubdiagnosticWithSuggestion { #[primary_span] span: Span, diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 5a0948e4dcb..5943ffa6bc2 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -373,7 +373,7 @@ LL | #[label(label, foo("..."))] | ^^^^^^^^^^ error: `#[primary_span]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:545:5 + --> $DIR/diagnostic-derive.rs:544:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -381,13 +381,13 @@ LL | #[primary_span] = help: the `primary_span` field attribute is not valid for lint diagnostics error: `#[error(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:565:1 + --> $DIR/diagnostic-derive.rs:564:1 | LL | #[error(compiletest_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:565:1 + --> $DIR/diagnostic-derive.rs:564:1 | LL | / #[error(compiletest_example, code = "E0123")] LL | | @@ -399,13 +399,13 @@ LL | | struct ErrorAttribute {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[warn_(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:572:1 + --> $DIR/diagnostic-derive.rs:571:1 | LL | #[warn_(compiletest_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:572:1 + --> $DIR/diagnostic-derive.rs:571:1 | LL | / #[warn_(compiletest_example, code = "E0123")] LL | | @@ -417,13 +417,13 @@ LL | | struct WarnAttribute {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:579:1 + --> $DIR/diagnostic-derive.rs:578:1 | LL | #[lint(compiletest_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:579:1 + --> $DIR/diagnostic-derive.rs:578:1 | LL | / #[lint(compiletest_example, code = "E0123")] LL | | @@ -435,19 +435,19 @@ LL | | struct LintAttributeOnSessionDiag {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:586:1 + --> $DIR/diagnostic-derive.rs:585:1 | LL | #[lint(compiletest_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:586:1 + --> $DIR/diagnostic-derive.rs:585:1 | LL | #[lint(compiletest_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:586:1 + --> $DIR/diagnostic-derive.rs:585:1 | LL | / #[lint(compiletest_example, code = "E0123")] LL | | @@ -460,19 +460,19 @@ LL | | struct LintAttributeOnLintDiag {} = help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]` error: specified multiple times - --> $DIR/diagnostic-derive.rs:596:44 + --> $DIR/diagnostic-derive.rs:595:44 | LL | #[suggestion(suggestion, code = "...", code = ",,,")] | ^^^^^^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:596:30 + --> $DIR/diagnostic-derive.rs:595:30 | LL | #[suggestion(suggestion, code = "...", code = ",,,")] | ^^^^^^^^^^^^ error: wrong types for suggestion - --> $DIR/diagnostic-derive.rs:605:24 + --> $DIR/diagnostic-derive.rs:604:24 | LL | suggestion: (Span, usize), | ^^^^^ @@ -480,7 +480,7 @@ LL | suggestion: (Span, usize), = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` error: wrong types for suggestion - --> $DIR/diagnostic-derive.rs:613:17 + --> $DIR/diagnostic-derive.rs:612:17 | LL | suggestion: (Span,), | ^^^^^^^ @@ -488,13 +488,13 @@ LL | suggestion: (Span,), = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:620:5 + --> $DIR/diagnostic-derive.rs:619:5 | LL | #[suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:627:1 + --> $DIR/diagnostic-derive.rs:626:1 | LL | #[multipart_suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -502,7 +502,7 @@ LL | #[multipart_suggestion(suggestion)] = help: consider creating a `Subdiagnostic` instead error: `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:630:1 + --> $DIR/diagnostic-derive.rs:629:1 | LL | #[multipart_suggestion()] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -510,7 +510,7 @@ LL | #[multipart_suggestion()] = help: consider creating a `Subdiagnostic` instead error: `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:634:5 + --> $DIR/diagnostic-derive.rs:633:5 | LL | #[multipart_suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -518,7 +518,7 @@ LL | #[multipart_suggestion(suggestion)] = help: consider creating a `Subdiagnostic` instead error: `#[suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:642:1 + --> $DIR/diagnostic-derive.rs:641:1 | LL | #[suggestion(suggestion, code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -526,7 +526,7 @@ LL | #[suggestion(suggestion, code = "...")] = help: `#[label]` and `#[suggestion]` can only be applied to fields error: `#[label]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:651:1 + --> $DIR/diagnostic-derive.rs:650:1 | LL | #[label] | ^^^^^^^^ @@ -534,7 +534,7 @@ LL | #[label] = help: `#[label]` and `#[suggestion]` can only be applied to fields error: `#[subdiagnostic(bad)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:685:21 + --> $DIR/diagnostic-derive.rs:684:21 | LL | #[subdiagnostic(bad)] | ^^^ @@ -542,7 +542,7 @@ LL | #[subdiagnostic(bad)] = help: `eager` is the only supported nested attribute for `subdiagnostic` error: `#[subdiagnostic = ...]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:693:5 + --> $DIR/diagnostic-derive.rs:692:5 | LL | #[subdiagnostic = "bad"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -550,7 +550,7 @@ LL | #[subdiagnostic = "bad"] = help: `eager` is the only supported nested attribute for `subdiagnostic` error: `#[subdiagnostic(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:701:5 + --> $DIR/diagnostic-derive.rs:700:5 | LL | #[subdiagnostic(bad, bad)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -558,7 +558,7 @@ LL | #[subdiagnostic(bad, bad)] = help: `eager` is the only supported nested attribute for `subdiagnostic` error: `#[subdiagnostic("...")]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:709:21 + --> $DIR/diagnostic-derive.rs:708:21 | LL | #[subdiagnostic("bad")] | ^^^^^ @@ -566,7 +566,7 @@ LL | #[subdiagnostic("bad")] = help: `eager` is the only supported nested attribute for `subdiagnostic` error: `#[subdiagnostic(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:717:5 + --> $DIR/diagnostic-derive.rs:716:5 | LL | #[subdiagnostic(eager)] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -574,19 +574,19 @@ LL | #[subdiagnostic(eager)] = help: eager subdiagnostics are not supported on lints error: expected at least one string literal for `code(...)` - --> $DIR/diagnostic-derive.rs:779:18 + --> $DIR/diagnostic-derive.rs:774:18 | LL | #[suggestion(code())] | ^^^^^^ error: `code(...)` must contain only string literals - --> $DIR/diagnostic-derive.rs:787:23 + --> $DIR/diagnostic-derive.rs:782:23 | LL | #[suggestion(code(foo))] | ^^^ error: `code = "..."`/`code(...)` must contain only string literals - --> $DIR/diagnostic-derive.rs:795:18 + --> $DIR/diagnostic-derive.rs:790:18 | LL | #[suggestion(code = 3)] | ^^^^^^^^ @@ -604,43 +604,43 @@ LL | #[nonsense] | ^^^^^^^^ error: cannot find attribute `error` in this scope - --> $DIR/diagnostic-derive.rs:565:3 + --> $DIR/diagnostic-derive.rs:564:3 | LL | #[error(compiletest_example, code = "E0123")] | ^^^^^ error: cannot find attribute `warn_` in this scope - --> $DIR/diagnostic-derive.rs:572:3 + --> $DIR/diagnostic-derive.rs:571:3 | LL | #[warn_(compiletest_example, code = "E0123")] | ^^^^^ help: a built-in attribute with a similar name exists: `warn` error: cannot find attribute `lint` in this scope - --> $DIR/diagnostic-derive.rs:579:3 + --> $DIR/diagnostic-derive.rs:578:3 | LL | #[lint(compiletest_example, code = "E0123")] | ^^^^ help: a built-in attribute with a similar name exists: `link` error: cannot find attribute `lint` in this scope - --> $DIR/diagnostic-derive.rs:586:3 + --> $DIR/diagnostic-derive.rs:585:3 | LL | #[lint(compiletest_example, code = "E0123")] | ^^^^ help: a built-in attribute with a similar name exists: `link` error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive.rs:627:3 + --> $DIR/diagnostic-derive.rs:626:3 | LL | #[multipart_suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^ error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive.rs:630:3 + --> $DIR/diagnostic-derive.rs:629:3 | LL | #[multipart_suggestion()] | ^^^^^^^^^^^^^^^^^^^^ error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive.rs:634:7 + --> $DIR/diagnostic-derive.rs:633:7 | LL | #[multipart_suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 9a1a57e2eaf..50a6c816578 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -11,13 +11,13 @@ #![crate_type = "lib"] extern crate rustc_errors; +extern crate rustc_macros; extern crate rustc_session; extern crate rustc_span; -extern crate rustc_macros; use rustc_errors::Applicability; -use rustc_span::Span; use rustc_macros::Subdiagnostic; +use rustc_span::Span; #[derive(Subdiagnostic)] #[label(parser_add_paren)] @@ -40,7 +40,7 @@ enum B { #[primary_span] span: Span, var: String, - } + }, } #[derive(Subdiagnostic)] @@ -165,7 +165,7 @@ enum P { #[primary_span] span: Span, var: String, - } + }, } #[derive(Subdiagnostic)] @@ -177,7 +177,7 @@ enum Q { #[primary_span] span: Span, var: String, - } + }, } #[derive(Subdiagnostic)] @@ -189,7 +189,7 @@ enum R { #[primary_span] span: Span, var: String, - } + }, } #[derive(Subdiagnostic)] @@ -201,7 +201,7 @@ enum S { #[primary_span] span: Span, var: String, - } + }, } #[derive(Subdiagnostic)] @@ -213,7 +213,7 @@ enum T { #[primary_span] span: Span, var: String, - } + }, } #[derive(Subdiagnostic)] @@ -225,7 +225,7 @@ enum U { #[primary_span] span: Span, var: String, - } + }, } #[derive(Subdiagnostic)] @@ -240,7 +240,7 @@ enum V { #[primary_span] span: Span, var: String, - } + }, } #[derive(Subdiagnostic)] @@ -301,14 +301,14 @@ struct AB { #[primary_span] span: Span, #[skip_arg] - z: Z + z: Z, } #[derive(Subdiagnostic)] union AC { -//~^ ERROR unexpected unsupported untagged union + //~^ ERROR unexpected unsupported untagged union span: u32, - b: u64 + b: u64, } #[derive(Subdiagnostic)] @@ -372,7 +372,7 @@ enum AI { #[applicability] applicability: Applicability, var: String, - } + }, } #[derive(Subdiagnostic)] @@ -427,7 +427,7 @@ struct AN { } #[derive(Subdiagnostic)] -#[suggestion(parser_add_paren, code ="...", applicability = "foo")] +#[suggestion(parser_add_paren, code = "...", applicability = "foo")] //~^ ERROR invalid applicability struct AO { #[primary_span] @@ -437,7 +437,7 @@ struct AO { #[derive(Subdiagnostic)] #[help(parser_add_paren)] struct AP { - var: String + var: String, } #[derive(Subdiagnostic)] @@ -452,7 +452,7 @@ struct AR { } #[derive(Subdiagnostic)] -#[suggestion(parser_add_paren, code ="...", applicability = "machine-applicable")] +#[suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] struct AS { #[primary_span] span: Span, @@ -467,11 +467,11 @@ enum AT { #[primary_span] span: Span, var: String, - } + }, } #[derive(Subdiagnostic)] -#[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] +#[suggestion(parser_add_paren, code = "{var}", applicability = "machine-applicable")] struct AU { #[primary_span] span: Span, @@ -479,7 +479,7 @@ struct AU { } #[derive(Subdiagnostic)] -#[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] +#[suggestion(parser_add_paren, code = "{var}", applicability = "machine-applicable")] //~^ ERROR `var` doesn't refer to a field on this type struct AV { #[primary_span] @@ -488,22 +488,22 @@ struct AV { #[derive(Subdiagnostic)] enum AW { - #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] + #[suggestion(parser_add_paren, code = "{var}", applicability = "machine-applicable")] A { #[primary_span] span: Span, var: String, - } + }, } #[derive(Subdiagnostic)] enum AX { - #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] -//~^ ERROR `var` doesn't refer to a field on this type + #[suggestion(parser_add_paren, code = "{var}", applicability = "machine-applicable")] + //~^ ERROR `var` doesn't refer to a field on this type A { #[primary_span] span: Span, - } + }, } #[derive(Subdiagnostic)] @@ -659,7 +659,7 @@ enum BL { /// ..and the field #[primary_span] span: Span, - } + }, } #[derive(Subdiagnostic)] diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index d5e136fa40c..4ae7ed34230 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -186,7 +186,7 @@ error: unexpected unsupported untagged union LL | / union AC { LL | | LL | | span: u32, -LL | | b: u64 +LL | | b: u64, LL | | } | |_^ @@ -253,10 +253,10 @@ LL | #[suggestion(parser_add_paren)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/subdiagnostic-derive.rs:430:45 + --> $DIR/subdiagnostic-derive.rs:430:46 | -LL | #[suggestion(parser_add_paren, code ="...", applicability = "foo")] - | ^^^^^^^^^^^^^^^^^^^^^ +LL | #[suggestion(parser_add_paren, code = "...", applicability = "foo")] + | ^^^^^^^^^^^^^^^^^^^^^ error: suggestion without `#[primary_span]` field --> $DIR/subdiagnostic-derive.rs:448:1 @@ -275,16 +275,16 @@ LL | #[label] | ^^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:482:38 + --> $DIR/subdiagnostic-derive.rs:482:39 | -LL | #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] - | ^^^^^^^ +LL | #[suggestion(parser_add_paren, code = "{var}", applicability = "machine-applicable")] + | ^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:501:42 + --> $DIR/subdiagnostic-derive.rs:501:43 | -LL | #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] - | ^^^^^^^ +LL | #[suggestion(parser_add_paren, code = "{var}", applicability = "machine-applicable")] + | ^^^^^^^ error: `#[suggestion_part]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:524:5 From 20f2958b8af32dd08173272a7ede09aaa255c980 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Thu, 20 Oct 2022 21:17:14 +0200 Subject: [PATCH 054/219] Add "tool-only" suggestion style --- compiler/rustc_macros/src/diagnostics/utils.rs | 13 ++++++++----- .../session-diagnostic/subdiagnostic-derive.rs | 7 +++++++ .../subdiagnostic-derive.stderr | 18 +++++++++--------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_macros/src/diagnostics/utils.rs b/compiler/rustc_macros/src/diagnostics/utils.rs index aaeb0e1aba9..99ecaaae0e8 100644 --- a/compiler/rustc_macros/src/diagnostics/utils.rs +++ b/compiler/rustc_macros/src/diagnostics/utils.rs @@ -474,14 +474,11 @@ pub(super) fn build_suggestion_code( /// Possible styles for suggestion subdiagnostics. #[derive(Clone, Copy, PartialEq)] pub(super) enum SuggestionKind { - /// `#[suggestion]` Normal, - /// `#[suggestion_short]` Short, - /// `#[suggestion_hidden]` Hidden, - /// `#[suggestion_verbose]` Verbose, + ToolOnly, } impl FromStr for SuggestionKind { @@ -493,6 +490,7 @@ impl FromStr for SuggestionKind { "short" => Ok(SuggestionKind::Short), "hidden" => Ok(SuggestionKind::Hidden), "verbose" => Ok(SuggestionKind::Verbose), + "tool-only" => Ok(SuggestionKind::ToolOnly), _ => Err(()), } } @@ -513,6 +511,9 @@ impl SuggestionKind { SuggestionKind::Verbose => { quote! { rustc_errors::SuggestionStyle::ShowAlways } } + SuggestionKind::ToolOnly => { + quote! { rustc_errors::SuggestionStyle::CompletelyHidden } + } } } @@ -583,6 +584,8 @@ impl SubdiagnosticKind { "help" => SubdiagnosticKind::Help, "warning" => SubdiagnosticKind::Warn, _ => { + // FIXME(#100717): remove #[suggestion_{short,verbose,hidden}] attributes, use + // #[suggestion(style = "...")] instead if let Some(suggestion_kind) = name.strip_prefix("suggestion").and_then(SuggestionKind::from_suffix) { @@ -719,7 +722,7 @@ impl SubdiagnosticKind { let value = value.value().parse().unwrap_or_else(|()| { span_err(value.span().unwrap(), "invalid suggestion style") - .help("valid styles are `normal`, `short`, `hidden` and `verbose`") + .help("valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only`") .emit(); SuggestionKind::Normal }); diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 50a6c816578..7d9e2576cae 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -735,6 +735,13 @@ struct SuggestionStyleVerbose { sub: Span, } +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "", style = "tool-only")] +struct SuggestionStyleToolOnly { + #[primary_span] + sub: Span, +} + #[derive(Subdiagnostic)] #[suggestion(parser_add_paren, code = "", style = "hidden", style = "normal")] //~^ ERROR specified multiple times diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index 4ae7ed34230..b76b7fdfcea 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -446,45 +446,45 @@ LL | #[suggestion_part(code = 3)] | ^^^^^^^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:739:61 + --> $DIR/subdiagnostic-derive.rs:746:61 | LL | #[suggestion(parser_add_paren, code = "", style = "hidden", style = "normal")] | ^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:739:43 + --> $DIR/subdiagnostic-derive.rs:746:43 | LL | #[suggestion(parser_add_paren, code = "", style = "hidden", style = "normal")] | ^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:748:50 + --> $DIR/subdiagnostic-derive.rs:755:50 | LL | #[suggestion_hidden(parser_add_paren, code = "", style = "normal")] | ^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:748:3 + --> $DIR/subdiagnostic-derive.rs:755:3 | LL | #[suggestion_hidden(parser_add_paren, code = "", style = "normal")] | ^^^^^^^^^^^^^^^^^ error: invalid suggestion style - --> $DIR/subdiagnostic-derive.rs:757:51 + --> $DIR/subdiagnostic-derive.rs:764:51 | LL | #[suggestion(parser_add_paren, code = "", style = "foo")] | ^^^^^ | - = help: valid styles are `normal`, `short`, `hidden` and `verbose` + = help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only` error: `#[suggestion(style = ...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:765:43 + --> $DIR/subdiagnostic-derive.rs:772:43 | LL | #[suggestion(parser_add_paren, code = "", style = 42)] | ^^^^^^^^^^ error: `#[suggestion(style)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:773:43 + --> $DIR/subdiagnostic-derive.rs:780:43 | LL | #[suggestion(parser_add_paren, code = "", style)] | ^^^^^ @@ -492,7 +492,7 @@ LL | #[suggestion(parser_add_paren, code = "", style)] = help: a diagnostic slug must be the first argument to the attribute error: `#[suggestion(style(...))]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:781:43 + --> $DIR/subdiagnostic-derive.rs:788:43 | LL | #[suggestion(parser_add_paren, code = "", style("foo"))] | ^^^^^^^^^^^^ From cd621be7821834e5322f0acfb9a7826d4397401d Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sat, 22 Oct 2022 15:48:55 +0200 Subject: [PATCH 055/219] Convert all #[suggestion_*] attributes to #[suggestion(style = "...")] Using the following command: find compiler/ -type f -name '*.rs' -exec perl -i -gpe \ 's/(#\[\w*suggestion)_(short|verbose|hidden)\(\s*(\S+,)?/\1(\3style = "\2",/g' \ '{}' + --- compiler/rustc_ast_lowering/src/errors.rs | 3 +- .../rustc_borrowck/src/session_diagnostics.rs | 2 +- compiler/rustc_hir_analysis/src/errors.rs | 8 ++- compiler/rustc_hir_typeck/src/errors.rs | 3 +- compiler/rustc_infer/src/errors/mod.rs | 15 ++-- compiler/rustc_lint/src/errors.rs | 2 +- .../src/opaque_hidden_inferred_bound.rs | 3 +- compiler/rustc_macros/src/diagnostics/mod.rs | 2 +- compiler/rustc_parse/src/errors.rs | 71 ++++++++++++------- compiler/rustc_passes/src/errors.rs | 2 +- 10 files changed, 73 insertions(+), 38 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index 157f46501e1..21c6a2d26f4 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -277,8 +277,9 @@ pub struct RegisterConflict<'a> { pub struct SubTupleBinding<'a> { #[primary_span] #[label] - #[suggestion_verbose( + #[suggestion( ast_lowering_sub_tuple_binding_suggestion, + style = "verbose", code = "..", applicability = "maybe-incorrect" )] diff --git a/compiler/rustc_borrowck/src/session_diagnostics.rs b/compiler/rustc_borrowck/src/session_diagnostics.rs index cff3089c397..fe24f85fae1 100644 --- a/compiler/rustc_borrowck/src/session_diagnostics.rs +++ b/compiler/rustc_borrowck/src/session_diagnostics.rs @@ -49,7 +49,7 @@ pub(crate) struct GenericDoesNotLiveLongEnough { #[derive(LintDiagnostic)] #[diag(borrowck_var_does_not_need_mut)] pub(crate) struct VarNeedNotMut { - #[suggestion_short(applicability = "machine-applicable", code = "")] + #[suggestion(style = "short", applicability = "machine-applicable", code = "")] pub span: Span, } #[derive(Diagnostic)] diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index 9457da32ce6..144421ac249 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -120,7 +120,7 @@ pub struct TypeofReservedKeywordUsed<'tcx> { #[primary_span] #[label] pub span: Span, - #[suggestion_verbose(code = "{ty}")] + #[suggestion(style = "verbose", code = "{ty}")] pub opt_sugg: Option<(Span, Applicability)>, } @@ -237,7 +237,11 @@ pub struct UnusedExternCrate { #[derive(LintDiagnostic)] #[diag(hir_analysis_extern_crate_not_idiomatic)] pub struct ExternCrateNotIdiomatic { - #[suggestion_short(applicability = "machine-applicable", code = "{suggestion_code}")] + #[suggestion( + style = "short", + applicability = "machine-applicable", + code = "{suggestion_code}" + )] pub span: Span, pub msg_code: String, pub suggestion_code: String, diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index 175037f9b3a..cfb408396da 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -113,8 +113,9 @@ pub struct MissingParentheseInRange { } #[derive(Subdiagnostic)] -#[multipart_suggestion_verbose( +#[multipart_suggestion( hir_analysis_add_missing_parentheses_in_range, + style = "verbose", applicability = "maybe-incorrect" )] pub struct AddMissingParenthesesInRange { diff --git a/compiler/rustc_infer/src/errors/mod.rs b/compiler/rustc_infer/src/errors/mod.rs index 2131d19068e..bb04e1c49ba 100644 --- a/compiler/rustc_infer/src/errors/mod.rs +++ b/compiler/rustc_infer/src/errors/mod.rs @@ -109,8 +109,9 @@ pub struct InferenceBadError<'a> { #[derive(Subdiagnostic)] pub enum SourceKindSubdiag<'a> { - #[suggestion_verbose( + #[suggestion( infer_source_kind_subdiag_let, + style = "verbose", code = ": {type_name}", applicability = "has-placeholders" )] @@ -135,8 +136,9 @@ pub enum SourceKindSubdiag<'a> { parent_prefix: String, parent_name: String, }, - #[suggestion_verbose( + #[suggestion( infer_source_kind_subdiag_generic_suggestion, + style = "verbose", code = "::<{args}>", applicability = "has-placeholders" )] @@ -150,8 +152,9 @@ pub enum SourceKindSubdiag<'a> { #[derive(Subdiagnostic)] pub enum SourceKindMultiSuggestion<'a> { - #[multipart_suggestion_verbose( + #[multipart_suggestion( infer_source_kind_fully_qualified, + style = "verbose", applicability = "has-placeholders" )] FullyQualified { @@ -163,8 +166,9 @@ pub enum SourceKindMultiSuggestion<'a> { adjustment: &'a str, successor_pos: &'a str, }, - #[multipart_suggestion_verbose( + #[multipart_suggestion( infer_source_kind_closure_return, + style = "verbose", applicability = "has-placeholders" )] ClosureReturn { @@ -478,8 +482,9 @@ pub enum ImplicitStaticLifetimeSubdiag { #[primary_span] span: Span, }, - #[suggestion_verbose( + #[suggestion( infer_implicit_static_lifetime_suggestion, + style = "verbose", code = " + '_", applicability = "maybe-incorrect" )] diff --git a/compiler/rustc_lint/src/errors.rs b/compiler/rustc_lint/src/errors.rs index a49d1bdacc2..1a769893f55 100644 --- a/compiler/rustc_lint/src/errors.rs +++ b/compiler/rustc_lint/src/errors.rs @@ -83,7 +83,7 @@ pub struct UnknownToolInScopedLint { pub struct BuiltinEllpisisInclusiveRangePatterns { #[primary_span] pub span: Span, - #[suggestion_short(code = "{replace}", applicability = "machine-applicable")] + #[suggestion(style = "short", code = "{replace}", applicability = "machine-applicable")] pub suggestion: Span, pub replace: String, } diff --git a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs index 7f6f4a0abb4..25ee0227428 100644 --- a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs +++ b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs @@ -150,8 +150,9 @@ struct OpaqueHiddenInferredBoundLint<'tcx> { } #[derive(Subdiagnostic)] -#[suggestion_verbose( +#[suggestion( lint_opaque_hidden_inferred_bound_sugg, + style = "verbose", applicability = "machine-applicable", code = " + {trait_ref}" )] diff --git a/compiler/rustc_macros/src/diagnostics/mod.rs b/compiler/rustc_macros/src/diagnostics/mod.rs index 860340b4390..78df0cd1d34 100644 --- a/compiler/rustc_macros/src/diagnostics/mod.rs +++ b/compiler/rustc_macros/src/diagnostics/mod.rs @@ -129,7 +129,7 @@ pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream { /// } /// /// #[derive(Subdiagnostic)] -/// #[suggestion_verbose(parser::raw_identifier)] +/// #[suggestion(style = "verbose",parser::raw_identifier)] /// pub struct RawIdentifierSuggestion<'tcx> { /// #[primary_span] /// span: Span, diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 9b177c5189b..ce7b1a979d7 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -64,7 +64,7 @@ pub(crate) struct BadQPathStage2 { #[diag(parser_incorrect_semicolon)] pub(crate) struct IncorrectSemicolon<'a> { #[primary_span] - #[suggestion_short(code = "", applicability = "machine-applicable")] + #[suggestion(style = "short", code = "", applicability = "machine-applicable")] pub span: Span, #[help] pub opt_help: Option<()>, @@ -136,7 +136,12 @@ pub(crate) struct InvalidComparisonOperator { #[derive(Subdiagnostic)] pub(crate) enum InvalidComparisonOperatorSub { - #[suggestion_short(use_instead, applicability = "machine-applicable", code = "{correct}")] + #[suggestion( + use_instead, + style = "short", + applicability = "machine-applicable", + code = "{correct}" + )] Correctable { #[primary_span] span: Span, @@ -160,14 +165,16 @@ pub(crate) struct InvalidLogicalOperator { #[derive(Subdiagnostic)] pub(crate) enum InvalidLogicalOperatorSub { - #[suggestion_short( + #[suggestion( use_amp_amp_for_conjunction, + style = "short", applicability = "machine-applicable", code = "&&" )] Conjunction(#[primary_span] Span), - #[suggestion_short( + #[suggestion( use_pipe_pipe_for_disjunction, + style = "short", applicability = "machine-applicable", code = "||" )] @@ -178,7 +185,7 @@ pub(crate) enum InvalidLogicalOperatorSub { #[diag(parser_tilde_is_not_unary_operator)] pub(crate) struct TildeAsUnaryOperator( #[primary_span] - #[suggestion_short(applicability = "machine-applicable", code = "!")] + #[suggestion(style = "short", applicability = "machine-applicable", code = "!")] pub Span, ); @@ -194,22 +201,25 @@ pub(crate) struct NotAsNegationOperator { #[derive(Subdiagnostic)] pub enum NotAsNegationOperatorSub { - #[suggestion_short( + #[suggestion( parser_unexpected_token_after_not_default, + style = "short", applicability = "machine-applicable", code = "!" )] SuggestNotDefault(#[primary_span] Span), - #[suggestion_short( + #[suggestion( parser_unexpected_token_after_not_bitwise, + style = "short", applicability = "machine-applicable", code = "!" )] SuggestNotBitwise(#[primary_span] Span), - #[suggestion_short( + #[suggestion( parser_unexpected_token_after_not_logical, + style = "short", applicability = "machine-applicable", code = "!" )] @@ -249,7 +259,7 @@ pub(crate) struct UnexpectedTokenAfterLabel { #[primary_span] #[label(parser_unexpected_token_after_label)] pub span: Span, - #[suggestion_verbose(suggestion_remove_label, code = "")] + #[suggestion(suggestion_remove_label, style = "verbose", code = "")] pub remove_label: Option, #[subdiagnostic] pub enclose_in_block: Option, @@ -272,7 +282,7 @@ pub(crate) struct RequireColonAfterLabeledExpression { pub span: Span, #[label] pub label: Span, - #[suggestion_short(applicability = "machine-applicable", code = ": ")] + #[suggestion(style = "short", applicability = "machine-applicable", code = ": ")] pub label_end: Span, } @@ -354,7 +364,7 @@ pub(crate) struct IntLiteralTooLarge { pub(crate) struct MissingSemicolonBeforeArray { #[primary_span] pub open_delim: Span, - #[suggestion_verbose(applicability = "maybe-incorrect", code = ";")] + #[suggestion(style = "verbose", applicability = "maybe-incorrect", code = ";")] pub semicolon: Span, } @@ -442,9 +452,9 @@ pub(crate) struct MissingInInForLoop { #[derive(Subdiagnostic)] pub(crate) enum MissingInInForLoopSub { // Has been misleading, at least in the past (closed Issue #48492), thus maybe-incorrect - #[suggestion_short(use_in_not_of, applicability = "maybe-incorrect", code = "in")] + #[suggestion(use_in_not_of, style = "short", applicability = "maybe-incorrect", code = "in")] InNotOf(#[primary_span] Span), - #[suggestion_short(add_in, applicability = "maybe-incorrect", code = " in ")] + #[suggestion(add_in, style = "short", applicability = "maybe-incorrect", code = " in ")] AddIn(#[primary_span] Span), } @@ -470,7 +480,7 @@ pub(crate) struct CatchAfterTry { pub(crate) struct CommaAfterBaseStruct { #[primary_span] pub span: Span, - #[suggestion_short(applicability = "machine-applicable", code = "")] + #[suggestion(style = "short", applicability = "machine-applicable", code = "")] pub comma: Span, } @@ -512,7 +522,7 @@ pub(crate) struct RemoveLet { #[diag(parser_use_eq_instead)] pub(crate) struct UseEqInstead { #[primary_span] - #[suggestion_short(applicability = "machine-applicable", code = "=")] + #[suggestion(style = "short", applicability = "machine-applicable", code = "=")] pub span: Span, } @@ -520,7 +530,7 @@ pub(crate) struct UseEqInstead { #[diag(parser_use_empty_block_not_semi)] pub(crate) struct UseEmptyBlockNotSemi { #[primary_span] - #[suggestion_hidden(applicability = "machine-applicable", code = "{{}}")] + #[suggestion(style = "hidden", applicability = "machine-applicable", code = "{{}}")] pub span: Span, } @@ -576,7 +586,12 @@ pub(crate) struct LeadingPlusNotSupported { #[primary_span] #[label] pub span: Span, - #[suggestion_verbose(suggestion_remove_plus, code = "", applicability = "machine-applicable")] + #[suggestion( + suggestion_remove_plus, + style = "verbose", + code = "", + applicability = "machine-applicable" + )] pub remove_plus: Option, #[subdiagnostic] pub add_parentheses: Option, @@ -843,7 +858,7 @@ pub(crate) struct InvalidCurlyInLetElse { #[help] pub(crate) struct CompoundAssignmentExpressionInLet { #[primary_span] - #[suggestion_short(code = "=", applicability = "maybe-incorrect")] + #[suggestion(style = "short", code = "=", applicability = "maybe-incorrect")] pub span: Span, } @@ -864,8 +879,9 @@ pub(crate) struct InvalidMetaItem { } #[derive(Subdiagnostic)] -#[suggestion_verbose( +#[suggestion( parser_sugg_escape_to_use_as_identifier, + style = "verbose", applicability = "maybe-incorrect", code = "r#" )] @@ -1003,7 +1019,12 @@ pub(crate) enum ExpectedSemiSugg { applicability = "machine-applicable" )] ChangeToSemi(#[primary_span] Span), - #[suggestion_short(parser_sugg_add_semi, code = ";", applicability = "machine-applicable")] + #[suggestion( + parser_sugg_add_semi, + style = "short", + code = ";", + applicability = "machine-applicable" + )] AddSemi(#[primary_span] Span), } @@ -1057,8 +1078,9 @@ pub(crate) struct GenericParamsWithoutAngleBracketsSugg { pub(crate) struct ComparisonOperatorsCannotBeChained { #[primary_span] pub span: Vec, - #[suggestion_verbose( + #[suggestion( parser_sugg_turbofish_syntax, + style = "verbose", code = "::", applicability = "maybe-incorrect" )] @@ -1072,8 +1094,9 @@ pub(crate) struct ComparisonOperatorsCannotBeChained { #[derive(Subdiagnostic)] pub(crate) enum ComparisonOperatorsCannotBeChainedSugg { - #[suggestion_verbose( + #[suggestion( sugg_split_comparison, + style = "verbose", code = " && {middle_term}", applicability = "maybe-incorrect" )] @@ -1215,7 +1238,7 @@ pub(crate) enum UnexpectedConstParamDeclarationSugg { pub(crate) struct UnexpectedConstInGenericParam { #[primary_span] pub span: Span, - #[suggestion_verbose(code = "", applicability = "maybe-incorrect")] + #[suggestion(style = "verbose", code = "", applicability = "maybe-incorrect")] pub to_remove: Option, } @@ -1223,7 +1246,7 @@ pub(crate) struct UnexpectedConstInGenericParam { #[diag(parser_async_move_order_incorrect)] pub(crate) struct AsyncMoveOrderIncorrect { #[primary_span] - #[suggestion_verbose(code = "async move", applicability = "maybe-incorrect")] + #[suggestion(style = "verbose", code = "async move", applicability = "maybe-incorrect")] pub span: Span, } diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index adaaf539242..26e04ce8c10 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -291,7 +291,7 @@ pub struct DocTestUnknownAny { #[note(no_op_note)] pub struct DocTestUnknownSpotlight { pub path: String, - #[suggestion_short(applicability = "machine-applicable", code = "notable_trait")] + #[suggestion(style = "short", applicability = "machine-applicable", code = "notable_trait")] pub span: Span, } From 2eeb7802b3cfe25005c446bf6a82f5e9a1979c1e Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sat, 22 Oct 2022 17:21:11 +0200 Subject: [PATCH 056/219] Remove #[suggestion_*] attributes --- .../rustc_macros/src/diagnostics/utils.rs | 52 ++++++--- .../session-diagnostic/diagnostic-derive.rs | 9 +- .../diagnostic-derive.stderr | 106 +++++++++--------- .../subdiagnostic-derive.rs | 13 ++- .../subdiagnostic-derive.stderr | 30 ++--- 5 files changed, 122 insertions(+), 88 deletions(-) diff --git a/compiler/rustc_macros/src/diagnostics/utils.rs b/compiler/rustc_macros/src/diagnostics/utils.rs index 99ecaaae0e8..ba06f61299f 100644 --- a/compiler/rustc_macros/src/diagnostics/utils.rs +++ b/compiler/rustc_macros/src/diagnostics/utils.rs @@ -12,7 +12,7 @@ use syn::{spanned::Spanned, Attribute, Field, Meta, Type, TypeTuple}; use syn::{MetaList, MetaNameValue, NestedMeta, Path}; use synstructure::{BindingInfo, VariantInfo}; -use super::error::invalid_nested_attr; +use super::error::{invalid_attr, invalid_nested_attr}; thread_local! { pub static CODE_IDENT_COUNT: RefCell = RefCell::new(0); @@ -496,6 +496,18 @@ impl FromStr for SuggestionKind { } } +impl fmt::Display for SuggestionKind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + SuggestionKind::Normal => write!(f, "normal"), + SuggestionKind::Short => write!(f, "short"), + SuggestionKind::Hidden => write!(f, "hidden"), + SuggestionKind::Verbose => write!(f, "verbose"), + SuggestionKind::ToolOnly => write!(f, "tool-only"), + } + } +} + impl SuggestionKind { pub fn to_suggestion_style(&self) -> TokenStream { match self { @@ -577,21 +589,24 @@ impl SubdiagnosticKind { let meta = attr.parse_meta()?; - let mut opt_suggestion_kind = None; let mut kind = match name { "label" => SubdiagnosticKind::Label, "note" => SubdiagnosticKind::Note, "help" => SubdiagnosticKind::Help, "warning" => SubdiagnosticKind::Warn, _ => { - // FIXME(#100717): remove #[suggestion_{short,verbose,hidden}] attributes, use - // #[suggestion(style = "...")] instead + // Recover old `#[(multipart_)suggestion_*]` syntaxes + // FIXME(#100717): remove if let Some(suggestion_kind) = name.strip_prefix("suggestion").and_then(SuggestionKind::from_suffix) { if suggestion_kind != SuggestionKind::Normal { - // Plain `#[suggestion]` can have a `style = "..."` attribute later, so don't set it here - opt_suggestion_kind.set_once(suggestion_kind, attr.path.span().unwrap()); + invalid_attr(attr, &meta) + .help(format!( + r#"Use `#[suggestion(..., style = "{}")]` instead"#, + suggestion_kind + )) + .emit(); } SubdiagnosticKind::Suggestion { @@ -604,8 +619,12 @@ impl SubdiagnosticKind { name.strip_prefix("multipart_suggestion").and_then(SuggestionKind::from_suffix) { if suggestion_kind != SuggestionKind::Normal { - // Plain `#[multipart_suggestion]` can have a `style = "..."` attribute later, so don't set it here - opt_suggestion_kind.set_once(suggestion_kind, attr.path.span().unwrap()); + invalid_attr(attr, &meta) + .help(format!( + r#"Use `#[multipart_suggestion(..., style = "{}")]` instead"#, + suggestion_kind + )) + .emit(); } SubdiagnosticKind::MultipartSuggestion { @@ -649,6 +668,7 @@ impl SubdiagnosticKind { }; let mut code = None; + let mut suggestion_kind = None; let mut nested_iter = nested.into_iter().peekable(); @@ -727,7 +747,7 @@ impl SubdiagnosticKind { SuggestionKind::Normal }); - opt_suggestion_kind.set_once(value, span); + suggestion_kind.set_once(value, span); } // Invalid nested attribute @@ -753,11 +773,11 @@ impl SubdiagnosticKind { SubdiagnosticKind::Suggestion { ref code_field, ref mut code_init, - ref mut suggestion_kind, + suggestion_kind: ref mut kind_field, .. } => { - if let Some(kind) = opt_suggestion_kind.value() { - *suggestion_kind = kind; + if let Some(kind) = suggestion_kind.value() { + *kind_field = kind; } *code_init = if let Some(init) = code.value() { @@ -767,9 +787,11 @@ impl SubdiagnosticKind { quote! { let #code_field = std::iter::empty(); } }; } - SubdiagnosticKind::MultipartSuggestion { ref mut suggestion_kind, .. } => { - if let Some(kind) = opt_suggestion_kind.value() { - *suggestion_kind = kind; + SubdiagnosticKind::MultipartSuggestion { + suggestion_kind: ref mut kind_field, .. + } => { + if let Some(kind) = suggestion_kind.value() { + *kind_field = kind; } } SubdiagnosticKind::Label diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index b998f71e3aa..411eb3fba48 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -211,9 +211,10 @@ struct LabelOnNonSpan { #[diag(compiletest_example, code = "E0123")] struct Suggest { #[suggestion(suggestion, code = "This is the suggested code")] - #[suggestion_short(suggestion, code = "This is the suggested code")] - #[suggestion_hidden(suggestion, code = "This is the suggested code")] - #[suggestion_verbose(suggestion, code = "This is the suggested code")] + #[suggestion(suggestion, code = "This is the suggested code", style = "normal")] + #[suggestion(suggestion, code = "This is the suggested code", style = "short")] + #[suggestion(suggestion, code = "This is the suggested code", style = "hidden")] + #[suggestion(suggestion, code = "This is the suggested code", style = "verbose")] suggestion: (Span, Applicability), } @@ -730,7 +731,7 @@ struct SubdiagnosticEagerCorrect { // after the `span_suggestion` call - which breaks eager translation. #[derive(Subdiagnostic)] -#[suggestion_short(use_instead, applicability = "machine-applicable", code = "{correct}")] +#[suggestion(use_instead, applicability = "machine-applicable", code = "{correct}")] pub(crate) struct SubdiagnosticWithSuggestion { #[primary_span] span: Span, diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 5943ffa6bc2..b4c211db47c 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -261,13 +261,13 @@ LL | #[label(label)] | ^^^^^^^^^^^^^^^ error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:223:5 + --> $DIR/diagnostic-derive.rs:224:5 | LL | #[suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[suggestion(nonsense = ...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:231:18 + --> $DIR/diagnostic-derive.rs:232:18 | LL | #[suggestion(nonsense = "bar")] | ^^^^^^^^^^^^^^^^ @@ -275,13 +275,13 @@ LL | #[suggestion(nonsense = "bar")] = help: only `style`, `code` and `applicability` are valid nested attributes error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:231:5 + --> $DIR/diagnostic-derive.rs:232:5 | LL | #[suggestion(nonsense = "bar")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[suggestion(msg = ...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:240:18 + --> $DIR/diagnostic-derive.rs:241:18 | LL | #[suggestion(msg = "bar")] | ^^^^^^^^^^^ @@ -289,13 +289,13 @@ LL | #[suggestion(msg = "bar")] = help: only `style`, `code` and `applicability` are valid nested attributes error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:240:5 + --> $DIR/diagnostic-derive.rs:241:5 | LL | #[suggestion(msg = "bar")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: wrong field type for suggestion - --> $DIR/diagnostic-derive.rs:263:5 + --> $DIR/diagnostic-derive.rs:264:5 | LL | / #[suggestion(suggestion, code = "This is suggested code")] LL | | @@ -305,55 +305,55 @@ LL | | suggestion: Applicability, = help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)` error: specified multiple times - --> $DIR/diagnostic-derive.rs:279:24 + --> $DIR/diagnostic-derive.rs:280:24 | LL | suggestion: (Span, Span, Applicability), | ^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:279:18 + --> $DIR/diagnostic-derive.rs:280:18 | LL | suggestion: (Span, Span, Applicability), | ^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:287:33 + --> $DIR/diagnostic-derive.rs:288:33 | LL | suggestion: (Applicability, Applicability, Span), | ^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:287:18 + --> $DIR/diagnostic-derive.rs:288:18 | LL | suggestion: (Applicability, Applicability, Span), | ^^^^^^^^^^^^^ error: `#[label = ...]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:294:5 + --> $DIR/diagnostic-derive.rs:295:5 | LL | #[label = "bar"] | ^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:445:44 + --> $DIR/diagnostic-derive.rs:446:44 | LL | #[suggestion(suggestion, code = "...", applicability = "maybe-incorrect")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:447:24 + --> $DIR/diagnostic-derive.rs:448:24 | LL | suggestion: (Span, Applicability), | ^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/diagnostic-derive.rs:453:44 + --> $DIR/diagnostic-derive.rs:454:44 | LL | #[suggestion(suggestion, code = "...", applicability = "batman")] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[label(foo)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:516:20 + --> $DIR/diagnostic-derive.rs:517:20 | LL | #[label(label, foo)] | ^^^ @@ -361,19 +361,19 @@ LL | #[label(label, foo)] = help: a diagnostic slug must be the first argument to the attribute error: `#[label(foo = ...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:524:20 + --> $DIR/diagnostic-derive.rs:525:20 | LL | #[label(label, foo = "...")] | ^^^^^^^^^^^ error: `#[label(foo(...))]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:532:20 + --> $DIR/diagnostic-derive.rs:533:20 | LL | #[label(label, foo("..."))] | ^^^^^^^^^^ error: `#[primary_span]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:544:5 + --> $DIR/diagnostic-derive.rs:545:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -381,13 +381,13 @@ LL | #[primary_span] = help: the `primary_span` field attribute is not valid for lint diagnostics error: `#[error(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:564:1 + --> $DIR/diagnostic-derive.rs:565:1 | LL | #[error(compiletest_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:564:1 + --> $DIR/diagnostic-derive.rs:565:1 | LL | / #[error(compiletest_example, code = "E0123")] LL | | @@ -399,13 +399,13 @@ LL | | struct ErrorAttribute {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[warn_(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:571:1 + --> $DIR/diagnostic-derive.rs:572:1 | LL | #[warn_(compiletest_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:571:1 + --> $DIR/diagnostic-derive.rs:572:1 | LL | / #[warn_(compiletest_example, code = "E0123")] LL | | @@ -417,13 +417,13 @@ LL | | struct WarnAttribute {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:578:1 + --> $DIR/diagnostic-derive.rs:579:1 | LL | #[lint(compiletest_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:578:1 + --> $DIR/diagnostic-derive.rs:579:1 | LL | / #[lint(compiletest_example, code = "E0123")] LL | | @@ -435,19 +435,19 @@ LL | | struct LintAttributeOnSessionDiag {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:585:1 + --> $DIR/diagnostic-derive.rs:586:1 | LL | #[lint(compiletest_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:585:1 + --> $DIR/diagnostic-derive.rs:586:1 | LL | #[lint(compiletest_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:585:1 + --> $DIR/diagnostic-derive.rs:586:1 | LL | / #[lint(compiletest_example, code = "E0123")] LL | | @@ -460,19 +460,19 @@ LL | | struct LintAttributeOnLintDiag {} = help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]` error: specified multiple times - --> $DIR/diagnostic-derive.rs:595:44 + --> $DIR/diagnostic-derive.rs:596:44 | LL | #[suggestion(suggestion, code = "...", code = ",,,")] | ^^^^^^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:595:30 + --> $DIR/diagnostic-derive.rs:596:30 | LL | #[suggestion(suggestion, code = "...", code = ",,,")] | ^^^^^^^^^^^^ error: wrong types for suggestion - --> $DIR/diagnostic-derive.rs:604:24 + --> $DIR/diagnostic-derive.rs:605:24 | LL | suggestion: (Span, usize), | ^^^^^ @@ -480,7 +480,7 @@ LL | suggestion: (Span, usize), = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` error: wrong types for suggestion - --> $DIR/diagnostic-derive.rs:612:17 + --> $DIR/diagnostic-derive.rs:613:17 | LL | suggestion: (Span,), | ^^^^^^^ @@ -488,13 +488,13 @@ LL | suggestion: (Span,), = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:619:5 + --> $DIR/diagnostic-derive.rs:620:5 | LL | #[suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:626:1 + --> $DIR/diagnostic-derive.rs:627:1 | LL | #[multipart_suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -502,7 +502,7 @@ LL | #[multipart_suggestion(suggestion)] = help: consider creating a `Subdiagnostic` instead error: `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:629:1 + --> $DIR/diagnostic-derive.rs:630:1 | LL | #[multipart_suggestion()] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -510,7 +510,7 @@ LL | #[multipart_suggestion()] = help: consider creating a `Subdiagnostic` instead error: `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:633:5 + --> $DIR/diagnostic-derive.rs:634:5 | LL | #[multipart_suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -518,7 +518,7 @@ LL | #[multipart_suggestion(suggestion)] = help: consider creating a `Subdiagnostic` instead error: `#[suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:641:1 + --> $DIR/diagnostic-derive.rs:642:1 | LL | #[suggestion(suggestion, code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -526,7 +526,7 @@ LL | #[suggestion(suggestion, code = "...")] = help: `#[label]` and `#[suggestion]` can only be applied to fields error: `#[label]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:650:1 + --> $DIR/diagnostic-derive.rs:651:1 | LL | #[label] | ^^^^^^^^ @@ -534,7 +534,7 @@ LL | #[label] = help: `#[label]` and `#[suggestion]` can only be applied to fields error: `#[subdiagnostic(bad)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:684:21 + --> $DIR/diagnostic-derive.rs:685:21 | LL | #[subdiagnostic(bad)] | ^^^ @@ -542,7 +542,7 @@ LL | #[subdiagnostic(bad)] = help: `eager` is the only supported nested attribute for `subdiagnostic` error: `#[subdiagnostic = ...]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:692:5 + --> $DIR/diagnostic-derive.rs:693:5 | LL | #[subdiagnostic = "bad"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -550,7 +550,7 @@ LL | #[subdiagnostic = "bad"] = help: `eager` is the only supported nested attribute for `subdiagnostic` error: `#[subdiagnostic(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:700:5 + --> $DIR/diagnostic-derive.rs:701:5 | LL | #[subdiagnostic(bad, bad)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -558,7 +558,7 @@ LL | #[subdiagnostic(bad, bad)] = help: `eager` is the only supported nested attribute for `subdiagnostic` error: `#[subdiagnostic("...")]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:708:21 + --> $DIR/diagnostic-derive.rs:709:21 | LL | #[subdiagnostic("bad")] | ^^^^^ @@ -566,7 +566,7 @@ LL | #[subdiagnostic("bad")] = help: `eager` is the only supported nested attribute for `subdiagnostic` error: `#[subdiagnostic(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:716:5 + --> $DIR/diagnostic-derive.rs:717:5 | LL | #[subdiagnostic(eager)] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -574,19 +574,19 @@ LL | #[subdiagnostic(eager)] = help: eager subdiagnostics are not supported on lints error: expected at least one string literal for `code(...)` - --> $DIR/diagnostic-derive.rs:774:18 + --> $DIR/diagnostic-derive.rs:775:18 | LL | #[suggestion(code())] | ^^^^^^ error: `code(...)` must contain only string literals - --> $DIR/diagnostic-derive.rs:782:23 + --> $DIR/diagnostic-derive.rs:783:23 | LL | #[suggestion(code(foo))] | ^^^ error: `code = "..."`/`code(...)` must contain only string literals - --> $DIR/diagnostic-derive.rs:790:18 + --> $DIR/diagnostic-derive.rs:791:18 | LL | #[suggestion(code = 3)] | ^^^^^^^^ @@ -604,43 +604,43 @@ LL | #[nonsense] | ^^^^^^^^ error: cannot find attribute `error` in this scope - --> $DIR/diagnostic-derive.rs:564:3 + --> $DIR/diagnostic-derive.rs:565:3 | LL | #[error(compiletest_example, code = "E0123")] | ^^^^^ error: cannot find attribute `warn_` in this scope - --> $DIR/diagnostic-derive.rs:571:3 + --> $DIR/diagnostic-derive.rs:572:3 | LL | #[warn_(compiletest_example, code = "E0123")] | ^^^^^ help: a built-in attribute with a similar name exists: `warn` error: cannot find attribute `lint` in this scope - --> $DIR/diagnostic-derive.rs:578:3 + --> $DIR/diagnostic-derive.rs:579:3 | LL | #[lint(compiletest_example, code = "E0123")] | ^^^^ help: a built-in attribute with a similar name exists: `link` error: cannot find attribute `lint` in this scope - --> $DIR/diagnostic-derive.rs:585:3 + --> $DIR/diagnostic-derive.rs:586:3 | LL | #[lint(compiletest_example, code = "E0123")] | ^^^^ help: a built-in attribute with a similar name exists: `link` error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive.rs:626:3 + --> $DIR/diagnostic-derive.rs:627:3 | LL | #[multipart_suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^ error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive.rs:629:3 + --> $DIR/diagnostic-derive.rs:630:3 | LL | #[multipart_suggestion()] | ^^^^^^^^^^^^^^^^^^^^ error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive.rs:633:7 + --> $DIR/diagnostic-derive.rs:634:7 | LL | #[multipart_suggestion(suggestion)] | ^^^^^^^^^^^^^^^^^^^^ @@ -652,7 +652,7 @@ LL | #[diag(nonsense, code = "E0123")] | ^^^^^^^^ not found in `rustc_errors::fluent` error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied - --> $DIR/diagnostic-derive.rs:338:10 + --> $DIR/diagnostic-derive.rs:339:10 | LL | #[derive(Diagnostic)] | ^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello` diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 7d9e2576cae..078ec3baac9 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -751,11 +751,18 @@ struct SuggestionStyleTwice { sub: Span, } +#[derive(Subdiagnostic)] +#[suggestion_hidden(parser_add_paren, code = "")] +//~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute +struct SuggestionStyleOldSyntax { + #[primary_span] + sub: Span, +} + #[derive(Subdiagnostic)] #[suggestion_hidden(parser_add_paren, code = "", style = "normal")] -//~^ ERROR specified multiple times -//~| NOTE previously specified here -struct SuggestionStyleTwiceExplicit { +//~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute +struct SuggestionStyleOldAndNewSyntax { #[primary_span] sub: Span, } diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index b76b7fdfcea..8e06c43e6d0 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -457,20 +457,24 @@ note: previously specified here LL | #[suggestion(parser_add_paren, code = "", style = "hidden", style = "normal")] | ^^^^^^^^^^^^^^^^ -error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:755:50 +error: `#[suggestion_hidden(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:755:1 + | +LL | #[suggestion_hidden(parser_add_paren, code = "")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: Use `#[suggestion(..., style = "hidden")]` instead + +error: `#[suggestion_hidden(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:763:1 | LL | #[suggestion_hidden(parser_add_paren, code = "", style = "normal")] - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: previously specified here - --> $DIR/subdiagnostic-derive.rs:755:3 - | -LL | #[suggestion_hidden(parser_add_paren, code = "", style = "normal")] - | ^^^^^^^^^^^^^^^^^ + = help: Use `#[suggestion(..., style = "hidden")]` instead error: invalid suggestion style - --> $DIR/subdiagnostic-derive.rs:764:51 + --> $DIR/subdiagnostic-derive.rs:771:51 | LL | #[suggestion(parser_add_paren, code = "", style = "foo")] | ^^^^^ @@ -478,13 +482,13 @@ LL | #[suggestion(parser_add_paren, code = "", style = "foo")] = help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only` error: `#[suggestion(style = ...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:772:43 + --> $DIR/subdiagnostic-derive.rs:779:43 | LL | #[suggestion(parser_add_paren, code = "", style = 42)] | ^^^^^^^^^^ error: `#[suggestion(style)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:780:43 + --> $DIR/subdiagnostic-derive.rs:787:43 | LL | #[suggestion(parser_add_paren, code = "", style)] | ^^^^^ @@ -492,7 +496,7 @@ LL | #[suggestion(parser_add_paren, code = "", style)] = help: a diagnostic slug must be the first argument to the attribute error: `#[suggestion(style(...))]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:788:43 + --> $DIR/subdiagnostic-derive.rs:795:43 | LL | #[suggestion(parser_add_paren, code = "", style("foo"))] | ^^^^^^^^^^^^ @@ -557,6 +561,6 @@ error[E0425]: cannot find value `slug` in module `rustc_errors::fluent` LL | #[label(slug)] | ^^^^ not found in `rustc_errors::fluent` -error: aborting due to 78 previous errors +error: aborting due to 79 previous errors For more information about this error, try `rustc --explain E0425`. From ddba6c1e6c7b6e2f1bdff54e314831cec8a4a954 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Wed, 26 Oct 2022 23:59:27 +0800 Subject: [PATCH 057/219] doc(rustdoc): redirect more urls --- src/doc/rustdoc/book.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/doc/rustdoc/book.toml b/src/doc/rustdoc/book.toml index 45405a11765..dfa68578500 100644 --- a/src/doc/rustdoc/book.toml +++ b/src/doc/rustdoc/book.toml @@ -6,5 +6,9 @@ title = "The rustdoc book" git-repository-url = "https://github.com/rust-lang/rust/tree/master/src/doc/rustdoc" [output.html.redirect] +"/what-to-include.html" = "write-documentation/what-to-include.html" "/the-doc-attribute.html" = "write-documentation/the-doc-attribute.html" +"/linking-to-items-by-name.html" = "write-documentation/linking-to-items-by-name.html" "/documentation-tests.html" = "write-documentation/documentation-tests.html" +"/website-features.html" = "advanced-features.html#custom-search-engines" +"/passes.html" = "deprecated-features.html#passes" From 06692ea4441b168b279ec6fbdd8311d0444cbc4c Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Thu, 27 Oct 2022 00:01:15 +0800 Subject: [PATCH 058/219] fix(rustdoc): add missing URL component for error messages --- src/librustdoc/passes/collect_intra_doc_links.rs | 2 +- .../intra-doc/unknown-disambiguator.stderr | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 3513c13d522..70ae5e9d99d 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1893,7 +1893,7 @@ fn disambiguator_error( diag_info.link_range = disambiguator_range; report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |diag, _sp| { let msg = format!( - "see {}/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators", + "see {}/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators", crate::DOC_RUST_LANG_ORG_CHANNEL ); diag.note(&msg); diff --git a/src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr b/src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr index e7b4c43e790..19e541736bd 100644 --- a/src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr +++ b/src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr @@ -4,7 +4,7 @@ error: unknown disambiguator `foo` LL | //! Linking to [foo@banana] and [`bar@banana!()`]. | ^^^ | - = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators note: the lint level is defined here --> $DIR/unknown-disambiguator.rs:2:9 | @@ -18,7 +18,7 @@ error: unknown disambiguator `bar` LL | //! Linking to [foo@banana] and [`bar@banana!()`]. | ^^^ | - = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: unknown disambiguator `foo` --> $DIR/unknown-disambiguator.rs:10:34 @@ -26,7 +26,7 @@ error: unknown disambiguator `foo` LL | //! And with weird backticks: [``foo@hello``] [foo`@`hello]. | ^^^ | - = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: unknown disambiguator `foo` --> $DIR/unknown-disambiguator.rs:10:48 @@ -34,7 +34,7 @@ error: unknown disambiguator `foo` LL | //! And with weird backticks: [``foo@hello``] [foo`@`hello]. | ^^^ | - = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: unknown disambiguator `` --> $DIR/unknown-disambiguator.rs:7:31 @@ -42,7 +42,7 @@ error: unknown disambiguator `` LL | //! And to [no disambiguator](@nectarine) and [another](@apricot!()). | ^ | - = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: unknown disambiguator `` --> $DIR/unknown-disambiguator.rs:7:57 @@ -50,7 +50,7 @@ error: unknown disambiguator `` LL | //! And to [no disambiguator](@nectarine) and [another](@apricot!()). | ^ | - = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: aborting due to 6 previous errors From 7c6345d175a6976e68d3902240ab6dd8d6b99bc2 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Wed, 26 Oct 2022 20:28:25 -0400 Subject: [PATCH 059/219] Allow use of `-Clto=thin` with `-Ccodegen-units=1` in general The current logic to ignore ThinLTO when `-Ccodegen-units=1` makes sense for local ThinLTO but even in this scenario, a user may still want (non-local) ThinLTO for the purpose of optimizing dependencies into the final crate which is being compiled with 1 CGU. The previous behavior was even more confusing because if you were generating a binary (`--emit=link`), then you would get ThinLTO but if you asked for LLVM IR or bytecode, then it would silently change to using regular LTO. With this change, we only override the defaults for local ThinLTO if you ask for a single output such as LLVM IR or bytecode and in all other cases honor the requested LTO setting. --- compiler/rustc_session/src/config.rs | 14 +++++++------- compiler/rustc_session/src/options.rs | 2 +- compiler/rustc_session/src/session.rs | 9 +++------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index f2ee52262ad..82159cff29f 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -738,7 +738,7 @@ impl Default for Options { actually_rustdoc: false, trimmed_def_paths: TrimmedDefPaths::default(), cli_forced_codegen_units: None, - cli_forced_thinlto_off: false, + cli_forced_local_thinlto_off: false, remap_path_prefix: Vec::new(), real_rust_source_base_dir: None, edition: DEFAULT_EDITION, @@ -1720,7 +1720,7 @@ fn should_override_cgus_and_disable_thinlto( error_format: ErrorOutputType, mut codegen_units: Option, ) -> (bool, Option) { - let mut disable_thinlto = false; + let mut disable_local_thinlto = false; // Issue #30063: if user requests LLVM-related output to one // particular path, disable codegen-units. let incompatible: Vec<_> = output_types @@ -1745,12 +1745,12 @@ fn should_override_cgus_and_disable_thinlto( } early_warn(error_format, "resetting to default -C codegen-units=1"); codegen_units = Some(1); - disable_thinlto = true; + disable_local_thinlto = true; } } _ => { codegen_units = Some(1); - disable_thinlto = true; + disable_local_thinlto = true; } } } @@ -1759,7 +1759,7 @@ fn should_override_cgus_and_disable_thinlto( early_error(error_format, "value for codegen units must be a positive non-zero integer"); } - (disable_thinlto, codegen_units) + (disable_local_thinlto, codegen_units) } fn check_thread_count(unstable_opts: &UnstableOptions, error_format: ErrorOutputType) { @@ -2249,7 +2249,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { let output_types = parse_output_types(&unstable_opts, matches, error_format); let mut cg = CodegenOptions::build(matches, error_format); - let (disable_thinlto, mut codegen_units) = should_override_cgus_and_disable_thinlto( + let (disable_local_thinlto, mut codegen_units) = should_override_cgus_and_disable_thinlto( &output_types, matches, error_format, @@ -2492,7 +2492,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { actually_rustdoc: false, trimmed_def_paths: TrimmedDefPaths::default(), cli_forced_codegen_units: codegen_units, - cli_forced_thinlto_off: disable_thinlto, + cli_forced_local_thinlto_off: disable_local_thinlto, remap_path_prefix, real_rust_source_base_dir, edition, diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index a8be318dea8..0483bac490a 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -181,7 +181,7 @@ top_level_options!( #[rustc_lint_opt_deny_field_access("use `Session::codegen_units` instead of this field")] cli_forced_codegen_units: Option [UNTRACKED], #[rustc_lint_opt_deny_field_access("use `Session::lto` instead of this field")] - cli_forced_thinlto_off: bool [UNTRACKED], + cli_forced_local_thinlto_off: bool [UNTRACKED], /// Remap source path prefixes in all output (messages, object files, debug, etc.). remap_path_prefix: Vec<(PathBuf, PathBuf)> [TRACKED_NO_CRATE_HASH], diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index beb22ab3eb9..6c37c8f1487 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -991,11 +991,8 @@ impl Session { return config::Lto::Fat; } config::LtoCli::Thin => { - return if self.opts.cli_forced_thinlto_off { - config::Lto::Fat - } else { - config::Lto::Thin - }; + // The user explicitly asked for ThinLTO + return config::Lto::Thin; } } @@ -1007,7 +1004,7 @@ impl Session { // If processing command line options determined that we're incompatible // with ThinLTO (e.g., `-C lto --emit llvm-ir`) then return that option. - if self.opts.cli_forced_thinlto_off { + if self.opts.cli_forced_local_thinlto_off { return config::Lto::No; } From c0472a5450f3e2a39d2ea1f64d8886411b377667 Mon Sep 17 00:00:00 2001 From: Byron Zhong Date: Thu, 27 Oct 2022 00:49:39 -0500 Subject: [PATCH 060/219] Fix E0433 diagnostics ignoring typo suggestions and outputing wrong message --- compiler/rustc_resolve/src/late.rs | 53 +++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 58853346a92..6337540efbd 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -31,7 +31,7 @@ use smallvec::{smallvec, SmallVec}; use rustc_span::source_map::{respan, Spanned}; use std::collections::{hash_map::Entry, BTreeSet}; -use std::mem::{replace, take}; +use std::mem::{replace, take, swap}; mod diagnostics; @@ -3334,10 +3334,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { let (mut err, candidates) = this.smart_resolve_report_errors(path, path_span, PathSource::Type, None); - if candidates.is_empty() { - err.cancel(); - return Some(parent_err); - } // There are two different error messages user might receive at // this point: @@ -3348,37 +3344,62 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { // latter one - for paths in expression-position. // // Thus (since we're in expression-position at this point), not to - // confuse the user, we want to keep the *message* from E0432 (so + // confuse the user, we want to keep the *message* from E0433 (so // `parent_err`), but we want *hints* from E0412 (so `err`). // // And that's what happens below - we're just mixing both messages // into a single one. let mut parent_err = this.r.into_struct_error(parent_err.span, parent_err.node); + // overwrite all properties with the parent's error message err.message = take(&mut parent_err.message); err.code = take(&mut parent_err.code); + swap(&mut err.span, &mut parent_err.span); err.children = take(&mut parent_err.children); + err.sort_span = parent_err.sort_span; + err.is_lint = parent_err.is_lint; + + // merge the parent's suggestions with the typo suggestions + fn append_result(res1: &mut Result, E>, res2: Result, E>) { + match res1 { + Ok(vec1) => match res2 { + Ok(mut vec2) => { vec1.append(&mut vec2); }, + Err(e) => { *res1 = Err(e) }, + }, + Err(_) => (), + }; + } + append_result(&mut err.suggestions, parent_err.suggestions.clone()); parent_err.cancel(); let def_id = this.parent_scope.module.nearest_parent_mod(); if this.should_report_errs() { - this.r.use_injections.push(UseError { - err, - candidates, - def_id, - instead: false, - suggestion: None, - path: path.into(), - is_call: source.is_call(), - }); + if candidates.is_empty() { + // When there is no suggested imports, we can just emit the error + // and suggestions immediately. Note that we bypass the usually error + // reporting routine (ie via `self.r.report_error`) because we need + // to post-process the `ResolutionError` above. + err.emit(); + } else { + // If there are suggested imports, the error reporting is delayed + this.r.use_injections.push(UseError { + err, + candidates, + def_id, + instead: false, + suggestion: None, + path: path.into(), + is_call: source.is_call(), + }); + } } else { err.cancel(); } // We don't return `Some(parent_err)` here, because the error will - // be already printed as part of the `use` injections + // be already printed either immediately or as part of the `use` injections None }; From 545702e432fb2c7971940f64f7cb57b0275ca500 Mon Sep 17 00:00:00 2001 From: Byron Zhong Date: Thu, 27 Oct 2022 01:36:07 -0500 Subject: [PATCH 061/219] Correct inconsistent error messages in tests --- src/test/ui/const-generics/issues/issue-82956.stderr | 2 +- src/test/ui/derived-errors/issue-31997-1.stderr | 2 +- src/test/ui/hygiene/no_implicit_prelude.stderr | 2 +- src/test/ui/proc-macro/amputate-span.stderr | 4 ++-- src/test/ui/resolve/missing-in-namespace.stderr | 4 ++-- src/test/ui/resolve/use_suggestion.stderr | 2 +- .../core-std-import-order-issue-83564.stderr | 2 +- .../ui/suggestions/suggest-tryinto-edition-change.rs | 5 +++-- .../suggestions/suggest-tryinto-edition-change.stderr | 11 +++-------- 9 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/test/ui/const-generics/issues/issue-82956.stderr b/src/test/ui/const-generics/issues/issue-82956.stderr index c8b999da981..d2320293e85 100644 --- a/src/test/ui/const-generics/issues/issue-82956.stderr +++ b/src/test/ui/const-generics/issues/issue-82956.stderr @@ -2,7 +2,7 @@ error[E0433]: failed to resolve: use of undeclared type `IntoIter` --> $DIR/issue-82956.rs:25:24 | LL | let mut iter = IntoIter::new(self); - | ^^^^^^^^ not found in this scope + | ^^^^^^^^ use of undeclared type `IntoIter` | help: consider importing one of these items | diff --git a/src/test/ui/derived-errors/issue-31997-1.stderr b/src/test/ui/derived-errors/issue-31997-1.stderr index 6d177666ed0..2f4aabf8453 100644 --- a/src/test/ui/derived-errors/issue-31997-1.stderr +++ b/src/test/ui/derived-errors/issue-31997-1.stderr @@ -2,7 +2,7 @@ error[E0433]: failed to resolve: use of undeclared type `HashMap` --> $DIR/issue-31997-1.rs:20:19 | LL | let mut map = HashMap::new(); - | ^^^^^^^ not found in this scope + | ^^^^^^^ use of undeclared type `HashMap` | help: consider importing this struct | diff --git a/src/test/ui/hygiene/no_implicit_prelude.stderr b/src/test/ui/hygiene/no_implicit_prelude.stderr index 0f2ff96b5ed..c48c840352f 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.stderr +++ b/src/test/ui/hygiene/no_implicit_prelude.stderr @@ -5,7 +5,7 @@ LL | fn f() { ::bar::m!(); } | ----------- in this macro invocation ... LL | Vec::new(); - | ^^^ not found in this scope + | ^^^ use of undeclared type `Vec` | = note: this error originates in the macro `::bar::m` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing this struct diff --git a/src/test/ui/proc-macro/amputate-span.stderr b/src/test/ui/proc-macro/amputate-span.stderr index 9553ba3da54..ab467041144 100644 --- a/src/test/ui/proc-macro/amputate-span.stderr +++ b/src/test/ui/proc-macro/amputate-span.stderr @@ -2,7 +2,7 @@ error[E0433]: failed to resolve: use of undeclared type `Command` --> $DIR/amputate-span.rs:49:5 | LL | Command::new("git"); - | ^^^^^^^ not found in this scope + | ^^^^^^^ use of undeclared type `Command` | help: consider importing this struct | @@ -13,7 +13,7 @@ error[E0433]: failed to resolve: use of undeclared type `Command` --> $DIR/amputate-span.rs:63:9 | LL | Command::new("git"); - | ^^^^^^^ not found in this scope + | ^^^^^^^ use of undeclared type `Command` | help: consider importing this struct | diff --git a/src/test/ui/resolve/missing-in-namespace.stderr b/src/test/ui/resolve/missing-in-namespace.stderr index 3d49b2e5dfc..fc925ba3b6a 100644 --- a/src/test/ui/resolve/missing-in-namespace.stderr +++ b/src/test/ui/resolve/missing-in-namespace.stderr @@ -1,8 +1,8 @@ error[E0433]: failed to resolve: could not find `hahmap` in `std` - --> $DIR/missing-in-namespace.rs:2:29 + --> $DIR/missing-in-namespace.rs:2:21 | LL | let _map = std::hahmap::HashMap::new(); - | ^^^^^^^ not found in `std::hahmap` + | ^^^^^^ could not find `hahmap` in `std` | help: consider importing this struct | diff --git a/src/test/ui/resolve/use_suggestion.stderr b/src/test/ui/resolve/use_suggestion.stderr index 4fff179b1fe..58cb659e822 100644 --- a/src/test/ui/resolve/use_suggestion.stderr +++ b/src/test/ui/resolve/use_suggestion.stderr @@ -8,7 +8,7 @@ error[E0433]: failed to resolve: use of undeclared type `HashMap` --> $DIR/use_suggestion.rs:2:14 | LL | let x1 = HashMap::new(); - | ^^^^^^^ not found in this scope + | ^^^^^^^ use of undeclared type `HashMap` | help: consider importing this struct | diff --git a/src/test/ui/suggestions/core-std-import-order-issue-83564.stderr b/src/test/ui/suggestions/core-std-import-order-issue-83564.stderr index ce85d93b96c..e4e1fc591c4 100644 --- a/src/test/ui/suggestions/core-std-import-order-issue-83564.stderr +++ b/src/test/ui/suggestions/core-std-import-order-issue-83564.stderr @@ -2,7 +2,7 @@ error[E0433]: failed to resolve: use of undeclared type `NonZeroU32` --> $DIR/core-std-import-order-issue-83564.rs:8:14 | LL | let _x = NonZeroU32::new(5).unwrap(); - | ^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^ use of undeclared type `NonZeroU32` | help: consider importing one of these items | diff --git a/src/test/ui/suggestions/suggest-tryinto-edition-change.rs b/src/test/ui/suggestions/suggest-tryinto-edition-change.rs index f03b42bbe47..70c4b210d3a 100644 --- a/src/test/ui/suggestions/suggest-tryinto-edition-change.rs +++ b/src/test/ui/suggestions/suggest-tryinto-edition-change.rs @@ -10,18 +10,19 @@ fn test() { let _i: i16 = TryFrom::try_from(0_i32).unwrap(); //~^ ERROR failed to resolve: use of undeclared type - //~| NOTE not found in this scope + //~| NOTE use of undeclared type //~| NOTE 'std::convert::TryFrom' is included in the prelude starting in Edition 2021 //~| NOTE 'core::convert::TryFrom' is included in the prelude starting in Edition 2021 let _i: i16 = TryInto::try_into(0_i32).unwrap(); //~^ ERROR failed to resolve: use of undeclared type - //~| NOTE not found in this scope + //~| NOTE use of undeclared type //~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021 //~| NOTE 'core::convert::TryInto' is included in the prelude starting in Edition 2021 let _v: Vec<_> = FromIterator::from_iter(&[1]); //~^ ERROR failed to resolve: use of undeclared type + //~| NOTE use of undeclared type //~| NOTE 'std::iter::FromIterator' is included in the prelude starting in Edition 2021 //~| NOTE 'core::iter::FromIterator' is included in the prelude starting in Edition 2021 } diff --git a/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr b/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr index 86f48716b16..3d1f2492360 100644 --- a/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr +++ b/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr @@ -2,7 +2,7 @@ error[E0433]: failed to resolve: use of undeclared type `TryFrom` --> $DIR/suggest-tryinto-edition-change.rs:11:19 | LL | let _i: i16 = TryFrom::try_from(0_i32).unwrap(); - | ^^^^^^^ not found in this scope + | ^^^^^^^ use of undeclared type `TryFrom` | = note: 'std::convert::TryFrom' is included in the prelude starting in Edition 2021 = note: 'core::convert::TryFrom' is included in the prelude starting in Edition 2021 @@ -17,7 +17,7 @@ error[E0433]: failed to resolve: use of undeclared type `TryInto` --> $DIR/suggest-tryinto-edition-change.rs:17:19 | LL | let _i: i16 = TryInto::try_into(0_i32).unwrap(); - | ^^^^^^^ not found in this scope + | ^^^^^^^ use of undeclared type `TryInto` | = note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021 = note: 'core::convert::TryInto' is included in the prelude starting in Edition 2021 @@ -32,12 +32,7 @@ error[E0433]: failed to resolve: use of undeclared type `FromIterator` --> $DIR/suggest-tryinto-edition-change.rs:23:22 | LL | let _v: Vec<_> = FromIterator::from_iter(&[1]); - | ^^^^^^^^^^^^ - | - ::: $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL - | -LL | pub trait IntoIterator { - | ---------------------- similarly named trait `IntoIterator` defined here + | ^^^^^^^^^^^^ use of undeclared type `FromIterator` | = note: 'std::iter::FromIterator' is included in the prelude starting in Edition 2021 = note: 'core::iter::FromIterator' is included in the prelude starting in Edition 2021 From 20a8427a113eba6a56090f2c9588963eba43c7ac Mon Sep 17 00:00:00 2001 From: Byron Zhong Date: Thu, 27 Oct 2022 01:41:24 -0500 Subject: [PATCH 062/219] Remove redundant braces --- compiler/rustc_resolve/src/late.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 6337540efbd..058ce0aa616 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -31,7 +31,7 @@ use smallvec::{smallvec, SmallVec}; use rustc_span::source_map::{respan, Spanned}; use std::collections::{hash_map::Entry, BTreeSet}; -use std::mem::{replace, take, swap}; +use std::mem::{replace, swap, take}; mod diagnostics; @@ -3334,7 +3334,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { let (mut err, candidates) = this.smart_resolve_report_errors(path, path_span, PathSource::Type, None); - // There are two different error messages user might receive at // this point: // - E0412 cannot find type `{}` in this scope @@ -3363,8 +3362,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { fn append_result(res1: &mut Result, E>, res2: Result, E>) { match res1 { Ok(vec1) => match res2 { - Ok(mut vec2) => { vec1.append(&mut vec2); }, - Err(e) => { *res1 = Err(e) }, + Ok(mut vec2) => vec1.append(&mut vec2), + Err(e) => *res1 = Err(e), }, Err(_) => (), }; From c4c4c566d080ccd7511ce6151ef5f7a6ed39522f Mon Sep 17 00:00:00 2001 From: Jakob Degen Date: Sun, 4 Sep 2022 20:00:31 -0700 Subject: [PATCH 063/219] Replace `mir_map.0` dump with `built` phase change dump --- compiler/rustc_mir_transform/src/lib.rs | 2 +- compiler/rustc_mir_transform/src/shim.rs | 2 +- ...e_edges.full_tested_match.built.after.mir} | 29 ++++---- ..._edges.full_tested_match2.built.after.mir} | 22 +++--- .../match_false_edges.main.built.after.mir} | 73 ++++++++++++------- .../{ => building}/match_false_edges.rs | 6 +- .../mir-opt/const-promotion-extern-static.rs | 2 +- ...omotion_extern_static.BOP.built.after.mir} | 2 +- ...ap.0.mir => enum_cast.bar.built.after.mir} | 2 +- ...ap.0.mir => enum_cast.boo.built.after.mir} | 2 +- ...0.mir => enum_cast.droppy.built.after.mir} | 2 +- ...ap.0.mir => enum_cast.foo.built.after.mir} | 2 +- src/test/mir-opt/enum_cast.rs | 8 +- ...ap.0.dot => graphviz.main.built.after.dot} | 0 src/test/mir-opt/graphviz.rs | 2 +- src/test/mir-opt/issue-101867.rs | 2 +- src/test/mir-opt/issue-49232.rs | 2 +- src/test/mir-opt/issue-72181-1.rs | 4 +- src/test/mir-opt/issue-72181.rs | 6 +- src/test/mir-opt/issue-91633.rs | 8 +- src/test/mir-opt/issue-99325.rs | 2 +- ....mir => issue_101867.main.built.after.mir} | 2 +- ...0.mir => issue_49232.main.built.after.mir} | 2 +- ....0.mir => issue_72181.bar.built.after.mir} | 2 +- ....0.mir => issue_72181.foo.built.after.mir} | 2 +- ...0.mir => issue_72181.main.built.after.mir} | 2 +- ....0.mir => issue_72181_1.f.built.after.mir} | 2 +- ...mir => issue_72181_1.main.built.after.mir} | 2 +- ....0.mir => issue_91633.bar.built.after.mir} | 2 +- ....0.mir => issue_91633.foo.built.after.mir} | 2 +- ....0.mir => issue_91633.fun.built.after.mir} | 2 +- ....0.mir => issue_91633.hey.built.after.mir} | 2 +- ...0.mir => issue_99325.main.built.after.mir} | 2 +- src/test/mir-opt/receiver-ptr-mutability.rs | 2 +- ...eiver_ptr_mutability.main.built.after.mir} | 2 +- src/test/mir-opt/simple-match.rs | 2 +- ...> simple_match.match_bool.built.after.mir} | 2 +- src/test/mir-opt/spanview-block.rs | 2 +- src/test/mir-opt/spanview-statement.rs | 2 +- src/test/mir-opt/spanview-terminator.rs | 2 +- ...l => spanview_block.main.built.after.html} | 2 +- ... spanview_statement.main.built.after.html} | 2 +- ...spanview_terminator.main.built.after.html} | 2 +- ..._live_dead_in_statics.XXX.built.after.mir} | 2 +- .../mir-opt/storage_live_dead_in_statics.rs | 2 +- ..._out.move_out_by_subslice.built.after.mir} | 2 +- ...ove_out.move_out_from_end.built.after.mir} | 2 +- src/test/mir-opt/uniform_array_move_out.rs | 4 +- src/test/mir-opt/unusual-item-types.rs | 6 +- ...em_types.E-V-{constant#0}.built.after.mir} | 2 +- ...es.Test-X-{constructor#0}.built.after.mir} | 2 +- ...pl#0}-ASSOCIATED_CONSTANT.built.after.mir} | 2 +- 52 files changed, 136 insertions(+), 112 deletions(-) rename src/test/mir-opt/{match_false_edges.full_tested_match.PromoteTemps.after.mir => building/match_false_edges.full_tested_match.built.after.mir} (85%) rename src/test/mir-opt/{match_false_edges.full_tested_match2.PromoteTemps.before.mir => building/match_false_edges.full_tested_match2.built.after.mir} (91%) rename src/test/mir-opt/{match_false_edges.main.PromoteTemps.before.mir => building/match_false_edges.main.built.after.mir} (83%) rename src/test/mir-opt/{ => building}/match_false_edges.rs (77%) rename src/test/mir-opt/{const_promotion_extern_static.BOP.mir_map.0.mir => const_promotion_extern_static.BOP.built.after.mir} (97%) rename src/test/mir-opt/{enum_cast.bar.mir_map.0.mir => enum_cast.bar.built.after.mir} (96%) rename src/test/mir-opt/{enum_cast.boo.mir_map.0.mir => enum_cast.boo.built.after.mir} (96%) rename src/test/mir-opt/{enum_cast.droppy.mir_map.0.mir => enum_cast.droppy.built.after.mir} (99%) rename src/test/mir-opt/{enum_cast.foo.mir_map.0.mir => enum_cast.foo.built.after.mir} (96%) rename src/test/mir-opt/{graphviz.main.mir_map.0.dot => graphviz.main.built.after.dot} (100%) rename src/test/mir-opt/{issue_101867.main.mir_map.0.mir => issue_101867.main.built.after.mir} (99%) rename src/test/mir-opt/{issue_49232.main.mir_map.0.mir => issue_49232.main.built.after.mir} (99%) rename src/test/mir-opt/{issue_72181.bar.mir_map.0.mir => issue_72181.bar.built.after.mir} (96%) rename src/test/mir-opt/{issue_72181.foo.mir_map.0.mir => issue_72181.foo.built.after.mir} (98%) rename src/test/mir-opt/{issue_72181.main.mir_map.0.mir => issue_72181.main.built.after.mir} (99%) rename src/test/mir-opt/{issue_72181_1.f.mir_map.0.mir => issue_72181_1.f.built.after.mir} (97%) rename src/test/mir-opt/{issue_72181_1.main.mir_map.0.mir => issue_72181_1.main.built.after.mir} (99%) rename src/test/mir-opt/{issue_91633.bar.mir_map.0.mir => issue_91633.bar.built.after.mir} (98%) rename src/test/mir-opt/{issue_91633.foo.mir_map.0.mir => issue_91633.foo.built.after.mir} (99%) rename src/test/mir-opt/{issue_91633.fun.mir_map.0.mir => issue_91633.fun.built.after.mir} (98%) rename src/test/mir-opt/{issue_91633.hey.mir_map.0.mir => issue_91633.hey.built.after.mir} (98%) rename src/test/mir-opt/{issue_99325.main.mir_map.0.mir => issue_99325.main.built.after.mir} (99%) rename src/test/mir-opt/{receiver_ptr_mutability.main.mir_map.0.mir => receiver_ptr_mutability.main.built.after.mir} (99%) rename src/test/mir-opt/{simple_match.match_bool.mir_map.0.mir => simple_match.match_bool.built.after.mir} (96%) rename src/test/mir-opt/{spanview_block.main.mir_map.0.html => spanview_block.main.built.after.html} (97%) rename src/test/mir-opt/{spanview_statement.main.mir_map.0.html => spanview_statement.main.built.after.html} (97%) rename src/test/mir-opt/{spanview_terminator.main.mir_map.0.html => spanview_terminator.main.built.after.html} (97%) rename src/test/mir-opt/{storage_live_dead_in_statics.XXX.mir_map.0.mir => storage_live_dead_in_statics.XXX.built.after.mir} (99%) rename src/test/mir-opt/{uniform_array_move_out.move_out_by_subslice.mir_map.0.mir => uniform_array_move_out.move_out_by_subslice.built.after.mir} (99%) rename src/test/mir-opt/{uniform_array_move_out.move_out_from_end.mir_map.0.mir => uniform_array_move_out.move_out_from_end.built.after.mir} (99%) rename src/test/mir-opt/{unusual_item_types.E-V-{constant#0}.mir_map.0.mir => unusual_item_types.E-V-{constant#0}.built.after.mir} (88%) rename src/test/mir-opt/{unusual_item_types.Test-X-{constructor#0}.mir_map.0.mir => unusual_item_types.Test-X-{constructor#0}.built.after.mir} (94%) rename src/test/mir-opt/{unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.mir => unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir} (94%) diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 5be2232547b..4791be1306c 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -288,7 +288,7 @@ fn mir_const<'tcx>( let mut body = tcx.mir_built(def).steal(); - rustc_middle::mir::dump_mir(tcx, None, "mir_map", &0, &body, |_, _| Ok(())); + pass_manager::dump_mir_for_phase_change(tcx, &body); pm::run_passes( tcx, diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index c19380ef89c..343bb3d44e8 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -845,7 +845,7 @@ pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> { span, ); - rustc_middle::mir::dump_mir(tcx, None, "mir_map", &0, &body, |_, _| Ok(())); + crate::pass_manager::dump_mir_for_phase_change(tcx, &body); body } diff --git a/src/test/mir-opt/match_false_edges.full_tested_match.PromoteTemps.after.mir b/src/test/mir-opt/building/match_false_edges.full_tested_match.built.after.mir similarity index 85% rename from src/test/mir-opt/match_false_edges.full_tested_match.PromoteTemps.after.mir rename to src/test/mir-opt/building/match_false_edges.full_tested_match.built.after.mir index b193a8d76fc..9a190c3d60e 100644 --- a/src/test/mir-opt/match_false_edges.full_tested_match.PromoteTemps.after.mir +++ b/src/test/mir-opt/building/match_false_edges.full_tested_match.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `full_tested_match` after PromoteTemps +// MIR for `full_tested_match` after built fn full_tested_match() -> () { let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:28: +0:28 @@ -12,7 +12,6 @@ fn full_tested_match() -> () { let mut _8: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:35: +2:36 let _9: i32; // in scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15 let mut _10: i32; // in scope 0 at $DIR/match_false_edges.rs:+3:24: +3:25 - let mut _11: &std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 scope 1 { } scope 2 { @@ -34,7 +33,7 @@ fn full_tested_match() -> () { bb1: { _1 = (const 3_i32, const 3_i32); // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23 - goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23 + goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23 } bb2: { @@ -42,7 +41,7 @@ fn full_tested_match() -> () { } bb3: { - falseEdge -> [real: bb9, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:16 + falseEdge -> [real: bb10, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:16 } bb4: { @@ -51,14 +50,10 @@ fn full_tested_match() -> () { bb5: { StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - _11 = const _; // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - // mir::Constant - // + span: $DIR/match_false_edges.rs:14:14: 14:15 - // + literal: Const { ty: &Option, val: Unevaluated(full_tested_match, [], Some(promoted[0])) } - _6 = &(((*_11) as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + _6 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 _4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 - _7 = guard() -> [return: bb6, unwind: bb11]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + _7 = guard() -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 // mir::Constant // + span: $DIR/match_false_edges.rs:14:20: 14:25 // + literal: Const { ty: fn() -> bool {guard}, val: Value() } @@ -80,16 +75,20 @@ fn full_tested_match() -> () { StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:+2:36: +2:37 StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 - goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 + goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 } bb8: { + goto -> bb9; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + } + + bb9: { StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 goto -> bb3; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 } - bb9: { + bb10: { StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15 _9 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15 StorageLive(_10); // scope 3 at $DIR/match_false_edges.rs:+3:24: +3:25 @@ -97,17 +96,17 @@ fn full_tested_match() -> () { _1 = (const 2_i32, move _10); // scope 3 at $DIR/match_false_edges.rs:+3:20: +3:26 StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:+3:25: +3:26 StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26 - goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26 + goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26 } - bb10: { + bb11: { StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:28: +6:2 return; // scope 0 at $DIR/match_false_edges.rs:+6:2: +6:2 } - bb11 (cleanup): { + bb12 (cleanup): { resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +6:2 } } diff --git a/src/test/mir-opt/match_false_edges.full_tested_match2.PromoteTemps.before.mir b/src/test/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir similarity index 91% rename from src/test/mir-opt/match_false_edges.full_tested_match2.PromoteTemps.before.mir rename to src/test/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir index 145ed878fc9..1c9953e7efc 100644 --- a/src/test/mir-opt/match_false_edges.full_tested_match2.PromoteTemps.before.mir +++ b/src/test/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `full_tested_match2` before PromoteTemps +// MIR for `full_tested_match2` after built fn full_tested_match2() -> () { let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:29: +0:29 @@ -32,7 +32,7 @@ fn full_tested_match2() -> () { } bb1: { - falseEdge -> [real: bb9, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:13 + falseEdge -> [real: bb10, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:13 } bb2: { @@ -47,7 +47,7 @@ fn full_tested_match2() -> () { _1 = (const 2_i32, move _10); // scope 3 at $DIR/match_false_edges.rs:+4:20: +4:26 StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:+4:25: +4:26 StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26 - goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26 + goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26 } bb4: { @@ -59,7 +59,7 @@ fn full_tested_match2() -> () { _6 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 _4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 - _7 = guard() -> [return: bb6, unwind: bb11]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + _7 = guard() -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 // mir::Constant // + span: $DIR/match_false_edges.rs:25:20: 25:25 // + literal: Const { ty: fn() -> bool {guard}, val: Value() } @@ -81,28 +81,32 @@ fn full_tested_match2() -> () { StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:+2:36: +2:37 StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 - goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 + goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 } bb8: { + goto -> bb9; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + } + + bb9: { StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 falseEdge -> [real: bb3, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 } - bb9: { + bb10: { _1 = (const 3_i32, const 3_i32); // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23 - goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23 + goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23 } - bb10: { + bb11: { StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:29: +6:2 return; // scope 0 at $DIR/match_false_edges.rs:+6:2: +6:2 } - bb11 (cleanup): { + bb12 (cleanup): { resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +6:2 } } diff --git a/src/test/mir-opt/match_false_edges.main.PromoteTemps.before.mir b/src/test/mir-opt/building/match_false_edges.main.built.after.mir similarity index 83% rename from src/test/mir-opt/match_false_edges.main.PromoteTemps.before.mir rename to src/test/mir-opt/building/match_false_edges.main.built.after.mir index 8f40e8a887f..08c67d39d78 100644 --- a/src/test/mir-opt/match_false_edges.main.PromoteTemps.before.mir +++ b/src/test/mir-opt/building/match_false_edges.main.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `main` before PromoteTemps +// MIR for `main` after built fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:11: +0:11 @@ -43,41 +43,54 @@ fn main() -> () { } bb1: { - falseEdge -> [real: bb9, imaginary: bb4]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11 + falseEdge -> [real: bb13, imaginary: bb6]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11 } bb2: { - falseEdge -> [real: bb5, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:17 + falseEdge -> [real: bb8, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:17 } bb3: { + goto -> bb1; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26 + } + + bb4: { + _3 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 + switchInt(move _3) -> [1_isize: bb6, otherwise: bb5]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26 + } + + bb5: { StorageLive(_14); // scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11 _14 = _2; // scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11 _1 = const 4_i32; // scope 5 at $DIR/match_false_edges.rs:+5:15: +5:16 StorageDead(_14); // scope 0 at $DIR/match_false_edges.rs:+5:15: +5:16 - goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:+5:15: +5:16 + goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+5:15: +5:16 } - bb4: { - falseEdge -> [real: bb10, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+4:9: +4:16 + bb6: { + falseEdge -> [real: bb14, imaginary: bb5]; // scope 0 at $DIR/match_false_edges.rs:+4:9: +4:16 } - bb5: { + bb7: { + goto -> bb5; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26 + } + + bb8: { StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 _7 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 _5 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 StorageLive(_8); // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 - _8 = guard() -> [return: bb6, unwind: bb15]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 + _8 = guard() -> [return: bb9, unwind: bb20]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 // mir::Constant // + span: $DIR/match_false_edges.rs:34:21: 34:26 // + literal: Const { ty: fn() -> bool {guard}, val: Value() } } - bb6: { - switchInt(move _8) -> [false: bb8, otherwise: bb7]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 + bb9: { + switchInt(move _8) -> [false: bb11, otherwise: bb10]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 } - bb7: { + bb10: { StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28 FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28 FakeRead(ForGuardBinding, _7); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28 @@ -86,41 +99,45 @@ fn main() -> () { _1 = const 1_i32; // scope 2 at $DIR/match_false_edges.rs:+2:32: +2:33 StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 - goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 + goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 } - bb8: { + bb11: { + goto -> bb12; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 + } + + bb12: { StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28 StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 - falseEdge -> [real: bb1, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 + falseEdge -> [real: bb3, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 } - bb9: { + bb13: { StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11 _9 = _2; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11 _1 = const 2_i32; // scope 3 at $DIR/match_false_edges.rs:+3:15: +3:16 StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+3:15: +3:16 - goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:+3:15: +3:16 + goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+3:15: +3:16 } - bb10: { + bb14: { StorageLive(_11); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 _11 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 _5 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 StorageLive(_12); // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 StorageLive(_13); // scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28 _13 = (*_11); // scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28 - _12 = guard2(move _13) -> [return: bb11, unwind: bb15]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 + _12 = guard2(move _13) -> [return: bb15, unwind: bb20]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 // mir::Constant // + span: $DIR/match_false_edges.rs:36:20: 36:26 // + literal: Const { ty: fn(i32) -> bool {guard2}, val: Value() } } - bb11: { - switchInt(move _12) -> [false: bb13, otherwise: bb12]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 + bb15: { + switchInt(move _12) -> [false: bb17, otherwise: bb16]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 } - bb12: { + bb16: { StorageDead(_13); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 @@ -130,24 +147,28 @@ fn main() -> () { _1 = const 3_i32; // scope 4 at $DIR/match_false_edges.rs:+4:33: +4:34 StorageDead(_10); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 - goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 + goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 } - bb13: { + bb17: { + goto -> bb18; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 + } + + bb18: { StorageDead(_13); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 - falseEdge -> [real: bb3, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 + falseEdge -> [real: bb7, imaginary: bb5]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 } - bb14: { + bb19: { StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7 StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7 _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:11: +7:2 return; // scope 0 at $DIR/match_false_edges.rs:+7:2: +7:2 } - bb15 (cleanup): { + bb20 (cleanup): { resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +7:2 } } diff --git a/src/test/mir-opt/match_false_edges.rs b/src/test/mir-opt/building/match_false_edges.rs similarity index 77% rename from src/test/mir-opt/match_false_edges.rs rename to src/test/mir-opt/building/match_false_edges.rs index 3603253dafc..ddfcc149319 100644 --- a/src/test/mir-opt/match_false_edges.rs +++ b/src/test/mir-opt/building/match_false_edges.rs @@ -8,7 +8,7 @@ fn guard2(_: i32) -> bool { // no_mangle to make sure this gets instantiated even in an executable. #[no_mangle] -// EMIT_MIR match_false_edges.full_tested_match.PromoteTemps.after.mir +// EMIT_MIR match_false_edges.full_tested_match.built.after.mir pub fn full_tested_match() { let _ = match Some(42) { Some(x) if guard() => (1, x), @@ -19,7 +19,7 @@ pub fn full_tested_match() { // no_mangle to make sure this gets instantiated even in an executable. #[no_mangle] -// EMIT_MIR match_false_edges.full_tested_match2.PromoteTemps.before.mir +// EMIT_MIR match_false_edges.full_tested_match2.built.after.mir pub fn full_tested_match2() { let _ = match Some(42) { Some(x) if guard() => (1, x), @@ -28,7 +28,7 @@ pub fn full_tested_match2() { }; } -// EMIT_MIR match_false_edges.main.PromoteTemps.before.mir +// EMIT_MIR match_false_edges.main.built.after.mir fn main() { let _ = match Some(1) { Some(_w) if guard() => 1, diff --git a/src/test/mir-opt/const-promotion-extern-static.rs b/src/test/mir-opt/const-promotion-extern-static.rs index a0d4e9b2c65..e4261cfe504 100644 --- a/src/test/mir-opt/const-promotion-extern-static.rs +++ b/src/test/mir-opt/const-promotion-extern-static.rs @@ -12,7 +12,7 @@ static mut BAR: *const &i32 = [&Y].as_ptr(); // EMIT_MIR const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir static mut FOO: *const &i32 = [unsafe { &X }].as_ptr(); -// EMIT_MIR const_promotion_extern_static.BOP.mir_map.0.mir +// EMIT_MIR const_promotion_extern_static.BOP.built.after.mir static BOP: &i32 = &13; fn main() {} diff --git a/src/test/mir-opt/const_promotion_extern_static.BOP.mir_map.0.mir b/src/test/mir-opt/const_promotion_extern_static.BOP.built.after.mir similarity index 97% rename from src/test/mir-opt/const_promotion_extern_static.BOP.mir_map.0.mir rename to src/test/mir-opt/const_promotion_extern_static.BOP.built.after.mir index 90920fbe7f8..5bda86bbd4f 100644 --- a/src/test/mir-opt/const_promotion_extern_static.BOP.mir_map.0.mir +++ b/src/test/mir-opt/const_promotion_extern_static.BOP.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `BOP` 0 mir_map +// MIR for `BOP` after built static BOP: &i32 = { let mut _0: &i32; // return place in scope 0 at $DIR/const-promotion-extern-static.rs:+0:13: +0:17 diff --git a/src/test/mir-opt/enum_cast.bar.mir_map.0.mir b/src/test/mir-opt/enum_cast.bar.built.after.mir similarity index 96% rename from src/test/mir-opt/enum_cast.bar.mir_map.0.mir rename to src/test/mir-opt/enum_cast.bar.built.after.mir index e58085f701a..194b107bead 100644 --- a/src/test/mir-opt/enum_cast.bar.mir_map.0.mir +++ b/src/test/mir-opt/enum_cast.bar.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `bar` 0 mir_map +// MIR for `bar` after built fn bar(_1: Bar) -> usize { debug bar => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11 diff --git a/src/test/mir-opt/enum_cast.boo.mir_map.0.mir b/src/test/mir-opt/enum_cast.boo.built.after.mir similarity index 96% rename from src/test/mir-opt/enum_cast.boo.mir_map.0.mir rename to src/test/mir-opt/enum_cast.boo.built.after.mir index 525c6234ed3..dde26afc77a 100644 --- a/src/test/mir-opt/enum_cast.boo.mir_map.0.mir +++ b/src/test/mir-opt/enum_cast.boo.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `boo` 0 mir_map +// MIR for `boo` after built fn boo(_1: Boo) -> usize { debug boo => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11 diff --git a/src/test/mir-opt/enum_cast.droppy.mir_map.0.mir b/src/test/mir-opt/enum_cast.droppy.built.after.mir similarity index 99% rename from src/test/mir-opt/enum_cast.droppy.mir_map.0.mir rename to src/test/mir-opt/enum_cast.droppy.built.after.mir index bb5faa48047..a43c523c71f 100644 --- a/src/test/mir-opt/enum_cast.droppy.mir_map.0.mir +++ b/src/test/mir-opt/enum_cast.droppy.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `droppy` 0 mir_map +// MIR for `droppy` after built fn droppy() -> () { let mut _0: (); // return place in scope 0 at $DIR/enum_cast.rs:+0:13: +0:13 diff --git a/src/test/mir-opt/enum_cast.foo.mir_map.0.mir b/src/test/mir-opt/enum_cast.foo.built.after.mir similarity index 96% rename from src/test/mir-opt/enum_cast.foo.mir_map.0.mir rename to src/test/mir-opt/enum_cast.foo.built.after.mir index a1d29a0b903..17e0abf2e31 100644 --- a/src/test/mir-opt/enum_cast.foo.mir_map.0.mir +++ b/src/test/mir-opt/enum_cast.foo.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `foo` 0 mir_map +// MIR for `foo` after built fn foo(_1: Foo) -> usize { debug foo => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11 diff --git a/src/test/mir-opt/enum_cast.rs b/src/test/mir-opt/enum_cast.rs index 090142aaf35..98fd5acfb14 100644 --- a/src/test/mir-opt/enum_cast.rs +++ b/src/test/mir-opt/enum_cast.rs @@ -1,6 +1,6 @@ -// EMIT_MIR enum_cast.foo.mir_map.0.mir -// EMIT_MIR enum_cast.bar.mir_map.0.mir -// EMIT_MIR enum_cast.boo.mir_map.0.mir +// EMIT_MIR enum_cast.foo.built.after.mir +// EMIT_MIR enum_cast.bar.built.after.mir +// EMIT_MIR enum_cast.boo.built.after.mir enum Foo { A @@ -27,7 +27,7 @@ fn boo(boo: Boo) -> usize { boo as usize } -// EMIT_MIR enum_cast.droppy.mir_map.0.mir +// EMIT_MIR enum_cast.droppy.built.after.mir enum Droppy { A, B, C } diff --git a/src/test/mir-opt/graphviz.main.mir_map.0.dot b/src/test/mir-opt/graphviz.main.built.after.dot similarity index 100% rename from src/test/mir-opt/graphviz.main.mir_map.0.dot rename to src/test/mir-opt/graphviz.main.built.after.dot diff --git a/src/test/mir-opt/graphviz.rs b/src/test/mir-opt/graphviz.rs index 074dba2c373..6906b86c2a5 100644 --- a/src/test/mir-opt/graphviz.rs +++ b/src/test/mir-opt/graphviz.rs @@ -1,5 +1,5 @@ // Test graphviz output // compile-flags: -Z dump-mir-graphviz -// EMIT_MIR graphviz.main.mir_map.0.dot +// EMIT_MIR graphviz.main.built.after.dot fn main() {} diff --git a/src/test/mir-opt/issue-101867.rs b/src/test/mir-opt/issue-101867.rs index 8a357eb7995..a32d8cb3714 100644 --- a/src/test/mir-opt/issue-101867.rs +++ b/src/test/mir-opt/issue-101867.rs @@ -1,4 +1,4 @@ -// EMIT_MIR issue_101867.main.mir_map.0.mir +// EMIT_MIR issue_101867.main.built.after.mir fn main() { let x: Option = Some(1); let Some(y) = x else { diff --git a/src/test/mir-opt/issue-49232.rs b/src/test/mir-opt/issue-49232.rs index 86494c76aec..7e9f0de81f7 100644 --- a/src/test/mir-opt/issue-49232.rs +++ b/src/test/mir-opt/issue-49232.rs @@ -1,7 +1,7 @@ // We must mark a variable whose initialization fails due to an // abort statement as StorageDead. -// EMIT_MIR issue_49232.main.mir_map.0.mir +// EMIT_MIR issue_49232.main.built.after.mir fn main() { loop { let beacon = { diff --git a/src/test/mir-opt/issue-72181-1.rs b/src/test/mir-opt/issue-72181-1.rs index 91e98adbe80..8ae2599ec73 100644 --- a/src/test/mir-opt/issue-72181-1.rs +++ b/src/test/mir-opt/issue-72181-1.rs @@ -6,12 +6,12 @@ enum Void {} -// EMIT_MIR issue_72181_1.f.mir_map.0.mir +// EMIT_MIR issue_72181_1.f.built.after.mir fn f(v: Void) -> ! { match v {} } -// EMIT_MIR issue_72181_1.main.mir_map.0.mir +// EMIT_MIR issue_72181_1.main.built.after.mir fn main() { let v: Void = unsafe { std::mem::transmute::<(), Void>(()) diff --git a/src/test/mir-opt/issue-72181.rs b/src/test/mir-opt/issue-72181.rs index ebb5f5042fc..6a32d4bbee2 100644 --- a/src/test/mir-opt/issue-72181.rs +++ b/src/test/mir-opt/issue-72181.rs @@ -12,14 +12,14 @@ union Foo { } -// EMIT_MIR issue_72181.foo.mir_map.0.mir +// EMIT_MIR issue_72181.foo.built.after.mir fn foo(xs: [(Never, u32); 1]) -> u32 { xs[0].1 } -// EMIT_MIR issue_72181.bar.mir_map.0.mir +// EMIT_MIR issue_72181.bar.built.after.mir fn bar([(_, x)]: [(Never, u32); 1]) -> u32 { x } -// EMIT_MIR issue_72181.main.mir_map.0.mir +// EMIT_MIR issue_72181.main.built.after.mir fn main() { let _ = mem::size_of::(); diff --git a/src/test/mir-opt/issue-91633.rs b/src/test/mir-opt/issue-91633.rs index 8f66019857f..9127cacc97c 100644 --- a/src/test/mir-opt/issue-91633.rs +++ b/src/test/mir-opt/issue-91633.rs @@ -1,5 +1,5 @@ // compile-flags: -Z mir-opt-level=0 -// EMIT_MIR issue_91633.hey.mir_map.0.mir +// EMIT_MIR issue_91633.hey.built.after.mir fn hey (it: &[T]) where [T] : std::ops::Index, @@ -7,7 +7,7 @@ fn hey (it: &[T]) let _ = &it[0]; } -// EMIT_MIR issue_91633.bar.mir_map.0.mir +// EMIT_MIR issue_91633.bar.built.after.mir fn bar (it: Box<[T]>) where [T] : std::ops::Index, @@ -15,14 +15,14 @@ fn bar (it: Box<[T]>) let _ = it[0]; } -// EMIT_MIR issue_91633.fun.mir_map.0.mir +// EMIT_MIR issue_91633.fun.built.after.mir fn fun (it: &[T]) -> &T { let f = &it[0]; f } -// EMIT_MIR issue_91633.foo.mir_map.0.mir +// EMIT_MIR issue_91633.foo.built.after.mir fn foo (it: Box<[T]>) -> T { let f = it[0].clone(); diff --git a/src/test/mir-opt/issue-99325.rs b/src/test/mir-opt/issue-99325.rs index b79946ea8b5..fe819cddb2c 100644 --- a/src/test/mir-opt/issue-99325.rs +++ b/src/test/mir-opt/issue-99325.rs @@ -5,7 +5,7 @@ pub fn function_with_bytes() -> &'static [u8] { BYTES } -// EMIT_MIR issue_99325.main.mir_map.0.mir +// EMIT_MIR issue_99325.main.built.after.mir pub fn main() { assert_eq!(function_with_bytes::(), &[0x41, 0x41, 0x41, 0x41]); assert_eq!(function_with_bytes::<{ &[0x41, 0x41, 0x41, 0x41] }>(), b"AAAA"); diff --git a/src/test/mir-opt/issue_101867.main.mir_map.0.mir b/src/test/mir-opt/issue_101867.main.built.after.mir similarity index 99% rename from src/test/mir-opt/issue_101867.main.mir_map.0.mir rename to src/test/mir-opt/issue_101867.main.built.after.mir index 42a9e558760..6834205b649 100644 --- a/src/test/mir-opt/issue_101867.main.mir_map.0.mir +++ b/src/test/mir-opt/issue_101867.main.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `main` 0 mir_map +// MIR for `main` after built | User Type Annotations | 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option) }, span: $DIR/issue-101867.rs:3:12: 3:22, inferred_ty: std::option::Option diff --git a/src/test/mir-opt/issue_49232.main.mir_map.0.mir b/src/test/mir-opt/issue_49232.main.built.after.mir similarity index 99% rename from src/test/mir-opt/issue_49232.main.mir_map.0.mir rename to src/test/mir-opt/issue_49232.main.built.after.mir index 821323b5e24..b90f8c13589 100644 --- a/src/test/mir-opt/issue_49232.main.mir_map.0.mir +++ b/src/test/mir-opt/issue_49232.main.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `main` 0 mir_map +// MIR for `main` after built fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/issue-49232.rs:+0:11: +0:11 diff --git a/src/test/mir-opt/issue_72181.bar.mir_map.0.mir b/src/test/mir-opt/issue_72181.bar.built.after.mir similarity index 96% rename from src/test/mir-opt/issue_72181.bar.mir_map.0.mir rename to src/test/mir-opt/issue_72181.bar.built.after.mir index 972ce1d5078..aa9c9986aac 100644 --- a/src/test/mir-opt/issue_72181.bar.mir_map.0.mir +++ b/src/test/mir-opt/issue_72181.bar.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `bar` 0 mir_map +// MIR for `bar` after built fn bar(_1: [(Never, u32); 1]) -> u32 { let mut _0: u32; // return place in scope 0 at $DIR/issue-72181.rs:+0:40: +0:43 diff --git a/src/test/mir-opt/issue_72181.foo.mir_map.0.mir b/src/test/mir-opt/issue_72181.foo.built.after.mir similarity index 98% rename from src/test/mir-opt/issue_72181.foo.mir_map.0.mir rename to src/test/mir-opt/issue_72181.foo.built.after.mir index 534f131ea93..1d771ad3656 100644 --- a/src/test/mir-opt/issue_72181.foo.mir_map.0.mir +++ b/src/test/mir-opt/issue_72181.foo.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `foo` 0 mir_map +// MIR for `foo` after built fn foo(_1: [(Never, u32); 1]) -> u32 { debug xs => _1; // in scope 0 at $DIR/issue-72181.rs:+0:8: +0:10 diff --git a/src/test/mir-opt/issue_72181.main.mir_map.0.mir b/src/test/mir-opt/issue_72181.main.built.after.mir similarity index 99% rename from src/test/mir-opt/issue_72181.main.mir_map.0.mir rename to src/test/mir-opt/issue_72181.main.built.after.mir index 425906f84fc..afa09b16fe9 100644 --- a/src/test/mir-opt/issue_72181.main.mir_map.0.mir +++ b/src/test/mir-opt/issue_72181.main.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `main` 0 mir_map +// MIR for `main` after built fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/issue-72181.rs:+0:11: +0:11 diff --git a/src/test/mir-opt/issue_72181_1.f.mir_map.0.mir b/src/test/mir-opt/issue_72181_1.f.built.after.mir similarity index 97% rename from src/test/mir-opt/issue_72181_1.f.mir_map.0.mir rename to src/test/mir-opt/issue_72181_1.f.built.after.mir index e1a35d88bf1..31e997f9b33 100644 --- a/src/test/mir-opt/issue_72181_1.f.mir_map.0.mir +++ b/src/test/mir-opt/issue_72181_1.f.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `f` 0 mir_map +// MIR for `f` after built fn f(_1: Void) -> ! { debug v => _1; // in scope 0 at $DIR/issue-72181-1.rs:+0:6: +0:7 diff --git a/src/test/mir-opt/issue_72181_1.main.mir_map.0.mir b/src/test/mir-opt/issue_72181_1.main.built.after.mir similarity index 99% rename from src/test/mir-opt/issue_72181_1.main.mir_map.0.mir rename to src/test/mir-opt/issue_72181_1.main.built.after.mir index 336693337fb..65177a81b03 100644 --- a/src/test/mir-opt/issue_72181_1.main.mir_map.0.mir +++ b/src/test/mir-opt/issue_72181_1.main.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `main` 0 mir_map +// MIR for `main` after built | User Type Annotations | 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(Void) }, span: $DIR/issue-72181-1.rs:16:12: 16:16, inferred_ty: Void diff --git a/src/test/mir-opt/issue_91633.bar.mir_map.0.mir b/src/test/mir-opt/issue_91633.bar.built.after.mir similarity index 98% rename from src/test/mir-opt/issue_91633.bar.mir_map.0.mir rename to src/test/mir-opt/issue_91633.bar.built.after.mir index 625f6c7361a..19b1b6fe12b 100644 --- a/src/test/mir-opt/issue_91633.bar.mir_map.0.mir +++ b/src/test/mir-opt/issue_91633.bar.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `bar` 0 mir_map +// MIR for `bar` after built fn bar(_1: Box<[T]>) -> () { debug it => _1; // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14 diff --git a/src/test/mir-opt/issue_91633.foo.mir_map.0.mir b/src/test/mir-opt/issue_91633.foo.built.after.mir similarity index 99% rename from src/test/mir-opt/issue_91633.foo.mir_map.0.mir rename to src/test/mir-opt/issue_91633.foo.built.after.mir index 9903e203a23..1a6eee93d36 100644 --- a/src/test/mir-opt/issue_91633.foo.mir_map.0.mir +++ b/src/test/mir-opt/issue_91633.foo.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `foo` 0 mir_map +// MIR for `foo` after built fn foo(_1: Box<[T]>) -> T { debug it => _1; // in scope 0 at $DIR/issue-91633.rs:+0:19: +0:21 diff --git a/src/test/mir-opt/issue_91633.fun.mir_map.0.mir b/src/test/mir-opt/issue_91633.fun.built.after.mir similarity index 98% rename from src/test/mir-opt/issue_91633.fun.mir_map.0.mir rename to src/test/mir-opt/issue_91633.fun.built.after.mir index ded9a4cf7e3..b3eea600330 100644 --- a/src/test/mir-opt/issue_91633.fun.mir_map.0.mir +++ b/src/test/mir-opt/issue_91633.fun.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `fun` 0 mir_map +// MIR for `fun` after built fn fun(_1: &[T]) -> &T { debug it => _1; // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14 diff --git a/src/test/mir-opt/issue_91633.hey.mir_map.0.mir b/src/test/mir-opt/issue_91633.hey.built.after.mir similarity index 98% rename from src/test/mir-opt/issue_91633.hey.mir_map.0.mir rename to src/test/mir-opt/issue_91633.hey.built.after.mir index 37c3b3fcaca..e7e31ad33c1 100644 --- a/src/test/mir-opt/issue_91633.hey.mir_map.0.mir +++ b/src/test/mir-opt/issue_91633.hey.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `hey` 0 mir_map +// MIR for `hey` after built fn hey(_1: &[T]) -> () { debug it => _1; // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14 diff --git a/src/test/mir-opt/issue_99325.main.mir_map.0.mir b/src/test/mir-opt/issue_99325.main.built.after.mir similarity index 99% rename from src/test/mir-opt/issue_99325.main.mir_map.0.mir rename to src/test/mir-opt/issue_99325.main.built.after.mir index 165efa9df41..f588f06b7e4 100644 --- a/src/test/mir-opt/issue_99325.main.mir_map.0.mir +++ b/src/test/mir-opt/issue_99325.main.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `main` 0 mir_map +// MIR for `main` after built | User Type Annotations | 0: user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_99325[8f58]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Value(Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)])) }], user_self_ty: None }) }, span: $DIR/issue-99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} diff --git a/src/test/mir-opt/receiver-ptr-mutability.rs b/src/test/mir-opt/receiver-ptr-mutability.rs index 8e2ff0451c6..668530968fe 100644 --- a/src/test/mir-opt/receiver-ptr-mutability.rs +++ b/src/test/mir-opt/receiver-ptr-mutability.rs @@ -1,4 +1,4 @@ -// EMIT_MIR receiver_ptr_mutability.main.mir_map.0.mir +// EMIT_MIR receiver_ptr_mutability.main.built.after.mir #![feature(arbitrary_self_types)] diff --git a/src/test/mir-opt/receiver_ptr_mutability.main.mir_map.0.mir b/src/test/mir-opt/receiver_ptr_mutability.main.built.after.mir similarity index 99% rename from src/test/mir-opt/receiver_ptr_mutability.main.mir_map.0.mir rename to src/test/mir-opt/receiver_ptr_mutability.main.built.after.mir index 45797ec0607..0192bdc2d5e 100644 --- a/src/test/mir-opt/receiver_ptr_mutability.main.mir_map.0.mir +++ b/src/test/mir-opt/receiver_ptr_mutability.main.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `main` 0 mir_map +// MIR for `main` after built | User Type Annotations | 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver-ptr-mutability.rs:14:14: 14:23, inferred_ty: *mut Test diff --git a/src/test/mir-opt/simple-match.rs b/src/test/mir-opt/simple-match.rs index 103033c4e2b..0ef97dde636 100644 --- a/src/test/mir-opt/simple-match.rs +++ b/src/test/mir-opt/simple-match.rs @@ -1,7 +1,7 @@ // Test that we don't generate unnecessarily large MIR for very simple matches -// EMIT_MIR simple_match.match_bool.mir_map.0.mir +// EMIT_MIR simple_match.match_bool.built.after.mir fn match_bool(x: bool) -> usize { match x { true => 10, diff --git a/src/test/mir-opt/simple_match.match_bool.mir_map.0.mir b/src/test/mir-opt/simple_match.match_bool.built.after.mir similarity index 96% rename from src/test/mir-opt/simple_match.match_bool.mir_map.0.mir rename to src/test/mir-opt/simple_match.match_bool.built.after.mir index 3bef6aa0579..5b101cbdee7 100644 --- a/src/test/mir-opt/simple_match.match_bool.mir_map.0.mir +++ b/src/test/mir-opt/simple_match.match_bool.built.after.mir @@ -1,4 +1,4 @@ -// MIR for `match_bool` 0 mir_map +// MIR for `match_bool` after built fn match_bool(_1: bool) -> usize { debug x => _1; // in scope 0 at $DIR/simple-match.rs:+0:15: +0:16 diff --git a/src/test/mir-opt/spanview-block.rs b/src/test/mir-opt/spanview-block.rs index fc1d6e0ede6..0ecf35ad6a2 100644 --- a/src/test/mir-opt/spanview-block.rs +++ b/src/test/mir-opt/spanview-block.rs @@ -1,5 +1,5 @@ // Test spanview block output // compile-flags: -Z dump-mir-spanview=block -// EMIT_MIR spanview_block.main.mir_map.0.html +// EMIT_MIR spanview_block.main.built.after.html fn main() {} diff --git a/src/test/mir-opt/spanview-statement.rs b/src/test/mir-opt/spanview-statement.rs index a43ad5e71a3..457052617b7 100644 --- a/src/test/mir-opt/spanview-statement.rs +++ b/src/test/mir-opt/spanview-statement.rs @@ -1,5 +1,5 @@ // Test spanview output (the default value for `-Z dump-mir-spanview` is "statement") // compile-flags: -Z dump-mir-spanview -// EMIT_MIR spanview_statement.main.mir_map.0.html +// EMIT_MIR spanview_statement.main.built.after.html fn main() {} diff --git a/src/test/mir-opt/spanview-terminator.rs b/src/test/mir-opt/spanview-terminator.rs index 92e1411eadb..76fced188f1 100644 --- a/src/test/mir-opt/spanview-terminator.rs +++ b/src/test/mir-opt/spanview-terminator.rs @@ -1,5 +1,5 @@ // Test spanview terminator output // compile-flags: -Z dump-mir-spanview=terminator -// EMIT_MIR spanview_terminator.main.mir_map.0.html +// EMIT_MIR spanview_terminator.main.built.after.html fn main() {} diff --git a/src/test/mir-opt/spanview_block.main.mir_map.0.html b/src/test/mir-opt/spanview_block.main.built.after.html similarity index 97% rename from src/test/mir-opt/spanview_block.main.mir_map.0.html rename to src/test/mir-opt/spanview_block.main.built.after.html index 8e5268043e7..fbf751d6d30 100644 --- a/src/test/mir-opt/spanview_block.main.mir_map.0.html +++ b/src/test/mir-opt/spanview_block.main.built.after.html @@ -1,7 +1,7 @@ -spanview_block.main.mir_map.0 +spanview_block.main.built.after -
#![crate_type = "lib"]
+
#![crate_type = "lib"]
 
 use std::path::{Path, PathBuf};
 
-#[cfg(target_os = "linux")]
+#[cfg(target_os = "linux")]
 #[cfg(target_os = "windows")]
 fn main() -> () {
     let foo = true && false || true;
@@ -23,7 +23,7 @@
     mac!(foo, &mut bar);
     assert!(self.length < N && index <= self.length);
     ::std::env::var("gateau").is_ok();
-    #[rustfmt::skip]
+    #[rustfmt::skip]
     let s:std::path::PathBuf = std::path::PathBuf::new();
     let mut s = String::new();
 
diff --git a/src/librustdoc/html/highlight/tests.rs b/src/librustdoc/html/highlight/tests.rs
index a5e633df434..2c93b9a097f 100644
--- a/src/librustdoc/html/highlight/tests.rs
+++ b/src/librustdoc/html/highlight/tests.rs
@@ -9,7 +9,7 @@ const STYLE: &str = r#"
 .kw { color: #8959A8; }
 .kw-2, .prelude-ty { color: #4271AE; }
 .number, .string { color: #718C00; }
-.self, .bool-val, .prelude-val, .attribute, .attribute .ident { color: #C82829; }
+.self, .bool-val, .prelude-val, .attr, .attr .ident { color: #C82829; }
 .macro, .macro-nonterminal { color: #3E999F; }
 .lifetime { color: #B76514; }
 .question-mark { color: #ff9011; }
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index 894499e5c4f..ae1cef776a1 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -1092,7 +1092,7 @@ pre.rust .bool-val {
 pre.rust .self {
 	color: var(--code-highlight-self-color);
 }
-pre.rust .attribute {
+pre.rust .attr {
 	color: var(--code-highlight-attribute-color);
 }
 pre.rust .macro,
diff --git a/src/test/rustdoc-gui/highlight-colors.goml b/src/test/rustdoc-gui/highlight-colors.goml
index 51693314e85..ff1be389dcb 100644
--- a/src/test/rustdoc-gui/highlight-colors.goml
+++ b/src/test/rustdoc-gui/highlight-colors.goml
@@ -15,7 +15,7 @@ define-function: (
         string,
         bool_val,
         self,
-        attribute,
+        attr,
         macro,
         question_mark,
         comment,
@@ -33,7 +33,7 @@ define-function: (
         ("assert-css", ("pre.rust .string", {"color": |string|}, ALL)),
         ("assert-css", ("pre.rust .bool-val", {"color": |bool_val|}, ALL)),
         ("assert-css", ("pre.rust .self", {"color": |self|}, ALL)),
-        ("assert-css", ("pre.rust .attribute", {"color": |attribute|}, ALL)),
+        ("assert-css", ("pre.rust .attr", {"color": |attr|}, ALL)),
         ("assert-css", ("pre.rust .macro", {"color": |macro|}, ALL)),
         ("assert-css", ("pre.rust .question-mark", {"color": |question_mark|}, ALL)),
         ("assert-css", ("pre.rust .comment", {"color": |comment|}, ALL)),
@@ -52,7 +52,7 @@ call-function: ("check-colors", {
     "string": "rgb(184, 204, 82)",
     "bool_val": "rgb(255, 119, 51)",
     "self": "rgb(54, 163, 217)",
-    "attribute": "rgb(230, 225, 207)",
+    "attr": "rgb(230, 225, 207)",
     "macro": "rgb(163, 122, 204)",
     "question_mark": "rgb(255, 144, 17)",
     "comment": "rgb(120, 135, 151)",
@@ -69,7 +69,7 @@ call-function: ("check-colors", {
     "string": "rgb(131, 163, 0)",
     "bool_val": "rgb(238, 104, 104)",
     "self": "rgb(238, 104, 104)",
-    "attribute": "rgb(238, 104, 104)",
+    "attr": "rgb(238, 104, 104)",
     "macro": "rgb(62, 153, 159)",
     "question_mark": "rgb(255, 144, 17)",
     "comment": "rgb(141, 141, 139)",
@@ -86,7 +86,7 @@ call-function: ("check-colors", {
     "string": "rgb(113, 140, 0)",
     "bool_val": "rgb(200, 40, 41)",
     "self": "rgb(200, 40, 41)",
-    "attribute": "rgb(200, 40, 41)",
+    "attr": "rgb(200, 40, 41)",
     "macro": "rgb(62, 153, 159)",
     "question_mark": "rgb(255, 144, 17)",
     "comment": "rgb(142, 144, 140)",
diff --git a/src/test/rustdoc/issue-41783.codeblock.html b/src/test/rustdoc/issue-41783.codeblock.html
index 89987491d1b..3bca4536cd5 100644
--- a/src/test/rustdoc/issue-41783.codeblock.html
+++ b/src/test/rustdoc/issue-41783.codeblock.html
@@ -1,5 +1,5 @@
 # single
 ## double
 ### triple
-#[outer]
+#[outer]
 #![inner]
diff --git a/src/test/rustdoc/issue-41783.rs b/src/test/rustdoc/issue-41783.rs
index 87267a750c6..769f984a274 100644
--- a/src/test/rustdoc/issue-41783.rs
+++ b/src/test/rustdoc/issue-41783.rs
@@ -1,10 +1,10 @@
 // @has issue_41783/struct.Foo.html
 // @!hasraw - 'space'
 // @!hasraw - 'comment'
-// @hasraw - '#[outer]'
-// @!hasraw - '#[outer]'
+// @hasraw - '#[outer]'
+// @!hasraw - '#[outer]'
 // @hasraw - '#![inner]'
-// @!hasraw - '#![inner]'
+// @!hasraw - '#![inner]'
 // @snapshot 'codeblock' - '//*[@class="rustdoc-toggle top-doc"]/*[@class="docblock"]//pre/code'
 
 /// ```no_run

From 5ba1556e0ddb6805526f8c3938c7aaf266d0b319 Mon Sep 17 00:00:00 2001
From: Michael Goulet 
Date: Sun, 30 Oct 2022 20:51:15 +0000
Subject: [PATCH 143/219] Create NLL infer vars for late-bound regions from
 closures

---
 .../rustc_borrowck/src/universal_regions.rs   | 62 +++++++++++--------
 compiler/rustc_middle/src/ty/context.rs       |  4 +-
 2 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs
index 2beb5e0ab5d..51439dec440 100644
--- a/compiler/rustc_borrowck/src/universal_regions.rs
+++ b/compiler/rustc_borrowck/src/universal_regions.rs
@@ -22,7 +22,9 @@ use rustc_hir::{BodyOwnerKind, HirId};
 use rustc_index::vec::{Idx, IndexVec};
 use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin};
 use rustc_middle::ty::fold::TypeFoldable;
-use rustc_middle::ty::{self, InlineConstSubsts, InlineConstSubstsParts, RegionVid, Ty, TyCtxt};
+use rustc_middle::ty::{
+    self, DefIdTree, InlineConstSubsts, InlineConstSubstsParts, RegionVid, Ty, TyCtxt,
+};
 use rustc_middle::ty::{InternalSubsts, SubstsRef};
 use std::iter;
 
@@ -421,13 +423,15 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
             first_extern_index
         } else {
             // If this is a closure, generator, or inline-const, then the late-bound regions from the enclosing
-            // function are actually external regions to us. For example, here, 'a is not local
+            // function/closures are actually external regions to us. For example, here, 'a is not local
             // to the closure c (although it is local to the fn foo):
             // fn foo<'a>() {
             //     let c = || { let x: &'a u32 = ...; }
             // }
-            self.infcx
-                .replace_late_bound_regions_with_nll_infer_vars(self.mir_def.did, &mut indices);
+            self.infcx.replace_late_bound_regions_with_nll_infer_vars(
+                self.infcx.tcx.local_parent(self.mir_def.did),
+                &mut indices,
+            );
             // Any regions created during the execution of `defining_ty` or during the above
             // late-bound region replacement are all considered 'extern' regions
             self.infcx.num_region_vars()
@@ -444,12 +448,9 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
             bound_inputs_and_output,
             &mut indices,
         );
-        // Converse of above, if this is a function then the late-bound regions declared on its
-        // signature are local to the fn.
-        if self.mir_def.did.to_def_id() == typeck_root_def_id {
-            self.infcx
-                .replace_late_bound_regions_with_nll_infer_vars(self.mir_def.did, &mut indices);
-        }
+        // Converse of above, if this is a function/closure then the late-bound regions declared on its
+        // signature are local.
+        self.infcx.replace_late_bound_regions_with_nll_infer_vars(self.mir_def.did, &mut indices);
 
         let (unnormalized_output_ty, mut unnormalized_input_tys) =
             inputs_and_output.split_last().unwrap();
@@ -748,18 +749,28 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
     #[instrument(skip(self, indices))]
     fn replace_late_bound_regions_with_nll_infer_vars(
         &self,
-        mir_def_id: LocalDefId,
+        mut mir_def_id: LocalDefId,
         indices: &mut UniversalRegionIndices<'tcx>,
     ) {
         let typeck_root_def_id = self.tcx.typeck_root_def_id(mir_def_id.to_def_id());
-        for_each_late_bound_region_defined_on(self.tcx, typeck_root_def_id, |r| {
-            debug!(?r);
-            if !indices.indices.contains_key(&r) {
-                let region_vid = self.next_nll_region_var(FR);
-                debug!(?region_vid);
-                indices.insert_late_bound_region(r, region_vid.to_region_vid());
+
+        // Walk up the tree, collecting late-bound regions until we hit the typeck root
+        loop {
+            for_each_late_bound_region_defined_on(self.tcx, mir_def_id.to_def_id(), |r| {
+                debug!(?r);
+                if !indices.indices.contains_key(&r) {
+                    let region_vid = self.next_nll_region_var(FR);
+                    debug!(?region_vid);
+                    indices.insert_late_bound_region(r, region_vid.to_region_vid());
+                }
+            });
+
+            if mir_def_id.to_def_id() == typeck_root_def_id {
+                break;
+            } else {
+                mir_def_id = self.tcx.parent(mir_def_id.to_def_id()).expect_local();
             }
-        });
+        }
     }
 }
 
@@ -810,14 +821,11 @@ fn for_each_late_bound_region_defined_on<'tcx>(
     fn_def_id: DefId,
     mut f: impl FnMut(ty::Region<'tcx>),
 ) {
-    if let Some(late_bounds) = tcx.is_late_bound_map(fn_def_id.expect_local()) {
-        for ®ion_def_id in late_bounds.iter() {
-            let name = tcx.item_name(region_def_id.to_def_id());
-            let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
-                scope: fn_def_id,
-                bound_region: ty::BoundRegionKind::BrNamed(region_def_id.to_def_id(), name),
-            }));
-            f(liberated_region);
-        }
+    for bound_var in tcx.late_bound_vars(tcx.hir().local_def_id_to_hir_id(fn_def_id.expect_local()))
+    {
+        let ty::BoundVariableKind::Region(bound_region) = bound_var else { continue; };
+        let liberated_region =
+            tcx.mk_region(ty::ReFree(ty::FreeRegion { scope: fn_def_id, bound_region }));
+        f(liberated_region);
     }
 }
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 3d7e2a0839a..a9c503585a1 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -2895,9 +2895,7 @@ impl<'tcx> TyCtxt<'tcx> {
         self.mk_bound_variable_kinds(
             self.late_bound_vars_map(id.owner)
                 .and_then(|map| map.get(&id.local_id).cloned())
-                .unwrap_or_else(|| {
-                    bug!("No bound vars found for {:?} ({:?})", self.hir().node_to_string(id), id)
-                })
+                .unwrap_or_default()
                 .iter(),
         )
     }

From 630dff6ba7217d15e757ba4c552b8a4bedca4130 Mon Sep 17 00:00:00 2001
From: Michael Goulet 
Date: Sun, 30 Oct 2022 20:51:30 +0000
Subject: [PATCH 144/219] tests

---
 src/test/ui/closures/binder/late-bound-in-body.rs | 9 +++++++++
 src/test/ui/closures/binder/nested-closures.rs    | 7 +++++++
 2 files changed, 16 insertions(+)
 create mode 100644 src/test/ui/closures/binder/late-bound-in-body.rs
 create mode 100644 src/test/ui/closures/binder/nested-closures.rs

diff --git a/src/test/ui/closures/binder/late-bound-in-body.rs b/src/test/ui/closures/binder/late-bound-in-body.rs
new file mode 100644
index 00000000000..bb5c7552fda
--- /dev/null
+++ b/src/test/ui/closures/binder/late-bound-in-body.rs
@@ -0,0 +1,9 @@
+// check-pass
+
+#![feature(closure_lifetime_binder)]
+
+fn main() {
+    let _ = for<'a> || -> () {
+        let _: &'a bool = &true;
+    };
+}
diff --git a/src/test/ui/closures/binder/nested-closures.rs b/src/test/ui/closures/binder/nested-closures.rs
new file mode 100644
index 00000000000..b3c36e7eebb
--- /dev/null
+++ b/src/test/ui/closures/binder/nested-closures.rs
@@ -0,0 +1,7 @@
+// check-pass
+
+#![feature(closure_lifetime_binder)]
+
+fn main() {
+    for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; };
+}

From f27bdf175034bd0455eb960fc0dc8262484f187b Mon Sep 17 00:00:00 2001
From: Michael Goulet 
Date: Mon, 31 Oct 2022 03:28:05 +0000
Subject: [PATCH 145/219] Collect late-bound regions from all closure parents
 in `closure_mapping`

---
 .../rustc_borrowck/src/region_infer/mod.rs    |  2 +-
 .../rustc_borrowck/src/universal_regions.rs   | 82 ++++++++++---------
 .../binder/nested-closures-regions.rs         |  9 ++
 .../binder/nested-closures-regions.stderr     | 38 +++++++++
 4 files changed, 91 insertions(+), 40 deletions(-)
 create mode 100644 src/test/ui/closures/binder/nested-closures-regions.rs
 create mode 100644 src/test/ui/closures/binder/nested-closures-regions.stderr

diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs
index 8b63294fbab..0e7f243bcf3 100644
--- a/compiler/rustc_borrowck/src/region_infer/mod.rs
+++ b/compiler/rustc_borrowck/src/region_infer/mod.rs
@@ -2314,7 +2314,7 @@ impl<'tcx> ClosureRegionRequirementsExt<'tcx> for ClosureRegionRequirements<'tcx
             tcx,
             closure_substs,
             self.num_external_vids,
-            tcx.typeck_root_def_id(closure_def_id),
+            closure_def_id.expect_local(),
         );
         debug!("apply_requirements: closure_mapping={:?}", closure_mapping);
 
diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs
index 51439dec440..0f300564c20 100644
--- a/compiler/rustc_borrowck/src/universal_regions.rs
+++ b/compiler/rustc_borrowck/src/universal_regions.rs
@@ -243,7 +243,7 @@ impl<'tcx> UniversalRegions<'tcx> {
         tcx: TyCtxt<'tcx>,
         closure_substs: SubstsRef<'tcx>,
         expected_num_vars: usize,
-        typeck_root_def_id: DefId,
+        closure_def_id: LocalDefId,
     ) -> IndexVec> {
         let mut region_mapping = IndexVec::with_capacity(expected_num_vars);
         region_mapping.push(tcx.lifetimes.re_static);
@@ -251,9 +251,13 @@ impl<'tcx> UniversalRegions<'tcx> {
             region_mapping.push(fr);
         });
 
-        for_each_late_bound_region_defined_on(tcx, typeck_root_def_id, |r| {
-            region_mapping.push(r);
-        });
+        for_each_late_bound_region_in_scope(
+            tcx,
+            tcx.local_parent(closure_def_id),
+            |r| {
+                region_mapping.push(r);
+            },
+        );
 
         assert_eq!(
             region_mapping.len(),
@@ -341,9 +345,8 @@ impl<'tcx> UniversalRegions<'tcx> {
                 // tests, and the resulting print-outs include def-ids
                 // and other things that are not stable across tests!
                 // So we just include the region-vid. Annoying.
-                let typeck_root_def_id = tcx.typeck_root_def_id(def_id);
-                for_each_late_bound_region_defined_on(tcx, typeck_root_def_id, |r| {
-                    err.note(&format!("late-bound region is {:?}", self.to_region_vid(r),));
+                for_each_late_bound_region_in_scope(tcx, def_id.expect_local(), |r| {
+                    err.note(&format!("late-bound region is {:?}", self.to_region_vid(r)));
                 });
             }
             DefiningTy::Generator(def_id, substs, _) => {
@@ -356,9 +359,8 @@ impl<'tcx> UniversalRegions<'tcx> {
                 // FIXME: As above, we'd like to print out the region
                 // `r` but doing so is not stable across architectures
                 // and so forth.
-                let typeck_root_def_id = tcx.typeck_root_def_id(def_id);
-                for_each_late_bound_region_defined_on(tcx, typeck_root_def_id, |r| {
-                    err.note(&format!("late-bound region is {:?}", self.to_region_vid(r),));
+                for_each_late_bound_region_in_scope(tcx, def_id.expect_local(), |r| {
+                    err.note(&format!("late-bound region is {:?}", self.to_region_vid(r)));
                 });
             }
             DefiningTy::FnDef(def_id, substs) => {
@@ -749,28 +751,17 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
     #[instrument(skip(self, indices))]
     fn replace_late_bound_regions_with_nll_infer_vars(
         &self,
-        mut mir_def_id: LocalDefId,
+        mir_def_id: LocalDefId,
         indices: &mut UniversalRegionIndices<'tcx>,
     ) {
-        let typeck_root_def_id = self.tcx.typeck_root_def_id(mir_def_id.to_def_id());
-
-        // Walk up the tree, collecting late-bound regions until we hit the typeck root
-        loop {
-            for_each_late_bound_region_defined_on(self.tcx, mir_def_id.to_def_id(), |r| {
-                debug!(?r);
-                if !indices.indices.contains_key(&r) {
-                    let region_vid = self.next_nll_region_var(FR);
-                    debug!(?region_vid);
-                    indices.insert_late_bound_region(r, region_vid.to_region_vid());
-                }
-            });
-
-            if mir_def_id.to_def_id() == typeck_root_def_id {
-                break;
-            } else {
-                mir_def_id = self.tcx.parent(mir_def_id.to_def_id()).expect_local();
+        for_each_late_bound_region_in_scope(self.tcx, mir_def_id, |r| {
+            debug!(?r);
+            if !indices.indices.contains_key(&r) {
+                let region_vid = self.next_nll_region_var(FR);
+                debug!(?region_vid);
+                indices.insert_late_bound_region(r, region_vid.to_region_vid());
             }
-        }
+        });
     }
 }
 
@@ -814,18 +805,31 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
     }
 }
 
-/// Iterates over the late-bound regions defined on fn_def_id and
-/// invokes `f` with the liberated form of each one.
-fn for_each_late_bound_region_defined_on<'tcx>(
+/// Iterates over the late-bound regions defined on fn_def_id and all of its
+/// parents, up to the typeck root, and invokes `f` with the liberated form
+/// of each one.
+fn for_each_late_bound_region_in_scope<'tcx>(
     tcx: TyCtxt<'tcx>,
-    fn_def_id: DefId,
+    mut mir_def_id: LocalDefId,
     mut f: impl FnMut(ty::Region<'tcx>),
 ) {
-    for bound_var in tcx.late_bound_vars(tcx.hir().local_def_id_to_hir_id(fn_def_id.expect_local()))
-    {
-        let ty::BoundVariableKind::Region(bound_region) = bound_var else { continue; };
-        let liberated_region =
-            tcx.mk_region(ty::ReFree(ty::FreeRegion { scope: fn_def_id, bound_region }));
-        f(liberated_region);
+    let typeck_root_def_id = tcx.typeck_root_def_id(mir_def_id.to_def_id());
+
+    // Walk up the tree, collecting late-bound regions until we hit the typeck root
+    loop {
+        for bound_var in tcx.late_bound_vars(tcx.hir().local_def_id_to_hir_id(mir_def_id)) {
+            let ty::BoundVariableKind::Region(bound_region) = bound_var else { continue; };
+            let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
+                scope: mir_def_id.to_def_id(),
+                bound_region,
+            }));
+            f(liberated_region);
+        }
+
+        if mir_def_id.to_def_id() == typeck_root_def_id {
+            break;
+        } else {
+            mir_def_id = tcx.local_parent(mir_def_id);
+        }
     }
 }
diff --git a/src/test/ui/closures/binder/nested-closures-regions.rs b/src/test/ui/closures/binder/nested-closures-regions.rs
new file mode 100644
index 00000000000..6bfc6c80b78
--- /dev/null
+++ b/src/test/ui/closures/binder/nested-closures-regions.rs
@@ -0,0 +1,9 @@
+// check-pass
+
+#![feature(closure_lifetime_binder)]
+#![feature(rustc_attrs)]
+
+#[rustc_regions]
+fn main() {
+    for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; };
+}
diff --git a/src/test/ui/closures/binder/nested-closures-regions.stderr b/src/test/ui/closures/binder/nested-closures-regions.stderr
new file mode 100644
index 00000000000..b385e0ed6e0
--- /dev/null
+++ b/src/test/ui/closures/binder/nested-closures-regions.stderr
@@ -0,0 +1,38 @@
+note: external requirements
+  --> $DIR/nested-closures-regions.rs:8:24
+   |
+LL |     for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; };
+   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: defining type: main::{closure#0}::{closure#0} with closure substs [
+               i8,
+               extern "rust-call" fn((&(),)),
+               (),
+           ]
+   = note: late-bound region is '_#4r
+   = note: late-bound region is '_#2r
+   = note: number of external vids: 3
+   = note: where '_#1r: '_#2r
+   = note: where '_#2r: '_#1r
+
+note: no external requirements
+  --> $DIR/nested-closures-regions.rs:8:5
+   |
+LL |     for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; };
+   |     ^^^^^^^^^^^^^^^^
+   |
+   = note: defining type: main::{closure#0} with closure substs [
+               i8,
+               extern "rust-call" fn(()),
+               (),
+           ]
+   = note: late-bound region is '_#2r
+
+note: no external requirements
+  --> $DIR/nested-closures-regions.rs:7:1
+   |
+LL | fn main() {
+   | ^^^^^^^^^
+   |
+   = note: defining type: main
+

From 4427af082797a1e477781efd09947bb27d9b19c3 Mon Sep 17 00:00:00 2001
From: Michael Goulet 
Date: Mon, 31 Oct 2022 21:18:17 +0000
Subject: [PATCH 146/219] Make external/local late-bound region registration
 more explicit

---
 .../rustc_borrowck/src/universal_regions.rs   | 93 ++++++++++++++-----
 1 file changed, 68 insertions(+), 25 deletions(-)

diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs
index 0f300564c20..482e10d520b 100644
--- a/compiler/rustc_borrowck/src/universal_regions.rs
+++ b/compiler/rustc_borrowck/src/universal_regions.rs
@@ -251,13 +251,9 @@ impl<'tcx> UniversalRegions<'tcx> {
             region_mapping.push(fr);
         });
 
-        for_each_late_bound_region_in_scope(
-            tcx,
-            tcx.local_parent(closure_def_id),
-            |r| {
-                region_mapping.push(r);
-            },
-        );
+        for_each_late_bound_region_in_recursive_scope(tcx, tcx.local_parent(closure_def_id), |r| {
+            region_mapping.push(r);
+        });
 
         assert_eq!(
             region_mapping.len(),
@@ -345,7 +341,7 @@ impl<'tcx> UniversalRegions<'tcx> {
                 // tests, and the resulting print-outs include def-ids
                 // and other things that are not stable across tests!
                 // So we just include the region-vid. Annoying.
-                for_each_late_bound_region_in_scope(tcx, def_id.expect_local(), |r| {
+                for_each_late_bound_region_in_recursive_scope(tcx, def_id.expect_local(), |r| {
                     err.note(&format!("late-bound region is {:?}", self.to_region_vid(r)));
                 });
             }
@@ -359,7 +355,7 @@ impl<'tcx> UniversalRegions<'tcx> {
                 // FIXME: As above, we'd like to print out the region
                 // `r` but doing so is not stable across architectures
                 // and so forth.
-                for_each_late_bound_region_in_scope(tcx, def_id.expect_local(), |r| {
+                for_each_late_bound_region_in_recursive_scope(tcx, def_id.expect_local(), |r| {
                     err.note(&format!("late-bound region is {:?}", self.to_region_vid(r)));
                 });
             }
@@ -430,10 +426,19 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
             // fn foo<'a>() {
             //     let c = || { let x: &'a u32 = ...; }
             // }
-            self.infcx.replace_late_bound_regions_with_nll_infer_vars(
+            for_each_late_bound_region_in_recursive_scope(
+                self.infcx.tcx,
                 self.infcx.tcx.local_parent(self.mir_def.did),
-                &mut indices,
+                |r| {
+                    debug!(?r);
+                    if !indices.indices.contains_key(&r) {
+                        let region_vid = self.infcx.next_nll_region_var(FR);
+                        debug!(?region_vid);
+                        indices.insert_late_bound_region(r, region_vid.to_region_vid());
+                    }
+                },
             );
+
             // Any regions created during the execution of `defining_ty` or during the above
             // late-bound region replacement are all considered 'extern' regions
             self.infcx.num_region_vars()
@@ -452,7 +457,14 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
         );
         // Converse of above, if this is a function/closure then the late-bound regions declared on its
         // signature are local.
-        self.infcx.replace_late_bound_regions_with_nll_infer_vars(self.mir_def.did, &mut indices);
+        for_each_late_bound_region_in_item(self.infcx.tcx, self.mir_def.did, |r| {
+            debug!(?r);
+            if !indices.indices.contains_key(&r) {
+                let region_vid = self.infcx.next_nll_region_var(FR);
+                debug!(?region_vid);
+                indices.insert_late_bound_region(r, region_vid.to_region_vid());
+            }
+        });
 
         let (unnormalized_output_ty, mut unnormalized_input_tys) =
             inputs_and_output.split_last().unwrap();
@@ -695,7 +707,13 @@ trait InferCtxtExt<'tcx> {
     where
         T: TypeFoldable<'tcx>;
 
-    fn replace_late_bound_regions_with_nll_infer_vars(
+    fn replace_late_bound_regions_with_nll_infer_vars_in_recursive_scope(
+        &self,
+        mir_def_id: LocalDefId,
+        indices: &mut UniversalRegionIndices<'tcx>,
+    );
+
+    fn replace_late_bound_regions_with_nll_infer_vars_in_item(
         &self,
         mir_def_id: LocalDefId,
         indices: &mut UniversalRegionIndices<'tcx>,
@@ -749,12 +767,28 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
     /// set of late-bound regions and checks for any that we have not yet seen, adding them to the
     /// inputs vector.
     #[instrument(skip(self, indices))]
-    fn replace_late_bound_regions_with_nll_infer_vars(
+    fn replace_late_bound_regions_with_nll_infer_vars_in_recursive_scope(
         &self,
         mir_def_id: LocalDefId,
         indices: &mut UniversalRegionIndices<'tcx>,
     ) {
-        for_each_late_bound_region_in_scope(self.tcx, mir_def_id, |r| {
+        for_each_late_bound_region_in_recursive_scope(self.tcx, mir_def_id, |r| {
+            debug!(?r);
+            if !indices.indices.contains_key(&r) {
+                let region_vid = self.next_nll_region_var(FR);
+                debug!(?region_vid);
+                indices.insert_late_bound_region(r, region_vid.to_region_vid());
+            }
+        });
+    }
+
+    #[instrument(skip(self, indices))]
+    fn replace_late_bound_regions_with_nll_infer_vars_in_item(
+        &self,
+        mir_def_id: LocalDefId,
+        indices: &mut UniversalRegionIndices<'tcx>,
+    ) {
+        for_each_late_bound_region_in_item(self.tcx, mir_def_id, |r| {
             debug!(?r);
             if !indices.indices.contains_key(&r) {
                 let region_vid = self.next_nll_region_var(FR);
@@ -805,10 +839,10 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
     }
 }
 
-/// Iterates over the late-bound regions defined on fn_def_id and all of its
+/// Iterates over the late-bound regions defined on `mir_def_id` and all of its
 /// parents, up to the typeck root, and invokes `f` with the liberated form
 /// of each one.
-fn for_each_late_bound_region_in_scope<'tcx>(
+fn for_each_late_bound_region_in_recursive_scope<'tcx>(
     tcx: TyCtxt<'tcx>,
     mut mir_def_id: LocalDefId,
     mut f: impl FnMut(ty::Region<'tcx>),
@@ -817,14 +851,7 @@ fn for_each_late_bound_region_in_scope<'tcx>(
 
     // Walk up the tree, collecting late-bound regions until we hit the typeck root
     loop {
-        for bound_var in tcx.late_bound_vars(tcx.hir().local_def_id_to_hir_id(mir_def_id)) {
-            let ty::BoundVariableKind::Region(bound_region) = bound_var else { continue; };
-            let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
-                scope: mir_def_id.to_def_id(),
-                bound_region,
-            }));
-            f(liberated_region);
-        }
+        for_each_late_bound_region_in_item(tcx, mir_def_id, &mut f);
 
         if mir_def_id.to_def_id() == typeck_root_def_id {
             break;
@@ -833,3 +860,19 @@ fn for_each_late_bound_region_in_scope<'tcx>(
         }
     }
 }
+
+/// Iterates over the late-bound regions defined on `mir_def_id` and all of its
+/// parents, up to the typeck root, and invokes `f` with the liberated form
+/// of each one.
+fn for_each_late_bound_region_in_item<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    mir_def_id: LocalDefId,
+    mut f: impl FnMut(ty::Region<'tcx>),
+) {
+    for bound_var in tcx.late_bound_vars(tcx.hir().local_def_id_to_hir_id(mir_def_id)) {
+        let ty::BoundVariableKind::Region(bound_region) = bound_var else { continue; };
+        let liberated_region = tcx
+            .mk_region(ty::ReFree(ty::FreeRegion { scope: mir_def_id.to_def_id(), bound_region }));
+        f(liberated_region);
+    }
+}

From 2768c2fb257fccc692712d5f38d979f4a8f127dd Mon Sep 17 00:00:00 2001
From: Michael Goulet 
Date: Mon, 31 Oct 2022 21:24:39 +0000
Subject: [PATCH 147/219] Add bug! back to late_bound_vars query

---
 compiler/rustc_borrowck/src/universal_regions.rs | 4 ++++
 compiler/rustc_middle/src/ty/context.rs          | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs
index 482e10d520b..618da9e3253 100644
--- a/compiler/rustc_borrowck/src/universal_regions.rs
+++ b/compiler/rustc_borrowck/src/universal_regions.rs
@@ -869,6 +869,10 @@ fn for_each_late_bound_region_in_item<'tcx>(
     mir_def_id: LocalDefId,
     mut f: impl FnMut(ty::Region<'tcx>),
 ) {
+    if !tcx.def_kind(mir_def_id).is_fn_like() {
+        return;
+    }
+
     for bound_var in tcx.late_bound_vars(tcx.hir().local_def_id_to_hir_id(mir_def_id)) {
         let ty::BoundVariableKind::Region(bound_region) = bound_var else { continue; };
         let liberated_region = tcx
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index a9c503585a1..3d7e2a0839a 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -2895,7 +2895,9 @@ impl<'tcx> TyCtxt<'tcx> {
         self.mk_bound_variable_kinds(
             self.late_bound_vars_map(id.owner)
                 .and_then(|map| map.get(&id.local_id).cloned())
-                .unwrap_or_default()
+                .unwrap_or_else(|| {
+                    bug!("No bound vars found for {:?} ({:?})", self.hir().node_to_string(id), id)
+                })
                 .iter(),
         )
     }

From a0c21e4e7ea3a2143af9e65a98a19e6b1942ff53 Mon Sep 17 00:00:00 2001
From: Mark Rousskov 
Date: Mon, 31 Oct 2022 20:55:03 -0400
Subject: [PATCH 148/219] Remove let_underscore_must_use from list of uplifted
 lints

---
 RELEASES.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/RELEASES.md b/RELEASES.md
index a3df56f1d2a..ad550260c8b 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -6,7 +6,7 @@ Language
 - [Error on `as` casts of enums with `#[non_exhaustive]` variants](https://github.com/rust-lang/rust/pull/92744/)
 - [Stabilize `let else`](https://github.com/rust-lang/rust/pull/93628/)
 - [Stabilize generic associated types (GATs)](https://github.com/rust-lang/rust/pull/96709/)
-- [Add lints `let_underscore_drop`, `let_underscore_lock`, and `let_underscore_must_use` from Clippy](https://github.com/rust-lang/rust/pull/97739/)
+- [Add lints `let_underscore_drop` and `let_underscore_lock` from Clippy](https://github.com/rust-lang/rust/pull/97739/)
 - [Stabilize `break`ing from arbitrary labeled blocks ("label-break-value")](https://github.com/rust-lang/rust/pull/99332/)
 - [Uninitialized integers, floats, and raw pointers are now considered immediate UB](https://github.com/rust-lang/rust/pull/98919/).
   Usage of `MaybeUninit` is the correct way to work with uninitialized memory.

From 17395b45b102b365e6fb19796223d190b5f2bebf Mon Sep 17 00:00:00 2001
From: Jakob Degen 
Date: Sun, 30 Oct 2022 17:17:25 -0700
Subject: [PATCH 149/219] Detect unused files in `src/test/mir-opt` and error
 on them in tidy.

---
 Cargo.lock                                    |   9 ++
 Cargo.toml                                    |   1 +
 src/bootstrap/builder.rs                      |   1 +
 src/bootstrap/check.rs                        |   1 +
 ...c.try_identity.DestinationPropagation.diff |  72 ----------
 ...y.try_identity.DestinationPropagation.diff | 106 --------------
 ..._try.try_identity.SimplifyArmIdentity.diff |  85 -----------
 ....try_identity.SimplifyBranchSame.after.mir |  83 -----------
 ..._try.try_identity.SimplifyLocals.after.mir |  58 --------
 src/tools/compiletest/Cargo.toml              |   1 +
 src/tools/compiletest/src/runtest.rs          | 132 ++++++------------
 src/tools/miropt-test-tools/Cargo.toml        |   7 +
 src/tools/miropt-test-tools/src/lib.rs        |  70 ++++++++++
 src/tools/tidy/Cargo.toml                     |   1 +
 src/tools/tidy/src/lib.rs                     |   1 +
 src/tools/tidy/src/main.rs                    |   1 +
 src/tools/tidy/src/mir_opt_tests.rs           |  37 +++++
 17 files changed, 169 insertions(+), 497 deletions(-)
 delete mode 100644 src/test/mir-opt/rustc.try_identity.DestinationPropagation.diff
 delete mode 100644 src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff
 delete mode 100644 src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff
 delete mode 100644 src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir
 delete mode 100644 src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir
 create mode 100644 src/tools/miropt-test-tools/Cargo.toml
 create mode 100644 src/tools/miropt-test-tools/src/lib.rs
 create mode 100644 src/tools/tidy/src/mir_opt_tests.rs

diff --git a/Cargo.lock b/Cargo.lock
index dab693419a9..301167e02cc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -816,6 +816,7 @@ dependencies = [
  "lazycell",
  "libc",
  "miow",
+ "miropt-test-tools",
  "regex",
  "rustfix",
  "serde",
@@ -2268,6 +2269,13 @@ dependencies = [
  "ui_test",
 ]
 
+[[package]]
+name = "miropt-test-tools"
+version = "0.1.0"
+dependencies = [
+ "regex",
+]
+
 [[package]]
 name = "new_debug_unreachable"
 version = "1.0.4"
@@ -4920,6 +4928,7 @@ version = "0.1.0"
 dependencies = [
  "cargo_metadata 0.14.0",
  "lazy_static",
+ "miropt-test-tools",
  "regex",
  "walkdir",
 ]
diff --git a/Cargo.toml b/Cargo.toml
index e49fe5e2f63..13a98eedde8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,6 +11,7 @@ members = [
   "src/tools/error_index_generator",
   "src/tools/linkchecker",
   "src/tools/lint-docs",
+  "src/tools/miropt-test-tools",
   "src/tools/rustbook",
   "src/tools/unstable-book-gen",
   "src/tools/tidy",
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index c8285c85d03..6de37463633 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -622,6 +622,7 @@ impl<'a> Builder<'a> {
                 check::Clippy,
                 check::Miri,
                 check::CargoMiri,
+                check::MiroptTestTools,
                 check::Rls,
                 check::RustAnalyzer,
                 check::Rustfmt,
diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs
index 4450dd7e80f..2e1bd8d6d1f 100644
--- a/src/bootstrap/check.rs
+++ b/src/bootstrap/check.rs
@@ -460,6 +460,7 @@ tool_check_step!(Miri, "src/tools/miri", SourceType::InTree);
 tool_check_step!(CargoMiri, "src/tools/miri/cargo-miri", SourceType::InTree);
 tool_check_step!(Rls, "src/tools/rls", SourceType::InTree);
 tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree);
+tool_check_step!(MiroptTestTools, "src/tools/miropt-test-tools", SourceType::InTree);
 
 tool_check_step!(Bootstrap, "src/bootstrap", SourceType::InTree, false);
 
diff --git a/src/test/mir-opt/rustc.try_identity.DestinationPropagation.diff b/src/test/mir-opt/rustc.try_identity.DestinationPropagation.diff
deleted file mode 100644
index c3e503bf2c6..00000000000
--- a/src/test/mir-opt/rustc.try_identity.DestinationPropagation.diff
+++ /dev/null
@@ -1,72 +0,0 @@
-- // MIR for `try_identity` before DestinationPropagation
-+ // MIR for `try_identity` after DestinationPropagation
-  
-  fn try_identity(_1: std::result::Result) -> std::result::Result {
-      debug x => _1;                       // in scope 0 at $DIR/simplify_try.rs:6:17: 6:18
-      let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:6:41: 6:57
-      let _2: u32;                         // in scope 0 at $DIR/simplify_try.rs:7:9: 7:10
-      let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:7:13: 7:15
-      let mut _4: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:7:13: 7:14
-      let mut _5: isize;                   // in scope 0 at $DIR/simplify_try.rs:7:14: 7:15
-      let _6: i32;                         // in scope 0 at $DIR/simplify_try.rs:7:14: 7:15
-      let mut _7: !;                       // in scope 0 at $DIR/simplify_try.rs:7:14: 7:15
-      let mut _8: i32;                     // in scope 0 at $DIR/simplify_try.rs:7:14: 7:15
-      let mut _9: i32;                     // in scope 0 at $DIR/simplify_try.rs:7:14: 7:15
-      let _10: u32;                        // in scope 0 at $DIR/simplify_try.rs:7:13: 7:15
-      let mut _11: u32;                    // in scope 0 at $DIR/simplify_try.rs:8:8: 8:9
-      scope 1 {
-          debug y => _2;                   // in scope 1 at $DIR/simplify_try.rs:7:9: 7:10
-      }
-      scope 2 {
-          debug err => _6;                 // in scope 2 at $DIR/simplify_try.rs:7:14: 7:15
-          scope 3 {
-              scope 7 {
-                  debug t => _9;           // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL
-              }
-              scope 8 {
-                  debug v => _8;           // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL
-                  let mut _12: i32;        // in scope 8 at $DIR/simplify_try.rs:7:14: 7:15
-              }
-          }
-      }
-      scope 4 {
-          debug val => _10;                // in scope 4 at $DIR/simplify_try.rs:7:13: 7:15
-          scope 5 {
-          }
-      }
-      scope 6 {
--         debug self => _4;                // in scope 6 at $SRC_DIR/libcore/result.rs:LL:COL
-+         debug self => _0;                // in scope 6 at $SRC_DIR/libcore/result.rs:LL:COL
-      }
-  
-      bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/simplify_try.rs:7:9: 7:10
--         StorageLive(_3);                 // scope 0 at $DIR/simplify_try.rs:7:13: 7:15
--         StorageLive(_4);                 // scope 0 at $DIR/simplify_try.rs:7:13: 7:14
--         _4 = _1;                         // scope 0 at $DIR/simplify_try.rs:7:13: 7:14
--         _3 = move _4;                    // scope 6 at $SRC_DIR/libcore/result.rs:LL:COL
--         StorageDead(_4);                 // scope 0 at $DIR/simplify_try.rs:7:14: 7:15
--         _5 = discriminant(_3);           // scope 0 at $DIR/simplify_try.rs:7:14: 7:15
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:7:13: 7:15
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:7:13: 7:14
-+         _0 = _1;                         // scope 0 at $DIR/simplify_try.rs:7:13: 7:14
-+         nop;                             // scope 6 at $SRC_DIR/libcore/result.rs:LL:COL
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:7:14: 7:15
-+         _5 = discriminant(_0);           // scope 0 at $DIR/simplify_try.rs:7:14: 7:15
-          goto -> bb1;                     // scope 0 at $DIR/simplify_try.rs:7:14: 7:15
-      }
-  
-      bb1: {
--         _0 = move _3;                    // scope 1 at $DIR/simplify_try.rs:8:5: 8:10
--         StorageDead(_3);                 // scope 0 at $DIR/simplify_try.rs:7:15: 7:16
-+         nop;                             // scope 1 at $DIR/simplify_try.rs:8:5: 8:10
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:7:15: 7:16
-          StorageDead(_2);                 // scope 0 at $DIR/simplify_try.rs:9:1: 9:2
-          goto -> bb2;                     // scope 0 at $DIR/simplify_try.rs:9:2: 9:2
-      }
-  
-      bb2: {
-          return;                          // scope 0 at $DIR/simplify_try.rs:9:2: 9:2
-      }
-  }
-  
diff --git a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff b/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff
deleted file mode 100644
index 83b91309be3..00000000000
--- a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff
+++ /dev/null
@@ -1,106 +0,0 @@
-- // MIR for `try_identity` before DestinationPropagation
-+ // MIR for `try_identity` after DestinationPropagation
-  
-  fn try_identity(_1: Result) -> Result {
-      debug x => _1;                       // in scope 0 at $DIR/simplify_try.rs:+0:17: +0:18
-      let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:+0:41: +0:57
-      let _2: u32;                         // in scope 0 at $DIR/simplify_try.rs:+1:9: +1:10
-      let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-      let mut _4: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
-      let mut _5: isize;                   // in scope 0 at $DIR/simplify_try.rs:+2:9: +2:15
-      let _6: i32;                         // in scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
-      let mut _7: !;                       // in scope 0 at $DIR/simplify_try.rs:+2:19: +2:51
-      let mut _8: i32;                     // in scope 0 at $DIR/simplify_try.rs:+2:37: +2:50
-      let mut _9: i32;                     // in scope 0 at $DIR/simplify_try.rs:+2:48: +2:49
-      let _10: u32;                        // in scope 0 at $DIR/simplify_try.rs:+3:12: +3:13
-      let mut _11: u32;                    // in scope 0 at $DIR/simplify_try.rs:+5:8: +5:9
-      scope 1 {
--         debug y => _2;                   // in scope 1 at $DIR/simplify_try.rs:+1:9: +1:10
-+         debug y => ((_0 as Ok).0: u32);  // in scope 1 at $DIR/simplify_try.rs:+1:9: +1:10
-      }
-      scope 2 {
-          debug e => _6;                   // in scope 2 at $DIR/simplify_try.rs:+2:13: +2:14
-          scope 5 (inlined >::from) { // at $DIR/simplify_try.rs:22:37: 22:50
-              debug t => _9;               // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-          }
-          scope 6 (inlined from_error::) { // at $DIR/simplify_try.rs:22:26: 22:51
-              debug e => _8;               // in scope 6 at $DIR/simplify_try.rs:12:21: 12:22
-          }
-      }
-      scope 3 {
--         debug v => _10;                  // in scope 3 at $DIR/simplify_try.rs:+3:12: +3:13
-+         debug v => ((_0 as Ok).0: u32);  // in scope 3 at $DIR/simplify_try.rs:+3:12: +3:13
-      }
-      scope 4 (inlined into_result::) { // at $DIR/simplify_try.rs:21:19: 21:33
--         debug r => _4;                   // in scope 4 at $DIR/simplify_try.rs:8:22: 8:23
-+         debug r => _3;                   // in scope 4 at $DIR/simplify_try.rs:8:22: 8:23
-      }
-  
-      bb0: {
--         StorageLive(_2);                 // scope 0 at $DIR/simplify_try.rs:+1:9: +1:10
--         StorageLive(_3);                 // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
--         StorageLive(_4);                 // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
--         _4 = _1;                         // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
--         _3 = move _4;                    // scope 4 at $DIR/simplify_try.rs:9:5: 9:6
--         StorageDead(_4);                 // scope 0 at $DIR/simplify_try.rs:+1:32: +1:33
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:+1:9: +1:10
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
-+         _3 = _1;                         // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
-+         nop;                             // scope 4 at $DIR/simplify_try.rs:9:5: 9:6
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:+1:32: +1:33
-          _5 = discriminant(_3);           // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-          switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33
-      }
-  
-      bb1: {
--         StorageLive(_10);                // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13
--         _10 = ((_3 as Ok).0: u32);       // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13
--         _2 = _10;                        // scope 3 at $DIR/simplify_try.rs:+3:18: +3:19
--         StorageDead(_10);                // scope 0 at $DIR/simplify_try.rs:+3:18: +3:19
--         StorageDead(_3);                 // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7
--         StorageLive(_11);                // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9
--         _11 = _2;                        // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13
-+         ((_0 as Ok).0: u32) = ((_3 as Ok).0: u32); // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13
-+         nop;                             // scope 3 at $DIR/simplify_try.rs:+3:18: +3:19
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:+3:18: +3:19
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7
-+         nop;                             // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9
-+         nop;                             // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9
-          Deinit(_0);                      // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10
--         ((_0 as Ok).0: u32) = move _11;  // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10
-+         nop;                             // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10
-          discriminant(_0) = 0;            // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10
--         StorageDead(_11);                // scope 1 at $DIR/simplify_try.rs:+5:9: +5:10
--         StorageDead(_2);                 // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2
-+         nop;                             // scope 1 at $DIR/simplify_try.rs:+5:9: +5:10
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2
-          return;                          // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2
-      }
-  
-      bb2: {
-          unreachable;                     // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-      }
-  
-      bb3: {
-          StorageLive(_6);                 // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
-          nop;                             // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
-          StorageLive(_8);                 // scope 2 at $DIR/simplify_try.rs:+2:37: +2:50
-          StorageLive(_9);                 // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49
-          nop;                             // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49
-          nop;                             // scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-          StorageDead(_9);                 // scope 2 at $DIR/simplify_try.rs:+2:49: +2:50
-          nop;                             // scope 6 at $DIR/simplify_try.rs:13:9: 13:10
-          Deinit(_0);                      // scope 6 at $DIR/simplify_try.rs:13:5: 13:11
-          discriminant(_0) = 1;            // scope 6 at $DIR/simplify_try.rs:13:5: 13:11
-          StorageDead(_8);                 // scope 2 at $DIR/simplify_try.rs:+2:50: +2:51
-          StorageDead(_6);                 // scope 0 at $DIR/simplify_try.rs:+2:50: +2:51
--         StorageDead(_3);                 // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7
--         StorageDead(_2);                 // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7
-+         nop;                             // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2
-          return;                          // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2
-      }
-  }
-  
diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff
deleted file mode 100644
index e025ae7c551..00000000000
--- a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff
+++ /dev/null
@@ -1,85 +0,0 @@
-- // MIR for `try_identity` before SimplifyArmIdentity
-+ // MIR for `try_identity` after SimplifyArmIdentity
-  
-  fn try_identity(_1: Result) -> Result {
-      debug x => _1;                       // in scope 0 at $DIR/simplify_try.rs:+0:17: +0:18
-      let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:+0:41: +0:57
-      let _2: u32;                         // in scope 0 at $DIR/simplify_try.rs:+1:9: +1:10
-      let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-      let mut _4: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
-      let mut _5: isize;                   // in scope 0 at $DIR/simplify_try.rs:+2:9: +2:15
-      let _6: i32;                         // in scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
-      let mut _7: !;                       // in scope 0 at $DIR/simplify_try.rs:+2:19: +2:51
-      let mut _8: i32;                     // in scope 0 at $DIR/simplify_try.rs:+2:37: +2:50
-      let mut _9: i32;                     // in scope 0 at $DIR/simplify_try.rs:+2:48: +2:49
-      let _10: u32;                        // in scope 0 at $DIR/simplify_try.rs:+3:12: +3:13
-      let mut _11: u32;                    // in scope 0 at $DIR/simplify_try.rs:+5:8: +5:9
-      scope 1 {
-          debug y => _2;                   // in scope 1 at $DIR/simplify_try.rs:+1:9: +1:10
-      }
-      scope 2 {
-          debug e => _6;                   // in scope 2 at $DIR/simplify_try.rs:+2:13: +2:14
-          scope 5 (inlined >::from) { // at $DIR/simplify_try.rs:22:37: 22:50
-              debug t => _9;               // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-          }
-          scope 6 (inlined from_error::) { // at $DIR/simplify_try.rs:22:26: 22:51
-              debug e => _8;               // in scope 6 at $DIR/simplify_try.rs:12:21: 12:22
-          }
-      }
-      scope 3 {
-          debug v => _10;                  // in scope 3 at $DIR/simplify_try.rs:+3:12: +3:13
-      }
-      scope 4 (inlined into_result::) { // at $DIR/simplify_try.rs:21:19: 21:33
-          debug r => _4;                   // in scope 4 at $DIR/simplify_try.rs:8:22: 8:23
-      }
-  
-      bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/simplify_try.rs:+1:9: +1:10
-          StorageLive(_3);                 // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-          StorageLive(_4);                 // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
-          _4 = _1;                         // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
-          _3 = move _4;                    // scope 4 at $DIR/simplify_try.rs:9:5: 9:6
-          StorageDead(_4);                 // scope 0 at $DIR/simplify_try.rs:+1:32: +1:33
-          _5 = discriminant(_3);           // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-          switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33
-      }
-  
-      bb1: {
-          StorageLive(_10);                // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13
-          _10 = ((_3 as Ok).0: u32);       // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13
-          _2 = _10;                        // scope 3 at $DIR/simplify_try.rs:+3:18: +3:19
-          StorageDead(_10);                // scope 0 at $DIR/simplify_try.rs:+3:18: +3:19
-          StorageDead(_3);                 // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7
-          StorageLive(_11);                // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9
-          _11 = _2;                        // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9
-          Deinit(_0);                      // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10
-          ((_0 as Ok).0: u32) = move _11;  // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10
-          discriminant(_0) = 0;            // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10
-          StorageDead(_11);                // scope 1 at $DIR/simplify_try.rs:+5:9: +5:10
-          StorageDead(_2);                 // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2
-          return;                          // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2
-      }
-  
-      bb2: {
-          unreachable;                     // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-      }
-  
-      bb3: {
-          StorageLive(_6);                 // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
-          _6 = ((_3 as Err).0: i32);       // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
-          StorageLive(_8);                 // scope 2 at $DIR/simplify_try.rs:+2:37: +2:50
-          StorageLive(_9);                 // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49
-          _9 = _6;                         // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49
-          _8 = move _9;                    // scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-          StorageDead(_9);                 // scope 2 at $DIR/simplify_try.rs:+2:49: +2:50
-          ((_0 as Err).0: i32) = move _8;  // scope 6 at $DIR/simplify_try.rs:13:9: 13:10
-          Deinit(_0);                      // scope 6 at $DIR/simplify_try.rs:13:5: 13:11
-          discriminant(_0) = 1;            // scope 6 at $DIR/simplify_try.rs:13:5: 13:11
-          StorageDead(_8);                 // scope 2 at $DIR/simplify_try.rs:+2:50: +2:51
-          StorageDead(_6);                 // scope 0 at $DIR/simplify_try.rs:+2:50: +2:51
-          StorageDead(_3);                 // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7
-          StorageDead(_2);                 // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2
-          return;                          // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2
-      }
-  }
-  
diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir b/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir
deleted file mode 100644
index eb5af2227ec..00000000000
--- a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir
+++ /dev/null
@@ -1,83 +0,0 @@
-// MIR for `try_identity` after SimplifyBranchSame
-
-fn try_identity(_1: Result) -> Result {
-    debug x => _1;                       // in scope 0 at $DIR/simplify_try.rs:+0:17: +0:18
-    let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:+0:41: +0:57
-    let _2: u32;                         // in scope 0 at $DIR/simplify_try.rs:+1:9: +1:10
-    let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-    let mut _4: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
-    let mut _5: isize;                   // in scope 0 at $DIR/simplify_try.rs:+2:9: +2:15
-    let _6: i32;                         // in scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
-    let mut _7: !;                       // in scope 0 at $DIR/simplify_try.rs:+2:19: +2:51
-    let mut _8: i32;                     // in scope 0 at $DIR/simplify_try.rs:+2:37: +2:50
-    let mut _9: i32;                     // in scope 0 at $DIR/simplify_try.rs:+2:48: +2:49
-    let _10: u32;                        // in scope 0 at $DIR/simplify_try.rs:+3:12: +3:13
-    let mut _11: u32;                    // in scope 0 at $DIR/simplify_try.rs:+5:8: +5:9
-    scope 1 {
-        debug y => _2;                   // in scope 1 at $DIR/simplify_try.rs:+1:9: +1:10
-    }
-    scope 2 {
-        debug e => _6;                   // in scope 2 at $DIR/simplify_try.rs:+2:13: +2:14
-        scope 5 (inlined >::from) { // at $DIR/simplify_try.rs:22:37: 22:50
-            debug t => _9;               // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-        }
-        scope 6 (inlined from_error::) { // at $DIR/simplify_try.rs:22:26: 22:51
-            debug e => _8;               // in scope 6 at $DIR/simplify_try.rs:12:21: 12:22
-        }
-    }
-    scope 3 {
-        debug v => _10;                  // in scope 3 at $DIR/simplify_try.rs:+3:12: +3:13
-    }
-    scope 4 (inlined into_result::) { // at $DIR/simplify_try.rs:21:19: 21:33
-        debug r => _4;                   // in scope 4 at $DIR/simplify_try.rs:8:22: 8:23
-    }
-
-    bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/simplify_try.rs:+1:9: +1:10
-        StorageLive(_3);                 // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-        StorageLive(_4);                 // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
-        _4 = _1;                         // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
-        _3 = move _4;                    // scope 4 at $DIR/simplify_try.rs:9:5: 9:6
-        StorageDead(_4);                 // scope 0 at $DIR/simplify_try.rs:+1:32: +1:33
-        _5 = discriminant(_3);           // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-        switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33
-    }
-
-    bb1: {
-        StorageLive(_10);                // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13
-        _10 = ((_3 as Ok).0: u32);       // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13
-        _2 = _10;                        // scope 3 at $DIR/simplify_try.rs:+3:18: +3:19
-        StorageDead(_10);                // scope 0 at $DIR/simplify_try.rs:+3:18: +3:19
-        StorageDead(_3);                 // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7
-        StorageLive(_11);                // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9
-        _11 = _2;                        // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9
-        Deinit(_0);                      // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10
-        ((_0 as Ok).0: u32) = move _11;  // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10
-        discriminant(_0) = 0;            // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10
-        StorageDead(_11);                // scope 1 at $DIR/simplify_try.rs:+5:9: +5:10
-        StorageDead(_2);                 // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2
-        return;                          // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2
-    }
-
-    bb2: {
-        unreachable;                     // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-    }
-
-    bb3: {
-        StorageLive(_6);                 // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
-        _6 = ((_3 as Err).0: i32);       // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
-        StorageLive(_8);                 // scope 2 at $DIR/simplify_try.rs:+2:37: +2:50
-        StorageLive(_9);                 // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49
-        _9 = _6;                         // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49
-        _8 = move _9;                    // scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-        StorageDead(_9);                 // scope 2 at $DIR/simplify_try.rs:+2:49: +2:50
-        ((_0 as Err).0: i32) = move _8;  // scope 6 at $DIR/simplify_try.rs:13:9: 13:10
-        Deinit(_0);                      // scope 6 at $DIR/simplify_try.rs:13:5: 13:11
-        discriminant(_0) = 1;            // scope 6 at $DIR/simplify_try.rs:13:5: 13:11
-        StorageDead(_8);                 // scope 2 at $DIR/simplify_try.rs:+2:50: +2:51
-        StorageDead(_6);                 // scope 0 at $DIR/simplify_try.rs:+2:50: +2:51
-        StorageDead(_3);                 // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7
-        StorageDead(_2);                 // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2
-        return;                          // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2
-    }
-}
diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir b/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir
deleted file mode 100644
index 1efa8a67e5c..00000000000
--- a/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir
+++ /dev/null
@@ -1,58 +0,0 @@
-// MIR for `try_identity` after SimplifyLocals
-
-fn try_identity(_1: Result) -> Result {
-    debug x => _1;                       // in scope 0 at $DIR/simplify_try.rs:+0:17: +0:18
-    let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:+0:41: +0:57
-    let mut _2: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-    let mut _3: isize;                   // in scope 0 at $DIR/simplify_try.rs:+2:9: +2:15
-    let _4: i32;                         // in scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
-    let mut _5: i32;                     // in scope 0 at $DIR/simplify_try.rs:+2:37: +2:50
-    let mut _6: i32;                     // in scope 0 at $DIR/simplify_try.rs:+2:48: +2:49
-    scope 1 {
-        debug y => ((_0 as Ok).0: u32);  // in scope 1 at $DIR/simplify_try.rs:+1:9: +1:10
-    }
-    scope 2 {
-        debug e => _4;                   // in scope 2 at $DIR/simplify_try.rs:+2:13: +2:14
-        scope 5 (inlined >::from) { // at $DIR/simplify_try.rs:22:37: 22:50
-            debug t => _6;               // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-        }
-        scope 6 (inlined from_error::) { // at $DIR/simplify_try.rs:22:26: 22:51
-            debug e => _5;               // in scope 6 at $DIR/simplify_try.rs:12:21: 12:22
-        }
-    }
-    scope 3 {
-        debug v => ((_0 as Ok).0: u32);  // in scope 3 at $DIR/simplify_try.rs:+3:12: +3:13
-    }
-    scope 4 (inlined into_result::) { // at $DIR/simplify_try.rs:21:19: 21:33
-        debug r => _2;                   // in scope 4 at $DIR/simplify_try.rs:8:22: 8:23
-    }
-
-    bb0: {
-        _2 = _1;                         // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32
-        _3 = discriminant(_2);           // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-        switchInt(move _3) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33
-    }
-
-    bb1: {
-        ((_0 as Ok).0: u32) = ((_2 as Ok).0: u32); // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13
-        Deinit(_0);                      // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10
-        discriminant(_0) = 0;            // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10
-        return;                          // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2
-    }
-
-    bb2: {
-        unreachable;                     // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33
-    }
-
-    bb3: {
-        StorageLive(_4);                 // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14
-        StorageLive(_5);                 // scope 2 at $DIR/simplify_try.rs:+2:37: +2:50
-        StorageLive(_6);                 // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49
-        StorageDead(_6);                 // scope 2 at $DIR/simplify_try.rs:+2:49: +2:50
-        Deinit(_0);                      // scope 6 at $DIR/simplify_try.rs:13:5: 13:11
-        discriminant(_0) = 1;            // scope 6 at $DIR/simplify_try.rs:13:5: 13:11
-        StorageDead(_5);                 // scope 2 at $DIR/simplify_try.rs:+2:50: +2:51
-        StorageDead(_4);                 // scope 0 at $DIR/simplify_try.rs:+2:50: +2:51
-        return;                          // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2
-    }
-}
diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml
index 41f97e4326a..1911f0f9c94 100644
--- a/src/tools/compiletest/Cargo.toml
+++ b/src/tools/compiletest/Cargo.toml
@@ -8,6 +8,7 @@ colored = "2"
 diff = "0.1.10"
 unified-diff = "0.2.1"
 getopts = "0.2"
+miropt-test-tools = { path = "../miropt-test-tools" }
 tracing = "0.1"
 tracing-subscriber = { version = "0.3.3", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
 regex = "1.0"
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 8af5f1da694..c37f81d1707 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -3399,103 +3399,49 @@ impl<'test> TestCx<'test> {
             }
         }
 
-        for l in test_file_contents.lines() {
-            if l.starts_with("// EMIT_MIR ") {
-                let test_name = l.trim_start_matches("// EMIT_MIR ").trim();
-                let mut test_names = test_name.split(' ');
-                // sometimes we specify two files so that we get a diff between the two files
-                let test_name = test_names.next().unwrap();
-                let mut expected_file;
-                let from_file;
-                let to_file;
+        let files = miropt_test_tools::files_for_miropt_test(
+            &self.testpaths.file,
+            self.config.get_pointer_width(),
+        );
 
-                if test_name.ends_with(".diff") {
-                    let trimmed = test_name.trim_end_matches(".diff");
-                    let test_against = format!("{}.after.mir", trimmed);
-                    from_file = format!("{}.before.mir", trimmed);
-                    expected_file = format!("{}{}.diff", trimmed, bit_width);
-                    assert!(
-                        test_names.next().is_none(),
-                        "two mir pass names specified for MIR diff"
-                    );
-                    to_file = Some(test_against);
-                } else if let Some(first_pass) = test_names.next() {
-                    let second_pass = test_names.next().unwrap();
-                    assert!(
-                        test_names.next().is_none(),
-                        "three mir pass names specified for MIR diff"
-                    );
-                    expected_file =
-                        format!("{}{}.{}-{}.diff", test_name, bit_width, first_pass, second_pass);
-                    let second_file = format!("{}.{}.mir", test_name, second_pass);
-                    from_file = format!("{}.{}.mir", test_name, first_pass);
-                    to_file = Some(second_file);
-                } else {
-                    let ext_re = Regex::new(r#"(\.(mir|dot|html))$"#).unwrap();
-                    let cap = ext_re
-                        .captures_iter(test_name)
-                        .next()
-                        .expect("test_name has an invalid extension");
-                    let extension = cap.get(1).unwrap().as_str();
-                    expected_file = format!(
-                        "{}{}{}",
-                        test_name.trim_end_matches(extension),
-                        bit_width,
-                        extension,
-                    );
-                    from_file = test_name.to_string();
-                    assert!(
-                        test_names.next().is_none(),
-                        "two mir pass names specified for MIR dump"
-                    );
-                    to_file = None;
-                };
-                if !expected_file.starts_with(&test_crate) {
-                    expected_file = format!("{}.{}", test_crate, expected_file);
-                }
-                let expected_file = test_dir.join(expected_file);
-
-                let dumped_string = if let Some(after) = to_file {
-                    self.diff_mir_files(from_file.into(), after.into())
-                } else {
-                    let mut output_file = PathBuf::new();
-                    output_file.push(self.get_mir_dump_dir());
-                    output_file.push(&from_file);
-                    debug!(
-                        "comparing the contents of: {} with {}",
+        for miropt_test_tools::MiroptTestFiles { from_file, to_file, expected_file } in files {
+            let dumped_string = if let Some(after) = to_file {
+                self.diff_mir_files(from_file.into(), after.into())
+            } else {
+                let mut output_file = PathBuf::new();
+                output_file.push(self.get_mir_dump_dir());
+                output_file.push(&from_file);
+                debug!(
+                    "comparing the contents of: {} with {}",
+                    output_file.display(),
+                    expected_file.display()
+                );
+                if !output_file.exists() {
+                    panic!(
+                        "Output file `{}` from test does not exist, available files are in `{}`",
                         output_file.display(),
+                        output_file.parent().unwrap().display()
+                    );
+                }
+                self.check_mir_test_timestamp(&from_file, &output_file);
+                let dumped_string = fs::read_to_string(&output_file).unwrap();
+                self.normalize_output(&dumped_string, &[])
+            };
+
+            if self.config.bless {
+                let _ = std::fs::remove_file(&expected_file);
+                std::fs::write(expected_file, dumped_string.as_bytes()).unwrap();
+            } else {
+                if !expected_file.exists() {
+                    panic!("Output file `{}` from test does not exist", expected_file.display());
+                }
+                let expected_string = fs::read_to_string(&expected_file).unwrap();
+                if dumped_string != expected_string {
+                    print!("{}", write_diff(&expected_string, &dumped_string, 3));
+                    panic!(
+                        "Actual MIR output differs from expected MIR output {}",
                         expected_file.display()
                     );
-                    if !output_file.exists() {
-                        panic!(
-                            "Output file `{}` from test does not exist, available files are in `{}`",
-                            output_file.display(),
-                            output_file.parent().unwrap().display()
-                        );
-                    }
-                    self.check_mir_test_timestamp(&from_file, &output_file);
-                    let dumped_string = fs::read_to_string(&output_file).unwrap();
-                    self.normalize_output(&dumped_string, &[])
-                };
-
-                if self.config.bless {
-                    let _ = std::fs::remove_file(&expected_file);
-                    std::fs::write(expected_file, dumped_string.as_bytes()).unwrap();
-                } else {
-                    if !expected_file.exists() {
-                        panic!(
-                            "Output file `{}` from test does not exist",
-                            expected_file.display()
-                        );
-                    }
-                    let expected_string = fs::read_to_string(&expected_file).unwrap();
-                    if dumped_string != expected_string {
-                        print!("{}", write_diff(&expected_string, &dumped_string, 3));
-                        panic!(
-                            "Actual MIR output differs from expected MIR output {}",
-                            expected_file.display()
-                        );
-                    }
                 }
             }
         }
diff --git a/src/tools/miropt-test-tools/Cargo.toml b/src/tools/miropt-test-tools/Cargo.toml
new file mode 100644
index 00000000000..8589a44cf1b
--- /dev/null
+++ b/src/tools/miropt-test-tools/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "miropt-test-tools"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+regex = "1.0"
diff --git a/src/tools/miropt-test-tools/src/lib.rs b/src/tools/miropt-test-tools/src/lib.rs
new file mode 100644
index 00000000000..96819d3547b
--- /dev/null
+++ b/src/tools/miropt-test-tools/src/lib.rs
@@ -0,0 +1,70 @@
+use std::fs;
+
+pub struct MiroptTestFiles {
+    pub expected_file: std::path::PathBuf,
+    pub from_file: String,
+    pub to_file: Option,
+}
+
+pub fn files_for_miropt_test(testfile: &std::path::Path, bit_width: u32) -> Vec {
+    let mut out = Vec::new();
+    let test_file_contents = fs::read_to_string(&testfile).unwrap();
+
+    let test_dir = testfile.parent().unwrap();
+    let test_crate = testfile.file_stem().unwrap().to_str().unwrap().replace("-", "_");
+
+    let bit_width = if test_file_contents.lines().any(|l| l == "// EMIT_MIR_FOR_EACH_BIT_WIDTH") {
+        format!(".{}bit", bit_width)
+    } else {
+        String::new()
+    };
+
+    for l in test_file_contents.lines() {
+        if l.starts_with("// EMIT_MIR ") {
+            let test_name = l.trim_start_matches("// EMIT_MIR ").trim();
+            let mut test_names = test_name.split(' ');
+            // sometimes we specify two files so that we get a diff between the two files
+            let test_name = test_names.next().unwrap();
+            let mut expected_file;
+            let from_file;
+            let to_file;
+
+            if test_name.ends_with(".diff") {
+                let trimmed = test_name.trim_end_matches(".diff");
+                let test_against = format!("{}.after.mir", trimmed);
+                from_file = format!("{}.before.mir", trimmed);
+                expected_file = format!("{}{}.diff", trimmed, bit_width);
+                assert!(test_names.next().is_none(), "two mir pass names specified for MIR diff");
+                to_file = Some(test_against);
+            } else if let Some(first_pass) = test_names.next() {
+                let second_pass = test_names.next().unwrap();
+                assert!(test_names.next().is_none(), "three mir pass names specified for MIR diff");
+                expected_file =
+                    format!("{}{}.{}-{}.diff", test_name, bit_width, first_pass, second_pass);
+                let second_file = format!("{}.{}.mir", test_name, second_pass);
+                from_file = format!("{}.{}.mir", test_name, first_pass);
+                to_file = Some(second_file);
+            } else {
+                let ext_re = regex::Regex::new(r#"(\.(mir|dot|html))$"#).unwrap();
+                let cap = ext_re
+                    .captures_iter(test_name)
+                    .next()
+                    .expect("test_name has an invalid extension");
+                let extension = cap.get(1).unwrap().as_str();
+                expected_file =
+                    format!("{}{}{}", test_name.trim_end_matches(extension), bit_width, extension,);
+                from_file = test_name.to_string();
+                assert!(test_names.next().is_none(), "two mir pass names specified for MIR dump");
+                to_file = None;
+            };
+            if !expected_file.starts_with(&test_crate) {
+                expected_file = format!("{}.{}", test_crate, expected_file);
+            }
+            let expected_file = test_dir.join(expected_file);
+
+            out.push(MiroptTestFiles { expected_file, from_file, to_file });
+        }
+    }
+
+    out
+}
diff --git a/src/tools/tidy/Cargo.toml b/src/tools/tidy/Cargo.toml
index 471d78a2922..774c97b7777 100644
--- a/src/tools/tidy/Cargo.toml
+++ b/src/tools/tidy/Cargo.toml
@@ -7,6 +7,7 @@ autobins = false
 [dependencies]
 cargo_metadata = "0.14"
 regex = "1"
+miropt-test-tools = { path = "../miropt-test-tools" }
 lazy_static = "1"
 walkdir = "2"
 
diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs
index fc0bce58572..698e4850bea 100644
--- a/src/tools/tidy/src/lib.rs
+++ b/src/tools/tidy/src/lib.rs
@@ -47,6 +47,7 @@ pub mod error_codes_check;
 pub mod errors;
 pub mod extdeps;
 pub mod features;
+pub mod mir_opt_tests;
 pub mod pal;
 pub mod primitive_docs;
 pub mod style;
diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs
index ca785042aaa..ee883777c31 100644
--- a/src/tools/tidy/src/main.rs
+++ b/src/tools/tidy/src/main.rs
@@ -64,6 +64,7 @@ fn main() {
         // Checks over tests.
         check!(debug_artifacts, &src_path);
         check!(ui_tests, &src_path);
+        check!(mir_opt_tests, &src_path);
 
         // Checks that only make sense for the compiler.
         check!(errors, &compiler_path);
diff --git a/src/tools/tidy/src/mir_opt_tests.rs b/src/tools/tidy/src/mir_opt_tests.rs
new file mode 100644
index 00000000000..f9e8b55497b
--- /dev/null
+++ b/src/tools/tidy/src/mir_opt_tests.rs
@@ -0,0 +1,37 @@
+//! Tidy check to ensure that mir opt directories do not have stale files.
+
+use std::collections::HashSet;
+use std::path::{Path, PathBuf};
+
+pub fn check(path: &Path, bad: &mut bool) {
+    let mut rs_files = Vec::::new();
+    let mut output_files = HashSet::::new();
+    let files = walkdir::WalkDir::new(&path.join("test/mir-opt")).into_iter();
+
+    for file in files.filter_map(Result::ok).filter(|e| e.file_type().is_file()) {
+        let filepath = file.path();
+        if filepath.extension() == Some("rs".as_ref()) {
+            rs_files.push(filepath.to_owned());
+        } else {
+            output_files.insert(filepath.to_owned());
+        }
+    }
+
+    for file in rs_files {
+        for bw in [32, 64] {
+            for output_file in miropt_test_tools::files_for_miropt_test(&file, bw) {
+                output_files.remove(&output_file.expected_file);
+            }
+        }
+    }
+
+    for extra in output_files {
+        if extra.file_name() != Some("README.md".as_ref()) {
+            tidy_error!(
+                bad,
+                "the following output file is not associated with any mir-opt test, you can remove it: {}",
+                extra.display()
+            );
+        }
+    }
+}

From b20d969516f2ade620ac0420ce3425e167684179 Mon Sep 17 00:00:00 2001
From: nils <48135649+Nilstrieb@users.noreply.github.com>
Date: Tue, 1 Nov 2022 16:24:01 +0100
Subject: [PATCH 150/219] Print valid `--print` requests if request is invalid

When someone makes a typo, it can be useful to see the valid options.
This is also useful if someone wants to find out about all the options.
---
 compiler/rustc_session/src/config.rs          | 61 ++++++++++++-------
 .../run-make/valid-print-requests/Makefile    |  4 ++
 .../valid-print-requests.stderr               |  2 +
 3 files changed, 44 insertions(+), 23 deletions(-)
 create mode 100644 src/test/run-make/valid-print-requests/Makefile
 create mode 100644 src/test/run-make/valid-print-requests/valid-print-requests.stderr

diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index f2ee52262ad..c0839d7e092 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -1788,34 +1788,49 @@ fn collect_print_requests(
         cg.target_feature = String::new();
     }
 
-    prints.extend(matches.opt_strs("print").into_iter().map(|s| match &*s {
-        "crate-name" => PrintRequest::CrateName,
-        "file-names" => PrintRequest::FileNames,
-        "sysroot" => PrintRequest::Sysroot,
-        "target-libdir" => PrintRequest::TargetLibdir,
-        "cfg" => PrintRequest::Cfg,
-        "calling-conventions" => PrintRequest::CallingConventions,
-        "target-list" => PrintRequest::TargetList,
-        "target-cpus" => PrintRequest::TargetCPUs,
-        "target-features" => PrintRequest::TargetFeatures,
-        "relocation-models" => PrintRequest::RelocationModels,
-        "code-models" => PrintRequest::CodeModels,
-        "tls-models" => PrintRequest::TlsModels,
-        "native-static-libs" => PrintRequest::NativeStaticLibs,
-        "stack-protector-strategies" => PrintRequest::StackProtectorStrategies,
-        "target-spec-json" => {
-            if unstable_opts.unstable_options {
-                PrintRequest::TargetSpec
-            } else {
+    const PRINT_REQUESTS: &[(&str, PrintRequest)] = &[
+        ("crate-name", PrintRequest::CrateName),
+        ("file-names", PrintRequest::FileNames),
+        ("sysroot", PrintRequest::Sysroot),
+        ("target-libdir", PrintRequest::TargetLibdir),
+        ("cfg", PrintRequest::Cfg),
+        ("calling-conventions", PrintRequest::CallingConventions),
+        ("target-list", PrintRequest::TargetList),
+        ("target-cpus", PrintRequest::TargetCPUs),
+        ("target-features", PrintRequest::TargetFeatures),
+        ("relocation-models", PrintRequest::RelocationModels),
+        ("code-models", PrintRequest::CodeModels),
+        ("tls-models", PrintRequest::TlsModels),
+        ("native-static-libs", PrintRequest::NativeStaticLibs),
+        ("stack-protector-strategies", PrintRequest::StackProtectorStrategies),
+        ("target-spec-json", PrintRequest::TargetSpec),
+        ("link-args", PrintRequest::LinkArgs),
+    ];
+
+    prints.extend(matches.opt_strs("print").into_iter().map(|req| {
+        match PRINT_REQUESTS.iter().find(|&&(name, _)| name == req) {
+            Some((_, PrintRequest::TargetSpec)) => {
+                if unstable_opts.unstable_options {
+                    PrintRequest::TargetSpec
+                } else {
+                    early_error(
+                        error_format,
+                        "the `-Z unstable-options` flag must also be passed to \
+                     enable the target-spec-json print option",
+                    );
+                }
+            }
+            Some(&(_, print_request)) => print_request,
+            None => {
+                let prints =
+                    PRINT_REQUESTS.iter().map(|(name, _)| format!("`{name}`")).collect::>();
+                let prints = prints.join(", ");
                 early_error(
                     error_format,
-                    "the `-Z unstable-options` flag must also be passed to \
-                     enable the target-spec-json print option",
+                    &format!("unknown print request `{req}`. Valid print requests are: {prints}"),
                 );
             }
         }
-        "link-args" => PrintRequest::LinkArgs,
-        req => early_error(error_format, &format!("unknown print request `{req}`")),
     }));
 
     prints
diff --git a/src/test/run-make/valid-print-requests/Makefile b/src/test/run-make/valid-print-requests/Makefile
new file mode 100644
index 00000000000..c325e536e7c
--- /dev/null
+++ b/src/test/run-make/valid-print-requests/Makefile
@@ -0,0 +1,4 @@
+include ../../run-make-fulldeps/tools.mk
+
+all:
+	$(RUSTC) --print uwu 2>&1 | diff - valid-print-requests.stderr
diff --git a/src/test/run-make/valid-print-requests/valid-print-requests.stderr b/src/test/run-make/valid-print-requests/valid-print-requests.stderr
new file mode 100644
index 00000000000..85782866d12
--- /dev/null
+++ b/src/test/run-make/valid-print-requests/valid-print-requests.stderr
@@ -0,0 +1,2 @@
+error: unknown print request `uwu`. Valid print requests are: `crate-name`, `file-names`, `sysroot`, `target-libdir`, `cfg`, `calling-conventions`, `target-list`, `target-cpus`, `target-features`, `relocation-models`, `code-models`, `tls-models`, `native-static-libs`, `stack-protector-strategies`, `target-spec-json`, `link-args`
+

From 10a5e75537e3189ffa808be7eadc19569966b266 Mon Sep 17 00:00:00 2001
From: Cameron Steffen 
Date: Tue, 1 Nov 2022 12:24:51 -0500
Subject: [PATCH 151/219] Add track_caller to some Lock methods

---
 compiler/rustc_data_structures/src/sync.rs | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs
index 9c0fb8265cf..c550f246e09 100644
--- a/compiler/rustc_data_structures/src/sync.rs
+++ b/compiler/rustc_data_structures/src/sync.rs
@@ -410,6 +410,7 @@ impl Lock {
 
     #[cfg(parallel_compiler)]
     #[inline(always)]
+    #[track_caller]
     pub fn lock(&self) -> LockGuard<'_, T> {
         if ERROR_CHECKING {
             self.0.try_lock().expect("lock was already held")
@@ -420,21 +421,25 @@ impl Lock {
 
     #[cfg(not(parallel_compiler))]
     #[inline(always)]
+    #[track_caller]
     pub fn lock(&self) -> LockGuard<'_, T> {
         self.0.borrow_mut()
     }
 
     #[inline(always)]
+    #[track_caller]
     pub fn with_lock R, R>(&self, f: F) -> R {
         f(&mut *self.lock())
     }
 
     #[inline(always)]
+    #[track_caller]
     pub fn borrow(&self) -> LockGuard<'_, T> {
         self.lock()
     }
 
     #[inline(always)]
+    #[track_caller]
     pub fn borrow_mut(&self) -> LockGuard<'_, T> {
         self.lock()
     }
@@ -476,6 +481,7 @@ impl RwLock {
 
     #[cfg(not(parallel_compiler))]
     #[inline(always)]
+    #[track_caller]
     pub fn read(&self) -> ReadGuard<'_, T> {
         self.0.borrow()
     }
@@ -491,6 +497,7 @@ impl RwLock {
     }
 
     #[inline(always)]
+    #[track_caller]
     pub fn with_read_lock R, R>(&self, f: F) -> R {
         f(&*self.read())
     }
@@ -509,6 +516,7 @@ impl RwLock {
 
     #[cfg(not(parallel_compiler))]
     #[inline(always)]
+    #[track_caller]
     pub fn write(&self) -> WriteGuard<'_, T> {
         self.0.borrow_mut()
     }
@@ -524,16 +532,19 @@ impl RwLock {
     }
 
     #[inline(always)]
+    #[track_caller]
     pub fn with_write_lock R, R>(&self, f: F) -> R {
         f(&mut *self.write())
     }
 
     #[inline(always)]
+    #[track_caller]
     pub fn borrow(&self) -> ReadGuard<'_, T> {
         self.read()
     }
 
     #[inline(always)]
+    #[track_caller]
     pub fn borrow_mut(&self) -> WriteGuard<'_, T> {
         self.write()
     }

From f00d2c9c90bfa8c72fbfe35acd139a93b583cb51 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= 
Date: Tue, 1 Nov 2022 19:36:25 +0100
Subject: [PATCH 152/219] Revert "ci: Bring back ninja for dist builders"

---
 src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile       | 2 +-
 src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile     | 2 +-
 src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh | 5 ++---
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile
index bff3f8f2192..cd86d9fb584 100644
--- a/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile
+++ b/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile
@@ -23,7 +23,6 @@ RUN yum upgrade -y && \
       libstdc++-devel.x86_64 \
       make \
       ncurses-devel \
-      ninja-build \
       openssl-devel \
       patch \
       perl \
@@ -65,6 +64,7 @@ ENV RUST_CONFIGURE_ARGS \
       --enable-profiler \
       --set target.i686-unknown-linux-gnu.linker=clang \
       --build=i686-unknown-linux-gnu \
+      --set llvm.ninja=false \
       --set rust.jemalloc
 ENV SCRIPT python3 ../x.py dist --build $HOSTS --host $HOSTS --target $HOSTS
 ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=clang
diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile
index 6fdf05aebd6..423aba06cca 100644
--- a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile
+++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile
@@ -23,7 +23,6 @@ RUN yum upgrade -y && \
       libstdc++-devel.x86_64 \
       make \
       ncurses-devel \
-      ninja-build \
       openssl-devel \
       patch \
       perl \
@@ -77,6 +76,7 @@ ENV RUST_CONFIGURE_ARGS \
       --set target.x86_64-unknown-linux-gnu.ar=/rustroot/bin/llvm-ar \
       --set target.x86_64-unknown-linux-gnu.ranlib=/rustroot/bin/llvm-ranlib \
       --set llvm.thin-lto=true \
+      --set llvm.ninja=false \
       --set rust.jemalloc \
       --set rust.use-lld=true \
       --set rust.lto=thin
diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh
index 15ab3e5bd6e..9abfd4e9731 100755
--- a/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh
+++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh
@@ -25,7 +25,6 @@ INC="/rustroot/include:/usr/include"
 # disable them. BOLT is used for optimizing LLVM.
 hide_output \
     cmake ../llvm \
-      -GNinja \
       -DCMAKE_C_COMPILER=/rustroot/bin/gcc \
       -DCMAKE_CXX_COMPILER=/rustroot/bin/g++ \
       -DCMAKE_BUILD_TYPE=Release \
@@ -40,8 +39,8 @@ hide_output \
       -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt;bolt" \
       -DC_INCLUDE_DIRS="$INC"
 
-hide_output ninja
-hide_output ninja install
+hide_output make -j$(nproc)
+hide_output make install
 
 cd ../..
 rm -rf llvm-project

From 2024f70379bdb45eb671eb1d23c1175320def736 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez 
Date: Tue, 1 Nov 2022 15:48:13 +0100
Subject: [PATCH 153/219] Migrate sidebar-links-color GUI test to functions

---
 src/test/rustdoc-gui/sidebar-links-color.goml | 382 ++++++++----------
 1 file changed, 160 insertions(+), 222 deletions(-)

diff --git a/src/test/rustdoc-gui/sidebar-links-color.goml b/src/test/rustdoc-gui/sidebar-links-color.goml
index 18a1a3fadea..7ef7ec90cd2 100644
--- a/src/test/rustdoc-gui/sidebar-links-color.goml
+++ b/src/test/rustdoc-gui/sidebar-links-color.goml
@@ -4,230 +4,168 @@ goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
 // This is needed so that the text color is computed.
 show-text: true
 
-// Ayu theme
-local-storage: {
-    "rustdoc-theme": "ayu",
-    "rustdoc-use-system-theme": "false",
-}
-reload:
-
-// Struct
-assert-css: (
-    ".sidebar .block.struct a:not(.current)",
-    {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.struct a:not(.current)"
-assert-css: (
-    ".sidebar .block.struct a:hover",
-    {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-// Enum
-assert-css: (
-    ".sidebar .block.enum a",
-    {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.enum a"
-assert-css: (
-    ".sidebar .block.enum a:hover",
-    {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-// Union
-assert-css: (
-    ".sidebar .block.union a",
-    {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.union a"
-assert-css: (
-    ".sidebar .block.union a:hover",
-    {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-// Trait
-assert-css: (
-    ".sidebar .block.trait a",
-    {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.trait a"
-assert-css: (
-    ".sidebar .block.trait a:hover",
-    {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-// Function
-assert-css: (
-    ".sidebar .block.fn a",
-    {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.fn a"
-assert-css: (
-    ".sidebar .block.fn a:hover",
-    {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-// Type definition
-assert-css: (
-    ".sidebar .block.type a",
-    {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.type a"
-assert-css: (
-    ".sidebar .block.type a:hover",
-    {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-// Keyword
-assert-css: (
-    ".sidebar .block.keyword a",
-    {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.keyword a"
-assert-css: (
-    ".sidebar .block.keyword a:hover",
-    {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)"},
+define-function: (
+    "check-colors",
+    (
+        theme, struct, struct_hover, struct_hover_background, enum, enum_hover,
+        enum_hover_background, union, union_hover, union_hover_background, trait, trait_hover,
+        trait_hover_background, fn, fn_hover, fn_hover_background, type, type_hover,
+        type_hover_background, keyword, keyword_hover, keyword_hover_background,
+    ),
+    [
+        ("local-storage", { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" }),
+        ("reload"),
+        // Struct
+        ("assert-css", (
+            ".sidebar .block.struct a:not(.current)",
+            {"color": |struct|, "background-color": "rgba(0, 0, 0, 0)"},
+        )),
+        ("move-cursor-to", ".sidebar .block.struct a:not(.current)"),
+        ("assert-css", (
+            ".sidebar .block.struct a:hover",
+            {"color": |struct_hover|, "background-color": |struct_hover_background|},
+        )),
+        // Enum
+        ("assert-css", (
+            ".sidebar .block.enum a",
+            {"color": |enum|, "background-color": "rgba(0, 0, 0, 0)"},
+        )),
+        ("move-cursor-to", ".sidebar .block.enum a"),
+        ("assert-css", (
+            ".sidebar .block.enum a:hover",
+            {"color": |enum_hover|, "background-color": |enum_hover_background|},
+        )),
+        // Union
+        ("assert-css", (
+            ".sidebar .block.union a",
+            {"color": |union|, "background-color": "rgba(0, 0, 0, 0)"},
+        )),
+        ("move-cursor-to", ".sidebar .block.union a"),
+        ("assert-css", (
+            ".sidebar .block.union a:hover",
+            {"color": |union_hover|, "background-color": |union_hover_background|},
+        )),
+        // Trait
+        ("assert-css", (
+            ".sidebar .block.trait a",
+            {"color": |trait|, "background-color": "rgba(0, 0, 0, 0)"},
+        )),
+        ("move-cursor-to", ".sidebar .block.trait a"),
+        ("assert-css", (
+            ".sidebar .block.trait a:hover",
+            {"color": |trait_hover|, "background-color": |trait_hover_background|},
+        )),
+        // Function
+        ("assert-css", (
+            ".sidebar .block.fn a",
+            {"color": |fn|, "background-color": "rgba(0, 0, 0, 0)"},
+        )),
+        ("move-cursor-to", ".sidebar .block.fn a"),
+        ("assert-css", (
+            ".sidebar .block.fn a:hover",
+            {"color": |fn_hover|, "background-color": |fn_hover_background|},
+        )),
+        // Type definition
+        ("assert-css", (
+            ".sidebar .block.type a",
+            {"color": |type|, "background-color": "rgba(0, 0, 0, 0)"},
+        )),
+        ("move-cursor-to", ".sidebar .block.type a"),
+        ("assert-css", (
+            ".sidebar .block.type a:hover",
+            {"color": |type_hover|, "background-color": |type_hover_background|},
+        )),
+        // Keyword
+        ("assert-css", (
+            ".sidebar .block.keyword a",
+            {"color": |keyword|, "background-color": "rgba(0, 0, 0, 0)"},
+        )),
+        ("move-cursor-to", ".sidebar .block.keyword a"),
+        ("assert-css", (
+            ".sidebar .block.keyword a:hover",
+            {"color": |keyword_hover|, "background-color": |keyword_hover_background|},
+        )),
+    ]
 )
 
-// Dark theme
-local-storage: {"rustdoc-theme": "dark"}
-reload:
-
-// Struct
-assert-css: (
-    ".sidebar .block.struct a:not(.current)",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"},
+call-function: (
+    "check-colors",
+    {
+        "theme": "ayu",
+        "struct": "rgb(83, 177, 219)",
+        "struct_hover": "rgb(255, 180, 76)",
+        "struct_hover_background": "rgba(0, 0, 0, 0)",
+        "enum": "rgb(83, 177, 219)",
+        "enum_hover": "rgb(255, 180, 76)",
+        "enum_hover_background": "rgba(0, 0, 0, 0)",
+        "union": "rgb(83, 177, 219)",
+        "union_hover": "rgb(255, 180, 76)",
+        "union_hover_background": "rgba(0, 0, 0, 0)",
+        "trait": "rgb(83, 177, 219)",
+        "trait_hover": "rgb(255, 180, 76)",
+        "trait_hover_background": "rgba(0, 0, 0, 0)",
+        "fn": "rgb(83, 177, 219)",
+        "fn_hover": "rgb(255, 180, 76)",
+        "fn_hover_background": "rgba(0, 0, 0, 0)",
+        "type": "rgb(83, 177, 219)",
+        "type_hover": "rgb(255, 180, 76)",
+        "type_hover_background": "rgba(0, 0, 0, 0)",
+        "keyword": "rgb(83, 177, 219)",
+        "keyword_hover": "rgb(255, 180, 76)",
+        "keyword_hover_background": "rgba(0, 0, 0, 0)",
+    }
 )
-move-cursor-to: ".sidebar .block.struct a:not(.current)"
-assert-css: (
-    ".sidebar .block.struct a:hover",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"},
+call-function: (
+    "check-colors",
+    {
+        "theme": "dark",
+        "struct": "rgb(253, 191, 53)",
+        "struct_hover": "rgb(253, 191, 53)",
+        "struct_hover_background": "rgb(68, 68, 68)",
+        "enum": "rgb(253, 191, 53)",
+        "enum_hover": "rgb(253, 191, 53)",
+        "enum_hover_background": "rgb(68, 68, 68)",
+        "union": "rgb(253, 191, 53)",
+        "union_hover": "rgb(253, 191, 53)",
+        "union_hover_background": "rgb(68, 68, 68)",
+        "trait": "rgb(253, 191, 53)",
+        "trait_hover": "rgb(253, 191, 53)",
+        "trait_hover_background": "rgb(68, 68, 68)",
+        "fn": "rgb(253, 191, 53)",
+        "fn_hover": "rgb(253, 191, 53)",
+        "fn_hover_background": "rgb(68, 68, 68)",
+        "type": "rgb(253, 191, 53)",
+        "type_hover": "rgb(253, 191, 53)",
+        "type_hover_background": "rgb(68, 68, 68)",
+        "keyword": "rgb(253, 191, 53)",
+        "keyword_hover": "rgb(253, 191, 53)",
+        "keyword_hover_background": "rgb(68, 68, 68)",
+    }
 )
-// Enum
-assert-css: (
-    ".sidebar .block.enum a",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.enum a"
-assert-css: (
-    ".sidebar .block.enum a:hover",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"},
-)
-// Union
-assert-css: (
-    ".sidebar .block.union a",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.union a"
-assert-css: (
-    ".sidebar .block.union a:hover",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"},
-)
-// Trait
-assert-css: (
-    ".sidebar .block.trait a",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.trait a"
-assert-css: (
-    ".sidebar .block.trait a:hover",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"},
-)
-// Function
-assert-css: (
-    ".sidebar .block.fn a",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.fn a"
-assert-css: (
-    ".sidebar .block.fn a:hover",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"},
-)
-// Type definition
-assert-css: (
-    ".sidebar .block.type a",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.type a"
-assert-css: (
-    ".sidebar .block.type a:hover",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"},
-)
-// Keyword
-assert-css: (
-    ".sidebar .block.keyword a",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.keyword a"
-assert-css: (
-    ".sidebar .block.keyword a:hover",
-    {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)"},
-)
-
-// Light theme
-local-storage: {"rustdoc-theme": "light"}
-reload:
-
-// Struct
-assert-css: (
-    ".sidebar .block.struct a:not(.current)",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.struct a:not(.current)"
-assert-css: (
-    ".sidebar .block.struct a:hover",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"},
-)
-// Enum
-assert-css: (
-    ".sidebar .block.enum a",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.enum a"
-assert-css: (
-    ".sidebar .block.enum a:hover",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"},
-)
-// Union
-assert-css: (
-    ".sidebar .block.union a",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.union a"
-assert-css: (
-    ".sidebar .block.union a:hover",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"},
-)
-// Trait
-assert-css: (
-    ".sidebar .block.trait a",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.trait a"
-assert-css: (
-    ".sidebar .block.trait a:hover",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"},
-)
-// Function
-assert-css: (
-    ".sidebar .block.fn a",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.fn a"
-assert-css: (
-    ".sidebar .block.fn a:hover",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"},
-)
-// Type definition
-assert-css: (
-    ".sidebar .block.type a",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.type a"
-assert-css: (
-    ".sidebar .block.type a:hover",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"},
-)
-// Keyword
-assert-css: (
-    ".sidebar .block.keyword a",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)"},
-)
-move-cursor-to: ".sidebar .block.keyword a"
-assert-css: (
-    ".sidebar .block.keyword a:hover",
-    {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)"},
+call-function: (
+    "check-colors",
+    {
+        "theme": "light",
+        "struct": "rgb(53, 109, 164)",
+        "struct_hover": "rgb(53, 109, 164)",
+        "struct_hover_background": "rgb(255, 255, 255)",
+        "enum": "rgb(53, 109, 164)",
+        "enum_hover": "rgb(53, 109, 164)",
+        "enum_hover_background": "rgb(255, 255, 255)",
+        "union": "rgb(53, 109, 164)",
+        "union_hover": "rgb(53, 109, 164)",
+        "union_hover_background": "rgb(255, 255, 255)",
+        "trait": "rgb(53, 109, 164)",
+        "trait_hover": "rgb(53, 109, 164)",
+        "trait_hover_background": "rgb(255, 255, 255)",
+        "fn": "rgb(53, 109, 164)",
+        "fn_hover": "rgb(53, 109, 164)",
+        "fn_hover_background": "rgb(255, 255, 255)",
+        "type": "rgb(53, 109, 164)",
+        "type_hover": "rgb(53, 109, 164)",
+        "type_hover_background": "rgb(255, 255, 255)",
+        "keyword": "rgb(53, 109, 164)",
+        "keyword_hover": "rgb(53, 109, 164)",
+        "keyword_hover_background": "rgb(255, 255, 255)",
+    }
 )

From a1dfefaded156c106cbba578ed1be589cffaaf72 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez 
Date: Tue, 1 Nov 2022 19:47:12 +0100
Subject: [PATCH 154/219] Remove unneeded "rustdoc-preferred-dark-theme"
 setting

---
 src/test/rustdoc-gui/theme-in-history.goml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/test/rustdoc-gui/theme-in-history.goml b/src/test/rustdoc-gui/theme-in-history.goml
index c29571728a1..10508e86a36 100644
--- a/src/test/rustdoc-gui/theme-in-history.goml
+++ b/src/test/rustdoc-gui/theme-in-history.goml
@@ -3,7 +3,6 @@ goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
 // Set the theme to dark.
 local-storage: {
     "rustdoc-theme": "dark",
-    "rustdoc-preferred-dark-theme": "dark",
     "rustdoc-use-system-theme": "false",
 }
 // We reload the page so the local storage settings are being used.

From e24df2778fb7a19dfe386ad563ea216a816db94a Mon Sep 17 00:00:00 2001
From: Michael Goulet 
Date: Sun, 30 Oct 2022 19:39:07 +0000
Subject: [PATCH 155/219] Format dyn Trait better in type_name intrinsic

---
 .../rustc_const_eval/src/util/type_name.rs     | 12 ++----------
 compiler/rustc_middle/src/ty/print/pretty.rs   |  2 +-
 library/core/tests/any.rs                      | 18 ++++++++++++++++++
 .../ui/type/issue-94187-verbose-type-name.rs   |  5 +----
 4 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/compiler/rustc_const_eval/src/util/type_name.rs b/compiler/rustc_const_eval/src/util/type_name.rs
index 221efc6f981..08a6d69b8e4 100644
--- a/compiler/rustc_const_eval/src/util/type_name.rs
+++ b/compiler/rustc_const_eval/src/util/type_name.rs
@@ -73,18 +73,10 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
     }
 
     fn print_dyn_existential(
-        mut self,
+        self,
         predicates: &'tcx ty::List>>,
     ) -> Result {
-        let mut first = true;
-        for p in predicates {
-            if !first {
-                write!(self, "+")?;
-            }
-            first = false;
-            self = p.print(self)?;
-        }
-        Ok(self)
+        self.pretty_print_dyn_existential(predicates)
     }
 
     fn path_crate(mut self, cnum: CrateNum) -> Result {
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs
index f07c60af248..fab85c39d25 100644
--- a/compiler/rustc_middle/src/ty/print/pretty.rs
+++ b/compiler/rustc_middle/src/ty/print/pretty.rs
@@ -1137,7 +1137,7 @@ pub trait PrettyPrinter<'tcx>:
         //
         // To avoid causing instabilities in compiletest
         // output, sort the auto-traits alphabetically.
-        auto_traits.sort_by_cached_key(|did| self.tcx().def_path_str(*did));
+        auto_traits.sort_by_cached_key(|did| with_no_trimmed_paths!(self.tcx().def_path_str(*did)));
 
         for def_id in auto_traits {
             if !first {
diff --git a/library/core/tests/any.rs b/library/core/tests/any.rs
index 9538b813949..e98dac8d12e 100644
--- a/library/core/tests/any.rs
+++ b/library/core/tests/any.rs
@@ -131,6 +131,24 @@ fn distinct_type_names() {
     assert_ne!(type_name_of_val(Velocity), type_name_of_val(Velocity(0.0, -9.8)),);
 }
 
+#[cfg(not(bootstrap))]
+#[test]
+fn dyn_type_name() {
+    trait Foo {
+        type Bar;
+    }
+
+    assert_eq!(
+        "dyn core::ops::function::Fn(i32, i32) -> i32",
+        std::any::type_name:: i32>()
+    );
+    assert_eq!(
+        "dyn coretests::any::dyn_type_name::Foo \
+        + core::marker::Send + core::marker::Sync",
+        std::any::type_name:: + Send + Sync>()
+    );
+}
+
 // Test the `Provider` API.
 
 struct SomeConcreteType {
diff --git a/src/test/ui/type/issue-94187-verbose-type-name.rs b/src/test/ui/type/issue-94187-verbose-type-name.rs
index 64f0c09e89b..3713a32eb11 100644
--- a/src/test/ui/type/issue-94187-verbose-type-name.rs
+++ b/src/test/ui/type/issue-94187-verbose-type-name.rs
@@ -12,8 +12,5 @@ fn main() {
     struct Wrapper;
     assert_eq!(type_name::>(), "issue_94187_verbose_type_name::main::Wrapper<0>");
 
-    assert_eq!(
-        type_name:: u32>(),
-        "dyn core::ops::function::Fn<(u32,)>+Output = u32"
-    );
+    assert_eq!(type_name:: u32>(), "dyn core::ops::function::Fn(u32) -> u32");
 }

From 744fa610eb6bd476b875dd2d6f8be5b7b9f1b77c Mon Sep 17 00:00:00 2001
From: Zhixing Zhang 
Date: Mon, 31 Oct 2022 17:01:00 -0700
Subject: [PATCH 156/219] fix(generic_const_exprs): Fix predicate inheritance
 for children of opaque types

---
 .../src/collect/predicates_of.rs              | 31 +++++++++++++++--
 .../generic_const_exprs/issue-99705.rs        | 33 +++++++++++++++++++
 2 files changed, 62 insertions(+), 2 deletions(-)
 create mode 100644 src/test/ui/const-generics/generic_const_exprs/issue-99705.rs

diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs
index 2e84e1d0160..5d1ca1cbd23 100644
--- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs
+++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs
@@ -427,6 +427,8 @@ pub(super) fn explicit_predicates_of<'tcx>(
     } else {
         if matches!(def_kind, DefKind::AnonConst) && tcx.lazy_normalization() {
             let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
+            let parent_def_id = tcx.hir().get_parent_item(hir_id);
+
             if tcx.hir().opt_const_param_default_param_hir_id(hir_id).is_some() {
                 // In `generics_of` we set the generics' parent to be our parent's parent which means that
                 // we lose out on the predicates of our actual parent if we dont return those predicates here.
@@ -439,8 +441,33 @@ pub(super) fn explicit_predicates_of<'tcx>(
                 //        parent of generics returned by `generics_of`
                 //
                 // In the above code we want the anon const to have predicates in its param env for `T: Trait`
-                let item_def_id = tcx.hir().get_parent_item(hir_id);
-                // In the above code example we would be calling `explicit_predicates_of(Foo)` here
+                // and we would be calling `explicit_predicates_of(Foo)` here
+                return tcx.explicit_predicates_of(parent_def_id);
+            }
+
+            let parent_def_kind = tcx.def_kind(parent_def_id);
+            if matches!(parent_def_kind, DefKind::OpaqueTy) {
+                // In `instantiate_identity` we inherit the predicates of our parent.
+                // However, opaque types do not have a parent (see `gather_explicit_predicates_of`), which means
+                // that we lose out on the predicates of our actual parent if we dont return those predicates here.
+                //
+                //
+                // fn foo() -> impl Iterator::ASSOC }> > { todo!() }
+                //                                                        ^^^^^^^^^^^^^^^^^^^ the def id we are calling
+                //                                                                            explicit_predicates_of on
+                //
+                // In the above code we want the anon const to have predicates in its param env for `T: Trait`.
+                // However, the anon const cannot inherit predicates from its parent since it's opaque.
+                //
+                // To fix this, we call `explicit_predicates_of` directly on `foo`, the parent's parent.
+
+                // In the above example this is `foo::{opaque#0}` or `impl Iterator`
+                let parent_hir_id = tcx.hir().local_def_id_to_hir_id(parent_def_id.def_id);
+
+                // In the above example this is the function `foo`
+                let item_def_id = tcx.hir().get_parent_item(parent_hir_id);
+
+                // In the above code example we would be calling `explicit_predicates_of(foo)` here
                 return tcx.explicit_predicates_of(item_def_id);
             }
         }
diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-99705.rs b/src/test/ui/const-generics/generic_const_exprs/issue-99705.rs
new file mode 100644
index 00000000000..75b57b621bb
--- /dev/null
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-99705.rs
@@ -0,0 +1,33 @@
+// check-pass
+#![crate_type = "lib"]
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
+pub trait MyIterator {
+    type Output;
+}
+
+pub trait Foo {
+    const ABC: usize;
+}
+
+pub struct IteratorStruct{
+
+}
+
+pub struct Bar {
+    pub data: [usize; N]
+}
+
+impl MyIterator for IteratorStruct {
+    type Output = Bar;
+}
+
+pub fn test1() -> impl MyIterator> where [(); T::ABC]: Sized {
+    IteratorStruct::<{T::ABC}>{}
+}
+
+pub trait Baz{}
+impl Baz for Bar {}
+pub fn test2() -> impl MyIterator> where [(); T::ABC]: Sized {
+    IteratorStruct::<{T::ABC}>{}
+}

From e6043272863e836a513b3d914eb66e1965d2f14a Mon Sep 17 00:00:00 2001
From: Samuel Moelius 
Date: Tue, 1 Nov 2022 19:02:45 -0400
Subject: [PATCH 157/219] Reorder `walk_` functions in intravisit.rs

---
 compiler/rustc_hir/src/intravisit.rs | 944 +++++++++++++--------------
 1 file changed, 472 insertions(+), 472 deletions(-)

diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs
index 9ee5e25c9bf..d852893ad5d 100644
--- a/compiler/rustc_hir/src/intravisit.rs
+++ b/compiler/rustc_hir/src/intravisit.rs
@@ -443,72 +443,6 @@ pub trait Visitor<'v>: Sized {
     }
 }
 
-pub fn walk_mod<'v, V: Visitor<'v>>(visitor: &mut V, module: &'v Mod<'v>, mod_hir_id: HirId) {
-    visitor.visit_id(mod_hir_id);
-    for &item_id in module.item_ids {
-        visitor.visit_nested_item(item_id);
-    }
-}
-
-pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &'v Body<'v>) {
-    walk_list!(visitor, visit_param, body.params);
-    visitor.visit_expr(&body.value);
-}
-
-pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local<'v>) {
-    // Intentionally visiting the expr first - the initialization expr
-    // dominates the local's definition.
-    walk_list!(visitor, visit_expr, &local.init);
-    visitor.visit_id(local.hir_id);
-    visitor.visit_pat(&local.pat);
-    if let Some(els) = local.els {
-        visitor.visit_block(els);
-    }
-    walk_list!(visitor, visit_ty, &local.ty);
-}
-
-pub fn walk_ident<'v, V: Visitor<'v>>(visitor: &mut V, ident: Ident) {
-    visitor.visit_name(ident.name);
-}
-
-pub fn walk_label<'v, V: Visitor<'v>>(visitor: &mut V, label: &'v Label) {
-    visitor.visit_ident(label.ident);
-}
-
-pub fn walk_generic_arg<'v, V: Visitor<'v>>(visitor: &mut V, generic_arg: &'v GenericArg<'v>) {
-    match generic_arg {
-        GenericArg::Lifetime(lt) => visitor.visit_lifetime(lt),
-        GenericArg::Type(ty) => visitor.visit_ty(ty),
-        GenericArg::Const(ct) => visitor.visit_anon_const(&ct.value),
-        GenericArg::Infer(inf) => visitor.visit_infer(inf),
-    }
-}
-
-pub fn walk_lifetime<'v, V: Visitor<'v>>(visitor: &mut V, lifetime: &'v Lifetime) {
-    visitor.visit_id(lifetime.hir_id);
-    match lifetime.name {
-        LifetimeName::Param(_, ParamName::Plain(ident)) => {
-            visitor.visit_ident(ident);
-        }
-        LifetimeName::Param(_, ParamName::Fresh)
-        | LifetimeName::Param(_, ParamName::Error)
-        | LifetimeName::Static
-        | LifetimeName::Error
-        | LifetimeName::ImplicitObjectLifetimeDefault
-        | LifetimeName::Infer => {}
-    }
-}
-
-pub fn walk_poly_trait_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_ref: &'v PolyTraitRef<'v>) {
-    walk_list!(visitor, visit_generic_param, trait_ref.bound_generic_params);
-    visitor.visit_trait_ref(&trait_ref.trait_ref);
-}
-
-pub fn walk_trait_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_ref: &'v TraitRef<'v>) {
-    visitor.visit_id(trait_ref.hir_ref_id);
-    visitor.visit_path(&trait_ref.path, trait_ref.hir_ref_id)
-}
-
 pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param<'v>) {
     visitor.visit_id(param.hir_id);
     visitor.visit_pat(¶m.pat);
@@ -605,142 +539,80 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
     }
 }
 
-pub fn walk_inline_asm<'v, V: Visitor<'v>>(visitor: &mut V, asm: &'v InlineAsm<'v>, id: HirId) {
-    for (op, op_sp) in asm.operands {
-        match op {
-            InlineAsmOperand::In { expr, .. } | InlineAsmOperand::InOut { expr, .. } => {
-                visitor.visit_expr(expr)
+pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &'v Body<'v>) {
+    walk_list!(visitor, visit_param, body.params);
+    visitor.visit_expr(&body.value);
+}
+
+pub fn walk_ident<'v, V: Visitor<'v>>(visitor: &mut V, ident: Ident) {
+    visitor.visit_name(ident.name);
+}
+
+pub fn walk_mod<'v, V: Visitor<'v>>(visitor: &mut V, module: &'v Mod<'v>, mod_hir_id: HirId) {
+    visitor.visit_id(mod_hir_id);
+    for &item_id in module.item_ids {
+        visitor.visit_nested_item(item_id);
+    }
+}
+
+pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v ForeignItem<'v>) {
+    visitor.visit_id(foreign_item.hir_id());
+    visitor.visit_ident(foreign_item.ident);
+
+    match foreign_item.kind {
+        ForeignItemKind::Fn(ref function_declaration, param_names, ref generics) => {
+            visitor.visit_generics(generics);
+            visitor.visit_fn_decl(function_declaration);
+            for ¶m_name in param_names {
+                visitor.visit_ident(param_name);
             }
-            InlineAsmOperand::Out { expr, .. } => {
-                if let Some(expr) = expr {
-                    visitor.visit_expr(expr);
-                }
+        }
+        ForeignItemKind::Static(ref typ, _) => visitor.visit_ty(typ),
+        ForeignItemKind::Type => (),
+    }
+}
+
+pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local<'v>) {
+    // Intentionally visiting the expr first - the initialization expr
+    // dominates the local's definition.
+    walk_list!(visitor, visit_expr, &local.init);
+    visitor.visit_id(local.hir_id);
+    visitor.visit_pat(&local.pat);
+    if let Some(els) = local.els {
+        visitor.visit_block(els);
+    }
+    walk_list!(visitor, visit_ty, &local.ty);
+}
+
+pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block<'v>) {
+    visitor.visit_id(block.hir_id);
+    walk_list!(visitor, visit_stmt, block.stmts);
+    walk_list!(visitor, visit_expr, &block.expr);
+}
+
+pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt<'v>) {
+    visitor.visit_id(statement.hir_id);
+    match statement.kind {
+        StmtKind::Local(ref local) => visitor.visit_local(local),
+        StmtKind::Item(item) => visitor.visit_nested_item(item),
+        StmtKind::Expr(ref expression) | StmtKind::Semi(ref expression) => {
+            visitor.visit_expr(expression)
+        }
+    }
+}
+
+pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm<'v>) {
+    visitor.visit_id(arm.hir_id);
+    visitor.visit_pat(&arm.pat);
+    if let Some(ref g) = arm.guard {
+        match g {
+            Guard::If(ref e) => visitor.visit_expr(e),
+            Guard::IfLet(ref l) => {
+                visitor.visit_let_expr(l);
             }
-            InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
-                visitor.visit_expr(in_expr);
-                if let Some(out_expr) = out_expr {
-                    visitor.visit_expr(out_expr);
-                }
-            }
-            InlineAsmOperand::Const { anon_const, .. }
-            | InlineAsmOperand::SymFn { anon_const, .. } => visitor.visit_anon_const(anon_const),
-            InlineAsmOperand::SymStatic { path, .. } => visitor.visit_qpath(path, id, *op_sp),
         }
     }
-}
-
-pub fn walk_use<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path<'v>, hir_id: HirId) {
-    visitor.visit_id(hir_id);
-    visitor.visit_path(path, hir_id);
-}
-
-pub fn walk_enum_def<'v, V: Visitor<'v>>(
-    visitor: &mut V,
-    enum_definition: &'v EnumDef<'v>,
-    item_id: HirId,
-) {
-    visitor.visit_id(item_id);
-    walk_list!(visitor, visit_variant, enum_definition.variants);
-}
-
-pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V, variant: &'v Variant<'v>) {
-    visitor.visit_ident(variant.ident);
-    visitor.visit_id(variant.id);
-    visitor.visit_variant_data(&variant.data);
-    walk_list!(visitor, visit_anon_const, &variant.disr_expr);
-}
-
-pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) {
-    visitor.visit_id(typ.hir_id);
-
-    match typ.kind {
-        TyKind::Slice(ref ty) => visitor.visit_ty(ty),
-        TyKind::Ptr(ref mutable_type) => visitor.visit_ty(&mutable_type.ty),
-        TyKind::Rptr(ref lifetime, ref mutable_type) => {
-            visitor.visit_lifetime(lifetime);
-            visitor.visit_ty(&mutable_type.ty)
-        }
-        TyKind::Never => {}
-        TyKind::Tup(tuple_element_types) => {
-            walk_list!(visitor, visit_ty, tuple_element_types);
-        }
-        TyKind::BareFn(ref function_declaration) => {
-            walk_list!(visitor, visit_generic_param, function_declaration.generic_params);
-            visitor.visit_fn_decl(&function_declaration.decl);
-        }
-        TyKind::Path(ref qpath) => {
-            visitor.visit_qpath(qpath, typ.hir_id, typ.span);
-        }
-        TyKind::OpaqueDef(item_id, lifetimes, _in_trait) => {
-            visitor.visit_nested_item(item_id);
-            walk_list!(visitor, visit_generic_arg, lifetimes);
-        }
-        TyKind::Array(ref ty, ref length) => {
-            visitor.visit_ty(ty);
-            visitor.visit_array_length(length)
-        }
-        TyKind::TraitObject(bounds, ref lifetime, _syntax) => {
-            for bound in bounds {
-                visitor.visit_poly_trait_ref(bound);
-            }
-            visitor.visit_lifetime(lifetime);
-        }
-        TyKind::Typeof(ref expression) => visitor.visit_anon_const(expression),
-        TyKind::Infer | TyKind::Err => {}
-    }
-}
-
-pub fn walk_inf<'v, V: Visitor<'v>>(visitor: &mut V, inf: &'v InferArg) {
-    visitor.visit_id(inf.hir_id);
-}
-
-pub fn walk_qpath<'v, V: Visitor<'v>>(visitor: &mut V, qpath: &'v QPath<'v>, id: HirId) {
-    match *qpath {
-        QPath::Resolved(ref maybe_qself, ref path) => {
-            walk_list!(visitor, visit_ty, maybe_qself);
-            visitor.visit_path(path, id)
-        }
-        QPath::TypeRelative(ref qself, ref segment) => {
-            visitor.visit_ty(qself);
-            visitor.visit_path_segment(segment);
-        }
-        QPath::LangItem(..) => {}
-    }
-}
-
-pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path<'v>) {
-    for segment in path.segments {
-        visitor.visit_path_segment(segment);
-    }
-}
-
-pub fn walk_path_segment<'v, V: Visitor<'v>>(visitor: &mut V, segment: &'v PathSegment<'v>) {
-    visitor.visit_ident(segment.ident);
-    visitor.visit_id(segment.hir_id);
-    if let Some(ref args) = segment.args {
-        visitor.visit_generic_args(args);
-    }
-}
-
-pub fn walk_generic_args<'v, V: Visitor<'v>>(visitor: &mut V, generic_args: &'v GenericArgs<'v>) {
-    walk_list!(visitor, visit_generic_arg, generic_args.args);
-    walk_list!(visitor, visit_assoc_type_binding, generic_args.bindings);
-}
-
-pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(
-    visitor: &mut V,
-    type_binding: &'v TypeBinding<'v>,
-) {
-    visitor.visit_id(type_binding.hir_id);
-    visitor.visit_ident(type_binding.ident);
-    visitor.visit_generic_args(type_binding.gen_args);
-    match type_binding.kind {
-        TypeBindingKind::Equality { ref term } => match term {
-            Term::Ty(ref ty) => visitor.visit_ty(ty),
-            Term::Const(ref c) => visitor.visit_anon_const(c),
-        },
-        TypeBindingKind::Constraint { bounds } => walk_list!(visitor, visit_param_bound, bounds),
-    }
+    visitor.visit_expr(&arm.body);
 }
 
 pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) {
@@ -788,257 +660,6 @@ pub fn walk_pat_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v PatField<'
     visitor.visit_pat(&field.pat)
 }
 
-pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v ForeignItem<'v>) {
-    visitor.visit_id(foreign_item.hir_id());
-    visitor.visit_ident(foreign_item.ident);
-
-    match foreign_item.kind {
-        ForeignItemKind::Fn(ref function_declaration, param_names, ref generics) => {
-            visitor.visit_generics(generics);
-            visitor.visit_fn_decl(function_declaration);
-            for ¶m_name in param_names {
-                visitor.visit_ident(param_name);
-            }
-        }
-        ForeignItemKind::Static(ref typ, _) => visitor.visit_ty(typ),
-        ForeignItemKind::Type => (),
-    }
-}
-
-pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v GenericBound<'v>) {
-    match *bound {
-        GenericBound::Trait(ref typ, _modifier) => {
-            visitor.visit_poly_trait_ref(typ);
-        }
-        GenericBound::LangItemTrait(_, _span, hir_id, args) => {
-            visitor.visit_id(hir_id);
-            visitor.visit_generic_args(args);
-        }
-        GenericBound::Outlives(ref lifetime) => visitor.visit_lifetime(lifetime),
-    }
-}
-
-pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v GenericParam<'v>) {
-    visitor.visit_id(param.hir_id);
-    match param.name {
-        ParamName::Plain(ident) => visitor.visit_ident(ident),
-        ParamName::Error | ParamName::Fresh => {}
-    }
-    match param.kind {
-        GenericParamKind::Lifetime { .. } => {}
-        GenericParamKind::Type { ref default, .. } => walk_list!(visitor, visit_ty, default),
-        GenericParamKind::Const { ref ty, ref default } => {
-            visitor.visit_ty(ty);
-            if let Some(ref default) = default {
-                visitor.visit_const_param_default(param.hir_id, default);
-            }
-        }
-    }
-}
-
-pub fn walk_const_param_default<'v, V: Visitor<'v>>(visitor: &mut V, ct: &'v AnonConst) {
-    visitor.visit_anon_const(ct)
-}
-
-pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics<'v>) {
-    walk_list!(visitor, visit_generic_param, generics.params);
-    walk_list!(visitor, visit_where_predicate, generics.predicates);
-}
-
-pub fn walk_where_predicate<'v, V: Visitor<'v>>(
-    visitor: &mut V,
-    predicate: &'v WherePredicate<'v>,
-) {
-    match *predicate {
-        WherePredicate::BoundPredicate(WhereBoundPredicate {
-            hir_id,
-            ref bounded_ty,
-            bounds,
-            bound_generic_params,
-            origin: _,
-            span: _,
-        }) => {
-            visitor.visit_id(hir_id);
-            visitor.visit_ty(bounded_ty);
-            walk_list!(visitor, visit_param_bound, bounds);
-            walk_list!(visitor, visit_generic_param, bound_generic_params);
-        }
-        WherePredicate::RegionPredicate(WhereRegionPredicate {
-            ref lifetime,
-            bounds,
-            span: _,
-            in_where_clause: _,
-        }) => {
-            visitor.visit_lifetime(lifetime);
-            walk_list!(visitor, visit_param_bound, bounds);
-        }
-        WherePredicate::EqPredicate(WhereEqPredicate { ref lhs_ty, ref rhs_ty, span: _ }) => {
-            visitor.visit_ty(lhs_ty);
-            visitor.visit_ty(rhs_ty);
-        }
-    }
-}
-
-pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FnRetTy<'v>) {
-    if let FnRetTy::Return(ref output_ty) = *ret_ty {
-        visitor.visit_ty(output_ty)
-    }
-}
-
-pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &'v FnDecl<'v>) {
-    for ty in function_declaration.inputs {
-        visitor.visit_ty(ty)
-    }
-    walk_fn_ret_ty(visitor, &function_declaration.output)
-}
-
-pub fn walk_fn_kind<'v, V: Visitor<'v>>(visitor: &mut V, function_kind: FnKind<'v>) {
-    match function_kind {
-        FnKind::ItemFn(_, generics, ..) => {
-            visitor.visit_generics(generics);
-        }
-        FnKind::Closure | FnKind::Method(..) => {}
-    }
-}
-
-pub fn walk_fn<'v, V: Visitor<'v>>(
-    visitor: &mut V,
-    function_kind: FnKind<'v>,
-    function_declaration: &'v FnDecl<'v>,
-    body_id: BodyId,
-    id: HirId,
-) {
-    visitor.visit_id(id);
-    visitor.visit_fn_decl(function_declaration);
-    walk_fn_kind(visitor, function_kind);
-    visitor.visit_nested_body(body_id)
-}
-
-pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v TraitItem<'v>) {
-    // N.B., deliberately force a compilation error if/when new fields are added.
-    let TraitItem { ident, generics, ref defaultness, ref kind, span, owner_id: _ } = *trait_item;
-    let hir_id = trait_item.hir_id();
-    visitor.visit_ident(ident);
-    visitor.visit_generics(&generics);
-    visitor.visit_defaultness(&defaultness);
-    match *kind {
-        TraitItemKind::Const(ref ty, default) => {
-            visitor.visit_id(hir_id);
-            visitor.visit_ty(ty);
-            walk_list!(visitor, visit_nested_body, default);
-        }
-        TraitItemKind::Fn(ref sig, TraitFn::Required(param_names)) => {
-            visitor.visit_id(hir_id);
-            visitor.visit_fn_decl(&sig.decl);
-            for ¶m_name in param_names {
-                visitor.visit_ident(param_name);
-            }
-        }
-        TraitItemKind::Fn(ref sig, TraitFn::Provided(body_id)) => {
-            visitor.visit_fn(FnKind::Method(ident, sig), &sig.decl, body_id, span, hir_id);
-        }
-        TraitItemKind::Type(bounds, ref default) => {
-            visitor.visit_id(hir_id);
-            walk_list!(visitor, visit_param_bound, bounds);
-            walk_list!(visitor, visit_ty, default);
-        }
-    }
-}
-
-pub fn walk_trait_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_item_ref: &'v TraitItemRef) {
-    // N.B., deliberately force a compilation error if/when new fields are added.
-    let TraitItemRef { id, ident, ref kind, span: _ } = *trait_item_ref;
-    visitor.visit_nested_trait_item(id);
-    visitor.visit_ident(ident);
-    visitor.visit_associated_item_kind(kind);
-}
-
-pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplItem<'v>) {
-    // N.B., deliberately force a compilation error if/when new fields are added.
-    let ImplItem {
-        owner_id: _,
-        ident,
-        ref generics,
-        ref kind,
-        ref defaultness,
-        span: _,
-        vis_span: _,
-    } = *impl_item;
-
-    visitor.visit_ident(ident);
-    visitor.visit_generics(generics);
-    visitor.visit_defaultness(defaultness);
-    match *kind {
-        ImplItemKind::Const(ref ty, body) => {
-            visitor.visit_id(impl_item.hir_id());
-            visitor.visit_ty(ty);
-            visitor.visit_nested_body(body);
-        }
-        ImplItemKind::Fn(ref sig, body_id) => {
-            visitor.visit_fn(
-                FnKind::Method(impl_item.ident, sig),
-                &sig.decl,
-                body_id,
-                impl_item.span,
-                impl_item.hir_id(),
-            );
-        }
-        ImplItemKind::Type(ref ty) => {
-            visitor.visit_id(impl_item.hir_id());
-            visitor.visit_ty(ty);
-        }
-    }
-}
-
-pub fn walk_foreign_item_ref<'v, V: Visitor<'v>>(
-    visitor: &mut V,
-    foreign_item_ref: &'v ForeignItemRef,
-) {
-    // N.B., deliberately force a compilation error if/when new fields are added.
-    let ForeignItemRef { id, ident, span: _ } = *foreign_item_ref;
-    visitor.visit_nested_foreign_item(id);
-    visitor.visit_ident(ident);
-}
-
-pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'v ImplItemRef) {
-    // N.B., deliberately force a compilation error if/when new fields are added.
-    let ImplItemRef { id, ident, ref kind, span: _, trait_item_def_id: _ } = *impl_item_ref;
-    visitor.visit_nested_impl_item(id);
-    visitor.visit_ident(ident);
-    visitor.visit_associated_item_kind(kind);
-}
-
-pub fn walk_struct_def<'v, V: Visitor<'v>>(
-    visitor: &mut V,
-    struct_definition: &'v VariantData<'v>,
-) {
-    walk_list!(visitor, visit_id, struct_definition.ctor_hir_id());
-    walk_list!(visitor, visit_field_def, struct_definition.fields());
-}
-
-pub fn walk_field_def<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v FieldDef<'v>) {
-    visitor.visit_id(field.hir_id);
-    visitor.visit_ident(field.ident);
-    visitor.visit_ty(&field.ty);
-}
-
-pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block<'v>) {
-    visitor.visit_id(block.hir_id);
-    walk_list!(visitor, visit_stmt, block.stmts);
-    walk_list!(visitor, visit_expr, &block.expr);
-}
-
-pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt<'v>) {
-    visitor.visit_id(statement.hir_id);
-    match statement.kind {
-        StmtKind::Local(ref local) => visitor.visit_local(local),
-        StmtKind::Item(item) => visitor.visit_nested_item(item),
-        StmtKind::Expr(ref expression) | StmtKind::Semi(ref expression) => {
-            visitor.visit_expr(expression)
-        }
-    }
-}
-
 pub fn walk_array_len<'v, V: Visitor<'v>>(visitor: &mut V, len: &'v ArrayLen) {
     match len {
         &ArrayLen::Infer(hir_id, _span) => visitor.visit_id(hir_id),
@@ -1051,20 +672,6 @@ pub fn walk_anon_const<'v, V: Visitor<'v>>(visitor: &mut V, constant: &'v AnonCo
     visitor.visit_nested_body(constant.body);
 }
 
-pub fn walk_let_expr<'v, V: Visitor<'v>>(visitor: &mut V, let_expr: &'v Let<'v>) {
-    // match the visit order in walk_local
-    visitor.visit_expr(let_expr.init);
-    visitor.visit_id(let_expr.hir_id);
-    visitor.visit_pat(let_expr.pat);
-    walk_list!(visitor, visit_ty, let_expr.ty);
-}
-
-pub fn walk_expr_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v ExprField<'v>) {
-    visitor.visit_id(field.hir_id);
-    visitor.visit_ident(field.ident);
-    visitor.visit_expr(&field.expr)
-}
-
 pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) {
     visitor.visit_id(expression.hir_id);
     match expression.kind {
@@ -1177,18 +784,387 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
     }
 }
 
-pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm<'v>) {
-    visitor.visit_id(arm.hir_id);
-    visitor.visit_pat(&arm.pat);
-    if let Some(ref g) = arm.guard {
-        match g {
-            Guard::If(ref e) => visitor.visit_expr(e),
-            Guard::IfLet(ref l) => {
-                visitor.visit_let_expr(l);
+pub fn walk_let_expr<'v, V: Visitor<'v>>(visitor: &mut V, let_expr: &'v Let<'v>) {
+    // match the visit order in walk_local
+    visitor.visit_expr(let_expr.init);
+    visitor.visit_id(let_expr.hir_id);
+    visitor.visit_pat(let_expr.pat);
+    walk_list!(visitor, visit_ty, let_expr.ty);
+}
+
+pub fn walk_expr_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v ExprField<'v>) {
+    visitor.visit_id(field.hir_id);
+    visitor.visit_ident(field.ident);
+    visitor.visit_expr(&field.expr)
+}
+
+pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) {
+    visitor.visit_id(typ.hir_id);
+
+    match typ.kind {
+        TyKind::Slice(ref ty) => visitor.visit_ty(ty),
+        TyKind::Ptr(ref mutable_type) => visitor.visit_ty(&mutable_type.ty),
+        TyKind::Rptr(ref lifetime, ref mutable_type) => {
+            visitor.visit_lifetime(lifetime);
+            visitor.visit_ty(&mutable_type.ty)
+        }
+        TyKind::Never => {}
+        TyKind::Tup(tuple_element_types) => {
+            walk_list!(visitor, visit_ty, tuple_element_types);
+        }
+        TyKind::BareFn(ref function_declaration) => {
+            walk_list!(visitor, visit_generic_param, function_declaration.generic_params);
+            visitor.visit_fn_decl(&function_declaration.decl);
+        }
+        TyKind::Path(ref qpath) => {
+            visitor.visit_qpath(qpath, typ.hir_id, typ.span);
+        }
+        TyKind::OpaqueDef(item_id, lifetimes, _in_trait) => {
+            visitor.visit_nested_item(item_id);
+            walk_list!(visitor, visit_generic_arg, lifetimes);
+        }
+        TyKind::Array(ref ty, ref length) => {
+            visitor.visit_ty(ty);
+            visitor.visit_array_length(length)
+        }
+        TyKind::TraitObject(bounds, ref lifetime, _syntax) => {
+            for bound in bounds {
+                visitor.visit_poly_trait_ref(bound);
+            }
+            visitor.visit_lifetime(lifetime);
+        }
+        TyKind::Typeof(ref expression) => visitor.visit_anon_const(expression),
+        TyKind::Infer | TyKind::Err => {}
+    }
+}
+
+pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v GenericParam<'v>) {
+    visitor.visit_id(param.hir_id);
+    match param.name {
+        ParamName::Plain(ident) => visitor.visit_ident(ident),
+        ParamName::Error | ParamName::Fresh => {}
+    }
+    match param.kind {
+        GenericParamKind::Lifetime { .. } => {}
+        GenericParamKind::Type { ref default, .. } => walk_list!(visitor, visit_ty, default),
+        GenericParamKind::Const { ref ty, ref default } => {
+            visitor.visit_ty(ty);
+            if let Some(ref default) = default {
+                visitor.visit_const_param_default(param.hir_id, default);
             }
         }
     }
-    visitor.visit_expr(&arm.body);
+}
+
+pub fn walk_const_param_default<'v, V: Visitor<'v>>(visitor: &mut V, ct: &'v AnonConst) {
+    visitor.visit_anon_const(ct)
+}
+
+pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics<'v>) {
+    walk_list!(visitor, visit_generic_param, generics.params);
+    walk_list!(visitor, visit_where_predicate, generics.predicates);
+}
+
+pub fn walk_where_predicate<'v, V: Visitor<'v>>(
+    visitor: &mut V,
+    predicate: &'v WherePredicate<'v>,
+) {
+    match *predicate {
+        WherePredicate::BoundPredicate(WhereBoundPredicate {
+            hir_id,
+            ref bounded_ty,
+            bounds,
+            bound_generic_params,
+            origin: _,
+            span: _,
+        }) => {
+            visitor.visit_id(hir_id);
+            visitor.visit_ty(bounded_ty);
+            walk_list!(visitor, visit_param_bound, bounds);
+            walk_list!(visitor, visit_generic_param, bound_generic_params);
+        }
+        WherePredicate::RegionPredicate(WhereRegionPredicate {
+            ref lifetime,
+            bounds,
+            span: _,
+            in_where_clause: _,
+        }) => {
+            visitor.visit_lifetime(lifetime);
+            walk_list!(visitor, visit_param_bound, bounds);
+        }
+        WherePredicate::EqPredicate(WhereEqPredicate { ref lhs_ty, ref rhs_ty, span: _ }) => {
+            visitor.visit_ty(lhs_ty);
+            visitor.visit_ty(rhs_ty);
+        }
+    }
+}
+
+pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &'v FnDecl<'v>) {
+    for ty in function_declaration.inputs {
+        visitor.visit_ty(ty)
+    }
+    walk_fn_ret_ty(visitor, &function_declaration.output)
+}
+
+pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FnRetTy<'v>) {
+    if let FnRetTy::Return(ref output_ty) = *ret_ty {
+        visitor.visit_ty(output_ty)
+    }
+}
+
+pub fn walk_fn<'v, V: Visitor<'v>>(
+    visitor: &mut V,
+    function_kind: FnKind<'v>,
+    function_declaration: &'v FnDecl<'v>,
+    body_id: BodyId,
+    id: HirId,
+) {
+    visitor.visit_id(id);
+    visitor.visit_fn_decl(function_declaration);
+    walk_fn_kind(visitor, function_kind);
+    visitor.visit_nested_body(body_id)
+}
+
+pub fn walk_fn_kind<'v, V: Visitor<'v>>(visitor: &mut V, function_kind: FnKind<'v>) {
+    match function_kind {
+        FnKind::ItemFn(_, generics, ..) => {
+            visitor.visit_generics(generics);
+        }
+        FnKind::Closure | FnKind::Method(..) => {}
+    }
+}
+
+pub fn walk_use<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path<'v>, hir_id: HirId) {
+    visitor.visit_id(hir_id);
+    visitor.visit_path(path, hir_id);
+}
+
+pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v TraitItem<'v>) {
+    // N.B., deliberately force a compilation error if/when new fields are added.
+    let TraitItem { ident, generics, ref defaultness, ref kind, span, owner_id: _ } = *trait_item;
+    let hir_id = trait_item.hir_id();
+    visitor.visit_ident(ident);
+    visitor.visit_generics(&generics);
+    visitor.visit_defaultness(&defaultness);
+    match *kind {
+        TraitItemKind::Const(ref ty, default) => {
+            visitor.visit_id(hir_id);
+            visitor.visit_ty(ty);
+            walk_list!(visitor, visit_nested_body, default);
+        }
+        TraitItemKind::Fn(ref sig, TraitFn::Required(param_names)) => {
+            visitor.visit_id(hir_id);
+            visitor.visit_fn_decl(&sig.decl);
+            for ¶m_name in param_names {
+                visitor.visit_ident(param_name);
+            }
+        }
+        TraitItemKind::Fn(ref sig, TraitFn::Provided(body_id)) => {
+            visitor.visit_fn(FnKind::Method(ident, sig), &sig.decl, body_id, span, hir_id);
+        }
+        TraitItemKind::Type(bounds, ref default) => {
+            visitor.visit_id(hir_id);
+            walk_list!(visitor, visit_param_bound, bounds);
+            walk_list!(visitor, visit_ty, default);
+        }
+    }
+}
+
+pub fn walk_trait_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_item_ref: &'v TraitItemRef) {
+    // N.B., deliberately force a compilation error if/when new fields are added.
+    let TraitItemRef { id, ident, ref kind, span: _ } = *trait_item_ref;
+    visitor.visit_nested_trait_item(id);
+    visitor.visit_ident(ident);
+    visitor.visit_associated_item_kind(kind);
+}
+
+pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplItem<'v>) {
+    // N.B., deliberately force a compilation error if/when new fields are added.
+    let ImplItem {
+        owner_id: _,
+        ident,
+        ref generics,
+        ref kind,
+        ref defaultness,
+        span: _,
+        vis_span: _,
+    } = *impl_item;
+
+    visitor.visit_ident(ident);
+    visitor.visit_generics(generics);
+    visitor.visit_defaultness(defaultness);
+    match *kind {
+        ImplItemKind::Const(ref ty, body) => {
+            visitor.visit_id(impl_item.hir_id());
+            visitor.visit_ty(ty);
+            visitor.visit_nested_body(body);
+        }
+        ImplItemKind::Fn(ref sig, body_id) => {
+            visitor.visit_fn(
+                FnKind::Method(impl_item.ident, sig),
+                &sig.decl,
+                body_id,
+                impl_item.span,
+                impl_item.hir_id(),
+            );
+        }
+        ImplItemKind::Type(ref ty) => {
+            visitor.visit_id(impl_item.hir_id());
+            visitor.visit_ty(ty);
+        }
+    }
+}
+
+pub fn walk_foreign_item_ref<'v, V: Visitor<'v>>(
+    visitor: &mut V,
+    foreign_item_ref: &'v ForeignItemRef,
+) {
+    // N.B., deliberately force a compilation error if/when new fields are added.
+    let ForeignItemRef { id, ident, span: _ } = *foreign_item_ref;
+    visitor.visit_nested_foreign_item(id);
+    visitor.visit_ident(ident);
+}
+
+pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'v ImplItemRef) {
+    // N.B., deliberately force a compilation error if/when new fields are added.
+    let ImplItemRef { id, ident, ref kind, span: _, trait_item_def_id: _ } = *impl_item_ref;
+    visitor.visit_nested_impl_item(id);
+    visitor.visit_ident(ident);
+    visitor.visit_associated_item_kind(kind);
+}
+
+pub fn walk_trait_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_ref: &'v TraitRef<'v>) {
+    visitor.visit_id(trait_ref.hir_ref_id);
+    visitor.visit_path(&trait_ref.path, trait_ref.hir_ref_id)
+}
+
+pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v GenericBound<'v>) {
+    match *bound {
+        GenericBound::Trait(ref typ, _modifier) => {
+            visitor.visit_poly_trait_ref(typ);
+        }
+        GenericBound::LangItemTrait(_, _span, hir_id, args) => {
+            visitor.visit_id(hir_id);
+            visitor.visit_generic_args(args);
+        }
+        GenericBound::Outlives(ref lifetime) => visitor.visit_lifetime(lifetime),
+    }
+}
+
+pub fn walk_poly_trait_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_ref: &'v PolyTraitRef<'v>) {
+    walk_list!(visitor, visit_generic_param, trait_ref.bound_generic_params);
+    visitor.visit_trait_ref(&trait_ref.trait_ref);
+}
+
+pub fn walk_struct_def<'v, V: Visitor<'v>>(
+    visitor: &mut V,
+    struct_definition: &'v VariantData<'v>,
+) {
+    walk_list!(visitor, visit_id, struct_definition.ctor_hir_id());
+    walk_list!(visitor, visit_field_def, struct_definition.fields());
+}
+
+pub fn walk_field_def<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v FieldDef<'v>) {
+    visitor.visit_id(field.hir_id);
+    visitor.visit_ident(field.ident);
+    visitor.visit_ty(&field.ty);
+}
+
+pub fn walk_enum_def<'v, V: Visitor<'v>>(
+    visitor: &mut V,
+    enum_definition: &'v EnumDef<'v>,
+    item_id: HirId,
+) {
+    visitor.visit_id(item_id);
+    walk_list!(visitor, visit_variant, enum_definition.variants);
+}
+
+pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V, variant: &'v Variant<'v>) {
+    visitor.visit_ident(variant.ident);
+    visitor.visit_id(variant.id);
+    visitor.visit_variant_data(&variant.data);
+    walk_list!(visitor, visit_anon_const, &variant.disr_expr);
+}
+
+pub fn walk_label<'v, V: Visitor<'v>>(visitor: &mut V, label: &'v Label) {
+    visitor.visit_ident(label.ident);
+}
+
+pub fn walk_inf<'v, V: Visitor<'v>>(visitor: &mut V, inf: &'v InferArg) {
+    visitor.visit_id(inf.hir_id);
+}
+
+pub fn walk_generic_arg<'v, V: Visitor<'v>>(visitor: &mut V, generic_arg: &'v GenericArg<'v>) {
+    match generic_arg {
+        GenericArg::Lifetime(lt) => visitor.visit_lifetime(lt),
+        GenericArg::Type(ty) => visitor.visit_ty(ty),
+        GenericArg::Const(ct) => visitor.visit_anon_const(&ct.value),
+        GenericArg::Infer(inf) => visitor.visit_infer(inf),
+    }
+}
+
+pub fn walk_lifetime<'v, V: Visitor<'v>>(visitor: &mut V, lifetime: &'v Lifetime) {
+    visitor.visit_id(lifetime.hir_id);
+    match lifetime.name {
+        LifetimeName::Param(_, ParamName::Plain(ident)) => {
+            visitor.visit_ident(ident);
+        }
+        LifetimeName::Param(_, ParamName::Fresh)
+        | LifetimeName::Param(_, ParamName::Error)
+        | LifetimeName::Static
+        | LifetimeName::Error
+        | LifetimeName::ImplicitObjectLifetimeDefault
+        | LifetimeName::Infer => {}
+    }
+}
+
+pub fn walk_qpath<'v, V: Visitor<'v>>(visitor: &mut V, qpath: &'v QPath<'v>, id: HirId) {
+    match *qpath {
+        QPath::Resolved(ref maybe_qself, ref path) => {
+            walk_list!(visitor, visit_ty, maybe_qself);
+            visitor.visit_path(path, id)
+        }
+        QPath::TypeRelative(ref qself, ref segment) => {
+            visitor.visit_ty(qself);
+            visitor.visit_path_segment(segment);
+        }
+        QPath::LangItem(..) => {}
+    }
+}
+
+pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path<'v>) {
+    for segment in path.segments {
+        visitor.visit_path_segment(segment);
+    }
+}
+
+pub fn walk_path_segment<'v, V: Visitor<'v>>(visitor: &mut V, segment: &'v PathSegment<'v>) {
+    visitor.visit_ident(segment.ident);
+    visitor.visit_id(segment.hir_id);
+    if let Some(ref args) = segment.args {
+        visitor.visit_generic_args(args);
+    }
+}
+
+pub fn walk_generic_args<'v, V: Visitor<'v>>(visitor: &mut V, generic_args: &'v GenericArgs<'v>) {
+    walk_list!(visitor, visit_generic_arg, generic_args.args);
+    walk_list!(visitor, visit_assoc_type_binding, generic_args.bindings);
+}
+
+pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(
+    visitor: &mut V,
+    type_binding: &'v TypeBinding<'v>,
+) {
+    visitor.visit_id(type_binding.hir_id);
+    visitor.visit_ident(type_binding.ident);
+    visitor.visit_generic_args(type_binding.gen_args);
+    match type_binding.kind {
+        TypeBindingKind::Equality { ref term } => match term {
+            Term::Ty(ref ty) => visitor.visit_ty(ty),
+            Term::Const(ref c) => visitor.visit_anon_const(c),
+        },
+        TypeBindingKind::Constraint { bounds } => walk_list!(visitor, visit_param_bound, bounds),
+    }
 }
 
 pub fn walk_associated_item_kind<'v, V: Visitor<'v>>(_: &mut V, _: &'v AssocItemKind) {
@@ -1202,3 +1178,27 @@ pub fn walk_defaultness<'v, V: Visitor<'v>>(_: &mut V, _: &'v Defaultness) {
     // the right thing to do, should content be added in the future,
     // would be to walk it.
 }
+
+pub fn walk_inline_asm<'v, V: Visitor<'v>>(visitor: &mut V, asm: &'v InlineAsm<'v>, id: HirId) {
+    for (op, op_sp) in asm.operands {
+        match op {
+            InlineAsmOperand::In { expr, .. } | InlineAsmOperand::InOut { expr, .. } => {
+                visitor.visit_expr(expr)
+            }
+            InlineAsmOperand::Out { expr, .. } => {
+                if let Some(expr) = expr {
+                    visitor.visit_expr(expr);
+                }
+            }
+            InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
+                visitor.visit_expr(in_expr);
+                if let Some(out_expr) = out_expr {
+                    visitor.visit_expr(out_expr);
+                }
+            }
+            InlineAsmOperand::Const { anon_const, .. }
+            | InlineAsmOperand::SymFn { anon_const, .. } => visitor.visit_anon_const(anon_const),
+            InlineAsmOperand::SymStatic { path, .. } => visitor.visit_qpath(path, id, *op_sp),
+        }
+    }
+}

From 82c68cae18b798b6cd1f0d9d31cb7a429fcd55ca Mon Sep 17 00:00:00 2001
From: Michael Howell 
Date: Tue, 1 Nov 2022 16:27:00 -0700
Subject: [PATCH 158/219] rustdoc: simplify mobile item-table CSS

Using flexbox in column direction is needlessly complicated, since no
special flex powers are being used here. Just use regular block layout.

This should result in no visible changes.
---
 src/librustdoc/html/static/css/rustdoc.css | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index 219d1b4ed53..360b6b9832a 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -1870,16 +1870,9 @@ in storage.js
 	}
 
 	/* Display an alternating layout on tablets and phones */
-	.item-table {
+	.item-table, .item-row, .item-left, .item-right {
 		display: block;
 	}
-	.item-row {
-		display: flex;
-		flex-flow: column wrap;
-	}
-	.item-left, .item-right {
-		width: 100%;
-	}
 
 	/* Display an alternating layout on tablets and phones */
 	.search-results > a {

From a9881f52131a2ed745c188ccdecf37a2e2430fe7 Mon Sep 17 00:00:00 2001
From: Michael Goulet 
Date: Wed, 2 Nov 2022 00:48:44 +0000
Subject: [PATCH 159/219] Use ObligationCtxt in fully_normalize

---
 .../rustc_trait_selection/src/traits/mod.rs   | 27 +++++++------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs
index 0bf54c096cd..9ee6e0a2bf3 100644
--- a/compiler/rustc_trait_selection/src/traits/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/mod.rs
@@ -390,6 +390,7 @@ pub fn normalize_param_env_or_error<'tcx>(
 }
 
 /// Normalize a type and process all resulting obligations, returning any errors
+#[instrument(skip_all)]
 pub fn fully_normalize<'tcx, T>(
     infcx: &InferCtxt<'tcx>,
     cause: ObligationCause<'tcx>,
@@ -399,28 +400,18 @@ pub fn fully_normalize<'tcx, T>(
 where
     T: TypeFoldable<'tcx>,
 {
-    debug!("fully_normalize_with_fulfillcx(value={:?})", value);
-    let selcx = &mut SelectionContext::new(infcx);
-    let Normalized { value: normalized_value, obligations } =
-        project::normalize(selcx, param_env, cause, value);
-    debug!(
-        "fully_normalize: normalized_value={:?} obligations={:?}",
-        normalized_value, obligations
-    );
-
-    let mut fulfill_cx = FulfillmentContext::new();
-    for obligation in obligations {
-        fulfill_cx.register_predicate_obligation(infcx, obligation);
-    }
-
-    debug!("fully_normalize: select_all_or_error start");
-    let errors = fulfill_cx.select_all_or_error(infcx);
+    let ocx = ObligationCtxt::new(infcx);
+    debug!(?value);
+    let normalized_value = ocx.normalize(cause, param_env, value);
+    debug!(?normalized_value);
+    debug!("select_all_or_error start");
+    let errors = ocx.select_all_or_error();
     if !errors.is_empty() {
         return Err(errors);
     }
-    debug!("fully_normalize: select_all_or_error complete");
+    debug!("select_all_or_error complete");
     let resolved_value = infcx.resolve_vars_if_possible(normalized_value);
-    debug!("fully_normalize: resolved_value={:?}", resolved_value);
+    debug!(?resolved_value);
     Ok(resolved_value)
 }
 

From 5e016b88017568824b070fb450cea9cd3c794682 Mon Sep 17 00:00:00 2001
From: Michael Goulet 
Date: Wed, 2 Nov 2022 02:02:33 +0000
Subject: [PATCH 160/219] Remove some return-type booleans from FnCtxt

---
 compiler/rustc_hir_typeck/src/_match.rs              |  6 +-----
 compiler/rustc_hir_typeck/src/check.rs               |  5 -----
 compiler/rustc_hir_typeck/src/closure.rs             |  3 ---
 compiler/rustc_hir_typeck/src/coercion.rs            |  3 ++-
 compiler/rustc_hir_typeck/src/expr.rs                |  4 +++-
 compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs         | 11 -----------
 compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs |  8 ++++++++
 compiler/rustc_hir_typeck/src/lib.rs                 |  2 +-
 8 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs
index 2b15d4dcd08..8d39fa81165 100644
--- a/compiler/rustc_hir_typeck/src/_match.rs
+++ b/compiler/rustc_hir_typeck/src/_match.rs
@@ -491,11 +491,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     ..
                 } = self.type_var_origin(expected)? else { return None; };
 
-                let sig = *self
-                    .typeck_results
-                    .borrow()
-                    .liberated_fn_sigs()
-                    .get(hir::HirId::make_owner(self.body_id.owner.def_id))?;
+                let sig = self.body_fn_sig()?;
 
                 let substs = sig.output().walk().find_map(|arg| {
                     if let ty::GenericArgKind::Type(ty) = arg.unpack()
diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs
index b706d786b52..80147d90091 100644
--- a/compiler/rustc_hir_typeck/src/check.rs
+++ b/compiler/rustc_hir_typeck/src/check.rs
@@ -31,13 +31,11 @@ pub(super) fn check_fn<'a, 'tcx>(
     fn_id: hir::HirId,
     body: &'tcx hir::Body<'tcx>,
     can_be_generator: Option,
-    return_type_pre_known: bool,
 ) -> (FnCtxt<'a, 'tcx>, Option>) {
     // Create the function context. This is either derived from scratch or,
     // in the case of closures, based on the outer context.
     let mut fcx = FnCtxt::new(inherited, param_env, body.value.hir_id);
     fcx.ps.set(UnsafetyState::function(fn_sig.unsafety, fn_id));
-    fcx.return_type_pre_known = return_type_pre_known;
 
     let tcx = fcx.tcx;
     let hir = tcx.hir();
@@ -51,9 +49,6 @@ pub(super) fn check_fn<'a, 'tcx>(
             decl.output.span(),
             param_env,
         ));
-    // If we replaced declared_ret_ty with infer vars, then we must be inferring
-    // an opaque type, so set a flag so we can improve diagnostics.
-    fcx.return_type_has_opaque = ret_ty != declared_ret_ty;
 
     fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(ret_ty)));
 
diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs
index a5a45f75e0e..1c2a7dfd994 100644
--- a/compiler/rustc_hir_typeck/src/closure.rs
+++ b/compiler/rustc_hir_typeck/src/closure.rs
@@ -82,8 +82,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
         debug!(?bound_sig, ?liberated_sig);
 
-        let return_type_pre_known = !liberated_sig.output().is_ty_infer();
-
         let generator_types = check_fn(
             self,
             self.param_env.without_const(),
@@ -92,7 +90,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             expr.hir_id,
             body,
             gen,
-            return_type_pre_known,
         )
         .1;
 
diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs
index 86597a703e8..e8bf299b037 100644
--- a/compiler/rustc_hir_typeck/src/coercion.rs
+++ b/compiler/rustc_hir_typeck/src/coercion.rs
@@ -1782,7 +1782,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
             // may occur at the first return expression we see in the closure
             // (if it conflicts with the declared return type). Skip adding a
             // note in this case, since it would be incorrect.
-            && !fcx.return_type_pre_known
+            && let Some(fn_sig) = fcx.body_fn_sig()
+            && fn_sig.output().is_ty_var()
         {
             err.span_note(
                 sp,
diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs
index 9fde62a81a1..14d36d37776 100644
--- a/compiler/rustc_hir_typeck/src/expr.rs
+++ b/compiler/rustc_hir_typeck/src/expr.rs
@@ -840,7 +840,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             return_expr_ty,
         );
 
-        if self.return_type_has_opaque {
+        if let Some(fn_sig) = self.body_fn_sig()
+            && fn_sig.output().has_opaque_types()
+        {
             // Point any obligations that were registered due to opaque type
             // inference at the return expression.
             self.select_obligations_where_possible(false, |errors| {
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
index 0c600daf445..3956db7eebe 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
@@ -118,15 +118,6 @@ pub struct FnCtxt<'a, 'tcx> {
     pub(super) enclosing_breakables: RefCell>,
 
     pub(super) inh: &'a Inherited<'tcx>,
-
-    /// True if the function or closure's return type is known before
-    /// entering the function/closure, i.e. if the return type is
-    /// either given explicitly or inferred from, say, an `Fn*` trait
-    /// bound. Used for diagnostic purposes only.
-    pub(super) return_type_pre_known: bool,
-
-    /// True if the return type has an Opaque type
-    pub(super) return_type_has_opaque: bool,
 }
 
 impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
@@ -151,8 +142,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 by_id: Default::default(),
             }),
             inh,
-            return_type_pre_known: true,
-            return_type_has_opaque: false,
         }
     }
 
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
index 4db9c56f98f..e3b3fb499b1 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
@@ -22,6 +22,14 @@ use rustc_trait_selection::traits::error_reporting::DefIdOrName;
 use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
 
 impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
+    pub(crate) fn body_fn_sig(&self) -> Option> {
+        self.typeck_results
+            .borrow()
+            .liberated_fn_sigs()
+            .get(self.tcx.hir().get_parent_node(self.body_id))
+            .copied()
+    }
+
     pub(in super::super) fn suggest_semicolon_at_end(&self, span: Span, err: &mut Diagnostic) {
         err.span_suggestion_short(
             span.shrink_to_hi(),
diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs
index 959c5486645..d1762598a52 100644
--- a/compiler/rustc_hir_typeck/src/lib.rs
+++ b/compiler/rustc_hir_typeck/src/lib.rs
@@ -250,7 +250,7 @@ fn typeck_with_fallback<'tcx>(
                 param_env,
                 fn_sig,
             );
-            check_fn(&inh, param_env, fn_sig, decl, id, body, None, true).0
+            check_fn(&inh, param_env, fn_sig, decl, id, body, None).0
         } else {
             let fcx = FnCtxt::new(&inh, param_env, body.value.hir_id);
             let expected_type = body_ty

From 41e4218d2a218896d9acde3ab68d7862b56b7f54 Mon Sep 17 00:00:00 2001
From: Michael Goulet 
Date: Wed, 2 Nov 2022 04:09:01 +0000
Subject: [PATCH 161/219] Use TraitEngine less

---
 .../src/diagnostics/conflict_errors.rs        |  9 +---
 .../src/region_infer/opaque_types.rs          | 53 +++++++++----------
 .../src/transform/check_consts/check.rs       | 42 ++++++---------
 compiler/rustc_hir_typeck/src/op.rs           |  6 +--
 .../src/for_loops_over_fallibles.rs           | 11 +---
 .../src/traits/outlives_bounds.rs             | 22 ++++----
 6 files changed, 57 insertions(+), 86 deletions(-)

diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index 583bc2e281d..8987a51757c 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -23,7 +23,6 @@ use rustc_span::hygiene::DesugaringKind;
 use rustc_span::symbol::sym;
 use rustc_span::{BytePos, Span, Symbol};
 use rustc_trait_selection::infer::InferCtxtExt;
-use rustc_trait_selection::traits::TraitEngineExt as _;
 
 use crate::borrow_set::TwoPhaseActivation;
 use crate::borrowck_errors;
@@ -613,24 +612,20 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
         else { return; };
         // Try to find predicates on *generic params* that would allow copying `ty`
         let infcx = tcx.infer_ctxt().build();
-        let mut fulfill_cx = >::new(infcx.tcx);
-
         let copy_did = infcx.tcx.lang_items().copy_trait().unwrap();
         let cause = ObligationCause::new(
             span,
             self.mir_hir_id(),
             rustc_infer::traits::ObligationCauseCode::MiscObligation,
         );
-        fulfill_cx.register_bound(
+        let errors = rustc_trait_selection::traits::fully_solve_bound(
             &infcx,
+            cause,
             self.param_env,
             // Erase any region vids from the type, which may not be resolved
             infcx.tcx.erase_regions(ty),
             copy_did,
-            cause,
         );
-        // Select all, including ambiguous predicates
-        let errors = fulfill_cx.select_all_or_error(&infcx);
 
         // Only emit suggestion if all required predicates are on generic
         let predicates: Result, _> = errors
diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs
index 465f353aaa3..95ea42b584a 100644
--- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs
+++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs
@@ -4,7 +4,7 @@ use rustc_hir::def_id::LocalDefId;
 use rustc_hir::OpaqueTyOrigin;
 use rustc_infer::infer::TyCtxtInferExt as _;
 use rustc_infer::infer::{DefiningAnchor, InferCtxt};
-use rustc_infer::traits::{Obligation, ObligationCause, TraitEngine};
+use rustc_infer::traits::{Obligation, ObligationCause};
 use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts};
 use rustc_middle::ty::visit::TypeVisitable;
 use rustc_middle::ty::{
@@ -12,7 +12,7 @@ use rustc_middle::ty::{
 };
 use rustc_span::Span;
 use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt as _;
-use rustc_trait_selection::traits::TraitEngineExt as _;
+use rustc_trait_selection::traits::ObligationCtxt;
 
 use super::RegionInferenceContext;
 
@@ -252,48 +252,45 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
         // type-alias-impl-trait/issue-67844-nested-opaque.rs
         let infcx =
             self.tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).build();
+        let ocx = ObligationCtxt::new(&infcx);
         // Require the hidden type to be well-formed with only the generics of the opaque type.
         // Defining use functions may have more bounds than the opaque type, which is ok, as long as the
         // hidden type is well formed even without those bounds.
         let predicate = ty::Binder::dummy(ty::PredicateKind::WellFormed(definition_ty.into()))
             .to_predicate(infcx.tcx);
-        let mut fulfillment_cx = >::new(infcx.tcx);
 
         let id_substs = InternalSubsts::identity_for_item(self.tcx, def_id.to_def_id());
 
         // Require that the hidden type actually fulfills all the bounds of the opaque type, even without
         // the bounds that the function supplies.
         let opaque_ty = self.tcx.mk_opaque(def_id.to_def_id(), id_substs);
-        match infcx
-            .at(&ObligationCause::misc(instantiated_ty.span, body_id), param_env)
-            .eq(opaque_ty, definition_ty)
-        {
-            Ok(infer_ok) => {
-                for obligation in infer_ok.obligations {
-                    fulfillment_cx.register_predicate_obligation(&infcx, obligation);
-                }
-            }
-            Err(err) => {
-                infcx
-                    .err_ctxt()
-                    .report_mismatched_types(
-                        &ObligationCause::misc(instantiated_ty.span, body_id),
-                        opaque_ty,
-                        definition_ty,
-                        err,
-                    )
-                    .emit();
-            }
+        if let Err(err) = ocx.eq(
+            &ObligationCause::misc(instantiated_ty.span, body_id),
+            param_env,
+            opaque_ty,
+            definition_ty,
+        ) {
+            infcx
+                .err_ctxt()
+                .report_mismatched_types(
+                    &ObligationCause::misc(instantiated_ty.span, body_id),
+                    opaque_ty,
+                    definition_ty,
+                    err,
+                )
+                .emit();
         }
 
-        fulfillment_cx.register_predicate_obligation(
-            &infcx,
-            Obligation::misc(instantiated_ty.span, body_id, param_env, predicate),
-        );
+        ocx.register_obligation(Obligation::misc(
+            instantiated_ty.span,
+            body_id,
+            param_env,
+            predicate,
+        ));
 
         // Check that all obligations are satisfied by the implementation's
         // version.
-        let errors = fulfillment_cx.select_all_or_error(&infcx);
+        let errors = ocx.select_all_or_error();
 
         // This is still required for many(half of the tests in ui/type-alias-impl-trait)
         // tests to pass
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs
index 22a61774e8c..b1ad22b899e 100644
--- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs
+++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs
@@ -13,11 +13,8 @@ use rustc_middle::ty::{self, adjustment::PointerCast, Instance, InstanceDef, Ty,
 use rustc_middle::ty::{Binder, TraitPredicate, TraitRef, TypeVisitable};
 use rustc_mir_dataflow::{self, Analysis};
 use rustc_span::{sym, Span, Symbol};
-use rustc_trait_selection::infer::InferCtxtExt;
 use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt as _;
-use rustc_trait_selection::traits::{
-    self, ObligationCauseCode, SelectionContext, TraitEngine, TraitEngineExt,
-};
+use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt, SelectionContext};
 
 use std::mem;
 use std::ops::Deref;
@@ -747,35 +744,26 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
                     // "non-const" check. This is required for correctness here.
                     {
                         let infcx = tcx.infer_ctxt().build();
-                        let mut fulfill_cx = >::new(infcx.tcx);
+                        let ocx = ObligationCtxt::new(&infcx);
+
                         let predicates = tcx.predicates_of(callee).instantiate(tcx, substs);
                         let hir_id = tcx
                             .hir()
                             .local_def_id_to_hir_id(self.body.source.def_id().expect_local());
-                        let cause = || {
-                            ObligationCause::new(
-                                terminator.source_info.span,
-                                hir_id,
-                                ObligationCauseCode::ItemObligation(callee),
-                            )
-                        };
-                        let normalized = infcx.partially_normalize_associated_types_in(
-                            cause(),
-                            param_env,
-                            predicates,
+                        let cause = ObligationCause::new(
+                            terminator.source_info.span,
+                            hir_id,
+                            ObligationCauseCode::ItemObligation(callee),
                         );
-
-                        for p in normalized.obligations {
-                            fulfill_cx.register_predicate_obligation(&infcx, p);
-                        }
-                        for obligation in traits::predicates_for_generics(
-                            |_, _| cause(),
+                        let normalized_predicates =
+                            ocx.normalize(cause.clone(), param_env, predicates);
+                        ocx.register_obligations(traits::predicates_for_generics(
+                            |_, _| cause.clone(),
                             self.param_env,
-                            normalized.value,
-                        ) {
-                            fulfill_cx.register_predicate_obligation(&infcx, obligation);
-                        }
-                        let errors = fulfill_cx.select_all_or_error(&infcx);
+                            normalized_predicates,
+                        ));
+
+                        let errors = ocx.select_all_or_error();
                         if !errors.is_empty() {
                             infcx.err_ctxt().report_fulfillment_errors(&errors, None, false);
                         }
diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs
index 89573997693..8598369e884 100644
--- a/compiler/rustc_hir_typeck/src/op.rs
+++ b/compiler/rustc_hir_typeck/src/op.rs
@@ -19,7 +19,7 @@ use rustc_span::symbol::{sym, Ident};
 use rustc_span::Span;
 use rustc_trait_selection::infer::InferCtxtExt;
 use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt as _;
-use rustc_trait_selection::traits::{FulfillmentError, TraitEngine, TraitEngineExt};
+use rustc_trait_selection::traits::FulfillmentError;
 use rustc_type_ir::sty::TyKind::*;
 
 impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
@@ -785,9 +785,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     other_ty_expr,
                     expected,
                 );
-                let mut fulfill = >::new(self.tcx);
-                fulfill.register_predicate_obligation(self, obligation);
-                Err(fulfill.select_where_possible(&self.infcx))
+                Err(rustc_trait_selection::traits::fully_solve_obligation(self, obligation))
             }
         }
     }
diff --git a/compiler/rustc_lint/src/for_loops_over_fallibles.rs b/compiler/rustc_lint/src/for_loops_over_fallibles.rs
index ed8d424e0c6..4187850153c 100644
--- a/compiler/rustc_lint/src/for_loops_over_fallibles.rs
+++ b/compiler/rustc_lint/src/for_loops_over_fallibles.rs
@@ -3,11 +3,9 @@ use crate::{LateContext, LateLintPass, LintContext};
 use hir::{Expr, Pat};
 use rustc_errors::{Applicability, DelayDm};
 use rustc_hir as hir;
-use rustc_infer::traits::TraitEngine;
 use rustc_infer::{infer::TyCtxtInferExt, traits::ObligationCause};
 use rustc_middle::ty::{self, List};
 use rustc_span::{sym, Span};
-use rustc_trait_selection::traits::TraitEngineExt;
 
 declare_lint! {
     /// The `for_loops_over_fallibles` lint checks for `for` loops over `Option` or `Result` values.
@@ -160,24 +158,19 @@ fn suggest_question_mark<'tcx>(
 
     let ty = substs.type_at(0);
     let infcx = cx.tcx.infer_ctxt().build();
-    let mut fulfill_cx = >::new(infcx.tcx);
-
     let cause = ObligationCause::new(
         span,
         body_id.hir_id,
         rustc_infer::traits::ObligationCauseCode::MiscObligation,
     );
-    fulfill_cx.register_bound(
+    let errors = rustc_trait_selection::traits::fully_solve_bound(
         &infcx,
+        cause,
         ty::ParamEnv::empty(),
         // Erase any region vids from the type, which may not be resolved
         infcx.tcx.erase_regions(ty),
         into_iterator_did,
-        cause,
     );
 
-    // Select all, including ambiguous predicates
-    let errors = fulfill_cx.select_all_or_error(&infcx);
-
     errors.is_empty()
 }
diff --git a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs
index 108dae092cf..b1a161c3536 100644
--- a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs
+++ b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs
@@ -1,7 +1,7 @@
 use crate::infer::InferCtxt;
 use crate::traits::query::type_op::{self, TypeOp, TypeOpOutput};
 use crate::traits::query::NoSolution;
-use crate::traits::{ObligationCause, TraitEngine, TraitEngineExt};
+use crate::traits::ObligationCause;
 use rustc_data_structures::fx::FxHashSet;
 use rustc_hir as hir;
 use rustc_hir::HirId;
@@ -74,20 +74,20 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
             debug!(?constraints);
             // Instantiation may have produced new inference variables and constraints on those
             // variables. Process these constraints.
-            let mut fulfill_cx = >::new(self.tcx);
             let cause = ObligationCause::misc(span, body_id);
-            for &constraint in &constraints.outlives {
-                let obligation = self.query_outlives_constraint_to_obligation(
-                    constraint,
-                    cause.clone(),
-                    param_env,
-                );
-                fulfill_cx.register_predicate_obligation(self, obligation);
-            }
+            let errors = super::fully_solve_obligations(
+                self,
+                constraints.outlives.iter().map(|constraint| {
+                    self.query_outlives_constraint_to_obligation(
+                        *constraint,
+                        cause.clone(),
+                        param_env,
+                    )
+                }),
+            );
             if !constraints.member_constraints.is_empty() {
                 span_bug!(span, "{:#?}", constraints.member_constraints);
             }
-            let errors = fulfill_cx.select_all_or_error(self);
             if !errors.is_empty() {
                 self.tcx.sess.delay_span_bug(
                     span,

From b96ad1c0960bd64fde273efe00df3fbc580a9c0a Mon Sep 17 00:00:00 2001
From: Takayuki Maeda 
Date: Wed, 2 Nov 2022 14:47:48 +0900
Subject: [PATCH 162/219] return const_error when ty has errors

---
 .../rustc_hir_analysis/src/astconv/mod.rs     |  3 +
 src/test/ui/consts/issue-103790.rs            | 10 +++
 src/test/ui/consts/issue-103790.stderr        | 65 +++++++++++++++++++
 3 files changed, 78 insertions(+)
 create mode 100644 src/test/ui/consts/issue-103790.rs
 create mode 100644 src/test/ui/consts/issue-103790.stderr

diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs
index 6baf9844977..21e6ab13a59 100644
--- a/compiler/rustc_hir_analysis/src/astconv/mod.rs
+++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs
@@ -501,6 +501,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
                     }
                     GenericParamDefKind::Const { has_default } => {
                         let ty = tcx.at(self.span).type_of(param.def_id);
+                        if ty.references_error() {
+                            return tcx.const_error(ty).into();
+                        }
                         if !infer_args && has_default {
                             tcx.bound_const_param_default(param.def_id)
                                 .subst(tcx, substs.unwrap())
diff --git a/src/test/ui/consts/issue-103790.rs b/src/test/ui/consts/issue-103790.rs
new file mode 100644
index 00000000000..ea3cac605b1
--- /dev/null
+++ b/src/test/ui/consts/issue-103790.rs
@@ -0,0 +1,10 @@
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
+
+struct S;
+//~^ ERROR the name `S` is already used for a generic parameter in this item's generic parameters
+//~| ERROR missing generics for struct `S`
+//~| ERROR cycle detected when computing type of `S::S`
+//~| ERROR cycle detected when computing type of `S`
+
+fn main() {}
diff --git a/src/test/ui/consts/issue-103790.stderr b/src/test/ui/consts/issue-103790.stderr
new file mode 100644
index 00000000000..41b0816dc32
--- /dev/null
+++ b/src/test/ui/consts/issue-103790.stderr
@@ -0,0 +1,65 @@
+error[E0403]: the name `S` is already used for a generic parameter in this item's generic parameters
+  --> $DIR/issue-103790.rs:4:29
+   |
+LL | struct S;
+   |                -            ^ already used
+   |                |
+   |                first use of `S`
+
+error[E0107]: missing generics for struct `S`
+  --> $DIR/issue-103790.rs:4:32
+   |
+LL | struct S;
+   |                                ^ expected at least 1 generic argument
+   |
+note: struct defined here, with at least 1 generic parameter: `S`
+  --> $DIR/issue-103790.rs:4:8
+   |
+LL | struct S;
+   |        ^ -----------
+help: add missing generic argument
+   |
+LL | struct S = { S }>;
+   |                                ~~~~
+
+error[E0391]: cycle detected when computing type of `S::S`
+  --> $DIR/issue-103790.rs:4:32
+   |
+LL | struct S;
+   |                                ^
+   |
+   = note: ...which immediately requires computing type of `S::S` again
+note: cycle used when computing type of `S`
+  --> $DIR/issue-103790.rs:4:1
+   |
+LL | struct S;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0391]: cycle detected when computing type of `S`
+  --> $DIR/issue-103790.rs:4:1
+   |
+LL | struct S;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: ...which requires computing type of `S::S`...
+  --> $DIR/issue-103790.rs:4:32
+   |
+LL | struct S;
+   |                                ^
+   = note: ...which again requires computing type of `S`, completing the cycle
+note: cycle used when collecting item types in top-level module
+  --> $DIR/issue-103790.rs:1:1
+   |
+LL | / #![feature(generic_const_exprs)]
+LL | | #![allow(incomplete_features)]
+LL | |
+LL | | struct S;
+...  |
+LL | |
+LL | | fn main() {}
+   | |____________^
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0107, E0391, E0403.
+For more information about an error, try `rustc --explain E0107`.

From ecea6160525367568e8333ad71d4c1fadbe5f8f7 Mon Sep 17 00:00:00 2001
From: Oli Scherer 
Date: Mon, 31 Oct 2022 16:19:36 +0000
Subject: [PATCH 163/219] Simplify astconv item def id handling

---
 compiler/rustc_hir_analysis/src/astconv/errors.rs | 7 ++-----
 compiler/rustc_hir_analysis/src/astconv/mod.rs    | 9 +++------
 compiler/rustc_hir_analysis/src/collect.rs        | 4 ++--
 compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs      | 4 ++--
 4 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/compiler/rustc_hir_analysis/src/astconv/errors.rs b/compiler/rustc_hir_analysis/src/astconv/errors.rs
index a9152bdc597..e6465d641f1 100644
--- a/compiler/rustc_hir_analysis/src/astconv/errors.rs
+++ b/compiler/rustc_hir_analysis/src/astconv/errors.rs
@@ -177,11 +177,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
             .all_traits()
             .filter(|trait_def_id| {
                 let viz = self.tcx().visibility(*trait_def_id);
-                if let Some(def_id) = self.item_def_id() {
-                    viz.is_accessible_from(def_id, self.tcx())
-                } else {
-                    viz.is_visible_locally()
-                }
+                let def_id = self.item_def_id();
+                viz.is_accessible_from(def_id, self.tcx())
             })
             .collect();
 
diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs
index 39b178f5976..5181754eb1c 100644
--- a/compiler/rustc_hir_analysis/src/astconv/mod.rs
+++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs
@@ -54,7 +54,7 @@ pub struct PathSeg(pub DefId, pub usize);
 pub trait AstConv<'tcx> {
     fn tcx<'a>(&'a self) -> TyCtxt<'tcx>;
 
-    fn item_def_id(&self) -> Option;
+    fn item_def_id(&self) -> DefId;
 
     /// Returns predicates in scope of the form `X: Foo`, where `X`
     /// is a type parameter `X` with the given id `def_id` and T
@@ -2079,17 +2079,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
 
             debug!("qpath_to_ty: self.item_def_id()={:?}", def_id);
 
-            let parent_def_id = def_id
-                .and_then(|def_id| {
-                    def_id.as_local().map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id))
-                })
+            let parent_def_id = def_id.as_local().map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id))
                 .map(|hir_id| tcx.hir().get_parent_item(hir_id).to_def_id());
 
             debug!("qpath_to_ty: parent_def_id={:?}", parent_def_id);
 
             // If the trait in segment is the same as the trait defining the item,
             // use the `` syntax in the error.
-            let is_part_of_self_trait_constraints = def_id == Some(trait_def_id);
+            let is_part_of_self_trait_constraints = def_id == trait_def_id;
             let is_part_of_fn_in_self_trait = parent_def_id == Some(trait_def_id);
 
             let type_name = if is_part_of_self_trait_constraints || is_part_of_fn_in_self_trait {
diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs
index 46db0f74d4d..25faacadf3d 100644
--- a/compiler/rustc_hir_analysis/src/collect.rs
+++ b/compiler/rustc_hir_analysis/src/collect.rs
@@ -379,8 +379,8 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
         self.tcx
     }
 
-    fn item_def_id(&self) -> Option {
-        Some(self.item_def_id)
+    fn item_def_id(&self) -> DefId {
+        self.item_def_id
     }
 
     fn get_type_parameter_bounds(
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
index 0c600daf445..c36c01e1b46 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
@@ -194,8 +194,8 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
         self.tcx
     }
 
-    fn item_def_id(&self) -> Option {
-        None
+    fn item_def_id(&self) -> DefId {
+        self.body_id.owner.to_def_id()
     }
 
     fn get_type_parameter_bounds(

From 7df9d818ab07d1d014ac46a1f462d87a2d57ce21 Mon Sep 17 00:00:00 2001
From: yukang 
Date: Wed, 2 Nov 2022 23:15:49 +0800
Subject: [PATCH 164/219] deprecate DelaySpanBugEmitted and use ErrorGuaranteed
 directly

---
 .../rustc_const_eval/src/interpret/operand.rs     |  4 ++--
 compiler/rustc_middle/src/ty/abstract_const.rs    |  4 ++--
 compiler/rustc_middle/src/ty/consts/kind.rs       |  2 +-
 compiler/rustc_middle/src/ty/context.rs           | 15 +++------------
 compiler/rustc_middle/src/ty/mod.rs               |  2 +-
 compiler/rustc_middle/src/ty/structural_impls.rs  |  1 -
 compiler/rustc_type_ir/src/lib.rs                 |  2 +-
 compiler/rustc_type_ir/src/sty.rs                 | 10 ++++------
 8 files changed, 14 insertions(+), 26 deletions(-)

diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs
index 0c212cf59e1..dd00678aa0c 100644
--- a/compiler/rustc_const_eval/src/interpret/operand.rs
+++ b/compiler/rustc_const_eval/src/interpret/operand.rs
@@ -4,7 +4,7 @@
 use rustc_hir::def::Namespace;
 use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout};
 use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter};
-use rustc_middle::ty::{ConstInt, DelaySpanBugEmitted, Ty};
+use rustc_middle::ty::{ConstInt, Ty};
 use rustc_middle::{mir, ty};
 use rustc_target::abi::{self, Abi, Align, HasDataLayout, Size, TagEncoding};
 use rustc_target::abi::{VariantIdx, Variants};
@@ -567,7 +567,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
                     ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(..) => {
                         throw_inval!(TooGeneric)
                     }
-                    ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => {
+                    ty::ConstKind::Error(reported) => {
                         throw_inval!(AlreadyReported(reported))
                     }
                     ty::ConstKind::Unevaluated(uv) => {
diff --git a/compiler/rustc_middle/src/ty/abstract_const.rs b/compiler/rustc_middle/src/ty/abstract_const.rs
index 1aa4df77800..e5bcd5fb27a 100644
--- a/compiler/rustc_middle/src/ty/abstract_const.rs
+++ b/compiler/rustc_middle/src/ty/abstract_const.rs
@@ -1,7 +1,7 @@
 //! A subset of a mir body used for const evaluatability checking.
 use crate::mir;
 use crate::ty::visit::TypeVisitable;
-use crate::ty::{self, DelaySpanBugEmitted, EarlyBinder, SubstsRef, Ty, TyCtxt};
+use crate::ty::{self, EarlyBinder, SubstsRef, Ty, TyCtxt};
 use rustc_errors::ErrorGuaranteed;
 use rustc_hir::def_id::DefId;
 use std::cmp;
@@ -43,7 +43,7 @@ impl<'tcx> AbstractConst<'tcx> {
     ) -> Result>, ErrorGuaranteed> {
         match ct.kind() {
             ty::ConstKind::Unevaluated(uv) => AbstractConst::new(tcx, uv),
-            ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => Err(reported),
+            ty::ConstKind::Error(reported) => Err(reported),
             _ => Ok(None),
         }
     }
diff --git a/compiler/rustc_middle/src/ty/consts/kind.rs b/compiler/rustc_middle/src/ty/consts/kind.rs
index 4ab761e0715..c1c613f6c60 100644
--- a/compiler/rustc_middle/src/ty/consts/kind.rs
+++ b/compiler/rustc_middle/src/ty/consts/kind.rs
@@ -69,7 +69,7 @@ pub enum ConstKind<'tcx> {
 
     /// A placeholder for a const which could not be computed; this is
     /// propagated to avoid useless error messages.
-    Error(ty::DelaySpanBugEmitted),
+    Error(ErrorGuaranteed),
 }
 
 #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 94e3f3b63c8..eeb53f9714c 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -116,7 +116,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
     type BoundTy = ty::BoundTy;
     type PlaceholderType = ty::PlaceholderType;
     type InferTy = InferTy;
-    type DelaySpanBugEmitted = DelaySpanBugEmitted;
+    type ErrorGuaranteed = ErrorGuaranteed;
     type PredicateKind = ty::PredicateKind<'tcx>;
     type AllocId = crate::mir::interpret::AllocId;
 
@@ -127,15 +127,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
     type PlaceholderRegion = ty::PlaceholderRegion;
 }
 
-/// A type that is not publicly constructable. This prevents people from making [`TyKind::Error`]s
-/// except through the error-reporting functions on a [`tcx`][TyCtxt].
-#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
-#[derive(TyEncodable, TyDecodable, HashStable)]
-pub struct DelaySpanBugEmitted {
-    pub reported: ErrorGuaranteed,
-    _priv: (),
-}
-
 type InternedSet<'tcx, T> = ShardedHashMap, ()>;
 
 pub struct CtxtInterners<'tcx> {
@@ -1302,7 +1293,7 @@ impl<'tcx> TyCtxt<'tcx> {
     #[track_caller]
     pub fn ty_error_with_message>(self, span: S, msg: &str) -> Ty<'tcx> {
         let reported = self.sess.delay_span_bug(span, msg);
-        self.mk_ty(Error(DelaySpanBugEmitted { reported, _priv: () }))
+        self.mk_ty(Error(reported))
     }
 
     /// Like [TyCtxt::ty_error] but for constants.
@@ -1325,7 +1316,7 @@ impl<'tcx> TyCtxt<'tcx> {
     ) -> Const<'tcx> {
         let reported = self.sess.delay_span_bug(span, msg);
         self.mk_const(ty::ConstS {
-            kind: ty::ConstKind::Error(DelaySpanBugEmitted { reported, _priv: () }),
+            kind: ty::ConstKind::Error(reported),
             ty,
         })
     }
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs
index 9671d3a32f9..9267a541a59 100644
--- a/compiler/rustc_middle/src/ty/mod.rs
+++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -80,7 +80,7 @@ pub use self::consts::{
 };
 pub use self::context::{
     tls, CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations,
-    CtxtInterners, DeducedParamAttrs, DelaySpanBugEmitted, FreeRegionInfo, GeneratorDiagnosticData,
+    CtxtInterners, DeducedParamAttrs, FreeRegionInfo, GeneratorDiagnosticData,
     GeneratorInteriorTypeCause, GlobalCtxt, Lift, OnDiskCache, TyCtxt, TypeckResults, UserType,
     UserTypeAnnotationIndex,
 };
diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs
index 2cad333e3f5..23cd93d6af4 100644
--- a/compiler/rustc_middle/src/ty/structural_impls.rs
+++ b/compiler/rustc_middle/src/ty/structural_impls.rs
@@ -240,7 +240,6 @@ TrivialTypeTraversalAndLiftImpls! {
     Field,
     interpret::Scalar,
     rustc_target::abi::Size,
-    ty::DelaySpanBugEmitted,
     rustc_type_ir::DebruijnIndex,
     ty::BoundVar,
     ty::Placeholder,
diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs
index 7fbe78aa523..7c3eb4efbc9 100644
--- a/compiler/rustc_type_ir/src/lib.rs
+++ b/compiler/rustc_type_ir/src/lib.rs
@@ -45,7 +45,7 @@ pub trait Interner {
     type BoundTy: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
     type PlaceholderType: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
     type InferTy: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
-    type DelaySpanBugEmitted: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
+    type ErrorGuaranteed: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
     type PredicateKind: Clone + Debug + Hash + PartialEq + Eq;
     type AllocId: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
 
diff --git a/compiler/rustc_type_ir/src/sty.rs b/compiler/rustc_type_ir/src/sty.rs
index a4fb1480fa4..02cbb2e858f 100644
--- a/compiler/rustc_type_ir/src/sty.rs
+++ b/compiler/rustc_type_ir/src/sty.rs
@@ -217,7 +217,7 @@ pub enum TyKind {
 
     /// A placeholder for a type which could not be computed; this is
     /// propagated to avoid useless error messages.
-    Error(I::DelaySpanBugEmitted),
+    Error(I::ErrorGuaranteed),
 }
 
 impl TyKind {
@@ -626,7 +626,7 @@ impl fmt::Debug for TyKind {
 // This is manually implemented because a derive would require `I: Encodable`
 impl Encodable for TyKind
 where
-    I::DelaySpanBugEmitted: Encodable,
+    I::ErrorGuaranteed: Encodable,
     I::AdtDef: Encodable,
     I::SubstsRef: Encodable,
     I::DefId: Encodable,
@@ -645,7 +645,6 @@ where
     I::BoundTy: Encodable,
     I::PlaceholderType: Encodable,
     I::InferTy: Encodable,
-    I::DelaySpanBugEmitted: Encodable,
     I::PredicateKind: Encodable,
     I::AllocId: Encodable,
 {
@@ -744,7 +743,7 @@ where
 // This is manually implemented because a derive would require `I: Decodable`
 impl> Decodable for TyKind
 where
-    I::DelaySpanBugEmitted: Decodable,
+    I::ErrorGuaranteed: Decodable,
     I::AdtDef: Decodable,
     I::SubstsRef: Decodable,
     I::DefId: Decodable,
@@ -763,7 +762,6 @@ where
     I::BoundTy: Decodable,
     I::PlaceholderType: Decodable,
     I::InferTy: Decodable,
-    I::DelaySpanBugEmitted: Decodable,
     I::PredicateKind: Decodable,
     I::AllocId: Decodable,
 {
@@ -829,7 +827,7 @@ where
     I::ParamTy: HashStable,
     I::PlaceholderType: HashStable,
     I::InferTy: HashStable,
-    I::DelaySpanBugEmitted: HashStable,
+    I::ErrorGuaranteed: HashStable,
 {
     #[inline]
     fn hash_stable(

From 1123852d08ba004c13ec0ac49f6f2b8c3317b508 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez 
Date: Wed, 2 Nov 2022 16:51:37 +0100
Subject: [PATCH 165/219] Fix merge of attributes for reexports of local items

---
 src/librustdoc/clean/mod.rs | 26 +++++++++++++++++++++-----
 src/librustdoc/visit_ast.rs | 29 ++++++++++++++++-------------
 2 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 1ce0d1e4ffd..ad4ad4104e1 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -74,12 +74,12 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
     // This covers the case where somebody does an import which should pull in an item,
     // but there's already an item with the same namespace and same name. Rust gives
     // priority to the not-imported one, so we should, too.
-    items.extend(doc.items.iter().flat_map(|(item, renamed)| {
+    items.extend(doc.items.iter().flat_map(|(item, renamed, import_id)| {
         // First, lower everything other than imports.
         if matches!(item.kind, hir::ItemKind::Use(_, hir::UseKind::Glob)) {
             return Vec::new();
         }
-        let v = clean_maybe_renamed_item(cx, item, *renamed);
+        let v = clean_maybe_renamed_item(cx, item, *renamed, *import_id);
         for item in &v {
             if let Some(name) = item.name && !item.attrs.lists(sym::doc).has_word(sym::hidden) {
                 inserted.insert((item.type_(), name));
@@ -87,7 +87,7 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
         }
         v
     }));
-    items.extend(doc.items.iter().flat_map(|(item, renamed)| {
+    items.extend(doc.items.iter().flat_map(|(item, renamed, _)| {
         // Now we actually lower the imports, skipping everything else.
         if let hir::ItemKind::Use(path, hir::UseKind::Glob) = item.kind {
             let name = renamed.unwrap_or_else(|| cx.tcx.hir().name(item.hir_id()));
@@ -1911,6 +1911,7 @@ fn clean_maybe_renamed_item<'tcx>(
     cx: &mut DocContext<'tcx>,
     item: &hir::Item<'tcx>,
     renamed: Option,
+    import_id: Option,
 ) -> Vec {
     use hir::ItemKind;
 
@@ -1987,8 +1988,23 @@ fn clean_maybe_renamed_item<'tcx>(
             }
             _ => unreachable!("not yet converted"),
         };
-
-        vec![Item::from_def_id_and_parts(def_id, Some(name), kind, cx)]
+        if let Some(import_id) = import_id {
+            let (attrs, cfg) = inline::merge_attrs(
+                cx,
+                Some(cx.tcx.parent_module(import_id).to_def_id()),
+                inline::load_attrs(cx, def_id),
+                Some(inline::load_attrs(cx, cx.tcx.hir().local_def_id(import_id).to_def_id())),
+            );
+            vec![Item::from_def_id_and_attrs_and_parts(
+                def_id,
+                Some(name),
+                kind,
+                Box::new(attrs),
+                cfg,
+            )]
+        } else {
+            vec![Item::from_def_id_and_parts(def_id, Some(name), kind, cx)]
+        }
     })
 }
 
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index 7ee7eb25e0d..c788b9f4093 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -25,8 +25,8 @@ pub(crate) struct Module<'hir> {
     pub(crate) where_inner: Span,
     pub(crate) mods: Vec>,
     pub(crate) id: hir::HirId,
-    // (item, renamed)
-    pub(crate) items: Vec<(&'hir hir::Item<'hir>, Option)>,
+    // (item, renamed, import_id)
+    pub(crate) items: Vec<(&'hir hir::Item<'hir>, Option, Option)>,
     pub(crate) foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option)>,
 }
 
@@ -93,6 +93,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
             hir::CRATE_HIR_ID,
             self.cx.tcx.hir().root_module(),
             self.cx.tcx.crate_name(LOCAL_CRATE),
+            None,
         );
 
         // `#[macro_export] macro_rules!` items are reexported at the top level of the
@@ -113,7 +114,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                     if self.cx.tcx.has_attr(def_id, sym::macro_export) {
                         if inserted.insert(def_id) {
                             let item = self.cx.tcx.hir().expect_item(local_def_id);
-                            top_level_module.items.push((item, None));
+                            top_level_module.items.push((item, None, None));
                         }
                     }
                 }
@@ -155,6 +156,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
         id: hir::HirId,
         m: &'tcx hir::Mod<'tcx>,
         name: Symbol,
+        parent_id: Option,
     ) -> Module<'tcx> {
         let mut om = Module::new(name, id, m.spans.inner_span);
         let def_id = self.cx.tcx.hir().local_def_id(id).to_def_id();
@@ -166,7 +168,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
             if matches!(item.kind, hir::ItemKind::Use(_, hir::UseKind::Glob)) {
                 continue;
             }
-            self.visit_item(item, None, &mut om);
+            self.visit_item(item, None, &mut om, parent_id);
         }
         for &i in m.item_ids {
             let item = self.cx.tcx.hir().item(i);
@@ -174,7 +176,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
             // Later passes in rustdoc will de-duplicate by name and kind, so if glob-
             // imported items appear last, then they'll be the ones that get discarded.
             if matches!(item.kind, hir::ItemKind::Use(_, hir::UseKind::Glob)) {
-                self.visit_item(item, None, &mut om);
+                self.visit_item(item, None, &mut om, parent_id);
             }
         }
         self.inside_public_path = orig_inside_public_path;
@@ -247,14 +249,14 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                 let prev = mem::replace(&mut self.inlining, true);
                 for &i in m.item_ids {
                     let i = self.cx.tcx.hir().item(i);
-                    self.visit_item(i, None, om);
+                    self.visit_item(i, None, om, Some(id));
                 }
                 self.inlining = prev;
                 true
             }
             Node::Item(it) if !glob => {
                 let prev = mem::replace(&mut self.inlining, true);
-                self.visit_item(it, renamed, om);
+                self.visit_item(it, renamed, om, Some(id));
                 self.inlining = prev;
                 true
             }
@@ -275,6 +277,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
         item: &'tcx hir::Item<'_>,
         renamed: Option,
         om: &mut Module<'tcx>,
+        parent_id: Option,
     ) {
         debug!("visiting item {:?}", item);
         let name = renamed.unwrap_or(item.ident.name);
@@ -330,7 +333,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                     }
                 }
 
-                om.items.push((item, renamed))
+                om.items.push((item, renamed, parent_id))
             }
             hir::ItemKind::Macro(ref macro_def, _) => {
                 // `#[macro_export] macro_rules!` items are handled separately in `visit()`,
@@ -349,11 +352,11 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                 let nonexported = !self.cx.tcx.has_attr(def_id, sym::macro_export);
 
                 if is_macro_2_0 || nonexported || self.inlining {
-                    om.items.push((item, renamed));
+                    om.items.push((item, renamed, None));
                 }
             }
             hir::ItemKind::Mod(ref m) => {
-                om.mods.push(self.visit_mod_contents(item.hir_id(), m, name));
+                om.mods.push(self.visit_mod_contents(item.hir_id(), m, name, parent_id));
             }
             hir::ItemKind::Fn(..)
             | hir::ItemKind::ExternCrate(..)
@@ -364,19 +367,19 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
             | hir::ItemKind::OpaqueTy(..)
             | hir::ItemKind::Static(..)
             | hir::ItemKind::Trait(..)
-            | hir::ItemKind::TraitAlias(..) => om.items.push((item, renamed)),
+            | hir::ItemKind::TraitAlias(..) => om.items.push((item, renamed, parent_id)),
             hir::ItemKind::Const(..) => {
                 // Underscore constants do not correspond to a nameable item and
                 // so are never useful in documentation.
                 if name != kw::Underscore {
-                    om.items.push((item, renamed));
+                    om.items.push((item, renamed, parent_id));
                 }
             }
             hir::ItemKind::Impl(impl_) => {
                 // Don't duplicate impls when inlining or if it's implementing a trait, we'll pick
                 // them up regardless of where they're located.
                 if !self.inlining && impl_.of_trait.is_none() {
-                    om.items.push((item, None));
+                    om.items.push((item, None, None));
                 }
             }
         }

From c983bb162c932acc4854c6288104e03280a17983 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez 
Date: Wed, 2 Nov 2022 16:55:55 +0100
Subject: [PATCH 166/219] Add regression test for doc of reexport of local
 items

---
 src/test/rustdoc/local-reexport-doc.rs | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 src/test/rustdoc/local-reexport-doc.rs

diff --git a/src/test/rustdoc/local-reexport-doc.rs b/src/test/rustdoc/local-reexport-doc.rs
new file mode 100644
index 00000000000..1c8468008dd
--- /dev/null
+++ b/src/test/rustdoc/local-reexport-doc.rs
@@ -0,0 +1,16 @@
+// This test ensures that the reexports of local items also get the doc from
+// the reexport.
+
+#![crate_name = "foo"]
+
+// @has 'foo/fn.g.html'
+// @has - '//*[@class="rustdoc-toggle top-doc"]/*[@class="docblock"]' \
+// 'outer module inner module'
+
+mod inner_mod {
+    /// inner module
+    pub fn g() {}
+}
+
+/// outer module
+pub use inner_mod::g;

From 74fec9b95ad308c3dc064bb38778aea4ec51f5ee Mon Sep 17 00:00:00 2001
From: Michael Goulet 
Date: Wed, 2 Nov 2022 02:13:27 +0000
Subject: [PATCH 167/219] Remove has_errors from FnCtxt

---
 compiler/rustc_hir_typeck/src/expr.rs         |  2 --
 .../rustc_hir_typeck/src/fn_ctxt/_impl.rs     |  1 -
 .../rustc_hir_typeck/src/fn_ctxt/checks.rs    |  8 +------
 compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs  |  4 ----
 src/test/ui/error-codes/E0767.rs              |  3 ++-
 src/test/ui/error-codes/E0767.stderr          | 21 +++++++++++++++----
 6 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs
index 9fde62a81a1..47b5673e8b3 100644
--- a/compiler/rustc_hir_typeck/src/expr.rs
+++ b/compiler/rustc_hir_typeck/src/expr.rs
@@ -220,7 +220,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
         // Hide the outer diverging and has_errors flags.
         let old_diverges = self.diverges.replace(Diverges::Maybe);
-        let old_has_errors = self.has_errors.replace(false);
 
         let ty = ensure_sufficient_stack(|| match &expr.kind {
             hir::ExprKind::Path(
@@ -259,7 +258,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
         // Combine the diverging and has_error flags.
         self.diverges.set(self.diverges.get() | old_diverges);
-        self.has_errors.set(self.has_errors.get() | old_has_errors);
 
         debug!("type of {} is...", self.tcx.hir().node_to_string(expr.hir_id));
         debug!("... {:?}, expected is {:?}", ty, expected);
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
index 6a1cffe3e60..38da0a47d71 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
@@ -143,7 +143,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         self.typeck_results.borrow_mut().node_types_mut().insert(id, ty);
 
         if ty.references_error() {
-            self.has_errors.set(true);
             self.set_tainted_by_errors();
         }
     }
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index 8e0fcb56c7f..e1955d838f2 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
@@ -1334,7 +1334,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
         // Hide the outer diverging and `has_errors` flags.
         let old_diverges = self.diverges.replace(Diverges::Maybe);
-        let old_has_errors = self.has_errors.replace(false);
 
         match stmt.kind {
             hir::StmtKind::Local(l) => {
@@ -1364,7 +1363,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
         // Combine the diverging and `has_error` flags.
         self.diverges.set(self.diverges.get() | old_diverges);
-        self.has_errors.set(self.has_errors.get() | old_has_errors);
     }
 
     pub fn check_block_no_value(&self, blk: &'tcx hir::Block<'tcx>) {
@@ -1544,11 +1542,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             self.diverges.set(prev_diverges);
         }
 
-        let mut ty = ctxt.coerce.unwrap().complete(self);
-
-        if self.has_errors.get() || ty.references_error() {
-            ty = self.tcx.ty_error()
-        }
+        let ty = ctxt.coerce.unwrap().complete(self);
 
         self.write_ty(blk.hir_id, ty);
 
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
index 0c600daf445..19839ad4d4c 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
@@ -112,9 +112,6 @@ pub struct FnCtxt<'a, 'tcx> {
     /// the diverges flag is set to something other than `Maybe`.
     pub(super) diverges: Cell,
 
-    /// Whether any child nodes have any type errors.
-    pub(super) has_errors: Cell,
-
     pub(super) enclosing_breakables: RefCell>,
 
     pub(super) inh: &'a Inherited<'tcx>,
@@ -145,7 +142,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             resume_yield_tys: None,
             ps: Cell::new(UnsafetyState::function(hir::Unsafety::Normal, hir::CRATE_HIR_ID)),
             diverges: Cell::new(Diverges::Maybe),
-            has_errors: Cell::new(false),
             enclosing_breakables: RefCell::new(EnclosingBreakables {
                 stack: Vec::new(),
                 by_id: Default::default(),
diff --git a/src/test/ui/error-codes/E0767.rs b/src/test/ui/error-codes/E0767.rs
index 6c6cb746e6c..14215d36a38 100644
--- a/src/test/ui/error-codes/E0767.rs
+++ b/src/test/ui/error-codes/E0767.rs
@@ -1,6 +1,7 @@
-fn main () {
+fn main() {
     'a: loop {
         || {
+            //~^ ERROR mismatched types
             loop { break 'a; } //~ ERROR E0767
         }
     }
diff --git a/src/test/ui/error-codes/E0767.stderr b/src/test/ui/error-codes/E0767.stderr
index 2429823306b..ee85247301c 100644
--- a/src/test/ui/error-codes/E0767.stderr
+++ b/src/test/ui/error-codes/E0767.stderr
@@ -1,14 +1,27 @@
 error[E0767]: use of unreachable label `'a`
-  --> $DIR/E0767.rs:4:26
+  --> $DIR/E0767.rs:5:26
    |
 LL |     'a: loop {
    |     -- unreachable label defined here
-LL |         || {
+...
 LL |             loop { break 'a; }
    |                          ^^ unreachable label `'a`
    |
    = note: labels are unreachable through functions, closures, async blocks and modules
 
-error: aborting due to previous error
+error[E0308]: mismatched types
+  --> $DIR/E0767.rs:3:9
+   |
+LL | /         || {
+LL | |
+LL | |             loop { break 'a; }
+LL | |         }
+   | |_________^ expected `()`, found closure
+   |
+   = note: expected unit type `()`
+                found closure `[closure@$DIR/E0767.rs:3:9: 3:11]`
 
-For more information about this error, try `rustc --explain E0767`.
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0308, E0767.
+For more information about an error, try `rustc --explain E0308`.

From deb6538348644b5b8357a0f5dd3b34b27702ed43 Mon Sep 17 00:00:00 2001
From: Michael Howell 
Date: Wed, 2 Nov 2022 10:10:44 -0700
Subject: [PATCH 168/219] rustdoc: remove unused mobile CSS `.rustdoc {
 padding-top: 0 }`

When this rule was added in dd437ee6ed81f85c715bf415d261feca484bb39f, as
`body { padding-top: 0 }`, the desktop body tag had non-zero top padding.
This padding was removed in 135281ed1525db15edd8ebd092aa10aa40df2386.

This rule no longer overrides a rule in rustdoc's desktop styles, and also
doesn't override the UA stylesheet, since the [HTML standard] has only
margin, not padding, on the page body.

[HTML standard]: https://html.spec.whatwg.org/multipage/rendering.html#the-page
---
 src/librustdoc/html/static/css/rustdoc.css | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index 219d1b4ed53..a18fff3bb14 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -1677,7 +1677,6 @@ in storage.js
 	}
 
 	.rustdoc {
-		padding-top: 0px;
 		/* Sidebar should overlay main content, rather than pushing main content to the right.
 		   Turn off `display: flex` on the body element. */
 		display: block;

From 59be5151287e29d5340d6189dea2f18206f51e02 Mon Sep 17 00:00:00 2001
From: Michael Goulet 
Date: Wed, 2 Nov 2022 17:33:25 +0000
Subject: [PATCH 169/219] Properly render asyncness for traits without default
 body

---
 compiler/rustc_ty_utils/src/ty.rs   |  2 +-
 src/librustdoc/clean/mod.rs         | 32 +++++++++++++++++------------
 src/librustdoc/clean/types.rs       |  5 +----
 src/test/rustdoc/async-trait-sig.rs | 14 +++++++++++++
 4 files changed, 35 insertions(+), 18 deletions(-)
 create mode 100644 src/test/rustdoc/async-trait-sig.rs

diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs
index 3eebb4ace47..99d3bda6ebf 100644
--- a/compiler/rustc_ty_utils/src/ty.rs
+++ b/compiler/rustc_ty_utils/src/ty.rs
@@ -413,7 +413,7 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option> {
 /// Check if a function is async.
 fn asyncness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::IsAsync {
     let node = tcx.hir().get_by_def_id(def_id.expect_local());
-    if let Some(fn_kind) = node.fn_kind() { fn_kind.asyncness() } else { hir::IsAsync::NotAsync }
+    node.fn_sig().map_or(hir::IsAsync::NotAsync, |sig| sig.header.asyncness)
 }
 
 /// Don't call this directly: use ``tcx.conservative_is_privately_uninhabited`` instead.
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 1ce0d1e4ffd..84afdadfa00 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -880,7 +880,7 @@ fn clean_fn_or_proc_macro<'tcx>(
             ProcMacroItem(ProcMacro { kind, helpers })
         }
         None => {
-            let mut func = clean_function(cx, sig, generics, body_id);
+            let mut func = clean_function(cx, sig, generics, FunctionArgs::Body(body_id));
             clean_fn_decl_legacy_const_generics(&mut func, attrs);
             FunctionItem(func)
         }
@@ -917,16 +917,28 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[ast::Attrib
     }
 }
 
+enum FunctionArgs<'tcx> {
+    Body(hir::BodyId),
+    Names(&'tcx [Ident]),
+}
+
 fn clean_function<'tcx>(
     cx: &mut DocContext<'tcx>,
     sig: &hir::FnSig<'tcx>,
     generics: &hir::Generics<'tcx>,
-    body_id: hir::BodyId,
+    args: FunctionArgs<'tcx>,
 ) -> Box {
     let (generics, decl) = enter_impl_trait(cx, |cx| {
         // NOTE: generics must be cleaned before args
         let generics = clean_generics(generics, cx);
-        let args = clean_args_from_types_and_body_id(cx, sig.decl.inputs, body_id);
+        let args = match args {
+            FunctionArgs::Body(body_id) => {
+                clean_args_from_types_and_body_id(cx, sig.decl.inputs, body_id)
+            }
+            FunctionArgs::Names(names) => {
+                clean_args_from_types_and_names(cx, sig.decl.inputs, names)
+            }
+        };
         let mut decl = clean_fn_decl_with_args(cx, sig.decl, args);
         if sig.header.is_async() {
             decl.output = decl.sugared_async_return_type();
@@ -1051,18 +1063,12 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext
             ),
             hir::TraitItemKind::Const(ty, None) => TyAssocConstItem(clean_ty(ty, cx)),
             hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(body)) => {
-                let m = clean_function(cx, sig, trait_item.generics, body);
+                let m = clean_function(cx, sig, trait_item.generics, FunctionArgs::Body(body));
                 MethodItem(m, None)
             }
             hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(names)) => {
-                let (generics, decl) = enter_impl_trait(cx, |cx| {
-                    // NOTE: generics must be cleaned before args
-                    let generics = clean_generics(trait_item.generics, cx);
-                    let args = clean_args_from_types_and_names(cx, sig.decl.inputs, names);
-                    let decl = clean_fn_decl_with_args(cx, sig.decl, args);
-                    (generics, decl)
-                });
-                TyMethodItem(Box::new(Function { decl, generics }))
+                let m = clean_function(cx, sig, trait_item.generics, FunctionArgs::Names(names));
+                TyMethodItem(m)
             }
             hir::TraitItemKind::Type(bounds, Some(default)) => {
                 let generics = enter_impl_trait(cx, |cx| clean_generics(trait_item.generics, cx));
@@ -1099,7 +1105,7 @@ pub(crate) fn clean_impl_item<'tcx>(
                 AssocConstItem(clean_ty(ty, cx), default)
             }
             hir::ImplItemKind::Fn(ref sig, body) => {
-                let m = clean_function(cx, sig, impl_.generics, body);
+                let m = clean_function(cx, sig, impl_.generics, FunctionArgs::Body(body));
                 let defaultness = cx.tcx.impl_defaultness(impl_.owner_id);
                 MethodItem(m, Some(defaultness))
             }
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index 439311f0640..f1eb438b199 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -694,13 +694,10 @@ impl Item {
                     asyncness: hir::IsAsync::NotAsync,
                 }
             }
-            ItemKind::FunctionItem(_) | ItemKind::MethodItem(_, _) => {
+            ItemKind::FunctionItem(_) | ItemKind::MethodItem(_, _) | ItemKind::TyMethodItem(_) => {
                 let def_id = self.item_id.as_def_id().unwrap();
                 build_fn_header(def_id, tcx, tcx.asyncness(def_id))
             }
-            ItemKind::TyMethodItem(_) => {
-                build_fn_header(self.item_id.as_def_id().unwrap(), tcx, hir::IsAsync::NotAsync)
-            }
             _ => return None,
         };
         Some(header)
diff --git a/src/test/rustdoc/async-trait-sig.rs b/src/test/rustdoc/async-trait-sig.rs
new file mode 100644
index 00000000000..2578bc8f7a1
--- /dev/null
+++ b/src/test/rustdoc/async-trait-sig.rs
@@ -0,0 +1,14 @@
+// edition:2021
+
+#![feature(async_fn_in_trait)]
+#![allow(incomplete_features)]
+
+pub trait Foo {
+    // @has async_trait_sig/trait.Foo.html '//h4[@class="code-header"]' "async fn bar() -> i32"
+    async fn bar() -> i32;
+
+    // @has async_trait_sig/trait.Foo.html '//h4[@class="code-header"]' "async fn baz() -> i32"
+    async fn baz() -> i32 {
+        1
+    }
+}

From 03e4c76dcffc35c660bbea602993828328fda7b2 Mon Sep 17 00:00:00 2001
From: Amanieu d'Antras 
Date: Wed, 2 Nov 2022 18:47:58 +0000
Subject: [PATCH 170/219] asm: Work around LLVM bug on AArch64

Upstream issue: https://github.com/llvm/llvm-project/issues/58384

LLVM gets confused if we assign a 32-bit value to a 64-bit register, so
pass the 32-bit register name to LLVM in that case.
---
 compiler/rustc_codegen_llvm/src/asm.rs | 57 ++++++++++++++++++++++++--
 src/test/ui/asm/aarch64/llvm-58384.rs  | 16 ++++++++
 2 files changed, 70 insertions(+), 3 deletions(-)
 create mode 100644 src/test/ui/asm/aarch64/llvm-58384.rs

diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs
index 017513721b7..2e65b1b3460 100644
--- a/compiler/rustc_codegen_llvm/src/asm.rs
+++ b/compiler/rustc_codegen_llvm/src/asm.rs
@@ -496,6 +496,44 @@ fn xmm_reg_index(reg: InlineAsmReg) -> Option {
     }
 }
 
+/// If the register is an AArch64 integer register then return its index.
+fn a64_reg_index(reg: InlineAsmReg) -> Option {
+    match reg {
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x0) => Some(0),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x1) => Some(1),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x2) => Some(2),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x3) => Some(3),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x4) => Some(4),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x5) => Some(5),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x6) => Some(6),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x7) => Some(7),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x8) => Some(8),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x9) => Some(9),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x10) => Some(10),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x11) => Some(11),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x12) => Some(12),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x13) => Some(13),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x14) => Some(14),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x15) => Some(15),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x16) => Some(16),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x17) => Some(17),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x18) => Some(18),
+        // x19 is reserved
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x20) => Some(20),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x21) => Some(21),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x22) => Some(22),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x23) => Some(23),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x24) => Some(24),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x25) => Some(25),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x26) => Some(26),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x27) => Some(27),
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x28) => Some(28),
+        // x29 is reserved
+        InlineAsmReg::AArch64(AArch64InlineAsmReg::x30) => Some(30),
+        _ => None,
+    }
+}
+
 /// If the register is an AArch64 vector register then return its index.
 fn a64_vreg_index(reg: InlineAsmReg) -> Option {
     match reg {
@@ -526,6 +564,22 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
                     'x'
                 };
                 format!("{{{}mm{}}}", class, idx)
+            } else if let Some(idx) = a64_reg_index(reg) {
+                let class = if let Some(layout) = layout {
+                    match layout.size.bytes() {
+                        8 => 'x',
+                        _ => 'w',
+                    }
+                } else {
+                    // We use i32 as the type for discarded outputs
+                    'w'
+                };
+                if class == 'x' && reg == InlineAsmReg::AArch64(AArch64InlineAsmReg::x30) {
+                    // LLVM doesn't recognize x30. use lr instead.
+                    "{lr}".to_string()
+                } else {
+                    format!("{{{}{}}}", class, idx)
+                }
             } else if let Some(idx) = a64_vreg_index(reg) {
                 let class = if let Some(layout) = layout {
                     match layout.size.bytes() {
@@ -541,9 +595,6 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
                     'q'
                 };
                 format!("{{{}{}}}", class, idx)
-            } else if reg == InlineAsmReg::AArch64(AArch64InlineAsmReg::x30) {
-                // LLVM doesn't recognize x30
-                "{lr}".to_string()
             } else if reg == InlineAsmReg::Arm(ArmInlineAsmReg::r14) {
                 // LLVM doesn't recognize r14
                 "{lr}".to_string()
diff --git a/src/test/ui/asm/aarch64/llvm-58384.rs b/src/test/ui/asm/aarch64/llvm-58384.rs
new file mode 100644
index 00000000000..308f7890829
--- /dev/null
+++ b/src/test/ui/asm/aarch64/llvm-58384.rs
@@ -0,0 +1,16 @@
+// only-aarch64
+// run-pass
+// needs-asm-support
+
+// Test that we properly work around this LLVM issue:
+// https://github.com/llvm/llvm-project/issues/58384
+
+use std::arch::asm;
+
+fn main() {
+    let a: i32;
+    unsafe {
+        asm!("", inout("x0") 435 => a);
+    }
+    assert_eq!(a, 435);
+}

From ab22f5521bdb940d8beabd442298a56ecb236b38 Mon Sep 17 00:00:00 2001
From: yukang 
Date: Thu, 3 Nov 2022 04:57:44 +0800
Subject: [PATCH 171/219] change error_reported to use Result instead of an
 option

---
 compiler/rustc_hir_analysis/src/astconv/mod.rs   |  2 +-
 .../rustc_hir_analysis/src/coherence/orphan.rs   |  4 +---
 compiler/rustc_hir_typeck/src/cast.rs            | 16 +++++++---------
 .../src/traits/specialization_graph.rs           |  2 +-
 compiler/rustc_middle/src/ty/context.rs          |  5 +----
 compiler/rustc_middle/src/ty/visit.rs            |  6 +++---
 compiler/rustc_transmute/src/lib.rs              |  2 +-
 7 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs
index 6baf9844977..3d3d3d2d94f 100644
--- a/compiler/rustc_hir_analysis/src/astconv/mod.rs
+++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs
@@ -1977,7 +1977,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
                     }
 
                     err.emit()
-                } else if let Some(reported) = qself_ty.error_reported() {
+                } else if let Err(reported) = qself_ty.error_reported() {
                     reported
                 } else {
                     // Don't print `TyErr` to the user.
diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs
index 1307f74f210..e9674c93f3e 100644
--- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs
@@ -23,9 +23,7 @@ pub(crate) fn orphan_check_impl(
     impl_def_id: LocalDefId,
 ) -> Result<(), ErrorGuaranteed> {
     let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
-    if let Some(err) = trait_ref.error_reported() {
-        return Err(err);
-    }
+    trait_ref.error_reported()?;
 
     let ret = do_orphan_check_impl(tcx, trait_ref, impl_def_id);
     if tcx.trait_is_auto(trait_ref.def_id) {
diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs
index 0e7576ecf8b..cf7587ffa0e 100644
--- a/compiler/rustc_hir_typeck/src/cast.rs
+++ b/compiler/rustc_hir_typeck/src/cast.rs
@@ -92,10 +92,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         debug!("pointer_kind({:?}, {:?})", t, span);
 
         let t = self.resolve_vars_if_possible(t);
-
-        if let Some(reported) = t.error_reported() {
-            return Err(reported);
-        }
+        t.error_reported()?;
 
         if self.type_is_sized_modulo_regions(self.param_env, t, span) {
             return Ok(Some(PointerKind::Thin));
@@ -220,7 +217,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
         match cast_ty.kind() {
             ty::Dynamic(_, _, ty::Dyn) | ty::Slice(..) => {
                 let reported = check.report_cast_to_unsized_type(fcx);
-                Err(reported)
+                return Err(reported);
             }
             _ => Ok(check),
         }
@@ -611,10 +608,11 @@ impl<'a, 'tcx> CastCheck<'tcx> {
     }
 
     fn report_cast_to_unsized_type(&self, fcx: &FnCtxt<'a, 'tcx>) -> ErrorGuaranteed {
-        if let Some(reported) =
-            self.cast_ty.error_reported().or_else(|| self.expr_ty.error_reported())
-        {
-            return reported;
+        if let Err(err) = self.cast_ty.error_reported() {
+            return err;
+        }
+        if let Err(err) = self.expr_ty.error_reported() {
+            return err;
         }
 
         let tstr = fcx.ty_to_string(self.cast_ty);
diff --git a/compiler/rustc_middle/src/traits/specialization_graph.rs b/compiler/rustc_middle/src/traits/specialization_graph.rs
index 0a2819feecf..82442c8430d 100644
--- a/compiler/rustc_middle/src/traits/specialization_graph.rs
+++ b/compiler/rustc_middle/src/traits/specialization_graph.rs
@@ -249,7 +249,7 @@ pub fn ancestors<'tcx>(
 
     if let Some(reported) = specialization_graph.has_errored {
         Err(reported)
-    } else if let Some(reported) = tcx.type_of(start_from_impl).error_reported() {
+    } else if let Err(reported) = tcx.type_of(start_from_impl).error_reported() {
         Err(reported)
     } else {
         Ok(Ancestors {
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index eeb53f9714c..95004e5c5ca 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -1315,10 +1315,7 @@ impl<'tcx> TyCtxt<'tcx> {
         msg: &str,
     ) -> Const<'tcx> {
         let reported = self.sess.delay_span_bug(span, msg);
-        self.mk_const(ty::ConstS {
-            kind: ty::ConstKind::Error(reported),
-            ty,
-        })
+        self.mk_const(ty::ConstS { kind: ty::ConstKind::Error(reported), ty })
     }
 
     pub fn consider_optimizing String>(self, msg: T) -> bool {
diff --git a/compiler/rustc_middle/src/ty/visit.rs b/compiler/rustc_middle/src/ty/visit.rs
index c09f71f9a6d..f0e9f990a81 100644
--- a/compiler/rustc_middle/src/ty/visit.rs
+++ b/compiler/rustc_middle/src/ty/visit.rs
@@ -95,11 +95,11 @@ pub trait TypeVisitable<'tcx>: fmt::Debug + Clone {
     fn references_error(&self) -> bool {
         self.has_type_flags(TypeFlags::HAS_ERROR)
     }
-    fn error_reported(&self) -> Option {
+    fn error_reported(&self) -> Result<(), ErrorGuaranteed> {
         if self.references_error() {
-            Some(ErrorGuaranteed::unchecked_claim_error_was_emitted())
+            Err(ErrorGuaranteed::unchecked_claim_error_was_emitted())
         } else {
-            None
+            Ok(())
         }
     }
     fn has_non_region_param(&self) -> bool {
diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs
index f7cc94e5314..384d03106b1 100644
--- a/compiler/rustc_transmute/src/lib.rs
+++ b/compiler/rustc_transmute/src/lib.rs
@@ -122,7 +122,7 @@ mod rustc {
 
             let c = c.eval(tcx, param_env);
 
-            if let Some(err) = c.error_reported() {
+            if let Err(err) = c.error_reported() {
                 return Some(Self {
                     alignment: true,
                     lifetimes: true,

From dfab01b6e0ee60dda61b2c51ac76850c5e79b550 Mon Sep 17 00:00:00 2001
From: Collin Baker 
Date: Fri, 21 Oct 2022 14:38:56 -0400
Subject: [PATCH 172/219] Remove std's transitive dependency on cfg-if 0.1

After rust-lang/rust#101946 this completes the move to cfg-if 1.0 by:
* Updating getrandom 0.1.14->0.1.16
* Updating panic_abort, panic_unwind, and unwind to cfg-if 1.0
---
 Cargo.lock                      | 16 ++++++++--------
 library/panic_abort/Cargo.toml  |  2 +-
 library/panic_unwind/Cargo.toml |  2 +-
 library/unwind/Cargo.toml       |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 33b1299976f..f79392cffdb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1526,11 +1526,11 @@ dependencies = [
 
 [[package]]
 name = "getrandom"
-version = "0.1.14"
+version = "0.1.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
+checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
 dependencies = [
- "cfg-if 0.1.10",
+ "cfg-if 1.0.0",
  "libc",
  "wasi 0.9.0+wasi-snapshot-preview1",
 ]
@@ -2478,7 +2478,7 @@ name = "panic_abort"
 version = "0.0.0"
 dependencies = [
  "alloc",
- "cfg-if 0.1.10",
+ "cfg-if 1.0.0",
  "compiler_builtins",
  "core",
  "libc",
@@ -2489,7 +2489,7 @@ name = "panic_unwind"
 version = "0.0.0"
 dependencies = [
  "alloc",
- "cfg-if 0.1.10",
+ "cfg-if 1.0.0",
  "compiler_builtins",
  "core",
  "libc",
@@ -2817,7 +2817,7 @@ version = "0.7.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
 dependencies = [
- "getrandom 0.1.14",
+ "getrandom 0.1.16",
  "libc",
  "rand_chacha 0.2.2",
  "rand_core 0.5.1",
@@ -2861,7 +2861,7 @@ version = "0.5.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
 dependencies = [
- "getrandom 0.1.14",
+ "getrandom 0.1.16",
 ]
 
 [[package]]
@@ -5357,7 +5357,7 @@ name = "unwind"
 version = "0.0.0"
 dependencies = [
  "cc",
- "cfg-if 0.1.10",
+ "cfg-if 1.0.0",
  "compiler_builtins",
  "core",
  "libc",
diff --git a/library/panic_abort/Cargo.toml b/library/panic_abort/Cargo.toml
index 46183d1ad00..e6ea2b1849b 100644
--- a/library/panic_abort/Cargo.toml
+++ b/library/panic_abort/Cargo.toml
@@ -13,7 +13,7 @@ doc = false
 
 [dependencies]
 alloc = { path = "../alloc" }
-cfg-if = { version = "0.1.8", features = ['rustc-dep-of-std'] }
+cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
 core = { path = "../core" }
 libc = { version = "0.2", default-features = false }
 compiler_builtins = "0.1.0"
diff --git a/library/panic_unwind/Cargo.toml b/library/panic_unwind/Cargo.toml
index d720cc7bcbd..85386976d63 100644
--- a/library/panic_unwind/Cargo.toml
+++ b/library/panic_unwind/Cargo.toml
@@ -17,4 +17,4 @@ core = { path = "../core" }
 libc = { version = "0.2", default-features = false }
 unwind = { path = "../unwind" }
 compiler_builtins = "0.1.0"
-cfg-if = "0.1.8"
+cfg-if = "1.0"
diff --git a/library/unwind/Cargo.toml b/library/unwind/Cargo.toml
index 69fce8d7795..32c4a7eb5c1 100644
--- a/library/unwind/Cargo.toml
+++ b/library/unwind/Cargo.toml
@@ -17,7 +17,7 @@ doc = false
 core = { path = "../core" }
 libc = { version = "0.2.79", features = ['rustc-dep-of-std'], default-features = false }
 compiler_builtins = "0.1.0"
-cfg-if = "0.1.8"
+cfg-if = "1.0"
 
 [build-dependencies]
 cc = "1.0.69"

From 68e19aa4ac8812e83b80035988d915087a4183e5 Mon Sep 17 00:00:00 2001
From: Michael Howell 
Date: Wed, 2 Nov 2022 15:33:36 -0700
Subject: [PATCH 173/219] rustdoc: remove redundant mobile CSS `.sidebar-elems
 { background }`

The exact same background is already set for its parent, the `nav.sidebar`.
---
 src/librustdoc/html/static/css/rustdoc.css | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index 360b6b9832a..d7526498b0d 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -1797,7 +1797,6 @@ in storage.js
 
 	.sidebar-elems {
 		margin-top: 1em;
-		background-color: var(--sidebar-background-color);
 	}
 
 	.content {

From 0bd4f76944703dc8e8af26c8e55d3db9488689f9 Mon Sep 17 00:00:00 2001
From: Jakob Degen 
Date: Wed, 2 Nov 2022 14:54:49 -0700
Subject: [PATCH 174/219] Ban dashes in miropt test file names

---
 src/bootstrap/test.rs                         |   3 +
 ..._of_reborrow.SimplifyCfg-initial.after.mir | 542 +++++++++---------
 ...row_and_cast.SimplifyCfg-initial.after.mir |  68 +--
 .../mir-opt/{address-of.rs => address_of.rs}  |   0
 ...main.SimplifyCfg-elaborate-drops.after.mir |  82 +--
 ...mporary.rs => array_index_is_temporary.rs} |   0
 .../issue_101867.main.built.after.mir         |  58 +-
 .../{issue-101867.rs => issue_101867.rs}      |   0
 .../building/issue_49232.main.built.after.mir |  76 +--
 .../{issue-49232.rs => issue_49232.rs}        |   0
 ...ceiver_ptr_mutability.main.built.after.mir | 130 ++---
 ...tability.rs => receiver_ptr_mutability.rs} |   0
 .../simple_match.match_bool.built.after.mir   |  20 +-
 .../{simple-match.rs => simple_match.rs}      |   0
 ...d[0].SimplifyCfg-elaborate-drops.after.mir |  20 +-
 ...motion_extern_static.BAR.PromoteTemps.diff |  60 +-
 ...romotion_extern_static.BOP.built.after.mir |  20 +-
 ...d[0].SimplifyCfg-elaborate-drops.after.mir |  20 +-
 ...motion_extern_static.FOO.PromoteTemps.diff |  60 +-
 ...ic.rs => const_promotion_extern_static.rs} |   0
 ...l_flow_simplification.hello.ConstProp.diff |  18 +-
 ...simplification.hello.PreCodegen.before.mir |   4 +-
 ...tion.rs => control_flow_simplification.rs} |   0
 .../issue_66971.main.ConstProp.diff           |  38 +-
 .../{issue-66971.rs => issue_66971.rs}        |   0
 .../issue_67019.main.ConstProp.diff           |  40 +-
 .../{issue-67019.rs => issue_67019.rs}        |   0
 ....match_tuple.SimplifyCfg-initial.after.mir |  88 +--
 .../{exponential-or.rs => exponential_or.rs}  |   0
 .../{fn-ptr-shim.rs => fn_ptr_shim.rs}        |   0
 ...anup.main-{closure#0}.generator_drop.0.mir |  58 +-
 ...p-cleanup.rs => generator_drop_cleanup.rs} |   0
 ...main-{closure#0}.StateTransform.before.mir | 122 ++--
 ...nd.rs => generator_storage_dead_unwind.rs} |   0
 ...ny.main-{closure#0}.generator_resume.0.mir |  84 +--
 .../{generator-tiny.rs => generator_tiny.rs}  |   0
 ...t_opt_bool.SimplifyComparisonIntegral.diff |  24 +-
 ...opt_floats.SimplifyComparisonIntegral.diff |  32 +-
 ...comparison.SimplifyComparisonIntegral.diff |  76 +--
 ...t.opt_char.SimplifyComparisonIntegral.diff |  42 +-
 ...int.opt_i8.SimplifyComparisonIntegral.diff |  42 +-
 ...ltiple_ifs.SimplifyComparisonIntegral.diff |  76 +--
 ...t_negative.SimplifyComparisonIntegral.diff |  42 +-
 ...nt.opt_u32.SimplifyComparisonIntegral.diff |  42 +-
 ...f-condition-int.rs => if_condition_int.rs} |   0
 .../inline/asm_unwind.main.Inline.diff        |  34 +-
 .../inline/{asm-unwind.rs => asm_unwind.rs}   |   0
 .../caller_with_trivial_bound.foo.Inline.diff |  22 +-
 ...-bound.rs => caller_with_trivial_bound.rs} |   0
 .../inline/dyn_trait.get_query.Inline.diff    |  74 +--
 .../inline/dyn_trait.mk_cycle.Inline.diff     |  18 +-
 .../inline/{dyn-trait.rs => dyn_trait.rs}     |   0
 .../dyn_trait.try_execute_query.Inline.diff   |  42 +-
 .../inline_any_operand.bar.Inline.after.mir   |  64 +--
 ...e-any-operand.rs => inline_any_operand.rs} |   0
 .../{inline-async.rs => inline_async.rs}      |   0
 .../inline_closure.foo.Inline.after.mir       |  78 +--
 .../{inline-closure.rs => inline_closure.rs}  |   0
 ...e_closure_borrows_arg.foo.Inline.after.mir |  88 +--
 ...s-arg.rs => inline_closure_borrows_arg.rs} |   0
 ...line_closure_captures.foo.Inline.after.mir | 110 ++--
 ...captures.rs => inline_closure_captures.rs} |   0
 ...patibility.inlined_no_sanitize.Inline.diff |  18 +-
 ...ibility.inlined_target_feature.Inline.diff |  18 +-
 ...ibility.not_inlined_c_variadic.Inline.diff |  18 +-
 ...bility.not_inlined_no_sanitize.Inline.diff |  16 +-
 ...ity.not_inlined_target_feature.Inline.diff |  16 +-
 ...mpatibility.rs => inline_compatibility.rs} |   0
 .../inline/inline_cycle.one.Inline.diff       |  26 +-
 .../{inline-cycle.rs => inline_cycle.rs}      |   0
 .../inline/inline_cycle.two.Inline.diff       |  66 +--
 .../inline_cycle_generic.main.Inline.diff     |  28 +-
 ...cle-generic.rs => inline_cycle_generic.rs} |   0
 .../inline/inline_diverging.f.Inline.diff     |  18 +-
 .../inline/inline_diverging.g.Inline.diff     |  46 +-
 .../inline/inline_diverging.h.Inline.diff     |  58 +-
 ...nline-diverging.rs => inline_diverging.rs} |   0
 .../inline/inline_generator.main.Inline.diff  | 164 +++---
 ...nline-generator.rs => inline_generator.rs} |   0
 ...inline_instruction_set.default.Inline.diff |  38 +-
 ...ction-set.rs => inline_instruction_set.rs} |   0
 .../inline_instruction_set.t32.Inline.diff    |  40 +-
 .../inline_into_box_place.main.Inline.diff    |  68 +--
 ...-box-place.rs => inline_into_box_place.rs} |   0
 .../inline_options.main.Inline.after.mir      |  54 +-
 .../{inline-options.rs => inline_options.rs}  |   0
 .../inline/inline_retag.bar.Inline.after.mir  | 112 ++--
 .../{inline-retag.rs => inline_retag.rs}      |   0
 .../inline/inline_shims.clone.Inline.diff     |  20 +-
 .../inline/inline_shims.drop.Inline.diff      |  48 +-
 .../{inline-shims.rs => inline_shims.rs}      |   0
 .../inline_specialization.main.Inline.diff    |  22 +-
 ...ialization.rs => inline_specialization.rs} |   0
 ...trait-method.rs => inline_trait_method.rs} |   0
 .../inline_trait_method.test.Inline.after.mir |  18 +-
 ...t-method_2.rs => inline_trait_method_2.rs} |   0
 ...line_trait_method_2.test2.Inline.after.mir |  38 +-
 ...67_inline_as_ref_as_mut.a.Inline.after.mir |  32 +-
 ...67_inline_as_ref_as_mut.b.Inline.after.mir |  32 +-
 ...67_inline_as_ref_as_mut.c.Inline.after.mir |  24 +-
 ...67_inline_as_ref_as_mut.d.Inline.after.mir |  24 +-
 ...rs => issue_58867_inline_as_ref_as_mut.rs} |   0
 ...ine_scopes_parenting.main.Inline.after.mir |  60 +-
 ...=> issue_76997_inline_scopes_parenting.rs} |   0
 .../inline/issue_78442.bar.Inline.diff        |  72 +--
 .../inline/issue_78442.bar.RevealAll.diff     |  56 +-
 .../inline/{issue-78442.rs => issue_78442.rs} |   0
 ...-recursion.rs => polymorphic_recursion.rs} |   0
 .../mir-opt/issue_101973.inner.ConstProp.diff | 122 ++--
 .../{issue-101973.rs => issue_101973.rs}      |   0
 ...e_38669.main.SimplifyCfg-initial.after.mir |  56 +-
 .../{issue-38669.rs => issue_38669.rs}        |   0
 .../issue_41110.main.ElaborateDrops.after.mir |  66 +--
 .../{issue-41110.rs => issue_41110.rs}        |   0
 .../issue_41110.test.ElaborateDrops.after.mir |  92 +--
 .../{issue-41697.rs => issue_41697.rs}        |   0
 ...nt#0}.SimplifyCfg-promote-consts.after.mir |  18 +-
 .../issue_41888.main.ElaborateDrops.after.mir | 146 ++---
 .../{issue-41888.rs => issue_41888.rs}        |   0
 .../{issue-62289.rs => issue_62289.rs}        |   0
 ...issue_62289.test.ElaborateDrops.before.mir | 120 ++--
 .../mir-opt/issue_72181.bar.built.after.mir   |  16 +-
 .../mir-opt/issue_72181.foo.built.after.mir   |  28 +-
 .../mir-opt/issue_72181.main.built.after.mir  |  72 +--
 .../{issue-72181.rs => issue_72181.rs}        |   0
 .../mir-opt/issue_72181_1.f.built.after.mir   |  26 +-
 .../issue_72181_1.main.built.after.mir        |  56 +-
 .../{issue-72181-1.rs => issue_72181_1.rs}    |   0
 .../issue_73223.main.SimplifyArmIdentity.diff |  80 +--
 .../{issue-73223.rs => issue_73223.rs}        |   0
 .../mir-opt/issue_78192.f.InstCombine.diff    |  36 +-
 .../{issue-78192.rs => issue_78192.rs}        |   0
 .../mir-opt/issue_91633.bar.built.after.mir   |  32 +-
 .../mir-opt/issue_91633.foo.built.after.mir   |  56 +-
 .../mir-opt/issue_91633.fun.built.after.mir   |  40 +-
 .../mir-opt/issue_91633.hey.built.after.mir   |  36 +-
 .../{issue-91633.rs => issue_91633.rs}        |   0
 .../mir-opt/issue_99325.main.built.after.mir  |  48 +-
 .../{issue-99325.rs => issue_99325.rs}        |   0
 ...ue_59352.num_to_digit.PreCodegen.after.mir |  54 +-
 .../issues/{issue-59352.rs => issue_59352.rs} |   0
 ...e_75439.foo.MatchBranchSimplification.diff |  82 +--
 .../issues/{issue-75439.rs => issue_75439.rs} |   0
 ...fg-initial.after-ElaborateDrops.after.diff | 290 +++++-----
 ...atch-arm-scopes.rs => match_arm_scopes.rs} |   0
 ...imes-basic.rs => named_lifetimes_basic.rs} |   0
 .../nll/named_lifetimes_basic.use_x.nll.0.mir |  30 +-
 ...egion_subtyping_basic.main.nll.0.32bit.mir | 110 ++--
 ...egion_subtyping_basic.main.nll.0.64bit.mir | 110 ++--
 ...ing-basic.rs => region_subtyping_basic.rs} |   0
 ...ant.rs => no_drop_for_inactive_variant.rs} |   0
 ...wrap.SimplifyCfg-elaborate-drops.after.mir |  38 +-
 ..._after_call.main.ElaborateDrops.before.mir |  48 +-
 ...call.rs => no_spurious_drop_after_call.rs} |   0
 .../nrvo_simple.nrvo.RenameReturnPlace.diff   |  58 +-
 .../{nrvo-simple.rs => nrvo_simple.rs}        |   0
 ...main.SimplifyCfg-elaborate-drops.after.mir |  78 +--
 ...igned.rs => packed_struct_drop_aligned.rs} |   0
 ...ever_const.no_codegen.PreCodegen.after.mir |   4 +-
 ...e-never-const.rs => remove_never_const.rs} |   0
 .../{simplify-arm.rs => simplify_arm.rs}      |   0
 ...m-identity.rs => simplify_arm_identity.rs} |   0
 .../simplify_locals.c.SimplifyLocals.diff     |  40 +-
 .../simplify_locals.d1.SimplifyLocals.diff    |  16 +-
 .../simplify_locals.d2.SimplifyLocals.diff    |  40 +-
 ...ify_locals.expose_addr.SimplifyLocals.diff |  24 +-
 .../simplify_locals.r.SimplifyLocals.diff     |  32 +-
 ...{simplify-locals.rs => simplify_locals.rs} |   0
 .../simplify_locals.t1.SimplifyLocals.diff    |  22 +-
 .../simplify_locals.t2.SimplifyLocals.diff    |  22 +-
 .../simplify_locals.t3.SimplifyLocals.diff    |  30 +-
 .../simplify_locals.t4.SimplifyLocals.diff    |  22 +-
 ..._locals_fixedpoint.foo.SimplifyLocals.diff |  78 +--
 ...point.rs => simplify_locals_fixedpoint.rs} |   0
 ...ves_unused_consts.main.SimplifyLocals.diff | 176 +++---
 ... simplify_locals_removes_unused_consts.rs} |   0
 ...discriminant_reads.map.SimplifyLocals.diff |  58 +-
 ...cals_removes_unused_discriminant_reads.rs} |   0
 ...{slice-drop-shim.rs => slice_drop_shim.rs} |   0
 .../spanview_block.main.built.after.html      |   2 +-
 .../{spanview-block.rs => spanview_block.rs}  |   0
 .../spanview_statement.main.built.after.html  |   4 +-
 ...iew-statement.rs => spanview_statement.rs} |   0
 .../spanview_terminator.main.built.after.html |   2 +-
 ...w-terminator.rs => spanview_terminator.rs} |   0
 .../tls_access.main.PreCodegen.after.mir      |  34 +-
 .../mir-opt/{tls-access.rs => tls_access.rs}  |   0
 ...num.process_never.SimplifyLocals.after.mir |  10 +-
 ...enum.process_void.SimplifyLocals.after.mir |  14 +-
 ...ninhabited-enum.rs => uninhabited_enum.rs} |   0
 ...tem_types.E-V-{constant#0}.built.after.mir |   6 +-
 ...pes.Test-X-{constructor#0}.built.after.mir |  10 +-
 ...al-item-types.rs => unusual_item_types.rs} |   0
 ...mpl#0}-ASSOCIATED_CONSTANT.built.after.mir |  10 +-
 .../{while-storage.rs => while_storage.rs}    |   0
 ...le_storage.while_loop.PreCodegen.after.mir |  54 +-
 src/tools/tidy/src/main.rs                    |   3 +-
 src/tools/tidy/src/mir_opt_tests.rs           |  37 +-
 198 files changed, 3299 insertions(+), 3262 deletions(-)
 rename src/test/mir-opt/{address-of.rs => address_of.rs} (100%)
 rename src/test/mir-opt/{array-index-is-temporary.rs => array_index_is_temporary.rs} (100%)
 rename src/test/mir-opt/building/{issue-101867.rs => issue_101867.rs} (100%)
 rename src/test/mir-opt/building/{issue-49232.rs => issue_49232.rs} (100%)
 rename src/test/mir-opt/building/{receiver-ptr-mutability.rs => receiver_ptr_mutability.rs} (100%)
 rename src/test/mir-opt/building/{simple-match.rs => simple_match.rs} (100%)
 rename src/test/mir-opt/{const-promotion-extern-static.rs => const_promotion_extern_static.rs} (100%)
 rename src/test/mir-opt/const_prop/{control-flow-simplification.rs => control_flow_simplification.rs} (100%)
 rename src/test/mir-opt/const_prop/{issue-66971.rs => issue_66971.rs} (100%)
 rename src/test/mir-opt/const_prop/{issue-67019.rs => issue_67019.rs} (100%)
 rename src/test/mir-opt/{exponential-or.rs => exponential_or.rs} (100%)
 rename src/test/mir-opt/{fn-ptr-shim.rs => fn_ptr_shim.rs} (100%)
 rename src/test/mir-opt/{generator-drop-cleanup.rs => generator_drop_cleanup.rs} (100%)
 rename src/test/mir-opt/{generator-storage-dead-unwind.rs => generator_storage_dead_unwind.rs} (100%)
 rename src/test/mir-opt/{generator-tiny.rs => generator_tiny.rs} (100%)
 rename src/test/mir-opt/{if-condition-int.rs => if_condition_int.rs} (100%)
 rename src/test/mir-opt/inline/{asm-unwind.rs => asm_unwind.rs} (100%)
 rename src/test/mir-opt/inline/{caller-with-trivial-bound.rs => caller_with_trivial_bound.rs} (100%)
 rename src/test/mir-opt/inline/{dyn-trait.rs => dyn_trait.rs} (100%)
 rename src/test/mir-opt/inline/{inline-any-operand.rs => inline_any_operand.rs} (100%)
 rename src/test/mir-opt/inline/{inline-async.rs => inline_async.rs} (100%)
 rename src/test/mir-opt/inline/{inline-closure.rs => inline_closure.rs} (100%)
 rename src/test/mir-opt/inline/{inline-closure-borrows-arg.rs => inline_closure_borrows_arg.rs} (100%)
 rename src/test/mir-opt/inline/{inline-closure-captures.rs => inline_closure_captures.rs} (100%)
 rename src/test/mir-opt/inline/{inline-compatibility.rs => inline_compatibility.rs} (100%)
 rename src/test/mir-opt/inline/{inline-cycle.rs => inline_cycle.rs} (100%)
 rename src/test/mir-opt/inline/{inline-cycle-generic.rs => inline_cycle_generic.rs} (100%)
 rename src/test/mir-opt/inline/{inline-diverging.rs => inline_diverging.rs} (100%)
 rename src/test/mir-opt/inline/{inline-generator.rs => inline_generator.rs} (100%)
 rename src/test/mir-opt/inline/{inline-instruction-set.rs => inline_instruction_set.rs} (100%)
 rename src/test/mir-opt/inline/{inline-into-box-place.rs => inline_into_box_place.rs} (100%)
 rename src/test/mir-opt/inline/{inline-options.rs => inline_options.rs} (100%)
 rename src/test/mir-opt/inline/{inline-retag.rs => inline_retag.rs} (100%)
 rename src/test/mir-opt/inline/{inline-shims.rs => inline_shims.rs} (100%)
 rename src/test/mir-opt/inline/{inline-specialization.rs => inline_specialization.rs} (100%)
 rename src/test/mir-opt/inline/{inline-trait-method.rs => inline_trait_method.rs} (100%)
 rename src/test/mir-opt/inline/{inline-trait-method_2.rs => inline_trait_method_2.rs} (100%)
 rename src/test/mir-opt/inline/{issue-58867-inline-as-ref-as-mut.rs => issue_58867_inline_as_ref_as_mut.rs} (100%)
 rename src/test/mir-opt/inline/{issue-76997-inline-scopes-parenting.rs => issue_76997_inline_scopes_parenting.rs} (100%)
 rename src/test/mir-opt/inline/{issue-78442.rs => issue_78442.rs} (100%)
 rename src/test/mir-opt/inline/{polymorphic-recursion.rs => polymorphic_recursion.rs} (100%)
 rename src/test/mir-opt/{issue-101973.rs => issue_101973.rs} (100%)
 rename src/test/mir-opt/{issue-38669.rs => issue_38669.rs} (100%)
 rename src/test/mir-opt/{issue-41110.rs => issue_41110.rs} (100%)
 rename src/test/mir-opt/{issue-41697.rs => issue_41697.rs} (100%)
 rename src/test/mir-opt/{issue-41888.rs => issue_41888.rs} (100%)
 rename src/test/mir-opt/{issue-62289.rs => issue_62289.rs} (100%)
 rename src/test/mir-opt/{issue-72181.rs => issue_72181.rs} (100%)
 rename src/test/mir-opt/{issue-72181-1.rs => issue_72181_1.rs} (100%)
 rename src/test/mir-opt/{issue-73223.rs => issue_73223.rs} (100%)
 rename src/test/mir-opt/{issue-78192.rs => issue_78192.rs} (100%)
 rename src/test/mir-opt/{issue-91633.rs => issue_91633.rs} (100%)
 rename src/test/mir-opt/{issue-99325.rs => issue_99325.rs} (100%)
 rename src/test/mir-opt/issues/{issue-59352.rs => issue_59352.rs} (100%)
 rename src/test/mir-opt/issues/{issue-75439.rs => issue_75439.rs} (100%)
 rename src/test/mir-opt/{match-arm-scopes.rs => match_arm_scopes.rs} (100%)
 rename src/test/mir-opt/nll/{named-lifetimes-basic.rs => named_lifetimes_basic.rs} (100%)
 rename src/test/mir-opt/nll/{region-subtyping-basic.rs => region_subtyping_basic.rs} (100%)
 rename src/test/mir-opt/{no-drop-for-inactive-variant.rs => no_drop_for_inactive_variant.rs} (100%)
 rename src/test/mir-opt/{no-spurious-drop-after-call.rs => no_spurious_drop_after_call.rs} (100%)
 rename src/test/mir-opt/{nrvo-simple.rs => nrvo_simple.rs} (100%)
 rename src/test/mir-opt/{packed-struct-drop-aligned.rs => packed_struct_drop_aligned.rs} (100%)
 rename src/test/mir-opt/{remove-never-const.rs => remove_never_const.rs} (100%)
 rename src/test/mir-opt/{simplify-arm.rs => simplify_arm.rs} (100%)
 rename src/test/mir-opt/{simplify-arm-identity.rs => simplify_arm_identity.rs} (100%)
 rename src/test/mir-opt/{simplify-locals.rs => simplify_locals.rs} (100%)
 rename src/test/mir-opt/{simplify-locals-fixedpoint.rs => simplify_locals_fixedpoint.rs} (100%)
 rename src/test/mir-opt/{simplify-locals-removes-unused-consts.rs => simplify_locals_removes_unused_consts.rs} (100%)
 rename src/test/mir-opt/{simplify-locals-removes-unused-discriminant-reads.rs => simplify_locals_removes_unused_discriminant_reads.rs} (100%)
 rename src/test/mir-opt/{slice-drop-shim.rs => slice_drop_shim.rs} (100%)
 rename src/test/mir-opt/{spanview-block.rs => spanview_block.rs} (100%)
 rename src/test/mir-opt/{spanview-statement.rs => spanview_statement.rs} (100%)
 rename src/test/mir-opt/{spanview-terminator.rs => spanview_terminator.rs} (100%)
 rename src/test/mir-opt/{tls-access.rs => tls_access.rs} (100%)
 rename src/test/mir-opt/{uninhabited-enum.rs => uninhabited_enum.rs} (100%)
 rename src/test/mir-opt/{unusual-item-types.rs => unusual_item_types.rs} (100%)
 rename src/test/mir-opt/{while-storage.rs => while_storage.rs} (100%)

diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index e168dd571f6..935ce5e7f84 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -1052,6 +1052,9 @@ impl Step for Tidy {
         if builder.is_verbose() {
             cmd.arg("--verbose");
         }
+        if builder.config.cmd.bless() {
+            cmd.arg("--bless");
+        }
 
         builder.info("tidy check");
         try_run(builder, &mut cmd);
diff --git a/src/test/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir b/src/test/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir
index d41a66871cc..5f8b2f9312b 100644
--- a/src/test/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir
+++ b/src/test/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir
@@ -1,115 +1,115 @@
 // MIR for `address_of_reborrow` after SimplifyCfg-initial
 
 | User Type Annotations
-| 0: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address-of.rs:7:5: 7:18, inferred_ty: *const [i32; 10]
-| 1: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address-of.rs:9:5: 9:25, inferred_ty: *const dyn std::marker::Send
-| 2: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address-of.rs:13:12: 13:20, inferred_ty: *const [i32; 10]
-| 3: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address-of.rs:13:12: 13:20, inferred_ty: *const [i32; 10]
-| 4: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address-of.rs:14:12: 14:28, inferred_ty: *const [i32; 10]
-| 5: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address-of.rs:14:12: 14:28, inferred_ty: *const [i32; 10]
-| 6: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address-of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send
-| 7: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address-of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send
-| 8: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address-of.rs:16:12: 16:24, inferred_ty: *const [i32]
-| 9: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address-of.rs:16:12: 16:24, inferred_ty: *const [i32]
-| 10: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address-of.rs:18:5: 18:18, inferred_ty: *const [i32; 10]
-| 11: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address-of.rs:20:5: 20:25, inferred_ty: *const dyn std::marker::Send
-| 12: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address-of.rs:23:12: 23:20, inferred_ty: *const [i32; 10]
-| 13: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address-of.rs:23:12: 23:20, inferred_ty: *const [i32; 10]
-| 14: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address-of.rs:24:12: 24:28, inferred_ty: *const [i32; 10]
-| 15: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address-of.rs:24:12: 24:28, inferred_ty: *const [i32; 10]
-| 16: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address-of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send
-| 17: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address-of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send
-| 18: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address-of.rs:26:12: 26:24, inferred_ty: *const [i32]
-| 19: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address-of.rs:26:12: 26:24, inferred_ty: *const [i32]
-| 20: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address-of.rs:28:5: 28:16, inferred_ty: *mut [i32; 10]
-| 21: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address-of.rs:30:5: 30:23, inferred_ty: *mut dyn std::marker::Send
-| 22: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address-of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10]
-| 23: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address-of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10]
-| 24: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) }, span: $DIR/address-of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10]
-| 25: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) }, span: $DIR/address-of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10]
-| 26: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address-of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send
-| 27: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address-of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send
-| 28: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) }, span: $DIR/address-of.rs:36:12: 36:22, inferred_ty: *mut [i32]
-| 29: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) }, span: $DIR/address-of.rs:36:12: 36:22, inferred_ty: *mut [i32]
+| 0: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:7:5: 7:18, inferred_ty: *const [i32; 10]
+| 1: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:9:5: 9:25, inferred_ty: *const dyn std::marker::Send
+| 2: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:13:12: 13:20, inferred_ty: *const [i32; 10]
+| 3: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:13:12: 13:20, inferred_ty: *const [i32; 10]
+| 4: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address_of.rs:14:12: 14:28, inferred_ty: *const [i32; 10]
+| 5: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address_of.rs:14:12: 14:28, inferred_ty: *const [i32; 10]
+| 6: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send
+| 7: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send
+| 8: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address_of.rs:16:12: 16:24, inferred_ty: *const [i32]
+| 9: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address_of.rs:16:12: 16:24, inferred_ty: *const [i32]
+| 10: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:18:5: 18:18, inferred_ty: *const [i32; 10]
+| 11: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:20:5: 20:25, inferred_ty: *const dyn std::marker::Send
+| 12: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:23:12: 23:20, inferred_ty: *const [i32; 10]
+| 13: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:23:12: 23:20, inferred_ty: *const [i32; 10]
+| 14: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address_of.rs:24:12: 24:28, inferred_ty: *const [i32; 10]
+| 15: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address_of.rs:24:12: 24:28, inferred_ty: *const [i32; 10]
+| 16: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send
+| 17: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send
+| 18: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address_of.rs:26:12: 26:24, inferred_ty: *const [i32]
+| 19: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address_of.rs:26:12: 26:24, inferred_ty: *const [i32]
+| 20: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address_of.rs:28:5: 28:16, inferred_ty: *mut [i32; 10]
+| 21: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address_of.rs:30:5: 30:23, inferred_ty: *mut dyn std::marker::Send
+| 22: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address_of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10]
+| 23: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address_of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10]
+| 24: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) }, span: $DIR/address_of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10]
+| 25: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) }, span: $DIR/address_of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10]
+| 26: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address_of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send
+| 27: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address_of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send
+| 28: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) }, span: $DIR/address_of.rs:36:12: 36:22, inferred_ty: *mut [i32]
+| 29: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) }, span: $DIR/address_of.rs:36:12: 36:22, inferred_ty: *mut [i32]
 |
 fn address_of_reborrow() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/address-of.rs:+0:26: +0:26
-    let _1: &[i32; 10];                  // in scope 0 at $DIR/address-of.rs:+1:9: +1:10
-    let _2: [i32; 10];                   // in scope 0 at $DIR/address-of.rs:+1:14: +1:21
-    let mut _4: [i32; 10];               // in scope 0 at $DIR/address-of.rs:+2:22: +2:29
-    let _5: *const [i32; 10];            // in scope 0 at $DIR/address-of.rs:+4:5: +4:18
-    let mut _6: *const [i32; 10];        // in scope 0 at $DIR/address-of.rs:+4:5: +4:18
-    let _7: *const [i32; 10];            // in scope 0 at $DIR/address-of.rs:+5:5: +5:26
-    let _8: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:+6:5: +6:25
-    let mut _9: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:+6:5: +6:25
-    let mut _10: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:+6:5: +6:6
-    let _11: *const [i32];               // in scope 0 at $DIR/address-of.rs:+7:5: +7:22
-    let mut _12: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:+7:5: +7:6
-    let _13: *const i32;                 // in scope 0 at $DIR/address-of.rs:+8:5: +8:20
-    let mut _14: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:+8:5: +8:6
-    let mut _18: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:+12:30: +12:31
-    let mut _20: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:+13:27: +13:28
-    let _21: *const [i32; 10];           // in scope 0 at $DIR/address-of.rs:+15:5: +15:18
-    let mut _22: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:+15:5: +15:18
-    let _23: *const [i32; 10];           // in scope 0 at $DIR/address-of.rs:+16:5: +16:26
-    let _24: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:+17:5: +17:25
-    let mut _25: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:+17:5: +17:25
-    let mut _26: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:+17:5: +17:6
-    let _27: *const [i32];               // in scope 0 at $DIR/address-of.rs:+18:5: +18:22
-    let mut _28: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:+18:5: +18:6
-    let mut _32: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:+22:30: +22:31
-    let mut _34: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:+23:27: +23:28
-    let _35: *mut [i32; 10];             // in scope 0 at $DIR/address-of.rs:+25:5: +25:16
-    let mut _36: *mut [i32; 10];         // in scope 0 at $DIR/address-of.rs:+25:5: +25:16
-    let _37: *mut [i32; 10];             // in scope 0 at $DIR/address-of.rs:+26:5: +26:24
-    let _38: *mut dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:+27:5: +27:23
-    let mut _39: *mut dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:+27:5: +27:23
-    let mut _40: *mut [i32; 10];         // in scope 0 at $DIR/address-of.rs:+27:5: +27:6
-    let _41: *mut [i32];                 // in scope 0 at $DIR/address-of.rs:+28:5: +28:20
-    let mut _42: *mut [i32; 10];         // in scope 0 at $DIR/address-of.rs:+28:5: +28:6
-    let mut _46: *mut [i32; 10];         // in scope 0 at $DIR/address-of.rs:+32:28: +32:29
-    let mut _48: *mut [i32; 10];         // in scope 0 at $DIR/address-of.rs:+33:25: +33:26
+    let mut _0: ();                      // return place in scope 0 at $DIR/address_of.rs:+0:26: +0:26
+    let _1: &[i32; 10];                  // in scope 0 at $DIR/address_of.rs:+1:9: +1:10
+    let _2: [i32; 10];                   // in scope 0 at $DIR/address_of.rs:+1:14: +1:21
+    let mut _4: [i32; 10];               // in scope 0 at $DIR/address_of.rs:+2:22: +2:29
+    let _5: *const [i32; 10];            // in scope 0 at $DIR/address_of.rs:+4:5: +4:18
+    let mut _6: *const [i32; 10];        // in scope 0 at $DIR/address_of.rs:+4:5: +4:18
+    let _7: *const [i32; 10];            // in scope 0 at $DIR/address_of.rs:+5:5: +5:26
+    let _8: *const dyn std::marker::Send; // in scope 0 at $DIR/address_of.rs:+6:5: +6:25
+    let mut _9: *const dyn std::marker::Send; // in scope 0 at $DIR/address_of.rs:+6:5: +6:25
+    let mut _10: *const [i32; 10];       // in scope 0 at $DIR/address_of.rs:+6:5: +6:6
+    let _11: *const [i32];               // in scope 0 at $DIR/address_of.rs:+7:5: +7:22
+    let mut _12: *const [i32; 10];       // in scope 0 at $DIR/address_of.rs:+7:5: +7:6
+    let _13: *const i32;                 // in scope 0 at $DIR/address_of.rs:+8:5: +8:20
+    let mut _14: *const [i32; 10];       // in scope 0 at $DIR/address_of.rs:+8:5: +8:6
+    let mut _18: *const [i32; 10];       // in scope 0 at $DIR/address_of.rs:+12:30: +12:31
+    let mut _20: *const [i32; 10];       // in scope 0 at $DIR/address_of.rs:+13:27: +13:28
+    let _21: *const [i32; 10];           // in scope 0 at $DIR/address_of.rs:+15:5: +15:18
+    let mut _22: *const [i32; 10];       // in scope 0 at $DIR/address_of.rs:+15:5: +15:18
+    let _23: *const [i32; 10];           // in scope 0 at $DIR/address_of.rs:+16:5: +16:26
+    let _24: *const dyn std::marker::Send; // in scope 0 at $DIR/address_of.rs:+17:5: +17:25
+    let mut _25: *const dyn std::marker::Send; // in scope 0 at $DIR/address_of.rs:+17:5: +17:25
+    let mut _26: *const [i32; 10];       // in scope 0 at $DIR/address_of.rs:+17:5: +17:6
+    let _27: *const [i32];               // in scope 0 at $DIR/address_of.rs:+18:5: +18:22
+    let mut _28: *const [i32; 10];       // in scope 0 at $DIR/address_of.rs:+18:5: +18:6
+    let mut _32: *const [i32; 10];       // in scope 0 at $DIR/address_of.rs:+22:30: +22:31
+    let mut _34: *const [i32; 10];       // in scope 0 at $DIR/address_of.rs:+23:27: +23:28
+    let _35: *mut [i32; 10];             // in scope 0 at $DIR/address_of.rs:+25:5: +25:16
+    let mut _36: *mut [i32; 10];         // in scope 0 at $DIR/address_of.rs:+25:5: +25:16
+    let _37: *mut [i32; 10];             // in scope 0 at $DIR/address_of.rs:+26:5: +26:24
+    let _38: *mut dyn std::marker::Send; // in scope 0 at $DIR/address_of.rs:+27:5: +27:23
+    let mut _39: *mut dyn std::marker::Send; // in scope 0 at $DIR/address_of.rs:+27:5: +27:23
+    let mut _40: *mut [i32; 10];         // in scope 0 at $DIR/address_of.rs:+27:5: +27:6
+    let _41: *mut [i32];                 // in scope 0 at $DIR/address_of.rs:+28:5: +28:20
+    let mut _42: *mut [i32; 10];         // in scope 0 at $DIR/address_of.rs:+28:5: +28:6
+    let mut _46: *mut [i32; 10];         // in scope 0 at $DIR/address_of.rs:+32:28: +32:29
+    let mut _48: *mut [i32; 10];         // in scope 0 at $DIR/address_of.rs:+33:25: +33:26
     scope 1 {
-        debug y => _1;                   // in scope 1 at $DIR/address-of.rs:+1:9: +1:10
-        let mut _3: &mut [i32; 10];      // in scope 1 at $DIR/address-of.rs:+2:9: +2:14
+        debug y => _1;                   // in scope 1 at $DIR/address_of.rs:+1:9: +1:10
+        let mut _3: &mut [i32; 10];      // in scope 1 at $DIR/address_of.rs:+2:9: +2:14
         scope 2 {
-            debug z => _3;               // in scope 2 at $DIR/address-of.rs:+2:9: +2:14
-            let _15: *const [i32; 10] as UserTypeProjection { base: UserType(2), projs: [] }; // in scope 2 at $DIR/address-of.rs:+10:9: +10:10
+            debug z => _3;               // in scope 2 at $DIR/address_of.rs:+2:9: +2:14
+            let _15: *const [i32; 10] as UserTypeProjection { base: UserType(2), projs: [] }; // in scope 2 at $DIR/address_of.rs:+10:9: +10:10
             scope 3 {
-                debug p => _15;          // in scope 3 at $DIR/address-of.rs:+10:9: +10:10
-                let _16: *const [i32; 10] as UserTypeProjection { base: UserType(4), projs: [] }; // in scope 3 at $DIR/address-of.rs:+11:9: +11:10
+                debug p => _15;          // in scope 3 at $DIR/address_of.rs:+10:9: +10:10
+                let _16: *const [i32; 10] as UserTypeProjection { base: UserType(4), projs: [] }; // in scope 3 at $DIR/address_of.rs:+11:9: +11:10
                 scope 4 {
-                    debug p => _16;      // in scope 4 at $DIR/address-of.rs:+11:9: +11:10
-                    let _17: *const dyn std::marker::Send as UserTypeProjection { base: UserType(6), projs: [] }; // in scope 4 at $DIR/address-of.rs:+12:9: +12:10
+                    debug p => _16;      // in scope 4 at $DIR/address_of.rs:+11:9: +11:10
+                    let _17: *const dyn std::marker::Send as UserTypeProjection { base: UserType(6), projs: [] }; // in scope 4 at $DIR/address_of.rs:+12:9: +12:10
                     scope 5 {
-                        debug p => _17;  // in scope 5 at $DIR/address-of.rs:+12:9: +12:10
-                        let _19: *const [i32] as UserTypeProjection { base: UserType(8), projs: [] }; // in scope 5 at $DIR/address-of.rs:+13:9: +13:10
+                        debug p => _17;  // in scope 5 at $DIR/address_of.rs:+12:9: +12:10
+                        let _19: *const [i32] as UserTypeProjection { base: UserType(8), projs: [] }; // in scope 5 at $DIR/address_of.rs:+13:9: +13:10
                         scope 6 {
-                            debug p => _19; // in scope 6 at $DIR/address-of.rs:+13:9: +13:10
-                            let _29: *const [i32; 10] as UserTypeProjection { base: UserType(12), projs: [] }; // in scope 6 at $DIR/address-of.rs:+20:9: +20:10
+                            debug p => _19; // in scope 6 at $DIR/address_of.rs:+13:9: +13:10
+                            let _29: *const [i32; 10] as UserTypeProjection { base: UserType(12), projs: [] }; // in scope 6 at $DIR/address_of.rs:+20:9: +20:10
                             scope 7 {
-                                debug p => _29; // in scope 7 at $DIR/address-of.rs:+20:9: +20:10
-                                let _30: *const [i32; 10] as UserTypeProjection { base: UserType(14), projs: [] }; // in scope 7 at $DIR/address-of.rs:+21:9: +21:10
+                                debug p => _29; // in scope 7 at $DIR/address_of.rs:+20:9: +20:10
+                                let _30: *const [i32; 10] as UserTypeProjection { base: UserType(14), projs: [] }; // in scope 7 at $DIR/address_of.rs:+21:9: +21:10
                                 scope 8 {
-                                    debug p => _30; // in scope 8 at $DIR/address-of.rs:+21:9: +21:10
-                                    let _31: *const dyn std::marker::Send as UserTypeProjection { base: UserType(16), projs: [] }; // in scope 8 at $DIR/address-of.rs:+22:9: +22:10
+                                    debug p => _30; // in scope 8 at $DIR/address_of.rs:+21:9: +21:10
+                                    let _31: *const dyn std::marker::Send as UserTypeProjection { base: UserType(16), projs: [] }; // in scope 8 at $DIR/address_of.rs:+22:9: +22:10
                                     scope 9 {
-                                        debug p => _31; // in scope 9 at $DIR/address-of.rs:+22:9: +22:10
-                                        let _33: *const [i32] as UserTypeProjection { base: UserType(18), projs: [] }; // in scope 9 at $DIR/address-of.rs:+23:9: +23:10
+                                        debug p => _31; // in scope 9 at $DIR/address_of.rs:+22:9: +22:10
+                                        let _33: *const [i32] as UserTypeProjection { base: UserType(18), projs: [] }; // in scope 9 at $DIR/address_of.rs:+23:9: +23:10
                                         scope 10 {
-                                            debug p => _33; // in scope 10 at $DIR/address-of.rs:+23:9: +23:10
-                                            let _43: *mut [i32; 10] as UserTypeProjection { base: UserType(22), projs: [] }; // in scope 10 at $DIR/address-of.rs:+30:9: +30:10
+                                            debug p => _33; // in scope 10 at $DIR/address_of.rs:+23:9: +23:10
+                                            let _43: *mut [i32; 10] as UserTypeProjection { base: UserType(22), projs: [] }; // in scope 10 at $DIR/address_of.rs:+30:9: +30:10
                                             scope 11 {
-                                                debug p => _43; // in scope 11 at $DIR/address-of.rs:+30:9: +30:10
-                                                let _44: *mut [i32; 10] as UserTypeProjection { base: UserType(24), projs: [] }; // in scope 11 at $DIR/address-of.rs:+31:9: +31:10
+                                                debug p => _43; // in scope 11 at $DIR/address_of.rs:+30:9: +30:10
+                                                let _44: *mut [i32; 10] as UserTypeProjection { base: UserType(24), projs: [] }; // in scope 11 at $DIR/address_of.rs:+31:9: +31:10
                                                 scope 12 {
-                                                    debug p => _44; // in scope 12 at $DIR/address-of.rs:+31:9: +31:10
-                                                    let _45: *mut dyn std::marker::Send as UserTypeProjection { base: UserType(26), projs: [] }; // in scope 12 at $DIR/address-of.rs:+32:9: +32:10
+                                                    debug p => _44; // in scope 12 at $DIR/address_of.rs:+31:9: +31:10
+                                                    let _45: *mut dyn std::marker::Send as UserTypeProjection { base: UserType(26), projs: [] }; // in scope 12 at $DIR/address_of.rs:+32:9: +32:10
                                                     scope 13 {
-                                                        debug p => _45; // in scope 13 at $DIR/address-of.rs:+32:9: +32:10
-                                                        let _47: *mut [i32] as UserTypeProjection { base: UserType(28), projs: [] }; // in scope 13 at $DIR/address-of.rs:+33:9: +33:10
+                                                        debug p => _45; // in scope 13 at $DIR/address_of.rs:+32:9: +32:10
+                                                        let _47: *mut [i32] as UserTypeProjection { base: UserType(28), projs: [] }; // in scope 13 at $DIR/address_of.rs:+33:9: +33:10
                                                         scope 14 {
-                                                            debug p => _47; // in scope 14 at $DIR/address-of.rs:+33:9: +33:10
+                                                            debug p => _47; // in scope 14 at $DIR/address_of.rs:+33:9: +33:10
                                                         }
                                                     }
                                                 }
@@ -126,183 +126,183 @@ fn address_of_reborrow() -> () {
     }
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/address-of.rs:+1:9: +1:10
-        StorageLive(_2);                 // scope 0 at $DIR/address-of.rs:+1:14: +1:21
-        _2 = [const 0_i32; 10];          // scope 0 at $DIR/address-of.rs:+1:14: +1:21
-        _1 = &_2;                        // scope 0 at $DIR/address-of.rs:+1:13: +1:21
-        FakeRead(ForLet(None), _1);      // scope 0 at $DIR/address-of.rs:+1:9: +1:10
-        StorageLive(_3);                 // scope 1 at $DIR/address-of.rs:+2:9: +2:14
-        StorageLive(_4);                 // scope 1 at $DIR/address-of.rs:+2:22: +2:29
-        _4 = [const 0_i32; 10];          // scope 1 at $DIR/address-of.rs:+2:22: +2:29
-        _3 = &mut _4;                    // scope 1 at $DIR/address-of.rs:+2:17: +2:29
-        FakeRead(ForLet(None), _3);      // scope 1 at $DIR/address-of.rs:+2:9: +2:14
-        StorageLive(_5);                 // scope 2 at $DIR/address-of.rs:+4:5: +4:18
-        StorageLive(_6);                 // scope 2 at $DIR/address-of.rs:+4:5: +4:18
-        _6 = &raw const (*_1);           // scope 2 at $DIR/address-of.rs:+4:5: +4:6
-        AscribeUserType(_6, o, UserTypeProjection { base: UserType(0), projs: [] }); // scope 2 at $DIR/address-of.rs:+4:5: +4:18
-        _5 = _6;                         // scope 2 at $DIR/address-of.rs:+4:5: +4:18
-        StorageDead(_6);                 // scope 2 at $DIR/address-of.rs:+4:18: +4:19
-        StorageDead(_5);                 // scope 2 at $DIR/address-of.rs:+4:18: +4:19
-        StorageLive(_7);                 // scope 2 at $DIR/address-of.rs:+5:5: +5:26
-        _7 = &raw const (*_1);           // scope 2 at $DIR/address-of.rs:+5:5: +5:6
-        StorageDead(_7);                 // scope 2 at $DIR/address-of.rs:+5:26: +5:27
-        StorageLive(_8);                 // scope 2 at $DIR/address-of.rs:+6:5: +6:25
-        StorageLive(_9);                 // scope 2 at $DIR/address-of.rs:+6:5: +6:25
-        StorageLive(_10);                // scope 2 at $DIR/address-of.rs:+6:5: +6:6
-        _10 = &raw const (*_1);          // scope 2 at $DIR/address-of.rs:+6:5: +6:6
-        _9 = move _10 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 2 at $DIR/address-of.rs:+6:5: +6:6
-        StorageDead(_10);                // scope 2 at $DIR/address-of.rs:+6:5: +6:6
-        AscribeUserType(_9, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 2 at $DIR/address-of.rs:+6:5: +6:25
-        _8 = _9;                         // scope 2 at $DIR/address-of.rs:+6:5: +6:25
-        StorageDead(_9);                 // scope 2 at $DIR/address-of.rs:+6:25: +6:26
-        StorageDead(_8);                 // scope 2 at $DIR/address-of.rs:+6:25: +6:26
-        StorageLive(_11);                // scope 2 at $DIR/address-of.rs:+7:5: +7:22
-        StorageLive(_12);                // scope 2 at $DIR/address-of.rs:+7:5: +7:6
-        _12 = &raw const (*_1);          // scope 2 at $DIR/address-of.rs:+7:5: +7:6
-        _11 = move _12 as *const [i32] (Pointer(Unsize)); // scope 2 at $DIR/address-of.rs:+7:5: +7:6
-        StorageDead(_12);                // scope 2 at $DIR/address-of.rs:+7:5: +7:6
-        StorageDead(_11);                // scope 2 at $DIR/address-of.rs:+7:22: +7:23
-        StorageLive(_13);                // scope 2 at $DIR/address-of.rs:+8:5: +8:20
-        StorageLive(_14);                // scope 2 at $DIR/address-of.rs:+8:5: +8:6
-        _14 = &raw const (*_1);          // scope 2 at $DIR/address-of.rs:+8:5: +8:6
-        _13 = move _14 as *const i32 (Pointer(ArrayToPointer)); // scope 2 at $DIR/address-of.rs:+8:5: +8:20
-        StorageDead(_14);                // scope 2 at $DIR/address-of.rs:+8:19: +8:20
-        StorageDead(_13);                // scope 2 at $DIR/address-of.rs:+8:20: +8:21
-        StorageLive(_15);                // scope 2 at $DIR/address-of.rs:+10:9: +10:10
-        _15 = &raw const (*_1);          // scope 2 at $DIR/address-of.rs:+10:23: +10:24
-        FakeRead(ForLet(None), _15);     // scope 2 at $DIR/address-of.rs:+10:9: +10:10
-        AscribeUserType(_15, o, UserTypeProjection { base: UserType(3), projs: [] }); // scope 2 at $DIR/address-of.rs:+10:12: +10:20
-        StorageLive(_16);                // scope 3 at $DIR/address-of.rs:+11:9: +11:10
-        _16 = &raw const (*_1);          // scope 3 at $DIR/address-of.rs:+11:31: +11:32
-        FakeRead(ForLet(None), _16);     // scope 3 at $DIR/address-of.rs:+11:9: +11:10
-        AscribeUserType(_16, o, UserTypeProjection { base: UserType(5), projs: [] }); // scope 3 at $DIR/address-of.rs:+11:12: +11:28
-        StorageLive(_17);                // scope 4 at $DIR/address-of.rs:+12:9: +12:10
-        StorageLive(_18);                // scope 4 at $DIR/address-of.rs:+12:30: +12:31
-        _18 = &raw const (*_1);          // scope 4 at $DIR/address-of.rs:+12:30: +12:31
-        _17 = move _18 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 4 at $DIR/address-of.rs:+12:30: +12:31
-        StorageDead(_18);                // scope 4 at $DIR/address-of.rs:+12:30: +12:31
-        FakeRead(ForLet(None), _17);     // scope 4 at $DIR/address-of.rs:+12:9: +12:10
-        AscribeUserType(_17, o, UserTypeProjection { base: UserType(7), projs: [] }); // scope 4 at $DIR/address-of.rs:+12:12: +12:27
-        StorageLive(_19);                // scope 5 at $DIR/address-of.rs:+13:9: +13:10
-        StorageLive(_20);                // scope 5 at $DIR/address-of.rs:+13:27: +13:28
-        _20 = &raw const (*_1);          // scope 5 at $DIR/address-of.rs:+13:27: +13:28
-        _19 = move _20 as *const [i32] (Pointer(Unsize)); // scope 5 at $DIR/address-of.rs:+13:27: +13:28
-        StorageDead(_20);                // scope 5 at $DIR/address-of.rs:+13:27: +13:28
-        FakeRead(ForLet(None), _19);     // scope 5 at $DIR/address-of.rs:+13:9: +13:10
-        AscribeUserType(_19, o, UserTypeProjection { base: UserType(9), projs: [] }); // scope 5 at $DIR/address-of.rs:+13:12: +13:24
-        StorageLive(_21);                // scope 6 at $DIR/address-of.rs:+15:5: +15:18
-        StorageLive(_22);                // scope 6 at $DIR/address-of.rs:+15:5: +15:18
-        _22 = &raw const (*_3);          // scope 6 at $DIR/address-of.rs:+15:5: +15:6
-        AscribeUserType(_22, o, UserTypeProjection { base: UserType(10), projs: [] }); // scope 6 at $DIR/address-of.rs:+15:5: +15:18
-        _21 = _22;                       // scope 6 at $DIR/address-of.rs:+15:5: +15:18
-        StorageDead(_22);                // scope 6 at $DIR/address-of.rs:+15:18: +15:19
-        StorageDead(_21);                // scope 6 at $DIR/address-of.rs:+15:18: +15:19
-        StorageLive(_23);                // scope 6 at $DIR/address-of.rs:+16:5: +16:26
-        _23 = &raw const (*_3);          // scope 6 at $DIR/address-of.rs:+16:5: +16:6
-        StorageDead(_23);                // scope 6 at $DIR/address-of.rs:+16:26: +16:27
-        StorageLive(_24);                // scope 6 at $DIR/address-of.rs:+17:5: +17:25
-        StorageLive(_25);                // scope 6 at $DIR/address-of.rs:+17:5: +17:25
-        StorageLive(_26);                // scope 6 at $DIR/address-of.rs:+17:5: +17:6
-        _26 = &raw const (*_3);          // scope 6 at $DIR/address-of.rs:+17:5: +17:6
-        _25 = move _26 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 6 at $DIR/address-of.rs:+17:5: +17:6
-        StorageDead(_26);                // scope 6 at $DIR/address-of.rs:+17:5: +17:6
-        AscribeUserType(_25, o, UserTypeProjection { base: UserType(11), projs: [] }); // scope 6 at $DIR/address-of.rs:+17:5: +17:25
-        _24 = _25;                       // scope 6 at $DIR/address-of.rs:+17:5: +17:25
-        StorageDead(_25);                // scope 6 at $DIR/address-of.rs:+17:25: +17:26
-        StorageDead(_24);                // scope 6 at $DIR/address-of.rs:+17:25: +17:26
-        StorageLive(_27);                // scope 6 at $DIR/address-of.rs:+18:5: +18:22
-        StorageLive(_28);                // scope 6 at $DIR/address-of.rs:+18:5: +18:6
-        _28 = &raw const (*_3);          // scope 6 at $DIR/address-of.rs:+18:5: +18:6
-        _27 = move _28 as *const [i32] (Pointer(Unsize)); // scope 6 at $DIR/address-of.rs:+18:5: +18:6
-        StorageDead(_28);                // scope 6 at $DIR/address-of.rs:+18:5: +18:6
-        StorageDead(_27);                // scope 6 at $DIR/address-of.rs:+18:22: +18:23
-        StorageLive(_29);                // scope 6 at $DIR/address-of.rs:+20:9: +20:10
-        _29 = &raw const (*_3);          // scope 6 at $DIR/address-of.rs:+20:23: +20:24
-        FakeRead(ForLet(None), _29);     // scope 6 at $DIR/address-of.rs:+20:9: +20:10
-        AscribeUserType(_29, o, UserTypeProjection { base: UserType(13), projs: [] }); // scope 6 at $DIR/address-of.rs:+20:12: +20:20
-        StorageLive(_30);                // scope 7 at $DIR/address-of.rs:+21:9: +21:10
-        _30 = &raw const (*_3);          // scope 7 at $DIR/address-of.rs:+21:31: +21:32
-        FakeRead(ForLet(None), _30);     // scope 7 at $DIR/address-of.rs:+21:9: +21:10
-        AscribeUserType(_30, o, UserTypeProjection { base: UserType(15), projs: [] }); // scope 7 at $DIR/address-of.rs:+21:12: +21:28
-        StorageLive(_31);                // scope 8 at $DIR/address-of.rs:+22:9: +22:10
-        StorageLive(_32);                // scope 8 at $DIR/address-of.rs:+22:30: +22:31
-        _32 = &raw const (*_3);          // scope 8 at $DIR/address-of.rs:+22:30: +22:31
-        _31 = move _32 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 8 at $DIR/address-of.rs:+22:30: +22:31
-        StorageDead(_32);                // scope 8 at $DIR/address-of.rs:+22:30: +22:31
-        FakeRead(ForLet(None), _31);     // scope 8 at $DIR/address-of.rs:+22:9: +22:10
-        AscribeUserType(_31, o, UserTypeProjection { base: UserType(17), projs: [] }); // scope 8 at $DIR/address-of.rs:+22:12: +22:27
-        StorageLive(_33);                // scope 9 at $DIR/address-of.rs:+23:9: +23:10
-        StorageLive(_34);                // scope 9 at $DIR/address-of.rs:+23:27: +23:28
-        _34 = &raw const (*_3);          // scope 9 at $DIR/address-of.rs:+23:27: +23:28
-        _33 = move _34 as *const [i32] (Pointer(Unsize)); // scope 9 at $DIR/address-of.rs:+23:27: +23:28
-        StorageDead(_34);                // scope 9 at $DIR/address-of.rs:+23:27: +23:28
-        FakeRead(ForLet(None), _33);     // scope 9 at $DIR/address-of.rs:+23:9: +23:10
-        AscribeUserType(_33, o, UserTypeProjection { base: UserType(19), projs: [] }); // scope 9 at $DIR/address-of.rs:+23:12: +23:24
-        StorageLive(_35);                // scope 10 at $DIR/address-of.rs:+25:5: +25:16
-        StorageLive(_36);                // scope 10 at $DIR/address-of.rs:+25:5: +25:16
-        _36 = &raw mut (*_3);            // scope 10 at $DIR/address-of.rs:+25:5: +25:6
-        AscribeUserType(_36, o, UserTypeProjection { base: UserType(20), projs: [] }); // scope 10 at $DIR/address-of.rs:+25:5: +25:16
-        _35 = _36;                       // scope 10 at $DIR/address-of.rs:+25:5: +25:16
-        StorageDead(_36);                // scope 10 at $DIR/address-of.rs:+25:16: +25:17
-        StorageDead(_35);                // scope 10 at $DIR/address-of.rs:+25:16: +25:17
-        StorageLive(_37);                // scope 10 at $DIR/address-of.rs:+26:5: +26:24
-        _37 = &raw mut (*_3);            // scope 10 at $DIR/address-of.rs:+26:5: +26:6
-        StorageDead(_37);                // scope 10 at $DIR/address-of.rs:+26:24: +26:25
-        StorageLive(_38);                // scope 10 at $DIR/address-of.rs:+27:5: +27:23
-        StorageLive(_39);                // scope 10 at $DIR/address-of.rs:+27:5: +27:23
-        StorageLive(_40);                // scope 10 at $DIR/address-of.rs:+27:5: +27:6
-        _40 = &raw mut (*_3);            // scope 10 at $DIR/address-of.rs:+27:5: +27:6
-        _39 = move _40 as *mut dyn std::marker::Send (Pointer(Unsize)); // scope 10 at $DIR/address-of.rs:+27:5: +27:6
-        StorageDead(_40);                // scope 10 at $DIR/address-of.rs:+27:5: +27:6
-        AscribeUserType(_39, o, UserTypeProjection { base: UserType(21), projs: [] }); // scope 10 at $DIR/address-of.rs:+27:5: +27:23
-        _38 = _39;                       // scope 10 at $DIR/address-of.rs:+27:5: +27:23
-        StorageDead(_39);                // scope 10 at $DIR/address-of.rs:+27:23: +27:24
-        StorageDead(_38);                // scope 10 at $DIR/address-of.rs:+27:23: +27:24
-        StorageLive(_41);                // scope 10 at $DIR/address-of.rs:+28:5: +28:20
-        StorageLive(_42);                // scope 10 at $DIR/address-of.rs:+28:5: +28:6
-        _42 = &raw mut (*_3);            // scope 10 at $DIR/address-of.rs:+28:5: +28:6
-        _41 = move _42 as *mut [i32] (Pointer(Unsize)); // scope 10 at $DIR/address-of.rs:+28:5: +28:6
-        StorageDead(_42);                // scope 10 at $DIR/address-of.rs:+28:5: +28:6
-        StorageDead(_41);                // scope 10 at $DIR/address-of.rs:+28:20: +28:21
-        StorageLive(_43);                // scope 10 at $DIR/address-of.rs:+30:9: +30:10
-        _43 = &raw mut (*_3);            // scope 10 at $DIR/address-of.rs:+30:21: +30:22
-        FakeRead(ForLet(None), _43);     // scope 10 at $DIR/address-of.rs:+30:9: +30:10
-        AscribeUserType(_43, o, UserTypeProjection { base: UserType(23), projs: [] }); // scope 10 at $DIR/address-of.rs:+30:12: +30:18
-        StorageLive(_44);                // scope 11 at $DIR/address-of.rs:+31:9: +31:10
-        _44 = &raw mut (*_3);            // scope 11 at $DIR/address-of.rs:+31:29: +31:30
-        FakeRead(ForLet(None), _44);     // scope 11 at $DIR/address-of.rs:+31:9: +31:10
-        AscribeUserType(_44, o, UserTypeProjection { base: UserType(25), projs: [] }); // scope 11 at $DIR/address-of.rs:+31:12: +31:26
-        StorageLive(_45);                // scope 12 at $DIR/address-of.rs:+32:9: +32:10
-        StorageLive(_46);                // scope 12 at $DIR/address-of.rs:+32:28: +32:29
-        _46 = &raw mut (*_3);            // scope 12 at $DIR/address-of.rs:+32:28: +32:29
-        _45 = move _46 as *mut dyn std::marker::Send (Pointer(Unsize)); // scope 12 at $DIR/address-of.rs:+32:28: +32:29
-        StorageDead(_46);                // scope 12 at $DIR/address-of.rs:+32:28: +32:29
-        FakeRead(ForLet(None), _45);     // scope 12 at $DIR/address-of.rs:+32:9: +32:10
-        AscribeUserType(_45, o, UserTypeProjection { base: UserType(27), projs: [] }); // scope 12 at $DIR/address-of.rs:+32:12: +32:25
-        StorageLive(_47);                // scope 13 at $DIR/address-of.rs:+33:9: +33:10
-        StorageLive(_48);                // scope 13 at $DIR/address-of.rs:+33:25: +33:26
-        _48 = &raw mut (*_3);            // scope 13 at $DIR/address-of.rs:+33:25: +33:26
-        _47 = move _48 as *mut [i32] (Pointer(Unsize)); // scope 13 at $DIR/address-of.rs:+33:25: +33:26
-        StorageDead(_48);                // scope 13 at $DIR/address-of.rs:+33:25: +33:26
-        FakeRead(ForLet(None), _47);     // scope 13 at $DIR/address-of.rs:+33:9: +33:10
-        AscribeUserType(_47, o, UserTypeProjection { base: UserType(29), projs: [] }); // scope 13 at $DIR/address-of.rs:+33:12: +33:22
-        _0 = const ();                   // scope 0 at $DIR/address-of.rs:+0:26: +34:2
-        StorageDead(_47);                // scope 13 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_45);                // scope 12 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_44);                // scope 11 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_43);                // scope 10 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_33);                // scope 9 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_31);                // scope 8 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_30);                // scope 7 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_29);                // scope 6 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_19);                // scope 5 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_17);                // scope 4 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_16);                // scope 3 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_15);                // scope 2 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_4);                 // scope 1 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_3);                 // scope 1 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_2);                 // scope 0 at $DIR/address-of.rs:+34:1: +34:2
-        StorageDead(_1);                 // scope 0 at $DIR/address-of.rs:+34:1: +34:2
-        return;                          // scope 0 at $DIR/address-of.rs:+34:2: +34:2
+        StorageLive(_1);                 // scope 0 at $DIR/address_of.rs:+1:9: +1:10
+        StorageLive(_2);                 // scope 0 at $DIR/address_of.rs:+1:14: +1:21
+        _2 = [const 0_i32; 10];          // scope 0 at $DIR/address_of.rs:+1:14: +1:21
+        _1 = &_2;                        // scope 0 at $DIR/address_of.rs:+1:13: +1:21
+        FakeRead(ForLet(None), _1);      // scope 0 at $DIR/address_of.rs:+1:9: +1:10
+        StorageLive(_3);                 // scope 1 at $DIR/address_of.rs:+2:9: +2:14
+        StorageLive(_4);                 // scope 1 at $DIR/address_of.rs:+2:22: +2:29
+        _4 = [const 0_i32; 10];          // scope 1 at $DIR/address_of.rs:+2:22: +2:29
+        _3 = &mut _4;                    // scope 1 at $DIR/address_of.rs:+2:17: +2:29
+        FakeRead(ForLet(None), _3);      // scope 1 at $DIR/address_of.rs:+2:9: +2:14
+        StorageLive(_5);                 // scope 2 at $DIR/address_of.rs:+4:5: +4:18
+        StorageLive(_6);                 // scope 2 at $DIR/address_of.rs:+4:5: +4:18
+        _6 = &raw const (*_1);           // scope 2 at $DIR/address_of.rs:+4:5: +4:6
+        AscribeUserType(_6, o, UserTypeProjection { base: UserType(0), projs: [] }); // scope 2 at $DIR/address_of.rs:+4:5: +4:18
+        _5 = _6;                         // scope 2 at $DIR/address_of.rs:+4:5: +4:18
+        StorageDead(_6);                 // scope 2 at $DIR/address_of.rs:+4:18: +4:19
+        StorageDead(_5);                 // scope 2 at $DIR/address_of.rs:+4:18: +4:19
+        StorageLive(_7);                 // scope 2 at $DIR/address_of.rs:+5:5: +5:26
+        _7 = &raw const (*_1);           // scope 2 at $DIR/address_of.rs:+5:5: +5:6
+        StorageDead(_7);                 // scope 2 at $DIR/address_of.rs:+5:26: +5:27
+        StorageLive(_8);                 // scope 2 at $DIR/address_of.rs:+6:5: +6:25
+        StorageLive(_9);                 // scope 2 at $DIR/address_of.rs:+6:5: +6:25
+        StorageLive(_10);                // scope 2 at $DIR/address_of.rs:+6:5: +6:6
+        _10 = &raw const (*_1);          // scope 2 at $DIR/address_of.rs:+6:5: +6:6
+        _9 = move _10 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 2 at $DIR/address_of.rs:+6:5: +6:6
+        StorageDead(_10);                // scope 2 at $DIR/address_of.rs:+6:5: +6:6
+        AscribeUserType(_9, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 2 at $DIR/address_of.rs:+6:5: +6:25
+        _8 = _9;                         // scope 2 at $DIR/address_of.rs:+6:5: +6:25
+        StorageDead(_9);                 // scope 2 at $DIR/address_of.rs:+6:25: +6:26
+        StorageDead(_8);                 // scope 2 at $DIR/address_of.rs:+6:25: +6:26
+        StorageLive(_11);                // scope 2 at $DIR/address_of.rs:+7:5: +7:22
+        StorageLive(_12);                // scope 2 at $DIR/address_of.rs:+7:5: +7:6
+        _12 = &raw const (*_1);          // scope 2 at $DIR/address_of.rs:+7:5: +7:6
+        _11 = move _12 as *const [i32] (Pointer(Unsize)); // scope 2 at $DIR/address_of.rs:+7:5: +7:6
+        StorageDead(_12);                // scope 2 at $DIR/address_of.rs:+7:5: +7:6
+        StorageDead(_11);                // scope 2 at $DIR/address_of.rs:+7:22: +7:23
+        StorageLive(_13);                // scope 2 at $DIR/address_of.rs:+8:5: +8:20
+        StorageLive(_14);                // scope 2 at $DIR/address_of.rs:+8:5: +8:6
+        _14 = &raw const (*_1);          // scope 2 at $DIR/address_of.rs:+8:5: +8:6
+        _13 = move _14 as *const i32 (Pointer(ArrayToPointer)); // scope 2 at $DIR/address_of.rs:+8:5: +8:20
+        StorageDead(_14);                // scope 2 at $DIR/address_of.rs:+8:19: +8:20
+        StorageDead(_13);                // scope 2 at $DIR/address_of.rs:+8:20: +8:21
+        StorageLive(_15);                // scope 2 at $DIR/address_of.rs:+10:9: +10:10
+        _15 = &raw const (*_1);          // scope 2 at $DIR/address_of.rs:+10:23: +10:24
+        FakeRead(ForLet(None), _15);     // scope 2 at $DIR/address_of.rs:+10:9: +10:10
+        AscribeUserType(_15, o, UserTypeProjection { base: UserType(3), projs: [] }); // scope 2 at $DIR/address_of.rs:+10:12: +10:20
+        StorageLive(_16);                // scope 3 at $DIR/address_of.rs:+11:9: +11:10
+        _16 = &raw const (*_1);          // scope 3 at $DIR/address_of.rs:+11:31: +11:32
+        FakeRead(ForLet(None), _16);     // scope 3 at $DIR/address_of.rs:+11:9: +11:10
+        AscribeUserType(_16, o, UserTypeProjection { base: UserType(5), projs: [] }); // scope 3 at $DIR/address_of.rs:+11:12: +11:28
+        StorageLive(_17);                // scope 4 at $DIR/address_of.rs:+12:9: +12:10
+        StorageLive(_18);                // scope 4 at $DIR/address_of.rs:+12:30: +12:31
+        _18 = &raw const (*_1);          // scope 4 at $DIR/address_of.rs:+12:30: +12:31
+        _17 = move _18 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 4 at $DIR/address_of.rs:+12:30: +12:31
+        StorageDead(_18);                // scope 4 at $DIR/address_of.rs:+12:30: +12:31
+        FakeRead(ForLet(None), _17);     // scope 4 at $DIR/address_of.rs:+12:9: +12:10
+        AscribeUserType(_17, o, UserTypeProjection { base: UserType(7), projs: [] }); // scope 4 at $DIR/address_of.rs:+12:12: +12:27
+        StorageLive(_19);                // scope 5 at $DIR/address_of.rs:+13:9: +13:10
+        StorageLive(_20);                // scope 5 at $DIR/address_of.rs:+13:27: +13:28
+        _20 = &raw const (*_1);          // scope 5 at $DIR/address_of.rs:+13:27: +13:28
+        _19 = move _20 as *const [i32] (Pointer(Unsize)); // scope 5 at $DIR/address_of.rs:+13:27: +13:28
+        StorageDead(_20);                // scope 5 at $DIR/address_of.rs:+13:27: +13:28
+        FakeRead(ForLet(None), _19);     // scope 5 at $DIR/address_of.rs:+13:9: +13:10
+        AscribeUserType(_19, o, UserTypeProjection { base: UserType(9), projs: [] }); // scope 5 at $DIR/address_of.rs:+13:12: +13:24
+        StorageLive(_21);                // scope 6 at $DIR/address_of.rs:+15:5: +15:18
+        StorageLive(_22);                // scope 6 at $DIR/address_of.rs:+15:5: +15:18
+        _22 = &raw const (*_3);          // scope 6 at $DIR/address_of.rs:+15:5: +15:6
+        AscribeUserType(_22, o, UserTypeProjection { base: UserType(10), projs: [] }); // scope 6 at $DIR/address_of.rs:+15:5: +15:18
+        _21 = _22;                       // scope 6 at $DIR/address_of.rs:+15:5: +15:18
+        StorageDead(_22);                // scope 6 at $DIR/address_of.rs:+15:18: +15:19
+        StorageDead(_21);                // scope 6 at $DIR/address_of.rs:+15:18: +15:19
+        StorageLive(_23);                // scope 6 at $DIR/address_of.rs:+16:5: +16:26
+        _23 = &raw const (*_3);          // scope 6 at $DIR/address_of.rs:+16:5: +16:6
+        StorageDead(_23);                // scope 6 at $DIR/address_of.rs:+16:26: +16:27
+        StorageLive(_24);                // scope 6 at $DIR/address_of.rs:+17:5: +17:25
+        StorageLive(_25);                // scope 6 at $DIR/address_of.rs:+17:5: +17:25
+        StorageLive(_26);                // scope 6 at $DIR/address_of.rs:+17:5: +17:6
+        _26 = &raw const (*_3);          // scope 6 at $DIR/address_of.rs:+17:5: +17:6
+        _25 = move _26 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 6 at $DIR/address_of.rs:+17:5: +17:6
+        StorageDead(_26);                // scope 6 at $DIR/address_of.rs:+17:5: +17:6
+        AscribeUserType(_25, o, UserTypeProjection { base: UserType(11), projs: [] }); // scope 6 at $DIR/address_of.rs:+17:5: +17:25
+        _24 = _25;                       // scope 6 at $DIR/address_of.rs:+17:5: +17:25
+        StorageDead(_25);                // scope 6 at $DIR/address_of.rs:+17:25: +17:26
+        StorageDead(_24);                // scope 6 at $DIR/address_of.rs:+17:25: +17:26
+        StorageLive(_27);                // scope 6 at $DIR/address_of.rs:+18:5: +18:22
+        StorageLive(_28);                // scope 6 at $DIR/address_of.rs:+18:5: +18:6
+        _28 = &raw const (*_3);          // scope 6 at $DIR/address_of.rs:+18:5: +18:6
+        _27 = move _28 as *const [i32] (Pointer(Unsize)); // scope 6 at $DIR/address_of.rs:+18:5: +18:6
+        StorageDead(_28);                // scope 6 at $DIR/address_of.rs:+18:5: +18:6
+        StorageDead(_27);                // scope 6 at $DIR/address_of.rs:+18:22: +18:23
+        StorageLive(_29);                // scope 6 at $DIR/address_of.rs:+20:9: +20:10
+        _29 = &raw const (*_3);          // scope 6 at $DIR/address_of.rs:+20:23: +20:24
+        FakeRead(ForLet(None), _29);     // scope 6 at $DIR/address_of.rs:+20:9: +20:10
+        AscribeUserType(_29, o, UserTypeProjection { base: UserType(13), projs: [] }); // scope 6 at $DIR/address_of.rs:+20:12: +20:20
+        StorageLive(_30);                // scope 7 at $DIR/address_of.rs:+21:9: +21:10
+        _30 = &raw const (*_3);          // scope 7 at $DIR/address_of.rs:+21:31: +21:32
+        FakeRead(ForLet(None), _30);     // scope 7 at $DIR/address_of.rs:+21:9: +21:10
+        AscribeUserType(_30, o, UserTypeProjection { base: UserType(15), projs: [] }); // scope 7 at $DIR/address_of.rs:+21:12: +21:28
+        StorageLive(_31);                // scope 8 at $DIR/address_of.rs:+22:9: +22:10
+        StorageLive(_32);                // scope 8 at $DIR/address_of.rs:+22:30: +22:31
+        _32 = &raw const (*_3);          // scope 8 at $DIR/address_of.rs:+22:30: +22:31
+        _31 = move _32 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 8 at $DIR/address_of.rs:+22:30: +22:31
+        StorageDead(_32);                // scope 8 at $DIR/address_of.rs:+22:30: +22:31
+        FakeRead(ForLet(None), _31);     // scope 8 at $DIR/address_of.rs:+22:9: +22:10
+        AscribeUserType(_31, o, UserTypeProjection { base: UserType(17), projs: [] }); // scope 8 at $DIR/address_of.rs:+22:12: +22:27
+        StorageLive(_33);                // scope 9 at $DIR/address_of.rs:+23:9: +23:10
+        StorageLive(_34);                // scope 9 at $DIR/address_of.rs:+23:27: +23:28
+        _34 = &raw const (*_3);          // scope 9 at $DIR/address_of.rs:+23:27: +23:28
+        _33 = move _34 as *const [i32] (Pointer(Unsize)); // scope 9 at $DIR/address_of.rs:+23:27: +23:28
+        StorageDead(_34);                // scope 9 at $DIR/address_of.rs:+23:27: +23:28
+        FakeRead(ForLet(None), _33);     // scope 9 at $DIR/address_of.rs:+23:9: +23:10
+        AscribeUserType(_33, o, UserTypeProjection { base: UserType(19), projs: [] }); // scope 9 at $DIR/address_of.rs:+23:12: +23:24
+        StorageLive(_35);                // scope 10 at $DIR/address_of.rs:+25:5: +25:16
+        StorageLive(_36);                // scope 10 at $DIR/address_of.rs:+25:5: +25:16
+        _36 = &raw mut (*_3);            // scope 10 at $DIR/address_of.rs:+25:5: +25:6
+        AscribeUserType(_36, o, UserTypeProjection { base: UserType(20), projs: [] }); // scope 10 at $DIR/address_of.rs:+25:5: +25:16
+        _35 = _36;                       // scope 10 at $DIR/address_of.rs:+25:5: +25:16
+        StorageDead(_36);                // scope 10 at $DIR/address_of.rs:+25:16: +25:17
+        StorageDead(_35);                // scope 10 at $DIR/address_of.rs:+25:16: +25:17
+        StorageLive(_37);                // scope 10 at $DIR/address_of.rs:+26:5: +26:24
+        _37 = &raw mut (*_3);            // scope 10 at $DIR/address_of.rs:+26:5: +26:6
+        StorageDead(_37);                // scope 10 at $DIR/address_of.rs:+26:24: +26:25
+        StorageLive(_38);                // scope 10 at $DIR/address_of.rs:+27:5: +27:23
+        StorageLive(_39);                // scope 10 at $DIR/address_of.rs:+27:5: +27:23
+        StorageLive(_40);                // scope 10 at $DIR/address_of.rs:+27:5: +27:6
+        _40 = &raw mut (*_3);            // scope 10 at $DIR/address_of.rs:+27:5: +27:6
+        _39 = move _40 as *mut dyn std::marker::Send (Pointer(Unsize)); // scope 10 at $DIR/address_of.rs:+27:5: +27:6
+        StorageDead(_40);                // scope 10 at $DIR/address_of.rs:+27:5: +27:6
+        AscribeUserType(_39, o, UserTypeProjection { base: UserType(21), projs: [] }); // scope 10 at $DIR/address_of.rs:+27:5: +27:23
+        _38 = _39;                       // scope 10 at $DIR/address_of.rs:+27:5: +27:23
+        StorageDead(_39);                // scope 10 at $DIR/address_of.rs:+27:23: +27:24
+        StorageDead(_38);                // scope 10 at $DIR/address_of.rs:+27:23: +27:24
+        StorageLive(_41);                // scope 10 at $DIR/address_of.rs:+28:5: +28:20
+        StorageLive(_42);                // scope 10 at $DIR/address_of.rs:+28:5: +28:6
+        _42 = &raw mut (*_3);            // scope 10 at $DIR/address_of.rs:+28:5: +28:6
+        _41 = move _42 as *mut [i32] (Pointer(Unsize)); // scope 10 at $DIR/address_of.rs:+28:5: +28:6
+        StorageDead(_42);                // scope 10 at $DIR/address_of.rs:+28:5: +28:6
+        StorageDead(_41);                // scope 10 at $DIR/address_of.rs:+28:20: +28:21
+        StorageLive(_43);                // scope 10 at $DIR/address_of.rs:+30:9: +30:10
+        _43 = &raw mut (*_3);            // scope 10 at $DIR/address_of.rs:+30:21: +30:22
+        FakeRead(ForLet(None), _43);     // scope 10 at $DIR/address_of.rs:+30:9: +30:10
+        AscribeUserType(_43, o, UserTypeProjection { base: UserType(23), projs: [] }); // scope 10 at $DIR/address_of.rs:+30:12: +30:18
+        StorageLive(_44);                // scope 11 at $DIR/address_of.rs:+31:9: +31:10
+        _44 = &raw mut (*_3);            // scope 11 at $DIR/address_of.rs:+31:29: +31:30
+        FakeRead(ForLet(None), _44);     // scope 11 at $DIR/address_of.rs:+31:9: +31:10
+        AscribeUserType(_44, o, UserTypeProjection { base: UserType(25), projs: [] }); // scope 11 at $DIR/address_of.rs:+31:12: +31:26
+        StorageLive(_45);                // scope 12 at $DIR/address_of.rs:+32:9: +32:10
+        StorageLive(_46);                // scope 12 at $DIR/address_of.rs:+32:28: +32:29
+        _46 = &raw mut (*_3);            // scope 12 at $DIR/address_of.rs:+32:28: +32:29
+        _45 = move _46 as *mut dyn std::marker::Send (Pointer(Unsize)); // scope 12 at $DIR/address_of.rs:+32:28: +32:29
+        StorageDead(_46);                // scope 12 at $DIR/address_of.rs:+32:28: +32:29
+        FakeRead(ForLet(None), _45);     // scope 12 at $DIR/address_of.rs:+32:9: +32:10
+        AscribeUserType(_45, o, UserTypeProjection { base: UserType(27), projs: [] }); // scope 12 at $DIR/address_of.rs:+32:12: +32:25
+        StorageLive(_47);                // scope 13 at $DIR/address_of.rs:+33:9: +33:10
+        StorageLive(_48);                // scope 13 at $DIR/address_of.rs:+33:25: +33:26
+        _48 = &raw mut (*_3);            // scope 13 at $DIR/address_of.rs:+33:25: +33:26
+        _47 = move _48 as *mut [i32] (Pointer(Unsize)); // scope 13 at $DIR/address_of.rs:+33:25: +33:26
+        StorageDead(_48);                // scope 13 at $DIR/address_of.rs:+33:25: +33:26
+        FakeRead(ForLet(None), _47);     // scope 13 at $DIR/address_of.rs:+33:9: +33:10
+        AscribeUserType(_47, o, UserTypeProjection { base: UserType(29), projs: [] }); // scope 13 at $DIR/address_of.rs:+33:12: +33:22
+        _0 = const ();                   // scope 0 at $DIR/address_of.rs:+0:26: +34:2
+        StorageDead(_47);                // scope 13 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_45);                // scope 12 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_44);                // scope 11 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_43);                // scope 10 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_33);                // scope 9 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_31);                // scope 8 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_30);                // scope 7 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_29);                // scope 6 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_19);                // scope 5 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_17);                // scope 4 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_16);                // scope 3 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_15);                // scope 2 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_4);                 // scope 1 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_3);                 // scope 1 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_2);                 // scope 0 at $DIR/address_of.rs:+34:1: +34:2
+        StorageDead(_1);                 // scope 0 at $DIR/address_of.rs:+34:1: +34:2
+        return;                          // scope 0 at $DIR/address_of.rs:+34:2: +34:2
     }
 }
diff --git a/src/test/mir-opt/address_of.borrow_and_cast.SimplifyCfg-initial.after.mir b/src/test/mir-opt/address_of.borrow_and_cast.SimplifyCfg-initial.after.mir
index 060077b8adb..4c67376b56a 100644
--- a/src/test/mir-opt/address_of.borrow_and_cast.SimplifyCfg-initial.after.mir
+++ b/src/test/mir-opt/address_of.borrow_and_cast.SimplifyCfg-initial.after.mir
@@ -1,47 +1,47 @@
 // MIR for `borrow_and_cast` after SimplifyCfg-initial
 
 fn borrow_and_cast(_1: i32) -> () {
-    debug x => _1;                       // in scope 0 at $DIR/address-of.rs:+0:20: +0:25
-    let mut _0: ();                      // return place in scope 0 at $DIR/address-of.rs:+0:32: +0:32
-    let _2: *const i32;                  // in scope 0 at $DIR/address-of.rs:+1:9: +1:10
-    let _3: &i32;                        // in scope 0 at $DIR/address-of.rs:+1:13: +1:15
-    let _5: &mut i32;                    // in scope 0 at $DIR/address-of.rs:+2:13: +2:19
-    let mut _7: &mut i32;                // in scope 0 at $DIR/address-of.rs:+3:13: +3:19
+    debug x => _1;                       // in scope 0 at $DIR/address_of.rs:+0:20: +0:25
+    let mut _0: ();                      // return place in scope 0 at $DIR/address_of.rs:+0:32: +0:32
+    let _2: *const i32;                  // in scope 0 at $DIR/address_of.rs:+1:9: +1:10
+    let _3: &i32;                        // in scope 0 at $DIR/address_of.rs:+1:13: +1:15
+    let _5: &mut i32;                    // in scope 0 at $DIR/address_of.rs:+2:13: +2:19
+    let mut _7: &mut i32;                // in scope 0 at $DIR/address_of.rs:+3:13: +3:19
     scope 1 {
-        debug p => _2;                   // in scope 1 at $DIR/address-of.rs:+1:9: +1:10
-        let _4: *const i32;              // in scope 1 at $DIR/address-of.rs:+2:9: +2:10
+        debug p => _2;                   // in scope 1 at $DIR/address_of.rs:+1:9: +1:10
+        let _4: *const i32;              // in scope 1 at $DIR/address_of.rs:+2:9: +2:10
         scope 2 {
-            debug q => _4;               // in scope 2 at $DIR/address-of.rs:+2:9: +2:10
-            let _6: *mut i32;            // in scope 2 at $DIR/address-of.rs:+3:9: +3:10
+            debug q => _4;               // in scope 2 at $DIR/address_of.rs:+2:9: +2:10
+            let _6: *mut i32;            // in scope 2 at $DIR/address_of.rs:+3:9: +3:10
             scope 3 {
-                debug r => _6;           // in scope 3 at $DIR/address-of.rs:+3:9: +3:10
+                debug r => _6;           // in scope 3 at $DIR/address_of.rs:+3:9: +3:10
             }
         }
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/address-of.rs:+1:9: +1:10
-        StorageLive(_3);                 // scope 0 at $DIR/address-of.rs:+1:13: +1:15
-        _3 = &_1;                        // scope 0 at $DIR/address-of.rs:+1:13: +1:15
-        _2 = &raw const (*_3);           // scope 0 at $DIR/address-of.rs:+1:13: +1:15
-        FakeRead(ForLet(None), _2);      // scope 0 at $DIR/address-of.rs:+1:9: +1:10
-        StorageDead(_3);                 // scope 0 at $DIR/address-of.rs:+1:29: +1:30
-        StorageLive(_4);                 // scope 1 at $DIR/address-of.rs:+2:9: +2:10
-        StorageLive(_5);                 // scope 1 at $DIR/address-of.rs:+2:13: +2:19
-        _5 = &mut _1;                    // scope 1 at $DIR/address-of.rs:+2:13: +2:19
-        _4 = &raw const (*_5);           // scope 1 at $DIR/address-of.rs:+2:13: +2:19
-        FakeRead(ForLet(None), _4);      // scope 1 at $DIR/address-of.rs:+2:9: +2:10
-        StorageDead(_5);                 // scope 1 at $DIR/address-of.rs:+2:33: +2:34
-        StorageLive(_6);                 // scope 2 at $DIR/address-of.rs:+3:9: +3:10
-        StorageLive(_7);                 // scope 2 at $DIR/address-of.rs:+3:13: +3:19
-        _7 = &mut _1;                    // scope 2 at $DIR/address-of.rs:+3:13: +3:19
-        _6 = &raw mut (*_7);             // scope 2 at $DIR/address-of.rs:+3:13: +3:19
-        FakeRead(ForLet(None), _6);      // scope 2 at $DIR/address-of.rs:+3:9: +3:10
-        StorageDead(_7);                 // scope 2 at $DIR/address-of.rs:+3:31: +3:32
-        _0 = const ();                   // scope 0 at $DIR/address-of.rs:+0:32: +4:2
-        StorageDead(_6);                 // scope 2 at $DIR/address-of.rs:+4:1: +4:2
-        StorageDead(_4);                 // scope 1 at $DIR/address-of.rs:+4:1: +4:2
-        StorageDead(_2);                 // scope 0 at $DIR/address-of.rs:+4:1: +4:2
-        return;                          // scope 0 at $DIR/address-of.rs:+4:2: +4:2
+        StorageLive(_2);                 // scope 0 at $DIR/address_of.rs:+1:9: +1:10
+        StorageLive(_3);                 // scope 0 at $DIR/address_of.rs:+1:13: +1:15
+        _3 = &_1;                        // scope 0 at $DIR/address_of.rs:+1:13: +1:15
+        _2 = &raw const (*_3);           // scope 0 at $DIR/address_of.rs:+1:13: +1:15
+        FakeRead(ForLet(None), _2);      // scope 0 at $DIR/address_of.rs:+1:9: +1:10
+        StorageDead(_3);                 // scope 0 at $DIR/address_of.rs:+1:29: +1:30
+        StorageLive(_4);                 // scope 1 at $DIR/address_of.rs:+2:9: +2:10
+        StorageLive(_5);                 // scope 1 at $DIR/address_of.rs:+2:13: +2:19
+        _5 = &mut _1;                    // scope 1 at $DIR/address_of.rs:+2:13: +2:19
+        _4 = &raw const (*_5);           // scope 1 at $DIR/address_of.rs:+2:13: +2:19
+        FakeRead(ForLet(None), _4);      // scope 1 at $DIR/address_of.rs:+2:9: +2:10
+        StorageDead(_5);                 // scope 1 at $DIR/address_of.rs:+2:33: +2:34
+        StorageLive(_6);                 // scope 2 at $DIR/address_of.rs:+3:9: +3:10
+        StorageLive(_7);                 // scope 2 at $DIR/address_of.rs:+3:13: +3:19
+        _7 = &mut _1;                    // scope 2 at $DIR/address_of.rs:+3:13: +3:19
+        _6 = &raw mut (*_7);             // scope 2 at $DIR/address_of.rs:+3:13: +3:19
+        FakeRead(ForLet(None), _6);      // scope 2 at $DIR/address_of.rs:+3:9: +3:10
+        StorageDead(_7);                 // scope 2 at $DIR/address_of.rs:+3:31: +3:32
+        _0 = const ();                   // scope 0 at $DIR/address_of.rs:+0:32: +4:2
+        StorageDead(_6);                 // scope 2 at $DIR/address_of.rs:+4:1: +4:2
+        StorageDead(_4);                 // scope 1 at $DIR/address_of.rs:+4:1: +4:2
+        StorageDead(_2);                 // scope 0 at $DIR/address_of.rs:+4:1: +4:2
+        return;                          // scope 0 at $DIR/address_of.rs:+4:2: +4:2
     }
 }
diff --git a/src/test/mir-opt/address-of.rs b/src/test/mir-opt/address_of.rs
similarity index 100%
rename from src/test/mir-opt/address-of.rs
rename to src/test/mir-opt/address_of.rs
diff --git a/src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir
index 27f883ed321..af5178d4079 100644
--- a/src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir
+++ b/src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir
@@ -1,22 +1,22 @@
 // MIR for `main` after SimplifyCfg-elaborate-drops
 
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/array-index-is-temporary.rs:+0:11: +0:11
-    let mut _1: [u32; 3];                // in scope 0 at $DIR/array-index-is-temporary.rs:+1:9: +1:14
-    let mut _4: &mut usize;              // in scope 0 at $DIR/array-index-is-temporary.rs:+3:25: +3:31
-    let mut _5: u32;                     // in scope 0 at $DIR/array-index-is-temporary.rs:+4:12: +4:29
-    let mut _6: *mut usize;              // in scope 0 at $DIR/array-index-is-temporary.rs:+4:25: +4:26
-    let _7: usize;                       // in scope 0 at $DIR/array-index-is-temporary.rs:+4:7: +4:8
-    let mut _8: usize;                   // in scope 0 at $DIR/array-index-is-temporary.rs:+4:5: +4:9
-    let mut _9: bool;                    // in scope 0 at $DIR/array-index-is-temporary.rs:+4:5: +4:9
+    let mut _0: ();                      // return place in scope 0 at $DIR/array_index_is_temporary.rs:+0:11: +0:11
+    let mut _1: [u32; 3];                // in scope 0 at $DIR/array_index_is_temporary.rs:+1:9: +1:14
+    let mut _4: &mut usize;              // in scope 0 at $DIR/array_index_is_temporary.rs:+3:25: +3:31
+    let mut _5: u32;                     // in scope 0 at $DIR/array_index_is_temporary.rs:+4:12: +4:29
+    let mut _6: *mut usize;              // in scope 0 at $DIR/array_index_is_temporary.rs:+4:25: +4:26
+    let _7: usize;                       // in scope 0 at $DIR/array_index_is_temporary.rs:+4:7: +4:8
+    let mut _8: usize;                   // in scope 0 at $DIR/array_index_is_temporary.rs:+4:5: +4:9
+    let mut _9: bool;                    // in scope 0 at $DIR/array_index_is_temporary.rs:+4:5: +4:9
     scope 1 {
-        debug x => _1;                   // in scope 1 at $DIR/array-index-is-temporary.rs:+1:9: +1:14
-        let mut _2: usize;               // in scope 1 at $DIR/array-index-is-temporary.rs:+2:9: +2:14
+        debug x => _1;                   // in scope 1 at $DIR/array_index_is_temporary.rs:+1:9: +1:14
+        let mut _2: usize;               // in scope 1 at $DIR/array_index_is_temporary.rs:+2:9: +2:14
         scope 2 {
-            debug y => _2;               // in scope 2 at $DIR/array-index-is-temporary.rs:+2:9: +2:14
-            let _3: *mut usize;          // in scope 2 at $DIR/array-index-is-temporary.rs:+3:9: +3:10
+            debug y => _2;               // in scope 2 at $DIR/array_index_is_temporary.rs:+2:9: +2:14
+            let _3: *mut usize;          // in scope 2 at $DIR/array_index_is_temporary.rs:+3:9: +3:10
             scope 3 {
-                debug z => _3;           // in scope 3 at $DIR/array-index-is-temporary.rs:+3:9: +3:10
+                debug z => _3;           // in scope 3 at $DIR/array_index_is_temporary.rs:+3:9: +3:10
                 scope 4 {
                 }
             }
@@ -24,41 +24,41 @@ fn main() -> () {
     }
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/array-index-is-temporary.rs:+1:9: +1:14
-        _1 = [const 42_u32, const 43_u32, const 44_u32]; // scope 0 at $DIR/array-index-is-temporary.rs:+1:17: +1:29
-        StorageLive(_2);                 // scope 1 at $DIR/array-index-is-temporary.rs:+2:9: +2:14
-        _2 = const 1_usize;              // scope 1 at $DIR/array-index-is-temporary.rs:+2:17: +2:18
-        StorageLive(_3);                 // scope 2 at $DIR/array-index-is-temporary.rs:+3:9: +3:10
-        StorageLive(_4);                 // scope 2 at $DIR/array-index-is-temporary.rs:+3:25: +3:31
-        _4 = &mut _2;                    // scope 2 at $DIR/array-index-is-temporary.rs:+3:25: +3:31
-        _3 = &raw mut (*_4);             // scope 2 at $DIR/array-index-is-temporary.rs:+3:25: +3:31
-        StorageDead(_4);                 // scope 2 at $DIR/array-index-is-temporary.rs:+3:31: +3:32
-        StorageLive(_5);                 // scope 3 at $DIR/array-index-is-temporary.rs:+4:12: +4:29
-        StorageLive(_6);                 // scope 4 at $DIR/array-index-is-temporary.rs:+4:25: +4:26
-        _6 = _3;                         // scope 4 at $DIR/array-index-is-temporary.rs:+4:25: +4:26
-        _5 = foo(move _6) -> bb1;        // scope 4 at $DIR/array-index-is-temporary.rs:+4:21: +4:27
+        StorageLive(_1);                 // scope 0 at $DIR/array_index_is_temporary.rs:+1:9: +1:14
+        _1 = [const 42_u32, const 43_u32, const 44_u32]; // scope 0 at $DIR/array_index_is_temporary.rs:+1:17: +1:29
+        StorageLive(_2);                 // scope 1 at $DIR/array_index_is_temporary.rs:+2:9: +2:14
+        _2 = const 1_usize;              // scope 1 at $DIR/array_index_is_temporary.rs:+2:17: +2:18
+        StorageLive(_3);                 // scope 2 at $DIR/array_index_is_temporary.rs:+3:9: +3:10
+        StorageLive(_4);                 // scope 2 at $DIR/array_index_is_temporary.rs:+3:25: +3:31
+        _4 = &mut _2;                    // scope 2 at $DIR/array_index_is_temporary.rs:+3:25: +3:31
+        _3 = &raw mut (*_4);             // scope 2 at $DIR/array_index_is_temporary.rs:+3:25: +3:31
+        StorageDead(_4);                 // scope 2 at $DIR/array_index_is_temporary.rs:+3:31: +3:32
+        StorageLive(_5);                 // scope 3 at $DIR/array_index_is_temporary.rs:+4:12: +4:29
+        StorageLive(_6);                 // scope 4 at $DIR/array_index_is_temporary.rs:+4:25: +4:26
+        _6 = _3;                         // scope 4 at $DIR/array_index_is_temporary.rs:+4:25: +4:26
+        _5 = foo(move _6) -> bb1;        // scope 4 at $DIR/array_index_is_temporary.rs:+4:21: +4:27
                                          // mir::Constant
-                                         // + span: $DIR/array-index-is-temporary.rs:16:21: 16:24
+                                         // + span: $DIR/array_index_is_temporary.rs:16:21: 16:24
                                          // + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value() }
     }
 
     bb1: {
-        StorageDead(_6);                 // scope 4 at $DIR/array-index-is-temporary.rs:+4:26: +4:27
-        StorageLive(_7);                 // scope 3 at $DIR/array-index-is-temporary.rs:+4:7: +4:8
-        _7 = _2;                         // scope 3 at $DIR/array-index-is-temporary.rs:+4:7: +4:8
-        _8 = Len(_1);                    // scope 3 at $DIR/array-index-is-temporary.rs:+4:5: +4:9
-        _9 = Lt(_7, _8);                 // scope 3 at $DIR/array-index-is-temporary.rs:+4:5: +4:9
-        assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> bb2; // scope 3 at $DIR/array-index-is-temporary.rs:+4:5: +4:9
+        StorageDead(_6);                 // scope 4 at $DIR/array_index_is_temporary.rs:+4:26: +4:27
+        StorageLive(_7);                 // scope 3 at $DIR/array_index_is_temporary.rs:+4:7: +4:8
+        _7 = _2;                         // scope 3 at $DIR/array_index_is_temporary.rs:+4:7: +4:8
+        _8 = Len(_1);                    // scope 3 at $DIR/array_index_is_temporary.rs:+4:5: +4:9
+        _9 = Lt(_7, _8);                 // scope 3 at $DIR/array_index_is_temporary.rs:+4:5: +4:9
+        assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> bb2; // scope 3 at $DIR/array_index_is_temporary.rs:+4:5: +4:9
     }
 
     bb2: {
-        _1[_7] = move _5;                // scope 3 at $DIR/array-index-is-temporary.rs:+4:5: +4:29
-        StorageDead(_5);                 // scope 3 at $DIR/array-index-is-temporary.rs:+4:28: +4:29
-        StorageDead(_7);                 // scope 3 at $DIR/array-index-is-temporary.rs:+4:29: +4:30
-        _0 = const ();                   // scope 0 at $DIR/array-index-is-temporary.rs:+0:11: +5:2
-        StorageDead(_3);                 // scope 2 at $DIR/array-index-is-temporary.rs:+5:1: +5:2
-        StorageDead(_2);                 // scope 1 at $DIR/array-index-is-temporary.rs:+5:1: +5:2
-        StorageDead(_1);                 // scope 0 at $DIR/array-index-is-temporary.rs:+5:1: +5:2
-        return;                          // scope 0 at $DIR/array-index-is-temporary.rs:+5:2: +5:2
+        _1[_7] = move _5;                // scope 3 at $DIR/array_index_is_temporary.rs:+4:5: +4:29
+        StorageDead(_5);                 // scope 3 at $DIR/array_index_is_temporary.rs:+4:28: +4:29
+        StorageDead(_7);                 // scope 3 at $DIR/array_index_is_temporary.rs:+4:29: +4:30
+        _0 = const ();                   // scope 0 at $DIR/array_index_is_temporary.rs:+0:11: +5:2
+        StorageDead(_3);                 // scope 2 at $DIR/array_index_is_temporary.rs:+5:1: +5:2
+        StorageDead(_2);                 // scope 1 at $DIR/array_index_is_temporary.rs:+5:1: +5:2
+        StorageDead(_1);                 // scope 0 at $DIR/array_index_is_temporary.rs:+5:1: +5:2
+        return;                          // scope 0 at $DIR/array_index_is_temporary.rs:+5:2: +5:2
     }
 }
diff --git a/src/test/mir-opt/array-index-is-temporary.rs b/src/test/mir-opt/array_index_is_temporary.rs
similarity index 100%
rename from src/test/mir-opt/array-index-is-temporary.rs
rename to src/test/mir-opt/array_index_is_temporary.rs
diff --git a/src/test/mir-opt/building/issue_101867.main.built.after.mir b/src/test/mir-opt/building/issue_101867.main.built.after.mir
index 6834205b649..0ebd840cf2d 100644
--- a/src/test/mir-opt/building/issue_101867.main.built.after.mir
+++ b/src/test/mir-opt/building/issue_101867.main.built.after.mir
@@ -1,33 +1,33 @@
 // MIR for `main` after built
 
 | User Type Annotations
-| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option) }, span: $DIR/issue-101867.rs:3:12: 3:22, inferred_ty: std::option::Option
-| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option) }, span: $DIR/issue-101867.rs:3:12: 3:22, inferred_ty: std::option::Option
+| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option) }, span: $DIR/issue_101867.rs:3:12: 3:22, inferred_ty: std::option::Option
+| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option) }, span: $DIR/issue_101867.rs:3:12: 3:22, inferred_ty: std::option::Option
 |
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue-101867.rs:+0:11: +0:11
-    let _1: std::option::Option as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/issue-101867.rs:+1:9: +1:10
-    let mut _2: !;                       // in scope 0 at $DIR/issue-101867.rs:+2:26: +4:6
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue_101867.rs:+0:11: +0:11
+    let _1: std::option::Option as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/issue_101867.rs:+1:9: +1:10
+    let mut _2: !;                       // in scope 0 at $DIR/issue_101867.rs:+2:26: +4:6
     let _3: ();                          // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL
     let mut _4: !;                       // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL
-    let mut _6: isize;                   // in scope 0 at $DIR/issue-101867.rs:+2:9: +2:16
+    let mut _6: isize;                   // in scope 0 at $DIR/issue_101867.rs:+2:9: +2:16
     scope 1 {
-        debug x => _1;                   // in scope 1 at $DIR/issue-101867.rs:+1:9: +1:10
-        let _5: u8;                      // in scope 1 at $DIR/issue-101867.rs:+2:14: +2:15
+        debug x => _1;                   // in scope 1 at $DIR/issue_101867.rs:+1:9: +1:10
+        let _5: u8;                      // in scope 1 at $DIR/issue_101867.rs:+2:14: +2:15
         scope 2 {
-            debug y => _5;               // in scope 2 at $DIR/issue-101867.rs:+2:14: +2:15
+            debug y => _5;               // in scope 2 at $DIR/issue_101867.rs:+2:14: +2:15
         }
     }
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/issue-101867.rs:+1:9: +1:10
-        _1 = Option::::Some(const 1_u8); // scope 0 at $DIR/issue-101867.rs:+1:25: +1:32
-        FakeRead(ForLet(None), _1);      // scope 0 at $DIR/issue-101867.rs:+1:9: +1:10
-        AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/issue-101867.rs:+1:12: +1:22
-        StorageLive(_5);                 // scope 1 at $DIR/issue-101867.rs:+2:14: +2:15
-        FakeRead(ForMatchedPlace(None), _1); // scope 1 at $DIR/issue-101867.rs:+2:19: +2:20
-        _6 = discriminant(_1);           // scope 1 at $DIR/issue-101867.rs:+2:19: +2:20
-        switchInt(move _6) -> [1_isize: bb4, otherwise: bb3]; // scope 1 at $DIR/issue-101867.rs:+2:9: +2:16
+        StorageLive(_1);                 // scope 0 at $DIR/issue_101867.rs:+1:9: +1:10
+        _1 = Option::::Some(const 1_u8); // scope 0 at $DIR/issue_101867.rs:+1:25: +1:32
+        FakeRead(ForLet(None), _1);      // scope 0 at $DIR/issue_101867.rs:+1:9: +1:10
+        AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/issue_101867.rs:+1:12: +1:22
+        StorageLive(_5);                 // scope 1 at $DIR/issue_101867.rs:+2:14: +2:15
+        FakeRead(ForMatchedPlace(None), _1); // scope 1 at $DIR/issue_101867.rs:+2:19: +2:20
+        _6 = discriminant(_1);           // scope 1 at $DIR/issue_101867.rs:+2:19: +2:20
+        switchInt(move _6) -> [1_isize: bb4, otherwise: bb3]; // scope 1 at $DIR/issue_101867.rs:+2:9: +2:16
     }
 
     bb1: {
@@ -44,32 +44,32 @@ fn main() -> () {
 
     bb2: {
         StorageDead(_4);                 // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL
-        StorageDead(_3);                 // scope 1 at $DIR/issue-101867.rs:+3:16: +3:17
-        unreachable;                     // scope 1 at $DIR/issue-101867.rs:+2:26: +4:6
+        StorageDead(_3);                 // scope 1 at $DIR/issue_101867.rs:+3:16: +3:17
+        unreachable;                     // scope 1 at $DIR/issue_101867.rs:+2:26: +4:6
     }
 
     bb3: {
-        goto -> bb6;                     // scope 1 at $DIR/issue-101867.rs:+2:19: +2:20
+        goto -> bb6;                     // scope 1 at $DIR/issue_101867.rs:+2:19: +2:20
     }
 
     bb4: {
-        falseEdge -> [real: bb5, imaginary: bb3]; // scope 1 at $DIR/issue-101867.rs:+2:9: +2:16
+        falseEdge -> [real: bb5, imaginary: bb3]; // scope 1 at $DIR/issue_101867.rs:+2:9: +2:16
     }
 
     bb5: {
-        _5 = ((_1 as Some).0: u8);       // scope 1 at $DIR/issue-101867.rs:+2:14: +2:15
-        _0 = const ();                   // scope 0 at $DIR/issue-101867.rs:+0:11: +5:2
-        StorageDead(_5);                 // scope 1 at $DIR/issue-101867.rs:+5:1: +5:2
-        StorageDead(_1);                 // scope 0 at $DIR/issue-101867.rs:+5:1: +5:2
-        return;                          // scope 0 at $DIR/issue-101867.rs:+5:2: +5:2
+        _5 = ((_1 as Some).0: u8);       // scope 1 at $DIR/issue_101867.rs:+2:14: +2:15
+        _0 = const ();                   // scope 0 at $DIR/issue_101867.rs:+0:11: +5:2
+        StorageDead(_5);                 // scope 1 at $DIR/issue_101867.rs:+5:1: +5:2
+        StorageDead(_1);                 // scope 0 at $DIR/issue_101867.rs:+5:1: +5:2
+        return;                          // scope 0 at $DIR/issue_101867.rs:+5:2: +5:2
     }
 
     bb6: {
-        StorageDead(_5);                 // scope 1 at $DIR/issue-101867.rs:+5:1: +5:2
-        goto -> bb1;                     // scope 0 at $DIR/issue-101867.rs:+0:11: +5:2
+        StorageDead(_5);                 // scope 1 at $DIR/issue_101867.rs:+5:1: +5:2
+        goto -> bb1;                     // scope 0 at $DIR/issue_101867.rs:+0:11: +5:2
     }
 
     bb7 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-101867.rs:+0:1: +5:2
+        resume;                          // scope 0 at $DIR/issue_101867.rs:+0:1: +5:2
     }
 }
diff --git a/src/test/mir-opt/building/issue-101867.rs b/src/test/mir-opt/building/issue_101867.rs
similarity index 100%
rename from src/test/mir-opt/building/issue-101867.rs
rename to src/test/mir-opt/building/issue_101867.rs
diff --git a/src/test/mir-opt/building/issue_49232.main.built.after.mir b/src/test/mir-opt/building/issue_49232.main.built.after.mir
index b90f8c13589..9182bcaa21f 100644
--- a/src/test/mir-opt/building/issue_49232.main.built.after.mir
+++ b/src/test/mir-opt/building/issue_49232.main.built.after.mir
@@ -1,82 +1,82 @@
 // MIR for `main` after built
 
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue-49232.rs:+0:11: +0:11
-    let mut _1: ();                      // in scope 0 at $DIR/issue-49232.rs:+0:1: +10:2
-    let _2: i32;                         // in scope 0 at $DIR/issue-49232.rs:+2:13: +2:19
-    let mut _3: bool;                    // in scope 0 at $DIR/issue-49232.rs:+3:19: +3:23
-    let mut _4: !;                       // in scope 0 at $DIR/issue-49232.rs:+5:25: +5:30
-    let _5: ();                          // in scope 0 at $DIR/issue-49232.rs:+8:9: +8:22
-    let mut _6: &i32;                    // in scope 0 at $DIR/issue-49232.rs:+8:14: +8:21
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue_49232.rs:+0:11: +0:11
+    let mut _1: ();                      // in scope 0 at $DIR/issue_49232.rs:+0:1: +10:2
+    let _2: i32;                         // in scope 0 at $DIR/issue_49232.rs:+2:13: +2:19
+    let mut _3: bool;                    // in scope 0 at $DIR/issue_49232.rs:+3:19: +3:23
+    let mut _4: !;                       // in scope 0 at $DIR/issue_49232.rs:+5:25: +5:30
+    let _5: ();                          // in scope 0 at $DIR/issue_49232.rs:+8:9: +8:22
+    let mut _6: &i32;                    // in scope 0 at $DIR/issue_49232.rs:+8:14: +8:21
     scope 1 {
-        debug beacon => _2;              // in scope 1 at $DIR/issue-49232.rs:+2:13: +2:19
+        debug beacon => _2;              // in scope 1 at $DIR/issue_49232.rs:+2:13: +2:19
     }
 
     bb0: {
-        goto -> bb1;                     // scope 0 at $DIR/issue-49232.rs:+1:5: +9:6
+        goto -> bb1;                     // scope 0 at $DIR/issue_49232.rs:+1:5: +9:6
     }
 
     bb1: {
-        falseUnwind -> [real: bb2, cleanup: bb11]; // scope 0 at $DIR/issue-49232.rs:+1:5: +9:6
+        falseUnwind -> [real: bb2, cleanup: bb11]; // scope 0 at $DIR/issue_49232.rs:+1:5: +9:6
     }
 
     bb2: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-49232.rs:+2:13: +2:19
-        StorageLive(_3);                 // scope 0 at $DIR/issue-49232.rs:+3:19: +3:23
-        _3 = const true;                 // scope 0 at $DIR/issue-49232.rs:+3:19: +3:23
-        FakeRead(ForMatchedPlace(None), _3); // scope 0 at $DIR/issue-49232.rs:+3:19: +3:23
-        switchInt(_3) -> [false: bb3, otherwise: bb4]; // scope 0 at $DIR/issue-49232.rs:+3:13: +3:23
+        StorageLive(_2);                 // scope 0 at $DIR/issue_49232.rs:+2:13: +2:19
+        StorageLive(_3);                 // scope 0 at $DIR/issue_49232.rs:+3:19: +3:23
+        _3 = const true;                 // scope 0 at $DIR/issue_49232.rs:+3:19: +3:23
+        FakeRead(ForMatchedPlace(None), _3); // scope 0 at $DIR/issue_49232.rs:+3:19: +3:23
+        switchInt(_3) -> [false: bb3, otherwise: bb4]; // scope 0 at $DIR/issue_49232.rs:+3:13: +3:23
     }
 
     bb3: {
-        falseEdge -> [real: bb5, imaginary: bb4]; // scope 0 at $DIR/issue-49232.rs:+4:17: +4:22
+        falseEdge -> [real: bb5, imaginary: bb4]; // scope 0 at $DIR/issue_49232.rs:+4:17: +4:22
     }
 
     bb4: {
-        _0 = const ();                   // scope 0 at $DIR/issue-49232.rs:+5:25: +5:30
-        goto -> bb10;                    // scope 0 at $DIR/issue-49232.rs:+5:25: +5:30
+        _0 = const ();                   // scope 0 at $DIR/issue_49232.rs:+5:25: +5:30
+        goto -> bb10;                    // scope 0 at $DIR/issue_49232.rs:+5:25: +5:30
     }
 
     bb5: {
-        _2 = const 4_i32;                // scope 0 at $DIR/issue-49232.rs:+4:26: +4:27
-        goto -> bb8;                     // scope 0 at $DIR/issue-49232.rs:+4:26: +4:27
+        _2 = const 4_i32;                // scope 0 at $DIR/issue_49232.rs:+4:26: +4:27
+        goto -> bb8;                     // scope 0 at $DIR/issue_49232.rs:+4:26: +4:27
     }
 
     bb6: {
-        unreachable;                     // scope 0 at $DIR/issue-49232.rs:+5:25: +5:30
+        unreachable;                     // scope 0 at $DIR/issue_49232.rs:+5:25: +5:30
     }
 
     bb7: {
-        goto -> bb8;                     // scope 0 at $DIR/issue-49232.rs:+6:13: +6:14
+        goto -> bb8;                     // scope 0 at $DIR/issue_49232.rs:+6:13: +6:14
     }
 
     bb8: {
-        FakeRead(ForLet(None), _2);      // scope 0 at $DIR/issue-49232.rs:+2:13: +2:19
-        StorageDead(_3);                 // scope 0 at $DIR/issue-49232.rs:+7:10: +7:11
-        StorageLive(_5);                 // scope 1 at $DIR/issue-49232.rs:+8:9: +8:22
-        StorageLive(_6);                 // scope 1 at $DIR/issue-49232.rs:+8:14: +8:21
-        _6 = &_2;                        // scope 1 at $DIR/issue-49232.rs:+8:14: +8:21
-        _5 = std::mem::drop::<&i32>(move _6) -> [return: bb9, unwind: bb11]; // scope 1 at $DIR/issue-49232.rs:+8:9: +8:22
+        FakeRead(ForLet(None), _2);      // scope 0 at $DIR/issue_49232.rs:+2:13: +2:19
+        StorageDead(_3);                 // scope 0 at $DIR/issue_49232.rs:+7:10: +7:11
+        StorageLive(_5);                 // scope 1 at $DIR/issue_49232.rs:+8:9: +8:22
+        StorageLive(_6);                 // scope 1 at $DIR/issue_49232.rs:+8:14: +8:21
+        _6 = &_2;                        // scope 1 at $DIR/issue_49232.rs:+8:14: +8:21
+        _5 = std::mem::drop::<&i32>(move _6) -> [return: bb9, unwind: bb11]; // scope 1 at $DIR/issue_49232.rs:+8:9: +8:22
                                          // mir::Constant
-                                         // + span: $DIR/issue-49232.rs:13:9: 13:13
+                                         // + span: $DIR/issue_49232.rs:13:9: 13:13
                                          // + literal: Const { ty: fn(&i32) {std::mem::drop::<&i32>}, val: Value() }
     }
 
     bb9: {
-        StorageDead(_6);                 // scope 1 at $DIR/issue-49232.rs:+8:21: +8:22
-        StorageDead(_5);                 // scope 1 at $DIR/issue-49232.rs:+8:22: +8:23
-        _1 = const ();                   // scope 0 at $DIR/issue-49232.rs:+1:10: +9:6
-        StorageDead(_2);                 // scope 0 at $DIR/issue-49232.rs:+9:5: +9:6
-        goto -> bb1;                     // scope 0 at $DIR/issue-49232.rs:+1:5: +9:6
+        StorageDead(_6);                 // scope 1 at $DIR/issue_49232.rs:+8:21: +8:22
+        StorageDead(_5);                 // scope 1 at $DIR/issue_49232.rs:+8:22: +8:23
+        _1 = const ();                   // scope 0 at $DIR/issue_49232.rs:+1:10: +9:6
+        StorageDead(_2);                 // scope 0 at $DIR/issue_49232.rs:+9:5: +9:6
+        goto -> bb1;                     // scope 0 at $DIR/issue_49232.rs:+1:5: +9:6
     }
 
     bb10: {
-        StorageDead(_3);                 // scope 0 at $DIR/issue-49232.rs:+7:10: +7:11
-        StorageDead(_2);                 // scope 0 at $DIR/issue-49232.rs:+9:5: +9:6
-        return;                          // scope 0 at $DIR/issue-49232.rs:+10:2: +10:2
+        StorageDead(_3);                 // scope 0 at $DIR/issue_49232.rs:+7:10: +7:11
+        StorageDead(_2);                 // scope 0 at $DIR/issue_49232.rs:+9:5: +9:6
+        return;                          // scope 0 at $DIR/issue_49232.rs:+10:2: +10:2
     }
 
     bb11 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-49232.rs:+0:1: +10:2
+        resume;                          // scope 0 at $DIR/issue_49232.rs:+0:1: +10:2
     }
 }
diff --git a/src/test/mir-opt/building/issue-49232.rs b/src/test/mir-opt/building/issue_49232.rs
similarity index 100%
rename from src/test/mir-opt/building/issue-49232.rs
rename to src/test/mir-opt/building/issue_49232.rs
diff --git a/src/test/mir-opt/building/receiver_ptr_mutability.main.built.after.mir b/src/test/mir-opt/building/receiver_ptr_mutability.main.built.after.mir
index 0192bdc2d5e..41eb00363bd 100644
--- a/src/test/mir-opt/building/receiver_ptr_mutability.main.built.after.mir
+++ b/src/test/mir-opt/building/receiver_ptr_mutability.main.built.after.mir
@@ -1,96 +1,96 @@
 // MIR for `main` after built
 
 | User Type Annotations
-| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver-ptr-mutability.rs:14:14: 14:23, inferred_ty: *mut Test
-| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver-ptr-mutability.rs:14:14: 14:23, inferred_ty: *mut Test
-| 2: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: Ty(&&&&*mut Test) }, span: $DIR/receiver-ptr-mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test
-| 3: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: Ty(&&&&*mut Test) }, span: $DIR/receiver-ptr-mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test
+| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:14:14: 14:23, inferred_ty: *mut Test
+| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:14:14: 14:23, inferred_ty: *mut Test
+| 2: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: Ty(&&&&*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test
+| 3: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: Ty(&&&&*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test
 |
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/receiver-ptr-mutability.rs:+0:11: +0:11
-    let _1: *mut Test as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/receiver-ptr-mutability.rs:+1:9: +1:12
-    let _2: ();                          // in scope 0 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:12
-    let mut _3: *const Test;             // in scope 0 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:12
-    let mut _4: *mut Test;               // in scope 0 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:8
-    let _6: &&&&*mut Test;               // in scope 0 at $DIR/receiver-ptr-mutability.rs:+5:34: +5:41
-    let _7: &&&*mut Test;                // in scope 0 at $DIR/receiver-ptr-mutability.rs:+5:35: +5:41
-    let _8: &&*mut Test;                 // in scope 0 at $DIR/receiver-ptr-mutability.rs:+5:36: +5:41
-    let _9: &*mut Test;                  // in scope 0 at $DIR/receiver-ptr-mutability.rs:+5:37: +5:41
-    let _10: ();                         // in scope 0 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16
-    let mut _11: *const Test;            // in scope 0 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16
-    let mut _12: *mut Test;              // in scope 0 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16
+    let mut _0: ();                      // return place in scope 0 at $DIR/receiver_ptr_mutability.rs:+0:11: +0:11
+    let _1: *mut Test as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+1:9: +1:12
+    let _2: ();                          // in scope 0 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12
+    let mut _3: *const Test;             // in scope 0 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12
+    let mut _4: *mut Test;               // in scope 0 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:8
+    let _6: &&&&*mut Test;               // in scope 0 at $DIR/receiver_ptr_mutability.rs:+5:34: +5:41
+    let _7: &&&*mut Test;                // in scope 0 at $DIR/receiver_ptr_mutability.rs:+5:35: +5:41
+    let _8: &&*mut Test;                 // in scope 0 at $DIR/receiver_ptr_mutability.rs:+5:36: +5:41
+    let _9: &*mut Test;                  // in scope 0 at $DIR/receiver_ptr_mutability.rs:+5:37: +5:41
+    let _10: ();                         // in scope 0 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+    let mut _11: *const Test;            // in scope 0 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+    let mut _12: *mut Test;              // in scope 0 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
     scope 1 {
-        debug ptr => _1;                 // in scope 1 at $DIR/receiver-ptr-mutability.rs:+1:9: +1:12
-        let _5: &&&&*mut Test as UserTypeProjection { base: UserType(2), projs: [] }; // in scope 1 at $DIR/receiver-ptr-mutability.rs:+5:9: +5:16
+        debug ptr => _1;                 // in scope 1 at $DIR/receiver_ptr_mutability.rs:+1:9: +1:12
+        let _5: &&&&*mut Test as UserTypeProjection { base: UserType(2), projs: [] }; // in scope 1 at $DIR/receiver_ptr_mutability.rs:+5:9: +5:16
         scope 2 {
-            debug ptr_ref => _5;         // in scope 2 at $DIR/receiver-ptr-mutability.rs:+5:9: +5:16
+            debug ptr_ref => _5;         // in scope 2 at $DIR/receiver_ptr_mutability.rs:+5:9: +5:16
         }
     }
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/receiver-ptr-mutability.rs:+1:9: +1:12
-        _1 = null_mut::() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/receiver-ptr-mutability.rs:+1:26: +1:46
+        StorageLive(_1);                 // scope 0 at $DIR/receiver_ptr_mutability.rs:+1:9: +1:12
+        _1 = null_mut::() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/receiver_ptr_mutability.rs:+1:26: +1:46
                                          // mir::Constant
-                                         // + span: $DIR/receiver-ptr-mutability.rs:14:26: 14:44
+                                         // + span: $DIR/receiver_ptr_mutability.rs:14:26: 14:44
                                          // + literal: Const { ty: fn() -> *mut Test {null_mut::}, val: Value() }
     }
 
     bb1: {
-        FakeRead(ForLet(None), _1);      // scope 0 at $DIR/receiver-ptr-mutability.rs:+1:9: +1:12
-        AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/receiver-ptr-mutability.rs:+1:14: +1:23
-        StorageLive(_2);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:12
-        StorageLive(_3);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:12
-        StorageLive(_4);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:8
-        _4 = _1;                         // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:8
-        _3 = move _4 as *const Test (Pointer(MutToConstPointer)); // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:12
-        StorageDead(_4);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:7: +2:8
-        _2 = Test::x(move _3) -> [return: bb2, unwind: bb4]; // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:12
+        FakeRead(ForLet(None), _1);      // scope 0 at $DIR/receiver_ptr_mutability.rs:+1:9: +1:12
+        AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/receiver_ptr_mutability.rs:+1:14: +1:23
+        StorageLive(_2);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12
+        StorageLive(_3);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12
+        StorageLive(_4);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:8
+        _4 = _1;                         // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:8
+        _3 = move _4 as *const Test (Pointer(MutToConstPointer)); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12
+        StorageDead(_4);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:7: +2:8
+        _2 = Test::x(move _3) -> [return: bb2, unwind: bb4]; // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12
                                          // mir::Constant
-                                         // + span: $DIR/receiver-ptr-mutability.rs:15:9: 15:10
+                                         // + span: $DIR/receiver_ptr_mutability.rs:15:9: 15:10
                                          // + literal: Const { ty: fn(*const Test) {Test::x}, val: Value() }
     }
 
     bb2: {
-        StorageDead(_3);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:11: +2:12
-        StorageDead(_2);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:12: +2:13
-        StorageLive(_5);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:9: +5:16
-        StorageLive(_6);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:34: +5:41
-        StorageLive(_7);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:35: +5:41
-        StorageLive(_8);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:36: +5:41
-        StorageLive(_9);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:37: +5:41
-        _9 = &_1;                        // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:37: +5:41
-        _8 = &_9;                        // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:36: +5:41
-        _7 = &_8;                        // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:35: +5:41
-        _6 = &_7;                        // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:34: +5:41
-        _5 = &(*_6);                     // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:34: +5:41
-        FakeRead(ForLet(None), _5);      // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:9: +5:16
-        AscribeUserType(_5, o, UserTypeProjection { base: UserType(3), projs: [] }); // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:18: +5:31
-        StorageDead(_6);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:41: +5:42
-        StorageLive(_10);                // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16
-        StorageLive(_11);                // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16
-        StorageLive(_12);                // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16
-        _12 = (*(*(*(*_5))));            // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16
-        _11 = move _12 as *const Test (Pointer(MutToConstPointer)); // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16
-        StorageDead(_12);                // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:11: +6:12
-        _10 = Test::x(move _11) -> [return: bb3, unwind: bb4]; // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16
+        StorageDead(_3);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:11: +2:12
+        StorageDead(_2);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:12: +2:13
+        StorageLive(_5);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:9: +5:16
+        StorageLive(_6);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:34: +5:41
+        StorageLive(_7);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:35: +5:41
+        StorageLive(_8);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:36: +5:41
+        StorageLive(_9);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:37: +5:41
+        _9 = &_1;                        // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:37: +5:41
+        _8 = &_9;                        // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:36: +5:41
+        _7 = &_8;                        // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:35: +5:41
+        _6 = &_7;                        // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:34: +5:41
+        _5 = &(*_6);                     // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:34: +5:41
+        FakeRead(ForLet(None), _5);      // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:9: +5:16
+        AscribeUserType(_5, o, UserTypeProjection { base: UserType(3), projs: [] }); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:18: +5:31
+        StorageDead(_6);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:41: +5:42
+        StorageLive(_10);                // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+        StorageLive(_11);                // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+        StorageLive(_12);                // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+        _12 = (*(*(*(*_5))));            // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+        _11 = move _12 as *const Test (Pointer(MutToConstPointer)); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+        StorageDead(_12);                // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:11: +6:12
+        _10 = Test::x(move _11) -> [return: bb3, unwind: bb4]; // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
                                          // mir::Constant
-                                         // + span: $DIR/receiver-ptr-mutability.rs:19:13: 19:14
+                                         // + span: $DIR/receiver_ptr_mutability.rs:19:13: 19:14
                                          // + literal: Const { ty: fn(*const Test) {Test::x}, val: Value() }
     }
 
     bb3: {
-        StorageDead(_11);                // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:15: +6:16
-        StorageDead(_10);                // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:16: +6:17
-        _0 = const ();                   // scope 0 at $DIR/receiver-ptr-mutability.rs:+0:11: +7:2
-        StorageDead(_9);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+7:1: +7:2
-        StorageDead(_8);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+7:1: +7:2
-        StorageDead(_7);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+7:1: +7:2
-        StorageDead(_5);                 // scope 1 at $DIR/receiver-ptr-mutability.rs:+7:1: +7:2
-        StorageDead(_1);                 // scope 0 at $DIR/receiver-ptr-mutability.rs:+7:1: +7:2
-        return;                          // scope 0 at $DIR/receiver-ptr-mutability.rs:+7:2: +7:2
+        StorageDead(_11);                // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:15: +6:16
+        StorageDead(_10);                // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:16: +6:17
+        _0 = const ();                   // scope 0 at $DIR/receiver_ptr_mutability.rs:+0:11: +7:2
+        StorageDead(_9);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2
+        StorageDead(_8);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2
+        StorageDead(_7);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2
+        StorageDead(_5);                 // scope 1 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2
+        StorageDead(_1);                 // scope 0 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2
+        return;                          // scope 0 at $DIR/receiver_ptr_mutability.rs:+7:2: +7:2
     }
 
     bb4 (cleanup): {
-        resume;                          // scope 0 at $DIR/receiver-ptr-mutability.rs:+0:1: +7:2
+        resume;                          // scope 0 at $DIR/receiver_ptr_mutability.rs:+0:1: +7:2
     }
 }
diff --git a/src/test/mir-opt/building/receiver-ptr-mutability.rs b/src/test/mir-opt/building/receiver_ptr_mutability.rs
similarity index 100%
rename from src/test/mir-opt/building/receiver-ptr-mutability.rs
rename to src/test/mir-opt/building/receiver_ptr_mutability.rs
diff --git a/src/test/mir-opt/building/simple_match.match_bool.built.after.mir b/src/test/mir-opt/building/simple_match.match_bool.built.after.mir
index 5b101cbdee7..a4516026c3b 100644
--- a/src/test/mir-opt/building/simple_match.match_bool.built.after.mir
+++ b/src/test/mir-opt/building/simple_match.match_bool.built.after.mir
@@ -1,29 +1,29 @@
 // MIR for `match_bool` after built
 
 fn match_bool(_1: bool) -> usize {
-    debug x => _1;                       // in scope 0 at $DIR/simple-match.rs:+0:15: +0:16
-    let mut _0: usize;                   // return place in scope 0 at $DIR/simple-match.rs:+0:27: +0:32
+    debug x => _1;                       // in scope 0 at $DIR/simple_match.rs:+0:15: +0:16
+    let mut _0: usize;                   // return place in scope 0 at $DIR/simple_match.rs:+0:27: +0:32
 
     bb0: {
-        FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/simple-match.rs:+1:11: +1:12
-        switchInt(_1) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/simple-match.rs:+1:5: +1:12
+        FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/simple_match.rs:+1:11: +1:12
+        switchInt(_1) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/simple_match.rs:+1:5: +1:12
     }
 
     bb1: {
-        falseEdge -> [real: bb3, imaginary: bb2]; // scope 0 at $DIR/simple-match.rs:+2:9: +2:13
+        falseEdge -> [real: bb3, imaginary: bb2]; // scope 0 at $DIR/simple_match.rs:+2:9: +2:13
     }
 
     bb2: {
-        _0 = const 20_usize;             // scope 0 at $DIR/simple-match.rs:+3:14: +3:16
-        goto -> bb4;                     // scope 0 at $DIR/simple-match.rs:+3:14: +3:16
+        _0 = const 20_usize;             // scope 0 at $DIR/simple_match.rs:+3:14: +3:16
+        goto -> bb4;                     // scope 0 at $DIR/simple_match.rs:+3:14: +3:16
     }
 
     bb3: {
-        _0 = const 10_usize;             // scope 0 at $DIR/simple-match.rs:+2:17: +2:19
-        goto -> bb4;                     // scope 0 at $DIR/simple-match.rs:+2:17: +2:19
+        _0 = const 10_usize;             // scope 0 at $DIR/simple_match.rs:+2:17: +2:19
+        goto -> bb4;                     // scope 0 at $DIR/simple_match.rs:+2:17: +2:19
     }
 
     bb4: {
-        return;                          // scope 0 at $DIR/simple-match.rs:+5:2: +5:2
+        return;                          // scope 0 at $DIR/simple_match.rs:+5:2: +5:2
     }
 }
diff --git a/src/test/mir-opt/building/simple-match.rs b/src/test/mir-opt/building/simple_match.rs
similarity index 100%
rename from src/test/mir-opt/building/simple-match.rs
rename to src/test/mir-opt/building/simple_match.rs
diff --git a/src/test/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir
index 7650769de3b..028480bdc88 100644
--- a/src/test/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir
+++ b/src/test/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir
@@ -1,20 +1,20 @@
 // MIR for `BAR::promoted[0]` after SimplifyCfg-elaborate-drops
 
 promoted[0] in BAR: &[&i32; 1] = {
-    let mut _0: &[&i32; 1];              // return place in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
-    let mut _1: [&i32; 1];               // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:35
-    let mut _2: &i32;                    // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:34
-    let mut _3: &i32;                    // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:33: +0:34
+    let mut _0: &[&i32; 1];              // return place in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
+    let mut _1: [&i32; 1];               // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:35
+    let mut _2: &i32;                    // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:34
+    let mut _3: &i32;                    // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:33: +0:34
 
     bb0: {
-        _3 = const {alloc1: &i32};       // scope 0 at $DIR/const-promotion-extern-static.rs:+0:33: +0:34
+        _3 = const {alloc1: &i32};       // scope 0 at $DIR/const_promotion_extern_static.rs:+0:33: +0:34
                                          // mir::Constant
-                                         // + span: $DIR/const-promotion-extern-static.rs:9:33: 9:34
+                                         // + span: $DIR/const_promotion_extern_static.rs:9:33: 9:34
                                          // + literal: Const { ty: &i32, val: Value(Scalar(alloc1)) }
-        _2 = &(*_3);                     // scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:34
-        _1 = [move _2];                  // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:35
-        _0 = &_1;                        // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
-        return;                          // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
+        _2 = &(*_3);                     // scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:34
+        _1 = [move _2];                  // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:35
+        _0 = &_1;                        // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
+        return;                          // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
     }
 }
 
diff --git a/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff b/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff
index f8a7c687e12..2ef4378115f 100644
--- a/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff
+++ b/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff
@@ -2,49 +2,49 @@
 + // MIR for `BAR` after PromoteTemps
   
   static mut BAR: *const &i32 = {
-      let mut _0: *const &i32;             // return place in scope 0 at $DIR/const-promotion-extern-static.rs:+0:17: +0:28
-      let mut _1: &[&i32];                 // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
-      let mut _2: &[&i32; 1];              // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
-      let _3: [&i32; 1];                   // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:35
-      let mut _4: &i32;                    // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:34
-      let _5: &i32;                        // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:33: +0:34
-+     let mut _6: &[&i32; 1];              // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
+      let mut _0: *const &i32;             // return place in scope 0 at $DIR/const_promotion_extern_static.rs:+0:17: +0:28
+      let mut _1: &[&i32];                 // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
+      let mut _2: &[&i32; 1];              // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
+      let _3: [&i32; 1];                   // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:35
+      let mut _4: &i32;                    // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:34
+      let _5: &i32;                        // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:33: +0:34
++     let mut _6: &[&i32; 1];              // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
-          StorageLive(_2);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
--         StorageLive(_3);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:35
--         StorageLive(_4);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:34
--         StorageLive(_5);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:33: +0:34
--         _5 = const {alloc1: &i32};       // scope 0 at $DIR/const-promotion-extern-static.rs:+0:33: +0:34
-+         _6 = const _;                    // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
+          StorageLive(_1);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
+          StorageLive(_2);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
+-         StorageLive(_3);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:35
+-         StorageLive(_4);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:34
+-         StorageLive(_5);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:33: +0:34
+-         _5 = const {alloc1: &i32};       // scope 0 at $DIR/const_promotion_extern_static.rs:+0:33: +0:34
++         _6 = const _;                    // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
                                            // mir::Constant
--                                          // + span: $DIR/const-promotion-extern-static.rs:9:33: 9:34
+-                                          // + span: $DIR/const_promotion_extern_static.rs:9:33: 9:34
 -                                          // + literal: Const { ty: &i32, val: Value(Scalar(alloc1)) }
--         _4 = &(*_5);                     // scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:34
--         _3 = [move _4];                  // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:35
--         _2 = &_3;                        // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
-+                                          // + span: $DIR/const-promotion-extern-static.rs:9:31: 9:44
+-         _4 = &(*_5);                     // scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:34
+-         _3 = [move _4];                  // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:35
+-         _2 = &_3;                        // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
++                                          // + span: $DIR/const_promotion_extern_static.rs:9:31: 9:44
 +                                          // + literal: Const { ty: &[&i32; 1], val: Unevaluated(BAR, [], Some(promoted[0])) }
-+         _2 = &(*_6);                     // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
-          _1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
--         StorageDead(_4);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:34: +0:35
-          StorageDead(_2);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:34: +0:35
-          _0 = core::slice::::as_ptr(move _1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44
++         _2 = &(*_6);                     // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
+          _1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
+-         StorageDead(_4);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:34: +0:35
+          StorageDead(_2);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:34: +0:35
+          _0 = core::slice::::as_ptr(move _1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44
                                            // mir::Constant
-                                           // + span: $DIR/const-promotion-extern-static.rs:9:36: 9:42
+                                           // + span: $DIR/const_promotion_extern_static.rs:9:36: 9:42
                                            // + literal: Const { ty: for<'a> fn(&'a [&i32]) -> *const &i32 {core::slice::::as_ptr}, val: Value() }
       }
   
       bb1: {
--         StorageDead(_5);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:43: +0:44
--         StorageDead(_3);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:43: +0:44
-          StorageDead(_1);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:43: +0:44
-          return;                          // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:45
+-         StorageDead(_5);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:43: +0:44
+-         StorageDead(_3);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:43: +0:44
+          StorageDead(_1);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:43: +0:44
+          return;                          // scope 0 at $DIR/const_promotion_extern_static.rs:+0:1: +0:45
       }
   
       bb2 (cleanup): {
-          resume;                          // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:45
+          resume;                          // scope 0 at $DIR/const_promotion_extern_static.rs:+0:1: +0:45
       }
 - }
 - 
diff --git a/src/test/mir-opt/const_promotion_extern_static.BOP.built.after.mir b/src/test/mir-opt/const_promotion_extern_static.BOP.built.after.mir
index 5bda86bbd4f..476fc49a1fe 100644
--- a/src/test/mir-opt/const_promotion_extern_static.BOP.built.after.mir
+++ b/src/test/mir-opt/const_promotion_extern_static.BOP.built.after.mir
@@ -1,17 +1,17 @@
 // MIR for `BOP` after built
 
 static BOP: &i32 = {
-    let mut _0: &i32;                    // return place in scope 0 at $DIR/const-promotion-extern-static.rs:+0:13: +0:17
-    let _1: &i32;                        // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:20: +0:23
-    let _2: i32;                         // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:21: +0:23
+    let mut _0: &i32;                    // return place in scope 0 at $DIR/const_promotion_extern_static.rs:+0:13: +0:17
+    let _1: &i32;                        // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:20: +0:23
+    let _2: i32;                         // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:21: +0:23
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:20: +0:23
-        StorageLive(_2);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:21: +0:23
-        _2 = const 13_i32;               // scope 0 at $DIR/const-promotion-extern-static.rs:+0:21: +0:23
-        _1 = &_2;                        // scope 0 at $DIR/const-promotion-extern-static.rs:+0:20: +0:23
-        _0 = &(*_1);                     // scope 0 at $DIR/const-promotion-extern-static.rs:+0:20: +0:23
-        StorageDead(_1);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:22: +0:23
-        return;                          // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:24
+        StorageLive(_1);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:20: +0:23
+        StorageLive(_2);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:21: +0:23
+        _2 = const 13_i32;               // scope 0 at $DIR/const_promotion_extern_static.rs:+0:21: +0:23
+        _1 = &_2;                        // scope 0 at $DIR/const_promotion_extern_static.rs:+0:20: +0:23
+        _0 = &(*_1);                     // scope 0 at $DIR/const_promotion_extern_static.rs:+0:20: +0:23
+        StorageDead(_1);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:22: +0:23
+        return;                          // scope 0 at $DIR/const_promotion_extern_static.rs:+0:1: +0:24
     }
 }
diff --git a/src/test/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir
index 71827eab1c2..41657b53fc1 100644
--- a/src/test/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir
+++ b/src/test/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir
@@ -1,20 +1,20 @@
 // MIR for `FOO::promoted[0]` after SimplifyCfg-elaborate-drops
 
 promoted[0] in FOO: &[&i32; 1] = {
-    let mut _0: &[&i32; 1];              // return place in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
-    let mut _1: [&i32; 1];               // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:46
-    let mut _2: &i32;                    // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:45
-    let mut _3: *const i32;              // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:42: +0:43
+    let mut _0: &[&i32; 1];              // return place in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
+    let mut _1: [&i32; 1];               // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46
+    let mut _2: &i32;                    // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:45
+    let mut _3: *const i32;              // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43
 
     bb0: {
-        _3 = const {alloc3: *const i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:42: +0:43
+        _3 = const {alloc3: *const i32}; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43
                                          // mir::Constant
-                                         // + span: $DIR/const-promotion-extern-static.rs:13:42: 13:43
+                                         // + span: $DIR/const_promotion_extern_static.rs:13:42: 13:43
                                          // + literal: Const { ty: *const i32, val: Value(Scalar(alloc3)) }
-        _2 = &(*_3);                     // scope 0 at $DIR/const-promotion-extern-static.rs:+0:41: +0:43
-        _1 = [move _2];                  // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:46
-        _0 = &_1;                        // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
-        return;                          // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
+        _2 = &(*_3);                     // scope 0 at $DIR/const_promotion_extern_static.rs:+0:41: +0:43
+        _1 = [move _2];                  // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46
+        _0 = &_1;                        // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
+        return;                          // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
     }
 }
 
diff --git a/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff b/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff
index e938ca28af5..25ba0face6b 100644
--- a/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff
+++ b/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff
@@ -2,51 +2,51 @@
 + // MIR for `FOO` after PromoteTemps
   
   static mut FOO: *const &i32 = {
-      let mut _0: *const &i32;             // return place in scope 0 at $DIR/const-promotion-extern-static.rs:+0:17: +0:28
-      let mut _1: &[&i32];                 // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
-      let mut _2: &[&i32; 1];              // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
-      let _3: [&i32; 1];                   // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:46
-      let mut _4: &i32;                    // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:45
-      let _5: *const i32;                  // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:42: +0:43
-+     let mut _6: &[&i32; 1];              // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
+      let mut _0: *const &i32;             // return place in scope 0 at $DIR/const_promotion_extern_static.rs:+0:17: +0:28
+      let mut _1: &[&i32];                 // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
+      let mut _2: &[&i32; 1];              // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
+      let _3: [&i32; 1];                   // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46
+      let mut _4: &i32;                    // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:45
+      let _5: *const i32;                  // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43
++     let mut _6: &[&i32; 1];              // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
       scope 1 {
       }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
-          StorageLive(_2);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
--         StorageLive(_3);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:46
--         StorageLive(_4);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:45
--         StorageLive(_5);                 // scope 1 at $DIR/const-promotion-extern-static.rs:+0:42: +0:43
--         _5 = const {alloc3: *const i32}; // scope 1 at $DIR/const-promotion-extern-static.rs:+0:42: +0:43
-+         _6 = const _;                    // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
+          StorageLive(_1);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
+          StorageLive(_2);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
+-         StorageLive(_3);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46
+-         StorageLive(_4);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:45
+-         StorageLive(_5);                 // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43
+-         _5 = const {alloc3: *const i32}; // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43
++         _6 = const _;                    // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
                                            // mir::Constant
--                                          // + span: $DIR/const-promotion-extern-static.rs:13:42: 13:43
+-                                          // + span: $DIR/const_promotion_extern_static.rs:13:42: 13:43
 -                                          // + literal: Const { ty: *const i32, val: Value(Scalar(alloc3)) }
--         _4 = &(*_5);                     // scope 1 at $DIR/const-promotion-extern-static.rs:+0:41: +0:43
--         _3 = [move _4];                  // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:46
--         _2 = &_3;                        // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
-+                                          // + span: $DIR/const-promotion-extern-static.rs:13:31: 13:55
+-         _4 = &(*_5);                     // scope 1 at $DIR/const_promotion_extern_static.rs:+0:41: +0:43
+-         _3 = [move _4];                  // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46
+-         _2 = &_3;                        // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
++                                          // + span: $DIR/const_promotion_extern_static.rs:13:31: 13:55
 +                                          // + literal: Const { ty: &[&i32; 1], val: Unevaluated(FOO, [], Some(promoted[0])) }
-+         _2 = &(*_6);                     // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
-          _1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
--         StorageDead(_4);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:45: +0:46
-          StorageDead(_2);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:45: +0:46
-          _0 = core::slice::::as_ptr(move _1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55
++         _2 = &(*_6);                     // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
+          _1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
+-         StorageDead(_4);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:45: +0:46
+          StorageDead(_2);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:45: +0:46
+          _0 = core::slice::::as_ptr(move _1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
                                            // mir::Constant
-                                           // + span: $DIR/const-promotion-extern-static.rs:13:47: 13:53
+                                           // + span: $DIR/const_promotion_extern_static.rs:13:47: 13:53
                                            // + literal: Const { ty: for<'a> fn(&'a [&i32]) -> *const &i32 {core::slice::::as_ptr}, val: Value() }
       }
   
       bb1: {
--         StorageDead(_5);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:54: +0:55
--         StorageDead(_3);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:54: +0:55
-          StorageDead(_1);                 // scope 0 at $DIR/const-promotion-extern-static.rs:+0:54: +0:55
-          return;                          // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:56
+-         StorageDead(_5);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:54: +0:55
+-         StorageDead(_3);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:54: +0:55
+          StorageDead(_1);                 // scope 0 at $DIR/const_promotion_extern_static.rs:+0:54: +0:55
+          return;                          // scope 0 at $DIR/const_promotion_extern_static.rs:+0:1: +0:56
       }
   
       bb2 (cleanup): {
-          resume;                          // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:56
+          resume;                          // scope 0 at $DIR/const_promotion_extern_static.rs:+0:1: +0:56
       }
   }
 - 
diff --git a/src/test/mir-opt/const-promotion-extern-static.rs b/src/test/mir-opt/const_promotion_extern_static.rs
similarity index 100%
rename from src/test/mir-opt/const-promotion-extern-static.rs
rename to src/test/mir-opt/const_promotion_extern_static.rs
diff --git a/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff b/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff
index a07bdd99825..8b3b9d0a4c1 100644
--- a/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff
+++ b/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff
@@ -2,15 +2,15 @@
 + // MIR for `hello` after ConstProp
   
   fn hello() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/control-flow-simplification.rs:+0:14: +0:14
-      let mut _1: bool;                    // in scope 0 at $DIR/control-flow-simplification.rs:+1:8: +1:21
+      let mut _0: ();                      // return place in scope 0 at $DIR/control_flow_simplification.rs:+0:14: +0:14
+      let mut _1: bool;                    // in scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21
       let mut _2: !;                       // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/control-flow-simplification.rs:+1:8: +1:21
-          _1 = const _;                    // scope 0 at $DIR/control-flow-simplification.rs:+1:8: +1:21
--         switchInt(move _1) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/control-flow-simplification.rs:+1:8: +1:21
-+         switchInt(const false) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/control-flow-simplification.rs:+1:8: +1:21
+          StorageLive(_1);                 // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21
+          _1 = const _;                    // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21
+-         switchInt(move _1) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21
++         switchInt(const false) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21
       }
   
       bb1: {
@@ -25,9 +25,9 @@
       }
   
       bb2: {
-          nop;                             // scope 0 at $DIR/control-flow-simplification.rs:+3:6: +3:6
-          StorageDead(_1);                 // scope 0 at $DIR/control-flow-simplification.rs:+3:5: +3:6
-          return;                          // scope 0 at $DIR/control-flow-simplification.rs:+4:2: +4:2
+          nop;                             // scope 0 at $DIR/control_flow_simplification.rs:+3:6: +3:6
+          StorageDead(_1);                 // scope 0 at $DIR/control_flow_simplification.rs:+3:5: +3:6
+          return;                          // scope 0 at $DIR/control_flow_simplification.rs:+4:2: +4:2
       }
   }
   
diff --git a/src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir b/src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir
index 70f97977511..9f7528f0ce1 100644
--- a/src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir
+++ b/src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir
@@ -1,9 +1,9 @@
 // MIR for `hello` before PreCodegen
 
 fn hello() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/control-flow-simplification.rs:+0:14: +0:14
+    let mut _0: ();                      // return place in scope 0 at $DIR/control_flow_simplification.rs:+0:14: +0:14
 
     bb0: {
-        return;                          // scope 0 at $DIR/control-flow-simplification.rs:+4:2: +4:2
+        return;                          // scope 0 at $DIR/control_flow_simplification.rs:+4:2: +4:2
     }
 }
diff --git a/src/test/mir-opt/const_prop/control-flow-simplification.rs b/src/test/mir-opt/const_prop/control_flow_simplification.rs
similarity index 100%
rename from src/test/mir-opt/const_prop/control-flow-simplification.rs
rename to src/test/mir-opt/const_prop/control_flow_simplification.rs
diff --git a/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff
index 9d541dcabbb..7d8e647cbce 100644
--- a/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff
+++ b/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff
@@ -2,32 +2,32 @@
 + // MIR for `main` after ConstProp
   
   fn main() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/issue-66971.rs:+0:11: +0:11
-      let _1: ();                          // in scope 0 at $DIR/issue-66971.rs:+1:5: +1:23
-      let mut _2: ((), u8, u8);            // in scope 0 at $DIR/issue-66971.rs:+1:12: +1:22
-      let mut _3: ();                      // in scope 0 at $DIR/issue-66971.rs:+1:13: +1:15
+      let mut _0: ();                      // return place in scope 0 at $DIR/issue_66971.rs:+0:11: +0:11
+      let _1: ();                          // in scope 0 at $DIR/issue_66971.rs:+1:5: +1:23
+      let mut _2: ((), u8, u8);            // in scope 0 at $DIR/issue_66971.rs:+1:12: +1:22
+      let mut _3: ();                      // in scope 0 at $DIR/issue_66971.rs:+1:13: +1:15
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/issue-66971.rs:+1:5: +1:23
-          StorageLive(_2);                 // scope 0 at $DIR/issue-66971.rs:+1:12: +1:22
-          StorageLive(_3);                 // scope 0 at $DIR/issue-66971.rs:+1:13: +1:15
-          nop;                             // scope 0 at $DIR/issue-66971.rs:+1:13: +1:15
-          Deinit(_2);                      // scope 0 at $DIR/issue-66971.rs:+1:12: +1:22
-          nop;                             // scope 0 at $DIR/issue-66971.rs:+1:12: +1:22
-          (_2.1: u8) = const 0_u8;         // scope 0 at $DIR/issue-66971.rs:+1:12: +1:22
-          (_2.2: u8) = const 0_u8;         // scope 0 at $DIR/issue-66971.rs:+1:12: +1:22
-          StorageDead(_3);                 // scope 0 at $DIR/issue-66971.rs:+1:21: +1:22
-          _1 = encode(move _2) -> bb1;     // scope 0 at $DIR/issue-66971.rs:+1:5: +1:23
+          StorageLive(_1);                 // scope 0 at $DIR/issue_66971.rs:+1:5: +1:23
+          StorageLive(_2);                 // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22
+          StorageLive(_3);                 // scope 0 at $DIR/issue_66971.rs:+1:13: +1:15
+          nop;                             // scope 0 at $DIR/issue_66971.rs:+1:13: +1:15
+          Deinit(_2);                      // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22
+          nop;                             // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22
+          (_2.1: u8) = const 0_u8;         // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22
+          (_2.2: u8) = const 0_u8;         // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22
+          StorageDead(_3);                 // scope 0 at $DIR/issue_66971.rs:+1:21: +1:22
+          _1 = encode(move _2) -> bb1;     // scope 0 at $DIR/issue_66971.rs:+1:5: +1:23
                                            // mir::Constant
-                                           // + span: $DIR/issue-66971.rs:17:5: 17:11
+                                           // + span: $DIR/issue_66971.rs:17:5: 17:11
                                            // + literal: Const { ty: fn(((), u8, u8)) {encode}, val: Value() }
       }
   
       bb1: {
-          StorageDead(_2);                 // scope 0 at $DIR/issue-66971.rs:+1:22: +1:23
-          StorageDead(_1);                 // scope 0 at $DIR/issue-66971.rs:+1:23: +1:24
-          nop;                             // scope 0 at $DIR/issue-66971.rs:+0:11: +2:2
-          return;                          // scope 0 at $DIR/issue-66971.rs:+2:2: +2:2
+          StorageDead(_2);                 // scope 0 at $DIR/issue_66971.rs:+1:22: +1:23
+          StorageDead(_1);                 // scope 0 at $DIR/issue_66971.rs:+1:23: +1:24
+          nop;                             // scope 0 at $DIR/issue_66971.rs:+0:11: +2:2
+          return;                          // scope 0 at $DIR/issue_66971.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/const_prop/issue-66971.rs b/src/test/mir-opt/const_prop/issue_66971.rs
similarity index 100%
rename from src/test/mir-opt/const_prop/issue-66971.rs
rename to src/test/mir-opt/const_prop/issue_66971.rs
diff --git a/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff
index b79d814760d..79cd8bf4839 100644
--- a/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff
+++ b/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff
@@ -2,33 +2,33 @@
 + // MIR for `main` after ConstProp
   
   fn main() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/issue-67019.rs:+0:11: +0:11
-      let _1: ();                          // in scope 0 at $DIR/issue-67019.rs:+1:5: +1:20
-      let mut _2: ((u8, u8),);             // in scope 0 at $DIR/issue-67019.rs:+1:10: +1:19
-      let mut _3: (u8, u8);                // in scope 0 at $DIR/issue-67019.rs:+1:11: +1:17
+      let mut _0: ();                      // return place in scope 0 at $DIR/issue_67019.rs:+0:11: +0:11
+      let _1: ();                          // in scope 0 at $DIR/issue_67019.rs:+1:5: +1:20
+      let mut _2: ((u8, u8),);             // in scope 0 at $DIR/issue_67019.rs:+1:10: +1:19
+      let mut _3: (u8, u8);                // in scope 0 at $DIR/issue_67019.rs:+1:11: +1:17
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/issue-67019.rs:+1:5: +1:20
-          StorageLive(_2);                 // scope 0 at $DIR/issue-67019.rs:+1:10: +1:19
-          StorageLive(_3);                 // scope 0 at $DIR/issue-67019.rs:+1:11: +1:17
-          Deinit(_3);                      // scope 0 at $DIR/issue-67019.rs:+1:11: +1:17
-          (_3.0: u8) = const 1_u8;         // scope 0 at $DIR/issue-67019.rs:+1:11: +1:17
-          (_3.1: u8) = const 2_u8;         // scope 0 at $DIR/issue-67019.rs:+1:11: +1:17
-          Deinit(_2);                      // scope 0 at $DIR/issue-67019.rs:+1:10: +1:19
--         (_2.0: (u8, u8)) = move _3;      // scope 0 at $DIR/issue-67019.rs:+1:10: +1:19
-+         (_2.0: (u8, u8)) = const (1_u8, 2_u8); // scope 0 at $DIR/issue-67019.rs:+1:10: +1:19
-          StorageDead(_3);                 // scope 0 at $DIR/issue-67019.rs:+1:18: +1:19
-          _1 = test(move _2) -> bb1;       // scope 0 at $DIR/issue-67019.rs:+1:5: +1:20
+          StorageLive(_1);                 // scope 0 at $DIR/issue_67019.rs:+1:5: +1:20
+          StorageLive(_2);                 // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19
+          StorageLive(_3);                 // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17
+          Deinit(_3);                      // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17
+          (_3.0: u8) = const 1_u8;         // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17
+          (_3.1: u8) = const 2_u8;         // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17
+          Deinit(_2);                      // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19
+-         (_2.0: (u8, u8)) = move _3;      // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19
++         (_2.0: (u8, u8)) = const (1_u8, 2_u8); // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19
+          StorageDead(_3);                 // scope 0 at $DIR/issue_67019.rs:+1:18: +1:19
+          _1 = test(move _2) -> bb1;       // scope 0 at $DIR/issue_67019.rs:+1:5: +1:20
                                            // mir::Constant
-                                           // + span: $DIR/issue-67019.rs:12:5: 12:9
+                                           // + span: $DIR/issue_67019.rs:12:5: 12:9
                                            // + literal: Const { ty: fn(((u8, u8),)) {test}, val: Value() }
       }
   
       bb1: {
-          StorageDead(_2);                 // scope 0 at $DIR/issue-67019.rs:+1:19: +1:20
-          StorageDead(_1);                 // scope 0 at $DIR/issue-67019.rs:+1:20: +1:21
-          nop;                             // scope 0 at $DIR/issue-67019.rs:+0:11: +2:2
-          return;                          // scope 0 at $DIR/issue-67019.rs:+2:2: +2:2
+          StorageDead(_2);                 // scope 0 at $DIR/issue_67019.rs:+1:19: +1:20
+          StorageDead(_1);                 // scope 0 at $DIR/issue_67019.rs:+1:20: +1:21
+          nop;                             // scope 0 at $DIR/issue_67019.rs:+0:11: +2:2
+          return;                          // scope 0 at $DIR/issue_67019.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/const_prop/issue-67019.rs b/src/test/mir-opt/const_prop/issue_67019.rs
similarity index 100%
rename from src/test/mir-opt/const_prop/issue-67019.rs
rename to src/test/mir-opt/const_prop/issue_67019.rs
diff --git a/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir b/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir
index 96716a39a2b..08481777ed4 100644
--- a/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir
+++ b/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir
@@ -1,83 +1,83 @@
 // MIR for `match_tuple` after SimplifyCfg-initial
 
 fn match_tuple(_1: (u32, bool, Option, u32)) -> u32 {
-    debug x => _1;                       // in scope 0 at $DIR/exponential-or.rs:+0:16: +0:17
-    let mut _0: u32;                     // return place in scope 0 at $DIR/exponential-or.rs:+0:53: +0:56
-    let mut _2: isize;                   // in scope 0 at $DIR/exponential-or.rs:+2:37: +2:48
-    let mut _3: bool;                    // in scope 0 at $DIR/exponential-or.rs:+2:70: +2:77
-    let mut _4: bool;                    // in scope 0 at $DIR/exponential-or.rs:+2:70: +2:77
-    let mut _5: bool;                    // in scope 0 at $DIR/exponential-or.rs:+2:62: +2:67
-    let mut _6: bool;                    // in scope 0 at $DIR/exponential-or.rs:+2:62: +2:67
-    let _7: u32;                         // in scope 0 at $DIR/exponential-or.rs:+2:10: +2:11
-    let _8: u32;                         // in scope 0 at $DIR/exponential-or.rs:+2:57: +2:58
-    let mut _9: u32;                     // in scope 0 at $DIR/exponential-or.rs:+2:83: +2:84
-    let mut _10: u32;                    // in scope 0 at $DIR/exponential-or.rs:+2:87: +2:88
+    debug x => _1;                       // in scope 0 at $DIR/exponential_or.rs:+0:16: +0:17
+    let mut _0: u32;                     // return place in scope 0 at $DIR/exponential_or.rs:+0:53: +0:56
+    let mut _2: isize;                   // in scope 0 at $DIR/exponential_or.rs:+2:37: +2:48
+    let mut _3: bool;                    // in scope 0 at $DIR/exponential_or.rs:+2:70: +2:77
+    let mut _4: bool;                    // in scope 0 at $DIR/exponential_or.rs:+2:70: +2:77
+    let mut _5: bool;                    // in scope 0 at $DIR/exponential_or.rs:+2:62: +2:67
+    let mut _6: bool;                    // in scope 0 at $DIR/exponential_or.rs:+2:62: +2:67
+    let _7: u32;                         // in scope 0 at $DIR/exponential_or.rs:+2:10: +2:11
+    let _8: u32;                         // in scope 0 at $DIR/exponential_or.rs:+2:57: +2:58
+    let mut _9: u32;                     // in scope 0 at $DIR/exponential_or.rs:+2:83: +2:84
+    let mut _10: u32;                    // in scope 0 at $DIR/exponential_or.rs:+2:87: +2:88
     scope 1 {
-        debug y => _7;                   // in scope 1 at $DIR/exponential-or.rs:+2:10: +2:11
-        debug z => _8;                   // in scope 1 at $DIR/exponential-or.rs:+2:57: +2:58
+        debug y => _7;                   // in scope 1 at $DIR/exponential_or.rs:+2:10: +2:11
+        debug z => _8;                   // in scope 1 at $DIR/exponential_or.rs:+2:57: +2:58
     }
 
     bb0: {
-        FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/exponential-or.rs:+1:11: +1:12
-        switchInt((_1.0: u32)) -> [1_u32: bb2, 4_u32: bb2, otherwise: bb1]; // scope 0 at $DIR/exponential-or.rs:+2:15: +2:20
+        FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/exponential_or.rs:+1:11: +1:12
+        switchInt((_1.0: u32)) -> [1_u32: bb2, 4_u32: bb2, otherwise: bb1]; // scope 0 at $DIR/exponential_or.rs:+2:15: +2:20
     }
 
     bb1: {
-        _0 = const 0_u32;                // scope 0 at $DIR/exponential-or.rs:+3:14: +3:15
-        goto -> bb10;                    // scope 0 at $DIR/exponential-or.rs:+3:14: +3:15
+        _0 = const 0_u32;                // scope 0 at $DIR/exponential_or.rs:+3:14: +3:15
+        goto -> bb10;                    // scope 0 at $DIR/exponential_or.rs:+3:14: +3:15
     }
 
     bb2: {
-        _2 = discriminant((_1.2: std::option::Option)); // scope 0 at $DIR/exponential-or.rs:+2:37: +2:55
-        switchInt(move _2) -> [0_isize: bb4, 1_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/exponential-or.rs:+2:37: +2:55
+        _2 = discriminant((_1.2: std::option::Option)); // scope 0 at $DIR/exponential_or.rs:+2:37: +2:55
+        switchInt(move _2) -> [0_isize: bb4, 1_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/exponential_or.rs:+2:37: +2:55
     }
 
     bb3: {
-        switchInt((((_1.2: std::option::Option) as Some).0: i32)) -> [1_i32: bb4, 8_i32: bb4, otherwise: bb1]; // scope 0 at $DIR/exponential-or.rs:+2:37: +2:55
+        switchInt((((_1.2: std::option::Option) as Some).0: i32)) -> [1_i32: bb4, 8_i32: bb4, otherwise: bb1]; // scope 0 at $DIR/exponential_or.rs:+2:37: +2:55
     }
 
     bb4: {
-        _5 = Le(const 6_u32, (_1.3: u32)); // scope 0 at $DIR/exponential-or.rs:+2:62: +2:67
-        switchInt(move _5) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/exponential-or.rs:+2:62: +2:67
+        _5 = Le(const 6_u32, (_1.3: u32)); // scope 0 at $DIR/exponential_or.rs:+2:62: +2:67
+        switchInt(move _5) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/exponential_or.rs:+2:62: +2:67
     }
 
     bb5: {
-        _6 = Le((_1.3: u32), const 9_u32); // scope 0 at $DIR/exponential-or.rs:+2:62: +2:67
-        switchInt(move _6) -> [false: bb6, otherwise: bb8]; // scope 0 at $DIR/exponential-or.rs:+2:62: +2:67
+        _6 = Le((_1.3: u32), const 9_u32); // scope 0 at $DIR/exponential_or.rs:+2:62: +2:67
+        switchInt(move _6) -> [false: bb6, otherwise: bb8]; // scope 0 at $DIR/exponential_or.rs:+2:62: +2:67
     }
 
     bb6: {
-        _3 = Le(const 13_u32, (_1.3: u32)); // scope 0 at $DIR/exponential-or.rs:+2:70: +2:77
-        switchInt(move _3) -> [false: bb1, otherwise: bb7]; // scope 0 at $DIR/exponential-or.rs:+2:70: +2:77
+        _3 = Le(const 13_u32, (_1.3: u32)); // scope 0 at $DIR/exponential_or.rs:+2:70: +2:77
+        switchInt(move _3) -> [false: bb1, otherwise: bb7]; // scope 0 at $DIR/exponential_or.rs:+2:70: +2:77
     }
 
     bb7: {
-        _4 = Le((_1.3: u32), const 16_u32); // scope 0 at $DIR/exponential-or.rs:+2:70: +2:77
-        switchInt(move _4) -> [false: bb1, otherwise: bb8]; // scope 0 at $DIR/exponential-or.rs:+2:70: +2:77
+        _4 = Le((_1.3: u32), const 16_u32); // scope 0 at $DIR/exponential_or.rs:+2:70: +2:77
+        switchInt(move _4) -> [false: bb1, otherwise: bb8]; // scope 0 at $DIR/exponential_or.rs:+2:70: +2:77
     }
 
     bb8: {
-        falseEdge -> [real: bb9, imaginary: bb1]; // scope 0 at $DIR/exponential-or.rs:+2:9: +2:79
+        falseEdge -> [real: bb9, imaginary: bb1]; // scope 0 at $DIR/exponential_or.rs:+2:9: +2:79
     }
 
     bb9: {
-        StorageLive(_7);                 // scope 0 at $DIR/exponential-or.rs:+2:10: +2:11
-        _7 = (_1.0: u32);                // scope 0 at $DIR/exponential-or.rs:+2:10: +2:11
-        StorageLive(_8);                 // scope 0 at $DIR/exponential-or.rs:+2:57: +2:58
-        _8 = (_1.3: u32);                // scope 0 at $DIR/exponential-or.rs:+2:57: +2:58
-        StorageLive(_9);                 // scope 1 at $DIR/exponential-or.rs:+2:83: +2:84
-        _9 = _7;                         // scope 1 at $DIR/exponential-or.rs:+2:83: +2:84
-        StorageLive(_10);                // scope 1 at $DIR/exponential-or.rs:+2:87: +2:88
-        _10 = _8;                        // scope 1 at $DIR/exponential-or.rs:+2:87: +2:88
-        _0 = BitXor(move _9, move _10);  // scope 1 at $DIR/exponential-or.rs:+2:83: +2:88
-        StorageDead(_10);                // scope 1 at $DIR/exponential-or.rs:+2:87: +2:88
-        StorageDead(_9);                 // scope 1 at $DIR/exponential-or.rs:+2:87: +2:88
-        StorageDead(_8);                 // scope 0 at $DIR/exponential-or.rs:+2:87: +2:88
-        StorageDead(_7);                 // scope 0 at $DIR/exponential-or.rs:+2:87: +2:88
-        goto -> bb10;                    // scope 0 at $DIR/exponential-or.rs:+2:87: +2:88
+        StorageLive(_7);                 // scope 0 at $DIR/exponential_or.rs:+2:10: +2:11
+        _7 = (_1.0: u32);                // scope 0 at $DIR/exponential_or.rs:+2:10: +2:11
+        StorageLive(_8);                 // scope 0 at $DIR/exponential_or.rs:+2:57: +2:58
+        _8 = (_1.3: u32);                // scope 0 at $DIR/exponential_or.rs:+2:57: +2:58
+        StorageLive(_9);                 // scope 1 at $DIR/exponential_or.rs:+2:83: +2:84
+        _9 = _7;                         // scope 1 at $DIR/exponential_or.rs:+2:83: +2:84
+        StorageLive(_10);                // scope 1 at $DIR/exponential_or.rs:+2:87: +2:88
+        _10 = _8;                        // scope 1 at $DIR/exponential_or.rs:+2:87: +2:88
+        _0 = BitXor(move _9, move _10);  // scope 1 at $DIR/exponential_or.rs:+2:83: +2:88
+        StorageDead(_10);                // scope 1 at $DIR/exponential_or.rs:+2:87: +2:88
+        StorageDead(_9);                 // scope 1 at $DIR/exponential_or.rs:+2:87: +2:88
+        StorageDead(_8);                 // scope 0 at $DIR/exponential_or.rs:+2:87: +2:88
+        StorageDead(_7);                 // scope 0 at $DIR/exponential_or.rs:+2:87: +2:88
+        goto -> bb10;                    // scope 0 at $DIR/exponential_or.rs:+2:87: +2:88
     }
 
     bb10: {
-        return;                          // scope 0 at $DIR/exponential-or.rs:+5:2: +5:2
+        return;                          // scope 0 at $DIR/exponential_or.rs:+5:2: +5:2
     }
 }
diff --git a/src/test/mir-opt/exponential-or.rs b/src/test/mir-opt/exponential_or.rs
similarity index 100%
rename from src/test/mir-opt/exponential-or.rs
rename to src/test/mir-opt/exponential_or.rs
diff --git a/src/test/mir-opt/fn-ptr-shim.rs b/src/test/mir-opt/fn_ptr_shim.rs
similarity index 100%
rename from src/test/mir-opt/fn-ptr-shim.rs
rename to src/test/mir-opt/fn_ptr_shim.rs
diff --git a/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir b/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir
index c718138b6b3..c3b08bf0648 100644
--- a/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir
+++ b/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir
@@ -14,71 +14,71 @@
     },
 } */
 
-fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 10:17]) -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
-    let mut _2: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
-    let _3: std::string::String;         // in scope 0 at $DIR/generator-drop-cleanup.rs:+1:13: +1:15
-    let _4: ();                          // in scope 0 at $DIR/generator-drop-cleanup.rs:+2:9: +2:14
-    let mut _5: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:+2:9: +2:14
-    let mut _6: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:18: +0:18
-    let mut _7: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
-    let mut _8: u32;                     // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
+fn main::{closure#0}(_1: *mut [generator@$DIR/generator_drop_cleanup.rs:10:15: 10:17]) -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
+    let mut _2: ();                      // in scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
+    let _3: std::string::String;         // in scope 0 at $DIR/generator_drop_cleanup.rs:+1:13: +1:15
+    let _4: ();                          // in scope 0 at $DIR/generator_drop_cleanup.rs:+2:9: +2:14
+    let mut _5: ();                      // in scope 0 at $DIR/generator_drop_cleanup.rs:+2:9: +2:14
+    let mut _6: ();                      // in scope 0 at $DIR/generator_drop_cleanup.rs:+0:18: +0:18
+    let mut _7: ();                      // in scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
+    let mut _8: u32;                     // in scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
     scope 1 {
-        debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator-drop-cleanup.rs:+1:13: +1:15
+        debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator_drop_cleanup.rs:+1:13: +1:15
     }
 
     bb0: {
-        _8 = discriminant((*_1));        // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
-        switchInt(move _8) -> [0_u32: bb7, 3_u32: bb10, otherwise: bb11]; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
+        _8 = discriminant((*_1));        // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
+        switchInt(move _8) -> [0_u32: bb7, 3_u32: bb10, otherwise: bb11]; // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
     }
 
     bb1: {
-        StorageDead(_5);                 // scope 1 at $DIR/generator-drop-cleanup.rs:+2:13: +2:14
-        StorageDead(_4);                 // scope 1 at $DIR/generator-drop-cleanup.rs:+2:14: +2:15
-        drop((((*_1) as variant#3).0: std::string::String)) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6
+        StorageDead(_5);                 // scope 1 at $DIR/generator_drop_cleanup.rs:+2:13: +2:14
+        StorageDead(_4);                 // scope 1 at $DIR/generator_drop_cleanup.rs:+2:14: +2:15
+        drop((((*_1) as variant#3).0: std::string::String)) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/generator_drop_cleanup.rs:+3:5: +3:6
     }
 
     bb2: {
-        nop;                             // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6
-        goto -> bb8;                     // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6
+        nop;                             // scope 0 at $DIR/generator_drop_cleanup.rs:+3:5: +3:6
+        goto -> bb8;                     // scope 0 at $DIR/generator_drop_cleanup.rs:+3:5: +3:6
     }
 
     bb3: {
-        return;                          // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
+        return;                          // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
     }
 
     bb4 (cleanup): {
-        resume;                          // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
+        resume;                          // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
     }
 
     bb5 (cleanup): {
-        nop;                             // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6
-        goto -> bb4;                     // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6
+        nop;                             // scope 0 at $DIR/generator_drop_cleanup.rs:+3:5: +3:6
+        goto -> bb4;                     // scope 0 at $DIR/generator_drop_cleanup.rs:+3:5: +3:6
     }
 
     bb6: {
-        return;                          // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
+        return;                          // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
     }
 
     bb7: {
-        goto -> bb9;                     // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
+        goto -> bb9;                     // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
     }
 
     bb8: {
-        goto -> bb3;                     // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6
+        goto -> bb3;                     // scope 0 at $DIR/generator_drop_cleanup.rs:+3:5: +3:6
     }
 
     bb9: {
-        goto -> bb6;                     // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
+        goto -> bb6;                     // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
     }
 
     bb10: {
-        StorageLive(_4);                 // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
-        StorageLive(_5);                 // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
-        goto -> bb1;                     // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
+        StorageLive(_4);                 // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
+        StorageLive(_5);                 // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
+        goto -> bb1;                     // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
     }
 
     bb11: {
-        return;                          // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6
+        return;                          // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6
     }
 }
diff --git a/src/test/mir-opt/generator-drop-cleanup.rs b/src/test/mir-opt/generator_drop_cleanup.rs
similarity index 100%
rename from src/test/mir-opt/generator-drop-cleanup.rs
rename to src/test/mir-opt/generator_drop_cleanup.rs
diff --git a/src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir b/src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir
index 3184343f207..cfbe0aaf252 100644
--- a/src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir
+++ b/src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir
@@ -1,124 +1,124 @@
 // MIR for `main::{closure#0}` before StateTransform
 
-fn main::{closure#0}(_1: [generator@$DIR/generator-storage-dead-unwind.rs:22:16: 22:18], _2: ()) -> ()
+fn main::{closure#0}(_1: [generator@$DIR/generator_storage_dead_unwind.rs:22:16: 22:18], _2: ()) -> ()
 yields ()
  {
-    let mut _0: ();                      // return place in scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:19: +0:19
-    let _3: Foo;                         // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+1:13: +1:14
-    let _5: ();                          // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14
-    let mut _6: ();                      // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14
-    let _7: ();                          // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+4:9: +4:16
-    let mut _8: Foo;                     // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+4:14: +4:15
-    let _9: ();                          // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+5:9: +5:16
-    let mut _10: Bar;                    // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+5:14: +5:15
+    let mut _0: ();                      // return place in scope 0 at $DIR/generator_storage_dead_unwind.rs:+0:19: +0:19
+    let _3: Foo;                         // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+1:13: +1:14
+    let _5: ();                          // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+3:9: +3:14
+    let mut _6: ();                      // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+3:9: +3:14
+    let _7: ();                          // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+4:9: +4:16
+    let mut _8: Foo;                     // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+4:14: +4:15
+    let _9: ();                          // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+5:9: +5:16
+    let mut _10: Bar;                    // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+5:14: +5:15
     scope 1 {
-        debug a => _3;                   // in scope 1 at $DIR/generator-storage-dead-unwind.rs:+1:13: +1:14
-        let _4: Bar;                     // in scope 1 at $DIR/generator-storage-dead-unwind.rs:+2:13: +2:14
+        debug a => _3;                   // in scope 1 at $DIR/generator_storage_dead_unwind.rs:+1:13: +1:14
+        let _4: Bar;                     // in scope 1 at $DIR/generator_storage_dead_unwind.rs:+2:13: +2:14
         scope 2 {
-            debug b => _4;               // in scope 2 at $DIR/generator-storage-dead-unwind.rs:+2:13: +2:14
+            debug b => _4;               // in scope 2 at $DIR/generator_storage_dead_unwind.rs:+2:13: +2:14
         }
     }
 
     bb0: {
-        StorageLive(_3);                 // scope 0 at $DIR/generator-storage-dead-unwind.rs:+1:13: +1:14
-        _3 = Foo(const 5_i32);           // scope 0 at $DIR/generator-storage-dead-unwind.rs:+1:17: +1:23
-        StorageLive(_4);                 // scope 1 at $DIR/generator-storage-dead-unwind.rs:+2:13: +2:14
-        _4 = Bar(const 6_i32);           // scope 1 at $DIR/generator-storage-dead-unwind.rs:+2:17: +2:23
-        StorageLive(_5);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14
-        StorageLive(_6);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14
-        _6 = ();                         // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14
-        _5 = yield(move _6) -> [resume: bb1, drop: bb6]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14
+        StorageLive(_3);                 // scope 0 at $DIR/generator_storage_dead_unwind.rs:+1:13: +1:14
+        _3 = Foo(const 5_i32);           // scope 0 at $DIR/generator_storage_dead_unwind.rs:+1:17: +1:23
+        StorageLive(_4);                 // scope 1 at $DIR/generator_storage_dead_unwind.rs:+2:13: +2:14
+        _4 = Bar(const 6_i32);           // scope 1 at $DIR/generator_storage_dead_unwind.rs:+2:17: +2:23
+        StorageLive(_5);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:9: +3:14
+        StorageLive(_6);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:9: +3:14
+        _6 = ();                         // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:9: +3:14
+        _5 = yield(move _6) -> [resume: bb1, drop: bb6]; // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:9: +3:14
     }
 
     bb1: {
-        StorageDead(_6);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:13: +3:14
-        StorageDead(_5);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:14: +3:15
-        StorageLive(_7);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:9: +4:16
-        StorageLive(_8);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:14: +4:15
-        _8 = move _3;                    // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:14: +4:15
-        _7 = take::(move _8) -> [return: bb2, unwind: bb10]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:9: +4:16
+        StorageDead(_6);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:13: +3:14
+        StorageDead(_5);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:14: +3:15
+        StorageLive(_7);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:9: +4:16
+        StorageLive(_8);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:14: +4:15
+        _8 = move _3;                    // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:14: +4:15
+        _7 = take::(move _8) -> [return: bb2, unwind: bb10]; // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:9: +4:16
                                          // mir::Constant
-                                         // + span: $DIR/generator-storage-dead-unwind.rs:26:9: 26:13
+                                         // + span: $DIR/generator_storage_dead_unwind.rs:26:9: 26:13
                                          // + literal: Const { ty: fn(Foo) {take::}, val: Value() }
     }
 
     bb2: {
-        StorageDead(_8);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:15: +4:16
-        StorageDead(_7);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:16: +4:17
-        StorageLive(_9);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:9: +5:16
-        StorageLive(_10);                // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:14: +5:15
-        _10 = move _4;                   // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:14: +5:15
-        _9 = take::(move _10) -> [return: bb3, unwind: bb9]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:9: +5:16
+        StorageDead(_8);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:15: +4:16
+        StorageDead(_7);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:16: +4:17
+        StorageLive(_9);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:9: +5:16
+        StorageLive(_10);                // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:14: +5:15
+        _10 = move _4;                   // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:14: +5:15
+        _9 = take::(move _10) -> [return: bb3, unwind: bb9]; // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:9: +5:16
                                          // mir::Constant
-                                         // + span: $DIR/generator-storage-dead-unwind.rs:27:9: 27:13
+                                         // + span: $DIR/generator_storage_dead_unwind.rs:27:9: 27:13
                                          // + literal: Const { ty: fn(Bar) {take::}, val: Value() }
     }
 
     bb3: {
-        StorageDead(_10);                // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:15: +5:16
-        StorageDead(_9);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:16: +5:17
-        _0 = const ();                   // scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:19: +6:6
-        StorageDead(_4);                 // scope 1 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
-        goto -> bb4;                     // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
+        StorageDead(_10);                // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:15: +5:16
+        StorageDead(_9);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:16: +5:17
+        _0 = const ();                   // scope 0 at $DIR/generator_storage_dead_unwind.rs:+0:19: +6:6
+        StorageDead(_4);                 // scope 1 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
+        goto -> bb4;                     // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
     }
 
     bb4: {
-        StorageDead(_3);                 // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
-        drop(_1) -> [return: bb5, unwind: bb14]; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
+        StorageDead(_3);                 // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
+        drop(_1) -> [return: bb5, unwind: bb14]; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
     }
 
     bb5: {
-        return;                          // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:6: +6:6
+        return;                          // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:6: +6:6
     }
 
     bb6: {
-        StorageDead(_6);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:13: +3:14
-        StorageDead(_5);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:14: +3:15
-        StorageDead(_4);                 // scope 1 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
-        drop(_3) -> [return: bb7, unwind: bb15]; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
+        StorageDead(_6);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:13: +3:14
+        StorageDead(_5);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:14: +3:15
+        StorageDead(_4);                 // scope 1 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
+        drop(_3) -> [return: bb7, unwind: bb15]; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
     }
 
     bb7: {
-        StorageDead(_3);                 // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
-        drop(_1) -> [return: bb8, unwind: bb14]; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
+        StorageDead(_3);                 // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
+        drop(_1) -> [return: bb8, unwind: bb14]; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
     }
 
     bb8: {
-        generator_drop;                  // scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:16: +6:6
+        generator_drop;                  // scope 0 at $DIR/generator_storage_dead_unwind.rs:+0:16: +6:6
     }
 
     bb9 (cleanup): {
-        StorageDead(_10);                // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:15: +5:16
-        StorageDead(_9);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:16: +5:17
+        StorageDead(_10);                // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:15: +5:16
+        StorageDead(_9);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:16: +5:17
         goto -> bb12;                    // scope 2 at no-location
     }
 
     bb10 (cleanup): {
-        goto -> bb11;                    // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:15: +4:16
+        goto -> bb11;                    // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:15: +4:16
     }
 
     bb11 (cleanup): {
-        StorageDead(_8);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:15: +4:16
-        StorageDead(_7);                 // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:16: +4:17
+        StorageDead(_8);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:15: +4:16
+        StorageDead(_7);                 // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:16: +4:17
         goto -> bb12;                    // scope 2 at no-location
     }
 
     bb12 (cleanup): {
-        StorageDead(_4);                 // scope 1 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
-        goto -> bb13;                    // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
+        StorageDead(_4);                 // scope 1 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
+        goto -> bb13;                    // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
     }
 
     bb13 (cleanup): {
-        StorageDead(_3);                 // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
-        drop(_1) -> bb14;                // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
+        StorageDead(_3);                 // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
+        drop(_1) -> bb14;                // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
     }
 
     bb14 (cleanup): {
-        resume;                          // scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:16: +6:6
+        resume;                          // scope 0 at $DIR/generator_storage_dead_unwind.rs:+0:16: +6:6
     }
 
     bb15 (cleanup): {
-        StorageDead(_3);                 // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
-        drop(_1) -> bb14;                // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6
+        StorageDead(_3);                 // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
+        drop(_1) -> bb14;                // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6
     }
 }
diff --git a/src/test/mir-opt/generator-storage-dead-unwind.rs b/src/test/mir-opt/generator_storage_dead_unwind.rs
similarity index 100%
rename from src/test/mir-opt/generator-storage-dead-unwind.rs
rename to src/test/mir-opt/generator_storage_dead_unwind.rs
diff --git a/src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir b/src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir
index 07aeeaae012..fee6da2c635 100644
--- a/src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir
+++ b/src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir
@@ -14,71 +14,71 @@
     },
 } */
 
-fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]>, _2: u8) -> GeneratorState<(), ()> {
-    debug _x => _10;                     // in scope 0 at $DIR/generator-tiny.rs:+0:17: +0:19
-    let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6
-    let _3: HasDrop;                     // in scope 0 at $DIR/generator-tiny.rs:+1:13: +1:15
-    let mut _4: !;                       // in scope 0 at $DIR/generator-tiny.rs:+2:9: +5:10
-    let mut _5: ();                      // in scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6
-    let _6: u8;                          // in scope 0 at $DIR/generator-tiny.rs:+3:13: +3:18
-    let mut _7: ();                      // in scope 0 at $DIR/generator-tiny.rs:+3:13: +3:18
-    let _8: ();                          // in scope 0 at $DIR/generator-tiny.rs:+4:13: +4:21
-    let mut _9: ();                      // in scope 0 at $DIR/generator-tiny.rs:+0:25: +0:25
-    let _10: u8;                         // in scope 0 at $DIR/generator-tiny.rs:+0:17: +0:19
-    let mut _11: u32;                    // in scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6
+fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator_tiny.rs:19:16: 19:24]>, _2: u8) -> GeneratorState<(), ()> {
+    debug _x => _10;                     // in scope 0 at $DIR/generator_tiny.rs:+0:17: +0:19
+    let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6
+    let _3: HasDrop;                     // in scope 0 at $DIR/generator_tiny.rs:+1:13: +1:15
+    let mut _4: !;                       // in scope 0 at $DIR/generator_tiny.rs:+2:9: +5:10
+    let mut _5: ();                      // in scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6
+    let _6: u8;                          // in scope 0 at $DIR/generator_tiny.rs:+3:13: +3:18
+    let mut _7: ();                      // in scope 0 at $DIR/generator_tiny.rs:+3:13: +3:18
+    let _8: ();                          // in scope 0 at $DIR/generator_tiny.rs:+4:13: +4:21
+    let mut _9: ();                      // in scope 0 at $DIR/generator_tiny.rs:+0:25: +0:25
+    let _10: u8;                         // in scope 0 at $DIR/generator_tiny.rs:+0:17: +0:19
+    let mut _11: u32;                    // in scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6
     scope 1 {
-        debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:+1:13: +1:15
+        debug _d => (((*(_1.0: &mut [generator@$DIR/generator_tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator_tiny.rs:+1:13: +1:15
     }
 
     bb0: {
-        _11 = discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]))); // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6
-        switchInt(move _11) -> [0_u32: bb1, 3_u32: bb5, otherwise: bb6]; // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6
+        _11 = discriminant((*(_1.0: &mut [generator@$DIR/generator_tiny.rs:19:16: 19:24]))); // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6
+        switchInt(move _11) -> [0_u32: bb1, 3_u32: bb5, otherwise: bb6]; // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6
     }
 
     bb1: {
-        _10 = move _2;                   // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6
-        nop;                             // scope 0 at $DIR/generator-tiny.rs:+1:13: +1:15
-        (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop) = HasDrop; // scope 0 at $DIR/generator-tiny.rs:+1:18: +1:25
-        StorageLive(_4);                 // scope 1 at $DIR/generator-tiny.rs:+2:9: +5:10
-        goto -> bb2;                     // scope 1 at $DIR/generator-tiny.rs:+2:9: +5:10
+        _10 = move _2;                   // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6
+        nop;                             // scope 0 at $DIR/generator_tiny.rs:+1:13: +1:15
+        (((*(_1.0: &mut [generator@$DIR/generator_tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop) = HasDrop; // scope 0 at $DIR/generator_tiny.rs:+1:18: +1:25
+        StorageLive(_4);                 // scope 1 at $DIR/generator_tiny.rs:+2:9: +5:10
+        goto -> bb2;                     // scope 1 at $DIR/generator_tiny.rs:+2:9: +5:10
     }
 
     bb2: {
-        StorageLive(_6);                 // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18
-        StorageLive(_7);                 // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18
-        _7 = ();                         // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18
-        Deinit(_0);                      // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18
-        ((_0 as Yielded).0: ()) = move _7; // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18
-        discriminant(_0) = 0;            // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18
-        discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]))) = 3; // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18
-        return;                          // scope 1 at $DIR/generator-tiny.rs:+3:13: +3:18
+        StorageLive(_6);                 // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18
+        StorageLive(_7);                 // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18
+        _7 = ();                         // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18
+        Deinit(_0);                      // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18
+        ((_0 as Yielded).0: ()) = move _7; // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18
+        discriminant(_0) = 0;            // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18
+        discriminant((*(_1.0: &mut [generator@$DIR/generator_tiny.rs:19:16: 19:24]))) = 3; // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18
+        return;                          // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18
     }
 
     bb3: {
-        StorageDead(_7);                 // scope 1 at $DIR/generator-tiny.rs:+3:17: +3:18
-        StorageDead(_6);                 // scope 1 at $DIR/generator-tiny.rs:+3:18: +3:19
-        StorageLive(_8);                 // scope 1 at $DIR/generator-tiny.rs:+4:13: +4:21
-        _8 = callee() -> bb4;            // scope 1 at $DIR/generator-tiny.rs:+4:13: +4:21
+        StorageDead(_7);                 // scope 1 at $DIR/generator_tiny.rs:+3:17: +3:18
+        StorageDead(_6);                 // scope 1 at $DIR/generator_tiny.rs:+3:18: +3:19
+        StorageLive(_8);                 // scope 1 at $DIR/generator_tiny.rs:+4:13: +4:21
+        _8 = callee() -> bb4;            // scope 1 at $DIR/generator_tiny.rs:+4:13: +4:21
                                          // mir::Constant
-                                         // + span: $DIR/generator-tiny.rs:23:13: 23:19
+                                         // + span: $DIR/generator_tiny.rs:23:13: 23:19
                                          // + literal: Const { ty: fn() {callee}, val: Value() }
     }
 
     bb4: {
-        StorageDead(_8);                 // scope 1 at $DIR/generator-tiny.rs:+4:21: +4:22
-        _5 = const ();                   // scope 1 at $DIR/generator-tiny.rs:+2:14: +5:10
-        goto -> bb2;                     // scope 1 at $DIR/generator-tiny.rs:+2:9: +5:10
+        StorageDead(_8);                 // scope 1 at $DIR/generator_tiny.rs:+4:21: +4:22
+        _5 = const ();                   // scope 1 at $DIR/generator_tiny.rs:+2:14: +5:10
+        goto -> bb2;                     // scope 1 at $DIR/generator_tiny.rs:+2:9: +5:10
     }
 
     bb5: {
-        StorageLive(_4);                 // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6
-        StorageLive(_6);                 // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6
-        StorageLive(_7);                 // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6
-        _6 = move _2;                    // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6
-        goto -> bb3;                     // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6
+        StorageLive(_4);                 // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6
+        StorageLive(_6);                 // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6
+        StorageLive(_7);                 // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6
+        _6 = move _2;                    // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6
+        goto -> bb3;                     // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6
     }
 
     bb6: {
-        unreachable;                     // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6
+        unreachable;                     // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6
     }
 }
diff --git a/src/test/mir-opt/generator-tiny.rs b/src/test/mir-opt/generator_tiny.rs
similarity index 100%
rename from src/test/mir-opt/generator-tiny.rs
rename to src/test/mir-opt/generator_tiny.rs
diff --git a/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff
index 19b5ab44156..94180d20343 100644
--- a/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff
+++ b/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff
@@ -2,29 +2,29 @@
 + // MIR for `dont_opt_bool` after SimplifyComparisonIntegral
   
   fn dont_opt_bool(_1: bool) -> u32 {
-      debug x => _1;                       // in scope 0 at $DIR/if-condition-int.rs:+0:18: +0:19
-      let mut _0: u32;                     // return place in scope 0 at $DIR/if-condition-int.rs:+0:30: +0:33
-      let mut _2: bool;                    // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
+      debug x => _1;                       // in scope 0 at $DIR/if_condition_int.rs:+0:18: +0:19
+      let mut _0: u32;                     // return place in scope 0 at $DIR/if_condition_int.rs:+0:30: +0:33
+      let mut _2: bool;                    // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
-          _2 = _1;                         // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
-          switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
+          StorageLive(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+          _2 = _1;                         // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+          switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
       }
   
       bb1: {
-          _0 = const 0_u32;                // scope 0 at $DIR/if-condition-int.rs:+1:12: +1:13
-          goto -> bb3;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:26
+          _0 = const 0_u32;                // scope 0 at $DIR/if_condition_int.rs:+1:12: +1:13
+          goto -> bb3;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:26
       }
   
       bb2: {
-          _0 = const 1_u32;                // scope 0 at $DIR/if-condition-int.rs:+1:23: +1:24
-          goto -> bb3;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:26
+          _0 = const 1_u32;                // scope 0 at $DIR/if_condition_int.rs:+1:23: +1:24
+          goto -> bb3;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:26
       }
   
       bb3: {
-          StorageDead(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:25: +1:26
-          return;                          // scope 0 at $DIR/if-condition-int.rs:+2:2: +2:2
+          StorageDead(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:25: +1:26
+          return;                          // scope 0 at $DIR/if_condition_int.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff
index 256af7b94be..b22c7eac622 100644
--- a/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff
+++ b/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff
@@ -2,33 +2,33 @@
 + // MIR for `dont_opt_floats` after SimplifyComparisonIntegral
   
   fn dont_opt_floats(_1: f32) -> i32 {
-      debug a => _1;                       // in scope 0 at $DIR/if-condition-int.rs:+0:20: +0:21
-      let mut _0: i32;                     // return place in scope 0 at $DIR/if-condition-int.rs:+0:31: +0:34
-      let mut _2: bool;                    // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:18
-      let mut _3: f32;                     // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
+      debug a => _1;                       // in scope 0 at $DIR/if_condition_int.rs:+0:20: +0:21
+      let mut _0: i32;                     // return place in scope 0 at $DIR/if_condition_int.rs:+0:31: +0:34
+      let mut _2: bool;                    // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:18
+      let mut _3: f32;                     // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:18
-          StorageLive(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
-          _3 = _1;                         // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
-          _2 = Eq(move _3, const -42f32);  // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:18
-          StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:17: +1:18
-          switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:18
+          StorageLive(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:18
+          StorageLive(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+          _3 = _1;                         // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+          _2 = Eq(move _3, const -42f32);  // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:18
+          StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:17: +1:18
+          switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:18
       }
   
       bb1: {
-          _0 = const 0_i32;                // scope 0 at $DIR/if-condition-int.rs:+1:21: +1:22
-          goto -> bb3;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:35
+          _0 = const 0_i32;                // scope 0 at $DIR/if_condition_int.rs:+1:21: +1:22
+          goto -> bb3;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:35
       }
   
       bb2: {
-          _0 = const 1_i32;                // scope 0 at $DIR/if-condition-int.rs:+1:32: +1:33
-          goto -> bb3;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:35
+          _0 = const 1_i32;                // scope 0 at $DIR/if_condition_int.rs:+1:32: +1:33
+          goto -> bb3;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:35
       }
   
       bb3: {
-          StorageDead(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:34: +1:35
-          return;                          // scope 0 at $DIR/if-condition-int.rs:+2:2: +2:2
+          StorageDead(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:34: +1:35
+          return;                          // scope 0 at $DIR/if_condition_int.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff
index ed53c9a956c..cc0995f99cf 100644
--- a/src/test/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff
+++ b/src/test/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff
@@ -2,57 +2,57 @@
 + // MIR for `dont_remove_comparison` after SimplifyComparisonIntegral
   
   fn dont_remove_comparison(_1: i8) -> i32 {
-      debug a => _1;                       // in scope 0 at $DIR/if-condition-int.rs:+0:27: +0:28
-      let mut _0: i32;                     // return place in scope 0 at $DIR/if-condition-int.rs:+0:37: +0:40
-      let _2: bool;                        // in scope 0 at $DIR/if-condition-int.rs:+1:9: +1:10
-      let mut _3: i8;                      // in scope 0 at $DIR/if-condition-int.rs:+1:13: +1:14
-      let mut _4: i32;                     // in scope 0 at $DIR/if-condition-int.rs:+3:23: +3:31
-      let mut _5: bool;                    // in scope 0 at $DIR/if-condition-int.rs:+3:23: +3:24
-      let mut _6: i32;                     // in scope 0 at $DIR/if-condition-int.rs:+4:23: +4:31
-      let mut _7: bool;                    // in scope 0 at $DIR/if-condition-int.rs:+4:23: +4:24
+      debug a => _1;                       // in scope 0 at $DIR/if_condition_int.rs:+0:27: +0:28
+      let mut _0: i32;                     // return place in scope 0 at $DIR/if_condition_int.rs:+0:37: +0:40
+      let _2: bool;                        // in scope 0 at $DIR/if_condition_int.rs:+1:9: +1:10
+      let mut _3: i8;                      // in scope 0 at $DIR/if_condition_int.rs:+1:13: +1:14
+      let mut _4: i32;                     // in scope 0 at $DIR/if_condition_int.rs:+3:23: +3:31
+      let mut _5: bool;                    // in scope 0 at $DIR/if_condition_int.rs:+3:23: +3:24
+      let mut _6: i32;                     // in scope 0 at $DIR/if_condition_int.rs:+4:23: +4:31
+      let mut _7: bool;                    // in scope 0 at $DIR/if_condition_int.rs:+4:23: +4:24
       scope 1 {
-          debug b => _2;                   // in scope 1 at $DIR/if-condition-int.rs:+1:9: +1:10
+          debug b => _2;                   // in scope 1 at $DIR/if_condition_int.rs:+1:9: +1:10
       }
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:9: +1:10
-          StorageLive(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:13: +1:14
-          _3 = _1;                         // scope 0 at $DIR/if-condition-int.rs:+1:13: +1:14
--         _2 = Eq(move _3, const 17_i8);   // scope 0 at $DIR/if-condition-int.rs:+1:13: +1:20
--         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:19: +1:20
--         switchInt(_2) -> [false: bb2, otherwise: bb1]; // scope 1 at $DIR/if-condition-int.rs:+2:5: +2:12
-+         _2 = Eq(_3, const 17_i8);        // scope 0 at $DIR/if-condition-int.rs:+1:13: +1:20
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+1:19: +1:20
-+         switchInt(move _3) -> [17_i8: bb1, otherwise: bb2]; // scope 1 at $DIR/if-condition-int.rs:+2:5: +2:12
+          StorageLive(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:9: +1:10
+          StorageLive(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:13: +1:14
+          _3 = _1;                         // scope 0 at $DIR/if_condition_int.rs:+1:13: +1:14
+-         _2 = Eq(move _3, const 17_i8);   // scope 0 at $DIR/if_condition_int.rs:+1:13: +1:20
+-         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:19: +1:20
+-         switchInt(_2) -> [false: bb2, otherwise: bb1]; // scope 1 at $DIR/if_condition_int.rs:+2:5: +2:12
++         _2 = Eq(_3, const 17_i8);        // scope 0 at $DIR/if_condition_int.rs:+1:13: +1:20
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+1:19: +1:20
++         switchInt(move _3) -> [17_i8: bb1, otherwise: bb2]; // scope 1 at $DIR/if_condition_int.rs:+2:5: +2:12
       }
   
       bb1: {
-+         StorageDead(_3);                 // scope 1 at $DIR/if-condition-int.rs:+2:5: +2:12
-          StorageLive(_6);                 // scope 1 at $DIR/if-condition-int.rs:+4:23: +4:31
-          StorageLive(_7);                 // scope 1 at $DIR/if-condition-int.rs:+4:23: +4:24
-          _7 = _2;                         // scope 1 at $DIR/if-condition-int.rs:+4:23: +4:24
-          _6 = move _7 as i32 (IntToInt);  // scope 1 at $DIR/if-condition-int.rs:+4:23: +4:31
-          StorageDead(_7);                 // scope 1 at $DIR/if-condition-int.rs:+4:30: +4:31
-          _0 = Add(const 100_i32, move _6); // scope 1 at $DIR/if-condition-int.rs:+4:17: +4:31
-          StorageDead(_6);                 // scope 1 at $DIR/if-condition-int.rs:+4:30: +4:31
-          goto -> bb3;                     // scope 1 at $DIR/if-condition-int.rs:+4:30: +4:31
++         StorageDead(_3);                 // scope 1 at $DIR/if_condition_int.rs:+2:5: +2:12
+          StorageLive(_6);                 // scope 1 at $DIR/if_condition_int.rs:+4:23: +4:31
+          StorageLive(_7);                 // scope 1 at $DIR/if_condition_int.rs:+4:23: +4:24
+          _7 = _2;                         // scope 1 at $DIR/if_condition_int.rs:+4:23: +4:24
+          _6 = move _7 as i32 (IntToInt);  // scope 1 at $DIR/if_condition_int.rs:+4:23: +4:31
+          StorageDead(_7);                 // scope 1 at $DIR/if_condition_int.rs:+4:30: +4:31
+          _0 = Add(const 100_i32, move _6); // scope 1 at $DIR/if_condition_int.rs:+4:17: +4:31
+          StorageDead(_6);                 // scope 1 at $DIR/if_condition_int.rs:+4:30: +4:31
+          goto -> bb3;                     // scope 1 at $DIR/if_condition_int.rs:+4:30: +4:31
       }
   
       bb2: {
-+         StorageDead(_3);                 // scope 1 at $DIR/if-condition-int.rs:+2:5: +2:12
-          StorageLive(_4);                 // scope 1 at $DIR/if-condition-int.rs:+3:23: +3:31
-          StorageLive(_5);                 // scope 1 at $DIR/if-condition-int.rs:+3:23: +3:24
-          _5 = _2;                         // scope 1 at $DIR/if-condition-int.rs:+3:23: +3:24
-          _4 = move _5 as i32 (IntToInt);  // scope 1 at $DIR/if-condition-int.rs:+3:23: +3:31
-          StorageDead(_5);                 // scope 1 at $DIR/if-condition-int.rs:+3:30: +3:31
-          _0 = Add(const 10_i32, move _4); // scope 1 at $DIR/if-condition-int.rs:+3:18: +3:31
-          StorageDead(_4);                 // scope 1 at $DIR/if-condition-int.rs:+3:30: +3:31
-          goto -> bb3;                     // scope 1 at $DIR/if-condition-int.rs:+3:30: +3:31
++         StorageDead(_3);                 // scope 1 at $DIR/if_condition_int.rs:+2:5: +2:12
+          StorageLive(_4);                 // scope 1 at $DIR/if_condition_int.rs:+3:23: +3:31
+          StorageLive(_5);                 // scope 1 at $DIR/if_condition_int.rs:+3:23: +3:24
+          _5 = _2;                         // scope 1 at $DIR/if_condition_int.rs:+3:23: +3:24
+          _4 = move _5 as i32 (IntToInt);  // scope 1 at $DIR/if_condition_int.rs:+3:23: +3:31
+          StorageDead(_5);                 // scope 1 at $DIR/if_condition_int.rs:+3:30: +3:31
+          _0 = Add(const 10_i32, move _4); // scope 1 at $DIR/if_condition_int.rs:+3:18: +3:31
+          StorageDead(_4);                 // scope 1 at $DIR/if_condition_int.rs:+3:30: +3:31
+          goto -> bb3;                     // scope 1 at $DIR/if_condition_int.rs:+3:30: +3:31
       }
   
       bb3: {
-          StorageDead(_2);                 // scope 0 at $DIR/if-condition-int.rs:+6:1: +6:2
-          return;                          // scope 0 at $DIR/if-condition-int.rs:+6:2: +6:2
+          StorageDead(_2);                 // scope 0 at $DIR/if_condition_int.rs:+6:1: +6:2
+          return;                          // scope 0 at $DIR/if_condition_int.rs:+6:2: +6:2
       }
   }
   
diff --git a/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff
index 9b64c379fee..801ea040203 100644
--- a/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff
+++ b/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff
@@ -2,38 +2,38 @@
 + // MIR for `opt_char` after SimplifyComparisonIntegral
   
   fn opt_char(_1: char) -> u32 {
-      debug x => _1;                       // in scope 0 at $DIR/if-condition-int.rs:+0:13: +0:14
-      let mut _0: u32;                     // return place in scope 0 at $DIR/if-condition-int.rs:+0:25: +0:28
-      let mut _2: bool;                    // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
-      let mut _3: char;                    // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
+      debug x => _1;                       // in scope 0 at $DIR/if_condition_int.rs:+0:13: +0:14
+      let mut _0: u32;                     // return place in scope 0 at $DIR/if_condition_int.rs:+0:25: +0:28
+      let mut _2: bool;                    // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
+      let mut _3: char;                    // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
-          StorageLive(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
-          _3 = _1;                         // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
--         _2 = Eq(move _3, const 'x');     // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
--         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:15: +1:16
--         switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+1:15: +1:16
-+         switchInt(move _3) -> ['x': bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
+          StorageLive(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
+          StorageLive(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+          _3 = _1;                         // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+-         _2 = Eq(move _3, const 'x');     // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
+-         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:15: +1:16
+-         switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+1:15: +1:16
++         switchInt(move _3) -> ['x': bb1, otherwise: bb2]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
       }
   
       bb1: {
-+         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
-          _0 = const 0_u32;                // scope 0 at $DIR/if-condition-int.rs:+1:19: +1:20
-          goto -> bb3;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:33
++         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
+          _0 = const 0_u32;                // scope 0 at $DIR/if_condition_int.rs:+1:19: +1:20
+          goto -> bb3;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:33
       }
   
       bb2: {
-+         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
-          _0 = const 1_u32;                // scope 0 at $DIR/if-condition-int.rs:+1:30: +1:31
-          goto -> bb3;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:33
++         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
+          _0 = const 1_u32;                // scope 0 at $DIR/if_condition_int.rs:+1:30: +1:31
+          goto -> bb3;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:33
       }
   
       bb3: {
-          StorageDead(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:32: +1:33
-          return;                          // scope 0 at $DIR/if-condition-int.rs:+2:2: +2:2
+          StorageDead(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:32: +1:33
+          return;                          // scope 0 at $DIR/if_condition_int.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff
index 8042d63bb34..4297f4d6466 100644
--- a/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff
+++ b/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff
@@ -2,38 +2,38 @@
 + // MIR for `opt_i8` after SimplifyComparisonIntegral
   
   fn opt_i8(_1: i8) -> u32 {
-      debug x => _1;                       // in scope 0 at $DIR/if-condition-int.rs:+0:11: +0:12
-      let mut _0: u32;                     // return place in scope 0 at $DIR/if-condition-int.rs:+0:21: +0:24
-      let mut _2: bool;                    // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-      let mut _3: i8;                      // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
+      debug x => _1;                       // in scope 0 at $DIR/if_condition_int.rs:+0:11: +0:12
+      let mut _0: u32;                     // return place in scope 0 at $DIR/if_condition_int.rs:+0:21: +0:24
+      let mut _2: bool;                    // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+      let mut _3: i8;                      // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-          StorageLive(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
-          _3 = _1;                         // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
--         _2 = Eq(move _3, const 42_i8);   // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
--         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:14: +1:15
--         switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+1:14: +1:15
-+         switchInt(move _3) -> [42_i8: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
+          StorageLive(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+          StorageLive(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+          _3 = _1;                         // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+-         _2 = Eq(move _3, const 42_i8);   // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+-         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:14: +1:15
+-         switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+1:14: +1:15
++         switchInt(move _3) -> [42_i8: bb1, otherwise: bb2]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
       }
   
       bb1: {
-+         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-          _0 = const 0_u32;                // scope 0 at $DIR/if-condition-int.rs:+1:18: +1:19
-          goto -> bb3;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:32
++         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+          _0 = const 0_u32;                // scope 0 at $DIR/if_condition_int.rs:+1:18: +1:19
+          goto -> bb3;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:32
       }
   
       bb2: {
-+         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-          _0 = const 1_u32;                // scope 0 at $DIR/if-condition-int.rs:+1:29: +1:30
-          goto -> bb3;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:32
++         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+          _0 = const 1_u32;                // scope 0 at $DIR/if_condition_int.rs:+1:29: +1:30
+          goto -> bb3;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:32
       }
   
       bb3: {
-          StorageDead(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:31: +1:32
-          return;                          // scope 0 at $DIR/if-condition-int.rs:+2:2: +2:2
+          StorageDead(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:31: +1:32
+          return;                          // scope 0 at $DIR/if_condition_int.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff
index a408de1ef3e..8fb794abbd4 100644
--- a/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff
+++ b/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff
@@ -2,64 +2,64 @@
 + // MIR for `opt_multiple_ifs` after SimplifyComparisonIntegral
   
   fn opt_multiple_ifs(_1: u32) -> u32 {
-      debug x => _1;                       // in scope 0 at $DIR/if-condition-int.rs:+0:21: +0:22
-      let mut _0: u32;                     // return place in scope 0 at $DIR/if-condition-int.rs:+0:32: +0:35
-      let mut _2: bool;                    // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-      let mut _3: u32;                     // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
-      let mut _4: bool;                    // in scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22
-      let mut _5: u32;                     // in scope 0 at $DIR/if-condition-int.rs:+3:15: +3:16
+      debug x => _1;                       // in scope 0 at $DIR/if_condition_int.rs:+0:21: +0:22
+      let mut _0: u32;                     // return place in scope 0 at $DIR/if_condition_int.rs:+0:32: +0:35
+      let mut _2: bool;                    // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+      let mut _3: u32;                     // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+      let mut _4: bool;                    // in scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22
+      let mut _5: u32;                     // in scope 0 at $DIR/if_condition_int.rs:+3:15: +3:16
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-          StorageLive(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
-          _3 = _1;                         // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
--         _2 = Eq(move _3, const 42_u32);  // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
--         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:14: +1:15
--         switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+1:14: +1:15
-+         switchInt(move _3) -> [42_u32: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
+          StorageLive(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+          StorageLive(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+          _3 = _1;                         // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+-         _2 = Eq(move _3, const 42_u32);  // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+-         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:14: +1:15
+-         switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+1:14: +1:15
++         switchInt(move _3) -> [42_u32: bb1, otherwise: bb2]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
       }
   
       bb1: {
-+         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-          _0 = const 0_u32;                // scope 0 at $DIR/if-condition-int.rs:+2:9: +2:10
-          goto -> bb6;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +7:6
++         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+          _0 = const 0_u32;                // scope 0 at $DIR/if_condition_int.rs:+2:9: +2:10
+          goto -> bb6;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +7:6
       }
   
       bb2: {
-+         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-          StorageLive(_4);                 // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22
-          StorageLive(_5);                 // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:16
-          _5 = _1;                         // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:16
--         _4 = Ne(move _5, const 21_u32);  // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22
--         StorageDead(_5);                 // scope 0 at $DIR/if-condition-int.rs:+3:21: +3:22
--         switchInt(move _4) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+3:21: +3:22
-+         switchInt(move _5) -> [21_u32: bb4, otherwise: bb3]; // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22
++         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+          StorageLive(_4);                 // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22
+          StorageLive(_5);                 // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:16
+          _5 = _1;                         // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:16
+-         _4 = Ne(move _5, const 21_u32);  // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22
+-         StorageDead(_5);                 // scope 0 at $DIR/if_condition_int.rs:+3:21: +3:22
+-         switchInt(move _4) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+3:21: +3:22
++         switchInt(move _5) -> [21_u32: bb4, otherwise: bb3]; // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22
       }
   
       bb3: {
-+         StorageDead(_5);                 // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22
-          _0 = const 1_u32;                // scope 0 at $DIR/if-condition-int.rs:+4:9: +4:10
-          goto -> bb5;                     // scope 0 at $DIR/if-condition-int.rs:+3:12: +7:6
++         StorageDead(_5);                 // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22
+          _0 = const 1_u32;                // scope 0 at $DIR/if_condition_int.rs:+4:9: +4:10
+          goto -> bb5;                     // scope 0 at $DIR/if_condition_int.rs:+3:12: +7:6
       }
   
       bb4: {
-+         StorageDead(_5);                 // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22
-          _0 = const 2_u32;                // scope 0 at $DIR/if-condition-int.rs:+6:9: +6:10
-          goto -> bb5;                     // scope 0 at $DIR/if-condition-int.rs:+3:12: +7:6
++         StorageDead(_5);                 // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22
+          _0 = const 2_u32;                // scope 0 at $DIR/if_condition_int.rs:+6:9: +6:10
+          goto -> bb5;                     // scope 0 at $DIR/if_condition_int.rs:+3:12: +7:6
       }
   
       bb5: {
-          StorageDead(_4);                 // scope 0 at $DIR/if-condition-int.rs:+7:5: +7:6
-          goto -> bb6;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +7:6
+          StorageDead(_4);                 // scope 0 at $DIR/if_condition_int.rs:+7:5: +7:6
+          goto -> bb6;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +7:6
       }
   
       bb6: {
-          StorageDead(_2);                 // scope 0 at $DIR/if-condition-int.rs:+7:5: +7:6
-          return;                          // scope 0 at $DIR/if-condition-int.rs:+8:2: +8:2
+          StorageDead(_2);                 // scope 0 at $DIR/if_condition_int.rs:+7:5: +7:6
+          return;                          // scope 0 at $DIR/if_condition_int.rs:+8:2: +8:2
       }
   }
   
diff --git a/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff
index 6802f89d927..992253ea780 100644
--- a/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff
+++ b/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff
@@ -2,38 +2,38 @@
 + // MIR for `opt_negative` after SimplifyComparisonIntegral
   
   fn opt_negative(_1: i32) -> u32 {
-      debug x => _1;                       // in scope 0 at $DIR/if-condition-int.rs:+0:17: +0:18
-      let mut _0: u32;                     // return place in scope 0 at $DIR/if-condition-int.rs:+0:28: +0:31
-      let mut _2: bool;                    // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
-      let mut _3: i32;                     // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
+      debug x => _1;                       // in scope 0 at $DIR/if_condition_int.rs:+0:17: +0:18
+      let mut _0: u32;                     // return place in scope 0 at $DIR/if_condition_int.rs:+0:28: +0:31
+      let mut _2: bool;                    // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
+      let mut _3: i32;                     // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
-          StorageLive(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
-          _3 = _1;                         // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
--         _2 = Eq(move _3, const -42_i32); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
--         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:15: +1:16
--         switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+1:15: +1:16
-+         switchInt(move _3) -> [-42_i32: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
+          StorageLive(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
+          StorageLive(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+          _3 = _1;                         // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+-         _2 = Eq(move _3, const -42_i32); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
+-         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:15: +1:16
+-         switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+1:15: +1:16
++         switchInt(move _3) -> [-42_i32: bb1, otherwise: bb2]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
       }
   
       bb1: {
-+         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
-          _0 = const 0_u32;                // scope 0 at $DIR/if-condition-int.rs:+1:19: +1:20
-          goto -> bb3;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:33
++         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
+          _0 = const 0_u32;                // scope 0 at $DIR/if_condition_int.rs:+1:19: +1:20
+          goto -> bb3;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:33
       }
   
       bb2: {
-+         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16
-          _0 = const 1_u32;                // scope 0 at $DIR/if-condition-int.rs:+1:30: +1:31
-          goto -> bb3;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:33
++         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16
+          _0 = const 1_u32;                // scope 0 at $DIR/if_condition_int.rs:+1:30: +1:31
+          goto -> bb3;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:33
       }
   
       bb3: {
-          StorageDead(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:32: +1:33
-          return;                          // scope 0 at $DIR/if-condition-int.rs:+2:2: +2:2
+          StorageDead(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:32: +1:33
+          return;                          // scope 0 at $DIR/if_condition_int.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff
index 96387771d06..7cea9472d3a 100644
--- a/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff
+++ b/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff
@@ -2,38 +2,38 @@
 + // MIR for `opt_u32` after SimplifyComparisonIntegral
   
   fn opt_u32(_1: u32) -> u32 {
-      debug x => _1;                       // in scope 0 at $DIR/if-condition-int.rs:+0:12: +0:13
-      let mut _0: u32;                     // return place in scope 0 at $DIR/if-condition-int.rs:+0:23: +0:26
-      let mut _2: bool;                    // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-      let mut _3: u32;                     // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
+      debug x => _1;                       // in scope 0 at $DIR/if_condition_int.rs:+0:12: +0:13
+      let mut _0: u32;                     // return place in scope 0 at $DIR/if_condition_int.rs:+0:23: +0:26
+      let mut _2: bool;                    // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+      let mut _3: u32;                     // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-          StorageLive(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
-          _3 = _1;                         // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9
--         _2 = Eq(move _3, const 42_u32);  // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
--         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:14: +1:15
--         switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-+         nop;                             // scope 0 at $DIR/if-condition-int.rs:+1:14: +1:15
-+         switchInt(move _3) -> [42_u32: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
+          StorageLive(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+          StorageLive(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+          _3 = _1;                         // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9
+-         _2 = Eq(move _3, const 42_u32);  // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+-         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:14: +1:15
+-         switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
++         nop;                             // scope 0 at $DIR/if_condition_int.rs:+1:14: +1:15
++         switchInt(move _3) -> [42_u32: bb1, otherwise: bb2]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
       }
   
       bb1: {
-+         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-          _0 = const 0_u32;                // scope 0 at $DIR/if-condition-int.rs:+1:18: +1:19
-          goto -> bb3;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:32
++         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+          _0 = const 0_u32;                // scope 0 at $DIR/if_condition_int.rs:+1:18: +1:19
+          goto -> bb3;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:32
       }
   
       bb2: {
-+         StorageDead(_3);                 // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15
-          _0 = const 1_u32;                // scope 0 at $DIR/if-condition-int.rs:+1:29: +1:30
-          goto -> bb3;                     // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:32
++         StorageDead(_3);                 // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15
+          _0 = const 1_u32;                // scope 0 at $DIR/if_condition_int.rs:+1:29: +1:30
+          goto -> bb3;                     // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:32
       }
   
       bb3: {
-          StorageDead(_2);                 // scope 0 at $DIR/if-condition-int.rs:+1:31: +1:32
-          return;                          // scope 0 at $DIR/if-condition-int.rs:+2:2: +2:2
+          StorageDead(_2);                 // scope 0 at $DIR/if_condition_int.rs:+1:31: +1:32
+          return;                          // scope 0 at $DIR/if_condition_int.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/if-condition-int.rs b/src/test/mir-opt/if_condition_int.rs
similarity index 100%
rename from src/test/mir-opt/if-condition-int.rs
rename to src/test/mir-opt/if_condition_int.rs
diff --git a/src/test/mir-opt/inline/asm_unwind.main.Inline.diff b/src/test/mir-opt/inline/asm_unwind.main.Inline.diff
index 57072fc0ad3..f1b62ac38ba 100644
--- a/src/test/mir-opt/inline/asm_unwind.main.Inline.diff
+++ b/src/test/mir-opt/inline/asm_unwind.main.Inline.diff
@@ -2,44 +2,44 @@
 + // MIR for `main` after Inline
   
   fn main() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/asm-unwind.rs:+0:15: +0:15
-      let _1: ();                          // in scope 0 at $DIR/asm-unwind.rs:+1:5: +1:10
-+     scope 1 (inlined foo) {              // at $DIR/asm-unwind.rs:21:5: 21:10
-+         let _2: D;                       // in scope 1 at $DIR/asm-unwind.rs:15:9: 15:11
+      let mut _0: ();                      // return place in scope 0 at $DIR/asm_unwind.rs:+0:15: +0:15
+      let _1: ();                          // in scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10
++     scope 1 (inlined foo) {              // at $DIR/asm_unwind.rs:21:5: 21:10
++         let _2: D;                       // in scope 1 at $DIR/asm_unwind.rs:15:9: 15:11
 +         scope 2 {
-+             debug _d => _2;              // in scope 2 at $DIR/asm-unwind.rs:15:9: 15:11
++             debug _d => _2;              // in scope 2 at $DIR/asm_unwind.rs:15:9: 15:11
 +             scope 3 {
 +             }
 +         }
 +     }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/asm-unwind.rs:+1:5: +1:10
--         _1 = foo() -> bb1;               // scope 0 at $DIR/asm-unwind.rs:+1:5: +1:10
+          StorageLive(_1);                 // scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10
+-         _1 = foo() -> bb1;               // scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10
 -                                          // mir::Constant
--                                          // + span: $DIR/asm-unwind.rs:21:5: 21:8
+-                                          // + span: $DIR/asm_unwind.rs:21:5: 21:8
 -                                          // + literal: Const { ty: fn() {foo}, val: Value() }
-+         StorageLive(_2);                 // scope 1 at $DIR/asm-unwind.rs:15:9: 15:11
-+         asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind: bb3]; // scope 3 at $DIR/asm-unwind.rs:16:14: 16:54
++         StorageLive(_2);                 // scope 1 at $DIR/asm_unwind.rs:15:9: 15:11
++         asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind: bb3]; // scope 3 at $DIR/asm_unwind.rs:16:14: 16:54
       }
   
       bb1: {
-+         drop(_2) -> bb2;                 // scope 1 at $DIR/asm-unwind.rs:17:1: 17:2
++         drop(_2) -> bb2;                 // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2
 +     }
 + 
 +     bb2: {
-+         StorageDead(_2);                 // scope 1 at $DIR/asm-unwind.rs:17:1: 17:2
-          StorageDead(_1);                 // scope 0 at $DIR/asm-unwind.rs:+1:10: +1:11
-          _0 = const ();                   // scope 0 at $DIR/asm-unwind.rs:+0:15: +2:2
-          return;                          // scope 0 at $DIR/asm-unwind.rs:+2:2: +2:2
++         StorageDead(_2);                 // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2
+          StorageDead(_1);                 // scope 0 at $DIR/asm_unwind.rs:+1:10: +1:11
+          _0 = const ();                   // scope 0 at $DIR/asm_unwind.rs:+0:15: +2:2
+          return;                          // scope 0 at $DIR/asm_unwind.rs:+2:2: +2:2
 +     }
 + 
 +     bb3 (cleanup): {
-+         drop(_2) -> bb4;                 // scope 1 at $DIR/asm-unwind.rs:17:1: 17:2
++         drop(_2) -> bb4;                 // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2
 +     }
 + 
 +     bb4 (cleanup): {
-+         resume;                          // scope 1 at $DIR/asm-unwind.rs:14:1: 17:2
++         resume;                          // scope 1 at $DIR/asm_unwind.rs:14:1: 17:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/asm-unwind.rs b/src/test/mir-opt/inline/asm_unwind.rs
similarity index 100%
rename from src/test/mir-opt/inline/asm-unwind.rs
rename to src/test/mir-opt/inline/asm_unwind.rs
diff --git a/src/test/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff b/src/test/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff
index d7deb9c66cf..8b03006782b 100644
--- a/src/test/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff
+++ b/src/test/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff
@@ -2,32 +2,32 @@
 + // MIR for `foo` after Inline
   
   fn foo() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/caller-with-trivial-bound.rs:+1:1: +1:1
-      let mut _1: >::Item; // in scope 0 at $DIR/caller-with-trivial-bound.rs:+4:9: +4:14
+      let mut _0: ();                      // return place in scope 0 at $DIR/caller_with_trivial_bound.rs:+1:1: +1:1
+      let mut _1: >::Item; // in scope 0 at $DIR/caller_with_trivial_bound.rs:+4:9: +4:14
       scope 1 {
-          debug x => _1;                   // in scope 1 at $DIR/caller-with-trivial-bound.rs:+4:9: +4:14
+          debug x => _1;                   // in scope 1 at $DIR/caller_with_trivial_bound.rs:+4:9: +4:14
       }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/caller-with-trivial-bound.rs:+4:9: +4:14
-          _1 = bar::() -> bb1;          // scope 0 at $DIR/caller-with-trivial-bound.rs:+4:51: +4:61
+          StorageLive(_1);                 // scope 0 at $DIR/caller_with_trivial_bound.rs:+4:9: +4:14
+          _1 = bar::() -> bb1;          // scope 0 at $DIR/caller_with_trivial_bound.rs:+4:51: +4:61
                                            // mir::Constant
-                                           // + span: $DIR/caller-with-trivial-bound.rs:20:51: 20:59
+                                           // + span: $DIR/caller_with_trivial_bound.rs:20:51: 20:59
                                            // + literal: Const { ty: fn() -> >::Item {bar::}, val: Value() }
       }
   
       bb1: {
-          _0 = const ();                   // scope 0 at $DIR/caller-with-trivial-bound.rs:+3:1: +5:2
-          drop(_1) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/caller-with-trivial-bound.rs:+5:1: +5:2
+          _0 = const ();                   // scope 0 at $DIR/caller_with_trivial_bound.rs:+3:1: +5:2
+          drop(_1) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/caller_with_trivial_bound.rs:+5:1: +5:2
       }
   
       bb2: {
-          StorageDead(_1);                 // scope 0 at $DIR/caller-with-trivial-bound.rs:+5:1: +5:2
-          return;                          // scope 0 at $DIR/caller-with-trivial-bound.rs:+5:2: +5:2
+          StorageDead(_1);                 // scope 0 at $DIR/caller_with_trivial_bound.rs:+5:1: +5:2
+          return;                          // scope 0 at $DIR/caller_with_trivial_bound.rs:+5:2: +5:2
       }
   
       bb3 (cleanup): {
-          resume;                          // scope 0 at $DIR/caller-with-trivial-bound.rs:+0:1: +5:2
+          resume;                          // scope 0 at $DIR/caller_with_trivial_bound.rs:+0:1: +5:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/caller-with-trivial-bound.rs b/src/test/mir-opt/inline/caller_with_trivial_bound.rs
similarity index 100%
rename from src/test/mir-opt/inline/caller-with-trivial-bound.rs
rename to src/test/mir-opt/inline/caller_with_trivial_bound.rs
diff --git a/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff b/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff
index 1e95b5b29ff..284306a352d 100644
--- a/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff
+++ b/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff
@@ -2,61 +2,61 @@
 + // MIR for `get_query` after Inline
   
   fn get_query(_1: &T) -> () {
-      debug t => _1;                       // in scope 0 at $DIR/dyn-trait.rs:+0:31: +0:32
-      let mut _0: ();                      // return place in scope 0 at $DIR/dyn-trait.rs:+0:38: +0:38
-      let _2: &::C;            // in scope 0 at $DIR/dyn-trait.rs:+1:9: +1:10
-      let mut _3: &T;                      // in scope 0 at $DIR/dyn-trait.rs:+1:22: +1:23
-      let mut _4: &::C;        // in scope 0 at $DIR/dyn-trait.rs:+2:23: +2:24
+      debug t => _1;                       // in scope 0 at $DIR/dyn_trait.rs:+0:31: +0:32
+      let mut _0: ();                      // return place in scope 0 at $DIR/dyn_trait.rs:+0:38: +0:38
+      let _2: &::C;            // in scope 0 at $DIR/dyn_trait.rs:+1:9: +1:10
+      let mut _3: &T;                      // in scope 0 at $DIR/dyn_trait.rs:+1:22: +1:23
+      let mut _4: &::C;        // in scope 0 at $DIR/dyn_trait.rs:+2:23: +2:24
       scope 1 {
-          debug c => _2;                   // in scope 1 at $DIR/dyn-trait.rs:+1:9: +1:10
-+         scope 2 (inlined try_execute_query::<::C>) { // at $DIR/dyn-trait.rs:34:5: 34:25
-+             debug c => _4;               // in scope 2 at $DIR/dyn-trait.rs:26:36: 26:37
-+             let mut _5: &dyn Cache::V>; // in scope 2 at $DIR/dyn-trait.rs:27:14: 27:15
-+             let mut _6: &::C; // in scope 2 at $DIR/dyn-trait.rs:27:14: 27:15
-+             scope 3 (inlined mk_cycle::<::V>) { // at $DIR/dyn-trait.rs:27:5: 27:16
-+                 debug c => _5;           // in scope 3 at $DIR/dyn-trait.rs:20:27: 20:28
-+                 let mut _7: &dyn Cache::V>; // in scope 3 at $DIR/dyn-trait.rs:21:5: 21:22
+          debug c => _2;                   // in scope 1 at $DIR/dyn_trait.rs:+1:9: +1:10
++         scope 2 (inlined try_execute_query::<::C>) { // at $DIR/dyn_trait.rs:34:5: 34:25
++             debug c => _4;               // in scope 2 at $DIR/dyn_trait.rs:26:36: 26:37
++             let mut _5: &dyn Cache::V>; // in scope 2 at $DIR/dyn_trait.rs:27:14: 27:15
++             let mut _6: &::C; // in scope 2 at $DIR/dyn_trait.rs:27:14: 27:15
++             scope 3 (inlined mk_cycle::<::V>) { // at $DIR/dyn_trait.rs:27:5: 27:16
++                 debug c => _5;           // in scope 3 at $DIR/dyn_trait.rs:20:27: 20:28
++                 let mut _7: &dyn Cache::V>; // in scope 3 at $DIR/dyn_trait.rs:21:5: 21:22
 +             }
 +         }
       }
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/dyn-trait.rs:+1:9: +1:10
-          StorageLive(_3);                 // scope 0 at $DIR/dyn-trait.rs:+1:22: +1:23
-          _3 = &(*_1);                     // scope 0 at $DIR/dyn-trait.rs:+1:22: +1:23
-          _2 = ::cache::(move _3) -> bb1; // scope 0 at $DIR/dyn-trait.rs:+1:13: +1:24
+          StorageLive(_2);                 // scope 0 at $DIR/dyn_trait.rs:+1:9: +1:10
+          StorageLive(_3);                 // scope 0 at $DIR/dyn_trait.rs:+1:22: +1:23
+          _3 = &(*_1);                     // scope 0 at $DIR/dyn_trait.rs:+1:22: +1:23
+          _2 = ::cache::(move _3) -> bb1; // scope 0 at $DIR/dyn_trait.rs:+1:13: +1:24
                                            // mir::Constant
-                                           // + span: $DIR/dyn-trait.rs:33:13: 33:21
+                                           // + span: $DIR/dyn_trait.rs:33:13: 33:21
                                            // + user_ty: UserType(0)
                                            // + literal: Const { ty: for<'a> fn(&'a T) -> &'a ::C {::cache::}, val: Value() }
       }
   
       bb1: {
-          StorageDead(_3);                 // scope 0 at $DIR/dyn-trait.rs:+1:23: +1:24
-          StorageLive(_4);                 // scope 1 at $DIR/dyn-trait.rs:+2:23: +2:24
-          _4 = &(*_2);                     // scope 1 at $DIR/dyn-trait.rs:+2:23: +2:24
--         _0 = try_execute_query::<::C>(move _4) -> bb2; // scope 1 at $DIR/dyn-trait.rs:+2:5: +2:25
-+         StorageLive(_5);                 // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15
-+         StorageLive(_6);                 // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15
-+         _6 = _4;                         // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15
-+         _5 = move _6 as &dyn Cache::V> (Pointer(Unsize)); // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15
-+         StorageDead(_6);                 // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15
-+         StorageLive(_7);                 // scope 3 at $DIR/dyn-trait.rs:21:5: 21:22
-+         _7 = _5;                         // scope 3 at $DIR/dyn-trait.rs:21:5: 21:22
-+         _0 = ::V> as Cache>::store_nocache(move _7) -> bb2; // scope 3 at $DIR/dyn-trait.rs:21:5: 21:22
+          StorageDead(_3);                 // scope 0 at $DIR/dyn_trait.rs:+1:23: +1:24
+          StorageLive(_4);                 // scope 1 at $DIR/dyn_trait.rs:+2:23: +2:24
+          _4 = &(*_2);                     // scope 1 at $DIR/dyn_trait.rs:+2:23: +2:24
+-         _0 = try_execute_query::<::C>(move _4) -> bb2; // scope 1 at $DIR/dyn_trait.rs:+2:5: +2:25
++         StorageLive(_5);                 // scope 2 at $DIR/dyn_trait.rs:27:14: 27:15
++         StorageLive(_6);                 // scope 2 at $DIR/dyn_trait.rs:27:14: 27:15
++         _6 = _4;                         // scope 2 at $DIR/dyn_trait.rs:27:14: 27:15
++         _5 = move _6 as &dyn Cache::V> (Pointer(Unsize)); // scope 2 at $DIR/dyn_trait.rs:27:14: 27:15
++         StorageDead(_6);                 // scope 2 at $DIR/dyn_trait.rs:27:14: 27:15
++         StorageLive(_7);                 // scope 3 at $DIR/dyn_trait.rs:21:5: 21:22
++         _7 = _5;                         // scope 3 at $DIR/dyn_trait.rs:21:5: 21:22
++         _0 = ::V> as Cache>::store_nocache(move _7) -> bb2; // scope 3 at $DIR/dyn_trait.rs:21:5: 21:22
                                            // mir::Constant
--                                          // + span: $DIR/dyn-trait.rs:34:5: 34:22
+-                                          // + span: $DIR/dyn_trait.rs:34:5: 34:22
 -                                          // + literal: Const { ty: for<'a> fn(&'a ::C) {try_execute_query::<::C>}, val: Value() }
-+                                          // + span: $DIR/dyn-trait.rs:21:7: 21:20
++                                          // + span: $DIR/dyn_trait.rs:21:7: 21:20
 +                                          // + literal: Const { ty: for<'a> fn(&'a dyn Cache::V>) {::V> as Cache>::store_nocache}, val: Value() }
       }
   
       bb2: {
-+         StorageDead(_7);                 // scope 3 at $DIR/dyn-trait.rs:21:21: 21:22
-+         StorageDead(_5);                 // scope 2 at $DIR/dyn-trait.rs:27:15: 27:16
-          StorageDead(_4);                 // scope 1 at $DIR/dyn-trait.rs:+2:24: +2:25
-          StorageDead(_2);                 // scope 0 at $DIR/dyn-trait.rs:+3:1: +3:2
-          return;                          // scope 0 at $DIR/dyn-trait.rs:+3:2: +3:2
++         StorageDead(_7);                 // scope 3 at $DIR/dyn_trait.rs:21:21: 21:22
++         StorageDead(_5);                 // scope 2 at $DIR/dyn_trait.rs:27:15: 27:16
+          StorageDead(_4);                 // scope 1 at $DIR/dyn_trait.rs:+2:24: +2:25
+          StorageDead(_2);                 // scope 0 at $DIR/dyn_trait.rs:+3:1: +3:2
+          return;                          // scope 0 at $DIR/dyn_trait.rs:+3:2: +3:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff b/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff
index 7421db4d063..7653a5ded44 100644
--- a/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff
+++ b/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff
@@ -2,22 +2,22 @@
 + // MIR for `mk_cycle` after Inline
   
   fn mk_cycle(_1: &dyn Cache) -> () {
-      debug c => _1;                       // in scope 0 at $DIR/dyn-trait.rs:+0:27: +0:28
-      let mut _0: ();                      // return place in scope 0 at $DIR/dyn-trait.rs:+0:49: +0:49
-      let mut _2: &dyn Cache;       // in scope 0 at $DIR/dyn-trait.rs:+1:5: +1:22
+      debug c => _1;                       // in scope 0 at $DIR/dyn_trait.rs:+0:27: +0:28
+      let mut _0: ();                      // return place in scope 0 at $DIR/dyn_trait.rs:+0:49: +0:49
+      let mut _2: &dyn Cache;       // in scope 0 at $DIR/dyn_trait.rs:+1:5: +1:22
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/dyn-trait.rs:+1:5: +1:22
-          _2 = &(*_1);                     // scope 0 at $DIR/dyn-trait.rs:+1:5: +1:22
-          _0 =  as Cache>::store_nocache(move _2) -> bb1; // scope 0 at $DIR/dyn-trait.rs:+1:5: +1:22
+          StorageLive(_2);                 // scope 0 at $DIR/dyn_trait.rs:+1:5: +1:22
+          _2 = &(*_1);                     // scope 0 at $DIR/dyn_trait.rs:+1:5: +1:22
+          _0 =  as Cache>::store_nocache(move _2) -> bb1; // scope 0 at $DIR/dyn_trait.rs:+1:5: +1:22
                                            // mir::Constant
-                                           // + span: $DIR/dyn-trait.rs:21:7: 21:20
+                                           // + span: $DIR/dyn_trait.rs:21:7: 21:20
                                            // + literal: Const { ty: for<'a> fn(&'a dyn Cache) { as Cache>::store_nocache}, val: Value() }
       }
   
       bb1: {
-          StorageDead(_2);                 // scope 0 at $DIR/dyn-trait.rs:+1:21: +1:22
-          return;                          // scope 0 at $DIR/dyn-trait.rs:+2:2: +2:2
+          StorageDead(_2);                 // scope 0 at $DIR/dyn_trait.rs:+1:21: +1:22
+          return;                          // scope 0 at $DIR/dyn_trait.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/dyn-trait.rs b/src/test/mir-opt/inline/dyn_trait.rs
similarity index 100%
rename from src/test/mir-opt/inline/dyn-trait.rs
rename to src/test/mir-opt/inline/dyn_trait.rs
diff --git a/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff b/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff
index e6e78374422..0191045f3d1 100644
--- a/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff
+++ b/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff
@@ -2,36 +2,36 @@
 + // MIR for `try_execute_query` after Inline
   
   fn try_execute_query(_1: &C) -> () {
-      debug c => _1;                       // in scope 0 at $DIR/dyn-trait.rs:+0:36: +0:37
-      let mut _0: ();                      // return place in scope 0 at $DIR/dyn-trait.rs:+0:43: +0:43
-      let mut _2: &dyn Cache::V>; // in scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15
-      let mut _3: &C;                      // in scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15
-+     scope 1 (inlined mk_cycle::<::V>) { // at $DIR/dyn-trait.rs:27:5: 27:16
-+         debug c => _2;                   // in scope 1 at $DIR/dyn-trait.rs:20:27: 20:28
-+         let mut _4: &dyn Cache::V>; // in scope 1 at $DIR/dyn-trait.rs:21:5: 21:22
+      debug c => _1;                       // in scope 0 at $DIR/dyn_trait.rs:+0:36: +0:37
+      let mut _0: ();                      // return place in scope 0 at $DIR/dyn_trait.rs:+0:43: +0:43
+      let mut _2: &dyn Cache::V>; // in scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15
+      let mut _3: &C;                      // in scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15
++     scope 1 (inlined mk_cycle::<::V>) { // at $DIR/dyn_trait.rs:27:5: 27:16
++         debug c => _2;                   // in scope 1 at $DIR/dyn_trait.rs:20:27: 20:28
++         let mut _4: &dyn Cache::V>; // in scope 1 at $DIR/dyn_trait.rs:21:5: 21:22
 +     }
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15
-          StorageLive(_3);                 // scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15
-          _3 = &(*_1);                     // scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15
-          _2 = move _3 as &dyn Cache::V> (Pointer(Unsize)); // scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15
-          StorageDead(_3);                 // scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15
--         _0 = mk_cycle::<::V>(move _2) -> bb1; // scope 0 at $DIR/dyn-trait.rs:+1:5: +1:16
-+         StorageLive(_4);                 // scope 1 at $DIR/dyn-trait.rs:21:5: 21:22
-+         _4 = _2;                         // scope 1 at $DIR/dyn-trait.rs:21:5: 21:22
-+         _0 = ::V> as Cache>::store_nocache(move _4) -> bb1; // scope 1 at $DIR/dyn-trait.rs:21:5: 21:22
+          StorageLive(_2);                 // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15
+          StorageLive(_3);                 // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15
+          _3 = &(*_1);                     // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15
+          _2 = move _3 as &dyn Cache::V> (Pointer(Unsize)); // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15
+          StorageDead(_3);                 // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15
+-         _0 = mk_cycle::<::V>(move _2) -> bb1; // scope 0 at $DIR/dyn_trait.rs:+1:5: +1:16
++         StorageLive(_4);                 // scope 1 at $DIR/dyn_trait.rs:21:5: 21:22
++         _4 = _2;                         // scope 1 at $DIR/dyn_trait.rs:21:5: 21:22
++         _0 = ::V> as Cache>::store_nocache(move _4) -> bb1; // scope 1 at $DIR/dyn_trait.rs:21:5: 21:22
                                            // mir::Constant
--                                          // + span: $DIR/dyn-trait.rs:27:5: 27:13
+-                                          // + span: $DIR/dyn_trait.rs:27:5: 27:13
 -                                          // + literal: Const { ty: for<'a> fn(&'a (dyn Cache::V> + 'a)) {mk_cycle::<::V>}, val: Value() }
-+                                          // + span: $DIR/dyn-trait.rs:21:7: 21:20
++                                          // + span: $DIR/dyn_trait.rs:21:7: 21:20
 +                                          // + literal: Const { ty: for<'a> fn(&'a dyn Cache::V>) {::V> as Cache>::store_nocache}, val: Value() }
       }
   
       bb1: {
-+         StorageDead(_4);                 // scope 1 at $DIR/dyn-trait.rs:21:21: 21:22
-          StorageDead(_2);                 // scope 0 at $DIR/dyn-trait.rs:+1:15: +1:16
-          return;                          // scope 0 at $DIR/dyn-trait.rs:+2:2: +2:2
++         StorageDead(_4);                 // scope 1 at $DIR/dyn_trait.rs:21:21: 21:22
+          StorageDead(_2);                 // scope 0 at $DIR/dyn_trait.rs:+1:15: +1:16
+          return;                          // scope 0 at $DIR/dyn_trait.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir
index b27425fb18c..8956c80dcd2 100644
--- a/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir
+++ b/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir
@@ -1,44 +1,44 @@
 // MIR for `bar` after Inline
 
 fn bar() -> bool {
-    let mut _0: bool;                    // return place in scope 0 at $DIR/inline-any-operand.rs:+0:13: +0:17
-    let _1: fn(i32, i32) -> bool {foo};  // in scope 0 at $DIR/inline-any-operand.rs:+1:9: +1:10
-    let mut _2: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline-any-operand.rs:+2:5: +2:6
-    let mut _3: i32;                     // in scope 0 at $DIR/inline-any-operand.rs:+2:5: +2:13
-    let mut _4: i32;                     // in scope 0 at $DIR/inline-any-operand.rs:+2:5: +2:13
+    let mut _0: bool;                    // return place in scope 0 at $DIR/inline_any_operand.rs:+0:13: +0:17
+    let _1: fn(i32, i32) -> bool {foo};  // in scope 0 at $DIR/inline_any_operand.rs:+1:9: +1:10
+    let mut _2: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline_any_operand.rs:+2:5: +2:6
+    let mut _3: i32;                     // in scope 0 at $DIR/inline_any_operand.rs:+2:5: +2:13
+    let mut _4: i32;                     // in scope 0 at $DIR/inline_any_operand.rs:+2:5: +2:13
     scope 1 {
-        debug f => _1;                   // in scope 1 at $DIR/inline-any-operand.rs:+1:9: +1:10
-        scope 2 (inlined foo) {          // at $DIR/inline-any-operand.rs:12:5: 12:13
-            debug x => _3;               // in scope 2 at $DIR/inline-any-operand.rs:16:8: 16:9
-            debug y => _4;               // in scope 2 at $DIR/inline-any-operand.rs:16:16: 16:17
-            let mut _5: i32;             // in scope 2 at $DIR/inline-any-operand.rs:17:5: 17:6
-            let mut _6: i32;             // in scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11
+        debug f => _1;                   // in scope 1 at $DIR/inline_any_operand.rs:+1:9: +1:10
+        scope 2 (inlined foo) {          // at $DIR/inline_any_operand.rs:12:5: 12:13
+            debug x => _3;               // in scope 2 at $DIR/inline_any_operand.rs:16:8: 16:9
+            debug y => _4;               // in scope 2 at $DIR/inline_any_operand.rs:16:16: 16:17
+            let mut _5: i32;             // in scope 2 at $DIR/inline_any_operand.rs:17:5: 17:6
+            let mut _6: i32;             // in scope 2 at $DIR/inline_any_operand.rs:17:10: 17:11
         }
     }
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/inline-any-operand.rs:+1:9: +1:10
-        _1 = foo;                        // scope 0 at $DIR/inline-any-operand.rs:+1:13: +1:16
+        StorageLive(_1);                 // scope 0 at $DIR/inline_any_operand.rs:+1:9: +1:10
+        _1 = foo;                        // scope 0 at $DIR/inline_any_operand.rs:+1:13: +1:16
                                          // mir::Constant
-                                         // + span: $DIR/inline-any-operand.rs:11:13: 11:16
+                                         // + span: $DIR/inline_any_operand.rs:11:13: 11:16
                                          // + literal: Const { ty: fn(i32, i32) -> bool {foo}, val: Value() }
-        StorageLive(_2);                 // scope 1 at $DIR/inline-any-operand.rs:+2:5: +2:6
-        _2 = _1;                         // scope 1 at $DIR/inline-any-operand.rs:+2:5: +2:6
-        StorageLive(_3);                 // scope 1 at $DIR/inline-any-operand.rs:+2:5: +2:13
-        _3 = const 1_i32;                // scope 1 at $DIR/inline-any-operand.rs:+2:5: +2:13
-        StorageLive(_4);                 // scope 1 at $DIR/inline-any-operand.rs:+2:5: +2:13
-        _4 = const -1_i32;               // scope 1 at $DIR/inline-any-operand.rs:+2:5: +2:13
-        StorageLive(_5);                 // scope 2 at $DIR/inline-any-operand.rs:17:5: 17:6
-        _5 = _3;                         // scope 2 at $DIR/inline-any-operand.rs:17:5: 17:6
-        StorageLive(_6);                 // scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11
-        _6 = _4;                         // scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11
-        _0 = Eq(move _5, move _6);       // scope 2 at $DIR/inline-any-operand.rs:17:5: 17:11
-        StorageDead(_6);                 // scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11
-        StorageDead(_5);                 // scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11
-        StorageDead(_4);                 // scope 1 at $DIR/inline-any-operand.rs:+2:5: +2:13
-        StorageDead(_3);                 // scope 1 at $DIR/inline-any-operand.rs:+2:5: +2:13
-        StorageDead(_2);                 // scope 1 at $DIR/inline-any-operand.rs:+2:12: +2:13
-        StorageDead(_1);                 // scope 0 at $DIR/inline-any-operand.rs:+3:1: +3:2
-        return;                          // scope 0 at $DIR/inline-any-operand.rs:+3:2: +3:2
+        StorageLive(_2);                 // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:6
+        _2 = _1;                         // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:6
+        StorageLive(_3);                 // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13
+        _3 = const 1_i32;                // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13
+        StorageLive(_4);                 // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13
+        _4 = const -1_i32;               // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13
+        StorageLive(_5);                 // scope 2 at $DIR/inline_any_operand.rs:17:5: 17:6
+        _5 = _3;                         // scope 2 at $DIR/inline_any_operand.rs:17:5: 17:6
+        StorageLive(_6);                 // scope 2 at $DIR/inline_any_operand.rs:17:10: 17:11
+        _6 = _4;                         // scope 2 at $DIR/inline_any_operand.rs:17:10: 17:11
+        _0 = Eq(move _5, move _6);       // scope 2 at $DIR/inline_any_operand.rs:17:5: 17:11
+        StorageDead(_6);                 // scope 2 at $DIR/inline_any_operand.rs:17:10: 17:11
+        StorageDead(_5);                 // scope 2 at $DIR/inline_any_operand.rs:17:10: 17:11
+        StorageDead(_4);                 // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13
+        StorageDead(_3);                 // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13
+        StorageDead(_2);                 // scope 1 at $DIR/inline_any_operand.rs:+2:12: +2:13
+        StorageDead(_1);                 // scope 0 at $DIR/inline_any_operand.rs:+3:1: +3:2
+        return;                          // scope 0 at $DIR/inline_any_operand.rs:+3:2: +3:2
     }
 }
diff --git a/src/test/mir-opt/inline/inline-any-operand.rs b/src/test/mir-opt/inline/inline_any_operand.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-any-operand.rs
rename to src/test/mir-opt/inline/inline_any_operand.rs
diff --git a/src/test/mir-opt/inline/inline-async.rs b/src/test/mir-opt/inline/inline_async.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-async.rs
rename to src/test/mir-opt/inline/inline_async.rs
diff --git a/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir
index 1fadd246479..9eb3a01eef9 100644
--- a/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir
+++ b/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir
@@ -1,49 +1,49 @@
 // MIR for `foo` after Inline
 
 fn foo(_1: T, _2: i32) -> i32 {
-    debug _t => _1;                      // in scope 0 at $DIR/inline-closure.rs:+0:17: +0:19
-    debug q => _2;                       // in scope 0 at $DIR/inline-closure.rs:+0:24: +0:25
-    let mut _0: i32;                     // return place in scope 0 at $DIR/inline-closure.rs:+0:35: +0:38
-    let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure.rs:+1:9: +1:10
-    let mut _4: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure.rs:+2:5: +2:6
-    let mut _5: (i32, i32);              // in scope 0 at $DIR/inline-closure.rs:+2:5: +2:12
-    let mut _6: i32;                     // in scope 0 at $DIR/inline-closure.rs:+2:7: +2:8
-    let mut _7: i32;                     // in scope 0 at $DIR/inline-closure.rs:+2:10: +2:11
-    let mut _8: i32;                     // in scope 0 at $DIR/inline-closure.rs:+2:5: +2:12
-    let mut _9: i32;                     // in scope 0 at $DIR/inline-closure.rs:+2:5: +2:12
+    debug _t => _1;                      // in scope 0 at $DIR/inline_closure.rs:+0:17: +0:19
+    debug q => _2;                       // in scope 0 at $DIR/inline_closure.rs:+0:24: +0:25
+    let mut _0: i32;                     // return place in scope 0 at $DIR/inline_closure.rs:+0:35: +0:38
+    let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline_closure.rs:+1:9: +1:10
+    let mut _4: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline_closure.rs:+2:5: +2:6
+    let mut _5: (i32, i32);              // in scope 0 at $DIR/inline_closure.rs:+2:5: +2:12
+    let mut _6: i32;                     // in scope 0 at $DIR/inline_closure.rs:+2:7: +2:8
+    let mut _7: i32;                     // in scope 0 at $DIR/inline_closure.rs:+2:10: +2:11
+    let mut _8: i32;                     // in scope 0 at $DIR/inline_closure.rs:+2:5: +2:12
+    let mut _9: i32;                     // in scope 0 at $DIR/inline_closure.rs:+2:5: +2:12
     scope 1 {
-        debug x => _3;                   // in scope 1 at $DIR/inline-closure.rs:+1:9: +1:10
-        scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline-closure.rs:12:5: 12:12
-            debug _t => _8;              // in scope 2 at $DIR/inline-closure.rs:+1:14: +1:16
-            debug _q => _9;              // in scope 2 at $DIR/inline-closure.rs:+1:18: +1:20
+        debug x => _3;                   // in scope 1 at $DIR/inline_closure.rs:+1:9: +1:10
+        scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline_closure.rs:12:5: 12:12
+            debug _t => _8;              // in scope 2 at $DIR/inline_closure.rs:+1:14: +1:16
+            debug _q => _9;              // in scope 2 at $DIR/inline_closure.rs:+1:18: +1:20
         }
     }
 
     bb0: {
-        StorageLive(_3);                 // scope 0 at $DIR/inline-closure.rs:+1:9: +1:10
-        Deinit(_3);                      // scope 0 at $DIR/inline-closure.rs:+1:13: +1:24
-        StorageLive(_4);                 // scope 1 at $DIR/inline-closure.rs:+2:5: +2:6
-        _4 = &_3;                        // scope 1 at $DIR/inline-closure.rs:+2:5: +2:6
-        StorageLive(_5);                 // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12
-        StorageLive(_6);                 // scope 1 at $DIR/inline-closure.rs:+2:7: +2:8
-        _6 = _2;                         // scope 1 at $DIR/inline-closure.rs:+2:7: +2:8
-        StorageLive(_7);                 // scope 1 at $DIR/inline-closure.rs:+2:10: +2:11
-        _7 = _2;                         // scope 1 at $DIR/inline-closure.rs:+2:10: +2:11
-        Deinit(_5);                      // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12
-        (_5.0: i32) = move _6;           // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12
-        (_5.1: i32) = move _7;           // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12
-        StorageLive(_8);                 // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12
-        _8 = move (_5.0: i32);           // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12
-        StorageLive(_9);                 // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12
-        _9 = move (_5.1: i32);           // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12
-        _0 = _8;                         // scope 2 at $DIR/inline-closure.rs:+1:22: +1:24
-        StorageDead(_9);                 // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12
-        StorageDead(_8);                 // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12
-        StorageDead(_7);                 // scope 1 at $DIR/inline-closure.rs:+2:11: +2:12
-        StorageDead(_6);                 // scope 1 at $DIR/inline-closure.rs:+2:11: +2:12
-        StorageDead(_5);                 // scope 1 at $DIR/inline-closure.rs:+2:11: +2:12
-        StorageDead(_4);                 // scope 1 at $DIR/inline-closure.rs:+2:11: +2:12
-        StorageDead(_3);                 // scope 0 at $DIR/inline-closure.rs:+3:1: +3:2
-        return;                          // scope 0 at $DIR/inline-closure.rs:+3:2: +3:2
+        StorageLive(_3);                 // scope 0 at $DIR/inline_closure.rs:+1:9: +1:10
+        Deinit(_3);                      // scope 0 at $DIR/inline_closure.rs:+1:13: +1:24
+        StorageLive(_4);                 // scope 1 at $DIR/inline_closure.rs:+2:5: +2:6
+        _4 = &_3;                        // scope 1 at $DIR/inline_closure.rs:+2:5: +2:6
+        StorageLive(_5);                 // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12
+        StorageLive(_6);                 // scope 1 at $DIR/inline_closure.rs:+2:7: +2:8
+        _6 = _2;                         // scope 1 at $DIR/inline_closure.rs:+2:7: +2:8
+        StorageLive(_7);                 // scope 1 at $DIR/inline_closure.rs:+2:10: +2:11
+        _7 = _2;                         // scope 1 at $DIR/inline_closure.rs:+2:10: +2:11
+        Deinit(_5);                      // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12
+        (_5.0: i32) = move _6;           // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12
+        (_5.1: i32) = move _7;           // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12
+        StorageLive(_8);                 // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12
+        _8 = move (_5.0: i32);           // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12
+        StorageLive(_9);                 // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12
+        _9 = move (_5.1: i32);           // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12
+        _0 = _8;                         // scope 2 at $DIR/inline_closure.rs:+1:22: +1:24
+        StorageDead(_9);                 // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12
+        StorageDead(_8);                 // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12
+        StorageDead(_7);                 // scope 1 at $DIR/inline_closure.rs:+2:11: +2:12
+        StorageDead(_6);                 // scope 1 at $DIR/inline_closure.rs:+2:11: +2:12
+        StorageDead(_5);                 // scope 1 at $DIR/inline_closure.rs:+2:11: +2:12
+        StorageDead(_4);                 // scope 1 at $DIR/inline_closure.rs:+2:11: +2:12
+        StorageDead(_3);                 // scope 0 at $DIR/inline_closure.rs:+3:1: +3:2
+        return;                          // scope 0 at $DIR/inline_closure.rs:+3:2: +3:2
     }
 }
diff --git a/src/test/mir-opt/inline/inline-closure.rs b/src/test/mir-opt/inline/inline_closure.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-closure.rs
rename to src/test/mir-opt/inline/inline_closure.rs
diff --git a/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir
index 4069e9f89c8..e6275ac7f5d 100644
--- a/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir
+++ b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir
@@ -1,56 +1,56 @@
 // MIR for `foo` after Inline
 
 fn foo(_1: T, _2: &i32) -> i32 {
-    debug _t => _1;                      // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+0:17: +0:19
-    debug q => _2;                       // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+0:24: +0:25
-    let mut _0: i32;                     // return place in scope 0 at $DIR/inline-closure-borrows-arg.rs:+0:36: +0:39
-    let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+1:9: +1:10
-    let mut _4: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:6
-    let mut _5: (&i32, &i32);            // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
-    let mut _6: &i32;                    // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:7: +5:8
-    let mut _7: &i32;                    // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:10: +5:11
-    let mut _8: &i32;                    // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
-    let mut _9: &i32;                    // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
+    debug _t => _1;                      // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+0:17: +0:19
+    debug q => _2;                       // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+0:24: +0:25
+    let mut _0: i32;                     // return place in scope 0 at $DIR/inline_closure_borrows_arg.rs:+0:36: +0:39
+    let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+1:9: +1:10
+    let mut _4: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:6
+    let mut _5: (&i32, &i32);            // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
+    let mut _6: &i32;                    // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:7: +5:8
+    let mut _7: &i32;                    // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:10: +5:11
+    let mut _8: &i32;                    // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
+    let mut _9: &i32;                    // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
     scope 1 {
-        debug x => _3;                   // in scope 1 at $DIR/inline-closure-borrows-arg.rs:+1:9: +1:10
-        scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
-            debug r => _8;               // in scope 2 at $DIR/inline-closure-borrows-arg.rs:+1:14: +1:15
-            debug _s => _9;              // in scope 2 at $DIR/inline-closure-borrows-arg.rs:+1:23: +1:25
-            let _10: &i32;               // in scope 2 at $DIR/inline-closure-borrows-arg.rs:+2:13: +2:21
+        debug x => _3;                   // in scope 1 at $DIR/inline_closure_borrows_arg.rs:+1:9: +1:10
+        scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline_closure_borrows_arg.rs:16:5: 16:12
+            debug r => _8;               // in scope 2 at $DIR/inline_closure_borrows_arg.rs:+1:14: +1:15
+            debug _s => _9;              // in scope 2 at $DIR/inline_closure_borrows_arg.rs:+1:23: +1:25
+            let _10: &i32;               // in scope 2 at $DIR/inline_closure_borrows_arg.rs:+2:13: +2:21
             scope 3 {
-                debug variable => _10;   // in scope 3 at $DIR/inline-closure-borrows-arg.rs:+2:13: +2:21
+                debug variable => _10;   // in scope 3 at $DIR/inline_closure_borrows_arg.rs:+2:13: +2:21
             }
         }
     }
 
     bb0: {
-        StorageLive(_3);                 // scope 0 at $DIR/inline-closure-borrows-arg.rs:+1:9: +1:10
-        Deinit(_3);                      // scope 0 at $DIR/inline-closure-borrows-arg.rs:+1:13: +4:6
-        StorageLive(_4);                 // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:6
-        _4 = &_3;                        // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:6
-        StorageLive(_5);                 // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
-        StorageLive(_6);                 // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:7: +5:8
-        _6 = &(*_2);                     // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:7: +5:8
-        StorageLive(_7);                 // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:10: +5:11
-        _7 = &(*_2);                     // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:10: +5:11
-        Deinit(_5);                      // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
-        (_5.0: &i32) = move _6;          // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
-        (_5.1: &i32) = move _7;          // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
-        StorageLive(_8);                 // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
-        _8 = move (_5.0: &i32);          // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
-        StorageLive(_9);                 // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
-        _9 = move (_5.1: &i32);          // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
-        StorageLive(_10);                // scope 2 at $DIR/inline-closure-borrows-arg.rs:+2:13: +2:21
-        _10 = _8;                        // scope 2 at $DIR/inline-closure-borrows-arg.rs:+2:24: +2:27
-        _0 = (*_10);                     // scope 3 at $DIR/inline-closure-borrows-arg.rs:+3:9: +3:18
-        StorageDead(_10);                // scope 2 at $DIR/inline-closure-borrows-arg.rs:+4:5: +4:6
-        StorageDead(_9);                 // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
-        StorageDead(_8);                 // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12
-        StorageDead(_7);                 // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:11: +5:12
-        StorageDead(_6);                 // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:11: +5:12
-        StorageDead(_5);                 // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:11: +5:12
-        StorageDead(_4);                 // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:11: +5:12
-        StorageDead(_3);                 // scope 0 at $DIR/inline-closure-borrows-arg.rs:+6:1: +6:2
-        return;                          // scope 0 at $DIR/inline-closure-borrows-arg.rs:+6:2: +6:2
+        StorageLive(_3);                 // scope 0 at $DIR/inline_closure_borrows_arg.rs:+1:9: +1:10
+        Deinit(_3);                      // scope 0 at $DIR/inline_closure_borrows_arg.rs:+1:13: +4:6
+        StorageLive(_4);                 // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:6
+        _4 = &_3;                        // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:6
+        StorageLive(_5);                 // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
+        StorageLive(_6);                 // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:7: +5:8
+        _6 = &(*_2);                     // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:7: +5:8
+        StorageLive(_7);                 // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:10: +5:11
+        _7 = &(*_2);                     // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:10: +5:11
+        Deinit(_5);                      // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
+        (_5.0: &i32) = move _6;          // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
+        (_5.1: &i32) = move _7;          // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
+        StorageLive(_8);                 // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
+        _8 = move (_5.0: &i32);          // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
+        StorageLive(_9);                 // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
+        _9 = move (_5.1: &i32);          // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
+        StorageLive(_10);                // scope 2 at $DIR/inline_closure_borrows_arg.rs:+2:13: +2:21
+        _10 = _8;                        // scope 2 at $DIR/inline_closure_borrows_arg.rs:+2:24: +2:27
+        _0 = (*_10);                     // scope 3 at $DIR/inline_closure_borrows_arg.rs:+3:9: +3:18
+        StorageDead(_10);                // scope 2 at $DIR/inline_closure_borrows_arg.rs:+4:5: +4:6
+        StorageDead(_9);                 // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
+        StorageDead(_8);                 // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12
+        StorageDead(_7);                 // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:11: +5:12
+        StorageDead(_6);                 // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:11: +5:12
+        StorageDead(_5);                 // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:11: +5:12
+        StorageDead(_4);                 // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:11: +5:12
+        StorageDead(_3);                 // scope 0 at $DIR/inline_closure_borrows_arg.rs:+6:1: +6:2
+        return;                          // scope 0 at $DIR/inline_closure_borrows_arg.rs:+6:2: +6:2
     }
 }
diff --git a/src/test/mir-opt/inline/inline-closure-borrows-arg.rs b/src/test/mir-opt/inline/inline_closure_borrows_arg.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-closure-borrows-arg.rs
rename to src/test/mir-opt/inline/inline_closure_borrows_arg.rs
diff --git a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir
index a2234e7c1ef..fd19c288666 100644
--- a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir
+++ b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir
@@ -1,65 +1,65 @@
 // MIR for `foo` after Inline
 
 fn foo(_1: T, _2: i32) -> (i32, T) {
-    debug t => _1;                       // in scope 0 at $DIR/inline-closure-captures.rs:+0:17: +0:18
-    debug q => _2;                       // in scope 0 at $DIR/inline-closure-captures.rs:+0:23: +0:24
-    let mut _0: (i32, T);                // return place in scope 0 at $DIR/inline-closure-captures.rs:+0:34: +0:42
-    let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure-captures.rs:+1:9: +1:10
-    let mut _4: &i32;                    // in scope 0 at $DIR/inline-closure-captures.rs:+1:13: +1:24
-    let mut _5: &T;                      // in scope 0 at $DIR/inline-closure-captures.rs:+1:13: +1:24
-    let mut _6: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure-captures.rs:+2:5: +2:6
-    let mut _7: (i32,);                  // in scope 0 at $DIR/inline-closure-captures.rs:+2:5: +2:9
-    let mut _8: i32;                     // in scope 0 at $DIR/inline-closure-captures.rs:+2:7: +2:8
-    let mut _9: i32;                     // in scope 0 at $DIR/inline-closure-captures.rs:+2:5: +2:9
+    debug t => _1;                       // in scope 0 at $DIR/inline_closure_captures.rs:+0:17: +0:18
+    debug q => _2;                       // in scope 0 at $DIR/inline_closure_captures.rs:+0:23: +0:24
+    let mut _0: (i32, T);                // return place in scope 0 at $DIR/inline_closure_captures.rs:+0:34: +0:42
+    let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline_closure_captures.rs:+1:9: +1:10
+    let mut _4: &i32;                    // in scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24
+    let mut _5: &T;                      // in scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24
+    let mut _6: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline_closure_captures.rs:+2:5: +2:6
+    let mut _7: (i32,);                  // in scope 0 at $DIR/inline_closure_captures.rs:+2:5: +2:9
+    let mut _8: i32;                     // in scope 0 at $DIR/inline_closure_captures.rs:+2:7: +2:8
+    let mut _9: i32;                     // in scope 0 at $DIR/inline_closure_captures.rs:+2:5: +2:9
     scope 1 {
-        debug x => _3;                   // in scope 1 at $DIR/inline-closure-captures.rs:+1:9: +1:10
-        scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline-closure-captures.rs:12:5: 12:9
-            debug _q => _9;              // in scope 2 at $DIR/inline-closure-captures.rs:+1:14: +1:16
-            debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline-closure-captures.rs:+0:23: +0:24
-            debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:+0:17: +0:18
-            let mut _10: i32;            // in scope 2 at $DIR/inline-closure-captures.rs:+1:19: +1:20
-            let mut _11: T;              // in scope 2 at $DIR/inline-closure-captures.rs:+1:22: +1:23
-            let mut _12: &i32;           // in scope 2 at $DIR/inline-closure-captures.rs:+1:13: +1:24
-            let mut _13: &T;             // in scope 2 at $DIR/inline-closure-captures.rs:+1:13: +1:24
+        debug x => _3;                   // in scope 1 at $DIR/inline_closure_captures.rs:+1:9: +1:10
+        scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline_closure_captures.rs:12:5: 12:9
+            debug _q => _9;              // in scope 2 at $DIR/inline_closure_captures.rs:+1:14: +1:16
+            debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline_closure_captures.rs:+0:23: +0:24
+            debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline_closure_captures.rs:+0:17: +0:18
+            let mut _10: i32;            // in scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20
+            let mut _11: T;              // in scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23
+            let mut _12: &i32;           // in scope 2 at $DIR/inline_closure_captures.rs:+1:13: +1:24
+            let mut _13: &T;             // in scope 2 at $DIR/inline_closure_captures.rs:+1:13: +1:24
         }
     }
 
     bb0: {
-        StorageLive(_3);                 // scope 0 at $DIR/inline-closure-captures.rs:+1:9: +1:10
-        StorageLive(_4);                 // scope 0 at $DIR/inline-closure-captures.rs:+1:13: +1:24
-        _4 = &_2;                        // scope 0 at $DIR/inline-closure-captures.rs:+1:13: +1:24
-        StorageLive(_5);                 // scope 0 at $DIR/inline-closure-captures.rs:+1:13: +1:24
-        _5 = &_1;                        // scope 0 at $DIR/inline-closure-captures.rs:+1:13: +1:24
-        Deinit(_3);                      // scope 0 at $DIR/inline-closure-captures.rs:+1:13: +1:24
-        (_3.0: &i32) = move _4;          // scope 0 at $DIR/inline-closure-captures.rs:+1:13: +1:24
-        (_3.1: &T) = move _5;            // scope 0 at $DIR/inline-closure-captures.rs:+1:13: +1:24
-        StorageDead(_5);                 // scope 0 at $DIR/inline-closure-captures.rs:+1:16: +1:17
-        StorageDead(_4);                 // scope 0 at $DIR/inline-closure-captures.rs:+1:16: +1:17
-        StorageLive(_6);                 // scope 1 at $DIR/inline-closure-captures.rs:+2:5: +2:6
-        _6 = &_3;                        // scope 1 at $DIR/inline-closure-captures.rs:+2:5: +2:6
-        StorageLive(_7);                 // scope 1 at $DIR/inline-closure-captures.rs:+2:5: +2:9
-        StorageLive(_8);                 // scope 1 at $DIR/inline-closure-captures.rs:+2:7: +2:8
-        _8 = _2;                         // scope 1 at $DIR/inline-closure-captures.rs:+2:7: +2:8
-        Deinit(_7);                      // scope 1 at $DIR/inline-closure-captures.rs:+2:5: +2:9
-        (_7.0: i32) = move _8;           // scope 1 at $DIR/inline-closure-captures.rs:+2:5: +2:9
-        StorageLive(_9);                 // scope 1 at $DIR/inline-closure-captures.rs:+2:5: +2:9
-        _9 = move (_7.0: i32);           // scope 1 at $DIR/inline-closure-captures.rs:+2:5: +2:9
-        StorageLive(_10);                // scope 2 at $DIR/inline-closure-captures.rs:+1:19: +1:20
-        _12 = deref_copy ((*_6).0: &i32); // scope 2 at $DIR/inline-closure-captures.rs:+1:19: +1:20
-        _10 = (*_12);                    // scope 2 at $DIR/inline-closure-captures.rs:+1:19: +1:20
-        StorageLive(_11);                // scope 2 at $DIR/inline-closure-captures.rs:+1:22: +1:23
-        _13 = deref_copy ((*_6).1: &T);  // scope 2 at $DIR/inline-closure-captures.rs:+1:22: +1:23
-        _11 = (*_13);                    // scope 2 at $DIR/inline-closure-captures.rs:+1:22: +1:23
-        Deinit(_0);                      // scope 2 at $DIR/inline-closure-captures.rs:+1:18: +1:24
-        (_0.0: i32) = move _10;          // scope 2 at $DIR/inline-closure-captures.rs:+1:18: +1:24
-        (_0.1: T) = move _11;            // scope 2 at $DIR/inline-closure-captures.rs:+1:18: +1:24
-        StorageDead(_11);                // scope 2 at $DIR/inline-closure-captures.rs:+1:23: +1:24
-        StorageDead(_10);                // scope 2 at $DIR/inline-closure-captures.rs:+1:23: +1:24
-        StorageDead(_9);                 // scope 1 at $DIR/inline-closure-captures.rs:+2:5: +2:9
-        StorageDead(_8);                 // scope 1 at $DIR/inline-closure-captures.rs:+2:8: +2:9
-        StorageDead(_7);                 // scope 1 at $DIR/inline-closure-captures.rs:+2:8: +2:9
-        StorageDead(_6);                 // scope 1 at $DIR/inline-closure-captures.rs:+2:8: +2:9
-        StorageDead(_3);                 // scope 0 at $DIR/inline-closure-captures.rs:+3:1: +3:2
-        return;                          // scope 0 at $DIR/inline-closure-captures.rs:+3:2: +3:2
+        StorageLive(_3);                 // scope 0 at $DIR/inline_closure_captures.rs:+1:9: +1:10
+        StorageLive(_4);                 // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24
+        _4 = &_2;                        // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24
+        StorageLive(_5);                 // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24
+        _5 = &_1;                        // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24
+        Deinit(_3);                      // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24
+        (_3.0: &i32) = move _4;          // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24
+        (_3.1: &T) = move _5;            // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24
+        StorageDead(_5);                 // scope 0 at $DIR/inline_closure_captures.rs:+1:16: +1:17
+        StorageDead(_4);                 // scope 0 at $DIR/inline_closure_captures.rs:+1:16: +1:17
+        StorageLive(_6);                 // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:6
+        _6 = &_3;                        // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:6
+        StorageLive(_7);                 // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9
+        StorageLive(_8);                 // scope 1 at $DIR/inline_closure_captures.rs:+2:7: +2:8
+        _8 = _2;                         // scope 1 at $DIR/inline_closure_captures.rs:+2:7: +2:8
+        Deinit(_7);                      // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9
+        (_7.0: i32) = move _8;           // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9
+        StorageLive(_9);                 // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9
+        _9 = move (_7.0: i32);           // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9
+        StorageLive(_10);                // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20
+        _12 = deref_copy ((*_6).0: &i32); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20
+        _10 = (*_12);                    // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20
+        StorageLive(_11);                // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23
+        _13 = deref_copy ((*_6).1: &T);  // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23
+        _11 = (*_13);                    // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23
+        Deinit(_0);                      // scope 2 at $DIR/inline_closure_captures.rs:+1:18: +1:24
+        (_0.0: i32) = move _10;          // scope 2 at $DIR/inline_closure_captures.rs:+1:18: +1:24
+        (_0.1: T) = move _11;            // scope 2 at $DIR/inline_closure_captures.rs:+1:18: +1:24
+        StorageDead(_11);                // scope 2 at $DIR/inline_closure_captures.rs:+1:23: +1:24
+        StorageDead(_10);                // scope 2 at $DIR/inline_closure_captures.rs:+1:23: +1:24
+        StorageDead(_9);                 // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9
+        StorageDead(_8);                 // scope 1 at $DIR/inline_closure_captures.rs:+2:8: +2:9
+        StorageDead(_7);                 // scope 1 at $DIR/inline_closure_captures.rs:+2:8: +2:9
+        StorageDead(_6);                 // scope 1 at $DIR/inline_closure_captures.rs:+2:8: +2:9
+        StorageDead(_3);                 // scope 0 at $DIR/inline_closure_captures.rs:+3:1: +3:2
+        return;                          // scope 0 at $DIR/inline_closure_captures.rs:+3:2: +3:2
     }
 }
diff --git a/src/test/mir-opt/inline/inline-closure-captures.rs b/src/test/mir-opt/inline/inline_closure_captures.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-closure-captures.rs
rename to src/test/mir-opt/inline/inline_closure_captures.rs
diff --git a/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff
index cf800ba1129..e30a5e116ea 100644
--- a/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff
+++ b/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff
@@ -2,23 +2,23 @@
 + // MIR for `inlined_no_sanitize` after Inline
   
   fn inlined_no_sanitize() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-compatibility.rs:+0:37: +0:37
-      let _1: ();                          // in scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:18
-+     scope 1 (inlined no_sanitize) {      // at $DIR/inline-compatibility.rs:24:5: 24:18
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_compatibility.rs:+0:37: +0:37
+      let _1: ();                          // in scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:18
++     scope 1 (inlined no_sanitize) {      // at $DIR/inline_compatibility.rs:24:5: 24:18
 +     }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:18
--         _1 = no_sanitize() -> bb1;       // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:18
+          StorageLive(_1);                 // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:18
+-         _1 = no_sanitize() -> bb1;       // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:18
 -                                          // mir::Constant
--                                          // + span: $DIR/inline-compatibility.rs:24:5: 24:16
+-                                          // + span: $DIR/inline_compatibility.rs:24:5: 24:16
 -                                          // + literal: Const { ty: unsafe fn() {no_sanitize}, val: Value() }
 -     }
 - 
 -     bb1: {
-          StorageDead(_1);                 // scope 0 at $DIR/inline-compatibility.rs:+1:18: +1:19
-          _0 = const ();                   // scope 0 at $DIR/inline-compatibility.rs:+0:37: +2:2
-          return;                          // scope 0 at $DIR/inline-compatibility.rs:+2:2: +2:2
+          StorageDead(_1);                 // scope 0 at $DIR/inline_compatibility.rs:+1:18: +1:19
+          _0 = const ();                   // scope 0 at $DIR/inline_compatibility.rs:+0:37: +2:2
+          return;                          // scope 0 at $DIR/inline_compatibility.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff
index a45f959026d..c2b3c46a30c 100644
--- a/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff
+++ b/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff
@@ -2,23 +2,23 @@
 + // MIR for `inlined_target_feature` after Inline
   
   fn inlined_target_feature() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-compatibility.rs:+0:40: +0:40
-      let _1: ();                          // in scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:21
-+     scope 1 (inlined target_feature) {   // at $DIR/inline-compatibility.rs:13:5: 13:21
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_compatibility.rs:+0:40: +0:40
+      let _1: ();                          // in scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:21
++     scope 1 (inlined target_feature) {   // at $DIR/inline_compatibility.rs:13:5: 13:21
 +     }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:21
--         _1 = target_feature() -> bb1;    // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:21
+          StorageLive(_1);                 // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:21
+-         _1 = target_feature() -> bb1;    // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:21
 -                                          // mir::Constant
--                                          // + span: $DIR/inline-compatibility.rs:13:5: 13:19
+-                                          // + span: $DIR/inline_compatibility.rs:13:5: 13:19
 -                                          // + literal: Const { ty: unsafe fn() {target_feature}, val: Value() }
 -     }
 - 
 -     bb1: {
-          StorageDead(_1);                 // scope 0 at $DIR/inline-compatibility.rs:+1:21: +1:22
-          _0 = const ();                   // scope 0 at $DIR/inline-compatibility.rs:+0:40: +2:2
-          return;                          // scope 0 at $DIR/inline-compatibility.rs:+2:2: +2:2
+          StorageDead(_1);                 // scope 0 at $DIR/inline_compatibility.rs:+1:21: +1:22
+          _0 = const ();                   // scope 0 at $DIR/inline_compatibility.rs:+0:40: +2:2
+          return;                          // scope 0 at $DIR/inline_compatibility.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff
index 49aea431e46..0ca5a5f70b7 100644
--- a/src/test/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff
+++ b/src/test/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff
@@ -2,24 +2,24 @@
 + // MIR for `not_inlined_c_variadic` after Inline
   
   fn not_inlined_c_variadic() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-compatibility.rs:+0:40: +0:40
-      let _1: u32;                         // in scope 0 at $DIR/inline-compatibility.rs:+1:9: +1:10
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_compatibility.rs:+0:40: +0:40
+      let _1: u32;                         // in scope 0 at $DIR/inline_compatibility.rs:+1:9: +1:10
       scope 1 {
-          debug s => _1;                   // in scope 1 at $DIR/inline-compatibility.rs:+1:9: +1:10
+          debug s => _1;                   // in scope 1 at $DIR/inline_compatibility.rs:+1:9: +1:10
       }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-compatibility.rs:+1:9: +1:10
-          _1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> bb1; // scope 0 at $DIR/inline-compatibility.rs:+1:13: +1:52
+          StorageLive(_1);                 // scope 0 at $DIR/inline_compatibility.rs:+1:9: +1:10
+          _1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> bb1; // scope 0 at $DIR/inline_compatibility.rs:+1:13: +1:52
                                            // mir::Constant
-                                           // + span: $DIR/inline-compatibility.rs:42:13: 42:16
+                                           // + span: $DIR/inline_compatibility.rs:42:13: 42:16
                                            // + literal: Const { ty: unsafe extern "C" fn(u32, ...) -> u32 {sum}, val: Value() }
       }
   
       bb1: {
-          _0 = const ();                   // scope 0 at $DIR/inline-compatibility.rs:+0:40: +2:2
-          StorageDead(_1);                 // scope 0 at $DIR/inline-compatibility.rs:+2:1: +2:2
-          return;                          // scope 0 at $DIR/inline-compatibility.rs:+2:2: +2:2
+          _0 = const ();                   // scope 0 at $DIR/inline_compatibility.rs:+0:40: +2:2
+          StorageDead(_1);                 // scope 0 at $DIR/inline_compatibility.rs:+2:1: +2:2
+          return;                          // scope 0 at $DIR/inline_compatibility.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff
index 94ce574a94d..00d405c77f9 100644
--- a/src/test/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff
+++ b/src/test/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff
@@ -2,21 +2,21 @@
 + // MIR for `not_inlined_no_sanitize` after Inline
   
   fn not_inlined_no_sanitize() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-compatibility.rs:+0:41: +0:41
-      let _1: ();                          // in scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:18
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_compatibility.rs:+0:41: +0:41
+      let _1: ();                          // in scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:18
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:18
-          _1 = no_sanitize() -> bb1;       // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:18
+          StorageLive(_1);                 // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:18
+          _1 = no_sanitize() -> bb1;       // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:18
                                            // mir::Constant
-                                           // + span: $DIR/inline-compatibility.rs:29:5: 29:16
+                                           // + span: $DIR/inline_compatibility.rs:29:5: 29:16
                                            // + literal: Const { ty: unsafe fn() {no_sanitize}, val: Value() }
       }
   
       bb1: {
-          StorageDead(_1);                 // scope 0 at $DIR/inline-compatibility.rs:+1:18: +1:19
-          _0 = const ();                   // scope 0 at $DIR/inline-compatibility.rs:+0:41: +2:2
-          return;                          // scope 0 at $DIR/inline-compatibility.rs:+2:2: +2:2
+          StorageDead(_1);                 // scope 0 at $DIR/inline_compatibility.rs:+1:18: +1:19
+          _0 = const ();                   // scope 0 at $DIR/inline_compatibility.rs:+0:41: +2:2
+          return;                          // scope 0 at $DIR/inline_compatibility.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff
index 8506e257b3f..8b9c86f5515 100644
--- a/src/test/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff
+++ b/src/test/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff
@@ -2,21 +2,21 @@
 + // MIR for `not_inlined_target_feature` after Inline
   
   fn not_inlined_target_feature() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-compatibility.rs:+0:44: +0:44
-      let _1: ();                          // in scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:21
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_compatibility.rs:+0:44: +0:44
+      let _1: ();                          // in scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:21
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:21
-          _1 = target_feature() -> bb1;    // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:21
+          StorageLive(_1);                 // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:21
+          _1 = target_feature() -> bb1;    // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:21
                                            // mir::Constant
-                                           // + span: $DIR/inline-compatibility.rs:18:5: 18:19
+                                           // + span: $DIR/inline_compatibility.rs:18:5: 18:19
                                            // + literal: Const { ty: unsafe fn() {target_feature}, val: Value() }
       }
   
       bb1: {
-          StorageDead(_1);                 // scope 0 at $DIR/inline-compatibility.rs:+1:21: +1:22
-          _0 = const ();                   // scope 0 at $DIR/inline-compatibility.rs:+0:44: +2:2
-          return;                          // scope 0 at $DIR/inline-compatibility.rs:+2:2: +2:2
+          StorageDead(_1);                 // scope 0 at $DIR/inline_compatibility.rs:+1:21: +1:22
+          _0 = const ();                   // scope 0 at $DIR/inline_compatibility.rs:+0:44: +2:2
+          return;                          // scope 0 at $DIR/inline_compatibility.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline-compatibility.rs b/src/test/mir-opt/inline/inline_compatibility.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-compatibility.rs
rename to src/test/mir-opt/inline/inline_compatibility.rs
diff --git a/src/test/mir-opt/inline/inline_cycle.one.Inline.diff b/src/test/mir-opt/inline/inline_cycle.one.Inline.diff
index a4d706de0ba..5510cd7bc8c 100644
--- a/src/test/mir-opt/inline/inline_cycle.one.Inline.diff
+++ b/src/test/mir-opt/inline/inline_cycle.one.Inline.diff
@@ -2,29 +2,29 @@
 + // MIR for `one` after Inline
   
   fn one() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-cycle.rs:+0:10: +0:10
-      let _1: ();                          // in scope 0 at $DIR/inline-cycle.rs:+1:5: +1:24
-+     scope 1 (inlined ::call) { // at $DIR/inline-cycle.rs:14:5: 14:24
-+         scope 2 (inlined  as Call>::call) { // at $DIR/inline-cycle.rs:43:9: 43:23
-+             scope 3 (inlined  as Call>::call) { // at $DIR/inline-cycle.rs:28:9: 28:31
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_cycle.rs:+0:10: +0:10
+      let _1: ();                          // in scope 0 at $DIR/inline_cycle.rs:+1:5: +1:24
++     scope 1 (inlined ::call) { // at $DIR/inline_cycle.rs:14:5: 14:24
++         scope 2 (inlined  as Call>::call) { // at $DIR/inline_cycle.rs:43:9: 43:23
++             scope 3 (inlined  as Call>::call) { // at $DIR/inline_cycle.rs:28:9: 28:31
 +             }
 +         }
 +     }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:24
--         _1 = ::call() -> bb1; // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:24
-+         _1 = ::call() -> bb1; // scope 3 at $DIR/inline-cycle.rs:36:9: 36:28
+          StorageLive(_1);                 // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:24
+-         _1 = ::call() -> bb1; // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:24
++         _1 = ::call() -> bb1; // scope 3 at $DIR/inline_cycle.rs:36:9: 36:28
                                            // mir::Constant
--                                          // + span: $DIR/inline-cycle.rs:14:5: 14:22
-+                                          // + span: $DIR/inline-cycle.rs:36:9: 36:26
+-                                          // + span: $DIR/inline_cycle.rs:14:5: 14:22
++                                          // + span: $DIR/inline_cycle.rs:36:9: 36:26
                                            // + literal: Const { ty: fn() {::call}, val: Value() }
       }
   
       bb1: {
-          StorageDead(_1);                 // scope 0 at $DIR/inline-cycle.rs:+1:24: +1:25
-          _0 = const ();                   // scope 0 at $DIR/inline-cycle.rs:+0:10: +2:2
-          return;                          // scope 0 at $DIR/inline-cycle.rs:+2:2: +2:2
+          StorageDead(_1);                 // scope 0 at $DIR/inline_cycle.rs:+1:24: +1:25
+          _0 = const ();                   // scope 0 at $DIR/inline_cycle.rs:+0:10: +2:2
+          return;                          // scope 0 at $DIR/inline_cycle.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline-cycle.rs b/src/test/mir-opt/inline/inline_cycle.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-cycle.rs
rename to src/test/mir-opt/inline/inline_cycle.rs
diff --git a/src/test/mir-opt/inline/inline_cycle.two.Inline.diff b/src/test/mir-opt/inline/inline_cycle.two.Inline.diff
index b1a5b62ef1d..eceeb96f79f 100644
--- a/src/test/mir-opt/inline/inline_cycle.two.Inline.diff
+++ b/src/test/mir-opt/inline/inline_cycle.two.Inline.diff
@@ -2,54 +2,54 @@
 + // MIR for `two` after Inline
   
   fn two() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-cycle.rs:+0:10: +0:10
-      let _1: ();                          // in scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12
-+     let mut _2: fn() {f};                // in scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12
-+     scope 1 (inlined call::) { // at $DIR/inline-cycle.rs:49:5: 49:12
-+         debug f => _2;                   // in scope 1 at $DIR/inline-cycle.rs:53:22: 53:23
-+         let _3: ();                      // in scope 1 at $DIR/inline-cycle.rs:54:5: 54:8
-+         let mut _4: fn() {f};            // in scope 1 at $DIR/inline-cycle.rs:54:5: 54:6
-+         let mut _5: ();                  // in scope 1 at $DIR/inline-cycle.rs:54:5: 54:8
-+         scope 2 (inlined >::call_once - shim(fn() {f})) { // at $DIR/inline-cycle.rs:54:5: 54:8
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_cycle.rs:+0:10: +0:10
+      let _1: ();                          // in scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12
++     let mut _2: fn() {f};                // in scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12
++     scope 1 (inlined call::) { // at $DIR/inline_cycle.rs:49:5: 49:12
++         debug f => _2;                   // in scope 1 at $DIR/inline_cycle.rs:53:22: 53:23
++         let _3: ();                      // in scope 1 at $DIR/inline_cycle.rs:54:5: 54:8
++         let mut _4: fn() {f};            // in scope 1 at $DIR/inline_cycle.rs:54:5: 54:6
++         let mut _5: ();                  // in scope 1 at $DIR/inline_cycle.rs:54:5: 54:8
++         scope 2 (inlined >::call_once - shim(fn() {f})) { // at $DIR/inline_cycle.rs:54:5: 54:8
 +             scope 3 (inlined f) {        // at $SRC_DIR/core/src/ops/function.rs:LL:COL
-+                 let _6: ();              // in scope 3 at $DIR/inline-cycle.rs:59:5: 59:12
++                 let _6: ();              // in scope 3 at $DIR/inline_cycle.rs:59:5: 59:12
 +             }
 +         }
 +     }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12
--         _1 = call::(f) -> bb1; // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12
-+         StorageLive(_2);                 // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12
-+         _2 = f;                          // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12
+          StorageLive(_1);                 // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12
+-         _1 = call::(f) -> bb1; // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12
++         StorageLive(_2);                 // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12
++         _2 = f;                          // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12
                                            // mir::Constant
--                                          // + span: $DIR/inline-cycle.rs:49:5: 49:9
-+                                          // + span: $DIR/inline-cycle.rs:49:10: 49:11
+-                                          // + span: $DIR/inline_cycle.rs:49:5: 49:9
++                                          // + span: $DIR/inline_cycle.rs:49:10: 49:11
 +                                          // + literal: Const { ty: fn() {f}, val: Value() }
-+         StorageLive(_3);                 // scope 1 at $DIR/inline-cycle.rs:54:5: 54:8
-+         StorageLive(_4);                 // scope 1 at $DIR/inline-cycle.rs:54:5: 54:6
-+         _4 = move _2;                    // scope 1 at $DIR/inline-cycle.rs:54:5: 54:6
-+         StorageLive(_5);                 // scope 1 at $DIR/inline-cycle.rs:54:5: 54:8
-+         StorageLive(_6);                 // scope 3 at $DIR/inline-cycle.rs:59:5: 59:12
-+         _6 = call::(f) -> bb1; // scope 3 at $DIR/inline-cycle.rs:59:5: 59:12
++         StorageLive(_3);                 // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8
++         StorageLive(_4);                 // scope 1 at $DIR/inline_cycle.rs:54:5: 54:6
++         _4 = move _2;                    // scope 1 at $DIR/inline_cycle.rs:54:5: 54:6
++         StorageLive(_5);                 // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8
++         StorageLive(_6);                 // scope 3 at $DIR/inline_cycle.rs:59:5: 59:12
++         _6 = call::(f) -> bb1; // scope 3 at $DIR/inline_cycle.rs:59:5: 59:12
 +                                          // mir::Constant
-+                                          // + span: $DIR/inline-cycle.rs:59:5: 59:9
++                                          // + span: $DIR/inline_cycle.rs:59:5: 59:9
                                            // + literal: Const { ty: fn(fn() {f}) {call::}, val: Value() }
                                            // mir::Constant
--                                          // + span: $DIR/inline-cycle.rs:49:10: 49:11
-+                                          // + span: $DIR/inline-cycle.rs:59:10: 59:11
+-                                          // + span: $DIR/inline_cycle.rs:49:10: 49:11
++                                          // + span: $DIR/inline_cycle.rs:59:10: 59:11
                                            // + literal: Const { ty: fn() {f}, val: Value() }
       }
   
       bb1: {
-+         StorageDead(_6);                 // scope 3 at $DIR/inline-cycle.rs:59:12: 59:13
-+         StorageDead(_5);                 // scope 1 at $DIR/inline-cycle.rs:54:7: 54:8
-+         StorageDead(_4);                 // scope 1 at $DIR/inline-cycle.rs:54:7: 54:8
-+         StorageDead(_3);                 // scope 1 at $DIR/inline-cycle.rs:54:8: 54:9
-+         StorageDead(_2);                 // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12
-          StorageDead(_1);                 // scope 0 at $DIR/inline-cycle.rs:+1:12: +1:13
-          _0 = const ();                   // scope 0 at $DIR/inline-cycle.rs:+0:10: +2:2
-          return;                          // scope 0 at $DIR/inline-cycle.rs:+2:2: +2:2
++         StorageDead(_6);                 // scope 3 at $DIR/inline_cycle.rs:59:12: 59:13
++         StorageDead(_5);                 // scope 1 at $DIR/inline_cycle.rs:54:7: 54:8
++         StorageDead(_4);                 // scope 1 at $DIR/inline_cycle.rs:54:7: 54:8
++         StorageDead(_3);                 // scope 1 at $DIR/inline_cycle.rs:54:8: 54:9
++         StorageDead(_2);                 // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12
+          StorageDead(_1);                 // scope 0 at $DIR/inline_cycle.rs:+1:12: +1:13
+          _0 = const ();                   // scope 0 at $DIR/inline_cycle.rs:+0:10: +2:2
+          return;                          // scope 0 at $DIR/inline_cycle.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline_cycle_generic.main.Inline.diff b/src/test/mir-opt/inline/inline_cycle_generic.main.Inline.diff
index fc5d57ce8bf..52debab4dd1 100644
--- a/src/test/mir-opt/inline/inline_cycle_generic.main.Inline.diff
+++ b/src/test/mir-opt/inline/inline_cycle_generic.main.Inline.diff
@@ -2,31 +2,31 @@
 + // MIR for `main` after Inline
   
   fn main() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-cycle-generic.rs:+0:11: +0:11
-      let _1: ();                          // in scope 0 at $DIR/inline-cycle-generic.rs:+1:5: +1:24
-+     scope 1 (inlined ::call) { // at $DIR/inline-cycle-generic.rs:9:5: 9:24
-+         scope 2 (inlined  as Call>::call) { // at $DIR/inline-cycle-generic.rs:38:9: 38:31
-+             scope 3 (inlined ::call) { // at $DIR/inline-cycle-generic.rs:31:9: 31:28
-+                 scope 4 (inlined  as Call>::call) { // at $DIR/inline-cycle-generic.rs:23:9: 23:31
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_cycle_generic.rs:+0:11: +0:11
+      let _1: ();                          // in scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24
++     scope 1 (inlined ::call) { // at $DIR/inline_cycle_generic.rs:9:5: 9:24
++         scope 2 (inlined  as Call>::call) { // at $DIR/inline_cycle_generic.rs:38:9: 38:31
++             scope 3 (inlined ::call) { // at $DIR/inline_cycle_generic.rs:31:9: 31:28
++                 scope 4 (inlined  as Call>::call) { // at $DIR/inline_cycle_generic.rs:23:9: 23:31
 +                 }
 +             }
 +         }
 +     }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-cycle-generic.rs:+1:5: +1:24
--         _1 = ::call() -> bb1; // scope 0 at $DIR/inline-cycle-generic.rs:+1:5: +1:24
-+         _1 = ::call() -> bb1; // scope 4 at $DIR/inline-cycle-generic.rs:31:9: 31:28
+          StorageLive(_1);                 // scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24
+-         _1 = ::call() -> bb1; // scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24
++         _1 = ::call() -> bb1; // scope 4 at $DIR/inline_cycle_generic.rs:31:9: 31:28
                                            // mir::Constant
--                                          // + span: $DIR/inline-cycle-generic.rs:9:5: 9:22
-+                                          // + span: $DIR/inline-cycle-generic.rs:31:9: 31:26
+-                                          // + span: $DIR/inline_cycle_generic.rs:9:5: 9:22
++                                          // + span: $DIR/inline_cycle_generic.rs:31:9: 31:26
                                            // + literal: Const { ty: fn() {::call}, val: Value() }
       }
   
       bb1: {
-          StorageDead(_1);                 // scope 0 at $DIR/inline-cycle-generic.rs:+1:24: +1:25
-          _0 = const ();                   // scope 0 at $DIR/inline-cycle-generic.rs:+0:11: +2:2
-          return;                          // scope 0 at $DIR/inline-cycle-generic.rs:+2:2: +2:2
+          StorageDead(_1);                 // scope 0 at $DIR/inline_cycle_generic.rs:+1:24: +1:25
+          _0 = const ();                   // scope 0 at $DIR/inline_cycle_generic.rs:+0:11: +2:2
+          return;                          // scope 0 at $DIR/inline_cycle_generic.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline-cycle-generic.rs b/src/test/mir-opt/inline/inline_cycle_generic.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-cycle-generic.rs
rename to src/test/mir-opt/inline/inline_cycle_generic.rs
diff --git a/src/test/mir-opt/inline/inline_diverging.f.Inline.diff b/src/test/mir-opt/inline/inline_diverging.f.Inline.diff
index cef4cfc67ab..b49191f495b 100644
--- a/src/test/mir-opt/inline/inline_diverging.f.Inline.diff
+++ b/src/test/mir-opt/inline/inline_diverging.f.Inline.diff
@@ -2,23 +2,23 @@
 + // MIR for `f` after Inline
   
   fn f() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-diverging.rs:+0:12: +0:12
-      let mut _1: !;                       // in scope 0 at $DIR/inline-diverging.rs:+0:12: +2:2
-      let _2: !;                           // in scope 0 at $DIR/inline-diverging.rs:+1:5: +1:12
-+     scope 1 (inlined sleep) {            // at $DIR/inline-diverging.rs:8:5: 8:12
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_diverging.rs:+0:12: +0:12
+      let mut _1: !;                       // in scope 0 at $DIR/inline_diverging.rs:+0:12: +2:2
+      let _2: !;                           // in scope 0 at $DIR/inline_diverging.rs:+1:5: +1:12
++     scope 1 (inlined sleep) {            // at $DIR/inline_diverging.rs:8:5: 8:12
 +     }
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:12
--         _2 = sleep();                    // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:12
+          StorageLive(_2);                 // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:12
+-         _2 = sleep();                    // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:12
 -                                          // mir::Constant
--                                          // + span: $DIR/inline-diverging.rs:8:5: 8:10
+-                                          // + span: $DIR/inline_diverging.rs:8:5: 8:10
 -                                          // + literal: Const { ty: fn() -> ! {sleep}, val: Value() }
-+         goto -> bb1;                     // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:12
++         goto -> bb1;                     // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:12
 +     }
 + 
 +     bb1: {
-+         goto -> bb1;                     // scope 1 at $DIR/inline-diverging.rs:39:5: 39:12
++         goto -> bb1;                     // scope 1 at $DIR/inline_diverging.rs:39:5: 39:12
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline_diverging.g.Inline.diff b/src/test/mir-opt/inline/inline_diverging.g.Inline.diff
index a71baad3e3e..1e703a8fd2b 100644
--- a/src/test/mir-opt/inline/inline_diverging.g.Inline.diff
+++ b/src/test/mir-opt/inline/inline_diverging.g.Inline.diff
@@ -2,42 +2,42 @@
 + // MIR for `g` after Inline
   
   fn g(_1: i32) -> u32 {
-      debug i => _1;                       // in scope 0 at $DIR/inline-diverging.rs:+0:10: +0:11
-      let mut _0: u32;                     // return place in scope 0 at $DIR/inline-diverging.rs:+0:21: +0:24
-      let mut _2: bool;                    // in scope 0 at $DIR/inline-diverging.rs:+1:8: +1:13
-      let mut _3: i32;                     // in scope 0 at $DIR/inline-diverging.rs:+1:8: +1:9
-      let mut _4: i32;                     // in scope 0 at $DIR/inline-diverging.rs:+2:9: +2:10
-      let mut _5: !;                       // in scope 0 at $DIR/inline-diverging.rs:+3:12: +5:6
-      let _6: !;                           // in scope 0 at $DIR/inline-diverging.rs:+4:9: +4:16
-+     scope 1 (inlined panic) {            // at $DIR/inline-diverging.rs:16:9: 16:16
+      debug i => _1;                       // in scope 0 at $DIR/inline_diverging.rs:+0:10: +0:11
+      let mut _0: u32;                     // return place in scope 0 at $DIR/inline_diverging.rs:+0:21: +0:24
+      let mut _2: bool;                    // in scope 0 at $DIR/inline_diverging.rs:+1:8: +1:13
+      let mut _3: i32;                     // in scope 0 at $DIR/inline_diverging.rs:+1:8: +1:9
+      let mut _4: i32;                     // in scope 0 at $DIR/inline_diverging.rs:+2:9: +2:10
+      let mut _5: !;                       // in scope 0 at $DIR/inline_diverging.rs:+3:12: +5:6
+      let _6: !;                           // in scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16
++     scope 1 (inlined panic) {            // at $DIR/inline_diverging.rs:16:9: 16:16
 +         let mut _7: !;                   // in scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL
 +     }
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/inline-diverging.rs:+1:8: +1:13
-          StorageLive(_3);                 // scope 0 at $DIR/inline-diverging.rs:+1:8: +1:9
-          _3 = _1;                         // scope 0 at $DIR/inline-diverging.rs:+1:8: +1:9
-          _2 = Gt(move _3, const 0_i32);   // scope 0 at $DIR/inline-diverging.rs:+1:8: +1:13
-          StorageDead(_3);                 // scope 0 at $DIR/inline-diverging.rs:+1:12: +1:13
-          switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/inline-diverging.rs:+1:8: +1:13
+          StorageLive(_2);                 // scope 0 at $DIR/inline_diverging.rs:+1:8: +1:13
+          StorageLive(_3);                 // scope 0 at $DIR/inline_diverging.rs:+1:8: +1:9
+          _3 = _1;                         // scope 0 at $DIR/inline_diverging.rs:+1:8: +1:9
+          _2 = Gt(move _3, const 0_i32);   // scope 0 at $DIR/inline_diverging.rs:+1:8: +1:13
+          StorageDead(_3);                 // scope 0 at $DIR/inline_diverging.rs:+1:12: +1:13
+          switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/inline_diverging.rs:+1:8: +1:13
       }
   
       bb1: {
-          StorageLive(_4);                 // scope 0 at $DIR/inline-diverging.rs:+2:9: +2:10
-          _4 = _1;                         // scope 0 at $DIR/inline-diverging.rs:+2:9: +2:10
-          _0 = move _4 as u32 (IntToInt);  // scope 0 at $DIR/inline-diverging.rs:+2:9: +2:17
-          StorageDead(_4);                 // scope 0 at $DIR/inline-diverging.rs:+2:16: +2:17
-          StorageDead(_2);                 // scope 0 at $DIR/inline-diverging.rs:+5:5: +5:6
-          return;                          // scope 0 at $DIR/inline-diverging.rs:+6:2: +6:2
+          StorageLive(_4);                 // scope 0 at $DIR/inline_diverging.rs:+2:9: +2:10
+          _4 = _1;                         // scope 0 at $DIR/inline_diverging.rs:+2:9: +2:10
+          _0 = move _4 as u32 (IntToInt);  // scope 0 at $DIR/inline_diverging.rs:+2:9: +2:17
+          StorageDead(_4);                 // scope 0 at $DIR/inline_diverging.rs:+2:16: +2:17
+          StorageDead(_2);                 // scope 0 at $DIR/inline_diverging.rs:+5:5: +5:6
+          return;                          // scope 0 at $DIR/inline_diverging.rs:+6:2: +6:2
       }
   
       bb2: {
-          StorageLive(_6);                 // scope 0 at $DIR/inline-diverging.rs:+4:9: +4:16
--         _6 = panic();                    // scope 0 at $DIR/inline-diverging.rs:+4:9: +4:16
+          StorageLive(_6);                 // scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16
+-         _6 = panic();                    // scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16
 +         StorageLive(_7);                 // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL
 +         _7 = begin_panic::<&str>(const "explicit panic"); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL
                                            // mir::Constant
--                                          // + span: $DIR/inline-diverging.rs:16:9: 16:14
+-                                          // + span: $DIR/inline_diverging.rs:16:9: 16:14
 -                                          // + literal: Const { ty: fn() -> ! {panic}, val: Value() }
 +                                          // + span: $SRC_DIR/std/src/panic.rs:LL:COL
 +                                          // + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value() }
diff --git a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff
index 6569ab24c38..152153a813c 100644
--- a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff
+++ b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff
@@ -2,55 +2,55 @@
 + // MIR for `h` after Inline
   
   fn h() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-diverging.rs:+0:12: +0:12
-      let _1: (!, !);                      // in scope 0 at $DIR/inline-diverging.rs:+1:5: +1:22
-+     let mut _2: fn() -> ! {sleep};       // in scope 0 at $DIR/inline-diverging.rs:+1:5: +1:22
-+     scope 1 (inlined call_twice:: ! {sleep}>) { // at $DIR/inline-diverging.rs:22:5: 22:22
-+         debug f => _2;                   // in scope 1 at $DIR/inline-diverging.rs:26:36: 26:37
-+         let _3: !;                       // in scope 1 at $DIR/inline-diverging.rs:27:9: 27:10
-+         let mut _4: &fn() -> ! {sleep};  // in scope 1 at $DIR/inline-diverging.rs:27:13: 27:14
-+         let mut _5: ();                  // in scope 1 at $DIR/inline-diverging.rs:27:13: 27:16
-+         let mut _7: &fn() -> ! {sleep};  // in scope 1 at $DIR/inline-diverging.rs:28:13: 28:14
-+         let mut _8: ();                  // in scope 1 at $DIR/inline-diverging.rs:28:13: 28:16
-+         let mut _9: !;                   // in scope 1 at $DIR/inline-diverging.rs:29:6: 29:7
-+         let mut _10: !;                  // in scope 1 at $DIR/inline-diverging.rs:29:9: 29:10
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_diverging.rs:+0:12: +0:12
+      let _1: (!, !);                      // in scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22
++     let mut _2: fn() -> ! {sleep};       // in scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22
++     scope 1 (inlined call_twice:: ! {sleep}>) { // at $DIR/inline_diverging.rs:22:5: 22:22
++         debug f => _2;                   // in scope 1 at $DIR/inline_diverging.rs:26:36: 26:37
++         let _3: !;                       // in scope 1 at $DIR/inline_diverging.rs:27:9: 27:10
++         let mut _4: &fn() -> ! {sleep};  // in scope 1 at $DIR/inline_diverging.rs:27:13: 27:14
++         let mut _5: ();                  // in scope 1 at $DIR/inline_diverging.rs:27:13: 27:16
++         let mut _7: &fn() -> ! {sleep};  // in scope 1 at $DIR/inline_diverging.rs:28:13: 28:14
++         let mut _8: ();                  // in scope 1 at $DIR/inline_diverging.rs:28:13: 28:16
++         let mut _9: !;                   // in scope 1 at $DIR/inline_diverging.rs:29:6: 29:7
++         let mut _10: !;                  // in scope 1 at $DIR/inline_diverging.rs:29:9: 29:10
 +         scope 2 {
-+             debug a => _3;               // in scope 2 at $DIR/inline-diverging.rs:27:9: 27:10
-+             let _6: !;                   // in scope 2 at $DIR/inline-diverging.rs:28:9: 28:10
++             debug a => _3;               // in scope 2 at $DIR/inline_diverging.rs:27:9: 27:10
++             let _6: !;                   // in scope 2 at $DIR/inline_diverging.rs:28:9: 28:10
 +             scope 3 {
-+                 debug b => _6;           // in scope 3 at $DIR/inline-diverging.rs:28:9: 28:10
++                 debug b => _6;           // in scope 3 at $DIR/inline_diverging.rs:28:9: 28:10
 +             }
-+             scope 6 (inlined  ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline-diverging.rs:28:13: 28:16
++             scope 6 (inlined  ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline_diverging.rs:28:13: 28:16
 +                 scope 7 (inlined sleep) { // at $SRC_DIR/core/src/ops/function.rs:LL:COL
 +                 }
 +             }
 +         }
-+         scope 4 (inlined  ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline-diverging.rs:27:13: 27:16
++         scope 4 (inlined  ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline_diverging.rs:27:13: 27:16
 +             scope 5 (inlined sleep) {    // at $SRC_DIR/core/src/ops/function.rs:LL:COL
 +             }
 +         }
 +     }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:22
--         _1 = call_twice:: ! {sleep}>(sleep); // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:22
-+         StorageLive(_2);                 // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:22
-+         _2 = sleep;                      // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:22
+          StorageLive(_1);                 // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22
+-         _1 = call_twice:: ! {sleep}>(sleep); // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22
++         StorageLive(_2);                 // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22
++         _2 = sleep;                      // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22
                                            // mir::Constant
--                                          // + span: $DIR/inline-diverging.rs:22:5: 22:15
+-                                          // + span: $DIR/inline_diverging.rs:22:5: 22:15
 -                                          // + literal: Const { ty: fn(fn() -> ! {sleep}) -> (!, !) {call_twice:: ! {sleep}>}, val: Value() }
 -                                          // mir::Constant
-                                           // + span: $DIR/inline-diverging.rs:22:16: 22:21
+                                           // + span: $DIR/inline_diverging.rs:22:16: 22:21
                                            // + literal: Const { ty: fn() -> ! {sleep}, val: Value() }
-+         StorageLive(_3);                 // scope 1 at $DIR/inline-diverging.rs:27:9: 27:10
-+         StorageLive(_4);                 // scope 1 at $DIR/inline-diverging.rs:27:13: 27:14
-+         _4 = &_2;                        // scope 1 at $DIR/inline-diverging.rs:27:13: 27:14
-+         StorageLive(_5);                 // scope 1 at $DIR/inline-diverging.rs:27:13: 27:16
-+         goto -> bb1;                     // scope 5 at $DIR/inline-diverging.rs:39:5: 39:12
++         StorageLive(_3);                 // scope 1 at $DIR/inline_diverging.rs:27:9: 27:10
++         StorageLive(_4);                 // scope 1 at $DIR/inline_diverging.rs:27:13: 27:14
++         _4 = &_2;                        // scope 1 at $DIR/inline_diverging.rs:27:13: 27:14
++         StorageLive(_5);                 // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16
++         goto -> bb1;                     // scope 5 at $DIR/inline_diverging.rs:39:5: 39:12
 +     }
 + 
 +     bb1: {
-+         goto -> bb1;                     // scope 5 at $DIR/inline-diverging.rs:39:5: 39:12
++         goto -> bb1;                     // scope 5 at $DIR/inline_diverging.rs:39:5: 39:12
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline-diverging.rs b/src/test/mir-opt/inline/inline_diverging.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-diverging.rs
rename to src/test/mir-opt/inline/inline_diverging.rs
diff --git a/src/test/mir-opt/inline/inline_generator.main.Inline.diff b/src/test/mir-opt/inline/inline_generator.main.Inline.diff
index 3fd8aad7238..26202f2f40d 100644
--- a/src/test/mir-opt/inline/inline_generator.main.Inline.diff
+++ b/src/test/mir-opt/inline/inline_generator.main.Inline.diff
@@ -2,59 +2,59 @@
 + // MIR for `main` after Inline
   
   fn main() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-generator.rs:+0:11: +0:11
-      let _1: std::ops::GeneratorState; // in scope 0 at $DIR/inline-generator.rs:+1:9: +1:11
-      let mut _2: std::pin::Pin<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>; // in scope 0 at $DIR/inline-generator.rs:+1:14: +1:32
-      let mut _3: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline-generator.rs:+1:23: +1:31
-      let mut _4: [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline-generator.rs:+1:28: +1:31
-+     let mut _7: bool;                    // in scope 0 at $DIR/inline-generator.rs:+1:14: +1:46
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_generator.rs:+0:11: +0:11
+      let _1: std::ops::GeneratorState; // in scope 0 at $DIR/inline_generator.rs:+1:9: +1:11
+      let mut _2: std::pin::Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>; // in scope 0 at $DIR/inline_generator.rs:+1:14: +1:32
+      let mut _3: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline_generator.rs:+1:23: +1:31
+      let mut _4: [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline_generator.rs:+1:28: +1:31
++     let mut _7: bool;                    // in scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
       scope 1 {
-          debug _r => _1;                  // in scope 1 at $DIR/inline-generator.rs:+1:9: +1:11
+          debug _r => _1;                  // in scope 1 at $DIR/inline_generator.rs:+1:9: +1:11
       }
-+     scope 2 (inlined g) {                // at $DIR/inline-generator.rs:9:28: 9:31
++     scope 2 (inlined g) {                // at $DIR/inline_generator.rs:9:28: 9:31
 +     }
-+     scope 3 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new) { // at $DIR/inline-generator.rs:9:14: 9:32
++     scope 3 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new) { // at $DIR/inline_generator.rs:9:14: 9:32
 +         debug pointer => _3;             // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL
-+         let mut _5: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL
++         let mut _5: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL
 +         scope 4 {
-+             scope 5 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new_unchecked) { // at $SRC_DIR/core/src/pin.rs:LL:COL
++             scope 5 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new_unchecked) { // at $SRC_DIR/core/src/pin.rs:LL:COL
 +                 debug pointer => _5;     // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
-+                 let mut _6: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
++                 let mut _6: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
 +             }
 +         }
 +     }
-+     scope 6 (inlined g::{closure#0}) {   // at $DIR/inline-generator.rs:9:14: 9:46
-+         debug a => _11;                  // in scope 6 at $DIR/inline-generator.rs:15:6: 15:7
-+         let mut _8: i32;                 // in scope 6 at $DIR/inline-generator.rs:15:17: 15:39
-+         let mut _9: bool;                // in scope 6 at $DIR/inline-generator.rs:15:20: 15:21
-+         let mut _10: bool;               // in scope 6 at $DIR/inline-generator.rs:15:9: 15:9
-+         let _11: bool;                   // in scope 6 at $DIR/inline-generator.rs:15:6: 15:7
-+         let mut _12: u32;                // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         let mut _13: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         let mut _14: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         let mut _15: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++     scope 6 (inlined g::{closure#0}) {   // at $DIR/inline_generator.rs:9:14: 9:46
++         debug a => _11;                  // in scope 6 at $DIR/inline_generator.rs:15:6: 15:7
++         let mut _8: i32;                 // in scope 6 at $DIR/inline_generator.rs:15:17: 15:39
++         let mut _9: bool;                // in scope 6 at $DIR/inline_generator.rs:15:20: 15:21
++         let mut _10: bool;               // in scope 6 at $DIR/inline_generator.rs:15:9: 15:9
++         let _11: bool;                   // in scope 6 at $DIR/inline_generator.rs:15:6: 15:7
++         let mut _12: u32;                // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41
++         let mut _13: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41
++         let mut _14: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41
++         let mut _15: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41
 +     }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-generator.rs:+1:9: +1:11
-          StorageLive(_2);                 // scope 0 at $DIR/inline-generator.rs:+1:14: +1:32
-          StorageLive(_3);                 // scope 0 at $DIR/inline-generator.rs:+1:23: +1:31
-          StorageLive(_4);                 // scope 0 at $DIR/inline-generator.rs:+1:28: +1:31
--         _4 = g() -> bb1;                 // scope 0 at $DIR/inline-generator.rs:+1:28: +1:31
+          StorageLive(_1);                 // scope 0 at $DIR/inline_generator.rs:+1:9: +1:11
+          StorageLive(_2);                 // scope 0 at $DIR/inline_generator.rs:+1:14: +1:32
+          StorageLive(_3);                 // scope 0 at $DIR/inline_generator.rs:+1:23: +1:31
+          StorageLive(_4);                 // scope 0 at $DIR/inline_generator.rs:+1:28: +1:31
+-         _4 = g() -> bb1;                 // scope 0 at $DIR/inline_generator.rs:+1:28: +1:31
 -                                          // mir::Constant
--                                          // + span: $DIR/inline-generator.rs:9:28: 9:29
+-                                          // + span: $DIR/inline_generator.rs:9:28: 9:29
 -                                          // + literal: Const { ty: fn() -> impl Generator {g}, val: Value() }
 -     }
 - 
 -     bb1: {
-+         Deinit(_4);                      // scope 2 at $DIR/inline-generator.rs:15:5: 15:41
-+         discriminant(_4) = 0;            // scope 2 at $DIR/inline-generator.rs:15:5: 15:41
-          _3 = &mut _4;                    // scope 0 at $DIR/inline-generator.rs:+1:23: +1:31
--         _2 = Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new(move _3) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:+1:14: +1:32
++         Deinit(_4);                      // scope 2 at $DIR/inline_generator.rs:15:5: 15:41
++         discriminant(_4) = 0;            // scope 2 at $DIR/inline_generator.rs:15:5: 15:41
+          _3 = &mut _4;                    // scope 0 at $DIR/inline_generator.rs:+1:23: +1:31
+-         _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new(move _3) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline_generator.rs:+1:14: +1:32
 -                                          // mir::Constant
--                                          // + span: $DIR/inline-generator.rs:9:14: 9:22
+-                                          // + span: $DIR/inline_generator.rs:9:14: 9:22
 -                                          // + user_ty: UserType(0)
--                                          // + literal: Const { ty: fn(&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]) -> Pin<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]> {Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new}, val: Value() }
+-                                          // + literal: Const { ty: fn(&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]) -> Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]> {Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new}, val: Value() }
 -     }
 - 
 -     bb2: {
@@ -63,86 +63,86 @@
 +         StorageLive(_6);                 // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
 +         _6 = move _5;                    // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
 +         Deinit(_2);                      // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
-+         (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]) = move _6; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
++         (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]) = move _6; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
 +         StorageDead(_6);                 // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
 +         StorageDead(_5);                 // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL
-          StorageDead(_3);                 // scope 0 at $DIR/inline-generator.rs:+1:31: +1:32
--         _1 = <[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46
+          StorageDead(_3);                 // scope 0 at $DIR/inline_generator.rs:+1:31: +1:32
+-         _1 = <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
 -                                          // mir::Constant
--                                          // + span: $DIR/inline-generator.rs:9:33: 9:39
--                                          // + literal: Const { ty: for<'a> fn(Pin<&'a mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>, bool) -> GeneratorState<<[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator>::Yield, <[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator>::Return> {<[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator>::resume}, val: Value() }
-+         StorageLive(_7);                 // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46
-+         _7 = const false;                // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46
-+         StorageLive(_10);                // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46
-+         StorageLive(_11);                // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46
-+         _13 = deref_copy (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         _12 = discriminant((*_13));      // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
+-                                          // + span: $DIR/inline_generator.rs:9:33: 9:39
+-                                          // + literal: Const { ty: for<'a> fn(Pin<&'a mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>, bool) -> GeneratorState<<[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::Yield, <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::Return> {<[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::resume}, val: Value() }
++         StorageLive(_7);                 // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
++         _7 = const false;                // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
++         StorageLive(_10);                // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
++         StorageLive(_11);                // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
++         _13 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41
++         _12 = discriminant((*_13));      // scope 6 at $DIR/inline_generator.rs:15:5: 15:41
++         switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41
       }
   
 -     bb3: {
 +     bb1: {
-+         StorageDead(_11);                // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46
-+         StorageDead(_10);                // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46
-+         StorageDead(_7);                 // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46
-          StorageDead(_2);                 // scope 0 at $DIR/inline-generator.rs:+1:45: +1:46
-          StorageDead(_4);                 // scope 0 at $DIR/inline-generator.rs:+1:46: +1:47
-          _0 = const ();                   // scope 0 at $DIR/inline-generator.rs:+0:11: +2:2
-          StorageDead(_1);                 // scope 0 at $DIR/inline-generator.rs:+2:1: +2:2
-          return;                          // scope 0 at $DIR/inline-generator.rs:+2:2: +2:2
++         StorageDead(_11);                // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
++         StorageDead(_10);                // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
++         StorageDead(_7);                 // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
+          StorageDead(_2);                 // scope 0 at $DIR/inline_generator.rs:+1:45: +1:46
+          StorageDead(_4);                 // scope 0 at $DIR/inline_generator.rs:+1:46: +1:47
+          _0 = const ();                   // scope 0 at $DIR/inline_generator.rs:+0:11: +2:2
+          StorageDead(_1);                 // scope 0 at $DIR/inline_generator.rs:+2:1: +2:2
+          return;                          // scope 0 at $DIR/inline_generator.rs:+2:2: +2:2
       }
   
 -     bb4 (cleanup): {
 +     bb2 (cleanup): {
-          resume;                          // scope 0 at $DIR/inline-generator.rs:+0:1: +2:2
+          resume;                          // scope 0 at $DIR/inline_generator.rs:+0:1: +2:2
 +     }
 + 
 +     bb3: {
-+         _11 = move _7;                   // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         StorageLive(_8);                 // scope 6 at $DIR/inline-generator.rs:15:17: 15:39
-+         StorageLive(_9);                 // scope 6 at $DIR/inline-generator.rs:15:20: 15:21
-+         _9 = _11;                        // scope 6 at $DIR/inline-generator.rs:15:20: 15:21
-+         switchInt(move _9) -> [false: bb5, otherwise: bb4]; // scope 6 at $DIR/inline-generator.rs:15:20: 15:21
++         _11 = move _7;                   // scope 6 at $DIR/inline_generator.rs:15:5: 15:41
++         StorageLive(_8);                 // scope 6 at $DIR/inline_generator.rs:15:17: 15:39
++         StorageLive(_9);                 // scope 6 at $DIR/inline_generator.rs:15:20: 15:21
++         _9 = _11;                        // scope 6 at $DIR/inline_generator.rs:15:20: 15:21
++         switchInt(move _9) -> [false: bb5, otherwise: bb4]; // scope 6 at $DIR/inline_generator.rs:15:20: 15:21
 +     }
 + 
 +     bb4: {
-+         _8 = const 7_i32;                // scope 6 at $DIR/inline-generator.rs:15:24: 15:25
-+         goto -> bb6;                     // scope 6 at $DIR/inline-generator.rs:15:17: 15:39
++         _8 = const 7_i32;                // scope 6 at $DIR/inline_generator.rs:15:24: 15:25
++         goto -> bb6;                     // scope 6 at $DIR/inline_generator.rs:15:17: 15:39
 +     }
 + 
 +     bb5: {
-+         _8 = const 13_i32;               // scope 6 at $DIR/inline-generator.rs:15:35: 15:37
-+         goto -> bb6;                     // scope 6 at $DIR/inline-generator.rs:15:17: 15:39
++         _8 = const 13_i32;               // scope 6 at $DIR/inline_generator.rs:15:35: 15:37
++         goto -> bb6;                     // scope 6 at $DIR/inline_generator.rs:15:17: 15:39
 +     }
 + 
 +     bb6: {
-+         StorageDead(_9);                 // scope 6 at $DIR/inline-generator.rs:15:38: 15:39
-+         Deinit(_1);                      // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
-+         ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
-+         discriminant(_1) = 0;            // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
-+         _14 = deref_copy (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
-+         discriminant((*_14)) = 3;        // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
-+         goto -> bb1;                     // scope 0 at $DIR/inline-generator.rs:15:11: 15:39
++         StorageDead(_9);                 // scope 6 at $DIR/inline_generator.rs:15:38: 15:39
++         Deinit(_1);                      // scope 6 at $DIR/inline_generator.rs:15:11: 15:39
++         ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline_generator.rs:15:11: 15:39
++         discriminant(_1) = 0;            // scope 6 at $DIR/inline_generator.rs:15:11: 15:39
++         _14 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:11: 15:39
++         discriminant((*_14)) = 3;        // scope 6 at $DIR/inline_generator.rs:15:11: 15:39
++         goto -> bb1;                     // scope 0 at $DIR/inline_generator.rs:15:11: 15:39
 +     }
 + 
 +     bb7: {
-+         StorageLive(_8);                 // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         _10 = move _7;                   // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+         StorageDead(_8);                 // scope 6 at $DIR/inline-generator.rs:15:38: 15:39
-+         Deinit(_1);                      // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+         ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+         discriminant(_1) = 1;            // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+         _15 = deref_copy (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+         discriminant((*_15)) = 1;        // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+         goto -> bb1;                     // scope 0 at $DIR/inline-generator.rs:15:41: 15:41
++         StorageLive(_8);                 // scope 6 at $DIR/inline_generator.rs:15:5: 15:41
++         _10 = move _7;                   // scope 6 at $DIR/inline_generator.rs:15:5: 15:41
++         StorageDead(_8);                 // scope 6 at $DIR/inline_generator.rs:15:38: 15:39
++         Deinit(_1);                      // scope 6 at $DIR/inline_generator.rs:15:41: 15:41
++         ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline_generator.rs:15:41: 15:41
++         discriminant(_1) = 1;            // scope 6 at $DIR/inline_generator.rs:15:41: 15:41
++         _15 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:41: 15:41
++         discriminant((*_15)) = 1;        // scope 6 at $DIR/inline_generator.rs:15:41: 15:41
++         goto -> bb1;                     // scope 0 at $DIR/inline_generator.rs:15:41: 15:41
 +     }
 + 
 +     bb8: {
-+         assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++         assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41
 +     }
 + 
 +     bb9: {
-+         unreachable;                     // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++         unreachable;                     // scope 6 at $DIR/inline_generator.rs:15:5: 15:41
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline-generator.rs b/src/test/mir-opt/inline/inline_generator.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-generator.rs
rename to src/test/mir-opt/inline/inline_generator.rs
diff --git a/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff b/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff
index 076509df349..e421428dcdf 100644
--- a/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff
+++ b/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff
@@ -2,43 +2,43 @@
 + // MIR for `default` after Inline
   
   fn default() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-instruction-set.rs:+0:18: +0:18
-      let _1: ();                          // in scope 0 at $DIR/inline-instruction-set.rs:+1:5: +1:26
-      let _2: ();                          // in scope 0 at $DIR/inline-instruction-set.rs:+2:5: +2:26
-      let _3: ();                          // in scope 0 at $DIR/inline-instruction-set.rs:+3:5: +3:30
-+     scope 1 (inlined instruction_set_default) { // at $DIR/inline-instruction-set.rs:53:5: 53:30
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_instruction_set.rs:+0:18: +0:18
+      let _1: ();                          // in scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26
+      let _2: ();                          // in scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26
+      let _3: ();                          // in scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30
++     scope 1 (inlined instruction_set_default) { // at $DIR/inline_instruction_set.rs:53:5: 53:30
 +     }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-instruction-set.rs:+1:5: +1:26
-          _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline-instruction-set.rs:+1:5: +1:26
+          StorageLive(_1);                 // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26
+          _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26
                                            // mir::Constant
-                                           // + span: $DIR/inline-instruction-set.rs:51:5: 51:24
+                                           // + span: $DIR/inline_instruction_set.rs:51:5: 51:24
                                            // + literal: Const { ty: fn() {instruction_set_a32}, val: Value() }
       }
   
       bb1: {
-          StorageDead(_1);                 // scope 0 at $DIR/inline-instruction-set.rs:+1:26: +1:27
-          StorageLive(_2);                 // scope 0 at $DIR/inline-instruction-set.rs:+2:5: +2:26
-          _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline-instruction-set.rs:+2:5: +2:26
+          StorageDead(_1);                 // scope 0 at $DIR/inline_instruction_set.rs:+1:26: +1:27
+          StorageLive(_2);                 // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26
+          _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26
                                            // mir::Constant
-                                           // + span: $DIR/inline-instruction-set.rs:52:5: 52:24
+                                           // + span: $DIR/inline_instruction_set.rs:52:5: 52:24
                                            // + literal: Const { ty: fn() {instruction_set_t32}, val: Value() }
       }
   
       bb2: {
-          StorageDead(_2);                 // scope 0 at $DIR/inline-instruction-set.rs:+2:26: +2:27
-          StorageLive(_3);                 // scope 0 at $DIR/inline-instruction-set.rs:+3:5: +3:30
--         _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline-instruction-set.rs:+3:5: +3:30
+          StorageDead(_2);                 // scope 0 at $DIR/inline_instruction_set.rs:+2:26: +2:27
+          StorageLive(_3);                 // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30
+-         _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30
 -                                          // mir::Constant
--                                          // + span: $DIR/inline-instruction-set.rs:53:5: 53:28
+-                                          // + span: $DIR/inline_instruction_set.rs:53:5: 53:28
 -                                          // + literal: Const { ty: fn() {instruction_set_default}, val: Value() }
 -     }
 - 
 -     bb3: {
-          StorageDead(_3);                 // scope 0 at $DIR/inline-instruction-set.rs:+3:30: +3:31
-          _0 = const ();                   // scope 0 at $DIR/inline-instruction-set.rs:+0:18: +4:2
-          return;                          // scope 0 at $DIR/inline-instruction-set.rs:+4:2: +4:2
+          StorageDead(_3);                 // scope 0 at $DIR/inline_instruction_set.rs:+3:30: +3:31
+          _0 = const ();                   // scope 0 at $DIR/inline_instruction_set.rs:+0:18: +4:2
+          return;                          // scope 0 at $DIR/inline_instruction_set.rs:+4:2: +4:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline-instruction-set.rs b/src/test/mir-opt/inline/inline_instruction_set.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-instruction-set.rs
rename to src/test/mir-opt/inline/inline_instruction_set.rs
diff --git a/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff b/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff
index b275d08e05f..1ea2b87e53a 100644
--- a/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff
+++ b/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff
@@ -2,45 +2,45 @@
 + // MIR for `t32` after Inline
   
   fn t32() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-instruction-set.rs:+0:14: +0:14
-      let _1: ();                          // in scope 0 at $DIR/inline-instruction-set.rs:+1:5: +1:26
-      let _2: ();                          // in scope 0 at $DIR/inline-instruction-set.rs:+2:5: +2:26
-      let _3: ();                          // in scope 0 at $DIR/inline-instruction-set.rs:+5:5: +5:30
-+     scope 1 (inlined instruction_set_t32) { // at $DIR/inline-instruction-set.rs:43:5: 43:26
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_instruction_set.rs:+0:14: +0:14
+      let _1: ();                          // in scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26
+      let _2: ();                          // in scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26
+      let _3: ();                          // in scope 0 at $DIR/inline_instruction_set.rs:+5:5: +5:30
++     scope 1 (inlined instruction_set_t32) { // at $DIR/inline_instruction_set.rs:43:5: 43:26
 +     }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-instruction-set.rs:+1:5: +1:26
-          _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline-instruction-set.rs:+1:5: +1:26
+          StorageLive(_1);                 // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26
+          _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26
                                            // mir::Constant
-                                           // + span: $DIR/inline-instruction-set.rs:42:5: 42:24
+                                           // + span: $DIR/inline_instruction_set.rs:42:5: 42:24
                                            // + literal: Const { ty: fn() {instruction_set_a32}, val: Value() }
       }
   
       bb1: {
-          StorageDead(_1);                 // scope 0 at $DIR/inline-instruction-set.rs:+1:26: +1:27
-          StorageLive(_2);                 // scope 0 at $DIR/inline-instruction-set.rs:+2:5: +2:26
--         _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline-instruction-set.rs:+2:5: +2:26
+          StorageDead(_1);                 // scope 0 at $DIR/inline_instruction_set.rs:+1:26: +1:27
+          StorageLive(_2);                 // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26
+-         _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26
 -                                          // mir::Constant
--                                          // + span: $DIR/inline-instruction-set.rs:43:5: 43:24
+-                                          // + span: $DIR/inline_instruction_set.rs:43:5: 43:24
 -                                          // + literal: Const { ty: fn() {instruction_set_t32}, val: Value() }
 -     }
 - 
 -     bb2: {
-          StorageDead(_2);                 // scope 0 at $DIR/inline-instruction-set.rs:+2:26: +2:27
-          StorageLive(_3);                 // scope 0 at $DIR/inline-instruction-set.rs:+5:5: +5:30
--         _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline-instruction-set.rs:+5:5: +5:30
-+         _3 = instruction_set_default() -> bb2; // scope 0 at $DIR/inline-instruction-set.rs:+5:5: +5:30
+          StorageDead(_2);                 // scope 0 at $DIR/inline_instruction_set.rs:+2:26: +2:27
+          StorageLive(_3);                 // scope 0 at $DIR/inline_instruction_set.rs:+5:5: +5:30
+-         _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline_instruction_set.rs:+5:5: +5:30
++         _3 = instruction_set_default() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+5:5: +5:30
                                            // mir::Constant
-                                           // + span: $DIR/inline-instruction-set.rs:46:5: 46:28
+                                           // + span: $DIR/inline_instruction_set.rs:46:5: 46:28
                                            // + literal: Const { ty: fn() {instruction_set_default}, val: Value() }
       }
   
 -     bb3: {
 +     bb2: {
-          StorageDead(_3);                 // scope 0 at $DIR/inline-instruction-set.rs:+5:30: +5:31
-          _0 = const ();                   // scope 0 at $DIR/inline-instruction-set.rs:+0:14: +6:2
-          return;                          // scope 0 at $DIR/inline-instruction-set.rs:+6:2: +6:2
+          StorageDead(_3);                 // scope 0 at $DIR/inline_instruction_set.rs:+5:30: +5:31
+          _0 = const ();                   // scope 0 at $DIR/inline_instruction_set.rs:+0:14: +6:2
+          return;                          // scope 0 at $DIR/inline_instruction_set.rs:+6:2: +6:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.diff b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.diff
index 7e017373b44..2a4dc9e3e80 100644
--- a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.diff
+++ b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.diff
@@ -2,45 +2,45 @@
 + // MIR for `main` after Inline
   
   fn main() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-into-box-place.rs:+0:11: +0:11
-      let _1: std::boxed::Box>; // in scope 0 at $DIR/inline-into-box-place.rs:+1:9: +1:11
-      let mut _2: usize;                   // in scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43
-      let mut _3: usize;                   // in scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43
-      let mut _4: *mut u8;                 // in scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43
-      let mut _5: std::boxed::Box>; // in scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43
-      let mut _6: ();                      // in scope 0 at $DIR/inline-into-box-place.rs:+1:42: +1:43
-      let mut _7: *const std::vec::Vec; // in scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43
-+     let mut _8: &mut std::vec::Vec; // in scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_into_box_place.rs:+0:11: +0:11
+      let _1: std::boxed::Box>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:9: +1:11
+      let mut _2: usize;                   // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
+      let mut _3: usize;                   // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
+      let mut _4: *mut u8;                 // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
+      let mut _5: std::boxed::Box>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
+      let mut _6: ();                      // in scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43
+      let mut _7: *const std::vec::Vec; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
++     let mut _8: &mut std::vec::Vec; // in scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
       scope 1 {
-          debug _x => _1;                  // in scope 1 at $DIR/inline-into-box-place.rs:+1:9: +1:11
+          debug _x => _1;                  // in scope 1 at $DIR/inline_into_box_place.rs:+1:9: +1:11
       }
       scope 2 {
       }
-+     scope 3 (inlined Vec::::new) {  // at $DIR/inline-into-box-place.rs:8:33: 8:43
++     scope 3 (inlined Vec::::new) {  // at $DIR/inline_into_box_place.rs:8:33: 8:43
 +         let mut _9: alloc::raw_vec::RawVec; // in scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
 +     }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-into-box-place.rs:+1:9: +1:11
-          _2 = SizeOf(std::vec::Vec); // scope 2 at $DIR/inline-into-box-place.rs:+1:29: +1:43
-          _3 = AlignOf(std::vec::Vec); // scope 2 at $DIR/inline-into-box-place.rs:+1:29: +1:43
-          _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/inline-into-box-place.rs:+1:29: +1:43
+          StorageLive(_1);                 // scope 0 at $DIR/inline_into_box_place.rs:+1:9: +1:11
+          _2 = SizeOf(std::vec::Vec); // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43
+          _3 = AlignOf(std::vec::Vec); // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43
+          _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43
                                            // mir::Constant
-                                           // + span: $DIR/inline-into-box-place.rs:8:29: 8:43
+                                           // + span: $DIR/inline_into_box_place.rs:8:29: 8:43
                                            // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value() }
       }
   
       bb1: {
-          StorageLive(_5);                 // scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43
-          _5 = ShallowInitBox(move _4, std::vec::Vec); // scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43
-          _7 = (((_5.0: std::ptr::Unique>).0: std::ptr::NonNull>).0: *const std::vec::Vec); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43
--         (*_7) = Vec::::new() -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43
-+         StorageLive(_8);                 // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43
-+         _8 = &mut (*_7);                 // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43
+          StorageLive(_5);                 // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
+          _5 = ShallowInitBox(move _4, std::vec::Vec); // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
+          _7 = (((_5.0: std::ptr::Unique>).0: std::ptr::NonNull>).0: *const std::vec::Vec); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
+-         (*_7) = Vec::::new() -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
++         StorageLive(_8);                 // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
++         _8 = &mut (*_7);                 // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
 +         StorageLive(_9);                 // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
 +         _9 = const _;                    // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
                                            // mir::Constant
--                                          // + span: $DIR/inline-into-box-place.rs:8:33: 8:41
+-                                          // + span: $DIR/inline_into_box_place.rs:8:33: 8:41
 -                                          // + user_ty: UserType(1)
 -                                          // + literal: Const { ty: fn() -> Vec {Vec::::new}, val: Value() }
 -     }
@@ -53,29 +53,29 @@
 +         ((*_8).0: alloc::raw_vec::RawVec) = move _9; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
 +         ((*_8).1: usize) = const 0_usize; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
 +         StorageDead(_9);                 // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
-+         StorageDead(_8);                 // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43
-          _1 = move _5;                    // scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43
-          StorageDead(_5);                 // scope 0 at $DIR/inline-into-box-place.rs:+1:42: +1:43
-          _0 = const ();                   // scope 0 at $DIR/inline-into-box-place.rs:+0:11: +2:2
--         drop(_1) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline-into-box-place.rs:+2:1: +2:2
-+         drop(_1) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/inline-into-box-place.rs:+2:1: +2:2
++         StorageDead(_8);                 // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43
+          _1 = move _5;                    // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43
+          StorageDead(_5);                 // scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43
+          _0 = const ();                   // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2
+-         drop(_1) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2
++         drop(_1) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2
       }
   
 -     bb3: {
 +     bb2: {
-          StorageDead(_1);                 // scope 0 at $DIR/inline-into-box-place.rs:+2:1: +2:2
-          return;                          // scope 0 at $DIR/inline-into-box-place.rs:+2:2: +2:2
+          StorageDead(_1);                 // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2
+          return;                          // scope 0 at $DIR/inline_into_box_place.rs:+2:2: +2:2
       }
   
 -     bb4 (cleanup): {
 +     bb3 (cleanup): {
-          resume;                          // scope 0 at $DIR/inline-into-box-place.rs:+0:1: +2:2
+          resume;                          // scope 0 at $DIR/inline_into_box_place.rs:+0:1: +2:2
 -     }
 - 
 -     bb5 (cleanup): {
--         _6 = alloc::alloc::box_free::, std::alloc::Global>(move (_5.0: std::ptr::Unique>), move (_5.1: std::alloc::Global)) -> bb4; // scope 0 at $DIR/inline-into-box-place.rs:+1:42: +1:43
+-         _6 = alloc::alloc::box_free::, std::alloc::Global>(move (_5.0: std::ptr::Unique>), move (_5.1: std::alloc::Global)) -> bb4; // scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43
 -                                          // mir::Constant
--                                          // + span: $DIR/inline-into-box-place.rs:8:42: 8:43
+-                                          // + span: $DIR/inline_into_box_place.rs:8:42: 8:43
 -                                          // + literal: Const { ty: unsafe fn(Unique>, std::alloc::Global) {alloc::alloc::box_free::, std::alloc::Global>}, val: Value() }
       }
   }
diff --git a/src/test/mir-opt/inline/inline-into-box-place.rs b/src/test/mir-opt/inline/inline_into_box_place.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-into-box-place.rs
rename to src/test/mir-opt/inline/inline_into_box_place.rs
diff --git a/src/test/mir-opt/inline/inline_options.main.Inline.after.mir b/src/test/mir-opt/inline/inline_options.main.Inline.after.mir
index 361b0271526..1c590be945c 100644
--- a/src/test/mir-opt/inline/inline_options.main.Inline.after.mir
+++ b/src/test/mir-opt/inline/inline_options.main.Inline.after.mir
@@ -1,55 +1,55 @@
 // MIR for `main` after Inline
 
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/inline-options.rs:+0:11: +0:11
-    let _1: ();                          // in scope 0 at $DIR/inline-options.rs:+1:5: +1:18
-    let _2: ();                          // in scope 0 at $DIR/inline-options.rs:+2:5: +2:21
-    scope 1 (inlined inlined::) {   // at $DIR/inline-options.rs:10:5: 10:21
-        let _3: ();                      // in scope 1 at $DIR/inline-options.rs:16:23: 16:26
-        let _4: ();                      // in scope 1 at $DIR/inline-options.rs:16:28: 16:31
-        let _5: ();                      // in scope 1 at $DIR/inline-options.rs:16:33: 16:36
+    let mut _0: ();                      // return place in scope 0 at $DIR/inline_options.rs:+0:11: +0:11
+    let _1: ();                          // in scope 0 at $DIR/inline_options.rs:+1:5: +1:18
+    let _2: ();                          // in scope 0 at $DIR/inline_options.rs:+2:5: +2:21
+    scope 1 (inlined inlined::) {   // at $DIR/inline_options.rs:10:5: 10:21
+        let _3: ();                      // in scope 1 at $DIR/inline_options.rs:16:23: 16:26
+        let _4: ();                      // in scope 1 at $DIR/inline_options.rs:16:28: 16:31
+        let _5: ();                      // in scope 1 at $DIR/inline_options.rs:16:33: 16:36
     }
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/inline-options.rs:+1:5: +1:18
-        _1 = not_inlined() -> bb1;       // scope 0 at $DIR/inline-options.rs:+1:5: +1:18
+        StorageLive(_1);                 // scope 0 at $DIR/inline_options.rs:+1:5: +1:18
+        _1 = not_inlined() -> bb1;       // scope 0 at $DIR/inline_options.rs:+1:5: +1:18
                                          // mir::Constant
-                                         // + span: $DIR/inline-options.rs:9:5: 9:16
+                                         // + span: $DIR/inline_options.rs:9:5: 9:16
                                          // + literal: Const { ty: fn() {not_inlined}, val: Value() }
     }
 
     bb1: {
-        StorageDead(_1);                 // scope 0 at $DIR/inline-options.rs:+1:18: +1:19
-        StorageLive(_2);                 // scope 0 at $DIR/inline-options.rs:+2:5: +2:21
-        StorageLive(_3);                 // scope 1 at $DIR/inline-options.rs:16:23: 16:26
-        _3 = g() -> bb2;                 // scope 1 at $DIR/inline-options.rs:16:23: 16:26
+        StorageDead(_1);                 // scope 0 at $DIR/inline_options.rs:+1:18: +1:19
+        StorageLive(_2);                 // scope 0 at $DIR/inline_options.rs:+2:5: +2:21
+        StorageLive(_3);                 // scope 1 at $DIR/inline_options.rs:16:23: 16:26
+        _3 = g() -> bb2;                 // scope 1 at $DIR/inline_options.rs:16:23: 16:26
                                          // mir::Constant
-                                         // + span: $DIR/inline-options.rs:16:23: 16:24
+                                         // + span: $DIR/inline_options.rs:16:23: 16:24
                                          // + literal: Const { ty: fn() {g}, val: Value() }
     }
 
     bb2: {
-        StorageDead(_3);                 // scope 1 at $DIR/inline-options.rs:16:26: 16:27
-        StorageLive(_4);                 // scope 1 at $DIR/inline-options.rs:16:28: 16:31
-        _4 = g() -> bb3;                 // scope 1 at $DIR/inline-options.rs:16:28: 16:31
+        StorageDead(_3);                 // scope 1 at $DIR/inline_options.rs:16:26: 16:27
+        StorageLive(_4);                 // scope 1 at $DIR/inline_options.rs:16:28: 16:31
+        _4 = g() -> bb3;                 // scope 1 at $DIR/inline_options.rs:16:28: 16:31
                                          // mir::Constant
-                                         // + span: $DIR/inline-options.rs:16:28: 16:29
+                                         // + span: $DIR/inline_options.rs:16:28: 16:29
                                          // + literal: Const { ty: fn() {g}, val: Value() }
     }
 
     bb3: {
-        StorageDead(_4);                 // scope 1 at $DIR/inline-options.rs:16:31: 16:32
-        StorageLive(_5);                 // scope 1 at $DIR/inline-options.rs:16:33: 16:36
-        _5 = g() -> bb4;                 // scope 1 at $DIR/inline-options.rs:16:33: 16:36
+        StorageDead(_4);                 // scope 1 at $DIR/inline_options.rs:16:31: 16:32
+        StorageLive(_5);                 // scope 1 at $DIR/inline_options.rs:16:33: 16:36
+        _5 = g() -> bb4;                 // scope 1 at $DIR/inline_options.rs:16:33: 16:36
                                          // mir::Constant
-                                         // + span: $DIR/inline-options.rs:16:33: 16:34
+                                         // + span: $DIR/inline_options.rs:16:33: 16:34
                                          // + literal: Const { ty: fn() {g}, val: Value() }
     }
 
     bb4: {
-        StorageDead(_5);                 // scope 1 at $DIR/inline-options.rs:16:36: 16:37
-        StorageDead(_2);                 // scope 0 at $DIR/inline-options.rs:+2:21: +2:22
-        _0 = const ();                   // scope 0 at $DIR/inline-options.rs:+0:11: +3:2
-        return;                          // scope 0 at $DIR/inline-options.rs:+3:2: +3:2
+        StorageDead(_5);                 // scope 1 at $DIR/inline_options.rs:16:36: 16:37
+        StorageDead(_2);                 // scope 0 at $DIR/inline_options.rs:+2:21: +2:22
+        _0 = const ();                   // scope 0 at $DIR/inline_options.rs:+0:11: +3:2
+        return;                          // scope 0 at $DIR/inline_options.rs:+3:2: +3:2
     }
 }
diff --git a/src/test/mir-opt/inline/inline-options.rs b/src/test/mir-opt/inline/inline_options.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-options.rs
rename to src/test/mir-opt/inline/inline_options.rs
diff --git a/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir
index 169e7f5c5d9..75af20d482d 100644
--- a/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir
+++ b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir
@@ -1,72 +1,72 @@
 // MIR for `bar` after Inline
 
 fn bar() -> bool {
-    let mut _0: bool;                    // return place in scope 0 at $DIR/inline-retag.rs:+0:13: +0:17
-    let _1: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:+1:9: +1:10
-    let mut _2: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:+2:5: +2:6
-    let mut _3: &i32;                    // in scope 0 at $DIR/inline-retag.rs:+2:7: +2:9
-    let _4: &i32;                        // in scope 0 at $DIR/inline-retag.rs:+2:7: +2:9
-    let _5: i32;                         // in scope 0 at $DIR/inline-retag.rs:+2:8: +2:9
-    let mut _6: &i32;                    // in scope 0 at $DIR/inline-retag.rs:+2:11: +2:14
-    let _7: &i32;                        // in scope 0 at $DIR/inline-retag.rs:+2:11: +2:14
-    let _8: i32;                         // in scope 0 at $DIR/inline-retag.rs:+2:12: +2:14
+    let mut _0: bool;                    // return place in scope 0 at $DIR/inline_retag.rs:+0:13: +0:17
+    let _1: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; // in scope 0 at $DIR/inline_retag.rs:+1:9: +1:10
+    let mut _2: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; // in scope 0 at $DIR/inline_retag.rs:+2:5: +2:6
+    let mut _3: &i32;                    // in scope 0 at $DIR/inline_retag.rs:+2:7: +2:9
+    let _4: &i32;                        // in scope 0 at $DIR/inline_retag.rs:+2:7: +2:9
+    let _5: i32;                         // in scope 0 at $DIR/inline_retag.rs:+2:8: +2:9
+    let mut _6: &i32;                    // in scope 0 at $DIR/inline_retag.rs:+2:11: +2:14
+    let _7: &i32;                        // in scope 0 at $DIR/inline_retag.rs:+2:11: +2:14
+    let _8: i32;                         // in scope 0 at $DIR/inline_retag.rs:+2:12: +2:14
     scope 1 {
-        debug f => _1;                   // in scope 1 at $DIR/inline-retag.rs:+1:9: +1:10
-        let mut _9: &i32;                // in scope 1 at $DIR/inline-retag.rs:+2:11: +2:14
-        let mut _10: &i32;               // in scope 1 at $DIR/inline-retag.rs:+2:7: +2:9
-        scope 2 (inlined foo) {          // at $DIR/inline-retag.rs:12:5: 12:15
-            debug x => _3;               // in scope 2 at $DIR/inline-retag.rs:16:8: 16:9
-            debug y => _6;               // in scope 2 at $DIR/inline-retag.rs:16:17: 16:18
-            let mut _11: i32;            // in scope 2 at $DIR/inline-retag.rs:17:5: 17:7
-            let mut _12: i32;            // in scope 2 at $DIR/inline-retag.rs:17:11: 17:13
+        debug f => _1;                   // in scope 1 at $DIR/inline_retag.rs:+1:9: +1:10
+        let mut _9: &i32;                // in scope 1 at $DIR/inline_retag.rs:+2:11: +2:14
+        let mut _10: &i32;               // in scope 1 at $DIR/inline_retag.rs:+2:7: +2:9
+        scope 2 (inlined foo) {          // at $DIR/inline_retag.rs:12:5: 12:15
+            debug x => _3;               // in scope 2 at $DIR/inline_retag.rs:16:8: 16:9
+            debug y => _6;               // in scope 2 at $DIR/inline_retag.rs:16:17: 16:18
+            let mut _11: i32;            // in scope 2 at $DIR/inline_retag.rs:17:5: 17:7
+            let mut _12: i32;            // in scope 2 at $DIR/inline_retag.rs:17:11: 17:13
         }
     }
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/inline-retag.rs:+1:9: +1:10
-        _1 = foo;                        // scope 0 at $DIR/inline-retag.rs:+1:13: +1:16
+        StorageLive(_1);                 // scope 0 at $DIR/inline_retag.rs:+1:9: +1:10
+        _1 = foo;                        // scope 0 at $DIR/inline_retag.rs:+1:13: +1:16
                                          // mir::Constant
-                                         // + span: $DIR/inline-retag.rs:11:13: 11:16
+                                         // + span: $DIR/inline_retag.rs:11:13: 11:16
                                          // + literal: Const { ty: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}, val: Value() }
-        StorageLive(_2);                 // scope 1 at $DIR/inline-retag.rs:+2:5: +2:6
-        _2 = _1;                         // scope 1 at $DIR/inline-retag.rs:+2:5: +2:6
-        StorageLive(_3);                 // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9
-        StorageLive(_4);                 // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9
-        _10 = const _;                   // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9
+        StorageLive(_2);                 // scope 1 at $DIR/inline_retag.rs:+2:5: +2:6
+        _2 = _1;                         // scope 1 at $DIR/inline_retag.rs:+2:5: +2:6
+        StorageLive(_3);                 // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9
+        StorageLive(_4);                 // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9
+        _10 = const _;                   // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9
                                          // mir::Constant
-                                         // + span: $DIR/inline-retag.rs:12:7: 12:9
+                                         // + span: $DIR/inline_retag.rs:12:7: 12:9
                                          // + literal: Const { ty: &i32, val: Unevaluated(bar, [], Some(promoted[1])) }
-        Retag(_10);                      // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9
-        _4 = &(*_10);                    // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9
-        Retag(_4);                       // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9
-        _3 = &(*_4);                     // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9
-        Retag(_3);                       // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9
-        StorageLive(_6);                 // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14
-        StorageLive(_7);                 // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14
-        _9 = const _;                    // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14
+        Retag(_10);                      // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9
+        _4 = &(*_10);                    // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9
+        Retag(_4);                       // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9
+        _3 = &(*_4);                     // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9
+        Retag(_3);                       // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9
+        StorageLive(_6);                 // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14
+        StorageLive(_7);                 // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14
+        _9 = const _;                    // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14
                                          // mir::Constant
-                                         // + span: $DIR/inline-retag.rs:12:11: 12:14
+                                         // + span: $DIR/inline_retag.rs:12:11: 12:14
                                          // + literal: Const { ty: &i32, val: Unevaluated(bar, [], Some(promoted[0])) }
-        Retag(_9);                       // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14
-        _7 = &(*_9);                     // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14
-        Retag(_7);                       // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14
-        _6 = &(*_7);                     // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14
-        Retag(_6);                       // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14
-        Retag(_3);                       // scope 2 at $DIR/inline-retag.rs:16:8: 16:9
-        Retag(_6);                       // scope 2 at $DIR/inline-retag.rs:16:17: 16:18
-        StorageLive(_11);                // scope 2 at $DIR/inline-retag.rs:17:5: 17:7
-        _11 = (*_3);                     // scope 2 at $DIR/inline-retag.rs:17:5: 17:7
-        StorageLive(_12);                // scope 2 at $DIR/inline-retag.rs:17:11: 17:13
-        _12 = (*_6);                     // scope 2 at $DIR/inline-retag.rs:17:11: 17:13
-        _0 = Eq(move _11, move _12);     // scope 2 at $DIR/inline-retag.rs:17:5: 17:13
-        StorageDead(_12);                // scope 2 at $DIR/inline-retag.rs:17:12: 17:13
-        StorageDead(_11);                // scope 2 at $DIR/inline-retag.rs:17:12: 17:13
-        StorageDead(_6);                 // scope 1 at $DIR/inline-retag.rs:+2:14: +2:15
-        StorageDead(_3);                 // scope 1 at $DIR/inline-retag.rs:+2:14: +2:15
-        StorageDead(_2);                 // scope 1 at $DIR/inline-retag.rs:+2:14: +2:15
-        StorageDead(_1);                 // scope 0 at $DIR/inline-retag.rs:+3:1: +3:2
-        StorageDead(_7);                 // scope 0 at $DIR/inline-retag.rs:+3:1: +3:2
-        StorageDead(_4);                 // scope 0 at $DIR/inline-retag.rs:+3:1: +3:2
-        return;                          // scope 0 at $DIR/inline-retag.rs:+3:2: +3:2
+        Retag(_9);                       // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14
+        _7 = &(*_9);                     // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14
+        Retag(_7);                       // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14
+        _6 = &(*_7);                     // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14
+        Retag(_6);                       // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14
+        Retag(_3);                       // scope 2 at $DIR/inline_retag.rs:16:8: 16:9
+        Retag(_6);                       // scope 2 at $DIR/inline_retag.rs:16:17: 16:18
+        StorageLive(_11);                // scope 2 at $DIR/inline_retag.rs:17:5: 17:7
+        _11 = (*_3);                     // scope 2 at $DIR/inline_retag.rs:17:5: 17:7
+        StorageLive(_12);                // scope 2 at $DIR/inline_retag.rs:17:11: 17:13
+        _12 = (*_6);                     // scope 2 at $DIR/inline_retag.rs:17:11: 17:13
+        _0 = Eq(move _11, move _12);     // scope 2 at $DIR/inline_retag.rs:17:5: 17:13
+        StorageDead(_12);                // scope 2 at $DIR/inline_retag.rs:17:12: 17:13
+        StorageDead(_11);                // scope 2 at $DIR/inline_retag.rs:17:12: 17:13
+        StorageDead(_6);                 // scope 1 at $DIR/inline_retag.rs:+2:14: +2:15
+        StorageDead(_3);                 // scope 1 at $DIR/inline_retag.rs:+2:14: +2:15
+        StorageDead(_2);                 // scope 1 at $DIR/inline_retag.rs:+2:14: +2:15
+        StorageDead(_1);                 // scope 0 at $DIR/inline_retag.rs:+3:1: +3:2
+        StorageDead(_7);                 // scope 0 at $DIR/inline_retag.rs:+3:1: +3:2
+        StorageDead(_4);                 // scope 0 at $DIR/inline_retag.rs:+3:1: +3:2
+        return;                          // scope 0 at $DIR/inline_retag.rs:+3:2: +3:2
     }
 }
diff --git a/src/test/mir-opt/inline/inline-retag.rs b/src/test/mir-opt/inline/inline_retag.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-retag.rs
rename to src/test/mir-opt/inline/inline_retag.rs
diff --git a/src/test/mir-opt/inline/inline_shims.clone.Inline.diff b/src/test/mir-opt/inline/inline_shims.clone.Inline.diff
index d691e90b7da..969573ba325 100644
--- a/src/test/mir-opt/inline/inline_shims.clone.Inline.diff
+++ b/src/test/mir-opt/inline/inline_shims.clone.Inline.diff
@@ -2,25 +2,25 @@
 + // MIR for `clone` after Inline
   
   fn clone(_1: fn(A, B)) -> fn(A, B) {
-      debug f => _1;                       // in scope 0 at $DIR/inline-shims.rs:+0:20: +0:21
-      let mut _0: fn(A, B);                // return place in scope 0 at $DIR/inline-shims.rs:+0:36: +0:44
-      let mut _2: &fn(A, B);               // in scope 0 at $DIR/inline-shims.rs:+1:5: +1:14
-+     scope 1 (inlined ::clone - shim(fn(A, B))) { // at $DIR/inline-shims.rs:6:5: 6:14
+      debug f => _1;                       // in scope 0 at $DIR/inline_shims.rs:+0:20: +0:21
+      let mut _0: fn(A, B);                // return place in scope 0 at $DIR/inline_shims.rs:+0:36: +0:44
+      let mut _2: &fn(A, B);               // in scope 0 at $DIR/inline_shims.rs:+1:5: +1:14
++     scope 1 (inlined ::clone - shim(fn(A, B))) { // at $DIR/inline_shims.rs:6:5: 6:14
 +     }
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/inline-shims.rs:+1:5: +1:14
-          _2 = &_1;                        // scope 0 at $DIR/inline-shims.rs:+1:5: +1:14
--         _0 = ::clone(move _2) -> bb1; // scope 0 at $DIR/inline-shims.rs:+1:5: +1:14
+          StorageLive(_2);                 // scope 0 at $DIR/inline_shims.rs:+1:5: +1:14
+          _2 = &_1;                        // scope 0 at $DIR/inline_shims.rs:+1:5: +1:14
+-         _0 = ::clone(move _2) -> bb1; // scope 0 at $DIR/inline_shims.rs:+1:5: +1:14
 -                                          // mir::Constant
--                                          // + span: $DIR/inline-shims.rs:6:7: 6:12
+-                                          // + span: $DIR/inline_shims.rs:6:7: 6:12
 -                                          // + literal: Const { ty: for<'a> fn(&'a fn(A, B)) -> fn(A, B) {::clone}, val: Value() }
 -     }
 - 
 -     bb1: {
 +         _0 = (*_2);                      // scope 1 at $SRC_DIR/core/src/clone.rs:LL:COL
-          StorageDead(_2);                 // scope 0 at $DIR/inline-shims.rs:+1:13: +1:14
-          return;                          // scope 0 at $DIR/inline-shims.rs:+2:2: +2:2
+          StorageDead(_2);                 // scope 0 at $DIR/inline_shims.rs:+1:13: +1:14
+          return;                          // scope 0 at $DIR/inline_shims.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline_shims.drop.Inline.diff b/src/test/mir-opt/inline/inline_shims.drop.Inline.diff
index f7b1cde80bd..7a54beca233 100644
--- a/src/test/mir-opt/inline/inline_shims.drop.Inline.diff
+++ b/src/test/mir-opt/inline/inline_shims.drop.Inline.diff
@@ -2,51 +2,51 @@
 + // MIR for `drop` after Inline
   
   fn drop(_1: *mut Vec, _2: *mut Option) -> () {
-      debug a => _1;                       // in scope 0 at $DIR/inline-shims.rs:+0:19: +0:20
-      debug b => _2;                       // in scope 0 at $DIR/inline-shims.rs:+0:35: +0:36
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-shims.rs:+0:54: +0:54
-      let _3: ();                          // in scope 0 at $DIR/inline-shims.rs:+1:14: +1:40
-      let mut _4: *mut std::vec::Vec;   // in scope 0 at $DIR/inline-shims.rs:+1:38: +1:39
-      let mut _5: *mut std::option::Option; // in scope 0 at $DIR/inline-shims.rs:+2:38: +2:39
+      debug a => _1;                       // in scope 0 at $DIR/inline_shims.rs:+0:19: +0:20
+      debug b => _2;                       // in scope 0 at $DIR/inline_shims.rs:+0:35: +0:36
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_shims.rs:+0:54: +0:54
+      let _3: ();                          // in scope 0 at $DIR/inline_shims.rs:+1:14: +1:40
+      let mut _4: *mut std::vec::Vec;   // in scope 0 at $DIR/inline_shims.rs:+1:38: +1:39
+      let mut _5: *mut std::option::Option; // in scope 0 at $DIR/inline_shims.rs:+2:38: +2:39
       scope 1 {
       }
       scope 2 {
-+         scope 3 (inlined std::ptr::drop_in_place::> - shim(Some(Option))) { // at $DIR/inline-shims.rs:12:14: 12:40
++         scope 3 (inlined std::ptr::drop_in_place::> - shim(Some(Option))) { // at $DIR/inline_shims.rs:12:14: 12:40
 +             let mut _6: isize;           // in scope 3 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
 +             let mut _7: isize;           // in scope 3 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
 +         }
       }
   
       bb0: {
-          StorageLive(_3);                 // scope 0 at $DIR/inline-shims.rs:+1:5: +1:42
-          StorageLive(_4);                 // scope 1 at $DIR/inline-shims.rs:+1:38: +1:39
-          _4 = _1;                         // scope 1 at $DIR/inline-shims.rs:+1:38: +1:39
-          _3 = std::ptr::drop_in_place::>(move _4) -> bb1; // scope 1 at $DIR/inline-shims.rs:+1:14: +1:40
+          StorageLive(_3);                 // scope 0 at $DIR/inline_shims.rs:+1:5: +1:42
+          StorageLive(_4);                 // scope 1 at $DIR/inline_shims.rs:+1:38: +1:39
+          _4 = _1;                         // scope 1 at $DIR/inline_shims.rs:+1:38: +1:39
+          _3 = std::ptr::drop_in_place::>(move _4) -> bb1; // scope 1 at $DIR/inline_shims.rs:+1:14: +1:40
                                            // mir::Constant
-                                           // + span: $DIR/inline-shims.rs:11:14: 11:37
+                                           // + span: $DIR/inline_shims.rs:11:14: 11:37
                                            // + literal: Const { ty: unsafe fn(*mut Vec) {std::ptr::drop_in_place::>}, val: Value() }
       }
   
       bb1: {
-          StorageDead(_4);                 // scope 1 at $DIR/inline-shims.rs:+1:39: +1:40
-          StorageDead(_3);                 // scope 0 at $DIR/inline-shims.rs:+1:41: +1:42
-          StorageLive(_5);                 // scope 2 at $DIR/inline-shims.rs:+2:38: +2:39
-          _5 = _2;                         // scope 2 at $DIR/inline-shims.rs:+2:38: +2:39
--         _0 = std::ptr::drop_in_place::>(move _5) -> bb2; // scope 2 at $DIR/inline-shims.rs:+2:14: +2:40
+          StorageDead(_4);                 // scope 1 at $DIR/inline_shims.rs:+1:39: +1:40
+          StorageDead(_3);                 // scope 0 at $DIR/inline_shims.rs:+1:41: +1:42
+          StorageLive(_5);                 // scope 2 at $DIR/inline_shims.rs:+2:38: +2:39
+          _5 = _2;                         // scope 2 at $DIR/inline_shims.rs:+2:38: +2:39
+-         _0 = std::ptr::drop_in_place::>(move _5) -> bb2; // scope 2 at $DIR/inline_shims.rs:+2:14: +2:40
 -                                          // mir::Constant
--                                          // + span: $DIR/inline-shims.rs:12:14: 12:37
+-                                          // + span: $DIR/inline_shims.rs:12:14: 12:37
 -                                          // + literal: Const { ty: unsafe fn(*mut Option) {std::ptr::drop_in_place::>}, val: Value() }
-+         StorageLive(_6);                 // scope 2 at $DIR/inline-shims.rs:+2:14: +2:40
-+         StorageLive(_7);                 // scope 2 at $DIR/inline-shims.rs:+2:14: +2:40
++         StorageLive(_6);                 // scope 2 at $DIR/inline_shims.rs:+2:14: +2:40
++         StorageLive(_7);                 // scope 2 at $DIR/inline_shims.rs:+2:14: +2:40
 +         _6 = discriminant((*_5));        // scope 3 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
 +         switchInt(move _6) -> [0_isize: bb2, otherwise: bb3]; // scope 3 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
       }
   
       bb2: {
-+         StorageDead(_7);                 // scope 2 at $DIR/inline-shims.rs:+2:14: +2:40
-+         StorageDead(_6);                 // scope 2 at $DIR/inline-shims.rs:+2:14: +2:40
-          StorageDead(_5);                 // scope 2 at $DIR/inline-shims.rs:+2:39: +2:40
-          return;                          // scope 0 at $DIR/inline-shims.rs:+3:2: +3:2
++         StorageDead(_7);                 // scope 2 at $DIR/inline_shims.rs:+2:14: +2:40
++         StorageDead(_6);                 // scope 2 at $DIR/inline_shims.rs:+2:14: +2:40
+          StorageDead(_5);                 // scope 2 at $DIR/inline_shims.rs:+2:39: +2:40
+          return;                          // scope 0 at $DIR/inline_shims.rs:+3:2: +3:2
 +     }
 + 
 +     bb3: {
diff --git a/src/test/mir-opt/inline/inline-shims.rs b/src/test/mir-opt/inline/inline_shims.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-shims.rs
rename to src/test/mir-opt/inline/inline_shims.rs
diff --git a/src/test/mir-opt/inline/inline_specialization.main.Inline.diff b/src/test/mir-opt/inline/inline_specialization.main.Inline.diff
index fdf2a1e1ff9..af08296edea 100644
--- a/src/test/mir-opt/inline/inline_specialization.main.Inline.diff
+++ b/src/test/mir-opt/inline/inline_specialization.main.Inline.diff
@@ -2,27 +2,27 @@
 + // MIR for `main` after Inline
   
   fn main() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/inline-specialization.rs:+0:11: +0:11
-      let _1: u32;                         // in scope 0 at $DIR/inline-specialization.rs:+1:9: +1:10
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline_specialization.rs:+0:11: +0:11
+      let _1: u32;                         // in scope 0 at $DIR/inline_specialization.rs:+1:9: +1:10
       scope 1 {
-          debug x => _1;                   // in scope 1 at $DIR/inline-specialization.rs:+1:9: +1:10
+          debug x => _1;                   // in scope 1 at $DIR/inline_specialization.rs:+1:9: +1:10
       }
-+     scope 2 (inlined  as Foo>::bar) { // at $DIR/inline-specialization.rs:5:13: 5:38
++     scope 2 (inlined  as Foo>::bar) { // at $DIR/inline_specialization.rs:5:13: 5:38
 +     }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/inline-specialization.rs:+1:9: +1:10
--         _1 =  as Foo>::bar() -> bb1; // scope 0 at $DIR/inline-specialization.rs:+1:13: +1:38
+          StorageLive(_1);                 // scope 0 at $DIR/inline_specialization.rs:+1:9: +1:10
+-         _1 =  as Foo>::bar() -> bb1; // scope 0 at $DIR/inline_specialization.rs:+1:13: +1:38
 -                                          // mir::Constant
--                                          // + span: $DIR/inline-specialization.rs:5:13: 5:36
+-                                          // + span: $DIR/inline_specialization.rs:5:13: 5:36
 -                                          // + literal: Const { ty: fn() -> u32 { as Foo>::bar}, val: Value() }
 -     }
 - 
 -     bb1: {
-+         _1 = const 123_u32;              // scope 2 at $DIR/inline-specialization.rs:14:31: 14:34
-          _0 = const ();                   // scope 0 at $DIR/inline-specialization.rs:+0:11: +2:2
-          StorageDead(_1);                 // scope 0 at $DIR/inline-specialization.rs:+2:1: +2:2
-          return;                          // scope 0 at $DIR/inline-specialization.rs:+2:2: +2:2
++         _1 = const 123_u32;              // scope 2 at $DIR/inline_specialization.rs:14:31: 14:34
+          _0 = const ();                   // scope 0 at $DIR/inline_specialization.rs:+0:11: +2:2
+          StorageDead(_1);                 // scope 0 at $DIR/inline_specialization.rs:+2:1: +2:2
+          return;                          // scope 0 at $DIR/inline_specialization.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/inline-specialization.rs b/src/test/mir-opt/inline/inline_specialization.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-specialization.rs
rename to src/test/mir-opt/inline/inline_specialization.rs
diff --git a/src/test/mir-opt/inline/inline-trait-method.rs b/src/test/mir-opt/inline/inline_trait_method.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-trait-method.rs
rename to src/test/mir-opt/inline/inline_trait_method.rs
diff --git a/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir b/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir
index 89eefc29269..637bf282a65 100644
--- a/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir
+++ b/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir
@@ -1,21 +1,21 @@
 // MIR for `test` after Inline
 
 fn test(_1: &dyn X) -> u32 {
-    debug x => _1;                       // in scope 0 at $DIR/inline-trait-method.rs:+0:9: +0:10
-    let mut _0: u32;                     // return place in scope 0 at $DIR/inline-trait-method.rs:+0:23: +0:26
-    let mut _2: &dyn X;                  // in scope 0 at $DIR/inline-trait-method.rs:+1:5: +1:10
+    debug x => _1;                       // in scope 0 at $DIR/inline_trait_method.rs:+0:9: +0:10
+    let mut _0: u32;                     // return place in scope 0 at $DIR/inline_trait_method.rs:+0:23: +0:26
+    let mut _2: &dyn X;                  // in scope 0 at $DIR/inline_trait_method.rs:+1:5: +1:10
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/inline-trait-method.rs:+1:5: +1:10
-        _2 = &(*_1);                     // scope 0 at $DIR/inline-trait-method.rs:+1:5: +1:10
-        _0 = ::y(move _2) -> bb1; // scope 0 at $DIR/inline-trait-method.rs:+1:5: +1:10
+        StorageLive(_2);                 // scope 0 at $DIR/inline_trait_method.rs:+1:5: +1:10
+        _2 = &(*_1);                     // scope 0 at $DIR/inline_trait_method.rs:+1:5: +1:10
+        _0 = ::y(move _2) -> bb1; // scope 0 at $DIR/inline_trait_method.rs:+1:5: +1:10
                                          // mir::Constant
-                                         // + span: $DIR/inline-trait-method.rs:9:7: 9:8
+                                         // + span: $DIR/inline_trait_method.rs:9:7: 9:8
                                          // + literal: Const { ty: for<'a> fn(&'a dyn X) -> u32 {::y}, val: Value() }
     }
 
     bb1: {
-        StorageDead(_2);                 // scope 0 at $DIR/inline-trait-method.rs:+1:9: +1:10
-        return;                          // scope 0 at $DIR/inline-trait-method.rs:+2:2: +2:2
+        StorageDead(_2);                 // scope 0 at $DIR/inline_trait_method.rs:+1:9: +1:10
+        return;                          // scope 0 at $DIR/inline_trait_method.rs:+2:2: +2:2
     }
 }
diff --git a/src/test/mir-opt/inline/inline-trait-method_2.rs b/src/test/mir-opt/inline/inline_trait_method_2.rs
similarity index 100%
rename from src/test/mir-opt/inline/inline-trait-method_2.rs
rename to src/test/mir-opt/inline/inline_trait_method_2.rs
diff --git a/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir b/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir
index 3d05869fa51..dab8bb9a0c6 100644
--- a/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir
+++ b/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir
@@ -1,32 +1,32 @@
 // MIR for `test2` after Inline
 
 fn test2(_1: &dyn X) -> bool {
-    debug x => _1;                       // in scope 0 at $DIR/inline-trait-method_2.rs:+0:10: +0:11
-    let mut _0: bool;                    // return place in scope 0 at $DIR/inline-trait-method_2.rs:+0:24: +0:28
-    let mut _2: &dyn X;                  // in scope 0 at $DIR/inline-trait-method_2.rs:+1:10: +1:11
-    let mut _3: &dyn X;                  // in scope 0 at $DIR/inline-trait-method_2.rs:+1:10: +1:11
-    scope 1 (inlined test) {             // at $DIR/inline-trait-method_2.rs:5:5: 5:12
-        debug x => _2;                   // in scope 1 at $DIR/inline-trait-method_2.rs:9:9: 9:10
-        let mut _4: &dyn X;              // in scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10
+    debug x => _1;                       // in scope 0 at $DIR/inline_trait_method_2.rs:+0:10: +0:11
+    let mut _0: bool;                    // return place in scope 0 at $DIR/inline_trait_method_2.rs:+0:24: +0:28
+    let mut _2: &dyn X;                  // in scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11
+    let mut _3: &dyn X;                  // in scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11
+    scope 1 (inlined test) {             // at $DIR/inline_trait_method_2.rs:5:5: 5:12
+        debug x => _2;                   // in scope 1 at $DIR/inline_trait_method_2.rs:9:9: 9:10
+        let mut _4: &dyn X;              // in scope 1 at $DIR/inline_trait_method_2.rs:10:5: 10:10
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/inline-trait-method_2.rs:+1:10: +1:11
-        StorageLive(_3);                 // scope 0 at $DIR/inline-trait-method_2.rs:+1:10: +1:11
-        _3 = &(*_1);                     // scope 0 at $DIR/inline-trait-method_2.rs:+1:10: +1:11
-        _2 = move _3 as &dyn X (Pointer(Unsize)); // scope 0 at $DIR/inline-trait-method_2.rs:+1:10: +1:11
-        StorageDead(_3);                 // scope 0 at $DIR/inline-trait-method_2.rs:+1:10: +1:11
-        StorageLive(_4);                 // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10
-        _4 = _2;                         // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10
-        _0 = ::y(move _4) -> bb1; // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10
+        StorageLive(_2);                 // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11
+        StorageLive(_3);                 // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11
+        _3 = &(*_1);                     // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11
+        _2 = move _3 as &dyn X (Pointer(Unsize)); // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11
+        StorageDead(_3);                 // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11
+        StorageLive(_4);                 // scope 1 at $DIR/inline_trait_method_2.rs:10:5: 10:10
+        _4 = _2;                         // scope 1 at $DIR/inline_trait_method_2.rs:10:5: 10:10
+        _0 = ::y(move _4) -> bb1; // scope 1 at $DIR/inline_trait_method_2.rs:10:5: 10:10
                                          // mir::Constant
-                                         // + span: $DIR/inline-trait-method_2.rs:10:7: 10:8
+                                         // + span: $DIR/inline_trait_method_2.rs:10:7: 10:8
                                          // + literal: Const { ty: for<'a> fn(&'a dyn X) -> bool {::y}, val: Value() }
     }
 
     bb1: {
-        StorageDead(_4);                 // scope 1 at $DIR/inline-trait-method_2.rs:10:9: 10:10
-        StorageDead(_2);                 // scope 0 at $DIR/inline-trait-method_2.rs:+1:11: +1:12
-        return;                          // scope 0 at $DIR/inline-trait-method_2.rs:+2:2: +2:2
+        StorageDead(_4);                 // scope 1 at $DIR/inline_trait_method_2.rs:10:9: 10:10
+        StorageDead(_2);                 // scope 0 at $DIR/inline_trait_method_2.rs:+1:11: +1:12
+        return;                          // scope 0 at $DIR/inline_trait_method_2.rs:+2:2: +2:2
     }
 }
diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir
index 5168ae031f0..777681e1ce7 100644
--- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir
+++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir
@@ -1,30 +1,30 @@
 // MIR for `a` after Inline
 
 fn a(_1: &mut [T]) -> &mut [T] {
-    debug x => _1;                       // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:13: +0:14
-    let mut _0: &mut [T];                // return place in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:29: +0:37
-    let mut _2: &mut [T];                // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-    let mut _3: &mut [T];                // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-    let mut _4: &mut [T];                // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-    scope 1 (inlined <[T] as AsMut<[T]>>::as_mut) { // at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15
+    debug x => _1;                       // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:13: +0:14
+    let mut _0: &mut [T];                // return place in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:29: +0:37
+    let mut _2: &mut [T];                // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+    let mut _3: &mut [T];                // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+    let mut _4: &mut [T];                // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+    scope 1 (inlined <[T] as AsMut<[T]>>::as_mut) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:3:5: 3:15
         debug self => _4;                // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
         let mut _5: &mut [T];            // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        StorageLive(_3);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        StorageLive(_4);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        _4 = &mut (*_1);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
+        StorageLive(_2);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        StorageLive(_3);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        StorageLive(_4);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        _4 = &mut (*_1);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
         StorageLive(_5);                 // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
         _5 = &mut (*_4);                 // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
         _3 = &mut (*_5);                 // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
         StorageDead(_5);                 // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-        _2 = &mut (*_3);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        StorageDead(_4);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:14: +1:15
-        _0 = &mut (*_2);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        StorageDead(_3);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2
-        StorageDead(_2);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2
-        return;                          // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:2: +2:2
+        _2 = &mut (*_3);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        StorageDead(_4);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15
+        _0 = &mut (*_2);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        StorageDead(_3);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2
+        StorageDead(_2);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2
+        return;                          // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:2: +2:2
     }
 }
diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir
index 06d442ae88b..83545c99100 100644
--- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir
+++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir
@@ -1,12 +1,12 @@
 // MIR for `b` after Inline
 
 fn b(_1: &mut Box) -> &mut T {
-    debug x => _1;                       // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:13: +0:14
-    let mut _0: &mut T;                  // return place in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:32: +0:38
-    let mut _2: &mut T;                  // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-    let mut _3: &mut T;                  // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-    let mut _4: &mut std::boxed::Box; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-    scope 1 (inlined  as AsMut>::as_mut) { // at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15
+    debug x => _1;                       // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:13: +0:14
+    let mut _0: &mut T;                  // return place in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:32: +0:38
+    let mut _2: &mut T;                  // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+    let mut _3: &mut T;                  // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+    let mut _4: &mut std::boxed::Box; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+    scope 1 (inlined  as AsMut>::as_mut) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:8:5: 8:15
         debug self => _4;                // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
         let mut _5: &mut T;              // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
         let mut _6: &mut T;              // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
@@ -15,10 +15,10 @@ fn b(_1: &mut Box) -> &mut T {
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        StorageLive(_3);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        StorageLive(_4);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        _4 = &mut (*_1);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
+        StorageLive(_2);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        StorageLive(_3);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        StorageLive(_4);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        _4 = &mut (*_1);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
         StorageLive(_5);                 // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
         StorageLive(_6);                 // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
         _7 = deref_copy (*_4);           // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
@@ -28,11 +28,11 @@ fn b(_1: &mut Box) -> &mut T {
         _3 = &mut (*_5);                 // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
         StorageDead(_6);                 // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
         StorageDead(_5);                 // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
-        _2 = &mut (*_3);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        StorageDead(_4);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:14: +1:15
-        _0 = &mut (*_2);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        StorageDead(_3);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2
-        StorageDead(_2);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2
-        return;                          // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:2: +2:2
+        _2 = &mut (*_3);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        StorageDead(_4);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15
+        _0 = &mut (*_2);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        StorageDead(_3);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2
+        StorageDead(_2);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2
+        return;                          // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:2: +2:2
     }
 }
diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir
index c7f20ff98ff..ed4e9927ce9 100644
--- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir
+++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir
@@ -1,22 +1,22 @@
 // MIR for `c` after Inline
 
 fn c(_1: &[T]) -> &[T] {
-    debug x => _1;                       // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:13: +0:14
-    let mut _0: &[T];                    // return place in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:25: +0:29
-    let _2: &[T];                        // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-    let mut _3: &[T];                    // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-    scope 1 (inlined <[T] as AsRef<[T]>>::as_ref) { // at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15
+    debug x => _1;                       // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:13: +0:14
+    let mut _0: &[T];                    // return place in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:25: +0:29
+    let _2: &[T];                        // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+    let mut _3: &[T];                    // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+    scope 1 (inlined <[T] as AsRef<[T]>>::as_ref) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:13:5: 13:15
         debug self => _3;                // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        StorageLive(_3);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        _3 = &(*_1);                     // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
+        StorageLive(_2);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        StorageLive(_3);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        _3 = &(*_1);                     // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
         _2 = _3;                         // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-        _0 = &(*_2);                     // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        StorageDead(_3);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:14: +1:15
-        StorageDead(_2);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2
-        return;                          // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:2: +2:2
+        _0 = &(*_2);                     // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        StorageDead(_3);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15
+        StorageDead(_2);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2
+        return;                          // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:2: +2:2
     }
 }
diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir
index d5f06c54a57..18a2670be21 100644
--- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir
+++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir
@@ -1,26 +1,26 @@
 // MIR for `d` after Inline
 
 fn d(_1: &Box) -> &T {
-    debug x => _1;                       // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:13: +0:14
-    let mut _0: &T;                      // return place in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:28: +0:30
-    let _2: &T;                          // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-    let mut _3: &std::boxed::Box;     // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-    scope 1 (inlined  as AsRef>::as_ref) { // at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15
+    debug x => _1;                       // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:13: +0:14
+    let mut _0: &T;                      // return place in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:28: +0:30
+    let _2: &T;                          // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+    let mut _3: &std::boxed::Box;     // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+    scope 1 (inlined  as AsRef>::as_ref) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:18:5: 18:15
         debug self => _3;                // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
         let mut _4: std::boxed::Box;  // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
         let mut _5: *const T;            // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        StorageLive(_3);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        _3 = &(*_1);                     // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
+        StorageLive(_2);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        StorageLive(_3);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        _3 = &(*_1);                     // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
         _4 = deref_copy (*_3);           // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
         _5 = (((_4.0: std::ptr::Unique).0: std::ptr::NonNull).0: *const T); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
         _2 = &(*_5);                     // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
-        _0 = &(*_2);                     // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15
-        StorageDead(_3);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:14: +1:15
-        StorageDead(_2);                 // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2
-        return;                          // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:2: +2:2
+        _0 = &(*_2);                     // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
+        StorageDead(_3);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15
+        StorageDead(_2);                 // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2
+        return;                          // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:2: +2:2
     }
 }
diff --git a/src/test/mir-opt/inline/issue-58867-inline-as-ref-as-mut.rs b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs
similarity index 100%
rename from src/test/mir-opt/inline/issue-58867-inline-as-ref-as-mut.rs
rename to src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs
diff --git a/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir
index fca53a72f88..d99ae1a6c7c 100644
--- a/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir
+++ b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir
@@ -1,42 +1,42 @@
 // MIR for `main` after Inline
 
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+0:11: +0:11
-    let _1: [closure@$DIR/issue-76997-inline-scopes-parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:9: +1:10
-    let mut _2: &[closure@$DIR/issue-76997-inline-scopes-parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:6
-    let mut _3: ((),);                   // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:10
-    let mut _4: ();                      // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:7: +2:9
-    let mut _5: ();                      // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:10
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+0:11: +0:11
+    let _1: [closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:9: +1:10
+    let mut _2: &[closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:6
+    let mut _3: ((),);                   // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10
+    let mut _4: ();                      // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:7: +2:9
+    let mut _5: ();                      // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10
     scope 1 {
-        debug f => _1;                   // in scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:9: +1:10
-        scope 2 (inlined main::{closure#0}) { // at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
-            debug x => _5;               // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:14: +1:15
-            let _6: ();                  // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:23: +1:24
+        debug f => _1;                   // in scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:9: +1:10
+        scope 2 (inlined main::{closure#0}) { // at $DIR/issue_76997_inline_scopes_parenting.rs:6:5: 6:10
+            debug x => _5;               // in scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:14: +1:15
+            let _6: ();                  // in scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24
             scope 3 {
-                debug y => _6;           // in scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:23: +1:24
+                debug y => _6;           // in scope 3 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24
             }
         }
     }
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:9: +1:10
-        Deinit(_1);                      // scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:13: +1:33
-        StorageLive(_2);                 // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:6
-        _2 = &_1;                        // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:6
-        StorageLive(_3);                 // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:10
-        StorageLive(_4);                 // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:7: +2:9
-        Deinit(_4);                      // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:7: +2:9
-        Deinit(_3);                      // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:10
-        (_3.0: ()) = move _4;            // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:10
-        StorageLive(_5);                 // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:10
-        _5 = move (_3.0: ());            // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:10
-        StorageLive(_6);                 // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:23: +1:24
-        StorageDead(_6);                 // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:32: +1:33
-        StorageDead(_5);                 // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:10
-        StorageDead(_4);                 // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:9: +2:10
-        StorageDead(_3);                 // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:9: +2:10
-        StorageDead(_2);                 // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:9: +2:10
-        StorageDead(_1);                 // scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+3:1: +3:2
-        return;                          // scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+3:2: +3:2
+        StorageLive(_1);                 // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:9: +1:10
+        Deinit(_1);                      // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:13: +1:33
+        StorageLive(_2);                 // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:6
+        _2 = &_1;                        // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:6
+        StorageLive(_3);                 // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10
+        StorageLive(_4);                 // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:7: +2:9
+        Deinit(_4);                      // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:7: +2:9
+        Deinit(_3);                      // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10
+        (_3.0: ()) = move _4;            // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10
+        StorageLive(_5);                 // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10
+        _5 = move (_3.0: ());            // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10
+        StorageLive(_6);                 // scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24
+        StorageDead(_6);                 // scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:32: +1:33
+        StorageDead(_5);                 // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10
+        StorageDead(_4);                 // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10
+        StorageDead(_3);                 // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10
+        StorageDead(_2);                 // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10
+        StorageDead(_1);                 // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+3:1: +3:2
+        return;                          // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+3:2: +3:2
     }
 }
diff --git a/src/test/mir-opt/inline/issue-76997-inline-scopes-parenting.rs b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.rs
similarity index 100%
rename from src/test/mir-opt/inline/issue-76997-inline-scopes-parenting.rs
rename to src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.rs
diff --git a/src/test/mir-opt/inline/issue_78442.bar.Inline.diff b/src/test/mir-opt/inline/issue_78442.bar.Inline.diff
index 4186650dfab..51a98465fd9 100644
--- a/src/test/mir-opt/inline/issue_78442.bar.Inline.diff
+++ b/src/test/mir-opt/inline/issue_78442.bar.Inline.diff
@@ -2,67 +2,67 @@
 + // MIR for `bar` after Inline
   
   fn bar(_1: P) -> () {
-      debug _baz => _1;                    // in scope 0 at $DIR/issue-78442.rs:+2:5: +2:9
-      let mut _0: ();                      // return place in scope 0 at $DIR/issue-78442.rs:+3:3: +3:3
-      let _2: ();                          // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
-      let mut _3: &fn() {foo};             // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
-      let _4: fn() {foo};                  // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
-      let mut _5: ();                      // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
-+     scope 1 (inlined >::call - shim(fn() {foo})) { // at $DIR/issue-78442.rs:11:5: 11:17
+      debug _baz => _1;                    // in scope 0 at $DIR/issue_78442.rs:+2:5: +2:9
+      let mut _0: ();                      // return place in scope 0 at $DIR/issue_78442.rs:+3:3: +3:3
+      let _2: ();                          // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
+      let mut _3: &fn() {foo};             // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
+      let _4: fn() {foo};                  // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
+      let mut _5: ();                      // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
++     scope 1 (inlined >::call - shim(fn() {foo})) { // at $DIR/issue_78442.rs:11:5: 11:17
 +     }
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
-          StorageLive(_3);                 // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
-          StorageLive(_4);                 // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
--         _4 = hide_foo() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
-+         _4 = hide_foo() -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
+          StorageLive(_2);                 // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
+          StorageLive(_3);                 // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
+          StorageLive(_4);                 // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
+-         _4 = hide_foo() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
++         _4 = hide_foo() -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
                                            // mir::Constant
-                                           // + span: $DIR/issue-78442.rs:11:5: 11:13
+                                           // + span: $DIR/issue_78442.rs:11:5: 11:13
                                            // + literal: Const { ty: fn() -> impl Fn() {hide_foo}, val: Value() }
       }
   
       bb1: {
-          _3 = &_4;                        // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
-          StorageLive(_5);                 // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
-          Deinit(_5);                      // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
--         _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
+          _3 = &_4;                        // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
+          StorageLive(_5);                 // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
+          Deinit(_5);                      // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
+-         _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
 -                                          // mir::Constant
--                                          // + span: $DIR/issue-78442.rs:11:5: 11:15
+-                                          // + span: $DIR/issue_78442.rs:11:5: 11:15
 -                                          // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() {foo}, ()) -> >::Output {>::call}, val: Value() }
 +         _2 = move (*_3)() -> [return: bb5, unwind: bb3]; // scope 1 at $SRC_DIR/core/src/ops/function.rs:LL:COL
       }
   
       bb2: {
--         StorageDead(_5);                 // scope 0 at $DIR/issue-78442.rs:+4:16: +4:17
--         StorageDead(_3);                 // scope 0 at $DIR/issue-78442.rs:+4:16: +4:17
--         StorageDead(_4);                 // scope 0 at $DIR/issue-78442.rs:+4:17: +4:18
--         StorageDead(_2);                 // scope 0 at $DIR/issue-78442.rs:+4:17: +4:18
--         _0 = const ();                   // scope 0 at $DIR/issue-78442.rs:+3:3: +5:2
--         drop(_1) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue-78442.rs:+5:1: +5:2
-+         return;                          // scope 0 at $DIR/issue-78442.rs:+5:2: +5:2
+-         StorageDead(_5);                 // scope 0 at $DIR/issue_78442.rs:+4:16: +4:17
+-         StorageDead(_3);                 // scope 0 at $DIR/issue_78442.rs:+4:16: +4:17
+-         StorageDead(_4);                 // scope 0 at $DIR/issue_78442.rs:+4:17: +4:18
+-         StorageDead(_2);                 // scope 0 at $DIR/issue_78442.rs:+4:17: +4:18
+-         _0 = const ();                   // scope 0 at $DIR/issue_78442.rs:+3:3: +5:2
+-         drop(_1) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2
++         return;                          // scope 0 at $DIR/issue_78442.rs:+5:2: +5:2
       }
   
 -     bb3: {
--         return;                          // scope 0 at $DIR/issue-78442.rs:+5:2: +5:2
+-         return;                          // scope 0 at $DIR/issue_78442.rs:+5:2: +5:2
 +     bb3 (cleanup): {
-+         drop(_1) -> bb4;                 // scope 0 at $DIR/issue-78442.rs:+5:1: +5:2
++         drop(_1) -> bb4;                 // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2
       }
   
       bb4 (cleanup): {
--         drop(_1) -> bb5;                 // scope 0 at $DIR/issue-78442.rs:+5:1: +5:2
-+         resume;                          // scope 0 at $DIR/issue-78442.rs:+0:1: +5:2
+-         drop(_1) -> bb5;                 // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2
++         resume;                          // scope 0 at $DIR/issue_78442.rs:+0:1: +5:2
       }
   
 -     bb5 (cleanup): {
--         resume;                          // scope 0 at $DIR/issue-78442.rs:+0:1: +5:2
+-         resume;                          // scope 0 at $DIR/issue_78442.rs:+0:1: +5:2
 +     bb5: {
-+         StorageDead(_5);                 // scope 0 at $DIR/issue-78442.rs:+4:16: +4:17
-+         StorageDead(_3);                 // scope 0 at $DIR/issue-78442.rs:+4:16: +4:17
-+         StorageDead(_4);                 // scope 0 at $DIR/issue-78442.rs:+4:17: +4:18
-+         StorageDead(_2);                 // scope 0 at $DIR/issue-78442.rs:+4:17: +4:18
-+         _0 = const ();                   // scope 0 at $DIR/issue-78442.rs:+3:3: +5:2
-+         drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue-78442.rs:+5:1: +5:2
++         StorageDead(_5);                 // scope 0 at $DIR/issue_78442.rs:+4:16: +4:17
++         StorageDead(_3);                 // scope 0 at $DIR/issue_78442.rs:+4:16: +4:17
++         StorageDead(_4);                 // scope 0 at $DIR/issue_78442.rs:+4:17: +4:18
++         StorageDead(_2);                 // scope 0 at $DIR/issue_78442.rs:+4:17: +4:18
++         _0 = const ();                   // scope 0 at $DIR/issue_78442.rs:+3:3: +5:2
++         drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff b/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff
index 24e9a3df15a..e47466c5e80 100644
--- a/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff
+++ b/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff
@@ -2,56 +2,56 @@
 + // MIR for `bar` after RevealAll
   
   fn bar(_1: P) -> () {
-      debug _baz => _1;                    // in scope 0 at $DIR/issue-78442.rs:+2:5: +2:9
-      let mut _0: ();                      // return place in scope 0 at $DIR/issue-78442.rs:+3:3: +3:3
-      let _2: ();                          // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
--     let mut _3: &impl Fn();              // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
--     let _4: impl Fn();                   // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
-+     let mut _3: &fn() {foo};             // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
-+     let _4: fn() {foo};                  // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
-      let mut _5: ();                      // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
+      debug _baz => _1;                    // in scope 0 at $DIR/issue_78442.rs:+2:5: +2:9
+      let mut _0: ();                      // return place in scope 0 at $DIR/issue_78442.rs:+3:3: +3:3
+      let _2: ();                          // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
+-     let mut _3: &impl Fn();              // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
+-     let _4: impl Fn();                   // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
++     let mut _3: &fn() {foo};             // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
++     let _4: fn() {foo};                  // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
+      let mut _5: ();                      // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
-          StorageLive(_3);                 // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
-          StorageLive(_4);                 // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
-          _4 = hide_foo() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
+          StorageLive(_2);                 // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
+          StorageLive(_3);                 // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
+          StorageLive(_4);                 // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
+          _4 = hide_foo() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
                                            // mir::Constant
-                                           // + span: $DIR/issue-78442.rs:11:5: 11:13
+                                           // + span: $DIR/issue_78442.rs:11:5: 11:13
                                            // + literal: Const { ty: fn() -> impl Fn() {hide_foo}, val: Value() }
       }
   
       bb1: {
-          _3 = &_4;                        // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15
-          StorageLive(_5);                 // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
-          Deinit(_5);                      // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
--         _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
-+         _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17
+          _3 = &_4;                        // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15
+          StorageLive(_5);                 // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
+          Deinit(_5);                      // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
+-         _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
++         _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17
                                            // mir::Constant
-                                           // + span: $DIR/issue-78442.rs:11:5: 11:15
+                                           // + span: $DIR/issue_78442.rs:11:5: 11:15
 -                                          // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(), ()) -> >::Output {>::call}, val: Value() }
 +                                          // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() {foo}, ()) -> >::Output {>::call}, val: Value() }
       }
   
       bb2: {
-          StorageDead(_5);                 // scope 0 at $DIR/issue-78442.rs:+4:16: +4:17
-          StorageDead(_3);                 // scope 0 at $DIR/issue-78442.rs:+4:16: +4:17
-          StorageDead(_4);                 // scope 0 at $DIR/issue-78442.rs:+4:17: +4:18
-          StorageDead(_2);                 // scope 0 at $DIR/issue-78442.rs:+4:17: +4:18
-          _0 = const ();                   // scope 0 at $DIR/issue-78442.rs:+3:3: +5:2
-          drop(_1) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue-78442.rs:+5:1: +5:2
+          StorageDead(_5);                 // scope 0 at $DIR/issue_78442.rs:+4:16: +4:17
+          StorageDead(_3);                 // scope 0 at $DIR/issue_78442.rs:+4:16: +4:17
+          StorageDead(_4);                 // scope 0 at $DIR/issue_78442.rs:+4:17: +4:18
+          StorageDead(_2);                 // scope 0 at $DIR/issue_78442.rs:+4:17: +4:18
+          _0 = const ();                   // scope 0 at $DIR/issue_78442.rs:+3:3: +5:2
+          drop(_1) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2
       }
   
       bb3: {
-          return;                          // scope 0 at $DIR/issue-78442.rs:+5:2: +5:2
+          return;                          // scope 0 at $DIR/issue_78442.rs:+5:2: +5:2
       }
   
       bb4 (cleanup): {
-          drop(_1) -> bb5;                 // scope 0 at $DIR/issue-78442.rs:+5:1: +5:2
+          drop(_1) -> bb5;                 // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2
       }
   
       bb5 (cleanup): {
-          resume;                          // scope 0 at $DIR/issue-78442.rs:+0:1: +5:2
+          resume;                          // scope 0 at $DIR/issue_78442.rs:+0:1: +5:2
       }
   }
   
diff --git a/src/test/mir-opt/inline/issue-78442.rs b/src/test/mir-opt/inline/issue_78442.rs
similarity index 100%
rename from src/test/mir-opt/inline/issue-78442.rs
rename to src/test/mir-opt/inline/issue_78442.rs
diff --git a/src/test/mir-opt/inline/polymorphic-recursion.rs b/src/test/mir-opt/inline/polymorphic_recursion.rs
similarity index 100%
rename from src/test/mir-opt/inline/polymorphic-recursion.rs
rename to src/test/mir-opt/inline/polymorphic_recursion.rs
diff --git a/src/test/mir-opt/issue_101973.inner.ConstProp.diff b/src/test/mir-opt/issue_101973.inner.ConstProp.diff
index 281afe4be17..c24abedae92 100644
--- a/src/test/mir-opt/issue_101973.inner.ConstProp.diff
+++ b/src/test/mir-opt/issue_101973.inner.ConstProp.diff
@@ -2,29 +2,29 @@
 + // MIR for `inner` after ConstProp
   
   fn inner(_1: u32) -> i64 {
-      debug fields => _1;                  // in scope 0 at $DIR/issue-101973.rs:+0:14: +0:20
-      let mut _0: i64;                     // return place in scope 0 at $DIR/issue-101973.rs:+0:30: +0:33
-      let mut _2: i32;                     // in scope 0 at $DIR/issue-101973.rs:+1:5: +1:65
-      let mut _3: u32;                     // in scope 0 at $DIR/issue-101973.rs:+1:5: +1:58
-      let mut _4: u32;                     // in scope 0 at $DIR/issue-101973.rs:+1:5: +1:17
-      let mut _5: u32;                     // in scope 0 at $DIR/issue-101973.rs:+1:10: +1:16
-      let mut _6: u32;                     // in scope 0 at $DIR/issue-101973.rs:+1:31: +1:57
-      let mut _7: u32;                     // in scope 0 at $DIR/issue-101973.rs:+1:31: +1:52
-      let mut _8: u32;                     // in scope 0 at $DIR/issue-101973.rs:+1:32: +1:45
-      let mut _9: u32;                     // in scope 0 at $DIR/issue-101973.rs:+1:33: +1:39
-      let mut _10: (u32, bool);            // in scope 0 at $DIR/issue-101973.rs:+1:32: +1:45
-      let mut _11: (u32, bool);            // in scope 0 at $DIR/issue-101973.rs:+1:31: +1:57
-      scope 1 (inlined imm8) {             // at $DIR/issue-101973.rs:14:5: 14:17
-          debug x => _5;                   // in scope 1 at $DIR/issue-101973.rs:5:13: 5:14
-          let mut _12: u32;                // in scope 1 at $DIR/issue-101973.rs:7:12: 7:27
-          let mut _13: u32;                // in scope 1 at $DIR/issue-101973.rs:7:12: 7:20
-          let mut _14: u32;                // in scope 1 at $DIR/issue-101973.rs:7:13: 7:14
-          let mut _15: (u32, bool);        // in scope 1 at $DIR/issue-101973.rs:7:12: 7:20
+      debug fields => _1;                  // in scope 0 at $DIR/issue_101973.rs:+0:14: +0:20
+      let mut _0: i64;                     // return place in scope 0 at $DIR/issue_101973.rs:+0:30: +0:33
+      let mut _2: i32;                     // in scope 0 at $DIR/issue_101973.rs:+1:5: +1:65
+      let mut _3: u32;                     // in scope 0 at $DIR/issue_101973.rs:+1:5: +1:58
+      let mut _4: u32;                     // in scope 0 at $DIR/issue_101973.rs:+1:5: +1:17
+      let mut _5: u32;                     // in scope 0 at $DIR/issue_101973.rs:+1:10: +1:16
+      let mut _6: u32;                     // in scope 0 at $DIR/issue_101973.rs:+1:31: +1:57
+      let mut _7: u32;                     // in scope 0 at $DIR/issue_101973.rs:+1:31: +1:52
+      let mut _8: u32;                     // in scope 0 at $DIR/issue_101973.rs:+1:32: +1:45
+      let mut _9: u32;                     // in scope 0 at $DIR/issue_101973.rs:+1:33: +1:39
+      let mut _10: (u32, bool);            // in scope 0 at $DIR/issue_101973.rs:+1:32: +1:45
+      let mut _11: (u32, bool);            // in scope 0 at $DIR/issue_101973.rs:+1:31: +1:57
+      scope 1 (inlined imm8) {             // at $DIR/issue_101973.rs:14:5: 14:17
+          debug x => _5;                   // in scope 1 at $DIR/issue_101973.rs:5:13: 5:14
+          let mut _12: u32;                // in scope 1 at $DIR/issue_101973.rs:7:12: 7:27
+          let mut _13: u32;                // in scope 1 at $DIR/issue_101973.rs:7:12: 7:20
+          let mut _14: u32;                // in scope 1 at $DIR/issue_101973.rs:7:13: 7:14
+          let mut _15: (u32, bool);        // in scope 1 at $DIR/issue_101973.rs:7:12: 7:20
           scope 2 {
-              debug out => _4;             // in scope 2 at $DIR/issue-101973.rs:6:9: 6:16
+              debug out => _4;             // in scope 2 at $DIR/issue_101973.rs:6:9: 6:16
           }
       }
-      scope 3 (inlined core::num::::rotate_right) { // at $DIR/issue-101973.rs:14:5: 14:58
+      scope 3 (inlined core::num::::rotate_right) { // at $DIR/issue_101973.rs:14:5: 14:58
           debug self => _4;                // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
           debug n => _6;                   // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
           let mut _16: u32;                // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
@@ -32,32 +32,32 @@
       }
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/issue-101973.rs:+1:5: +1:65
-          StorageLive(_3);                 // scope 0 at $DIR/issue-101973.rs:+1:5: +1:58
-          StorageLive(_4);                 // scope 0 at $DIR/issue-101973.rs:+1:5: +1:17
-          StorageLive(_5);                 // scope 0 at $DIR/issue-101973.rs:+1:10: +1:16
-          _5 = _1;                         // scope 0 at $DIR/issue-101973.rs:+1:10: +1:16
-          _4 = const 0_u32;                // scope 1 at $DIR/issue-101973.rs:6:19: 6:23
-          StorageLive(_12);                // scope 2 at $DIR/issue-101973.rs:7:12: 7:27
-          StorageLive(_13);                // scope 2 at $DIR/issue-101973.rs:7:12: 7:20
-          StorageLive(_14);                // scope 2 at $DIR/issue-101973.rs:7:13: 7:14
-          _14 = _5;                        // scope 2 at $DIR/issue-101973.rs:7:13: 7:14
-          _15 = CheckedShr(_14, const 0_i32); // scope 2 at $DIR/issue-101973.rs:7:12: 7:20
-          assert(!move (_15.1: bool), "attempt to shift right by `{}`, which would overflow", const 0_i32) -> bb3; // scope 2 at $DIR/issue-101973.rs:7:12: 7:20
+          StorageLive(_2);                 // scope 0 at $DIR/issue_101973.rs:+1:5: +1:65
+          StorageLive(_3);                 // scope 0 at $DIR/issue_101973.rs:+1:5: +1:58
+          StorageLive(_4);                 // scope 0 at $DIR/issue_101973.rs:+1:5: +1:17
+          StorageLive(_5);                 // scope 0 at $DIR/issue_101973.rs:+1:10: +1:16
+          _5 = _1;                         // scope 0 at $DIR/issue_101973.rs:+1:10: +1:16
+          _4 = const 0_u32;                // scope 1 at $DIR/issue_101973.rs:6:19: 6:23
+          StorageLive(_12);                // scope 2 at $DIR/issue_101973.rs:7:12: 7:27
+          StorageLive(_13);                // scope 2 at $DIR/issue_101973.rs:7:12: 7:20
+          StorageLive(_14);                // scope 2 at $DIR/issue_101973.rs:7:13: 7:14
+          _14 = _5;                        // scope 2 at $DIR/issue_101973.rs:7:13: 7:14
+          _15 = CheckedShr(_14, const 0_i32); // scope 2 at $DIR/issue_101973.rs:7:12: 7:20
+          assert(!move (_15.1: bool), "attempt to shift right by `{}`, which would overflow", const 0_i32) -> bb3; // scope 2 at $DIR/issue_101973.rs:7:12: 7:20
       }
   
       bb1: {
-          _8 = move (_10.0: u32);          // scope 0 at $DIR/issue-101973.rs:+1:32: +1:45
-          StorageDead(_9);                 // scope 0 at $DIR/issue-101973.rs:+1:44: +1:45
-          _7 = BitAnd(move _8, const 15_u32); // scope 0 at $DIR/issue-101973.rs:+1:31: +1:52
-          StorageDead(_8);                 // scope 0 at $DIR/issue-101973.rs:+1:51: +1:52
-          _11 = CheckedShl(_7, const 1_i32); // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57
-          assert(!move (_11.1: bool), "attempt to shift left by `{}`, which would overflow", const 1_i32) -> bb2; // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57
+          _8 = move (_10.0: u32);          // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45
+          StorageDead(_9);                 // scope 0 at $DIR/issue_101973.rs:+1:44: +1:45
+          _7 = BitAnd(move _8, const 15_u32); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:52
+          StorageDead(_8);                 // scope 0 at $DIR/issue_101973.rs:+1:51: +1:52
+          _11 = CheckedShl(_7, const 1_i32); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57
+          assert(!move (_11.1: bool), "attempt to shift left by `{}`, which would overflow", const 1_i32) -> bb2; // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57
       }
   
       bb2: {
-          _6 = move (_11.0: u32);          // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57
-          StorageDead(_7);                 // scope 0 at $DIR/issue-101973.rs:+1:56: +1:57
+          _6 = move (_11.0: u32);          // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57
+          StorageDead(_7);                 // scope 0 at $DIR/issue_101973.rs:+1:56: +1:57
           StorageLive(_16);                // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
           _16 = _4;                        // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
           StorageLive(_17);                // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
@@ -69,32 +69,32 @@
       }
   
       bb3: {
-          _13 = move (_15.0: u32);         // scope 2 at $DIR/issue-101973.rs:7:12: 7:20
-          StorageDead(_14);                // scope 2 at $DIR/issue-101973.rs:7:19: 7:20
-          _12 = BitAnd(move _13, const 255_u32); // scope 2 at $DIR/issue-101973.rs:7:12: 7:27
-          StorageDead(_13);                // scope 2 at $DIR/issue-101973.rs:7:26: 7:27
-          _4 = BitOr(_4, move _12);        // scope 2 at $DIR/issue-101973.rs:7:5: 7:27
-          StorageDead(_12);                // scope 2 at $DIR/issue-101973.rs:7:26: 7:27
-          StorageDead(_5);                 // scope 0 at $DIR/issue-101973.rs:+1:16: +1:17
-          StorageLive(_6);                 // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57
-          StorageLive(_7);                 // scope 0 at $DIR/issue-101973.rs:+1:31: +1:52
-          StorageLive(_8);                 // scope 0 at $DIR/issue-101973.rs:+1:32: +1:45
-          StorageLive(_9);                 // scope 0 at $DIR/issue-101973.rs:+1:33: +1:39
-          _9 = _1;                         // scope 0 at $DIR/issue-101973.rs:+1:33: +1:39
-          _10 = CheckedShr(_9, const 8_i32); // scope 0 at $DIR/issue-101973.rs:+1:32: +1:45
-          assert(!move (_10.1: bool), "attempt to shift right by `{}`, which would overflow", const 8_i32) -> bb1; // scope 0 at $DIR/issue-101973.rs:+1:32: +1:45
+          _13 = move (_15.0: u32);         // scope 2 at $DIR/issue_101973.rs:7:12: 7:20
+          StorageDead(_14);                // scope 2 at $DIR/issue_101973.rs:7:19: 7:20
+          _12 = BitAnd(move _13, const 255_u32); // scope 2 at $DIR/issue_101973.rs:7:12: 7:27
+          StorageDead(_13);                // scope 2 at $DIR/issue_101973.rs:7:26: 7:27
+          _4 = BitOr(_4, move _12);        // scope 2 at $DIR/issue_101973.rs:7:5: 7:27
+          StorageDead(_12);                // scope 2 at $DIR/issue_101973.rs:7:26: 7:27
+          StorageDead(_5);                 // scope 0 at $DIR/issue_101973.rs:+1:16: +1:17
+          StorageLive(_6);                 // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57
+          StorageLive(_7);                 // scope 0 at $DIR/issue_101973.rs:+1:31: +1:52
+          StorageLive(_8);                 // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45
+          StorageLive(_9);                 // scope 0 at $DIR/issue_101973.rs:+1:33: +1:39
+          _9 = _1;                         // scope 0 at $DIR/issue_101973.rs:+1:33: +1:39
+          _10 = CheckedShr(_9, const 8_i32); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45
+          assert(!move (_10.1: bool), "attempt to shift right by `{}`, which would overflow", const 8_i32) -> bb1; // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45
       }
   
       bb4: {
           StorageDead(_17);                // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
           StorageDead(_16);                // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-          StorageDead(_6);                 // scope 0 at $DIR/issue-101973.rs:+1:57: +1:58
-          StorageDead(_4);                 // scope 0 at $DIR/issue-101973.rs:+1:57: +1:58
-          _2 = move _3 as i32 (IntToInt);  // scope 0 at $DIR/issue-101973.rs:+1:5: +1:65
-          StorageDead(_3);                 // scope 0 at $DIR/issue-101973.rs:+1:64: +1:65
-          _0 = move _2 as i64 (IntToInt);  // scope 0 at $DIR/issue-101973.rs:+1:5: +1:72
-          StorageDead(_2);                 // scope 0 at $DIR/issue-101973.rs:+1:71: +1:72
-          return;                          // scope 0 at $DIR/issue-101973.rs:+2:2: +2:2
+          StorageDead(_6);                 // scope 0 at $DIR/issue_101973.rs:+1:57: +1:58
+          StorageDead(_4);                 // scope 0 at $DIR/issue_101973.rs:+1:57: +1:58
+          _2 = move _3 as i32 (IntToInt);  // scope 0 at $DIR/issue_101973.rs:+1:5: +1:65
+          StorageDead(_3);                 // scope 0 at $DIR/issue_101973.rs:+1:64: +1:65
+          _0 = move _2 as i64 (IntToInt);  // scope 0 at $DIR/issue_101973.rs:+1:5: +1:72
+          StorageDead(_2);                 // scope 0 at $DIR/issue_101973.rs:+1:71: +1:72
+          return;                          // scope 0 at $DIR/issue_101973.rs:+2:2: +2:2
       }
   }
   
diff --git a/src/test/mir-opt/issue-101973.rs b/src/test/mir-opt/issue_101973.rs
similarity index 100%
rename from src/test/mir-opt/issue-101973.rs
rename to src/test/mir-opt/issue_101973.rs
diff --git a/src/test/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir b/src/test/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir
index b13987f7360..82210081832 100644
--- a/src/test/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir
+++ b/src/test/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir
@@ -1,52 +1,52 @@
 // MIR for `main` after SimplifyCfg-initial
 
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue-38669.rs:+0:11: +0:11
-    let mut _1: bool;                    // in scope 0 at $DIR/issue-38669.rs:+1:9: +1:25
-    let mut _2: ();                      // in scope 0 at $DIR/issue-38669.rs:+0:1: +8:2
-    let _3: ();                          // in scope 0 at $DIR/issue-38669.rs:+3:9: +5:10
-    let mut _4: bool;                    // in scope 0 at $DIR/issue-38669.rs:+3:12: +3:24
-    let mut _5: !;                       // in scope 0 at $DIR/issue-38669.rs:+3:25: +5:10
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue_38669.rs:+0:11: +0:11
+    let mut _1: bool;                    // in scope 0 at $DIR/issue_38669.rs:+1:9: +1:25
+    let mut _2: ();                      // in scope 0 at $DIR/issue_38669.rs:+0:1: +8:2
+    let _3: ();                          // in scope 0 at $DIR/issue_38669.rs:+3:9: +5:10
+    let mut _4: bool;                    // in scope 0 at $DIR/issue_38669.rs:+3:12: +3:24
+    let mut _5: !;                       // in scope 0 at $DIR/issue_38669.rs:+3:25: +5:10
     scope 1 {
-        debug should_break => _1;        // in scope 1 at $DIR/issue-38669.rs:+1:9: +1:25
+        debug should_break => _1;        // in scope 1 at $DIR/issue_38669.rs:+1:9: +1:25
     }
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/issue-38669.rs:+1:9: +1:25
-        _1 = const false;                // scope 0 at $DIR/issue-38669.rs:+1:28: +1:33
-        FakeRead(ForLet(None), _1);      // scope 0 at $DIR/issue-38669.rs:+1:9: +1:25
-        goto -> bb1;                     // scope 1 at $DIR/issue-38669.rs:+2:5: +7:6
+        StorageLive(_1);                 // scope 0 at $DIR/issue_38669.rs:+1:9: +1:25
+        _1 = const false;                // scope 0 at $DIR/issue_38669.rs:+1:28: +1:33
+        FakeRead(ForLet(None), _1);      // scope 0 at $DIR/issue_38669.rs:+1:9: +1:25
+        goto -> bb1;                     // scope 1 at $DIR/issue_38669.rs:+2:5: +7:6
     }
 
     bb1: {
-        falseUnwind -> [real: bb2, cleanup: bb5]; // scope 1 at $DIR/issue-38669.rs:+2:5: +7:6
+        falseUnwind -> [real: bb2, cleanup: bb5]; // scope 1 at $DIR/issue_38669.rs:+2:5: +7:6
     }
 
     bb2: {
-        StorageLive(_3);                 // scope 1 at $DIR/issue-38669.rs:+3:9: +5:10
-        StorageLive(_4);                 // scope 1 at $DIR/issue-38669.rs:+3:12: +3:24
-        _4 = _1;                         // scope 1 at $DIR/issue-38669.rs:+3:12: +3:24
-        switchInt(move _4) -> [false: bb4, otherwise: bb3]; // scope 1 at $DIR/issue-38669.rs:+3:12: +3:24
+        StorageLive(_3);                 // scope 1 at $DIR/issue_38669.rs:+3:9: +5:10
+        StorageLive(_4);                 // scope 1 at $DIR/issue_38669.rs:+3:12: +3:24
+        _4 = _1;                         // scope 1 at $DIR/issue_38669.rs:+3:12: +3:24
+        switchInt(move _4) -> [false: bb4, otherwise: bb3]; // scope 1 at $DIR/issue_38669.rs:+3:12: +3:24
     }
 
     bb3: {
-        _0 = const ();                   // scope 1 at $DIR/issue-38669.rs:+4:13: +4:18
-        StorageDead(_4);                 // scope 1 at $DIR/issue-38669.rs:+5:9: +5:10
-        StorageDead(_3);                 // scope 1 at $DIR/issue-38669.rs:+5:9: +5:10
-        StorageDead(_1);                 // scope 0 at $DIR/issue-38669.rs:+8:1: +8:2
-        return;                          // scope 0 at $DIR/issue-38669.rs:+8:2: +8:2
+        _0 = const ();                   // scope 1 at $DIR/issue_38669.rs:+4:13: +4:18
+        StorageDead(_4);                 // scope 1 at $DIR/issue_38669.rs:+5:9: +5:10
+        StorageDead(_3);                 // scope 1 at $DIR/issue_38669.rs:+5:9: +5:10
+        StorageDead(_1);                 // scope 0 at $DIR/issue_38669.rs:+8:1: +8:2
+        return;                          // scope 0 at $DIR/issue_38669.rs:+8:2: +8:2
     }
 
     bb4: {
-        _3 = const ();                   // scope 1 at $DIR/issue-38669.rs:+5:10: +5:10
-        StorageDead(_4);                 // scope 1 at $DIR/issue-38669.rs:+5:9: +5:10
-        StorageDead(_3);                 // scope 1 at $DIR/issue-38669.rs:+5:9: +5:10
-        _1 = const true;                 // scope 1 at $DIR/issue-38669.rs:+6:9: +6:28
-        _2 = const ();                   // scope 1 at $DIR/issue-38669.rs:+2:10: +7:6
-        goto -> bb1;                     // scope 1 at $DIR/issue-38669.rs:+2:5: +7:6
+        _3 = const ();                   // scope 1 at $DIR/issue_38669.rs:+5:10: +5:10
+        StorageDead(_4);                 // scope 1 at $DIR/issue_38669.rs:+5:9: +5:10
+        StorageDead(_3);                 // scope 1 at $DIR/issue_38669.rs:+5:9: +5:10
+        _1 = const true;                 // scope 1 at $DIR/issue_38669.rs:+6:9: +6:28
+        _2 = const ();                   // scope 1 at $DIR/issue_38669.rs:+2:10: +7:6
+        goto -> bb1;                     // scope 1 at $DIR/issue_38669.rs:+2:5: +7:6
     }
 
     bb5 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-38669.rs:+0:1: +8:2
+        resume;                          // scope 0 at $DIR/issue_38669.rs:+0:1: +8:2
     }
 }
diff --git a/src/test/mir-opt/issue-38669.rs b/src/test/mir-opt/issue_38669.rs
similarity index 100%
rename from src/test/mir-opt/issue-38669.rs
rename to src/test/mir-opt/issue_38669.rs
diff --git a/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir
index 1d7cb91d6a7..c573ad5a8e4 100644
--- a/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir
+++ b/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir
@@ -1,70 +1,70 @@
 // MIR for `main` after ElaborateDrops
 
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue-41110.rs:+0:11: +0:11
-    let _1: ();                          // in scope 0 at $DIR/issue-41110.rs:+1:9: +1:10
-    let mut _2: S;                       // in scope 0 at $DIR/issue-41110.rs:+1:13: +1:14
-    let mut _3: S;                       // in scope 0 at $DIR/issue-41110.rs:+1:21: +1:27
-    let mut _4: S;                       // in scope 0 at $DIR/issue-41110.rs:+1:21: +1:22
-    let mut _5: bool;                    // in scope 0 at $DIR/issue-41110.rs:+1:27: +1:28
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue_41110.rs:+0:11: +0:11
+    let _1: ();                          // in scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
+    let mut _2: S;                       // in scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
+    let mut _3: S;                       // in scope 0 at $DIR/issue_41110.rs:+1:21: +1:27
+    let mut _4: S;                       // in scope 0 at $DIR/issue_41110.rs:+1:21: +1:22
+    let mut _5: bool;                    // in scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
     scope 1 {
-        debug x => _1;                   // in scope 1 at $DIR/issue-41110.rs:+1:9: +1:10
+        debug x => _1;                   // in scope 1 at $DIR/issue_41110.rs:+1:9: +1:10
     }
 
     bb0: {
-        _5 = const false;                // scope 0 at $DIR/issue-41110.rs:+1:9: +1:10
-        StorageLive(_1);                 // scope 0 at $DIR/issue-41110.rs:+1:9: +1:10
-        StorageLive(_2);                 // scope 0 at $DIR/issue-41110.rs:+1:13: +1:14
-        _5 = const true;                 // scope 0 at $DIR/issue-41110.rs:+1:13: +1:14
-        _2 = S;                          // scope 0 at $DIR/issue-41110.rs:+1:13: +1:14
-        StorageLive(_3);                 // scope 0 at $DIR/issue-41110.rs:+1:21: +1:27
-        StorageLive(_4);                 // scope 0 at $DIR/issue-41110.rs:+1:21: +1:22
-        _4 = S;                          // scope 0 at $DIR/issue-41110.rs:+1:21: +1:22
-        _3 = S::id(move _4) -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue-41110.rs:+1:21: +1:27
+        _5 = const false;                // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
+        StorageLive(_1);                 // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
+        StorageLive(_2);                 // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
+        _5 = const true;                 // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
+        _2 = S;                          // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
+        StorageLive(_3);                 // scope 0 at $DIR/issue_41110.rs:+1:21: +1:27
+        StorageLive(_4);                 // scope 0 at $DIR/issue_41110.rs:+1:21: +1:22
+        _4 = S;                          // scope 0 at $DIR/issue_41110.rs:+1:21: +1:22
+        _3 = S::id(move _4) -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue_41110.rs:+1:21: +1:27
                                          // mir::Constant
-                                         // + span: $DIR/issue-41110.rs:8:23: 8:25
+                                         // + span: $DIR/issue_41110.rs:8:23: 8:25
                                          // + literal: Const { ty: fn(S) -> S {S::id}, val: Value() }
     }
 
     bb1: {
-        StorageDead(_4);                 // scope 0 at $DIR/issue-41110.rs:+1:26: +1:27
-        _5 = const false;                // scope 0 at $DIR/issue-41110.rs:+1:13: +1:28
-        _1 = S::other(move _2, move _3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/issue-41110.rs:+1:13: +1:28
+        StorageDead(_4);                 // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27
+        _5 = const false;                // scope 0 at $DIR/issue_41110.rs:+1:13: +1:28
+        _1 = S::other(move _2, move _3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:28
                                          // mir::Constant
-                                         // + span: $DIR/issue-41110.rs:8:15: 8:20
+                                         // + span: $DIR/issue_41110.rs:8:15: 8:20
                                          // + literal: Const { ty: fn(S, S) {S::other}, val: Value() }
     }
 
     bb2: {
-        StorageDead(_3);                 // scope 0 at $DIR/issue-41110.rs:+1:27: +1:28
-        _5 = const false;                // scope 0 at $DIR/issue-41110.rs:+1:27: +1:28
-        StorageDead(_2);                 // scope 0 at $DIR/issue-41110.rs:+1:27: +1:28
-        _0 = const ();                   // scope 0 at $DIR/issue-41110.rs:+0:11: +2:2
-        StorageDead(_1);                 // scope 0 at $DIR/issue-41110.rs:+2:1: +2:2
-        return;                          // scope 0 at $DIR/issue-41110.rs:+2:2: +2:2
+        StorageDead(_3);                 // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
+        _5 = const false;                // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
+        StorageDead(_2);                 // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
+        _0 = const ();                   // scope 0 at $DIR/issue_41110.rs:+0:11: +2:2
+        StorageDead(_1);                 // scope 0 at $DIR/issue_41110.rs:+2:1: +2:2
+        return;                          // scope 0 at $DIR/issue_41110.rs:+2:2: +2:2
     }
 
     bb3 (cleanup): {
-        goto -> bb5;                     // scope 0 at $DIR/issue-41110.rs:+1:27: +1:28
+        goto -> bb5;                     // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
     }
 
     bb4 (cleanup): {
-        goto -> bb5;                     // scope 0 at $DIR/issue-41110.rs:+1:26: +1:27
+        goto -> bb5;                     // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27
     }
 
     bb5 (cleanup): {
-        goto -> bb8;                     // scope 0 at $DIR/issue-41110.rs:+1:27: +1:28
+        goto -> bb8;                     // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
     }
 
     bb6 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-41110.rs:+0:1: +2:2
+        resume;                          // scope 0 at $DIR/issue_41110.rs:+0:1: +2:2
     }
 
     bb7 (cleanup): {
-        drop(_2) -> bb6;                 // scope 0 at $DIR/issue-41110.rs:+1:27: +1:28
+        drop(_2) -> bb6;                 // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
     }
 
     bb8 (cleanup): {
-        switchInt(_5) -> [false: bb6, otherwise: bb7]; // scope 0 at $DIR/issue-41110.rs:+1:27: +1:28
+        switchInt(_5) -> [false: bb6, otherwise: bb7]; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
     }
 }
diff --git a/src/test/mir-opt/issue-41110.rs b/src/test/mir-opt/issue_41110.rs
similarity index 100%
rename from src/test/mir-opt/issue-41110.rs
rename to src/test/mir-opt/issue_41110.rs
diff --git a/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir b/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir
index b0e3496b2c8..470b0323281 100644
--- a/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir
+++ b/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir
@@ -1,101 +1,101 @@
 // MIR for `test` after ElaborateDrops
 
 fn test() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue-41110.rs:+0:15: +0:15
-    let _1: S;                           // in scope 0 at $DIR/issue-41110.rs:+1:9: +1:10
-    let _3: ();                          // in scope 0 at $DIR/issue-41110.rs:+3:5: +3:12
-    let mut _4: S;                       // in scope 0 at $DIR/issue-41110.rs:+3:10: +3:11
-    let mut _5: S;                       // in scope 0 at $DIR/issue-41110.rs:+4:9: +4:10
-    let mut _6: bool;                    // in scope 0 at $DIR/issue-41110.rs:+5:1: +5:2
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue_41110.rs:+0:15: +0:15
+    let _1: S;                           // in scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
+    let _3: ();                          // in scope 0 at $DIR/issue_41110.rs:+3:5: +3:12
+    let mut _4: S;                       // in scope 0 at $DIR/issue_41110.rs:+3:10: +3:11
+    let mut _5: S;                       // in scope 0 at $DIR/issue_41110.rs:+4:9: +4:10
+    let mut _6: bool;                    // in scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
     scope 1 {
-        debug u => _1;                   // in scope 1 at $DIR/issue-41110.rs:+1:9: +1:10
-        let mut _2: S;                   // in scope 1 at $DIR/issue-41110.rs:+2:9: +2:14
+        debug u => _1;                   // in scope 1 at $DIR/issue_41110.rs:+1:9: +1:10
+        let mut _2: S;                   // in scope 1 at $DIR/issue_41110.rs:+2:9: +2:14
         scope 2 {
-            debug v => _2;               // in scope 2 at $DIR/issue-41110.rs:+2:9: +2:14
+            debug v => _2;               // in scope 2 at $DIR/issue_41110.rs:+2:9: +2:14
         }
     }
 
     bb0: {
-        _6 = const false;                // scope 0 at $DIR/issue-41110.rs:+1:9: +1:10
-        StorageLive(_1);                 // scope 0 at $DIR/issue-41110.rs:+1:9: +1:10
-        _6 = const true;                 // scope 0 at $DIR/issue-41110.rs:+1:13: +1:14
-        _1 = S;                          // scope 0 at $DIR/issue-41110.rs:+1:13: +1:14
-        StorageLive(_2);                 // scope 1 at $DIR/issue-41110.rs:+2:9: +2:14
-        _2 = S;                          // scope 1 at $DIR/issue-41110.rs:+2:17: +2:18
-        StorageLive(_3);                 // scope 2 at $DIR/issue-41110.rs:+3:5: +3:12
-        StorageLive(_4);                 // scope 2 at $DIR/issue-41110.rs:+3:10: +3:11
-        _4 = move _2;                    // scope 2 at $DIR/issue-41110.rs:+3:10: +3:11
-        _3 = std::mem::drop::(move _4) -> [return: bb1, unwind: bb7]; // scope 2 at $DIR/issue-41110.rs:+3:5: +3:12
+        _6 = const false;                // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
+        StorageLive(_1);                 // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
+        _6 = const true;                 // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
+        _1 = S;                          // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
+        StorageLive(_2);                 // scope 1 at $DIR/issue_41110.rs:+2:9: +2:14
+        _2 = S;                          // scope 1 at $DIR/issue_41110.rs:+2:17: +2:18
+        StorageLive(_3);                 // scope 2 at $DIR/issue_41110.rs:+3:5: +3:12
+        StorageLive(_4);                 // scope 2 at $DIR/issue_41110.rs:+3:10: +3:11
+        _4 = move _2;                    // scope 2 at $DIR/issue_41110.rs:+3:10: +3:11
+        _3 = std::mem::drop::(move _4) -> [return: bb1, unwind: bb7]; // scope 2 at $DIR/issue_41110.rs:+3:5: +3:12
                                          // mir::Constant
-                                         // + span: $DIR/issue-41110.rs:17:5: 17:9
+                                         // + span: $DIR/issue_41110.rs:17:5: 17:9
                                          // + literal: Const { ty: fn(S) {std::mem::drop::}, val: Value() }
     }
 
     bb1: {
-        StorageDead(_4);                 // scope 2 at $DIR/issue-41110.rs:+3:11: +3:12
-        StorageDead(_3);                 // scope 2 at $DIR/issue-41110.rs:+3:12: +3:13
-        StorageLive(_5);                 // scope 2 at $DIR/issue-41110.rs:+4:9: +4:10
-        _6 = const false;                // scope 2 at $DIR/issue-41110.rs:+4:9: +4:10
-        _5 = move _1;                    // scope 2 at $DIR/issue-41110.rs:+4:9: +4:10
-        goto -> bb12;                    // scope 2 at $DIR/issue-41110.rs:+4:5: +4:6
+        StorageDead(_4);                 // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12
+        StorageDead(_3);                 // scope 2 at $DIR/issue_41110.rs:+3:12: +3:13
+        StorageLive(_5);                 // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
+        _6 = const false;                // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
+        _5 = move _1;                    // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
+        goto -> bb12;                    // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
     }
 
     bb2: {
-        goto -> bb3;                     // scope 2 at $DIR/issue-41110.rs:+4:9: +4:10
+        goto -> bb3;                     // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
     }
 
     bb3: {
-        StorageDead(_5);                 // scope 2 at $DIR/issue-41110.rs:+4:9: +4:10
-        _0 = const ();                   // scope 0 at $DIR/issue-41110.rs:+0:15: +5:2
-        drop(_2) -> [return: bb4, unwind: bb9]; // scope 1 at $DIR/issue-41110.rs:+5:1: +5:2
+        StorageDead(_5);                 // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
+        _0 = const ();                   // scope 0 at $DIR/issue_41110.rs:+0:15: +5:2
+        drop(_2) -> [return: bb4, unwind: bb9]; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
     }
 
     bb4: {
-        StorageDead(_2);                 // scope 1 at $DIR/issue-41110.rs:+5:1: +5:2
-        goto -> bb5;                     // scope 0 at $DIR/issue-41110.rs:+5:1: +5:2
+        StorageDead(_2);                 // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
+        goto -> bb5;                     // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
     }
 
     bb5: {
-        _6 = const false;                // scope 0 at $DIR/issue-41110.rs:+5:1: +5:2
-        StorageDead(_1);                 // scope 0 at $DIR/issue-41110.rs:+5:1: +5:2
-        return;                          // scope 0 at $DIR/issue-41110.rs:+5:2: +5:2
+        _6 = const false;                // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
+        StorageDead(_1);                 // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
+        return;                          // scope 0 at $DIR/issue_41110.rs:+5:2: +5:2
     }
 
     bb6 (cleanup): {
-        goto -> bb8;                     // scope 2 at $DIR/issue-41110.rs:+4:9: +4:10
+        goto -> bb8;                     // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
     }
 
     bb7 (cleanup): {
-        goto -> bb8;                     // scope 2 at $DIR/issue-41110.rs:+3:11: +3:12
+        goto -> bb8;                     // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12
     }
 
     bb8 (cleanup): {
-        goto -> bb9;                     // scope 1 at $DIR/issue-41110.rs:+5:1: +5:2
+        goto -> bb9;                     // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
     }
 
     bb9 (cleanup): {
-        goto -> bb14;                    // scope 0 at $DIR/issue-41110.rs:+5:1: +5:2
+        goto -> bb14;                    // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
     }
 
     bb10 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-41110.rs:+0:1: +5:2
+        resume;                          // scope 0 at $DIR/issue_41110.rs:+0:1: +5:2
     }
 
     bb11 (cleanup): {
-        _2 = move _5;                    // scope 2 at $DIR/issue-41110.rs:+4:5: +4:6
-        goto -> bb6;                     // scope 2 at $DIR/issue-41110.rs:+4:5: +4:6
+        _2 = move _5;                    // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
+        goto -> bb6;                     // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
     }
 
     bb12: {
-        _2 = move _5;                    // scope 2 at $DIR/issue-41110.rs:+4:5: +4:6
-        goto -> bb2;                     // scope 2 at $DIR/issue-41110.rs:+4:5: +4:6
+        _2 = move _5;                    // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
+        goto -> bb2;                     // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
     }
 
     bb13 (cleanup): {
-        drop(_1) -> bb10;                // scope 0 at $DIR/issue-41110.rs:+5:1: +5:2
+        drop(_1) -> bb10;                // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
     }
 
     bb14 (cleanup): {
-        switchInt(_6) -> [false: bb10, otherwise: bb13]; // scope 0 at $DIR/issue-41110.rs:+5:1: +5:2
+        switchInt(_6) -> [false: bb10, otherwise: bb13]; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
     }
 }
diff --git a/src/test/mir-opt/issue-41697.rs b/src/test/mir-opt/issue_41697.rs
similarity index 100%
rename from src/test/mir-opt/issue-41697.rs
rename to src/test/mir-opt/issue_41697.rs
diff --git a/src/test/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir b/src/test/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir
index 047b24db466..8af087d84f1 100644
--- a/src/test/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir
+++ b/src/test/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir
@@ -1,20 +1,20 @@
-// MIR for `::{constant#0}` after SimplifyCfg-promote-consts
+// MIR for `::{constant#0}` after SimplifyCfg-promote-consts
 
-::{constant#0}: usize = {
-    let mut _0: usize;                   // return place in scope 0 at $DIR/issue-41697.rs:+0:19: +0:22
-    let mut _1: (usize, bool);           // in scope 0 at $DIR/issue-41697.rs:+0:19: +0:22
+::{constant#0}: usize = {
+    let mut _0: usize;                   // return place in scope 0 at $DIR/issue_41697.rs:+0:19: +0:22
+    let mut _1: (usize, bool);           // in scope 0 at $DIR/issue_41697.rs:+0:19: +0:22
 
     bb0: {
-        _1 = CheckedAdd(const 1_usize, const 1_usize); // scope 0 at $DIR/issue-41697.rs:+0:19: +0:22
-        assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_usize, const 1_usize) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue-41697.rs:+0:19: +0:22
+        _1 = CheckedAdd(const 1_usize, const 1_usize); // scope 0 at $DIR/issue_41697.rs:+0:19: +0:22
+        assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_usize, const 1_usize) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue_41697.rs:+0:19: +0:22
     }
 
     bb1: {
-        _0 = move (_1.0: usize);         // scope 0 at $DIR/issue-41697.rs:+0:19: +0:22
-        return;                          // scope 0 at $DIR/issue-41697.rs:+0:19: +0:22
+        _0 = move (_1.0: usize);         // scope 0 at $DIR/issue_41697.rs:+0:19: +0:22
+        return;                          // scope 0 at $DIR/issue_41697.rs:+0:19: +0:22
     }
 
     bb2 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-41697.rs:+0:19: +0:22
+        resume;                          // scope 0 at $DIR/issue_41697.rs:+0:19: +0:22
     }
 }
diff --git a/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir
index f95a0a1c013..73372c97bea 100644
--- a/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir
+++ b/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir
@@ -1,152 +1,152 @@
 // MIR for `main` after ElaborateDrops
 
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue-41888.rs:+0:11: +0:11
-    let _1: E;                           // in scope 0 at $DIR/issue-41888.rs:+1:9: +1:10
-    let mut _2: bool;                    // in scope 0 at $DIR/issue-41888.rs:+2:8: +2:14
-    let mut _3: E;                       // in scope 0 at $DIR/issue-41888.rs:+3:13: +3:20
-    let mut _4: K;                       // in scope 0 at $DIR/issue-41888.rs:+3:18: +3:19
-    let mut _5: isize;                   // in scope 0 at $DIR/issue-41888.rs:+4:16: +4:24
-    let mut _7: bool;                    // in scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
-    let mut _8: bool;                    // in scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
-    let mut _9: bool;                    // in scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
-    let mut _10: isize;                  // in scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
-    let mut _11: isize;                  // in scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue_41888.rs:+0:11: +0:11
+    let _1: E;                           // in scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
+    let mut _2: bool;                    // in scope 0 at $DIR/issue_41888.rs:+2:8: +2:14
+    let mut _3: E;                       // in scope 0 at $DIR/issue_41888.rs:+3:13: +3:20
+    let mut _4: K;                       // in scope 0 at $DIR/issue_41888.rs:+3:18: +3:19
+    let mut _5: isize;                   // in scope 0 at $DIR/issue_41888.rs:+4:16: +4:24
+    let mut _7: bool;                    // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+    let mut _8: bool;                    // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+    let mut _9: bool;                    // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+    let mut _10: isize;                  // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+    let mut _11: isize;                  // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
     scope 1 {
-        debug e => _1;                   // in scope 1 at $DIR/issue-41888.rs:+1:9: +1:10
+        debug e => _1;                   // in scope 1 at $DIR/issue_41888.rs:+1:9: +1:10
         scope 2 {
-            debug _k => _6;              // in scope 2 at $DIR/issue-41888.rs:+4:21: +4:23
-            let _6: K;                   // in scope 2 at $DIR/issue-41888.rs:+4:21: +4:23
+            debug _k => _6;              // in scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
+            let _6: K;                   // in scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
         }
     }
 
     bb0: {
-        _9 = const false;                // scope 0 at $DIR/issue-41888.rs:+1:9: +1:10
-        _7 = const false;                // scope 0 at $DIR/issue-41888.rs:+1:9: +1:10
-        _8 = const false;                // scope 0 at $DIR/issue-41888.rs:+1:9: +1:10
-        StorageLive(_1);                 // scope 0 at $DIR/issue-41888.rs:+1:9: +1:10
-        StorageLive(_2);                 // scope 1 at $DIR/issue-41888.rs:+2:8: +2:14
-        _2 = cond() -> [return: bb1, unwind: bb11]; // scope 1 at $DIR/issue-41888.rs:+2:8: +2:14
+        _9 = const false;                // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
+        _7 = const false;                // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
+        _8 = const false;                // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
+        StorageLive(_1);                 // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
+        StorageLive(_2);                 // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14
+        _2 = cond() -> [return: bb1, unwind: bb11]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14
                                          // mir::Constant
-                                         // + span: $DIR/issue-41888.rs:8:8: 8:12
+                                         // + span: $DIR/issue_41888.rs:8:8: 8:12
                                          // + literal: Const { ty: fn() -> bool {cond}, val: Value() }
     }
 
     bb1: {
-        switchInt(move _2) -> [false: bb7, otherwise: bb2]; // scope 1 at $DIR/issue-41888.rs:+2:8: +2:14
+        switchInt(move _2) -> [false: bb7, otherwise: bb2]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14
     }
 
     bb2: {
-        StorageLive(_3);                 // scope 1 at $DIR/issue-41888.rs:+3:13: +3:20
-        StorageLive(_4);                 // scope 1 at $DIR/issue-41888.rs:+3:18: +3:19
-        _4 = K;                          // scope 1 at $DIR/issue-41888.rs:+3:18: +3:19
-        _3 = E::F(move _4);              // scope 1 at $DIR/issue-41888.rs:+3:13: +3:20
-        StorageDead(_4);                 // scope 1 at $DIR/issue-41888.rs:+3:19: +3:20
-        goto -> bb14;                    // scope 1 at $DIR/issue-41888.rs:+3:9: +3:10
+        StorageLive(_3);                 // scope 1 at $DIR/issue_41888.rs:+3:13: +3:20
+        StorageLive(_4);                 // scope 1 at $DIR/issue_41888.rs:+3:18: +3:19
+        _4 = K;                          // scope 1 at $DIR/issue_41888.rs:+3:18: +3:19
+        _3 = E::F(move _4);              // scope 1 at $DIR/issue_41888.rs:+3:13: +3:20
+        StorageDead(_4);                 // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
+        goto -> bb14;                    // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
     }
 
     bb3: {
-        goto -> bb4;                     // scope 1 at $DIR/issue-41888.rs:+3:19: +3:20
+        goto -> bb4;                     // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
     }
 
     bb4: {
-        StorageDead(_3);                 // scope 1 at $DIR/issue-41888.rs:+3:19: +3:20
-        _5 = discriminant(_1);           // scope 2 at $DIR/issue-41888.rs:+4:16: +4:24
-        switchInt(move _5) -> [0_isize: bb5, otherwise: bb6]; // scope 2 at $DIR/issue-41888.rs:+4:16: +4:24
+        StorageDead(_3);                 // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
+        _5 = discriminant(_1);           // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24
+        switchInt(move _5) -> [0_isize: bb5, otherwise: bb6]; // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24
     }
 
     bb5: {
-        StorageLive(_6);                 // scope 2 at $DIR/issue-41888.rs:+4:21: +4:23
-        _9 = const false;                // scope 2 at $DIR/issue-41888.rs:+4:21: +4:23
-        _6 = move ((_1 as F).0: K);      // scope 2 at $DIR/issue-41888.rs:+4:21: +4:23
-        _0 = const ();                   // scope 2 at $DIR/issue-41888.rs:+4:29: +7:10
-        StorageDead(_6);                 // scope 1 at $DIR/issue-41888.rs:+7:9: +7:10
-        goto -> bb8;                     // scope 1 at $DIR/issue-41888.rs:+4:9: +7:10
+        StorageLive(_6);                 // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
+        _9 = const false;                // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
+        _6 = move ((_1 as F).0: K);      // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
+        _0 = const ();                   // scope 2 at $DIR/issue_41888.rs:+4:29: +7:10
+        StorageDead(_6);                 // scope 1 at $DIR/issue_41888.rs:+7:9: +7:10
+        goto -> bb8;                     // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10
     }
 
     bb6: {
-        _0 = const ();                   // scope 1 at $DIR/issue-41888.rs:+7:10: +7:10
-        goto -> bb8;                     // scope 1 at $DIR/issue-41888.rs:+4:9: +7:10
+        _0 = const ();                   // scope 1 at $DIR/issue_41888.rs:+7:10: +7:10
+        goto -> bb8;                     // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10
     }
 
     bb7: {
-        _0 = const ();                   // scope 1 at $DIR/issue-41888.rs:+8:6: +8:6
-        goto -> bb8;                     // scope 1 at $DIR/issue-41888.rs:+2:5: +8:6
+        _0 = const ();                   // scope 1 at $DIR/issue_41888.rs:+8:6: +8:6
+        goto -> bb8;                     // scope 1 at $DIR/issue_41888.rs:+2:5: +8:6
     }
 
     bb8: {
-        StorageDead(_2);                 // scope 1 at $DIR/issue-41888.rs:+8:5: +8:6
-        goto -> bb20;                    // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
+        StorageDead(_2);                 // scope 1 at $DIR/issue_41888.rs:+8:5: +8:6
+        goto -> bb20;                    // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
     }
 
     bb9: {
-        _7 = const false;                // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
-        _8 = const false;                // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
-        _9 = const false;                // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
-        StorageDead(_1);                 // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
-        return;                          // scope 0 at $DIR/issue-41888.rs:+9:2: +9:2
+        _7 = const false;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+        _8 = const false;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+        _9 = const false;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+        StorageDead(_1);                 // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+        return;                          // scope 0 at $DIR/issue_41888.rs:+9:2: +9:2
     }
 
     bb10 (cleanup): {
-        goto -> bb11;                    // scope 1 at $DIR/issue-41888.rs:+3:19: +3:20
+        goto -> bb11;                    // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
     }
 
     bb11 (cleanup): {
-        goto -> bb12;                    // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
+        goto -> bb12;                    // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
     }
 
     bb12 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-41888.rs:+0:1: +9:2
+        resume;                          // scope 0 at $DIR/issue_41888.rs:+0:1: +9:2
     }
 
     bb13 (cleanup): {
-        _7 = const true;                 // scope 1 at $DIR/issue-41888.rs:+3:9: +3:10
-        _8 = const true;                 // scope 1 at $DIR/issue-41888.rs:+3:9: +3:10
-        _9 = const true;                 // scope 1 at $DIR/issue-41888.rs:+3:9: +3:10
-        _1 = move _3;                    // scope 1 at $DIR/issue-41888.rs:+3:9: +3:10
-        goto -> bb10;                    // scope 1 at $DIR/issue-41888.rs:+3:9: +3:10
+        _7 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
+        _8 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
+        _9 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
+        _1 = move _3;                    // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
+        goto -> bb10;                    // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
     }
 
     bb14: {
-        _7 = const true;                 // scope 1 at $DIR/issue-41888.rs:+3:9: +3:10
-        _8 = const true;                 // scope 1 at $DIR/issue-41888.rs:+3:9: +3:10
-        _9 = const true;                 // scope 1 at $DIR/issue-41888.rs:+3:9: +3:10
-        _1 = move _3;                    // scope 1 at $DIR/issue-41888.rs:+3:9: +3:10
-        goto -> bb3;                     // scope 1 at $DIR/issue-41888.rs:+3:9: +3:10
+        _7 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
+        _8 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
+        _9 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
+        _1 = move _3;                    // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
+        goto -> bb3;                     // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
     }
 
     bb15: {
-        _7 = const false;                // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
-        goto -> bb9;                     // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
+        _7 = const false;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+        goto -> bb9;                     // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
     }
 
     bb16 (cleanup): {
-        goto -> bb12;                    // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
+        goto -> bb12;                    // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
     }
 
     bb17: {
-        drop(_1) -> [return: bb15, unwind: bb12]; // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
+        drop(_1) -> [return: bb15, unwind: bb12]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
     }
 
     bb18 (cleanup): {
-        drop(_1) -> bb12;                // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
+        drop(_1) -> bb12;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
     }
 
     bb19: {
-        _10 = discriminant(_1);          // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
-        switchInt(move _10) -> [0_isize: bb15, otherwise: bb17]; // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
+        _10 = discriminant(_1);          // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+        switchInt(move _10) -> [0_isize: bb15, otherwise: bb17]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
     }
 
     bb20: {
-        switchInt(_7) -> [false: bb15, otherwise: bb19]; // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
+        switchInt(_7) -> [false: bb15, otherwise: bb19]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
     }
 
     bb21 (cleanup): {
-        _11 = discriminant(_1);          // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
-        switchInt(move _11) -> [0_isize: bb16, otherwise: bb18]; // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
+        _11 = discriminant(_1);          // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+        switchInt(move _11) -> [0_isize: bb16, otherwise: bb18]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
     }
 
     bb22 (cleanup): {
-        switchInt(_7) -> [false: bb12, otherwise: bb21]; // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2
+        switchInt(_7) -> [false: bb12, otherwise: bb21]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
     }
 }
diff --git a/src/test/mir-opt/issue-41888.rs b/src/test/mir-opt/issue_41888.rs
similarity index 100%
rename from src/test/mir-opt/issue-41888.rs
rename to src/test/mir-opt/issue_41888.rs
diff --git a/src/test/mir-opt/issue-62289.rs b/src/test/mir-opt/issue_62289.rs
similarity index 100%
rename from src/test/mir-opt/issue-62289.rs
rename to src/test/mir-opt/issue_62289.rs
diff --git a/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir b/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir
index 72603dc5dbe..6969a66ac19 100644
--- a/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir
+++ b/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir
@@ -1,122 +1,122 @@
 // MIR for `test` before ElaborateDrops
 
 fn test() -> Option> {
-    let mut _0: std::option::Option>; // return place in scope 0 at $DIR/issue-62289.rs:+0:14: +0:30
-    let mut _1: std::boxed::Box;    // in scope 0 at $DIR/issue-62289.rs:+1:10: +1:21
-    let mut _2: usize;                   // in scope 0 at $DIR/issue-62289.rs:+1:10: +1:21
-    let mut _3: usize;                   // in scope 0 at $DIR/issue-62289.rs:+1:10: +1:21
-    let mut _4: *mut u8;                 // in scope 0 at $DIR/issue-62289.rs:+1:10: +1:21
-    let mut _5: std::boxed::Box;    // in scope 0 at $DIR/issue-62289.rs:+1:10: +1:21
-    let mut _6: std::ops::ControlFlow, u32>; // in scope 0 at $DIR/issue-62289.rs:+1:15: +1:20
-    let mut _7: std::option::Option; // in scope 0 at $DIR/issue-62289.rs:+1:15: +1:19
-    let mut _8: isize;                   // in scope 0 at $DIR/issue-62289.rs:+1:19: +1:20
-    let _9: std::option::Option; // in scope 0 at $DIR/issue-62289.rs:+1:19: +1:20
-    let mut _10: !;                      // in scope 0 at $DIR/issue-62289.rs:+1:19: +1:20
-    let mut _11: std::option::Option; // in scope 0 at $DIR/issue-62289.rs:+1:19: +1:20
-    let _12: u32;                        // in scope 0 at $DIR/issue-62289.rs:+1:15: +1:20
+    let mut _0: std::option::Option>; // return place in scope 0 at $DIR/issue_62289.rs:+0:14: +0:30
+    let mut _1: std::boxed::Box;    // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
+    let mut _2: usize;                   // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
+    let mut _3: usize;                   // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
+    let mut _4: *mut u8;                 // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
+    let mut _5: std::boxed::Box;    // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
+    let mut _6: std::ops::ControlFlow, u32>; // in scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
+    let mut _7: std::option::Option; // in scope 0 at $DIR/issue_62289.rs:+1:15: +1:19
+    let mut _8: isize;                   // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
+    let _9: std::option::Option; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
+    let mut _10: !;                      // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
+    let mut _11: std::option::Option; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
+    let _12: u32;                        // in scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
     scope 1 {
     }
     scope 2 {
-        debug residual => _9;            // in scope 2 at $DIR/issue-62289.rs:+1:19: +1:20
+        debug residual => _9;            // in scope 2 at $DIR/issue_62289.rs:+1:19: +1:20
         scope 3 {
         }
     }
     scope 4 {
-        debug val => _12;                // in scope 4 at $DIR/issue-62289.rs:+1:15: +1:20
+        debug val => _12;                // in scope 4 at $DIR/issue_62289.rs:+1:15: +1:20
         scope 5 {
         }
     }
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/issue-62289.rs:+1:10: +1:21
-        _2 = SizeOf(u32);                // scope 1 at $DIR/issue-62289.rs:+1:10: +1:21
-        _3 = AlignOf(u32);               // scope 1 at $DIR/issue-62289.rs:+1:10: +1:21
-        _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/issue-62289.rs:+1:10: +1:21
+        StorageLive(_1);                 // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
+        _2 = SizeOf(u32);                // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21
+        _3 = AlignOf(u32);               // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21
+        _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21
                                          // mir::Constant
-                                         // + span: $DIR/issue-62289.rs:9:10: 9:21
+                                         // + span: $DIR/issue_62289.rs:9:10: 9:21
                                          // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value() }
     }
 
     bb1: {
-        StorageLive(_5);                 // scope 0 at $DIR/issue-62289.rs:+1:10: +1:21
-        _5 = ShallowInitBox(move _4, u32); // scope 0 at $DIR/issue-62289.rs:+1:10: +1:21
-        StorageLive(_6);                 // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20
-        StorageLive(_7);                 // scope 0 at $DIR/issue-62289.rs:+1:15: +1:19
-        _7 = Option::::None;        // scope 0 at $DIR/issue-62289.rs:+1:15: +1:19
-        _6 =  as Try>::branch(move _7) -> [return: bb2, unwind: bb12]; // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20
+        StorageLive(_5);                 // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
+        _5 = ShallowInitBox(move _4, u32); // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
+        StorageLive(_6);                 // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
+        StorageLive(_7);                 // scope 0 at $DIR/issue_62289.rs:+1:15: +1:19
+        _7 = Option::::None;        // scope 0 at $DIR/issue_62289.rs:+1:15: +1:19
+        _6 =  as Try>::branch(move _7) -> [return: bb2, unwind: bb12]; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
                                          // mir::Constant
-                                         // + span: $DIR/issue-62289.rs:9:15: 9:20
+                                         // + span: $DIR/issue_62289.rs:9:15: 9:20
                                          // + literal: Const { ty: fn(Option) -> ControlFlow< as Try>::Residual,  as Try>::Output> { as Try>::branch}, val: Value() }
     }
 
     bb2: {
-        StorageDead(_7);                 // scope 0 at $DIR/issue-62289.rs:+1:19: +1:20
-        _8 = discriminant(_6);           // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20
-        switchInt(move _8) -> [0_isize: bb3, 1_isize: bb5, otherwise: bb4]; // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20
+        StorageDead(_7);                 // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
+        _8 = discriminant(_6);           // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
+        switchInt(move _8) -> [0_isize: bb3, 1_isize: bb5, otherwise: bb4]; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
     }
 
     bb3: {
-        StorageLive(_12);                // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20
-        _12 = ((_6 as Continue).0: u32); // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20
-        (*_5) = _12;                     // scope 5 at $DIR/issue-62289.rs:+1:15: +1:20
-        StorageDead(_12);                // scope 0 at $DIR/issue-62289.rs:+1:19: +1:20
-        _1 = move _5;                    // scope 0 at $DIR/issue-62289.rs:+1:10: +1:21
-        drop(_5) -> [return: bb7, unwind: bb11]; // scope 0 at $DIR/issue-62289.rs:+1:20: +1:21
+        StorageLive(_12);                // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
+        _12 = ((_6 as Continue).0: u32); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
+        (*_5) = _12;                     // scope 5 at $DIR/issue_62289.rs:+1:15: +1:20
+        StorageDead(_12);                // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
+        _1 = move _5;                    // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21
+        drop(_5) -> [return: bb7, unwind: bb11]; // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21
     }
 
     bb4: {
-        unreachable;                     // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20
+        unreachable;                     // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20
     }
 
     bb5: {
-        StorageLive(_9);                 // scope 0 at $DIR/issue-62289.rs:+1:19: +1:20
-        _9 = ((_6 as Break).0: std::option::Option); // scope 0 at $DIR/issue-62289.rs:+1:19: +1:20
-        StorageLive(_11);                // scope 3 at $DIR/issue-62289.rs:+1:19: +1:20
-        _11 = _9;                        // scope 3 at $DIR/issue-62289.rs:+1:19: +1:20
-        _0 = > as FromResidual>>::from_residual(move _11) -> [return: bb6, unwind: bb12]; // scope 3 at $DIR/issue-62289.rs:+1:15: +1:20
+        StorageLive(_9);                 // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
+        _9 = ((_6 as Break).0: std::option::Option); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
+        StorageLive(_11);                // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20
+        _11 = _9;                        // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20
+        _0 = > as FromResidual>>::from_residual(move _11) -> [return: bb6, unwind: bb12]; // scope 3 at $DIR/issue_62289.rs:+1:15: +1:20
                                          // mir::Constant
-                                         // + span: $DIR/issue-62289.rs:9:19: 9:20
+                                         // + span: $DIR/issue_62289.rs:9:19: 9:20
                                          // + literal: Const { ty: fn(Option) -> Option> {> as FromResidual>>::from_residual}, val: Value() }
     }
 
     bb6: {
-        StorageDead(_11);                // scope 3 at $DIR/issue-62289.rs:+1:19: +1:20
-        StorageDead(_9);                 // scope 0 at $DIR/issue-62289.rs:+1:19: +1:20
-        drop(_5) -> bb9;                 // scope 0 at $DIR/issue-62289.rs:+1:20: +1:21
+        StorageDead(_11);                // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20
+        StorageDead(_9);                 // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20
+        drop(_5) -> bb9;                 // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21
     }
 
     bb7: {
-        StorageDead(_5);                 // scope 0 at $DIR/issue-62289.rs:+1:20: +1:21
-        _0 = Option::>::Some(move _1); // scope 0 at $DIR/issue-62289.rs:+1:5: +1:22
-        drop(_1) -> bb8;                 // scope 0 at $DIR/issue-62289.rs:+1:21: +1:22
+        StorageDead(_5);                 // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21
+        _0 = Option::>::Some(move _1); // scope 0 at $DIR/issue_62289.rs:+1:5: +1:22
+        drop(_1) -> bb8;                 // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22
     }
 
     bb8: {
-        StorageDead(_1);                 // scope 0 at $DIR/issue-62289.rs:+1:21: +1:22
-        StorageDead(_6);                 // scope 0 at $DIR/issue-62289.rs:+2:1: +2:2
-        goto -> bb10;                    // scope 0 at $DIR/issue-62289.rs:+2:2: +2:2
+        StorageDead(_1);                 // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22
+        StorageDead(_6);                 // scope 0 at $DIR/issue_62289.rs:+2:1: +2:2
+        goto -> bb10;                    // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2
     }
 
     bb9: {
-        StorageDead(_5);                 // scope 0 at $DIR/issue-62289.rs:+1:20: +1:21
-        StorageDead(_1);                 // scope 0 at $DIR/issue-62289.rs:+1:21: +1:22
-        StorageDead(_6);                 // scope 0 at $DIR/issue-62289.rs:+2:1: +2:2
-        goto -> bb10;                    // scope 0 at $DIR/issue-62289.rs:+2:2: +2:2
+        StorageDead(_5);                 // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21
+        StorageDead(_1);                 // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22
+        StorageDead(_6);                 // scope 0 at $DIR/issue_62289.rs:+2:1: +2:2
+        goto -> bb10;                    // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2
     }
 
     bb10: {
-        return;                          // scope 0 at $DIR/issue-62289.rs:+2:2: +2:2
+        return;                          // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2
     }
 
     bb11 (cleanup): {
-        drop(_1) -> bb13;                // scope 0 at $DIR/issue-62289.rs:+1:21: +1:22
+        drop(_1) -> bb13;                // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22
     }
 
     bb12 (cleanup): {
-        drop(_5) -> bb13;                // scope 0 at $DIR/issue-62289.rs:+1:20: +1:21
+        drop(_5) -> bb13;                // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21
     }
 
     bb13 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-62289.rs:+0:1: +2:2
+        resume;                          // scope 0 at $DIR/issue_62289.rs:+0:1: +2:2
     }
 }
diff --git a/src/test/mir-opt/issue_72181.bar.built.after.mir b/src/test/mir-opt/issue_72181.bar.built.after.mir
index aa9c9986aac..ebee89001b9 100644
--- a/src/test/mir-opt/issue_72181.bar.built.after.mir
+++ b/src/test/mir-opt/issue_72181.bar.built.after.mir
@@ -1,17 +1,17 @@
 // MIR for `bar` after built
 
 fn bar(_1: [(Never, u32); 1]) -> u32 {
-    let mut _0: u32;                     // return place in scope 0 at $DIR/issue-72181.rs:+0:40: +0:43
-    let _2: u32;                         // in scope 0 at $DIR/issue-72181.rs:+0:13: +0:14
+    let mut _0: u32;                     // return place in scope 0 at $DIR/issue_72181.rs:+0:40: +0:43
+    let _2: u32;                         // in scope 0 at $DIR/issue_72181.rs:+0:13: +0:14
     scope 1 {
-        debug x => _2;                   // in scope 1 at $DIR/issue-72181.rs:+0:13: +0:14
+        debug x => _2;                   // in scope 1 at $DIR/issue_72181.rs:+0:13: +0:14
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-72181.rs:+0:13: +0:14
-        _2 = (_1[0 of 1].1: u32);        // scope 0 at $DIR/issue-72181.rs:+0:13: +0:14
-        _0 = _2;                         // scope 1 at $DIR/issue-72181.rs:+0:46: +0:47
-        StorageDead(_2);                 // scope 0 at $DIR/issue-72181.rs:+0:48: +0:49
-        return;                          // scope 0 at $DIR/issue-72181.rs:+0:49: +0:49
+        StorageLive(_2);                 // scope 0 at $DIR/issue_72181.rs:+0:13: +0:14
+        _2 = (_1[0 of 1].1: u32);        // scope 0 at $DIR/issue_72181.rs:+0:13: +0:14
+        _0 = _2;                         // scope 1 at $DIR/issue_72181.rs:+0:46: +0:47
+        StorageDead(_2);                 // scope 0 at $DIR/issue_72181.rs:+0:48: +0:49
+        return;                          // scope 0 at $DIR/issue_72181.rs:+0:49: +0:49
     }
 }
diff --git a/src/test/mir-opt/issue_72181.foo.built.after.mir b/src/test/mir-opt/issue_72181.foo.built.after.mir
index 1d771ad3656..90c9785202a 100644
--- a/src/test/mir-opt/issue_72181.foo.built.after.mir
+++ b/src/test/mir-opt/issue_72181.foo.built.after.mir
@@ -1,27 +1,27 @@
 // MIR for `foo` after built
 
 fn foo(_1: [(Never, u32); 1]) -> u32 {
-    debug xs => _1;                      // in scope 0 at $DIR/issue-72181.rs:+0:8: +0:10
-    let mut _0: u32;                     // return place in scope 0 at $DIR/issue-72181.rs:+0:34: +0:37
-    let _2: usize;                       // in scope 0 at $DIR/issue-72181.rs:+0:43: +0:44
-    let mut _3: usize;                   // in scope 0 at $DIR/issue-72181.rs:+0:40: +0:45
-    let mut _4: bool;                    // in scope 0 at $DIR/issue-72181.rs:+0:40: +0:45
+    debug xs => _1;                      // in scope 0 at $DIR/issue_72181.rs:+0:8: +0:10
+    let mut _0: u32;                     // return place in scope 0 at $DIR/issue_72181.rs:+0:34: +0:37
+    let _2: usize;                       // in scope 0 at $DIR/issue_72181.rs:+0:43: +0:44
+    let mut _3: usize;                   // in scope 0 at $DIR/issue_72181.rs:+0:40: +0:45
+    let mut _4: bool;                    // in scope 0 at $DIR/issue_72181.rs:+0:40: +0:45
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-72181.rs:+0:43: +0:44
-        _2 = const 0_usize;              // scope 0 at $DIR/issue-72181.rs:+0:43: +0:44
-        _3 = Len(_1);                    // scope 0 at $DIR/issue-72181.rs:+0:40: +0:45
-        _4 = Lt(_2, _3);                 // scope 0 at $DIR/issue-72181.rs:+0:40: +0:45
-        assert(move _4, "index out of bounds: the length is {} but the index is {}", move _3, _2) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue-72181.rs:+0:40: +0:45
+        StorageLive(_2);                 // scope 0 at $DIR/issue_72181.rs:+0:43: +0:44
+        _2 = const 0_usize;              // scope 0 at $DIR/issue_72181.rs:+0:43: +0:44
+        _3 = Len(_1);                    // scope 0 at $DIR/issue_72181.rs:+0:40: +0:45
+        _4 = Lt(_2, _3);                 // scope 0 at $DIR/issue_72181.rs:+0:40: +0:45
+        assert(move _4, "index out of bounds: the length is {} but the index is {}", move _3, _2) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue_72181.rs:+0:40: +0:45
     }
 
     bb1: {
-        _0 = (_1[_2].1: u32);            // scope 0 at $DIR/issue-72181.rs:+0:40: +0:47
-        StorageDead(_2);                 // scope 0 at $DIR/issue-72181.rs:+0:48: +0:49
-        return;                          // scope 0 at $DIR/issue-72181.rs:+0:49: +0:49
+        _0 = (_1[_2].1: u32);            // scope 0 at $DIR/issue_72181.rs:+0:40: +0:47
+        StorageDead(_2);                 // scope 0 at $DIR/issue_72181.rs:+0:48: +0:49
+        return;                          // scope 0 at $DIR/issue_72181.rs:+0:49: +0:49
     }
 
     bb2 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-72181.rs:+0:1: +0:49
+        resume;                          // scope 0 at $DIR/issue_72181.rs:+0:1: +0:49
     }
 }
diff --git a/src/test/mir-opt/issue_72181.main.built.after.mir b/src/test/mir-opt/issue_72181.main.built.after.mir
index afa09b16fe9..e8683692770 100644
--- a/src/test/mir-opt/issue_72181.main.built.after.mir
+++ b/src/test/mir-opt/issue_72181.main.built.after.mir
@@ -1,18 +1,18 @@
 // MIR for `main` after built
 
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue-72181.rs:+0:11: +0:11
-    let mut _1: usize;                   // in scope 0 at $DIR/issue-72181.rs:+1:13: +1:34
-    let mut _3: Foo;                     // in scope 0 at $DIR/issue-72181.rs:+3:14: +3:27
-    let mut _4: Foo;                     // in scope 0 at $DIR/issue-72181.rs:+3:29: +3:42
-    let mut _5: u64;                     // in scope 0 at $DIR/issue-72181.rs:+4:13: +4:30
-    let _6: usize;                       // in scope 0 at $DIR/issue-72181.rs:+4:24: +4:25
-    let mut _7: usize;                   // in scope 0 at $DIR/issue-72181.rs:+4:22: +4:26
-    let mut _8: bool;                    // in scope 0 at $DIR/issue-72181.rs:+4:22: +4:26
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue_72181.rs:+0:11: +0:11
+    let mut _1: usize;                   // in scope 0 at $DIR/issue_72181.rs:+1:13: +1:34
+    let mut _3: Foo;                     // in scope 0 at $DIR/issue_72181.rs:+3:14: +3:27
+    let mut _4: Foo;                     // in scope 0 at $DIR/issue_72181.rs:+3:29: +3:42
+    let mut _5: u64;                     // in scope 0 at $DIR/issue_72181.rs:+4:13: +4:30
+    let _6: usize;                       // in scope 0 at $DIR/issue_72181.rs:+4:24: +4:25
+    let mut _7: usize;                   // in scope 0 at $DIR/issue_72181.rs:+4:22: +4:26
+    let mut _8: bool;                    // in scope 0 at $DIR/issue_72181.rs:+4:22: +4:26
     scope 1 {
-        let _2: [Foo; 2];                // in scope 1 at $DIR/issue-72181.rs:+3:9: +3:10
+        let _2: [Foo; 2];                // in scope 1 at $DIR/issue_72181.rs:+3:9: +3:10
         scope 2 {
-            debug f => _2;               // in scope 2 at $DIR/issue-72181.rs:+3:9: +3:10
+            debug f => _2;               // in scope 2 at $DIR/issue_72181.rs:+3:9: +3:10
             scope 3 {
             }
             scope 4 {
@@ -21,42 +21,42 @@ fn main() -> () {
     }
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/issue-72181.rs:+1:13: +1:34
-        _1 = std::mem::size_of::() -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue-72181.rs:+1:13: +1:34
+        StorageLive(_1);                 // scope 0 at $DIR/issue_72181.rs:+1:13: +1:34
+        _1 = std::mem::size_of::() -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue_72181.rs:+1:13: +1:34
                                          // mir::Constant
-                                         // + span: $DIR/issue-72181.rs:24:13: 24:32
+                                         // + span: $DIR/issue_72181.rs:24:13: 24:32
                                          // + literal: Const { ty: fn() -> usize {std::mem::size_of::}, val: Value() }
     }
 
     bb1: {
-        StorageDead(_1);                 // scope 0 at $DIR/issue-72181.rs:+1:34: +1:35
-        StorageLive(_2);                 // scope 1 at $DIR/issue-72181.rs:+3:9: +3:10
-        StorageLive(_3);                 // scope 1 at $DIR/issue-72181.rs:+3:14: +3:27
-        _3 = Foo { a: const 42_u64 };    // scope 1 at $DIR/issue-72181.rs:+3:14: +3:27
-        StorageLive(_4);                 // scope 1 at $DIR/issue-72181.rs:+3:29: +3:42
-        _4 = Foo { a: const 10_u64 };    // scope 1 at $DIR/issue-72181.rs:+3:29: +3:42
-        _2 = [move _3, move _4];         // scope 1 at $DIR/issue-72181.rs:+3:13: +3:43
-        StorageDead(_4);                 // scope 1 at $DIR/issue-72181.rs:+3:42: +3:43
-        StorageDead(_3);                 // scope 1 at $DIR/issue-72181.rs:+3:42: +3:43
-        FakeRead(ForLet(None), _2);      // scope 1 at $DIR/issue-72181.rs:+3:9: +3:10
-        StorageLive(_5);                 // scope 2 at $DIR/issue-72181.rs:+4:13: +4:30
-        StorageLive(_6);                 // scope 4 at $DIR/issue-72181.rs:+4:24: +4:25
-        _6 = const 0_usize;              // scope 4 at $DIR/issue-72181.rs:+4:24: +4:25
-        _7 = Len(_2);                    // scope 4 at $DIR/issue-72181.rs:+4:22: +4:26
-        _8 = Lt(_6, _7);                 // scope 4 at $DIR/issue-72181.rs:+4:22: +4:26
-        assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb2, unwind: bb3]; // scope 4 at $DIR/issue-72181.rs:+4:22: +4:26
+        StorageDead(_1);                 // scope 0 at $DIR/issue_72181.rs:+1:34: +1:35
+        StorageLive(_2);                 // scope 1 at $DIR/issue_72181.rs:+3:9: +3:10
+        StorageLive(_3);                 // scope 1 at $DIR/issue_72181.rs:+3:14: +3:27
+        _3 = Foo { a: const 42_u64 };    // scope 1 at $DIR/issue_72181.rs:+3:14: +3:27
+        StorageLive(_4);                 // scope 1 at $DIR/issue_72181.rs:+3:29: +3:42
+        _4 = Foo { a: const 10_u64 };    // scope 1 at $DIR/issue_72181.rs:+3:29: +3:42
+        _2 = [move _3, move _4];         // scope 1 at $DIR/issue_72181.rs:+3:13: +3:43
+        StorageDead(_4);                 // scope 1 at $DIR/issue_72181.rs:+3:42: +3:43
+        StorageDead(_3);                 // scope 1 at $DIR/issue_72181.rs:+3:42: +3:43
+        FakeRead(ForLet(None), _2);      // scope 1 at $DIR/issue_72181.rs:+3:9: +3:10
+        StorageLive(_5);                 // scope 2 at $DIR/issue_72181.rs:+4:13: +4:30
+        StorageLive(_6);                 // scope 4 at $DIR/issue_72181.rs:+4:24: +4:25
+        _6 = const 0_usize;              // scope 4 at $DIR/issue_72181.rs:+4:24: +4:25
+        _7 = Len(_2);                    // scope 4 at $DIR/issue_72181.rs:+4:22: +4:26
+        _8 = Lt(_6, _7);                 // scope 4 at $DIR/issue_72181.rs:+4:22: +4:26
+        assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb2, unwind: bb3]; // scope 4 at $DIR/issue_72181.rs:+4:22: +4:26
     }
 
     bb2: {
-        _5 = (_2[_6].0: u64);            // scope 4 at $DIR/issue-72181.rs:+4:22: +4:28
-        StorageDead(_6);                 // scope 2 at $DIR/issue-72181.rs:+4:30: +4:31
-        StorageDead(_5);                 // scope 2 at $DIR/issue-72181.rs:+4:30: +4:31
-        _0 = const ();                   // scope 0 at $DIR/issue-72181.rs:+0:11: +5:2
-        StorageDead(_2);                 // scope 1 at $DIR/issue-72181.rs:+5:1: +5:2
-        return;                          // scope 0 at $DIR/issue-72181.rs:+5:2: +5:2
+        _5 = (_2[_6].0: u64);            // scope 4 at $DIR/issue_72181.rs:+4:22: +4:28
+        StorageDead(_6);                 // scope 2 at $DIR/issue_72181.rs:+4:30: +4:31
+        StorageDead(_5);                 // scope 2 at $DIR/issue_72181.rs:+4:30: +4:31
+        _0 = const ();                   // scope 0 at $DIR/issue_72181.rs:+0:11: +5:2
+        StorageDead(_2);                 // scope 1 at $DIR/issue_72181.rs:+5:1: +5:2
+        return;                          // scope 0 at $DIR/issue_72181.rs:+5:2: +5:2
     }
 
     bb3 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-72181.rs:+0:1: +5:2
+        resume;                          // scope 0 at $DIR/issue_72181.rs:+0:1: +5:2
     }
 }
diff --git a/src/test/mir-opt/issue-72181.rs b/src/test/mir-opt/issue_72181.rs
similarity index 100%
rename from src/test/mir-opt/issue-72181.rs
rename to src/test/mir-opt/issue_72181.rs
diff --git a/src/test/mir-opt/issue_72181_1.f.built.after.mir b/src/test/mir-opt/issue_72181_1.f.built.after.mir
index 31e997f9b33..4086da52011 100644
--- a/src/test/mir-opt/issue_72181_1.f.built.after.mir
+++ b/src/test/mir-opt/issue_72181_1.f.built.after.mir
@@ -1,29 +1,29 @@
 // MIR for `f` after built
 
 fn f(_1: Void) -> ! {
-    debug v => _1;                       // in scope 0 at $DIR/issue-72181-1.rs:+0:6: +0:7
-    let mut _0: !;                       // return place in scope 0 at $DIR/issue-72181-1.rs:+0:18: +0:19
-    let mut _2: !;                       // in scope 0 at $DIR/issue-72181-1.rs:+0:20: +2:2
-    let mut _3: !;                       // in scope 0 at $DIR/issue-72181-1.rs:+1:5: +1:15
+    debug v => _1;                       // in scope 0 at $DIR/issue_72181_1.rs:+0:6: +0:7
+    let mut _0: !;                       // return place in scope 0 at $DIR/issue_72181_1.rs:+0:18: +0:19
+    let mut _2: !;                       // in scope 0 at $DIR/issue_72181_1.rs:+0:20: +2:2
+    let mut _3: !;                       // in scope 0 at $DIR/issue_72181_1.rs:+1:5: +1:15
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-72181-1.rs:+0:20: +2:2
-        StorageLive(_3);                 // scope 0 at $DIR/issue-72181-1.rs:+1:5: +1:15
-        FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/issue-72181-1.rs:+1:11: +1:12
-        unreachable;                     // scope 0 at $DIR/issue-72181-1.rs:+1:11: +1:12
+        StorageLive(_2);                 // scope 0 at $DIR/issue_72181_1.rs:+0:20: +2:2
+        StorageLive(_3);                 // scope 0 at $DIR/issue_72181_1.rs:+1:5: +1:15
+        FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/issue_72181_1.rs:+1:11: +1:12
+        unreachable;                     // scope 0 at $DIR/issue_72181_1.rs:+1:11: +1:12
     }
 
     bb1: {
-        unreachable;                     // scope 0 at $DIR/issue-72181-1.rs:+1:5: +1:15
+        unreachable;                     // scope 0 at $DIR/issue_72181_1.rs:+1:5: +1:15
     }
 
     bb2: {
-        StorageDead(_3);                 // scope 0 at $DIR/issue-72181-1.rs:+1:14: +1:15
-        unreachable;                     // scope 0 at $DIR/issue-72181-1.rs:+0:20: +2:2
+        StorageDead(_3);                 // scope 0 at $DIR/issue_72181_1.rs:+1:14: +1:15
+        unreachable;                     // scope 0 at $DIR/issue_72181_1.rs:+0:20: +2:2
     }
 
     bb3: {
-        StorageDead(_2);                 // scope 0 at $DIR/issue-72181-1.rs:+2:1: +2:2
-        return;                          // scope 0 at $DIR/issue-72181-1.rs:+2:2: +2:2
+        StorageDead(_2);                 // scope 0 at $DIR/issue_72181_1.rs:+2:1: +2:2
+        return;                          // scope 0 at $DIR/issue_72181_1.rs:+2:2: +2:2
     }
 }
diff --git a/src/test/mir-opt/issue_72181_1.main.built.after.mir b/src/test/mir-opt/issue_72181_1.main.built.after.mir
index 65177a81b03..2172f3aa9e2 100644
--- a/src/test/mir-opt/issue_72181_1.main.built.after.mir
+++ b/src/test/mir-opt/issue_72181_1.main.built.after.mir
@@ -1,57 +1,57 @@
 // MIR for `main` after built
 
 | User Type Annotations
-| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(Void) }, span: $DIR/issue-72181-1.rs:16:12: 16:16, inferred_ty: Void
-| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(Void) }, span: $DIR/issue-72181-1.rs:16:12: 16:16, inferred_ty: Void
+| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(Void) }, span: $DIR/issue_72181_1.rs:16:12: 16:16, inferred_ty: Void
+| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(Void) }, span: $DIR/issue_72181_1.rs:16:12: 16:16, inferred_ty: Void
 |
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue-72181-1.rs:+0:11: +0:11
-    let mut _1: !;                       // in scope 0 at $DIR/issue-72181-1.rs:+0:11: +6:2
-    let _2: Void as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/issue-72181-1.rs:+1:9: +1:10
-    let mut _3: ();                      // in scope 0 at $DIR/issue-72181-1.rs:+2:41: +2:43
-    let _4: !;                           // in scope 0 at $DIR/issue-72181-1.rs:+5:5: +5:9
-    let mut _5: Void;                    // in scope 0 at $DIR/issue-72181-1.rs:+5:7: +5:8
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue_72181_1.rs:+0:11: +0:11
+    let mut _1: !;                       // in scope 0 at $DIR/issue_72181_1.rs:+0:11: +6:2
+    let _2: Void as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/issue_72181_1.rs:+1:9: +1:10
+    let mut _3: ();                      // in scope 0 at $DIR/issue_72181_1.rs:+2:41: +2:43
+    let _4: !;                           // in scope 0 at $DIR/issue_72181_1.rs:+5:5: +5:9
+    let mut _5: Void;                    // in scope 0 at $DIR/issue_72181_1.rs:+5:7: +5:8
     scope 1 {
-        debug v => _2;                   // in scope 1 at $DIR/issue-72181-1.rs:+1:9: +1:10
+        debug v => _2;                   // in scope 1 at $DIR/issue_72181_1.rs:+1:9: +1:10
     }
     scope 2 {
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-72181-1.rs:+1:9: +1:10
-        StorageLive(_3);                 // scope 2 at $DIR/issue-72181-1.rs:+2:41: +2:43
-        _3 = ();                         // scope 2 at $DIR/issue-72181-1.rs:+2:41: +2:43
-        _2 = transmute::<(), Void>(move _3) -> bb4; // scope 2 at $DIR/issue-72181-1.rs:+2:9: +2:44
+        StorageLive(_2);                 // scope 0 at $DIR/issue_72181_1.rs:+1:9: +1:10
+        StorageLive(_3);                 // scope 2 at $DIR/issue_72181_1.rs:+2:41: +2:43
+        _3 = ();                         // scope 2 at $DIR/issue_72181_1.rs:+2:41: +2:43
+        _2 = transmute::<(), Void>(move _3) -> bb4; // scope 2 at $DIR/issue_72181_1.rs:+2:9: +2:44
                                          // mir::Constant
-                                         // + span: $DIR/issue-72181-1.rs:17:9: 17:40
+                                         // + span: $DIR/issue_72181_1.rs:17:9: 17:40
                                          // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(()) -> Void {transmute::<(), Void>}, val: Value() }
     }
 
     bb1: {
-        StorageDead(_3);                 // scope 2 at $DIR/issue-72181-1.rs:+2:43: +2:44
-        FakeRead(ForLet(None), _2);      // scope 0 at $DIR/issue-72181-1.rs:+1:9: +1:10
-        AscribeUserType(_2, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/issue-72181-1.rs:+1:12: +1:16
-        StorageLive(_4);                 // scope 1 at $DIR/issue-72181-1.rs:+5:5: +5:9
-        StorageLive(_5);                 // scope 1 at $DIR/issue-72181-1.rs:+5:7: +5:8
-        _5 = move _2;                    // scope 1 at $DIR/issue-72181-1.rs:+5:7: +5:8
-        _4 = f(move _5) -> bb4;          // scope 1 at $DIR/issue-72181-1.rs:+5:5: +5:9
+        StorageDead(_3);                 // scope 2 at $DIR/issue_72181_1.rs:+2:43: +2:44
+        FakeRead(ForLet(None), _2);      // scope 0 at $DIR/issue_72181_1.rs:+1:9: +1:10
+        AscribeUserType(_2, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/issue_72181_1.rs:+1:12: +1:16
+        StorageLive(_4);                 // scope 1 at $DIR/issue_72181_1.rs:+5:5: +5:9
+        StorageLive(_5);                 // scope 1 at $DIR/issue_72181_1.rs:+5:7: +5:8
+        _5 = move _2;                    // scope 1 at $DIR/issue_72181_1.rs:+5:7: +5:8
+        _4 = f(move _5) -> bb4;          // scope 1 at $DIR/issue_72181_1.rs:+5:5: +5:9
                                          // mir::Constant
-                                         // + span: $DIR/issue-72181-1.rs:20:5: 20:6
+                                         // + span: $DIR/issue_72181_1.rs:20:5: 20:6
                                          // + literal: Const { ty: fn(Void) -> ! {f}, val: Value() }
     }
 
     bb2: {
-        StorageDead(_5);                 // scope 1 at $DIR/issue-72181-1.rs:+5:8: +5:9
-        StorageDead(_4);                 // scope 1 at $DIR/issue-72181-1.rs:+5:9: +5:10
-        StorageDead(_2);                 // scope 0 at $DIR/issue-72181-1.rs:+6:1: +6:2
-        unreachable;                     // scope 0 at $DIR/issue-72181-1.rs:+0:11: +6:2
+        StorageDead(_5);                 // scope 1 at $DIR/issue_72181_1.rs:+5:8: +5:9
+        StorageDead(_4);                 // scope 1 at $DIR/issue_72181_1.rs:+5:9: +5:10
+        StorageDead(_2);                 // scope 0 at $DIR/issue_72181_1.rs:+6:1: +6:2
+        unreachable;                     // scope 0 at $DIR/issue_72181_1.rs:+0:11: +6:2
     }
 
     bb3: {
-        return;                          // scope 0 at $DIR/issue-72181-1.rs:+6:2: +6:2
+        return;                          // scope 0 at $DIR/issue_72181_1.rs:+6:2: +6:2
     }
 
     bb4 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-72181-1.rs:+0:1: +6:2
+        resume;                          // scope 0 at $DIR/issue_72181_1.rs:+0:1: +6:2
     }
 }
diff --git a/src/test/mir-opt/issue-72181-1.rs b/src/test/mir-opt/issue_72181_1.rs
similarity index 100%
rename from src/test/mir-opt/issue-72181-1.rs
rename to src/test/mir-opt/issue_72181_1.rs
diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff
index 269e4e32617..c9a9511586d 100644
--- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff
+++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff
@@ -2,18 +2,18 @@
 + // MIR for `main` after SimplifyArmIdentity
   
   fn main() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/issue-73223.rs:+0:11: +0:11
-      let _1: i32;                         // in scope 0 at $DIR/issue-73223.rs:+1:9: +1:14
-      let mut _2: std::option::Option; // in scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
-      let mut _3: isize;                   // in scope 0 at $DIR/issue-73223.rs:+2:9: +2:16
-      let _4: i32;                         // in scope 0 at $DIR/issue-73223.rs:+2:14: +2:15
-      let mut _5: !;                       // in scope 0 at $DIR/issue-73223.rs:+3:17: +3:23
-      let mut _7: i32;                     // in scope 0 at $DIR/issue-73223.rs:+6:22: +6:27
+      let mut _0: ();                      // return place in scope 0 at $DIR/issue_73223.rs:+0:11: +0:11
+      let _1: i32;                         // in scope 0 at $DIR/issue_73223.rs:+1:9: +1:14
+      let mut _2: std::option::Option; // in scope 0 at $DIR/issue_73223.rs:+1:23: +1:30
+      let mut _3: isize;                   // in scope 0 at $DIR/issue_73223.rs:+2:9: +2:16
+      let _4: i32;                         // in scope 0 at $DIR/issue_73223.rs:+2:14: +2:15
+      let mut _5: !;                       // in scope 0 at $DIR/issue_73223.rs:+3:17: +3:23
+      let mut _7: i32;                     // in scope 0 at $DIR/issue_73223.rs:+6:22: +6:27
       let _8: ();                          // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
       let mut _9: (&i32, &i32);            // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
       let mut _10: &i32;                   // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
       let mut _11: &i32;                   // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
-      let _12: i32;                        // in scope 0 at $DIR/issue-73223.rs:+7:23: +7:24
+      let _12: i32;                        // in scope 0 at $DIR/issue_73223.rs:+7:23: +7:24
       let mut _15: bool;                   // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
       let mut _16: bool;                   // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
       let mut _17: i32;                    // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -27,10 +27,10 @@
       let _26: &i32;                       // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
       let mut _27: std::option::Option>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
       scope 1 {
-          debug split => _1;               // in scope 1 at $DIR/issue-73223.rs:+1:9: +1:14
-          let _6: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:+6:9: +6:14
+          debug split => _1;               // in scope 1 at $DIR/issue_73223.rs:+1:9: +1:14
+          let _6: std::option::Option; // in scope 1 at $DIR/issue_73223.rs:+6:9: +6:14
           scope 3 {
-              debug _prev => _6;           // in scope 3 at $DIR/issue-73223.rs:+6:9: +6:14
+              debug _prev => _6;           // in scope 3 at $DIR/issue_73223.rs:+6:9: +6:14
               let _13: &i32;               // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
               let _14: &i32;               // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
               let mut _28: &i32;           // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -45,43 +45,43 @@
           }
       }
       scope 2 {
-          debug v => _4;                   // in scope 2 at $DIR/issue-73223.rs:+2:14: +2:15
+          debug v => _4;                   // in scope 2 at $DIR/issue_73223.rs:+2:14: +2:15
       }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/issue-73223.rs:+1:9: +1:14
-          StorageLive(_2);                 // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
-          Deinit(_2);                      // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
-          ((_2 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
-          discriminant(_2) = 1;            // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
-          _3 = const 1_isize;              // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
-          goto -> bb3;                     // scope 0 at $DIR/issue-73223.rs:+1:17: +1:30
+          StorageLive(_1);                 // scope 0 at $DIR/issue_73223.rs:+1:9: +1:14
+          StorageLive(_2);                 // scope 0 at $DIR/issue_73223.rs:+1:23: +1:30
+          Deinit(_2);                      // scope 0 at $DIR/issue_73223.rs:+1:23: +1:30
+          ((_2 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue_73223.rs:+1:23: +1:30
+          discriminant(_2) = 1;            // scope 0 at $DIR/issue_73223.rs:+1:23: +1:30
+          _3 = const 1_isize;              // scope 0 at $DIR/issue_73223.rs:+1:23: +1:30
+          goto -> bb3;                     // scope 0 at $DIR/issue_73223.rs:+1:17: +1:30
       }
   
       bb1: {
-          nop;                             // scope 0 at $DIR/issue-73223.rs:+3:17: +3:23
-          StorageDead(_2);                 // scope 0 at $DIR/issue-73223.rs:+4:6: +4:7
-          StorageDead(_1);                 // scope 0 at $DIR/issue-73223.rs:+8:1: +8:2
-          return;                          // scope 0 at $DIR/issue-73223.rs:+8:2: +8:2
+          nop;                             // scope 0 at $DIR/issue_73223.rs:+3:17: +3:23
+          StorageDead(_2);                 // scope 0 at $DIR/issue_73223.rs:+4:6: +4:7
+          StorageDead(_1);                 // scope 0 at $DIR/issue_73223.rs:+8:1: +8:2
+          return;                          // scope 0 at $DIR/issue_73223.rs:+8:2: +8:2
       }
   
       bb2: {
-          unreachable;                     // scope 0 at $DIR/issue-73223.rs:+1:23: +1:30
+          unreachable;                     // scope 0 at $DIR/issue_73223.rs:+1:23: +1:30
       }
   
       bb3: {
-          StorageLive(_4);                 // scope 0 at $DIR/issue-73223.rs:+2:14: +2:15
-          _4 = ((_2 as Some).0: i32);      // scope 0 at $DIR/issue-73223.rs:+2:14: +2:15
-          _1 = _4;                         // scope 2 at $DIR/issue-73223.rs:+2:20: +2:21
-          StorageDead(_4);                 // scope 0 at $DIR/issue-73223.rs:+2:20: +2:21
-          StorageDead(_2);                 // scope 0 at $DIR/issue-73223.rs:+4:6: +4:7
-          StorageLive(_6);                 // scope 1 at $DIR/issue-73223.rs:+6:9: +6:14
-          StorageLive(_7);                 // scope 1 at $DIR/issue-73223.rs:+6:22: +6:27
-          _7 = _1;                         // scope 1 at $DIR/issue-73223.rs:+6:22: +6:27
-          Deinit(_6);                      // scope 1 at $DIR/issue-73223.rs:+6:17: +6:28
-          ((_6 as Some).0: i32) = move _7; // scope 1 at $DIR/issue-73223.rs:+6:17: +6:28
-          discriminant(_6) = 1;            // scope 1 at $DIR/issue-73223.rs:+6:17: +6:28
-          StorageDead(_7);                 // scope 1 at $DIR/issue-73223.rs:+6:27: +6:28
+          StorageLive(_4);                 // scope 0 at $DIR/issue_73223.rs:+2:14: +2:15
+          _4 = ((_2 as Some).0: i32);      // scope 0 at $DIR/issue_73223.rs:+2:14: +2:15
+          _1 = _4;                         // scope 2 at $DIR/issue_73223.rs:+2:20: +2:21
+          StorageDead(_4);                 // scope 0 at $DIR/issue_73223.rs:+2:20: +2:21
+          StorageDead(_2);                 // scope 0 at $DIR/issue_73223.rs:+4:6: +4:7
+          StorageLive(_6);                 // scope 1 at $DIR/issue_73223.rs:+6:9: +6:14
+          StorageLive(_7);                 // scope 1 at $DIR/issue_73223.rs:+6:22: +6:27
+          _7 = _1;                         // scope 1 at $DIR/issue_73223.rs:+6:22: +6:27
+          Deinit(_6);                      // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28
+          ((_6 as Some).0: i32) = move _7; // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28
+          discriminant(_6) = 1;            // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28
+          StorageDead(_7);                 // scope 1 at $DIR/issue_73223.rs:+6:27: +6:28
           StorageLive(_8);                 // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
           StorageLive(_9);                 // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
           StorageLive(_10);                // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -152,10 +152,10 @@
           StorageDead(_13);                // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
           StorageDead(_9);                 // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
           StorageDead(_8);                 // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
-          nop;                             // scope 0 at $DIR/issue-73223.rs:+0:11: +8:2
-          StorageDead(_6);                 // scope 1 at $DIR/issue-73223.rs:+8:1: +8:2
-          StorageDead(_1);                 // scope 0 at $DIR/issue-73223.rs:+8:1: +8:2
-          return;                          // scope 0 at $DIR/issue-73223.rs:+8:2: +8:2
+          nop;                             // scope 0 at $DIR/issue_73223.rs:+0:11: +8:2
+          StorageDead(_6);                 // scope 1 at $DIR/issue_73223.rs:+8:1: +8:2
+          StorageDead(_1);                 // scope 0 at $DIR/issue_73223.rs:+8:1: +8:2
+          return;                          // scope 0 at $DIR/issue_73223.rs:+8:2: +8:2
       }
   }
   
diff --git a/src/test/mir-opt/issue-73223.rs b/src/test/mir-opt/issue_73223.rs
similarity index 100%
rename from src/test/mir-opt/issue-73223.rs
rename to src/test/mir-opt/issue_73223.rs
diff --git a/src/test/mir-opt/issue_78192.f.InstCombine.diff b/src/test/mir-opt/issue_78192.f.InstCombine.diff
index 8ec94d65fda..116ca304c99 100644
--- a/src/test/mir-opt/issue_78192.f.InstCombine.diff
+++ b/src/test/mir-opt/issue_78192.f.InstCombine.diff
@@ -2,28 +2,28 @@
 + // MIR for `f` after InstCombine
   
   fn f(_1: &T) -> *const T {
-      debug a => _1;                       // in scope 0 at $DIR/issue-78192.rs:+0:13: +0:14
-      let mut _0: *const T;                // return place in scope 0 at $DIR/issue-78192.rs:+0:23: +0:31
-      let _2: &*const T;                   // in scope 0 at $DIR/issue-78192.rs:+1:9: +1:10
-      let _3: &*const T;                   // in scope 0 at $DIR/issue-78192.rs:+1:24: +1:40
-      let _4: *const T;                    // in scope 0 at $DIR/issue-78192.rs:+1:25: +1:40
+      debug a => _1;                       // in scope 0 at $DIR/issue_78192.rs:+0:13: +0:14
+      let mut _0: *const T;                // return place in scope 0 at $DIR/issue_78192.rs:+0:23: +0:31
+      let _2: &*const T;                   // in scope 0 at $DIR/issue_78192.rs:+1:9: +1:10
+      let _3: &*const T;                   // in scope 0 at $DIR/issue_78192.rs:+1:24: +1:40
+      let _4: *const T;                    // in scope 0 at $DIR/issue_78192.rs:+1:25: +1:40
       scope 1 {
-          debug b => _2;                   // in scope 1 at $DIR/issue-78192.rs:+1:9: +1:10
+          debug b => _2;                   // in scope 1 at $DIR/issue_78192.rs:+1:9: +1:10
       }
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/issue-78192.rs:+1:9: +1:10
-          StorageLive(_3);                 // scope 0 at $DIR/issue-78192.rs:+1:24: +1:40
-          StorageLive(_4);                 // scope 0 at $DIR/issue-78192.rs:+1:25: +1:40
-          _4 = &raw const (*_1);           // scope 0 at $DIR/issue-78192.rs:+1:26: +1:27
-          _3 = &_4;                        // scope 0 at $DIR/issue-78192.rs:+1:24: +1:40
--         _2 = &(*_3);                     // scope 0 at $DIR/issue-78192.rs:+1:24: +1:40
-+         _2 = _3;                         // scope 0 at $DIR/issue-78192.rs:+1:24: +1:40
-          StorageDead(_3);                 // scope 0 at $DIR/issue-78192.rs:+1:40: +1:41
-          _0 = (*_2);                      // scope 1 at $DIR/issue-78192.rs:+2:5: +2:7
-          StorageDead(_4);                 // scope 0 at $DIR/issue-78192.rs:+3:1: +3:2
-          StorageDead(_2);                 // scope 0 at $DIR/issue-78192.rs:+3:1: +3:2
-          return;                          // scope 0 at $DIR/issue-78192.rs:+3:2: +3:2
+          StorageLive(_2);                 // scope 0 at $DIR/issue_78192.rs:+1:9: +1:10
+          StorageLive(_3);                 // scope 0 at $DIR/issue_78192.rs:+1:24: +1:40
+          StorageLive(_4);                 // scope 0 at $DIR/issue_78192.rs:+1:25: +1:40
+          _4 = &raw const (*_1);           // scope 0 at $DIR/issue_78192.rs:+1:26: +1:27
+          _3 = &_4;                        // scope 0 at $DIR/issue_78192.rs:+1:24: +1:40
+-         _2 = &(*_3);                     // scope 0 at $DIR/issue_78192.rs:+1:24: +1:40
++         _2 = _3;                         // scope 0 at $DIR/issue_78192.rs:+1:24: +1:40
+          StorageDead(_3);                 // scope 0 at $DIR/issue_78192.rs:+1:40: +1:41
+          _0 = (*_2);                      // scope 1 at $DIR/issue_78192.rs:+2:5: +2:7
+          StorageDead(_4);                 // scope 0 at $DIR/issue_78192.rs:+3:1: +3:2
+          StorageDead(_2);                 // scope 0 at $DIR/issue_78192.rs:+3:1: +3:2
+          return;                          // scope 0 at $DIR/issue_78192.rs:+3:2: +3:2
       }
   }
   
diff --git a/src/test/mir-opt/issue-78192.rs b/src/test/mir-opt/issue_78192.rs
similarity index 100%
rename from src/test/mir-opt/issue-78192.rs
rename to src/test/mir-opt/issue_78192.rs
diff --git a/src/test/mir-opt/issue_91633.bar.built.after.mir b/src/test/mir-opt/issue_91633.bar.built.after.mir
index 19b1b6fe12b..c3fb90e8402 100644
--- a/src/test/mir-opt/issue_91633.bar.built.after.mir
+++ b/src/test/mir-opt/issue_91633.bar.built.after.mir
@@ -1,39 +1,39 @@
 // MIR for `bar` after built
 
 fn bar(_1: Box<[T]>) -> () {
-    debug it => _1;                      // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue-91633.rs:+1:2: +1:2
-    let mut _2: &<[T] as std::ops::Index>::Output; // in scope 0 at $DIR/issue-91633.rs:+4:14: +4:19
-    let mut _3: &[T];                    // in scope 0 at $DIR/issue-91633.rs:+4:14: +4:16
+    debug it => _1;                      // in scope 0 at $DIR/issue_91633.rs:+0:12: +0:14
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue_91633.rs:+1:2: +1:2
+    let mut _2: &<[T] as std::ops::Index>::Output; // in scope 0 at $DIR/issue_91633.rs:+4:14: +4:19
+    let mut _3: &[T];                    // in scope 0 at $DIR/issue_91633.rs:+4:14: +4:16
     scope 1 {
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-91633.rs:+4:14: +4:19
-        StorageLive(_3);                 // scope 0 at $DIR/issue-91633.rs:+4:14: +4:16
-        _3 = &(*_1);                     // scope 0 at $DIR/issue-91633.rs:+4:14: +4:16
-        _2 = <[T] as Index>::index(move _3, const 0_usize) -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue-91633.rs:+4:14: +4:19
+        StorageLive(_2);                 // scope 0 at $DIR/issue_91633.rs:+4:14: +4:19
+        StorageLive(_3);                 // scope 0 at $DIR/issue_91633.rs:+4:14: +4:16
+        _3 = &(*_1);                     // scope 0 at $DIR/issue_91633.rs:+4:14: +4:16
+        _2 = <[T] as Index>::index(move _3, const 0_usize) -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue_91633.rs:+4:14: +4:19
                                          // mir::Constant
-                                         // + span: $DIR/issue-91633.rs:15:14: 15:19
+                                         // + span: $DIR/issue_91633.rs:15:14: 15:19
                                          // + literal: Const { ty: for<'a> fn(&'a [T], usize) -> &'a <[T] as Index>::Output {<[T] as Index>::index}, val: Value() }
     }
 
     bb1: {
-        StorageDead(_3);                 // scope 0 at $DIR/issue-91633.rs:+4:18: +4:19
-        StorageDead(_2);                 // scope 0 at $DIR/issue-91633.rs:+4:19: +4:20
-        _0 = const ();                   // scope 0 at $DIR/issue-91633.rs:+3:2: +5:3
-        drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue-91633.rs:+5:2: +5:3
+        StorageDead(_3);                 // scope 0 at $DIR/issue_91633.rs:+4:18: +4:19
+        StorageDead(_2);                 // scope 0 at $DIR/issue_91633.rs:+4:19: +4:20
+        _0 = const ();                   // scope 0 at $DIR/issue_91633.rs:+3:2: +5:3
+        drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_91633.rs:+5:2: +5:3
     }
 
     bb2: {
-        return;                          // scope 0 at $DIR/issue-91633.rs:+5:3: +5:3
+        return;                          // scope 0 at $DIR/issue_91633.rs:+5:3: +5:3
     }
 
     bb3 (cleanup): {
-        drop(_1) -> bb4;                 // scope 0 at $DIR/issue-91633.rs:+5:2: +5:3
+        drop(_1) -> bb4;                 // scope 0 at $DIR/issue_91633.rs:+5:2: +5:3
     }
 
     bb4 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-91633.rs:+0:1: +5:3
+        resume;                          // scope 0 at $DIR/issue_91633.rs:+0:1: +5:3
     }
 }
diff --git a/src/test/mir-opt/issue_91633.foo.built.after.mir b/src/test/mir-opt/issue_91633.foo.built.after.mir
index 1a6eee93d36..4e3dd365e92 100644
--- a/src/test/mir-opt/issue_91633.foo.built.after.mir
+++ b/src/test/mir-opt/issue_91633.foo.built.after.mir
@@ -1,57 +1,57 @@
 // MIR for `foo` after built
 
 fn foo(_1: Box<[T]>) -> T {
-    debug it => _1;                      // in scope 0 at $DIR/issue-91633.rs:+0:19: +0:21
-    let mut _0: T;                       // return place in scope 0 at $DIR/issue-91633.rs:+0:36: +0:37
-    let _2: T;                           // in scope 0 at $DIR/issue-91633.rs:+2:10: +2:11
-    let mut _3: &T;                      // in scope 0 at $DIR/issue-91633.rs:+2:14: +2:27
-    let _4: usize;                       // in scope 0 at $DIR/issue-91633.rs:+2:17: +2:18
-    let mut _5: usize;                   // in scope 0 at $DIR/issue-91633.rs:+2:14: +2:19
-    let mut _6: bool;                    // in scope 0 at $DIR/issue-91633.rs:+2:14: +2:19
+    debug it => _1;                      // in scope 0 at $DIR/issue_91633.rs:+0:19: +0:21
+    let mut _0: T;                       // return place in scope 0 at $DIR/issue_91633.rs:+0:36: +0:37
+    let _2: T;                           // in scope 0 at $DIR/issue_91633.rs:+2:10: +2:11
+    let mut _3: &T;                      // in scope 0 at $DIR/issue_91633.rs:+2:14: +2:27
+    let _4: usize;                       // in scope 0 at $DIR/issue_91633.rs:+2:17: +2:18
+    let mut _5: usize;                   // in scope 0 at $DIR/issue_91633.rs:+2:14: +2:19
+    let mut _6: bool;                    // in scope 0 at $DIR/issue_91633.rs:+2:14: +2:19
     scope 1 {
-        debug f => _2;                   // in scope 1 at $DIR/issue-91633.rs:+2:10: +2:11
+        debug f => _2;                   // in scope 1 at $DIR/issue_91633.rs:+2:10: +2:11
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-91633.rs:+2:10: +2:11
-        StorageLive(_3);                 // scope 0 at $DIR/issue-91633.rs:+2:14: +2:27
-        StorageLive(_4);                 // scope 0 at $DIR/issue-91633.rs:+2:17: +2:18
-        _4 = const 0_usize;              // scope 0 at $DIR/issue-91633.rs:+2:17: +2:18
-        _5 = Len((*_1));                 // scope 0 at $DIR/issue-91633.rs:+2:14: +2:19
-        _6 = Lt(_4, _5);                 // scope 0 at $DIR/issue-91633.rs:+2:14: +2:19
-        assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind: bb5]; // scope 0 at $DIR/issue-91633.rs:+2:14: +2:19
+        StorageLive(_2);                 // scope 0 at $DIR/issue_91633.rs:+2:10: +2:11
+        StorageLive(_3);                 // scope 0 at $DIR/issue_91633.rs:+2:14: +2:27
+        StorageLive(_4);                 // scope 0 at $DIR/issue_91633.rs:+2:17: +2:18
+        _4 = const 0_usize;              // scope 0 at $DIR/issue_91633.rs:+2:17: +2:18
+        _5 = Len((*_1));                 // scope 0 at $DIR/issue_91633.rs:+2:14: +2:19
+        _6 = Lt(_4, _5);                 // scope 0 at $DIR/issue_91633.rs:+2:14: +2:19
+        assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind: bb5]; // scope 0 at $DIR/issue_91633.rs:+2:14: +2:19
     }
 
     bb1: {
-        _3 = &(*_1)[_4];                 // scope 0 at $DIR/issue-91633.rs:+2:14: +2:27
-        _2 = ::clone(move _3) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/issue-91633.rs:+2:14: +2:27
+        _3 = &(*_1)[_4];                 // scope 0 at $DIR/issue_91633.rs:+2:14: +2:27
+        _2 = ::clone(move _3) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/issue_91633.rs:+2:14: +2:27
                                          // mir::Constant
-                                         // + span: $DIR/issue-91633.rs:28:20: 28:25
+                                         // + span: $DIR/issue_91633.rs:28:20: 28:25
                                          // + literal: Const { ty: for<'a> fn(&'a T) -> T {::clone}, val: Value() }
     }
 
     bb2: {
-        StorageDead(_3);                 // scope 0 at $DIR/issue-91633.rs:+2:26: +2:27
-        FakeRead(ForLet(None), _2);      // scope 0 at $DIR/issue-91633.rs:+2:10: +2:11
-        StorageDead(_4);                 // scope 0 at $DIR/issue-91633.rs:+2:27: +2:28
-        _0 = move _2;                    // scope 1 at $DIR/issue-91633.rs:+3:6: +3:7
-        drop(_2) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3
+        StorageDead(_3);                 // scope 0 at $DIR/issue_91633.rs:+2:26: +2:27
+        FakeRead(ForLet(None), _2);      // scope 0 at $DIR/issue_91633.rs:+2:10: +2:11
+        StorageDead(_4);                 // scope 0 at $DIR/issue_91633.rs:+2:27: +2:28
+        _0 = move _2;                    // scope 1 at $DIR/issue_91633.rs:+3:6: +3:7
+        drop(_2) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3
     }
 
     bb3: {
-        StorageDead(_2);                 // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3
-        drop(_1) -> [return: bb4, unwind: bb6]; // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3
+        StorageDead(_2);                 // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3
+        drop(_1) -> [return: bb4, unwind: bb6]; // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3
     }
 
     bb4: {
-        return;                          // scope 0 at $DIR/issue-91633.rs:+4:3: +4:3
+        return;                          // scope 0 at $DIR/issue_91633.rs:+4:3: +4:3
     }
 
     bb5 (cleanup): {
-        drop(_1) -> bb6;                 // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3
+        drop(_1) -> bb6;                 // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3
     }
 
     bb6 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-91633.rs:+0:1: +4:3
+        resume;                          // scope 0 at $DIR/issue_91633.rs:+0:1: +4:3
     }
 }
diff --git a/src/test/mir-opt/issue_91633.fun.built.after.mir b/src/test/mir-opt/issue_91633.fun.built.after.mir
index b3eea600330..42486d3a50e 100644
--- a/src/test/mir-opt/issue_91633.fun.built.after.mir
+++ b/src/test/mir-opt/issue_91633.fun.built.after.mir
@@ -1,35 +1,35 @@
 // MIR for `fun` after built
 
 fn fun(_1: &[T]) -> &T {
-    debug it => _1;                      // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14
-    let mut _0: &T;                      // return place in scope 0 at $DIR/issue-91633.rs:+0:25: +0:27
-    let _2: &T;                          // in scope 0 at $DIR/issue-91633.rs:+2:10: +2:11
-    let _3: usize;                       // in scope 0 at $DIR/issue-91633.rs:+2:18: +2:19
-    let mut _4: usize;                   // in scope 0 at $DIR/issue-91633.rs:+2:15: +2:20
-    let mut _5: bool;                    // in scope 0 at $DIR/issue-91633.rs:+2:15: +2:20
+    debug it => _1;                      // in scope 0 at $DIR/issue_91633.rs:+0:12: +0:14
+    let mut _0: &T;                      // return place in scope 0 at $DIR/issue_91633.rs:+0:25: +0:27
+    let _2: &T;                          // in scope 0 at $DIR/issue_91633.rs:+2:10: +2:11
+    let _3: usize;                       // in scope 0 at $DIR/issue_91633.rs:+2:18: +2:19
+    let mut _4: usize;                   // in scope 0 at $DIR/issue_91633.rs:+2:15: +2:20
+    let mut _5: bool;                    // in scope 0 at $DIR/issue_91633.rs:+2:15: +2:20
     scope 1 {
-        debug f => _2;                   // in scope 1 at $DIR/issue-91633.rs:+2:10: +2:11
+        debug f => _2;                   // in scope 1 at $DIR/issue_91633.rs:+2:10: +2:11
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-91633.rs:+2:10: +2:11
-        StorageLive(_3);                 // scope 0 at $DIR/issue-91633.rs:+2:18: +2:19
-        _3 = const 0_usize;              // scope 0 at $DIR/issue-91633.rs:+2:18: +2:19
-        _4 = Len((*_1));                 // scope 0 at $DIR/issue-91633.rs:+2:15: +2:20
-        _5 = Lt(_3, _4);                 // scope 0 at $DIR/issue-91633.rs:+2:15: +2:20
-        assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue-91633.rs:+2:15: +2:20
+        StorageLive(_2);                 // scope 0 at $DIR/issue_91633.rs:+2:10: +2:11
+        StorageLive(_3);                 // scope 0 at $DIR/issue_91633.rs:+2:18: +2:19
+        _3 = const 0_usize;              // scope 0 at $DIR/issue_91633.rs:+2:18: +2:19
+        _4 = Len((*_1));                 // scope 0 at $DIR/issue_91633.rs:+2:15: +2:20
+        _5 = Lt(_3, _4);                 // scope 0 at $DIR/issue_91633.rs:+2:15: +2:20
+        assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue_91633.rs:+2:15: +2:20
     }
 
     bb1: {
-        _2 = &(*_1)[_3];                 // scope 0 at $DIR/issue-91633.rs:+2:14: +2:20
-        FakeRead(ForLet(None), _2);      // scope 0 at $DIR/issue-91633.rs:+2:10: +2:11
-        _0 = &(*_2);                     // scope 1 at $DIR/issue-91633.rs:+3:6: +3:7
-        StorageDead(_3);                 // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3
-        StorageDead(_2);                 // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3
-        return;                          // scope 0 at $DIR/issue-91633.rs:+4:3: +4:3
+        _2 = &(*_1)[_3];                 // scope 0 at $DIR/issue_91633.rs:+2:14: +2:20
+        FakeRead(ForLet(None), _2);      // scope 0 at $DIR/issue_91633.rs:+2:10: +2:11
+        _0 = &(*_2);                     // scope 1 at $DIR/issue_91633.rs:+3:6: +3:7
+        StorageDead(_3);                 // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3
+        StorageDead(_2);                 // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3
+        return;                          // scope 0 at $DIR/issue_91633.rs:+4:3: +4:3
     }
 
     bb2 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-91633.rs:+0:1: +4:3
+        resume;                          // scope 0 at $DIR/issue_91633.rs:+0:1: +4:3
     }
 }
diff --git a/src/test/mir-opt/issue_91633.hey.built.after.mir b/src/test/mir-opt/issue_91633.hey.built.after.mir
index e7e31ad33c1..ccb06dd5983 100644
--- a/src/test/mir-opt/issue_91633.hey.built.after.mir
+++ b/src/test/mir-opt/issue_91633.hey.built.after.mir
@@ -1,35 +1,35 @@
 // MIR for `hey` after built
 
 fn hey(_1: &[T]) -> () {
-    debug it => _1;                      // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue-91633.rs:+1:2: +1:2
-    let mut _2: &<[T] as std::ops::Index>::Output; // in scope 0 at $DIR/issue-91633.rs:+4:14: +4:20
-    let _3: &<[T] as std::ops::Index>::Output; // in scope 0 at $DIR/issue-91633.rs:+4:15: +4:20
-    let mut _4: &[T];                    // in scope 0 at $DIR/issue-91633.rs:+4:15: +4:17
+    debug it => _1;                      // in scope 0 at $DIR/issue_91633.rs:+0:12: +0:14
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue_91633.rs:+1:2: +1:2
+    let mut _2: &<[T] as std::ops::Index>::Output; // in scope 0 at $DIR/issue_91633.rs:+4:14: +4:20
+    let _3: &<[T] as std::ops::Index>::Output; // in scope 0 at $DIR/issue_91633.rs:+4:15: +4:20
+    let mut _4: &[T];                    // in scope 0 at $DIR/issue_91633.rs:+4:15: +4:17
     scope 1 {
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-91633.rs:+4:14: +4:20
-        StorageLive(_3);                 // scope 0 at $DIR/issue-91633.rs:+4:15: +4:20
-        StorageLive(_4);                 // scope 0 at $DIR/issue-91633.rs:+4:15: +4:17
-        _4 = &(*_1);                     // scope 0 at $DIR/issue-91633.rs:+4:15: +4:17
-        _3 = <[T] as Index>::index(move _4, const 0_usize) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/issue-91633.rs:+4:15: +4:20
+        StorageLive(_2);                 // scope 0 at $DIR/issue_91633.rs:+4:14: +4:20
+        StorageLive(_3);                 // scope 0 at $DIR/issue_91633.rs:+4:15: +4:20
+        StorageLive(_4);                 // scope 0 at $DIR/issue_91633.rs:+4:15: +4:17
+        _4 = &(*_1);                     // scope 0 at $DIR/issue_91633.rs:+4:15: +4:17
+        _3 = <[T] as Index>::index(move _4, const 0_usize) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/issue_91633.rs:+4:15: +4:20
                                          // mir::Constant
-                                         // + span: $DIR/issue-91633.rs:7:15: 7:20
+                                         // + span: $DIR/issue_91633.rs:7:15: 7:20
                                          // + literal: Const { ty: for<'a> fn(&'a [T], usize) -> &'a <[T] as Index>::Output {<[T] as Index>::index}, val: Value() }
     }
 
     bb1: {
-        StorageDead(_4);                 // scope 0 at $DIR/issue-91633.rs:+4:19: +4:20
-        _2 = &(*_3);                     // scope 0 at $DIR/issue-91633.rs:+4:14: +4:20
-        StorageDead(_2);                 // scope 0 at $DIR/issue-91633.rs:+4:20: +4:21
-        _0 = const ();                   // scope 0 at $DIR/issue-91633.rs:+3:2: +5:3
-        StorageDead(_3);                 // scope 0 at $DIR/issue-91633.rs:+5:2: +5:3
-        return;                          // scope 0 at $DIR/issue-91633.rs:+5:3: +5:3
+        StorageDead(_4);                 // scope 0 at $DIR/issue_91633.rs:+4:19: +4:20
+        _2 = &(*_3);                     // scope 0 at $DIR/issue_91633.rs:+4:14: +4:20
+        StorageDead(_2);                 // scope 0 at $DIR/issue_91633.rs:+4:20: +4:21
+        _0 = const ();                   // scope 0 at $DIR/issue_91633.rs:+3:2: +5:3
+        StorageDead(_3);                 // scope 0 at $DIR/issue_91633.rs:+5:2: +5:3
+        return;                          // scope 0 at $DIR/issue_91633.rs:+5:3: +5:3
     }
 
     bb2 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-91633.rs:+0:1: +5:3
+        resume;                          // scope 0 at $DIR/issue_91633.rs:+0:1: +5:3
     }
 }
diff --git a/src/test/mir-opt/issue-91633.rs b/src/test/mir-opt/issue_91633.rs
similarity index 100%
rename from src/test/mir-opt/issue-91633.rs
rename to src/test/mir-opt/issue_91633.rs
diff --git a/src/test/mir-opt/issue_99325.main.built.after.mir b/src/test/mir-opt/issue_99325.main.built.after.mir
index f588f06b7e4..3db40412b2e 100644
--- a/src/test/mir-opt/issue_99325.main.built.after.mir
+++ b/src/test/mir-opt/issue_99325.main.built.after.mir
@@ -1,18 +1,18 @@
 // MIR for `main` after built
 
 | User Type Annotations
-| 0: user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_99325[8f58]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Value(Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)])) }], user_self_ty: None }) }, span: $DIR/issue-99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
-| 1: user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_99325[8f58]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Unevaluated(UnevaluatedConst { def: WithOptConstParam { did: DefId(0:8 ~ issue_99325[8f58]::main::{constant#1}), const_param_did: Some(DefId(0:4 ~ issue_99325[8f58]::function_with_bytes::BYTES)) }, substs: [] }) }], user_self_ty: None }) }, span: $DIR/issue-99325.rs:11:16: 11:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
+| 0: user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_99325[8f58]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Value(Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)])) }], user_self_ty: None }) }, span: $DIR/issue_99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
+| 1: user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_99325[8f58]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Unevaluated(UnevaluatedConst { def: WithOptConstParam { did: DefId(0:8 ~ issue_99325[8f58]::main::{constant#1}), const_param_did: Some(DefId(0:4 ~ issue_99325[8f58]::function_with_bytes::BYTES)) }, substs: [] }) }], user_self_ty: None }) }, span: $DIR/issue_99325.rs:11:16: 11:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
 |
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue-99325.rs:+0:15: +0:15
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue_99325.rs:+0:15: +0:15
     let _1: ();                          // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
     let mut _2: (&&[u8], &&[u8; 4]);     // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
     let mut _3: &&[u8];                  // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
-    let _4: &[u8];                       // in scope 0 at $DIR/issue-99325.rs:+1:16: +1:48
+    let _4: &[u8];                       // in scope 0 at $DIR/issue_99325.rs:+1:16: +1:48
     let mut _5: &&[u8; 4];               // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
-    let _6: &[u8; 4];                    // in scope 0 at $DIR/issue-99325.rs:+1:50: +1:75
-    let _7: [u8; 4];                     // in scope 0 at $DIR/issue-99325.rs:+1:51: +1:75
+    let _6: &[u8; 4];                    // in scope 0 at $DIR/issue_99325.rs:+1:50: +1:75
+    let _7: [u8; 4];                     // in scope 0 at $DIR/issue_99325.rs:+1:51: +1:75
     let _8: &&[u8];                      // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
     let _9: &&[u8; 4];                   // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
     let mut _10: bool;                   // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -30,9 +30,9 @@ fn main() -> () {
     let _23: ();                         // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
     let mut _24: (&&[u8], &&[u8; 4]);    // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
     let mut _25: &&[u8];                 // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
-    let _26: &[u8];                      // in scope 0 at $DIR/issue-99325.rs:+2:16: +2:70
+    let _26: &[u8];                      // in scope 0 at $DIR/issue_99325.rs:+2:16: +2:70
     let mut _27: &&[u8; 4];              // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
-    let _28: &[u8; 4];                   // in scope 0 at $DIR/issue-99325.rs:+2:72: +2:79
+    let _28: &[u8; 4];                   // in scope 0 at $DIR/issue_99325.rs:+2:72: +2:79
     let _29: &&[u8];                     // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
     let _30: &&[u8; 4];                  // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
     let mut _31: bool;                   // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -68,10 +68,10 @@ fn main() -> () {
         StorageLive(_1);                 // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
         StorageLive(_2);                 // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
         StorageLive(_3);                 // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
-        StorageLive(_4);                 // scope 0 at $DIR/issue-99325.rs:+1:16: +1:48
-        _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb19]; // scope 0 at $DIR/issue-99325.rs:+1:16: +1:48
+        StorageLive(_4);                 // scope 0 at $DIR/issue_99325.rs:+1:16: +1:48
+        _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb19]; // scope 0 at $DIR/issue_99325.rs:+1:16: +1:48
                                          // mir::Constant
-                                         // + span: $DIR/issue-99325.rs:10:16: 10:46
+                                         // + span: $DIR/issue_99325.rs:10:16: 10:46
                                          // + user_ty: UserType(0)
                                          // + literal: Const { ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}, val: Value() }
     }
@@ -79,10 +79,10 @@ fn main() -> () {
     bb1: {
         _3 = &_4;                        // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
         StorageLive(_5);                 // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
-        StorageLive(_6);                 // scope 0 at $DIR/issue-99325.rs:+1:50: +1:75
-        StorageLive(_7);                 // scope 0 at $DIR/issue-99325.rs:+1:51: +1:75
-        _7 = [const 65_u8, const 65_u8, const 65_u8, const 65_u8]; // scope 0 at $DIR/issue-99325.rs:+1:51: +1:75
-        _6 = &_7;                        // scope 0 at $DIR/issue-99325.rs:+1:50: +1:75
+        StorageLive(_6);                 // scope 0 at $DIR/issue_99325.rs:+1:50: +1:75
+        StorageLive(_7);                 // scope 0 at $DIR/issue_99325.rs:+1:51: +1:75
+        _7 = [const 65_u8, const 65_u8, const 65_u8, const 65_u8]; // scope 0 at $DIR/issue_99325.rs:+1:51: +1:75
+        _6 = &_7;                        // scope 0 at $DIR/issue_99325.rs:+1:50: +1:75
         _5 = &_6;                        // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
         _2 = (move _3, move _5);         // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
         StorageDead(_5);                 // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -176,10 +176,10 @@ fn main() -> () {
         StorageLive(_23);                // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
         StorageLive(_24);                // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
         StorageLive(_25);                // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
-        StorageLive(_26);                // scope 0 at $DIR/issue-99325.rs:+2:16: +2:70
-        _26 = function_with_bytes::<&*b"AAAA">() -> [return: bb10, unwind: bb19]; // scope 0 at $DIR/issue-99325.rs:+2:16: +2:70
+        StorageLive(_26);                // scope 0 at $DIR/issue_99325.rs:+2:16: +2:70
+        _26 = function_with_bytes::<&*b"AAAA">() -> [return: bb10, unwind: bb19]; // scope 0 at $DIR/issue_99325.rs:+2:16: +2:70
                                          // mir::Constant
-                                         // + span: $DIR/issue-99325.rs:11:16: 11:68
+                                         // + span: $DIR/issue_99325.rs:11:16: 11:68
                                          // + user_ty: UserType(1)
                                          // + literal: Const { ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}, val: Value() }
     }
@@ -187,10 +187,10 @@ fn main() -> () {
     bb10: {
         _25 = &_26;                      // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
         StorageLive(_27);                // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
-        StorageLive(_28);                // scope 0 at $DIR/issue-99325.rs:+2:72: +2:79
-        _28 = const b"AAAA";             // scope 0 at $DIR/issue-99325.rs:+2:72: +2:79
+        StorageLive(_28);                // scope 0 at $DIR/issue_99325.rs:+2:72: +2:79
+        _28 = const b"AAAA";             // scope 0 at $DIR/issue_99325.rs:+2:72: +2:79
                                          // mir::Constant
-                                         // + span: $DIR/issue-99325.rs:11:72: 11:79
+                                         // + span: $DIR/issue_99325.rs:11:72: 11:79
                                          // + literal: Const { ty: &[u8; 4], val: Value(Scalar(alloc4)) }
         _27 = &_28;                      // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
         _24 = (move _25, move _27);      // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -281,12 +281,12 @@ fn main() -> () {
         StorageDead(_26);                // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
         StorageDead(_24);                // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
         StorageDead(_23);                // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
-        _0 = const ();                   // scope 0 at $DIR/issue-99325.rs:+0:15: +3:2
-        return;                          // scope 0 at $DIR/issue-99325.rs:+3:2: +3:2
+        _0 = const ();                   // scope 0 at $DIR/issue_99325.rs:+0:15: +3:2
+        return;                          // scope 0 at $DIR/issue_99325.rs:+3:2: +3:2
     }
 
     bb19 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue-99325.rs:+0:1: +3:2
+        resume;                          // scope 0 at $DIR/issue_99325.rs:+0:1: +3:2
     }
 }
 
diff --git a/src/test/mir-opt/issue-99325.rs b/src/test/mir-opt/issue_99325.rs
similarity index 100%
rename from src/test/mir-opt/issue-99325.rs
rename to src/test/mir-opt/issue_99325.rs
diff --git a/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir b/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir
index f46c10711f6..1cfa41b4daa 100644
--- a/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir
+++ b/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir
@@ -1,14 +1,14 @@
 // MIR for `num_to_digit` after PreCodegen
 
 fn num_to_digit(_1: char) -> u32 {
-    debug num => _1;                     // in scope 0 at $DIR/issue-59352.rs:+0:21: +0:24
-    let mut _0: u32;                     // return place in scope 0 at $DIR/issue-59352.rs:+0:35: +0:38
-    let mut _2: char;                    // in scope 0 at $DIR/issue-59352.rs:+2:8: +2:11
-    let mut _3: std::option::Option; // in scope 0 at $DIR/issue-59352.rs:+2:26: +2:41
-    let mut _4: char;                    // in scope 0 at $DIR/issue-59352.rs:+2:26: +2:29
-    let mut _5: u32;                     // in scope 0 at $DIR/issue-59352.rs:+2:8: +2:23
+    debug num => _1;                     // in scope 0 at $DIR/issue_59352.rs:+0:21: +0:24
+    let mut _0: u32;                     // return place in scope 0 at $DIR/issue_59352.rs:+0:35: +0:38
+    let mut _2: char;                    // in scope 0 at $DIR/issue_59352.rs:+2:8: +2:11
+    let mut _3: std::option::Option; // in scope 0 at $DIR/issue_59352.rs:+2:26: +2:41
+    let mut _4: char;                    // in scope 0 at $DIR/issue_59352.rs:+2:26: +2:29
+    let mut _5: u32;                     // in scope 0 at $DIR/issue_59352.rs:+2:8: +2:23
     let mut _12: isize;                  // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
-    scope 1 (inlined char::methods::::is_digit) { // at $DIR/issue-59352.rs:14:8: 14:23
+    scope 1 (inlined char::methods::::is_digit) { // at $DIR/issue_59352.rs:14:8: 14:23
         debug self => _2;                // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
         debug radix => _5;               // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
         let mut _6: &std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
@@ -19,7 +19,7 @@ fn num_to_digit(_1: char) -> u32 {
             let mut _9: isize;           // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL
         }
     }
-    scope 3 (inlined #[track_caller] Option::::unwrap) { // at $DIR/issue-59352.rs:14:26: 14:50
+    scope 3 (inlined #[track_caller] Option::::unwrap) { // at $DIR/issue_59352.rs:14:26: 14:50
         debug self => _3;                // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL
         let mut _10: isize;              // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL
         let mut _11: !;                  // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL
@@ -29,9 +29,9 @@ fn num_to_digit(_1: char) -> u32 {
     }
 
     bb0: {
-        StorageLive(_2);                 // scope 0 at $DIR/issue-59352.rs:+2:8: +2:11
-        _2 = _1;                         // scope 0 at $DIR/issue-59352.rs:+2:8: +2:11
-        StorageLive(_5);                 // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23
+        StorageLive(_2);                 // scope 0 at $DIR/issue_59352.rs:+2:8: +2:11
+        _2 = _1;                         // scope 0 at $DIR/issue_59352.rs:+2:8: +2:11
+        StorageLive(_5);                 // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23
         StorageLive(_6);                 // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
         StorageLive(_7);                 // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
         StorageLive(_8);                 // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
@@ -43,30 +43,30 @@ fn num_to_digit(_1: char) -> u32 {
     }
 
     bb1: {
-        StorageDead(_12);                // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23
-        StorageLive(_3);                 // scope 0 at $DIR/issue-59352.rs:+2:26: +2:41
-        StorageLive(_4);                 // scope 0 at $DIR/issue-59352.rs:+2:26: +2:29
-        _4 = _1;                         // scope 0 at $DIR/issue-59352.rs:+2:26: +2:29
-        _3 = char::methods::::to_digit(move _4, const 8_u32) -> bb2; // scope 0 at $DIR/issue-59352.rs:+2:26: +2:41
+        StorageDead(_12);                // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23
+        StorageLive(_3);                 // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41
+        StorageLive(_4);                 // scope 0 at $DIR/issue_59352.rs:+2:26: +2:29
+        _4 = _1;                         // scope 0 at $DIR/issue_59352.rs:+2:26: +2:29
+        _3 = char::methods::::to_digit(move _4, const 8_u32) -> bb2; // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41
                                          // mir::Constant
-                                         // + span: $DIR/issue-59352.rs:14:30: 14:38
+                                         // + span: $DIR/issue_59352.rs:14:30: 14:38
                                          // + literal: Const { ty: fn(char, u32) -> Option {char::methods::::to_digit}, val: Value() }
     }
 
     bb2: {
-        StorageDead(_4);                 // scope 0 at $DIR/issue-59352.rs:+2:40: +2:41
+        StorageDead(_4);                 // scope 0 at $DIR/issue_59352.rs:+2:40: +2:41
         _10 = discriminant(_3);          // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL
         switchInt(move _10) -> [0_isize: bb6, 1_isize: bb8, otherwise: bb7]; // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL
     }
 
     bb3: {
-        StorageDead(_12);                // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23
-        _0 = const 0_u32;                // scope 0 at $DIR/issue-59352.rs:+2:60: +2:61
-        goto -> bb4;                     // scope 0 at $DIR/issue-59352.rs:+2:5: +2:63
+        StorageDead(_12);                // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23
+        _0 = const 0_u32;                // scope 0 at $DIR/issue_59352.rs:+2:60: +2:61
+        goto -> bb4;                     // scope 0 at $DIR/issue_59352.rs:+2:5: +2:63
     }
 
     bb4: {
-        return;                          // scope 0 at $DIR/issue-59352.rs:+3:2: +3:2
+        return;                          // scope 0 at $DIR/issue_59352.rs:+3:2: +3:2
     }
 
     bb5: {
@@ -77,9 +77,9 @@ fn num_to_digit(_1: char) -> u32 {
         _12 = move _9;                   // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
         StorageDead(_6);                 // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
         StorageDead(_7);                 // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
-        StorageDead(_5);                 // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23
-        StorageDead(_2);                 // scope 0 at $DIR/issue-59352.rs:+2:22: +2:23
-        switchInt(move _12) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23
+        StorageDead(_5);                 // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23
+        StorageDead(_2);                 // scope 0 at $DIR/issue_59352.rs:+2:22: +2:23
+        switchInt(move _12) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23
     }
 
     bb6: {
@@ -99,7 +99,7 @@ fn num_to_digit(_1: char) -> u32 {
 
     bb8: {
         _0 = move ((_3 as Some).0: u32); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL
-        StorageDead(_3);                 // scope 0 at $DIR/issue-59352.rs:+2:49: +2:50
-        goto -> bb4;                     // scope 0 at $DIR/issue-59352.rs:+2:5: +2:63
+        StorageDead(_3);                 // scope 0 at $DIR/issue_59352.rs:+2:49: +2:50
+        goto -> bb4;                     // scope 0 at $DIR/issue_59352.rs:+2:5: +2:63
     }
 }
diff --git a/src/test/mir-opt/issues/issue-59352.rs b/src/test/mir-opt/issues/issue_59352.rs
similarity index 100%
rename from src/test/mir-opt/issues/issue-59352.rs
rename to src/test/mir-opt/issues/issue_59352.rs
diff --git a/src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff b/src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff
index 2ee4332ad38..87066cc62c0 100644
--- a/src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff
+++ b/src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff
@@ -2,17 +2,17 @@
 + // MIR for `foo` after MatchBranchSimplification
   
   fn foo(_1: [u8; 16]) -> Option<[u8; 4]> {
-      debug bytes => _1;                   // in scope 0 at $DIR/issue-75439.rs:+0:12: +0:17
-      let mut _0: std::option::Option<[u8; 4]>; // return place in scope 0 at $DIR/issue-75439.rs:+0:32: +0:47
-      let _2: [u32; 4];                    // in scope 0 at $DIR/issue-75439.rs:+2:9: +2:15
-      let mut _3: [u8; 16];                // in scope 0 at $DIR/issue-75439.rs:+2:47: +2:52
-      let mut _5: [u8; 4];                 // in scope 0 at $DIR/issue-75439.rs:+5:14: +5:38
-      let mut _6: u32;                     // in scope 0 at $DIR/issue-75439.rs:+5:33: +5:35
+      debug bytes => _1;                   // in scope 0 at $DIR/issue_75439.rs:+0:12: +0:17
+      let mut _0: std::option::Option<[u8; 4]>; // return place in scope 0 at $DIR/issue_75439.rs:+0:32: +0:47
+      let _2: [u32; 4];                    // in scope 0 at $DIR/issue_75439.rs:+2:9: +2:15
+      let mut _3: [u8; 16];                // in scope 0 at $DIR/issue_75439.rs:+2:47: +2:52
+      let mut _5: [u8; 4];                 // in scope 0 at $DIR/issue_75439.rs:+5:14: +5:38
+      let mut _6: u32;                     // in scope 0 at $DIR/issue_75439.rs:+5:33: +5:35
       scope 1 {
-          debug dwords => _2;              // in scope 1 at $DIR/issue-75439.rs:+2:9: +2:15
+          debug dwords => _2;              // in scope 1 at $DIR/issue_75439.rs:+2:9: +2:15
           scope 3 {
-              debug ip => _4;              // in scope 3 at $DIR/issue-75439.rs:+4:27: +4:29
-              let _4: u32;                 // in scope 3 at $DIR/issue-75439.rs:+4:27: +4:29
+              debug ip => _4;              // in scope 3 at $DIR/issue_75439.rs:+4:27: +4:29
+              let _4: u32;                 // in scope 3 at $DIR/issue_75439.rs:+4:27: +4:29
               scope 4 {
               }
           }
@@ -21,69 +21,69 @@
       }
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/issue-75439.rs:+2:9: +2:15
-          StorageLive(_3);                 // scope 2 at $DIR/issue-75439.rs:+2:47: +2:52
-          _3 = _1;                         // scope 2 at $DIR/issue-75439.rs:+2:47: +2:52
-          _2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue-75439.rs:+2:37: +2:53
+          StorageLive(_2);                 // scope 0 at $DIR/issue_75439.rs:+2:9: +2:15
+          StorageLive(_3);                 // scope 2 at $DIR/issue_75439.rs:+2:47: +2:52
+          _3 = _1;                         // scope 2 at $DIR/issue_75439.rs:+2:47: +2:52
+          _2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue_75439.rs:+2:37: +2:53
                                            // mir::Constant
-                                           // + span: $DIR/issue-75439.rs:7:37: 7:46
+                                           // + span: $DIR/issue_75439.rs:7:37: 7:46
                                            // + literal: Const { ty: unsafe extern "rust-intrinsic" fn([u8; 16]) -> [u32; 4] {transmute::<[u8; 16], [u32; 4]>}, val: Value() }
       }
   
       bb1: {
-          StorageDead(_3);                 // scope 2 at $DIR/issue-75439.rs:+2:52: +2:53
-          switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb8]; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30
+          StorageDead(_3);                 // scope 2 at $DIR/issue_75439.rs:+2:52: +2:53
+          switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb8]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30
       }
   
       bb2: {
-          switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb8]; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30
+          switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb8]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30
       }
   
       bb3: {
-          switchInt(_2[2 of 4]) -> [0_u32: bb5, 4294901760_u32: bb6, otherwise: bb8]; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30
+          switchInt(_2[2 of 4]) -> [0_u32: bb5, 4294901760_u32: bb6, otherwise: bb8]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30
       }
   
       bb4: {
-          StorageLive(_5);                 // scope 3 at $DIR/issue-75439.rs:+5:14: +5:38
-          StorageLive(_6);                 // scope 4 at $DIR/issue-75439.rs:+5:33: +5:35
-          _6 = _4;                         // scope 4 at $DIR/issue-75439.rs:+5:33: +5:35
-          _5 = transmute::(move _6) -> bb7; // scope 4 at $DIR/issue-75439.rs:+5:23: +5:36
+          StorageLive(_5);                 // scope 3 at $DIR/issue_75439.rs:+5:14: +5:38
+          StorageLive(_6);                 // scope 4 at $DIR/issue_75439.rs:+5:33: +5:35
+          _6 = _4;                         // scope 4 at $DIR/issue_75439.rs:+5:33: +5:35
+          _5 = transmute::(move _6) -> bb7; // scope 4 at $DIR/issue_75439.rs:+5:23: +5:36
                                            // mir::Constant
-                                           // + span: $DIR/issue-75439.rs:10:23: 10:32
+                                           // + span: $DIR/issue_75439.rs:10:23: 10:32
                                            // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) -> [u8; 4] {transmute::}, val: Value() }
       }
   
       bb5: {
-          StorageLive(_4);                 // scope 3 at $DIR/issue-75439.rs:+4:27: +4:29
-          _4 = _2[3 of 4];                 // scope 3 at $DIR/issue-75439.rs:+4:27: +4:29
-          goto -> bb4;                     // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30
+          StorageLive(_4);                 // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29
+          _4 = _2[3 of 4];                 // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29
+          goto -> bb4;                     // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30
       }
   
       bb6: {
-          StorageLive(_4);                 // scope 3 at $DIR/issue-75439.rs:+4:27: +4:29
-          _4 = _2[3 of 4];                 // scope 3 at $DIR/issue-75439.rs:+4:27: +4:29
-          goto -> bb4;                     // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30
+          StorageLive(_4);                 // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29
+          _4 = _2[3 of 4];                 // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29
+          goto -> bb4;                     // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30
       }
   
       bb7: {
-          StorageDead(_6);                 // scope 4 at $DIR/issue-75439.rs:+5:35: +5:36
-          Deinit(_0);                      // scope 3 at $DIR/issue-75439.rs:+5:9: +5:39
-          ((_0 as Some).0: [u8; 4]) = move _5; // scope 3 at $DIR/issue-75439.rs:+5:9: +5:39
-          discriminant(_0) = 1;            // scope 3 at $DIR/issue-75439.rs:+5:9: +5:39
-          StorageDead(_5);                 // scope 3 at $DIR/issue-75439.rs:+5:38: +5:39
-          StorageDead(_4);                 // scope 1 at $DIR/issue-75439.rs:+6:5: +6:6
-          goto -> bb9;                     // scope 1 at $DIR/issue-75439.rs:+4:5: +8:6
+          StorageDead(_6);                 // scope 4 at $DIR/issue_75439.rs:+5:35: +5:36
+          Deinit(_0);                      // scope 3 at $DIR/issue_75439.rs:+5:9: +5:39
+          ((_0 as Some).0: [u8; 4]) = move _5; // scope 3 at $DIR/issue_75439.rs:+5:9: +5:39
+          discriminant(_0) = 1;            // scope 3 at $DIR/issue_75439.rs:+5:9: +5:39
+          StorageDead(_5);                 // scope 3 at $DIR/issue_75439.rs:+5:38: +5:39
+          StorageDead(_4);                 // scope 1 at $DIR/issue_75439.rs:+6:5: +6:6
+          goto -> bb9;                     // scope 1 at $DIR/issue_75439.rs:+4:5: +8:6
       }
   
       bb8: {
-          Deinit(_0);                      // scope 1 at $DIR/issue-75439.rs:+7:9: +7:13
-          discriminant(_0) = 0;            // scope 1 at $DIR/issue-75439.rs:+7:9: +7:13
-          goto -> bb9;                     // scope 1 at $DIR/issue-75439.rs:+4:5: +8:6
+          Deinit(_0);                      // scope 1 at $DIR/issue_75439.rs:+7:9: +7:13
+          discriminant(_0) = 0;            // scope 1 at $DIR/issue_75439.rs:+7:9: +7:13
+          goto -> bb9;                     // scope 1 at $DIR/issue_75439.rs:+4:5: +8:6
       }
   
       bb9: {
-          StorageDead(_2);                 // scope 0 at $DIR/issue-75439.rs:+9:1: +9:2
-          return;                          // scope 0 at $DIR/issue-75439.rs:+9:2: +9:2
+          StorageDead(_2);                 // scope 0 at $DIR/issue_75439.rs:+9:1: +9:2
+          return;                          // scope 0 at $DIR/issue_75439.rs:+9:2: +9:2
       }
   }
   
diff --git a/src/test/mir-opt/issues/issue-75439.rs b/src/test/mir-opt/issues/issue_75439.rs
similarity index 100%
rename from src/test/mir-opt/issues/issue-75439.rs
rename to src/test/mir-opt/issues/issue_75439.rs
diff --git a/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff
index 25ab0c9f7f4..d3db3b18271 100644
--- a/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff
+++ b/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff
@@ -2,271 +2,271 @@
 + // MIR for `complicated_match` after ElaborateDrops
   
   fn complicated_match(_1: bool, _2: (bool, bool, String)) -> i32 {
-      debug cond => _1;                    // in scope 0 at $DIR/match-arm-scopes.rs:+0:22: +0:26
-      debug items => _2;                   // in scope 0 at $DIR/match-arm-scopes.rs:+0:34: +0:39
-      let mut _0: i32;                     // return place in scope 0 at $DIR/match-arm-scopes.rs:+0:66: +0:69
-      let mut _3: &bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16
-      let mut _4: &bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16
-      let _5: bool;                        // in scope 0 at $DIR/match-arm-scopes.rs:+2:17: +2:18
-      let _6: &bool;                       // in scope 0 at $DIR/match-arm-scopes.rs:+2:17: +2:18
-      let _7: std::string::String;         // in scope 0 at $DIR/match-arm-scopes.rs:+2:20: +2:21
-      let _8: &std::string::String;        // in scope 0 at $DIR/match-arm-scopes.rs:+2:20: +2:21
-      let mut _9: bool;                    // in scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73
-      let mut _10: bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49
-      let mut _11: !;                      // in scope 0 at $DIR/match-arm-scopes.rs:+2:52: +2:60
-      let mut _12: bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73
-      let mut _13: bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49
-      let mut _14: !;                      // in scope 0 at $DIR/match-arm-scopes.rs:+2:52: +2:60
-      let _15: bool;                       // in scope 0 at $DIR/match-arm-scopes.rs:+3:16: +3:17
-      let _16: std::string::String;        // in scope 0 at $DIR/match-arm-scopes.rs:+3:19: +3:20
+      debug cond => _1;                    // in scope 0 at $DIR/match_arm_scopes.rs:+0:22: +0:26
+      debug items => _2;                   // in scope 0 at $DIR/match_arm_scopes.rs:+0:34: +0:39
+      let mut _0: i32;                     // return place in scope 0 at $DIR/match_arm_scopes.rs:+0:66: +0:69
+      let mut _3: &bool;                   // in scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16
+      let mut _4: &bool;                   // in scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16
+      let _5: bool;                        // in scope 0 at $DIR/match_arm_scopes.rs:+2:17: +2:18
+      let _6: &bool;                       // in scope 0 at $DIR/match_arm_scopes.rs:+2:17: +2:18
+      let _7: std::string::String;         // in scope 0 at $DIR/match_arm_scopes.rs:+2:20: +2:21
+      let _8: &std::string::String;        // in scope 0 at $DIR/match_arm_scopes.rs:+2:20: +2:21
+      let mut _9: bool;                    // in scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73
+      let mut _10: bool;                   // in scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49
+      let mut _11: !;                      // in scope 0 at $DIR/match_arm_scopes.rs:+2:52: +2:60
+      let mut _12: bool;                   // in scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73
+      let mut _13: bool;                   // in scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49
+      let mut _14: !;                      // in scope 0 at $DIR/match_arm_scopes.rs:+2:52: +2:60
+      let _15: bool;                       // in scope 0 at $DIR/match_arm_scopes.rs:+3:16: +3:17
+      let _16: std::string::String;        // in scope 0 at $DIR/match_arm_scopes.rs:+3:19: +3:20
       scope 1 {
-          debug a => _5;                   // in scope 1 at $DIR/match-arm-scopes.rs:+2:17: +2:18
-          debug a => _6;                   // in scope 1 at $DIR/match-arm-scopes.rs:+2:17: +2:18
-          debug s => _7;                   // in scope 1 at $DIR/match-arm-scopes.rs:+2:20: +2:21
-          debug s => _8;                   // in scope 1 at $DIR/match-arm-scopes.rs:+2:20: +2:21
+          debug a => _5;                   // in scope 1 at $DIR/match_arm_scopes.rs:+2:17: +2:18
+          debug a => _6;                   // in scope 1 at $DIR/match_arm_scopes.rs:+2:17: +2:18
+          debug s => _7;                   // in scope 1 at $DIR/match_arm_scopes.rs:+2:20: +2:21
+          debug s => _8;                   // in scope 1 at $DIR/match_arm_scopes.rs:+2:20: +2:21
       }
       scope 2 {
-          debug b => _15;                  // in scope 2 at $DIR/match-arm-scopes.rs:+3:16: +3:17
-          debug t => _16;                  // in scope 2 at $DIR/match-arm-scopes.rs:+3:19: +3:20
+          debug b => _15;                  // in scope 2 at $DIR/match_arm_scopes.rs:+3:16: +3:17
+          debug t => _16;                  // in scope 2 at $DIR/match_arm_scopes.rs:+3:19: +3:20
       }
   
       bb0: {
--         FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16
--         switchInt((_2.0: bool)) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +1:16
-+         switchInt((_2.0: bool)) -> [false: bb5, otherwise: bb1]; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +1:16
+-         FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16
+-         switchInt((_2.0: bool)) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +1:16
++         switchInt((_2.0: bool)) -> [false: bb5, otherwise: bb1]; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +1:16
       }
   
       bb1: {
--         falseEdge -> [real: bb8, imaginary: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:+2:9: +2:22
-+         switchInt((_2.1: bool)) -> [false: bb10, otherwise: bb2]; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +1:16
+-         falseEdge -> [real: bb8, imaginary: bb3]; // scope 0 at $DIR/match_arm_scopes.rs:+2:9: +2:22
++         switchInt((_2.1: bool)) -> [false: bb10, otherwise: bb2]; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +1:16
       }
   
       bb2: {
--         switchInt((_2.1: bool)) -> [false: bb3, otherwise: bb4]; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +1:16
-+         switchInt((_2.0: bool)) -> [false: bb3, otherwise: bb17]; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +1:16
+-         switchInt((_2.1: bool)) -> [false: bb3, otherwise: bb4]; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +1:16
++         switchInt((_2.0: bool)) -> [false: bb3, otherwise: bb17]; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +1:16
       }
   
       bb3: {
--         falseEdge -> [real: bb13, imaginary: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:+2:25: +2:38
+-         falseEdge -> [real: bb13, imaginary: bb5]; // scope 0 at $DIR/match_arm_scopes.rs:+2:25: +2:38
 -     }
 - 
 -     bb4: {
--         switchInt((_2.0: bool)) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +1:16
+-         switchInt((_2.0: bool)) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +1:16
 -     }
 - 
 -     bb5: {
--         falseEdge -> [real: bb20, imaginary: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:+3:9: +3:21
+-         falseEdge -> [real: bb20, imaginary: bb6]; // scope 0 at $DIR/match_arm_scopes.rs:+3:9: +3:21
 -     }
 - 
 -     bb6: {
-          StorageLive(_15);                // scope 0 at $DIR/match-arm-scopes.rs:+3:32: +3:33
-          _15 = (_2.1: bool);              // scope 0 at $DIR/match-arm-scopes.rs:+3:32: +3:33
-          StorageLive(_16);                // scope 0 at $DIR/match-arm-scopes.rs:+3:35: +3:36
-          _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:+3:35: +3:36
--         goto -> bb19;                    // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6
-+         goto -> bb16;                    // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6
+          StorageLive(_15);                // scope 0 at $DIR/match_arm_scopes.rs:+3:32: +3:33
+          _15 = (_2.1: bool);              // scope 0 at $DIR/match_arm_scopes.rs:+3:32: +3:33
+          StorageLive(_16);                // scope 0 at $DIR/match_arm_scopes.rs:+3:35: +3:36
+          _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match_arm_scopes.rs:+3:35: +3:36
+-         goto -> bb19;                    // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6
++         goto -> bb16;                    // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6
       }
   
 -     bb7: {
 +     bb4: {
-          _0 = const 1_i32;                // scope 1 at $DIR/match-arm-scopes.rs:+2:77: +2:78
--         drop(_7) -> [return: bb18, unwind: bb25]; // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
-+         drop(_7) -> [return: bb15, unwind: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
+          _0 = const 1_i32;                // scope 1 at $DIR/match_arm_scopes.rs:+2:77: +2:78
+-         drop(_7) -> [return: bb18, unwind: bb25]; // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
++         drop(_7) -> [return: bb15, unwind: bb22]; // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
       }
   
 -     bb8: {
 +     bb5: {
-          StorageLive(_6);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:17: +2:18
-          _6 = &(_2.1: bool);              // scope 0 at $DIR/match-arm-scopes.rs:+2:17: +2:18
-          StorageLive(_8);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:20: +2:21
-          _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:+2:20: +2:21
--         _3 = &shallow (_2.0: bool);      // scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16
--         _4 = &shallow (_2.1: bool);      // scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16
-          StorageLive(_9);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73
-          StorageLive(_10);                // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49
-          _10 = _1;                        // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49
--         switchInt(move _10) -> [false: bb10, otherwise: bb9]; // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49
-+         switchInt(move _10) -> [false: bb7, otherwise: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49
+          StorageLive(_6);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:17: +2:18
+          _6 = &(_2.1: bool);              // scope 0 at $DIR/match_arm_scopes.rs:+2:17: +2:18
+          StorageLive(_8);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:20: +2:21
+          _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match_arm_scopes.rs:+2:20: +2:21
+-         _3 = &shallow (_2.0: bool);      // scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16
+-         _4 = &shallow (_2.1: bool);      // scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16
+          StorageLive(_9);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73
+          StorageLive(_10);                // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49
+          _10 = _1;                        // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49
+-         switchInt(move _10) -> [false: bb10, otherwise: bb9]; // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49
++         switchInt(move _10) -> [false: bb7, otherwise: bb6]; // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49
       }
   
 -     bb9: {
 +     bb6: {
-          _0 = const 3_i32;                // scope 0 at $DIR/match-arm-scopes.rs:+2:59: +2:60
-          StorageDead(_10);                // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
-          StorageDead(_9);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
+          _0 = const 3_i32;                // scope 0 at $DIR/match_arm_scopes.rs:+2:59: +2:60
+          StorageDead(_10);                // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+          StorageDead(_9);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
 -         goto -> bb23;                    // scope 0 at no-location
 +         goto -> bb20;                    // scope 0 at no-location
       }
   
 -     bb10: {
 +     bb7: {
-          _9 = (*_6);                      // scope 0 at $DIR/match-arm-scopes.rs:+2:70: +2:71
--         switchInt(move _9) -> [false: bb12, otherwise: bb11]; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73
-+         switchInt(move _9) -> [false: bb9, otherwise: bb8]; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73
+          _9 = (*_6);                      // scope 0 at $DIR/match_arm_scopes.rs:+2:70: +2:71
+-         switchInt(move _9) -> [false: bb12, otherwise: bb11]; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73
++         switchInt(move _9) -> [false: bb9, otherwise: bb8]; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73
       }
   
 -     bb11: {
 +     bb8: {
-          StorageDead(_10);                // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
-          StorageDead(_9);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
--         FakeRead(ForMatchGuard, _3);     // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
--         FakeRead(ForMatchGuard, _4);     // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
--         FakeRead(ForGuardBinding, _6);   // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
--         FakeRead(ForGuardBinding, _8);   // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
-          StorageLive(_5);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:17: +2:18
-          _5 = (_2.1: bool);               // scope 0 at $DIR/match-arm-scopes.rs:+2:17: +2:18
-          StorageLive(_7);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:20: +2:21
-          _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:+2:20: +2:21
--         goto -> bb7;                     // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6
-+         goto -> bb4;                     // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6
+          StorageDead(_10);                // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+          StorageDead(_9);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+-         FakeRead(ForMatchGuard, _3);     // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+-         FakeRead(ForMatchGuard, _4);     // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+-         FakeRead(ForGuardBinding, _6);   // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+-         FakeRead(ForGuardBinding, _8);   // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+          StorageLive(_5);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:17: +2:18
+          _5 = (_2.1: bool);               // scope 0 at $DIR/match_arm_scopes.rs:+2:17: +2:18
+          StorageLive(_7);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:20: +2:21
+          _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match_arm_scopes.rs:+2:20: +2:21
+-         goto -> bb7;                     // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6
++         goto -> bb4;                     // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6
       }
   
 -     bb12: {
 +     bb9: {
-          StorageDead(_10);                // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
-          StorageDead(_9);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
-          StorageDead(_8);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
-          StorageDead(_6);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
--         falseEdge -> [real: bb2, imaginary: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73
-+         goto -> bb1;                     // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73
+          StorageDead(_10);                // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+          StorageDead(_9);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+          StorageDead(_8);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
+          StorageDead(_6);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
+-         falseEdge -> [real: bb2, imaginary: bb3]; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73
++         goto -> bb1;                     // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73
       }
   
 -     bb13: {
 +     bb10: {
-          StorageLive(_6);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:26: +2:27
-          _6 = &(_2.0: bool);              // scope 0 at $DIR/match-arm-scopes.rs:+2:26: +2:27
-          StorageLive(_8);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:36: +2:37
-          _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:+2:36: +2:37
--         _3 = &shallow (_2.0: bool);      // scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16
--         _4 = &shallow (_2.1: bool);      // scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16
-          StorageLive(_12);                // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73
-          StorageLive(_13);                // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49
-          _13 = _1;                        // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49
--         switchInt(move _13) -> [false: bb15, otherwise: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49
-+         switchInt(move _13) -> [false: bb12, otherwise: bb11]; // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49
+          StorageLive(_6);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:26: +2:27
+          _6 = &(_2.0: bool);              // scope 0 at $DIR/match_arm_scopes.rs:+2:26: +2:27
+          StorageLive(_8);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:36: +2:37
+          _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match_arm_scopes.rs:+2:36: +2:37
+-         _3 = &shallow (_2.0: bool);      // scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16
+-         _4 = &shallow (_2.1: bool);      // scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16
+          StorageLive(_12);                // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73
+          StorageLive(_13);                // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49
+          _13 = _1;                        // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49
+-         switchInt(move _13) -> [false: bb15, otherwise: bb14]; // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49
++         switchInt(move _13) -> [false: bb12, otherwise: bb11]; // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49
       }
   
 -     bb14: {
 +     bb11: {
-          _0 = const 3_i32;                // scope 0 at $DIR/match-arm-scopes.rs:+2:59: +2:60
-          StorageDead(_13);                // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
-          StorageDead(_12);                // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
+          _0 = const 3_i32;                // scope 0 at $DIR/match_arm_scopes.rs:+2:59: +2:60
+          StorageDead(_13);                // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+          StorageDead(_12);                // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
 -         goto -> bb23;                    // scope 0 at no-location
 +         goto -> bb20;                    // scope 0 at no-location
       }
   
 -     bb15: {
 +     bb12: {
-          _12 = (*_6);                     // scope 0 at $DIR/match-arm-scopes.rs:+2:70: +2:71
--         switchInt(move _12) -> [false: bb17, otherwise: bb16]; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73
-+         switchInt(move _12) -> [false: bb14, otherwise: bb13]; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73
+          _12 = (*_6);                     // scope 0 at $DIR/match_arm_scopes.rs:+2:70: +2:71
+-         switchInt(move _12) -> [false: bb17, otherwise: bb16]; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73
++         switchInt(move _12) -> [false: bb14, otherwise: bb13]; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73
       }
   
 -     bb16: {
 +     bb13: {
-          StorageDead(_13);                // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
-          StorageDead(_12);                // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
--         FakeRead(ForMatchGuard, _3);     // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
--         FakeRead(ForMatchGuard, _4);     // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
--         FakeRead(ForGuardBinding, _6);   // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
--         FakeRead(ForGuardBinding, _8);   // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
-          StorageLive(_5);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:26: +2:27
-          _5 = (_2.0: bool);               // scope 0 at $DIR/match-arm-scopes.rs:+2:26: +2:27
-          StorageLive(_7);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:36: +2:37
-          _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:+2:36: +2:37
--         goto -> bb7;                     // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6
-+         goto -> bb4;                     // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6
+          StorageDead(_13);                // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+          StorageDead(_12);                // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+-         FakeRead(ForMatchGuard, _3);     // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+-         FakeRead(ForMatchGuard, _4);     // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+-         FakeRead(ForGuardBinding, _6);   // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+-         FakeRead(ForGuardBinding, _8);   // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+          StorageLive(_5);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:26: +2:27
+          _5 = (_2.0: bool);               // scope 0 at $DIR/match_arm_scopes.rs:+2:26: +2:27
+          StorageLive(_7);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:36: +2:37
+          _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match_arm_scopes.rs:+2:36: +2:37
+-         goto -> bb7;                     // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6
++         goto -> bb4;                     // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6
       }
   
 -     bb17: {
 +     bb14: {
-          StorageDead(_13);                // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
-          StorageDead(_12);                // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73
-          StorageDead(_8);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
-          StorageDead(_6);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
--         falseEdge -> [real: bb4, imaginary: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73
-+         goto -> bb2;                     // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73
+          StorageDead(_13);                // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+          StorageDead(_12);                // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73
+          StorageDead(_8);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
+          StorageDead(_6);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
+-         falseEdge -> [real: bb4, imaginary: bb5]; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73
++         goto -> bb2;                     // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73
       }
   
 -     bb18: {
 +     bb15: {
-          StorageDead(_7);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
-          StorageDead(_5);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
-          StorageDead(_8);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
-          StorageDead(_6);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
--         goto -> bb22;                    // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
-+         goto -> bb19;                    // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
+          StorageDead(_7);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
+          StorageDead(_5);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
+          StorageDead(_8);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
+          StorageDead(_6);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
+-         goto -> bb22;                    // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
++         goto -> bb19;                    // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
       }
   
 -     bb19: {
 +     bb16: {
-          _0 = const 2_i32;                // scope 2 at $DIR/match-arm-scopes.rs:+3:41: +3:42
--         drop(_16) -> [return: bb21, unwind: bb25]; // scope 0 at $DIR/match-arm-scopes.rs:+3:41: +3:42
-+         drop(_16) -> [return: bb18, unwind: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:+3:41: +3:42
+          _0 = const 2_i32;                // scope 2 at $DIR/match_arm_scopes.rs:+3:41: +3:42
+-         drop(_16) -> [return: bb21, unwind: bb25]; // scope 0 at $DIR/match_arm_scopes.rs:+3:41: +3:42
++         drop(_16) -> [return: bb18, unwind: bb22]; // scope 0 at $DIR/match_arm_scopes.rs:+3:41: +3:42
       }
   
 -     bb20: {
 +     bb17: {
-          StorageLive(_15);                // scope 0 at $DIR/match-arm-scopes.rs:+3:16: +3:17
-          _15 = (_2.1: bool);              // scope 0 at $DIR/match-arm-scopes.rs:+3:16: +3:17
-          StorageLive(_16);                // scope 0 at $DIR/match-arm-scopes.rs:+3:19: +3:20
-          _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:+3:19: +3:20
--         goto -> bb19;                    // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6
-+         goto -> bb16;                    // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6
+          StorageLive(_15);                // scope 0 at $DIR/match_arm_scopes.rs:+3:16: +3:17
+          _15 = (_2.1: bool);              // scope 0 at $DIR/match_arm_scopes.rs:+3:16: +3:17
+          StorageLive(_16);                // scope 0 at $DIR/match_arm_scopes.rs:+3:19: +3:20
+          _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match_arm_scopes.rs:+3:19: +3:20
+-         goto -> bb19;                    // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6
++         goto -> bb16;                    // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6
       }
   
 -     bb21: {
 +     bb18: {
-          StorageDead(_16);                // scope 0 at $DIR/match-arm-scopes.rs:+3:41: +3:42
-          StorageDead(_15);                // scope 0 at $DIR/match-arm-scopes.rs:+3:41: +3:42
--         goto -> bb22;                    // scope 0 at $DIR/match-arm-scopes.rs:+3:41: +3:42
-+         goto -> bb19;                    // scope 0 at $DIR/match-arm-scopes.rs:+3:41: +3:42
+          StorageDead(_16);                // scope 0 at $DIR/match_arm_scopes.rs:+3:41: +3:42
+          StorageDead(_15);                // scope 0 at $DIR/match_arm_scopes.rs:+3:41: +3:42
+-         goto -> bb22;                    // scope 0 at $DIR/match_arm_scopes.rs:+3:41: +3:42
++         goto -> bb19;                    // scope 0 at $DIR/match_arm_scopes.rs:+3:41: +3:42
       }
   
 -     bb22: {
--         drop(_2) -> [return: bb24, unwind: bb26]; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2
+-         drop(_2) -> [return: bb24, unwind: bb26]; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2
 +     bb19: {
-+         goto -> bb26;                    // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2
++         goto -> bb26;                    // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2
       }
   
 -     bb23: {
 +     bb20: {
-          StorageDead(_8);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
-          StorageDead(_6);                 // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78
--         drop(_2) -> [return: bb24, unwind: bb26]; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2
-+         drop(_2) -> [return: bb21, unwind: bb23]; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2
+          StorageDead(_8);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
+          StorageDead(_6);                 // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78
+-         drop(_2) -> [return: bb24, unwind: bb26]; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2
++         drop(_2) -> [return: bb21, unwind: bb23]; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2
       }
   
 -     bb24: {
 +     bb21: {
-          return;                          // scope 0 at $DIR/match-arm-scopes.rs:+5:2: +5:2
+          return;                          // scope 0 at $DIR/match_arm_scopes.rs:+5:2: +5:2
       }
   
 -     bb25 (cleanup): {
--         drop(_2) -> bb26;                // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2
+-         drop(_2) -> bb26;                // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2
 +     bb22 (cleanup): {
-+         goto -> bb27;                    // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2
++         goto -> bb27;                    // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2
       }
   
 -     bb26 (cleanup): {
 +     bb23 (cleanup): {
-          resume;                          // scope 0 at $DIR/match-arm-scopes.rs:+0:1: +5:2
+          resume;                          // scope 0 at $DIR/match_arm_scopes.rs:+0:1: +5:2
 +     }
 + 
 +     bb24: {
-+         goto -> bb21;                    // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2
++         goto -> bb21;                    // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2
 +     }
 + 
 +     bb25 (cleanup): {
-+         goto -> bb23;                    // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2
++         goto -> bb23;                    // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2
 +     }
 + 
 +     bb26: {
-+         goto -> bb24;                    // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2
++         goto -> bb24;                    // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2
 +     }
 + 
 +     bb27 (cleanup): {
-+         goto -> bb23;                    // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2
++         goto -> bb23;                    // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2
       }
   }
   
diff --git a/src/test/mir-opt/match-arm-scopes.rs b/src/test/mir-opt/match_arm_scopes.rs
similarity index 100%
rename from src/test/mir-opt/match-arm-scopes.rs
rename to src/test/mir-opt/match_arm_scopes.rs
diff --git a/src/test/mir-opt/nll/named-lifetimes-basic.rs b/src/test/mir-opt/nll/named_lifetimes_basic.rs
similarity index 100%
rename from src/test/mir-opt/nll/named-lifetimes-basic.rs
rename to src/test/mir-opt/nll/named_lifetimes_basic.rs
diff --git a/src/test/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir b/src/test/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir
index 0ab9d712d9f..6cd6d8b7795 100644
--- a/src/test/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir
+++ b/src/test/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir
@@ -24,24 +24,24 @@
 | '_#2r live at {bb0[0..=1]}
 | '_#3r live at {bb0[0..=1]}
 | '_#4r live at {bb0[0..=1]}
-| '_#1r: '_#5r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27) ($DIR/named-lifetimes-basic.rs:12:26: 12:27 (#0)
-| '_#1r: '_#7r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55) ($DIR/named-lifetimes-basic.rs:12:54: 12:55 (#0)
-| '_#2r: '_#6r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43) ($DIR/named-lifetimes-basic.rs:12:42: 12:43 (#0)
-| '_#3r: '_#8r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67) ($DIR/named-lifetimes-basic.rs:12:66: 12:67 (#0)
-| '_#5r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27) ($DIR/named-lifetimes-basic.rs:12:26: 12:27 (#0)
-| '_#6r: '_#2r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43) ($DIR/named-lifetimes-basic.rs:12:42: 12:43 (#0)
-| '_#7r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55) ($DIR/named-lifetimes-basic.rs:12:54: 12:55 (#0)
-| '_#8r: '_#3r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67) ($DIR/named-lifetimes-basic.rs:12:66: 12:67 (#0)
+| '_#1r: '_#5r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:26: 12:27) ($DIR/named_lifetimes_basic.rs:12:26: 12:27 (#0)
+| '_#1r: '_#7r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:54: 12:55) ($DIR/named_lifetimes_basic.rs:12:54: 12:55 (#0)
+| '_#2r: '_#6r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:42: 12:43) ($DIR/named_lifetimes_basic.rs:12:42: 12:43 (#0)
+| '_#3r: '_#8r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:66: 12:67) ($DIR/named_lifetimes_basic.rs:12:66: 12:67 (#0)
+| '_#5r: '_#1r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:26: 12:27) ($DIR/named_lifetimes_basic.rs:12:26: 12:27 (#0)
+| '_#6r: '_#2r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:42: 12:43) ($DIR/named_lifetimes_basic.rs:12:42: 12:43 (#0)
+| '_#7r: '_#1r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:54: 12:55) ($DIR/named_lifetimes_basic.rs:12:54: 12:55 (#0)
+| '_#8r: '_#3r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:66: 12:67) ($DIR/named_lifetimes_basic.rs:12:66: 12:67 (#0)
 |
 fn use_x(_1: &'_#5r mut i32, _2: &'_#6r u32, _3: &'_#7r u32, _4: &'_#8r u32) -> bool {
-    debug w => _1;                       // in scope 0 at $DIR/named-lifetimes-basic.rs:+0:26: +0:27
-    debug x => _2;                       // in scope 0 at $DIR/named-lifetimes-basic.rs:+0:42: +0:43
-    debug y => _3;                       // in scope 0 at $DIR/named-lifetimes-basic.rs:+0:54: +0:55
-    debug z => _4;                       // in scope 0 at $DIR/named-lifetimes-basic.rs:+0:66: +0:67
-    let mut _0: bool;                    // return place in scope 0 at $DIR/named-lifetimes-basic.rs:+0:81: +0:85
+    debug w => _1;                       // in scope 0 at $DIR/named_lifetimes_basic.rs:+0:26: +0:27
+    debug x => _2;                       // in scope 0 at $DIR/named_lifetimes_basic.rs:+0:42: +0:43
+    debug y => _3;                       // in scope 0 at $DIR/named_lifetimes_basic.rs:+0:54: +0:55
+    debug z => _4;                       // in scope 0 at $DIR/named_lifetimes_basic.rs:+0:66: +0:67
+    let mut _0: bool;                    // return place in scope 0 at $DIR/named_lifetimes_basic.rs:+0:81: +0:85
 
     bb0: {
-        _0 = const ConstValue(Scalar(0x01): bool); // bb0[0]: scope 0 at $DIR/named-lifetimes-basic.rs:+0:88: +0:92
-        return;                          // bb0[1]: scope 0 at $DIR/named-lifetimes-basic.rs:+0:94: +0:94
+        _0 = const ConstValue(Scalar(0x01): bool); // bb0[0]: scope 0 at $DIR/named_lifetimes_basic.rs:+0:88: +0:92
+        return;                          // bb0[1]: scope 0 at $DIR/named_lifetimes_basic.rs:+0:94: +0:94
     }
 }
diff --git a/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir b/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir
index 36705d18e01..3e3fda6141a 100644
--- a/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir
+++ b/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir
@@ -17,95 +17,95 @@
 | '_#2r live at {bb1[0]}
 | '_#3r live at {bb1[1..=3]}
 | '_#4r live at {bb1[4..=7], bb2[0..=2]}
-| '_#2r: '_#3r due to Assignment at Single(bb1[0]) ($DIR/region-subtyping-basic.rs:18:13: 18:18 (#0)
-| '_#3r: '_#4r due to Assignment at Single(bb1[3]) ($DIR/region-subtyping-basic.rs:19:13: 19:14 (#0)
+| '_#2r: '_#3r due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:18:13: 18:18 (#0)
+| '_#3r: '_#4r due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:19:13: 19:14 (#0)
 |
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/region-subtyping-basic.rs:+0:11: +0:11
-    let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x00000003)) }]; // in scope 0 at $DIR/region-subtyping-basic.rs:+1:9: +1:14
-    let _3: usize;                       // in scope 0 at $DIR/region-subtyping-basic.rs:+2:16: +2:17
-    let mut _4: usize;                   // in scope 0 at $DIR/region-subtyping-basic.rs:+2:14: +2:18
-    let mut _5: bool;                    // in scope 0 at $DIR/region-subtyping-basic.rs:+2:14: +2:18
-    let mut _7: bool;                    // in scope 0 at $DIR/region-subtyping-basic.rs:+4:8: +4:12
-    let _8: bool;                        // in scope 0 at $DIR/region-subtyping-basic.rs:+5:9: +5:18
-    let mut _9: usize;                   // in scope 0 at $DIR/region-subtyping-basic.rs:+5:15: +5:17
-    let _10: bool;                       // in scope 0 at $DIR/region-subtyping-basic.rs:+7:9: +7:18
+    let mut _0: ();                      // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11
+    let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x00000003)) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
+    let _3: usize;                       // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17
+    let mut _4: usize;                   // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
+    let mut _5: bool;                    // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
+    let mut _7: bool;                    // in scope 0 at $DIR/region_subtyping_basic.rs:+4:8: +4:12
+    let _8: bool;                        // in scope 0 at $DIR/region_subtyping_basic.rs:+5:9: +5:18
+    let mut _9: usize;                   // in scope 0 at $DIR/region_subtyping_basic.rs:+5:15: +5:17
+    let _10: bool;                       // in scope 0 at $DIR/region_subtyping_basic.rs:+7:9: +7:18
     scope 1 {
-        debug v => _1;                   // in scope 1 at $DIR/region-subtyping-basic.rs:+1:9: +1:14
-        let _2: &'_#3r usize;            // in scope 1 at $DIR/region-subtyping-basic.rs:+2:9: +2:10
+        debug v => _1;                   // in scope 1 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
+        let _2: &'_#3r usize;            // in scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10
         scope 2 {
-            debug p => _2;               // in scope 2 at $DIR/region-subtyping-basic.rs:+2:9: +2:10
-            let _6: &'_#4r usize;        // in scope 2 at $DIR/region-subtyping-basic.rs:+3:9: +3:10
+            debug p => _2;               // in scope 2 at $DIR/region_subtyping_basic.rs:+2:9: +2:10
+            let _6: &'_#4r usize;        // in scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10
             scope 3 {
-                debug q => _6;           // in scope 3 at $DIR/region-subtyping-basic.rs:+3:9: +3:10
+                debug q => _6;           // in scope 3 at $DIR/region_subtyping_basic.rs:+3:9: +3:10
             }
         }
     }
 
     bb0: {
-        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/region-subtyping-basic.rs:+1:9: +1:14
-        _1 = [const ConstValue(Scalar(0x00000001): usize), const ConstValue(Scalar(0x00000002): usize), const ConstValue(Scalar(0x00000003): usize)]; // bb0[1]: scope 0 at $DIR/region-subtyping-basic.rs:+1:17: +1:26
-        FakeRead(ForLet(None), _1);      // bb0[2]: scope 0 at $DIR/region-subtyping-basic.rs:+1:9: +1:14
-        StorageLive(_2);                 // bb0[3]: scope 1 at $DIR/region-subtyping-basic.rs:+2:9: +2:10
-        StorageLive(_3);                 // bb0[4]: scope 1 at $DIR/region-subtyping-basic.rs:+2:16: +2:17
-        _3 = const ConstValue(Scalar(0x00000000): usize); // bb0[5]: scope 1 at $DIR/region-subtyping-basic.rs:+2:16: +2:17
-        _4 = Len(_1);                    // bb0[6]: scope 1 at $DIR/region-subtyping-basic.rs:+2:14: +2:18
-        _5 = Lt(_3, _4);                 // bb0[7]: scope 1 at $DIR/region-subtyping-basic.rs:+2:14: +2:18
-        assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb7]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:+2:14: +2:18
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
+        _1 = [const ConstValue(Scalar(0x00000001): usize), const ConstValue(Scalar(0x00000002): usize), const ConstValue(Scalar(0x00000003): usize)]; // bb0[1]: scope 0 at $DIR/region_subtyping_basic.rs:+1:17: +1:26
+        FakeRead(ForLet(None), _1);      // bb0[2]: scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
+        StorageLive(_2);                 // bb0[3]: scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10
+        StorageLive(_3);                 // bb0[4]: scope 1 at $DIR/region_subtyping_basic.rs:+2:16: +2:17
+        _3 = const ConstValue(Scalar(0x00000000): usize); // bb0[5]: scope 1 at $DIR/region_subtyping_basic.rs:+2:16: +2:17
+        _4 = Len(_1);                    // bb0[6]: scope 1 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
+        _5 = Lt(_3, _4);                 // bb0[7]: scope 1 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
+        assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb7]; // bb0[8]: scope 1 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
     }
 
     bb1: {
-        _2 = &'_#2r _1[_3];              // bb1[0]: scope 1 at $DIR/region-subtyping-basic.rs:+2:13: +2:18
-        FakeRead(ForLet(None), _2);      // bb1[1]: scope 1 at $DIR/region-subtyping-basic.rs:+2:9: +2:10
-        StorageLive(_6);                 // bb1[2]: scope 2 at $DIR/region-subtyping-basic.rs:+3:9: +3:10
-        _6 = _2;                         // bb1[3]: scope 2 at $DIR/region-subtyping-basic.rs:+3:13: +3:14
-        FakeRead(ForLet(None), _6);      // bb1[4]: scope 2 at $DIR/region-subtyping-basic.rs:+3:9: +3:10
-        StorageLive(_7);                 // bb1[5]: scope 3 at $DIR/region-subtyping-basic.rs:+4:8: +4:12
-        _7 = const ConstValue(Scalar(0x01): bool); // bb1[6]: scope 3 at $DIR/region-subtyping-basic.rs:+4:8: +4:12
-        switchInt(move _7) -> [ConstValue(Scalar(0x00): bool): bb4, otherwise: bb2]; // bb1[7]: scope 3 at $DIR/region-subtyping-basic.rs:+4:8: +4:12
+        _2 = &'_#2r _1[_3];              // bb1[0]: scope 1 at $DIR/region_subtyping_basic.rs:+2:13: +2:18
+        FakeRead(ForLet(None), _2);      // bb1[1]: scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10
+        StorageLive(_6);                 // bb1[2]: scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10
+        _6 = _2;                         // bb1[3]: scope 2 at $DIR/region_subtyping_basic.rs:+3:13: +3:14
+        FakeRead(ForLet(None), _6);      // bb1[4]: scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10
+        StorageLive(_7);                 // bb1[5]: scope 3 at $DIR/region_subtyping_basic.rs:+4:8: +4:12
+        _7 = const ConstValue(Scalar(0x01): bool); // bb1[6]: scope 3 at $DIR/region_subtyping_basic.rs:+4:8: +4:12
+        switchInt(move _7) -> [ConstValue(Scalar(0x00): bool): bb4, otherwise: bb2]; // bb1[7]: scope 3 at $DIR/region_subtyping_basic.rs:+4:8: +4:12
     }
 
     bb2: {
-        StorageLive(_8);                 // bb2[0]: scope 3 at $DIR/region-subtyping-basic.rs:+5:9: +5:18
-        StorageLive(_9);                 // bb2[1]: scope 3 at $DIR/region-subtyping-basic.rs:+5:15: +5:17
-        _9 = (*_6);                      // bb2[2]: scope 3 at $DIR/region-subtyping-basic.rs:+5:15: +5:17
-        _8 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _9) -> [return: bb3, unwind: bb7]; // bb2[3]: scope 3 at $DIR/region-subtyping-basic.rs:+5:9: +5:18
+        StorageLive(_8);                 // bb2[0]: scope 3 at $DIR/region_subtyping_basic.rs:+5:9: +5:18
+        StorageLive(_9);                 // bb2[1]: scope 3 at $DIR/region_subtyping_basic.rs:+5:15: +5:17
+        _9 = (*_6);                      // bb2[2]: scope 3 at $DIR/region_subtyping_basic.rs:+5:15: +5:17
+        _8 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _9) -> [return: bb3, unwind: bb7]; // bb2[3]: scope 3 at $DIR/region_subtyping_basic.rs:+5:9: +5:18
                                          // mir::Constant
-                                         // + span: $DIR/region-subtyping-basic.rs:21:9: 21:14
+                                         // + span: $DIR/region_subtyping_basic.rs:21:9: 21:14
                                          // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value() }
     }
 
     bb3: {
-        StorageDead(_9);                 // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:+5:17: +5:18
-        StorageDead(_8);                 // bb3[1]: scope 3 at $DIR/region-subtyping-basic.rs:+5:18: +5:19
-        _0 = const ConstValue(ZeroSized: ()); // bb3[2]: scope 3 at $DIR/region-subtyping-basic.rs:+4:13: +6:6
-        goto -> bb6;                     // bb3[3]: scope 3 at $DIR/region-subtyping-basic.rs:+4:5: +8:6
+        StorageDead(_9);                 // bb3[0]: scope 3 at $DIR/region_subtyping_basic.rs:+5:17: +5:18
+        StorageDead(_8);                 // bb3[1]: scope 3 at $DIR/region_subtyping_basic.rs:+5:18: +5:19
+        _0 = const ConstValue(ZeroSized: ()); // bb3[2]: scope 3 at $DIR/region_subtyping_basic.rs:+4:13: +6:6
+        goto -> bb6;                     // bb3[3]: scope 3 at $DIR/region_subtyping_basic.rs:+4:5: +8:6
     }
 
     bb4: {
-        StorageLive(_10);                // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:+7:9: +7:18
-        _10 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x00000016): usize)) -> [return: bb5, unwind: bb7]; // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:+7:9: +7:18
+        StorageLive(_10);                // bb4[0]: scope 3 at $DIR/region_subtyping_basic.rs:+7:9: +7:18
+        _10 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x00000016): usize)) -> [return: bb5, unwind: bb7]; // bb4[1]: scope 3 at $DIR/region_subtyping_basic.rs:+7:9: +7:18
                                          // mir::Constant
-                                         // + span: $DIR/region-subtyping-basic.rs:23:9: 23:14
+                                         // + span: $DIR/region_subtyping_basic.rs:23:9: 23:14
                                          // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value() }
     }
 
     bb5: {
-        StorageDead(_10);                // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:+7:18: +7:19
-        _0 = const ConstValue(ZeroSized: ()); // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:+6:12: +8:6
-        goto -> bb6;                     // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:+4:5: +8:6
+        StorageDead(_10);                // bb5[0]: scope 3 at $DIR/region_subtyping_basic.rs:+7:18: +7:19
+        _0 = const ConstValue(ZeroSized: ()); // bb5[1]: scope 3 at $DIR/region_subtyping_basic.rs:+6:12: +8:6
+        goto -> bb6;                     // bb5[2]: scope 3 at $DIR/region_subtyping_basic.rs:+4:5: +8:6
     }
 
     bb6: {
-        StorageDead(_7);                 // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:+8:5: +8:6
-        StorageDead(_6);                 // bb6[1]: scope 2 at $DIR/region-subtyping-basic.rs:+9:1: +9:2
-        StorageDead(_3);                 // bb6[2]: scope 1 at $DIR/region-subtyping-basic.rs:+9:1: +9:2
-        StorageDead(_2);                 // bb6[3]: scope 1 at $DIR/region-subtyping-basic.rs:+9:1: +9:2
-        StorageDead(_1);                 // bb6[4]: scope 0 at $DIR/region-subtyping-basic.rs:+9:1: +9:2
-        return;                          // bb6[5]: scope 0 at $DIR/region-subtyping-basic.rs:+9:2: +9:2
+        StorageDead(_7);                 // bb6[0]: scope 3 at $DIR/region_subtyping_basic.rs:+8:5: +8:6
+        StorageDead(_6);                 // bb6[1]: scope 2 at $DIR/region_subtyping_basic.rs:+9:1: +9:2
+        StorageDead(_3);                 // bb6[2]: scope 1 at $DIR/region_subtyping_basic.rs:+9:1: +9:2
+        StorageDead(_2);                 // bb6[3]: scope 1 at $DIR/region_subtyping_basic.rs:+9:1: +9:2
+        StorageDead(_1);                 // bb6[4]: scope 0 at $DIR/region_subtyping_basic.rs:+9:1: +9:2
+        return;                          // bb6[5]: scope 0 at $DIR/region_subtyping_basic.rs:+9:2: +9:2
     }
 
     bb7 (cleanup): {
-        resume;                          // bb7[0]: scope 0 at $DIR/region-subtyping-basic.rs:+0:1: +9:2
+        resume;                          // bb7[0]: scope 0 at $DIR/region_subtyping_basic.rs:+0:1: +9:2
     }
 }
diff --git a/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir b/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir
index 4f6256a67f4..39a53702a4c 100644
--- a/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir
+++ b/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir
@@ -17,95 +17,95 @@
 | '_#2r live at {bb1[0]}
 | '_#3r live at {bb1[1..=3]}
 | '_#4r live at {bb1[4..=7], bb2[0..=2]}
-| '_#2r: '_#3r due to Assignment at Single(bb1[0]) ($DIR/region-subtyping-basic.rs:18:13: 18:18 (#0)
-| '_#3r: '_#4r due to Assignment at Single(bb1[3]) ($DIR/region-subtyping-basic.rs:19:13: 19:14 (#0)
+| '_#2r: '_#3r due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:18:13: 18:18 (#0)
+| '_#3r: '_#4r due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:19:13: 19:14 (#0)
 |
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/region-subtyping-basic.rs:+0:11: +0:11
-    let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x0000000000000003)) }]; // in scope 0 at $DIR/region-subtyping-basic.rs:+1:9: +1:14
-    let _3: usize;                       // in scope 0 at $DIR/region-subtyping-basic.rs:+2:16: +2:17
-    let mut _4: usize;                   // in scope 0 at $DIR/region-subtyping-basic.rs:+2:14: +2:18
-    let mut _5: bool;                    // in scope 0 at $DIR/region-subtyping-basic.rs:+2:14: +2:18
-    let mut _7: bool;                    // in scope 0 at $DIR/region-subtyping-basic.rs:+4:8: +4:12
-    let _8: bool;                        // in scope 0 at $DIR/region-subtyping-basic.rs:+5:9: +5:18
-    let mut _9: usize;                   // in scope 0 at $DIR/region-subtyping-basic.rs:+5:15: +5:17
-    let _10: bool;                       // in scope 0 at $DIR/region-subtyping-basic.rs:+7:9: +7:18
+    let mut _0: ();                      // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11
+    let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x0000000000000003)) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
+    let _3: usize;                       // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17
+    let mut _4: usize;                   // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
+    let mut _5: bool;                    // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
+    let mut _7: bool;                    // in scope 0 at $DIR/region_subtyping_basic.rs:+4:8: +4:12
+    let _8: bool;                        // in scope 0 at $DIR/region_subtyping_basic.rs:+5:9: +5:18
+    let mut _9: usize;                   // in scope 0 at $DIR/region_subtyping_basic.rs:+5:15: +5:17
+    let _10: bool;                       // in scope 0 at $DIR/region_subtyping_basic.rs:+7:9: +7:18
     scope 1 {
-        debug v => _1;                   // in scope 1 at $DIR/region-subtyping-basic.rs:+1:9: +1:14
-        let _2: &'_#3r usize;            // in scope 1 at $DIR/region-subtyping-basic.rs:+2:9: +2:10
+        debug v => _1;                   // in scope 1 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
+        let _2: &'_#3r usize;            // in scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10
         scope 2 {
-            debug p => _2;               // in scope 2 at $DIR/region-subtyping-basic.rs:+2:9: +2:10
-            let _6: &'_#4r usize;        // in scope 2 at $DIR/region-subtyping-basic.rs:+3:9: +3:10
+            debug p => _2;               // in scope 2 at $DIR/region_subtyping_basic.rs:+2:9: +2:10
+            let _6: &'_#4r usize;        // in scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10
             scope 3 {
-                debug q => _6;           // in scope 3 at $DIR/region-subtyping-basic.rs:+3:9: +3:10
+                debug q => _6;           // in scope 3 at $DIR/region_subtyping_basic.rs:+3:9: +3:10
             }
         }
     }
 
     bb0: {
-        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/region-subtyping-basic.rs:+1:9: +1:14
-        _1 = [const ConstValue(Scalar(0x0000000000000001): usize), const ConstValue(Scalar(0x0000000000000002): usize), const ConstValue(Scalar(0x0000000000000003): usize)]; // bb0[1]: scope 0 at $DIR/region-subtyping-basic.rs:+1:17: +1:26
-        FakeRead(ForLet(None), _1);      // bb0[2]: scope 0 at $DIR/region-subtyping-basic.rs:+1:9: +1:14
-        StorageLive(_2);                 // bb0[3]: scope 1 at $DIR/region-subtyping-basic.rs:+2:9: +2:10
-        StorageLive(_3);                 // bb0[4]: scope 1 at $DIR/region-subtyping-basic.rs:+2:16: +2:17
-        _3 = const ConstValue(Scalar(0x0000000000000000): usize); // bb0[5]: scope 1 at $DIR/region-subtyping-basic.rs:+2:16: +2:17
-        _4 = Len(_1);                    // bb0[6]: scope 1 at $DIR/region-subtyping-basic.rs:+2:14: +2:18
-        _5 = Lt(_3, _4);                 // bb0[7]: scope 1 at $DIR/region-subtyping-basic.rs:+2:14: +2:18
-        assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb7]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:+2:14: +2:18
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
+        _1 = [const ConstValue(Scalar(0x0000000000000001): usize), const ConstValue(Scalar(0x0000000000000002): usize), const ConstValue(Scalar(0x0000000000000003): usize)]; // bb0[1]: scope 0 at $DIR/region_subtyping_basic.rs:+1:17: +1:26
+        FakeRead(ForLet(None), _1);      // bb0[2]: scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
+        StorageLive(_2);                 // bb0[3]: scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10
+        StorageLive(_3);                 // bb0[4]: scope 1 at $DIR/region_subtyping_basic.rs:+2:16: +2:17
+        _3 = const ConstValue(Scalar(0x0000000000000000): usize); // bb0[5]: scope 1 at $DIR/region_subtyping_basic.rs:+2:16: +2:17
+        _4 = Len(_1);                    // bb0[6]: scope 1 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
+        _5 = Lt(_3, _4);                 // bb0[7]: scope 1 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
+        assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb7]; // bb0[8]: scope 1 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
     }
 
     bb1: {
-        _2 = &'_#2r _1[_3];              // bb1[0]: scope 1 at $DIR/region-subtyping-basic.rs:+2:13: +2:18
-        FakeRead(ForLet(None), _2);      // bb1[1]: scope 1 at $DIR/region-subtyping-basic.rs:+2:9: +2:10
-        StorageLive(_6);                 // bb1[2]: scope 2 at $DIR/region-subtyping-basic.rs:+3:9: +3:10
-        _6 = _2;                         // bb1[3]: scope 2 at $DIR/region-subtyping-basic.rs:+3:13: +3:14
-        FakeRead(ForLet(None), _6);      // bb1[4]: scope 2 at $DIR/region-subtyping-basic.rs:+3:9: +3:10
-        StorageLive(_7);                 // bb1[5]: scope 3 at $DIR/region-subtyping-basic.rs:+4:8: +4:12
-        _7 = const ConstValue(Scalar(0x01): bool); // bb1[6]: scope 3 at $DIR/region-subtyping-basic.rs:+4:8: +4:12
-        switchInt(move _7) -> [ConstValue(Scalar(0x00): bool): bb4, otherwise: bb2]; // bb1[7]: scope 3 at $DIR/region-subtyping-basic.rs:+4:8: +4:12
+        _2 = &'_#2r _1[_3];              // bb1[0]: scope 1 at $DIR/region_subtyping_basic.rs:+2:13: +2:18
+        FakeRead(ForLet(None), _2);      // bb1[1]: scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10
+        StorageLive(_6);                 // bb1[2]: scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10
+        _6 = _2;                         // bb1[3]: scope 2 at $DIR/region_subtyping_basic.rs:+3:13: +3:14
+        FakeRead(ForLet(None), _6);      // bb1[4]: scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10
+        StorageLive(_7);                 // bb1[5]: scope 3 at $DIR/region_subtyping_basic.rs:+4:8: +4:12
+        _7 = const ConstValue(Scalar(0x01): bool); // bb1[6]: scope 3 at $DIR/region_subtyping_basic.rs:+4:8: +4:12
+        switchInt(move _7) -> [ConstValue(Scalar(0x00): bool): bb4, otherwise: bb2]; // bb1[7]: scope 3 at $DIR/region_subtyping_basic.rs:+4:8: +4:12
     }
 
     bb2: {
-        StorageLive(_8);                 // bb2[0]: scope 3 at $DIR/region-subtyping-basic.rs:+5:9: +5:18
-        StorageLive(_9);                 // bb2[1]: scope 3 at $DIR/region-subtyping-basic.rs:+5:15: +5:17
-        _9 = (*_6);                      // bb2[2]: scope 3 at $DIR/region-subtyping-basic.rs:+5:15: +5:17
-        _8 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _9) -> [return: bb3, unwind: bb7]; // bb2[3]: scope 3 at $DIR/region-subtyping-basic.rs:+5:9: +5:18
+        StorageLive(_8);                 // bb2[0]: scope 3 at $DIR/region_subtyping_basic.rs:+5:9: +5:18
+        StorageLive(_9);                 // bb2[1]: scope 3 at $DIR/region_subtyping_basic.rs:+5:15: +5:17
+        _9 = (*_6);                      // bb2[2]: scope 3 at $DIR/region_subtyping_basic.rs:+5:15: +5:17
+        _8 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _9) -> [return: bb3, unwind: bb7]; // bb2[3]: scope 3 at $DIR/region_subtyping_basic.rs:+5:9: +5:18
                                          // mir::Constant
-                                         // + span: $DIR/region-subtyping-basic.rs:21:9: 21:14
+                                         // + span: $DIR/region_subtyping_basic.rs:21:9: 21:14
                                          // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value() }
     }
 
     bb3: {
-        StorageDead(_9);                 // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:+5:17: +5:18
-        StorageDead(_8);                 // bb3[1]: scope 3 at $DIR/region-subtyping-basic.rs:+5:18: +5:19
-        _0 = const ConstValue(ZeroSized: ()); // bb3[2]: scope 3 at $DIR/region-subtyping-basic.rs:+4:13: +6:6
-        goto -> bb6;                     // bb3[3]: scope 3 at $DIR/region-subtyping-basic.rs:+4:5: +8:6
+        StorageDead(_9);                 // bb3[0]: scope 3 at $DIR/region_subtyping_basic.rs:+5:17: +5:18
+        StorageDead(_8);                 // bb3[1]: scope 3 at $DIR/region_subtyping_basic.rs:+5:18: +5:19
+        _0 = const ConstValue(ZeroSized: ()); // bb3[2]: scope 3 at $DIR/region_subtyping_basic.rs:+4:13: +6:6
+        goto -> bb6;                     // bb3[3]: scope 3 at $DIR/region_subtyping_basic.rs:+4:5: +8:6
     }
 
     bb4: {
-        StorageLive(_10);                // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:+7:9: +7:18
-        _10 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x0000000000000016): usize)) -> [return: bb5, unwind: bb7]; // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:+7:9: +7:18
+        StorageLive(_10);                // bb4[0]: scope 3 at $DIR/region_subtyping_basic.rs:+7:9: +7:18
+        _10 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x0000000000000016): usize)) -> [return: bb5, unwind: bb7]; // bb4[1]: scope 3 at $DIR/region_subtyping_basic.rs:+7:9: +7:18
                                          // mir::Constant
-                                         // + span: $DIR/region-subtyping-basic.rs:23:9: 23:14
+                                         // + span: $DIR/region_subtyping_basic.rs:23:9: 23:14
                                          // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value() }
     }
 
     bb5: {
-        StorageDead(_10);                // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:+7:18: +7:19
-        _0 = const ConstValue(ZeroSized: ()); // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:+6:12: +8:6
-        goto -> bb6;                     // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:+4:5: +8:6
+        StorageDead(_10);                // bb5[0]: scope 3 at $DIR/region_subtyping_basic.rs:+7:18: +7:19
+        _0 = const ConstValue(ZeroSized: ()); // bb5[1]: scope 3 at $DIR/region_subtyping_basic.rs:+6:12: +8:6
+        goto -> bb6;                     // bb5[2]: scope 3 at $DIR/region_subtyping_basic.rs:+4:5: +8:6
     }
 
     bb6: {
-        StorageDead(_7);                 // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:+8:5: +8:6
-        StorageDead(_6);                 // bb6[1]: scope 2 at $DIR/region-subtyping-basic.rs:+9:1: +9:2
-        StorageDead(_3);                 // bb6[2]: scope 1 at $DIR/region-subtyping-basic.rs:+9:1: +9:2
-        StorageDead(_2);                 // bb6[3]: scope 1 at $DIR/region-subtyping-basic.rs:+9:1: +9:2
-        StorageDead(_1);                 // bb6[4]: scope 0 at $DIR/region-subtyping-basic.rs:+9:1: +9:2
-        return;                          // bb6[5]: scope 0 at $DIR/region-subtyping-basic.rs:+9:2: +9:2
+        StorageDead(_7);                 // bb6[0]: scope 3 at $DIR/region_subtyping_basic.rs:+8:5: +8:6
+        StorageDead(_6);                 // bb6[1]: scope 2 at $DIR/region_subtyping_basic.rs:+9:1: +9:2
+        StorageDead(_3);                 // bb6[2]: scope 1 at $DIR/region_subtyping_basic.rs:+9:1: +9:2
+        StorageDead(_2);                 // bb6[3]: scope 1 at $DIR/region_subtyping_basic.rs:+9:1: +9:2
+        StorageDead(_1);                 // bb6[4]: scope 0 at $DIR/region_subtyping_basic.rs:+9:1: +9:2
+        return;                          // bb6[5]: scope 0 at $DIR/region_subtyping_basic.rs:+9:2: +9:2
     }
 
     bb7 (cleanup): {
-        resume;                          // bb7[0]: scope 0 at $DIR/region-subtyping-basic.rs:+0:1: +9:2
+        resume;                          // bb7[0]: scope 0 at $DIR/region_subtyping_basic.rs:+0:1: +9:2
     }
 }
diff --git a/src/test/mir-opt/nll/region-subtyping-basic.rs b/src/test/mir-opt/nll/region_subtyping_basic.rs
similarity index 100%
rename from src/test/mir-opt/nll/region-subtyping-basic.rs
rename to src/test/mir-opt/nll/region_subtyping_basic.rs
diff --git a/src/test/mir-opt/no-drop-for-inactive-variant.rs b/src/test/mir-opt/no_drop_for_inactive_variant.rs
similarity index 100%
rename from src/test/mir-opt/no-drop-for-inactive-variant.rs
rename to src/test/mir-opt/no_drop_for_inactive_variant.rs
diff --git a/src/test/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir
index 50fd98ff13a..e708255cea4 100644
--- a/src/test/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir
+++ b/src/test/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir
@@ -1,21 +1,21 @@
 // MIR for `unwrap` after SimplifyCfg-elaborate-drops
 
 fn unwrap(_1: Option) -> T {
-    debug opt => _1;                     // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+0:14: +0:17
-    let mut _0: T;                       // return place in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+0:33: +0:34
-    let mut _2: isize;                   // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+2:9: +2:16
-    let _3: T;                           // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+2:14: +2:15
+    debug opt => _1;                     // in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+0:14: +0:17
+    let mut _0: T;                       // return place in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+0:33: +0:34
+    let mut _2: isize;                   // in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+2:9: +2:16
+    let _3: T;                           // in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+2:14: +2:15
     let mut _4: !;                       // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL
-    let mut _5: isize;                   // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+5:1: +5:2
-    let mut _6: isize;                   // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+5:1: +5:2
-    let mut _7: isize;                   // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+5:1: +5:2
+    let mut _5: isize;                   // in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+5:1: +5:2
+    let mut _6: isize;                   // in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+5:1: +5:2
+    let mut _7: isize;                   // in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+5:1: +5:2
     scope 1 {
-        debug x => _3;                   // in scope 1 at $DIR/no-drop-for-inactive-variant.rs:+2:14: +2:15
+        debug x => _3;                   // in scope 1 at $DIR/no_drop_for_inactive_variant.rs:+2:14: +2:15
     }
 
     bb0: {
-        _2 = discriminant(_1);           // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+1:11: +1:14
-        switchInt(move _2) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+1:5: +1:14
+        _2 = discriminant(_1);           // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+1:11: +1:14
+        switchInt(move _2) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+1:5: +1:14
     }
 
     bb1: {
@@ -30,20 +30,20 @@ fn unwrap(_1: Option) -> T {
     }
 
     bb2: {
-        unreachable;                     // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+1:11: +1:14
+        unreachable;                     // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+1:11: +1:14
     }
 
     bb3: {
-        StorageLive(_3);                 // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+2:14: +2:15
-        _3 = move ((_1 as Some).0: T);   // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+2:14: +2:15
-        _0 = move _3;                    // scope 1 at $DIR/no-drop-for-inactive-variant.rs:+2:20: +2:21
-        StorageDead(_3);                 // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+2:20: +2:21
-        _5 = discriminant(_1);           // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+5:1: +5:2
-        return;                          // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+5:2: +5:2
+        StorageLive(_3);                 // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+2:14: +2:15
+        _3 = move ((_1 as Some).0: T);   // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+2:14: +2:15
+        _0 = move _3;                    // scope 1 at $DIR/no_drop_for_inactive_variant.rs:+2:20: +2:21
+        StorageDead(_3);                 // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+2:20: +2:21
+        _5 = discriminant(_1);           // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+5:1: +5:2
+        return;                          // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+5:2: +5:2
     }
 
     bb4 (cleanup): {
-        _7 = discriminant(_1);           // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+5:1: +5:2
-        resume;                          // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+0:1: +5:2
+        _7 = discriminant(_1);           // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+5:1: +5:2
+        resume;                          // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+0:1: +5:2
     }
 }
diff --git a/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir b/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir
index 963e7cde656..0cb34a2f274 100644
--- a/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir
+++ b/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir
@@ -1,49 +1,49 @@
 // MIR for `main` before ElaborateDrops
 
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/no-spurious-drop-after-call.rs:+0:11: +0:11
-    let _1: ();                          // in scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:5: +1:35
-    let mut _2: std::string::String;     // in scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34
-    let mut _3: &str;                    // in scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34
-    let _4: &str;                        // in scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:22
+    let mut _0: ();                      // return place in scope 0 at $DIR/no_spurious_drop_after_call.rs:+0:11: +0:11
+    let _1: ();                          // in scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:5: +1:35
+    let mut _2: std::string::String;     // in scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:34
+    let mut _3: &str;                    // in scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:34
+    let _4: &str;                        // in scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:22
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:5: +1:35
-        StorageLive(_2);                 // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34
-        StorageLive(_3);                 // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34
-        StorageLive(_4);                 // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:22
-        _4 = const "";                   // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:22
+        StorageLive(_1);                 // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:5: +1:35
+        StorageLive(_2);                 // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:34
+        StorageLive(_3);                 // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:34
+        StorageLive(_4);                 // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:22
+        _4 = const "";                   // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:22
                                          // mir::Constant
-                                         // + span: $DIR/no-spurious-drop-after-call.rs:9:20: 9:22
+                                         // + span: $DIR/no_spurious_drop_after_call.rs:9:20: 9:22
                                          // + literal: Const { ty: &str, val: Value(Slice(..)) }
-        _3 = &(*_4);                     // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34
-        _2 = ::to_string(move _3) -> bb1; // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34
+        _3 = &(*_4);                     // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:34
+        _2 = ::to_string(move _3) -> bb1; // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:34
                                          // mir::Constant
-                                         // + span: $DIR/no-spurious-drop-after-call.rs:9:23: 9:32
+                                         // + span: $DIR/no_spurious_drop_after_call.rs:9:23: 9:32
                                          // + literal: Const { ty: for<'a> fn(&'a str) -> String {::to_string}, val: Value() }
     }
 
     bb1: {
-        StorageDead(_3);                 // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:33: +1:34
-        _1 = std::mem::drop::(move _2) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:5: +1:35
+        StorageDead(_3);                 // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:33: +1:34
+        _1 = std::mem::drop::(move _2) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:5: +1:35
                                          // mir::Constant
-                                         // + span: $DIR/no-spurious-drop-after-call.rs:9:5: 9:19
+                                         // + span: $DIR/no_spurious_drop_after_call.rs:9:5: 9:19
                                          // + literal: Const { ty: fn(String) {std::mem::drop::}, val: Value() }
     }
 
     bb2: {
-        StorageDead(_2);                 // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:34: +1:35
-        StorageDead(_4);                 // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:35: +1:36
-        StorageDead(_1);                 // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:35: +1:36
-        _0 = const ();                   // scope 0 at $DIR/no-spurious-drop-after-call.rs:+0:11: +2:2
-        return;                          // scope 0 at $DIR/no-spurious-drop-after-call.rs:+2:2: +2:2
+        StorageDead(_2);                 // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:34: +1:35
+        StorageDead(_4);                 // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:35: +1:36
+        StorageDead(_1);                 // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:35: +1:36
+        _0 = const ();                   // scope 0 at $DIR/no_spurious_drop_after_call.rs:+0:11: +2:2
+        return;                          // scope 0 at $DIR/no_spurious_drop_after_call.rs:+2:2: +2:2
     }
 
     bb3 (cleanup): {
-        drop(_2) -> bb4;                 // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:34: +1:35
+        drop(_2) -> bb4;                 // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:34: +1:35
     }
 
     bb4 (cleanup): {
-        resume;                          // scope 0 at $DIR/no-spurious-drop-after-call.rs:+0:1: +2:2
+        resume;                          // scope 0 at $DIR/no_spurious_drop_after_call.rs:+0:1: +2:2
     }
 }
diff --git a/src/test/mir-opt/no-spurious-drop-after-call.rs b/src/test/mir-opt/no_spurious_drop_after_call.rs
similarity index 100%
rename from src/test/mir-opt/no-spurious-drop-after-call.rs
rename to src/test/mir-opt/no_spurious_drop_after_call.rs
diff --git a/src/test/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.diff b/src/test/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.diff
index ce35f920bf6..61a16065bfb 100644
--- a/src/test/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.diff
+++ b/src/test/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.diff
@@ -2,42 +2,42 @@
 + // MIR for `nrvo` after RenameReturnPlace
   
   fn nrvo(_1: for<'a> fn(&'a mut [u8; 1024])) -> [u8; 1024] {
-      debug init => _1;                    // in scope 0 at $DIR/nrvo-simple.rs:+0:9: +0:13
--     let mut _0: [u8; 1024];              // return place in scope 0 at $DIR/nrvo-simple.rs:+0:39: +0:49
-+     let mut _0: [u8; 1024];              // return place in scope 0 at $DIR/nrvo-simple.rs:+1:9: +1:16
-      let mut _2: [u8; 1024];              // in scope 0 at $DIR/nrvo-simple.rs:+1:9: +1:16
-      let _3: ();                          // in scope 0 at $DIR/nrvo-simple.rs:+2:5: +2:19
-      let mut _4: for<'a> fn(&'a mut [u8; 1024]); // in scope 0 at $DIR/nrvo-simple.rs:+2:5: +2:9
-      let mut _5: &mut [u8; 1024];         // in scope 0 at $DIR/nrvo-simple.rs:+2:10: +2:18
-      let mut _6: &mut [u8; 1024];         // in scope 0 at $DIR/nrvo-simple.rs:+2:10: +2:18
+      debug init => _1;                    // in scope 0 at $DIR/nrvo_simple.rs:+0:9: +0:13
+-     let mut _0: [u8; 1024];              // return place in scope 0 at $DIR/nrvo_simple.rs:+0:39: +0:49
++     let mut _0: [u8; 1024];              // return place in scope 0 at $DIR/nrvo_simple.rs:+1:9: +1:16
+      let mut _2: [u8; 1024];              // in scope 0 at $DIR/nrvo_simple.rs:+1:9: +1:16
+      let _3: ();                          // in scope 0 at $DIR/nrvo_simple.rs:+2:5: +2:19
+      let mut _4: for<'a> fn(&'a mut [u8; 1024]); // in scope 0 at $DIR/nrvo_simple.rs:+2:5: +2:9
+      let mut _5: &mut [u8; 1024];         // in scope 0 at $DIR/nrvo_simple.rs:+2:10: +2:18
+      let mut _6: &mut [u8; 1024];         // in scope 0 at $DIR/nrvo_simple.rs:+2:10: +2:18
       scope 1 {
--         debug buf => _2;                 // in scope 1 at $DIR/nrvo-simple.rs:+1:9: +1:16
-+         debug buf => _0;                 // in scope 1 at $DIR/nrvo-simple.rs:+1:9: +1:16
+-         debug buf => _2;                 // in scope 1 at $DIR/nrvo_simple.rs:+1:9: +1:16
++         debug buf => _0;                 // in scope 1 at $DIR/nrvo_simple.rs:+1:9: +1:16
       }
   
       bb0: {
--         StorageLive(_2);                 // scope 0 at $DIR/nrvo-simple.rs:+1:9: +1:16
--         _2 = [const 0_u8; 1024];         // scope 0 at $DIR/nrvo-simple.rs:+1:19: +1:28
-+         _0 = [const 0_u8; 1024];         // scope 0 at $DIR/nrvo-simple.rs:+1:19: +1:28
-          StorageLive(_3);                 // scope 1 at $DIR/nrvo-simple.rs:+2:5: +2:19
-          StorageLive(_4);                 // scope 1 at $DIR/nrvo-simple.rs:+2:5: +2:9
-          _4 = _1;                         // scope 1 at $DIR/nrvo-simple.rs:+2:5: +2:9
-          StorageLive(_5);                 // scope 1 at $DIR/nrvo-simple.rs:+2:10: +2:18
-          StorageLive(_6);                 // scope 1 at $DIR/nrvo-simple.rs:+2:10: +2:18
--         _6 = &mut _2;                    // scope 1 at $DIR/nrvo-simple.rs:+2:10: +2:18
-+         _6 = &mut _0;                    // scope 1 at $DIR/nrvo-simple.rs:+2:10: +2:18
-          _5 = &mut (*_6);                 // scope 1 at $DIR/nrvo-simple.rs:+2:10: +2:18
-          _3 = move _4(move _5) -> bb1;    // scope 1 at $DIR/nrvo-simple.rs:+2:5: +2:19
+-         StorageLive(_2);                 // scope 0 at $DIR/nrvo_simple.rs:+1:9: +1:16
+-         _2 = [const 0_u8; 1024];         // scope 0 at $DIR/nrvo_simple.rs:+1:19: +1:28
++         _0 = [const 0_u8; 1024];         // scope 0 at $DIR/nrvo_simple.rs:+1:19: +1:28
+          StorageLive(_3);                 // scope 1 at $DIR/nrvo_simple.rs:+2:5: +2:19
+          StorageLive(_4);                 // scope 1 at $DIR/nrvo_simple.rs:+2:5: +2:9
+          _4 = _1;                         // scope 1 at $DIR/nrvo_simple.rs:+2:5: +2:9
+          StorageLive(_5);                 // scope 1 at $DIR/nrvo_simple.rs:+2:10: +2:18
+          StorageLive(_6);                 // scope 1 at $DIR/nrvo_simple.rs:+2:10: +2:18
+-         _6 = &mut _2;                    // scope 1 at $DIR/nrvo_simple.rs:+2:10: +2:18
++         _6 = &mut _0;                    // scope 1 at $DIR/nrvo_simple.rs:+2:10: +2:18
+          _5 = &mut (*_6);                 // scope 1 at $DIR/nrvo_simple.rs:+2:10: +2:18
+          _3 = move _4(move _5) -> bb1;    // scope 1 at $DIR/nrvo_simple.rs:+2:5: +2:19
       }
   
       bb1: {
-          StorageDead(_5);                 // scope 1 at $DIR/nrvo-simple.rs:+2:18: +2:19
-          StorageDead(_4);                 // scope 1 at $DIR/nrvo-simple.rs:+2:18: +2:19
-          StorageDead(_6);                 // scope 1 at $DIR/nrvo-simple.rs:+2:19: +2:20
-          StorageDead(_3);                 // scope 1 at $DIR/nrvo-simple.rs:+2:19: +2:20
--         _0 = _2;                         // scope 1 at $DIR/nrvo-simple.rs:+3:5: +3:8
--         StorageDead(_2);                 // scope 0 at $DIR/nrvo-simple.rs:+4:1: +4:2
-          return;                          // scope 0 at $DIR/nrvo-simple.rs:+4:2: +4:2
+          StorageDead(_5);                 // scope 1 at $DIR/nrvo_simple.rs:+2:18: +2:19
+          StorageDead(_4);                 // scope 1 at $DIR/nrvo_simple.rs:+2:18: +2:19
+          StorageDead(_6);                 // scope 1 at $DIR/nrvo_simple.rs:+2:19: +2:20
+          StorageDead(_3);                 // scope 1 at $DIR/nrvo_simple.rs:+2:19: +2:20
+-         _0 = _2;                         // scope 1 at $DIR/nrvo_simple.rs:+3:5: +3:8
+-         StorageDead(_2);                 // scope 0 at $DIR/nrvo_simple.rs:+4:1: +4:2
+          return;                          // scope 0 at $DIR/nrvo_simple.rs:+4:2: +4:2
       }
   }
   
diff --git a/src/test/mir-opt/nrvo-simple.rs b/src/test/mir-opt/nrvo_simple.rs
similarity index 100%
rename from src/test/mir-opt/nrvo-simple.rs
rename to src/test/mir-opt/nrvo_simple.rs
diff --git a/src/test/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir
index f9ed1036f00..e522534867d 100644
--- a/src/test/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir
+++ b/src/test/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir
@@ -1,60 +1,60 @@
 // MIR for `main` after SimplifyCfg-elaborate-drops
 
 fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/packed-struct-drop-aligned.rs:+0:11: +0:11
-    let mut _1: Packed;                  // in scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:9: +1:14
-    let mut _2: Aligned;                 // in scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:24: +1:42
-    let mut _3: Droppy;                  // in scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:32: +1:41
-    let mut _4: Aligned;                 // in scope 0 at $DIR/packed-struct-drop-aligned.rs:+2:11: +2:29
-    let mut _5: Droppy;                  // in scope 0 at $DIR/packed-struct-drop-aligned.rs:+2:19: +2:28
-    let mut _6: Aligned;                 // in scope 0 at $DIR/packed-struct-drop-aligned.rs:+2:5: +2:8
+    let mut _0: ();                      // return place in scope 0 at $DIR/packed_struct_drop_aligned.rs:+0:11: +0:11
+    let mut _1: Packed;                  // in scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:9: +1:14
+    let mut _2: Aligned;                 // in scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:24: +1:42
+    let mut _3: Droppy;                  // in scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:32: +1:41
+    let mut _4: Aligned;                 // in scope 0 at $DIR/packed_struct_drop_aligned.rs:+2:11: +2:29
+    let mut _5: Droppy;                  // in scope 0 at $DIR/packed_struct_drop_aligned.rs:+2:19: +2:28
+    let mut _6: Aligned;                 // in scope 0 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8
     scope 1 {
-        debug x => _1;                   // in scope 1 at $DIR/packed-struct-drop-aligned.rs:+1:9: +1:14
+        debug x => _1;                   // in scope 1 at $DIR/packed_struct_drop_aligned.rs:+1:9: +1:14
     }
 
     bb0: {
-        StorageLive(_1);                 // scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:9: +1:14
-        StorageLive(_2);                 // scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:24: +1:42
-        StorageLive(_3);                 // scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:32: +1:41
-        Deinit(_3);                      // scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:32: +1:41
-        (_3.0: usize) = const 0_usize;   // scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:32: +1:41
-        Deinit(_2);                      // scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:24: +1:42
-        (_2.0: Droppy) = move _3;        // scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:24: +1:42
-        StorageDead(_3);                 // scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:41: +1:42
-        Deinit(_1);                      // scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:17: +1:43
-        (_1.0: Aligned) = move _2;       // scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:17: +1:43
-        StorageDead(_2);                 // scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:42: +1:43
-        StorageLive(_4);                 // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:11: +2:29
-        StorageLive(_5);                 // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:19: +2:28
-        Deinit(_5);                      // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:19: +2:28
-        (_5.0: usize) = const 0_usize;   // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:19: +2:28
-        Deinit(_4);                      // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:11: +2:29
-        (_4.0: Droppy) = move _5;        // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:11: +2:29
-        StorageDead(_5);                 // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:28: +2:29
-        StorageLive(_6);                 // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:5: +2:8
-        _6 = move (_1.0: Aligned);       // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:5: +2:8
-        drop(_6) -> [return: bb4, unwind: bb3]; // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:5: +2:8
+        StorageLive(_1);                 // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:9: +1:14
+        StorageLive(_2);                 // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:24: +1:42
+        StorageLive(_3);                 // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:32: +1:41
+        Deinit(_3);                      // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:32: +1:41
+        (_3.0: usize) = const 0_usize;   // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:32: +1:41
+        Deinit(_2);                      // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:24: +1:42
+        (_2.0: Droppy) = move _3;        // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:24: +1:42
+        StorageDead(_3);                 // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:41: +1:42
+        Deinit(_1);                      // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:17: +1:43
+        (_1.0: Aligned) = move _2;       // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:17: +1:43
+        StorageDead(_2);                 // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:42: +1:43
+        StorageLive(_4);                 // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:11: +2:29
+        StorageLive(_5);                 // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:19: +2:28
+        Deinit(_5);                      // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:19: +2:28
+        (_5.0: usize) = const 0_usize;   // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:19: +2:28
+        Deinit(_4);                      // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:11: +2:29
+        (_4.0: Droppy) = move _5;        // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:11: +2:29
+        StorageDead(_5);                 // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:28: +2:29
+        StorageLive(_6);                 // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8
+        _6 = move (_1.0: Aligned);       // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8
+        drop(_6) -> [return: bb4, unwind: bb3]; // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8
     }
 
     bb1: {
-        StorageDead(_1);                 // scope 0 at $DIR/packed-struct-drop-aligned.rs:+3:1: +3:2
-        return;                          // scope 0 at $DIR/packed-struct-drop-aligned.rs:+3:2: +3:2
+        StorageDead(_1);                 // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:1: +3:2
+        return;                          // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:2: +3:2
     }
 
     bb2 (cleanup): {
-        resume;                          // scope 0 at $DIR/packed-struct-drop-aligned.rs:+0:1: +3:2
+        resume;                          // scope 0 at $DIR/packed_struct_drop_aligned.rs:+0:1: +3:2
     }
 
     bb3 (cleanup): {
-        (_1.0: Aligned) = move _4;       // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:5: +2:8
-        drop(_1) -> bb2;                 // scope 0 at $DIR/packed-struct-drop-aligned.rs:+3:1: +3:2
+        (_1.0: Aligned) = move _4;       // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8
+        drop(_1) -> bb2;                 // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:1: +3:2
     }
 
     bb4: {
-        StorageDead(_6);                 // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:5: +2:8
-        (_1.0: Aligned) = move _4;       // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:5: +2:8
-        StorageDead(_4);                 // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:28: +2:29
-        _0 = const ();                   // scope 0 at $DIR/packed-struct-drop-aligned.rs:+0:11: +3:2
-        drop(_1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/packed-struct-drop-aligned.rs:+3:1: +3:2
+        StorageDead(_6);                 // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8
+        (_1.0: Aligned) = move _4;       // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8
+        StorageDead(_4);                 // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:28: +2:29
+        _0 = const ();                   // scope 0 at $DIR/packed_struct_drop_aligned.rs:+0:11: +3:2
+        drop(_1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:1: +3:2
     }
 }
diff --git a/src/test/mir-opt/packed-struct-drop-aligned.rs b/src/test/mir-opt/packed_struct_drop_aligned.rs
similarity index 100%
rename from src/test/mir-opt/packed-struct-drop-aligned.rs
rename to src/test/mir-opt/packed_struct_drop_aligned.rs
diff --git a/src/test/mir-opt/remove_never_const.no_codegen.PreCodegen.after.mir b/src/test/mir-opt/remove_never_const.no_codegen.PreCodegen.after.mir
index 76bdd23be16..8eb0e9c8f48 100644
--- a/src/test/mir-opt/remove_never_const.no_codegen.PreCodegen.after.mir
+++ b/src/test/mir-opt/remove_never_const.no_codegen.PreCodegen.after.mir
@@ -1,11 +1,11 @@
 // MIR for `no_codegen` after PreCodegen
 
 fn no_codegen() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/remove-never-const.rs:+0:20: +0:20
+    let mut _0: ();                      // return place in scope 0 at $DIR/remove_never_const.rs:+0:20: +0:20
     scope 1 {
     }
 
     bb0: {
-        unreachable;                     // scope 0 at $DIR/remove-never-const.rs:+1:13: +1:33
+        unreachable;                     // scope 0 at $DIR/remove_never_const.rs:+1:13: +1:33
     }
 }
diff --git a/src/test/mir-opt/remove-never-const.rs b/src/test/mir-opt/remove_never_const.rs
similarity index 100%
rename from src/test/mir-opt/remove-never-const.rs
rename to src/test/mir-opt/remove_never_const.rs
diff --git a/src/test/mir-opt/simplify-arm.rs b/src/test/mir-opt/simplify_arm.rs
similarity index 100%
rename from src/test/mir-opt/simplify-arm.rs
rename to src/test/mir-opt/simplify_arm.rs
diff --git a/src/test/mir-opt/simplify-arm-identity.rs b/src/test/mir-opt/simplify_arm_identity.rs
similarity index 100%
rename from src/test/mir-opt/simplify-arm-identity.rs
rename to src/test/mir-opt/simplify_arm_identity.rs
diff --git a/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff
index 5d7517e4eb4..1a5143aa0fa 100644
--- a/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff
+++ b/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff
@@ -2,32 +2,32 @@
 + // MIR for `c` after SimplifyLocals
   
   fn c() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-locals.rs:+0:8: +0:8
-      let _1: [u8; 10];                    // in scope 0 at $DIR/simplify-locals.rs:+1:9: +1:14
--     let mut _2: &[u8];                   // in scope 0 at $DIR/simplify-locals.rs:+3:20: +3:26
--     let mut _3: &[u8; 10];               // in scope 0 at $DIR/simplify-locals.rs:+3:20: +3:26
--     let _4: &[u8; 10];                   // in scope 0 at $DIR/simplify-locals.rs:+3:20: +3:26
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_locals.rs:+0:8: +0:8
+      let _1: [u8; 10];                    // in scope 0 at $DIR/simplify_locals.rs:+1:9: +1:14
+-     let mut _2: &[u8];                   // in scope 0 at $DIR/simplify_locals.rs:+3:20: +3:26
+-     let mut _3: &[u8; 10];               // in scope 0 at $DIR/simplify_locals.rs:+3:20: +3:26
+-     let _4: &[u8; 10];                   // in scope 0 at $DIR/simplify_locals.rs:+3:20: +3:26
       scope 1 {
-          debug bytes => _1;               // in scope 1 at $DIR/simplify-locals.rs:+1:9: +1:14
+          debug bytes => _1;               // in scope 1 at $DIR/simplify_locals.rs:+1:9: +1:14
           scope 2 {
           }
       }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/simplify-locals.rs:+1:9: +1:14
-          _1 = [const 0_u8; 10];           // scope 0 at $DIR/simplify-locals.rs:+1:17: +1:26
--         StorageLive(_2);                 // scope 1 at $DIR/simplify-locals.rs:+3:20: +3:26
--         StorageLive(_3);                 // scope 1 at $DIR/simplify-locals.rs:+3:20: +3:26
--         StorageLive(_4);                 // scope 1 at $DIR/simplify-locals.rs:+3:20: +3:26
--         _4 = &_1;                        // scope 1 at $DIR/simplify-locals.rs:+3:20: +3:26
--         _3 = &(*_4);                     // scope 1 at $DIR/simplify-locals.rs:+3:20: +3:26
--         _2 = move _3 as &[u8] (Pointer(Unsize)); // scope 1 at $DIR/simplify-locals.rs:+3:20: +3:26
--         StorageDead(_3);                 // scope 1 at $DIR/simplify-locals.rs:+3:25: +3:26
--         StorageDead(_4);                 // scope 1 at $DIR/simplify-locals.rs:+3:26: +3:27
--         StorageDead(_2);                 // scope 1 at $DIR/simplify-locals.rs:+3:26: +3:27
-          _0 = const ();                   // scope 0 at $DIR/simplify-locals.rs:+0:8: +4:2
-          StorageDead(_1);                 // scope 0 at $DIR/simplify-locals.rs:+4:1: +4:2
-          return;                          // scope 0 at $DIR/simplify-locals.rs:+4:2: +4:2
+          StorageLive(_1);                 // scope 0 at $DIR/simplify_locals.rs:+1:9: +1:14
+          _1 = [const 0_u8; 10];           // scope 0 at $DIR/simplify_locals.rs:+1:17: +1:26
+-         StorageLive(_2);                 // scope 1 at $DIR/simplify_locals.rs:+3:20: +3:26
+-         StorageLive(_3);                 // scope 1 at $DIR/simplify_locals.rs:+3:20: +3:26
+-         StorageLive(_4);                 // scope 1 at $DIR/simplify_locals.rs:+3:20: +3:26
+-         _4 = &_1;                        // scope 1 at $DIR/simplify_locals.rs:+3:20: +3:26
+-         _3 = &(*_4);                     // scope 1 at $DIR/simplify_locals.rs:+3:20: +3:26
+-         _2 = move _3 as &[u8] (Pointer(Unsize)); // scope 1 at $DIR/simplify_locals.rs:+3:20: +3:26
+-         StorageDead(_3);                 // scope 1 at $DIR/simplify_locals.rs:+3:25: +3:26
+-         StorageDead(_4);                 // scope 1 at $DIR/simplify_locals.rs:+3:26: +3:27
+-         StorageDead(_2);                 // scope 1 at $DIR/simplify_locals.rs:+3:26: +3:27
+          _0 = const ();                   // scope 0 at $DIR/simplify_locals.rs:+0:8: +4:2
+          StorageDead(_1);                 // scope 0 at $DIR/simplify_locals.rs:+4:1: +4:2
+          return;                          // scope 0 at $DIR/simplify_locals.rs:+4:2: +4:2
       }
   }
   
diff --git a/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff
index a9ea8869a96..6426bf926a4 100644
--- a/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff
+++ b/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff
@@ -2,18 +2,18 @@
 + // MIR for `d1` after SimplifyLocals
   
   fn d1() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-locals.rs:+0:9: +0:9
--     let mut _1: E;                       // in scope 0 at $DIR/simplify-locals.rs:+2:13: +2:17
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9
+-     let mut _1: E;                       // in scope 0 at $DIR/simplify_locals.rs:+2:13: +2:17
       scope 1 {
       }
   
       bb0: {
--         StorageLive(_1);                 // scope 0 at $DIR/simplify-locals.rs:+2:13: +2:17
--         Deinit(_1);                      // scope 0 at $DIR/simplify-locals.rs:+2:13: +2:17
--         discriminant(_1) = 0;            // scope 0 at $DIR/simplify-locals.rs:+2:13: +2:17
--         StorageDead(_1);                 // scope 0 at $DIR/simplify-locals.rs:+2:17: +2:18
-          _0 = const ();                   // scope 0 at $DIR/simplify-locals.rs:+0:9: +3:2
-          return;                          // scope 0 at $DIR/simplify-locals.rs:+3:2: +3:2
+-         StorageLive(_1);                 // scope 0 at $DIR/simplify_locals.rs:+2:13: +2:17
+-         Deinit(_1);                      // scope 0 at $DIR/simplify_locals.rs:+2:13: +2:17
+-         discriminant(_1) = 0;            // scope 0 at $DIR/simplify_locals.rs:+2:13: +2:17
+-         StorageDead(_1);                 // scope 0 at $DIR/simplify_locals.rs:+2:17: +2:18
+          _0 = const ();                   // scope 0 at $DIR/simplify_locals.rs:+0:9: +3:2
+          return;                          // scope 0 at $DIR/simplify_locals.rs:+3:2: +3:2
       }
   }
   
diff --git a/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff
index 6a89e45843b..db5ab182d6f 100644
--- a/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff
+++ b/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff
@@ -2,28 +2,28 @@
 + // MIR for `d2` after SimplifyLocals
   
   fn d2() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-locals.rs:+0:9: +0:9
--     let mut _1: E;                       // in scope 0 at $DIR/simplify-locals.rs:+2:22: +2:26
--     let mut _2: (i32, E);                // in scope 0 at $DIR/simplify-locals.rs:+2:5: +2:17
--     let mut _3: E;                       // in scope 0 at $DIR/simplify-locals.rs:+2:11: +2:15
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9
+-     let mut _1: E;                       // in scope 0 at $DIR/simplify_locals.rs:+2:22: +2:26
+-     let mut _2: (i32, E);                // in scope 0 at $DIR/simplify_locals.rs:+2:5: +2:17
+-     let mut _3: E;                       // in scope 0 at $DIR/simplify_locals.rs:+2:11: +2:15
   
       bb0: {
--         StorageLive(_1);                 // scope 0 at $DIR/simplify-locals.rs:+2:22: +2:26
--         Deinit(_1);                      // scope 0 at $DIR/simplify-locals.rs:+2:22: +2:26
--         discriminant(_1) = 1;            // scope 0 at $DIR/simplify-locals.rs:+2:22: +2:26
--         StorageLive(_2);                 // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:17
--         StorageLive(_3);                 // scope 0 at $DIR/simplify-locals.rs:+2:11: +2:15
--         Deinit(_3);                      // scope 0 at $DIR/simplify-locals.rs:+2:11: +2:15
--         discriminant(_3) = 0;            // scope 0 at $DIR/simplify-locals.rs:+2:11: +2:15
--         Deinit(_2);                      // scope 0 at $DIR/simplify-locals.rs:+2:6: +2:16
--         (_2.0: i32) = const 10_i32;      // scope 0 at $DIR/simplify-locals.rs:+2:6: +2:16
--         (_2.1: E) = move _3;             // scope 0 at $DIR/simplify-locals.rs:+2:6: +2:16
--         StorageDead(_3);                 // scope 0 at $DIR/simplify-locals.rs:+2:15: +2:16
--         (_2.1: E) = move _1;             // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:26
--         StorageDead(_1);                 // scope 0 at $DIR/simplify-locals.rs:+2:25: +2:26
--         StorageDead(_2);                 // scope 0 at $DIR/simplify-locals.rs:+2:26: +2:27
-          _0 = const ();                   // scope 0 at $DIR/simplify-locals.rs:+0:9: +3:2
-          return;                          // scope 0 at $DIR/simplify-locals.rs:+3:2: +3:2
+-         StorageLive(_1);                 // scope 0 at $DIR/simplify_locals.rs:+2:22: +2:26
+-         Deinit(_1);                      // scope 0 at $DIR/simplify_locals.rs:+2:22: +2:26
+-         discriminant(_1) = 1;            // scope 0 at $DIR/simplify_locals.rs:+2:22: +2:26
+-         StorageLive(_2);                 // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:17
+-         StorageLive(_3);                 // scope 0 at $DIR/simplify_locals.rs:+2:11: +2:15
+-         Deinit(_3);                      // scope 0 at $DIR/simplify_locals.rs:+2:11: +2:15
+-         discriminant(_3) = 0;            // scope 0 at $DIR/simplify_locals.rs:+2:11: +2:15
+-         Deinit(_2);                      // scope 0 at $DIR/simplify_locals.rs:+2:6: +2:16
+-         (_2.0: i32) = const 10_i32;      // scope 0 at $DIR/simplify_locals.rs:+2:6: +2:16
+-         (_2.1: E) = move _3;             // scope 0 at $DIR/simplify_locals.rs:+2:6: +2:16
+-         StorageDead(_3);                 // scope 0 at $DIR/simplify_locals.rs:+2:15: +2:16
+-         (_2.1: E) = move _1;             // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:26
+-         StorageDead(_1);                 // scope 0 at $DIR/simplify_locals.rs:+2:25: +2:26
+-         StorageDead(_2);                 // scope 0 at $DIR/simplify_locals.rs:+2:26: +2:27
+          _0 = const ();                   // scope 0 at $DIR/simplify_locals.rs:+0:9: +3:2
+          return;                          // scope 0 at $DIR/simplify_locals.rs:+3:2: +3:2
       }
   }
   
diff --git a/src/test/mir-opt/simplify_locals.expose_addr.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.expose_addr.SimplifyLocals.diff
index 204a1bffc81..c707b0da07e 100644
--- a/src/test/mir-opt/simplify_locals.expose_addr.SimplifyLocals.diff
+++ b/src/test/mir-opt/simplify_locals.expose_addr.SimplifyLocals.diff
@@ -2,20 +2,20 @@
 + // MIR for `expose_addr` after SimplifyLocals
   
   fn expose_addr(_1: *const usize) -> () {
-      debug p => _1;                       // in scope 0 at $DIR/simplify-locals.rs:+0:16: +0:17
-      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-locals.rs:+0:33: +0:33
-      let _2: usize;                       // in scope 0 at $DIR/simplify-locals.rs:+2:5: +2:15
-      let mut _3: *const usize;            // in scope 0 at $DIR/simplify-locals.rs:+2:5: +2:6
+      debug p => _1;                       // in scope 0 at $DIR/simplify_locals.rs:+0:16: +0:17
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_locals.rs:+0:33: +0:33
+      let _2: usize;                       // in scope 0 at $DIR/simplify_locals.rs:+2:5: +2:15
+      let mut _3: *const usize;            // in scope 0 at $DIR/simplify_locals.rs:+2:5: +2:6
   
       bb0: {
-          StorageLive(_2);                 // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:15
-          StorageLive(_3);                 // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:6
-          _3 = _1;                         // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:6
-          _2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:15
-          StorageDead(_3);                 // scope 0 at $DIR/simplify-locals.rs:+2:14: +2:15
-          StorageDead(_2);                 // scope 0 at $DIR/simplify-locals.rs:+2:15: +2:16
-          _0 = const ();                   // scope 0 at $DIR/simplify-locals.rs:+0:33: +3:2
-          return;                          // scope 0 at $DIR/simplify-locals.rs:+3:2: +3:2
+          StorageLive(_2);                 // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:15
+          StorageLive(_3);                 // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:6
+          _3 = _1;                         // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:6
+          _2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:15
+          StorageDead(_3);                 // scope 0 at $DIR/simplify_locals.rs:+2:14: +2:15
+          StorageDead(_2);                 // scope 0 at $DIR/simplify_locals.rs:+2:15: +2:16
+          _0 = const ();                   // scope 0 at $DIR/simplify_locals.rs:+0:33: +3:2
+          return;                          // scope 0 at $DIR/simplify_locals.rs:+3:2: +3:2
       }
   }
   
diff --git a/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff
index 329e2a65a0d..ff6eb2cff5e 100644
--- a/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff
+++ b/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff
@@ -2,12 +2,12 @@
 + // MIR for `r` after SimplifyLocals
   
   fn r() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-locals.rs:+0:8: +0:8
-      let mut _1: i32;                     // in scope 0 at $DIR/simplify-locals.rs:+1:9: +1:14
--     let mut _2: &i32;                    // in scope 0 at $DIR/simplify-locals.rs:+3:13: +3:15
--     let mut _3: &mut i32;                // in scope 0 at $DIR/simplify-locals.rs:+4:13: +4:19
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_locals.rs:+0:8: +0:8
+      let mut _1: i32;                     // in scope 0 at $DIR/simplify_locals.rs:+1:9: +1:14
+-     let mut _2: &i32;                    // in scope 0 at $DIR/simplify_locals.rs:+3:13: +3:15
+-     let mut _3: &mut i32;                // in scope 0 at $DIR/simplify_locals.rs:+4:13: +4:19
       scope 1 {
-          debug a => _1;                   // in scope 1 at $DIR/simplify-locals.rs:+1:9: +1:14
+          debug a => _1;                   // in scope 1 at $DIR/simplify_locals.rs:+1:9: +1:14
           scope 2 {
               scope 3 {
               }
@@ -15,17 +15,17 @@
       }
   
       bb0: {
-          StorageLive(_1);                 // scope 0 at $DIR/simplify-locals.rs:+1:9: +1:14
-          _1 = const 1_i32;                // scope 0 at $DIR/simplify-locals.rs:+1:17: +1:18
--         StorageLive(_2);                 // scope 1 at $DIR/simplify-locals.rs:+3:13: +3:15
--         _2 = &_1;                        // scope 1 at $DIR/simplify-locals.rs:+3:13: +3:15
--         StorageDead(_2);                 // scope 1 at $DIR/simplify-locals.rs:+3:15: +3:16
--         StorageLive(_3);                 // scope 2 at $DIR/simplify-locals.rs:+4:13: +4:19
--         _3 = &mut _1;                    // scope 2 at $DIR/simplify-locals.rs:+4:13: +4:19
--         StorageDead(_3);                 // scope 2 at $DIR/simplify-locals.rs:+4:19: +4:20
-          _0 = const ();                   // scope 0 at $DIR/simplify-locals.rs:+0:8: +5:2
-          StorageDead(_1);                 // scope 0 at $DIR/simplify-locals.rs:+5:1: +5:2
-          return;                          // scope 0 at $DIR/simplify-locals.rs:+5:2: +5:2
+          StorageLive(_1);                 // scope 0 at $DIR/simplify_locals.rs:+1:9: +1:14
+          _1 = const 1_i32;                // scope 0 at $DIR/simplify_locals.rs:+1:17: +1:18
+-         StorageLive(_2);                 // scope 1 at $DIR/simplify_locals.rs:+3:13: +3:15
+-         _2 = &_1;                        // scope 1 at $DIR/simplify_locals.rs:+3:13: +3:15
+-         StorageDead(_2);                 // scope 1 at $DIR/simplify_locals.rs:+3:15: +3:16
+-         StorageLive(_3);                 // scope 2 at $DIR/simplify_locals.rs:+4:13: +4:19
+-         _3 = &mut _1;                    // scope 2 at $DIR/simplify_locals.rs:+4:13: +4:19
+-         StorageDead(_3);                 // scope 2 at $DIR/simplify_locals.rs:+4:19: +4:20
+          _0 = const ();                   // scope 0 at $DIR/simplify_locals.rs:+0:8: +5:2
+          StorageDead(_1);                 // scope 0 at $DIR/simplify_locals.rs:+5:1: +5:2
+          return;                          // scope 0 at $DIR/simplify_locals.rs:+5:2: +5:2
       }
   }
   
diff --git a/src/test/mir-opt/simplify-locals.rs b/src/test/mir-opt/simplify_locals.rs
similarity index 100%
rename from src/test/mir-opt/simplify-locals.rs
rename to src/test/mir-opt/simplify_locals.rs
diff --git a/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff
index b31156ad697..49db7747963 100644
--- a/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff
+++ b/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff
@@ -2,21 +2,21 @@
 + // MIR for `t1` after SimplifyLocals
   
   fn t1() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-locals.rs:+0:9: +0:9
--     let _1: u32;                         // in scope 0 at $DIR/simplify-locals.rs:+2:14: +2:15
--     let mut _2: *mut u32;                // in scope 0 at $DIR/simplify-locals.rs:+2:14: +2:15
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9
+-     let _1: u32;                         // in scope 0 at $DIR/simplify_locals.rs:+2:14: +2:15
+-     let mut _2: *mut u32;                // in scope 0 at $DIR/simplify_locals.rs:+2:14: +2:15
       scope 1 {
       }
   
       bb0: {
--         StorageLive(_1);                 // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:17
--         StorageLive(_2);                 // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15
--         _2 = &/*tls*/ mut X;             // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15
--         _1 = (*_2);                      // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15
--         StorageDead(_2);                 // scope 0 at $DIR/simplify-locals.rs:+2:17: +2:18
--         StorageDead(_1);                 // scope 0 at $DIR/simplify-locals.rs:+2:17: +2:18
-          _0 = const ();                   // scope 0 at $DIR/simplify-locals.rs:+0:9: +3:2
-          return;                          // scope 0 at $DIR/simplify-locals.rs:+3:2: +3:2
+-         StorageLive(_1);                 // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:17
+-         StorageLive(_2);                 // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15
+-         _2 = &/*tls*/ mut X;             // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15
+-         _1 = (*_2);                      // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15
+-         StorageDead(_2);                 // scope 0 at $DIR/simplify_locals.rs:+2:17: +2:18
+-         StorageDead(_1);                 // scope 0 at $DIR/simplify_locals.rs:+2:17: +2:18
+          _0 = const ();                   // scope 0 at $DIR/simplify_locals.rs:+0:9: +3:2
+          return;                          // scope 0 at $DIR/simplify_locals.rs:+3:2: +3:2
       }
   }
   
diff --git a/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff
index 66b6d8d6486..e3f4ae3701b 100644
--- a/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff
+++ b/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff
@@ -2,21 +2,21 @@
 + // MIR for `t2` after SimplifyLocals
   
   fn t2() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-locals.rs:+0:9: +0:9
--     let _1: &mut u32;                    // in scope 0 at $DIR/simplify-locals.rs:+2:14: +2:20
--     let mut _2: *mut u32;                // in scope 0 at $DIR/simplify-locals.rs:+2:19: +2:20
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9
+-     let _1: &mut u32;                    // in scope 0 at $DIR/simplify_locals.rs:+2:14: +2:20
+-     let mut _2: *mut u32;                // in scope 0 at $DIR/simplify_locals.rs:+2:19: +2:20
       scope 1 {
       }
   
       bb0: {
--         StorageLive(_1);                 // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:22
--         StorageLive(_2);                 // scope 1 at $DIR/simplify-locals.rs:+2:19: +2:20
--         _2 = &/*tls*/ mut X;             // scope 1 at $DIR/simplify-locals.rs:+2:19: +2:20
--         _1 = &mut (*_2);                 // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:20
--         StorageDead(_2);                 // scope 0 at $DIR/simplify-locals.rs:+2:22: +2:23
--         StorageDead(_1);                 // scope 0 at $DIR/simplify-locals.rs:+2:22: +2:23
-          _0 = const ();                   // scope 0 at $DIR/simplify-locals.rs:+0:9: +3:2
-          return;                          // scope 0 at $DIR/simplify-locals.rs:+3:2: +3:2
+-         StorageLive(_1);                 // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:22
+-         StorageLive(_2);                 // scope 1 at $DIR/simplify_locals.rs:+2:19: +2:20
+-         _2 = &/*tls*/ mut X;             // scope 1 at $DIR/simplify_locals.rs:+2:19: +2:20
+-         _1 = &mut (*_2);                 // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:20
+-         StorageDead(_2);                 // scope 0 at $DIR/simplify_locals.rs:+2:22: +2:23
+-         StorageDead(_1);                 // scope 0 at $DIR/simplify_locals.rs:+2:22: +2:23
+          _0 = const ();                   // scope 0 at $DIR/simplify_locals.rs:+0:9: +3:2
+          return;                          // scope 0 at $DIR/simplify_locals.rs:+3:2: +3:2
       }
   }
   
diff --git a/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff
index f6b6b78cdfb..f1ce7778e19 100644
--- a/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff
+++ b/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff
@@ -2,25 +2,25 @@
 + // MIR for `t3` after SimplifyLocals
   
   fn t3() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-locals.rs:+0:9: +0:9
--     let _1: u32;                         // in scope 0 at $DIR/simplify-locals.rs:+2:14: +2:21
--     let mut _2: &mut u32;                // in scope 0 at $DIR/simplify-locals.rs:+2:15: +2:21
--     let mut _3: *mut u32;                // in scope 0 at $DIR/simplify-locals.rs:+2:20: +2:21
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9
+-     let _1: u32;                         // in scope 0 at $DIR/simplify_locals.rs:+2:14: +2:21
+-     let mut _2: &mut u32;                // in scope 0 at $DIR/simplify_locals.rs:+2:15: +2:21
+-     let mut _3: *mut u32;                // in scope 0 at $DIR/simplify_locals.rs:+2:20: +2:21
       scope 1 {
       }
   
       bb0: {
--         StorageLive(_1);                 // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:23
--         StorageLive(_2);                 // scope 1 at $DIR/simplify-locals.rs:+2:15: +2:21
--         StorageLive(_3);                 // scope 1 at $DIR/simplify-locals.rs:+2:20: +2:21
--         _3 = &/*tls*/ mut X;             // scope 1 at $DIR/simplify-locals.rs:+2:20: +2:21
--         _2 = &mut (*_3);                 // scope 1 at $DIR/simplify-locals.rs:+2:15: +2:21
--         _1 = (*_2);                      // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:21
--         StorageDead(_3);                 // scope 0 at $DIR/simplify-locals.rs:+2:23: +2:24
--         StorageDead(_2);                 // scope 0 at $DIR/simplify-locals.rs:+2:23: +2:24
--         StorageDead(_1);                 // scope 0 at $DIR/simplify-locals.rs:+2:23: +2:24
-          _0 = const ();                   // scope 0 at $DIR/simplify-locals.rs:+0:9: +3:2
-          return;                          // scope 0 at $DIR/simplify-locals.rs:+3:2: +3:2
+-         StorageLive(_1);                 // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:23
+-         StorageLive(_2);                 // scope 1 at $DIR/simplify_locals.rs:+2:15: +2:21
+-         StorageLive(_3);                 // scope 1 at $DIR/simplify_locals.rs:+2:20: +2:21
+-         _3 = &/*tls*/ mut X;             // scope 1 at $DIR/simplify_locals.rs:+2:20: +2:21
+-         _2 = &mut (*_3);                 // scope 1 at $DIR/simplify_locals.rs:+2:15: +2:21
+-         _1 = (*_2);                      // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:21
+-         StorageDead(_3);                 // scope 0 at $DIR/simplify_locals.rs:+2:23: +2:24
+-         StorageDead(_2);                 // scope 0 at $DIR/simplify_locals.rs:+2:23: +2:24
+-         StorageDead(_1);                 // scope 0 at $DIR/simplify_locals.rs:+2:23: +2:24
+          _0 = const ();                   // scope 0 at $DIR/simplify_locals.rs:+0:9: +3:2
+          return;                          // scope 0 at $DIR/simplify_locals.rs:+3:2: +3:2
       }
   }
   
diff --git a/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff
index 1c1da29aa67..71cf9594b9e 100644
--- a/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff
+++ b/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff
@@ -2,21 +2,21 @@
 + // MIR for `t4` after SimplifyLocals
   
   fn t4() -> u32 {
-      let mut _0: u32;                     // return place in scope 0 at $DIR/simplify-locals.rs:+0:12: +0:15
-      let mut _1: u32;                     // in scope 0 at $DIR/simplify-locals.rs:+2:14: +2:15
-      let mut _2: *mut u32;                // in scope 0 at $DIR/simplify-locals.rs:+2:14: +2:15
+      let mut _0: u32;                     // return place in scope 0 at $DIR/simplify_locals.rs:+0:12: +0:15
+      let mut _1: u32;                     // in scope 0 at $DIR/simplify_locals.rs:+2:14: +2:15
+      let mut _2: *mut u32;                // in scope 0 at $DIR/simplify_locals.rs:+2:14: +2:15
       scope 1 {
       }
   
       bb0: {
-          StorageLive(_1);                 // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15
-          StorageLive(_2);                 // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15
-          _2 = &/*tls*/ mut X;             // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15
-          _1 = (*_2);                      // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15
-          _0 = Add(move _1, const 1_u32);  // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:19
-          StorageDead(_1);                 // scope 1 at $DIR/simplify-locals.rs:+2:18: +2:19
-          StorageDead(_2);                 // scope 0 at $DIR/simplify-locals.rs:+3:1: +3:2
-          return;                          // scope 0 at $DIR/simplify-locals.rs:+3:2: +3:2
+          StorageLive(_1);                 // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15
+          StorageLive(_2);                 // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15
+          _2 = &/*tls*/ mut X;             // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15
+          _1 = (*_2);                      // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15
+          _0 = Add(move _1, const 1_u32);  // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:19
+          StorageDead(_1);                 // scope 1 at $DIR/simplify_locals.rs:+2:18: +2:19
+          StorageDead(_2);                 // scope 0 at $DIR/simplify_locals.rs:+3:1: +3:2
+          return;                          // scope 0 at $DIR/simplify_locals.rs:+3:2: +3:2
       }
   }
   
diff --git a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff
index ac7a47ba58f..8feddcef2ce 100644
--- a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff
+++ b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff
@@ -2,61 +2,61 @@
 + // MIR for `foo` after SimplifyLocals
   
   fn foo() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+0:13: +0:13
-      let mut _1: (std::option::Option, std::option::Option); // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+1:30: +1:69
-      let mut _2: std::option::Option; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+1:31: +1:49
-      let mut _3: std::option::Option;  // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+1:51: +1:68
-      let mut _4: isize;                   // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+1:22: +1:26
-      let mut _5: isize;                   // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+1:13: +1:20
--     let mut _7: bool;                    // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+2:12: +2:20
--     let mut _8: u8;                      // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+2:12: +2:13
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+0:13: +0:13
+      let mut _1: (std::option::Option, std::option::Option); // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:30: +1:69
+      let mut _2: std::option::Option; // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:31: +1:49
+      let mut _3: std::option::Option;  // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:51: +1:68
+      let mut _4: isize;                   // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:22: +1:26
+      let mut _5: isize;                   // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:13: +1:20
+-     let mut _7: bool;                    // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:20
+-     let mut _8: u8;                      // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:13
       scope 1 {
-          debug a => _6;                   // in scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:18: +1:19
-          let _6: u8;                      // in scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:18: +1:19
+          debug a => _6;                   // in scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:18: +1:19
+          let _6: u8;                      // in scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:18: +1:19
       }
   
       bb0: {
-          StorageLive(_1);                 // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:30: +1:69
-          StorageLive(_2);                 // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:31: +1:49
-          Deinit(_2);                      // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:31: +1:49
-          discriminant(_2) = 0;            // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:31: +1:49
-          StorageLive(_3);                 // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:51: +1:68
-          Deinit(_3);                      // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:51: +1:68
-          discriminant(_3) = 0;            // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:51: +1:68
-          Deinit(_1);                      // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:30: +1:69
-          (_1.0: std::option::Option) = move _2; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:30: +1:69
-          (_1.1: std::option::Option) = move _3; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:30: +1:69
-          StorageDead(_3);                 // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:68: +1:69
-          StorageDead(_2);                 // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:68: +1:69
-          _5 = discriminant((_1.0: std::option::Option)); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:12: +1:27
-          switchInt(move _5) -> [1_isize: bb1, otherwise: bb3]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:12: +1:27
+          StorageLive(_1);                 // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:30: +1:69
+          StorageLive(_2);                 // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:31: +1:49
+          Deinit(_2);                      // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:31: +1:49
+          discriminant(_2) = 0;            // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:31: +1:49
+          StorageLive(_3);                 // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:51: +1:68
+          Deinit(_3);                      // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:51: +1:68
+          discriminant(_3) = 0;            // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:51: +1:68
+          Deinit(_1);                      // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:30: +1:69
+          (_1.0: std::option::Option) = move _2; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:30: +1:69
+          (_1.1: std::option::Option) = move _3; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:30: +1:69
+          StorageDead(_3);                 // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:68: +1:69
+          StorageDead(_2);                 // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:68: +1:69
+          _5 = discriminant((_1.0: std::option::Option)); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:12: +1:27
+          switchInt(move _5) -> [1_isize: bb1, otherwise: bb3]; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:12: +1:27
       }
   
       bb1: {
-          _4 = discriminant((_1.1: std::option::Option)); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:12: +1:27
-          switchInt(move _4) -> [0_isize: bb2, otherwise: bb3]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:12: +1:27
+          _4 = discriminant((_1.1: std::option::Option)); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:12: +1:27
+          switchInt(move _4) -> [0_isize: bb2, otherwise: bb3]; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:12: +1:27
       }
   
       bb2: {
-          StorageLive(_6);                 // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:18: +1:19
-          _6 = (((_1.0: std::option::Option) as Some).0: u8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:18: +1:19
--         StorageLive(_7);                 // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+2:12: +2:20
--         StorageLive(_8);                 // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+2:12: +2:13
--         _8 = _6;                         // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+2:12: +2:13
--         _7 = Gt(move _8, const 42_u8);   // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+2:12: +2:20
--         StorageDead(_8);                 // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+2:19: +2:20
--         StorageDead(_7);                 // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+4:9: +4:10
-          StorageDead(_6);                 // scope 0 at $DIR/simplify-locals-fixedpoint.rs:+5:5: +5:6
-          goto -> bb3;                     // scope 0 at $DIR/simplify-locals-fixedpoint.rs:+1:5: +5:6
+          StorageLive(_6);                 // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:18: +1:19
+          _6 = (((_1.0: std::option::Option) as Some).0: u8); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:18: +1:19
+-         StorageLive(_7);                 // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:20
+-         StorageLive(_8);                 // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:13
+-         _8 = _6;                         // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:13
+-         _7 = Gt(move _8, const 42_u8);   // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:20
+-         StorageDead(_8);                 // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+2:19: +2:20
+-         StorageDead(_7);                 // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+4:9: +4:10
+          StorageDead(_6);                 // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+5:5: +5:6
+          goto -> bb3;                     // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:5: +5:6
       }
   
       bb3: {
-          drop(_1) -> bb4;                 // scope 0 at $DIR/simplify-locals-fixedpoint.rs:+6:1: +6:2
+          drop(_1) -> bb4;                 // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+6:1: +6:2
       }
   
       bb4: {
-          StorageDead(_1);                 // scope 0 at $DIR/simplify-locals-fixedpoint.rs:+6:1: +6:2
-          return;                          // scope 0 at $DIR/simplify-locals-fixedpoint.rs:+6:2: +6:2
+          StorageDead(_1);                 // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+6:1: +6:2
+          return;                          // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+6:2: +6:2
       }
   }
   
diff --git a/src/test/mir-opt/simplify-locals-fixedpoint.rs b/src/test/mir-opt/simplify_locals_fixedpoint.rs
similarity index 100%
rename from src/test/mir-opt/simplify-locals-fixedpoint.rs
rename to src/test/mir-opt/simplify_locals_fixedpoint.rs
diff --git a/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff
index b41527ba02d..78272272b07 100644
--- a/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff
+++ b/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff
@@ -2,108 +2,108 @@
 + // MIR for `main` after SimplifyLocals
   
   fn main() -> () {
-      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+0:11: +0:11
--     let mut _1: ((), ());                // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:20: +1:28
--     let mut _2: ();                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:21: +1:23
--     let mut _3: ();                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:25: +1:27
--     let _4: ();                          // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22
--     let mut _5: ((), ());                // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
--     let mut _6: ();                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16
--     let mut _7: ();                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20
--     let _8: ();                          // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
--     let mut _9: u8;                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34
--     let mut _10: u8;                     // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30
--     let mut _11: Temp;                   // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
-+     let _1: ();                          // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22
-+     let mut _2: ((), ());                // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
-+     let mut _3: ();                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16
-+     let mut _4: ();                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20
-+     let _5: ();                          // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
-+     let mut _6: u8;                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34
-+     let mut _7: u8;                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30
-+     let mut _8: Temp;                    // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+0:11: +0:11
+-     let mut _1: ((), ());                // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:20: +1:28
+-     let mut _2: ();                      // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:21: +1:23
+-     let mut _3: ();                      // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:25: +1:27
+-     let _4: ();                          // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22
+-     let mut _5: ((), ());                // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21
+-     let mut _6: ();                      // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16
+-     let mut _7: ();                      // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20
+-     let _8: ();                          // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35
+-     let mut _9: u8;                      // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:34
+-     let mut _10: u8;                     // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:30
+-     let mut _11: Temp;                   // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28
++     let _1: ();                          // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22
++     let mut _2: ((), ());                // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21
++     let mut _3: ();                      // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16
++     let mut _4: ();                      // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20
++     let _5: ();                          // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35
++     let mut _6: u8;                      // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:34
++     let mut _7: u8;                      // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:30
++     let mut _8: Temp;                    // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28
       scope 1 {
       }
   
       bb0: {
--         StorageLive(_1);                 // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:20: +1:28
--         StorageLive(_2);                 // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:21: +1:23
--         Deinit(_2);                      // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:21: +1:23
--         StorageLive(_3);                 // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:25: +1:27
--         Deinit(_3);                      // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:25: +1:27
--         Deinit(_1);                      // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:20: +1:28
--         (_1.0: ()) = move _2;            // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:20: +1:28
--         (_1.1: ()) = move _3;            // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:20: +1:28
--         StorageDead(_3);                 // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:27: +1:28
--         StorageDead(_2);                 // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:27: +1:28
--         StorageDead(_1);                 // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:28: +1:29
--         StorageLive(_4);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22
--         StorageLive(_5);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
--         StorageLive(_6);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16
--         Deinit(_6);                      // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16
--         StorageLive(_7);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20
--         Deinit(_7);                      // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20
--         Deinit(_5);                      // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
--         (_5.0: ()) = move _6;            // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
--         (_5.1: ()) = move _7;            // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
--         StorageDead(_7);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:20: +2:21
--         StorageDead(_6);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:20: +2:21
--         _4 = use_zst(move _5) -> bb1;    // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22
-+         StorageLive(_1);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22
-+         StorageLive(_2);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
-+         StorageLive(_3);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16
-+         Deinit(_3);                      // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16
-+         StorageLive(_4);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20
-+         Deinit(_4);                      // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20
-+         Deinit(_2);                      // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
-+         (_2.0: ()) = move _3;            // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
-+         (_2.1: ()) = move _4;            // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
-+         StorageDead(_4);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:20: +2:21
-+         StorageDead(_3);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:20: +2:21
-+         _1 = use_zst(move _2) -> bb1;    // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22
+-         StorageLive(_1);                 // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:20: +1:28
+-         StorageLive(_2);                 // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:21: +1:23
+-         Deinit(_2);                      // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:21: +1:23
+-         StorageLive(_3);                 // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:25: +1:27
+-         Deinit(_3);                      // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:25: +1:27
+-         Deinit(_1);                      // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:20: +1:28
+-         (_1.0: ()) = move _2;            // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:20: +1:28
+-         (_1.1: ()) = move _3;            // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:20: +1:28
+-         StorageDead(_3);                 // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:27: +1:28
+-         StorageDead(_2);                 // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:27: +1:28
+-         StorageDead(_1);                 // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:28: +1:29
+-         StorageLive(_4);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22
+-         StorageLive(_5);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21
+-         StorageLive(_6);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16
+-         Deinit(_6);                      // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16
+-         StorageLive(_7);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20
+-         Deinit(_7);                      // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20
+-         Deinit(_5);                      // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21
+-         (_5.0: ()) = move _6;            // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21
+-         (_5.1: ()) = move _7;            // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21
+-         StorageDead(_7);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:20: +2:21
+-         StorageDead(_6);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:20: +2:21
+-         _4 = use_zst(move _5) -> bb1;    // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22
++         StorageLive(_1);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22
++         StorageLive(_2);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21
++         StorageLive(_3);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16
++         Deinit(_3);                      // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16
++         StorageLive(_4);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20
++         Deinit(_4);                      // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20
++         Deinit(_2);                      // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21
++         (_2.0: ()) = move _3;            // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21
++         (_2.1: ()) = move _4;            // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21
++         StorageDead(_4);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:20: +2:21
++         StorageDead(_3);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:20: +2:21
++         _1 = use_zst(move _2) -> bb1;    // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22
                                            // mir::Constant
-                                           // + span: $DIR/simplify-locals-removes-unused-consts.rs:15:5: 15:12
+                                           // + span: $DIR/simplify_locals_removes_unused_consts.rs:15:5: 15:12
                                            // + literal: Const { ty: fn(((), ())) {use_zst}, val: Value() }
       }
   
       bb1: {
--         StorageDead(_5);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:21: +2:22
--         StorageDead(_4);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:22: +2:23
--         StorageLive(_8);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
--         StorageLive(_9);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34
--         StorageLive(_10);                // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30
--         StorageLive(_11);                // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
--         Deinit(_11);                     // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
--         (_11.0: u8) = const 40_u8;       // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
--         _10 = (_11.0: u8);               // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30
--         _9 = Add(move _10, const 2_u8);  // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34
--         StorageDead(_10);                // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:33: +4:34
--         _8 = use_u8(move _9) -> bb2;     // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
-+         StorageDead(_2);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:21: +2:22
-+         StorageDead(_1);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:22: +2:23
-+         StorageLive(_5);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
-+         StorageLive(_6);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34
-+         StorageLive(_7);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30
-+         StorageLive(_8);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
-+         Deinit(_8);                      // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
-+         (_8.0: u8) = const 40_u8;        // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
-+         _7 = (_8.0: u8);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30
-+         _6 = Add(move _7, const 2_u8);   // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34
-+         StorageDead(_7);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:33: +4:34
-+         _5 = use_u8(move _6) -> bb2;     // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
+-         StorageDead(_5);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:21: +2:22
+-         StorageDead(_4);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:22: +2:23
+-         StorageLive(_8);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35
+-         StorageLive(_9);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:34
+-         StorageLive(_10);                // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:30
+-         StorageLive(_11);                // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28
+-         Deinit(_11);                     // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28
+-         (_11.0: u8) = const 40_u8;       // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28
+-         _10 = (_11.0: u8);               // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:30
+-         _9 = Add(move _10, const 2_u8);  // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:34
+-         StorageDead(_10);                // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:33: +4:34
+-         _8 = use_u8(move _9) -> bb2;     // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35
++         StorageDead(_2);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:21: +2:22
++         StorageDead(_1);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:22: +2:23
++         StorageLive(_5);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35
++         StorageLive(_6);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:34
++         StorageLive(_7);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:30
++         StorageLive(_8);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28
++         Deinit(_8);                      // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28
++         (_8.0: u8) = const 40_u8;        // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28
++         _7 = (_8.0: u8);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:30
++         _6 = Add(move _7, const 2_u8);   // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:34
++         StorageDead(_7);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:33: +4:34
++         _5 = use_u8(move _6) -> bb2;     // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35
                                            // mir::Constant
-                                           // + span: $DIR/simplify-locals-removes-unused-consts.rs:17:5: 17:11
+                                           // + span: $DIR/simplify_locals_removes_unused_consts.rs:17:5: 17:11
                                            // + literal: Const { ty: fn(u8) {use_u8}, val: Value() }
       }
   
       bb2: {
--         StorageDead(_9);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:34: +4:35
--         StorageDead(_11);                // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:35: +4:36
-+         StorageDead(_6);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:34: +4:35
-          StorageDead(_8);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:35: +4:36
-+         StorageDead(_5);                 // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:35: +4:36
-          _0 = const ();                   // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+0:11: +5:2
-          return;                          // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+5:2: +5:2
+-         StorageDead(_9);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:34: +4:35
+-         StorageDead(_11);                // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:35: +4:36
++         StorageDead(_6);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:34: +4:35
+          StorageDead(_8);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:35: +4:36
++         StorageDead(_5);                 // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:35: +4:36
+          _0 = const ();                   // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+0:11: +5:2
+          return;                          // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+5:2: +5:2
       }
   }
   
diff --git a/src/test/mir-opt/simplify-locals-removes-unused-consts.rs b/src/test/mir-opt/simplify_locals_removes_unused_consts.rs
similarity index 100%
rename from src/test/mir-opt/simplify-locals-removes-unused-consts.rs
rename to src/test/mir-opt/simplify_locals_removes_unused_consts.rs
diff --git a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff
index 51d26b08b2a..6e7294003af 100644
--- a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff
+++ b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff
@@ -2,51 +2,51 @@
 + // MIR for `map` after SimplifyLocals
   
   fn map(_1: Option>) -> Option> {
-      debug x => _1;                       // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+0:8: +0:9
-      let mut _0: std::option::Option>; // return place in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+0:31: +0:46
-      let mut _2: isize;                   // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:9: +2:13
-      let _3: std::boxed::Box<()>;         // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:14: +3:15
-      let mut _4: std::boxed::Box<()>;     // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:25: +3:26
--     let mut _5: bool;                    // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+5:1: +5:2
--     let mut _6: isize;                   // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+5:1: +5:2
--     let mut _7: isize;                   // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+5:1: +5:2
+      debug x => _1;                       // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+0:8: +0:9
+      let mut _0: std::option::Option>; // return place in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+0:31: +0:46
+      let mut _2: isize;                   // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+2:9: +2:13
+      let _3: std::boxed::Box<()>;         // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:14: +3:15
+      let mut _4: std::boxed::Box<()>;     // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:25: +3:26
+-     let mut _5: bool;                    // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+5:1: +5:2
+-     let mut _6: isize;                   // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+5:1: +5:2
+-     let mut _7: isize;                   // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+5:1: +5:2
       scope 1 {
-          debug x => _3;                   // in scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:14: +3:15
+          debug x => _3;                   // in scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:14: +3:15
       }
   
       bb0: {
--         _5 = const false;                // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:11: +1:12
--         _5 = const true;                 // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:11: +1:12
-          _2 = discriminant(_1);           // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:11: +1:12
-          switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:5: +1:12
+-         _5 = const false;                // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+1:11: +1:12
+-         _5 = const true;                 // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+1:11: +1:12
+          _2 = discriminant(_1);           // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+1:11: +1:12
+          switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+1:5: +1:12
       }
   
       bb1: {
-          StorageLive(_3);                 // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:14: +3:15
-          _3 = move ((_1 as Some).0: std::boxed::Box<()>); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:14: +3:15
-          StorageLive(_4);                 // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:25: +3:26
-          _4 = move _3;                    // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:25: +3:26
-          Deinit(_0);                      // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:20: +3:27
-          ((_0 as Some).0: std::boxed::Box<()>) = move _4; // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:20: +3:27
-          discriminant(_0) = 1;            // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:20: +3:27
-          StorageDead(_4);                 // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:26: +3:27
-          StorageDead(_3);                 // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:26: +3:27
-          goto -> bb4;                     // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:26: +3:27
+          StorageLive(_3);                 // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:14: +3:15
+          _3 = move ((_1 as Some).0: std::boxed::Box<()>); // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:14: +3:15
+          StorageLive(_4);                 // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:25: +3:26
+          _4 = move _3;                    // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:25: +3:26
+          Deinit(_0);                      // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:20: +3:27
+          ((_0 as Some).0: std::boxed::Box<()>) = move _4; // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:20: +3:27
+          discriminant(_0) = 1;            // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:20: +3:27
+          StorageDead(_4);                 // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:26: +3:27
+          StorageDead(_3);                 // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:26: +3:27
+          goto -> bb4;                     // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:26: +3:27
       }
   
       bb2: {
-          unreachable;                     // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:11: +1:12
+          unreachable;                     // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+1:11: +1:12
       }
   
       bb3: {
-          Deinit(_0);                      // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:17: +2:21
-          discriminant(_0) = 0;            // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:17: +2:21
-          goto -> bb4;                     // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:17: +2:21
+          Deinit(_0);                      // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+2:17: +2:21
+          discriminant(_0) = 0;            // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+2:17: +2:21
+          goto -> bb4;                     // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+2:17: +2:21
       }
   
       bb4: {
--         _6 = discriminant(_1);           // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+5:1: +5:2
-          return;                          // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+5:2: +5:2
+-         _6 = discriminant(_1);           // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+5:1: +5:2
+          return;                          // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+5:2: +5:2
       }
   }
   
diff --git a/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads.rs b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs
similarity index 100%
rename from src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads.rs
rename to src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs
diff --git a/src/test/mir-opt/slice-drop-shim.rs b/src/test/mir-opt/slice_drop_shim.rs
similarity index 100%
rename from src/test/mir-opt/slice-drop-shim.rs
rename to src/test/mir-opt/slice_drop_shim.rs
diff --git a/src/test/mir-opt/spanview_block.main.built.after.html b/src/test/mir-opt/spanview_block.main.built.after.html
index fbf751d6d30..b962d80c59e 100644
--- a/src/test/mir-opt/spanview_block.main.built.after.html
+++ b/src/test/mir-opt/spanview_block.main.built.after.html
@@ -59,7 +59,7 @@
 
 
 
-
fn main() fn main() 0⦊{}⦉0
diff --git a/src/test/mir-opt/spanview-block.rs b/src/test/mir-opt/spanview_block.rs similarity index 100% rename from src/test/mir-opt/spanview-block.rs rename to src/test/mir-opt/spanview_block.rs diff --git a/src/test/mir-opt/spanview_statement.main.built.after.html b/src/test/mir-opt/spanview_statement.main.built.after.html index 02b2720feef..43bff7d096e 100644 --- a/src/test/mir-opt/spanview_statement.main.built.after.html +++ b/src/test/mir-opt/spanview_statement.main.built.after.html @@ -59,8 +59,8 @@ -
fn main() 0[0]⦊{}⦉0[0]fn main() 0[0]⦊{}⦉0[0]0:Return⦊⦉0:Return
diff --git a/src/test/mir-opt/spanview-statement.rs b/src/test/mir-opt/spanview_statement.rs similarity index 100% rename from src/test/mir-opt/spanview-statement.rs rename to src/test/mir-opt/spanview_statement.rs diff --git a/src/test/mir-opt/spanview_terminator.main.built.after.html b/src/test/mir-opt/spanview_terminator.main.built.after.html index a4cda7dd67e..aa7e44c1571 100644 --- a/src/test/mir-opt/spanview_terminator.main.built.after.html +++ b/src/test/mir-opt/spanview_terminator.main.built.after.html @@ -59,7 +59,7 @@ -
fn main() {}fn main() {}0:Return⦊⦉0:Return
diff --git a/src/test/mir-opt/spanview-terminator.rs b/src/test/mir-opt/spanview_terminator.rs similarity index 100% rename from src/test/mir-opt/spanview-terminator.rs rename to src/test/mir-opt/spanview_terminator.rs diff --git a/src/test/mir-opt/tls_access.main.PreCodegen.after.mir b/src/test/mir-opt/tls_access.main.PreCodegen.after.mir index b6c36be2bbe..09453b8ba9c 100644 --- a/src/test/mir-opt/tls_access.main.PreCodegen.after.mir +++ b/src/test/mir-opt/tls_access.main.PreCodegen.after.mir @@ -1,28 +1,28 @@ // MIR for `main` after PreCodegen fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/tls-access.rs:+0:11: +0:11 - let _2: *mut u8; // in scope 0 at $DIR/tls-access.rs:+2:18: +2:21 - let mut _3: *mut u8; // in scope 0 at $DIR/tls-access.rs:+3:9: +3:12 + let mut _0: (); // return place in scope 0 at $DIR/tls_access.rs:+0:11: +0:11 + let _2: *mut u8; // in scope 0 at $DIR/tls_access.rs:+2:18: +2:21 + let mut _3: *mut u8; // in scope 0 at $DIR/tls_access.rs:+3:9: +3:12 scope 1 { - let _1: &u8; // in scope 1 at $DIR/tls-access.rs:+2:13: +2:14 + let _1: &u8; // in scope 1 at $DIR/tls_access.rs:+2:13: +2:14 scope 2 { - debug a => _1; // in scope 2 at $DIR/tls-access.rs:+2:13: +2:14 + debug a => _1; // in scope 2 at $DIR/tls_access.rs:+2:13: +2:14 } } bb0: { - StorageLive(_1); // scope 1 at $DIR/tls-access.rs:+2:13: +2:14 - StorageLive(_2); // scope 1 at $DIR/tls-access.rs:+2:18: +2:21 - _2 = &/*tls*/ mut FOO; // scope 1 at $DIR/tls-access.rs:+2:18: +2:21 - _1 = &(*_2); // scope 1 at $DIR/tls-access.rs:+2:17: +2:21 - StorageLive(_3); // scope 2 at $DIR/tls-access.rs:+3:9: +3:12 - _3 = &/*tls*/ mut FOO; // scope 2 at $DIR/tls-access.rs:+3:9: +3:12 - (*_3) = const 42_u8; // scope 2 at $DIR/tls-access.rs:+3:9: +3:17 - StorageDead(_3); // scope 2 at $DIR/tls-access.rs:+3:17: +3:18 - _0 = const (); // scope 1 at $DIR/tls-access.rs:+1:5: +4:6 - StorageDead(_2); // scope 1 at $DIR/tls-access.rs:+4:5: +4:6 - StorageDead(_1); // scope 1 at $DIR/tls-access.rs:+4:5: +4:6 - return; // scope 0 at $DIR/tls-access.rs:+5:2: +5:2 + StorageLive(_1); // scope 1 at $DIR/tls_access.rs:+2:13: +2:14 + StorageLive(_2); // scope 1 at $DIR/tls_access.rs:+2:18: +2:21 + _2 = &/*tls*/ mut FOO; // scope 1 at $DIR/tls_access.rs:+2:18: +2:21 + _1 = &(*_2); // scope 1 at $DIR/tls_access.rs:+2:17: +2:21 + StorageLive(_3); // scope 2 at $DIR/tls_access.rs:+3:9: +3:12 + _3 = &/*tls*/ mut FOO; // scope 2 at $DIR/tls_access.rs:+3:9: +3:12 + (*_3) = const 42_u8; // scope 2 at $DIR/tls_access.rs:+3:9: +3:17 + StorageDead(_3); // scope 2 at $DIR/tls_access.rs:+3:17: +3:18 + _0 = const (); // scope 1 at $DIR/tls_access.rs:+1:5: +4:6 + StorageDead(_2); // scope 1 at $DIR/tls_access.rs:+4:5: +4:6 + StorageDead(_1); // scope 1 at $DIR/tls_access.rs:+4:5: +4:6 + return; // scope 0 at $DIR/tls_access.rs:+5:2: +5:2 } } diff --git a/src/test/mir-opt/tls-access.rs b/src/test/mir-opt/tls_access.rs similarity index 100% rename from src/test/mir-opt/tls-access.rs rename to src/test/mir-opt/tls_access.rs diff --git a/src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals.after.mir b/src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals.after.mir index 6ed53643f4b..2c0fcc6621a 100644 --- a/src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals.after.mir +++ b/src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals.after.mir @@ -1,16 +1,16 @@ // MIR for `process_never` after SimplifyLocals fn process_never(_1: *const !) -> () { - debug input => _1; // in scope 0 at $DIR/uninhabited-enum.rs:+0:22: +0:27 - let mut _0: (); // return place in scope 0 at $DIR/uninhabited-enum.rs:+0:39: +0:39 - let _2: &!; // in scope 0 at $DIR/uninhabited-enum.rs:+1:8: +1:14 + debug input => _1; // in scope 0 at $DIR/uninhabited_enum.rs:+0:22: +0:27 + let mut _0: (); // return place in scope 0 at $DIR/uninhabited_enum.rs:+0:39: +0:39 + let _2: &!; // in scope 0 at $DIR/uninhabited_enum.rs:+1:8: +1:14 scope 1 { - debug _input => _2; // in scope 1 at $DIR/uninhabited-enum.rs:+1:8: +1:14 + debug _input => _2; // in scope 1 at $DIR/uninhabited_enum.rs:+1:8: +1:14 } scope 2 { } bb0: { - unreachable; // scope 0 at $DIR/uninhabited-enum.rs:+0:39: +2:2 + unreachable; // scope 0 at $DIR/uninhabited_enum.rs:+0:39: +2:2 } } diff --git a/src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals.after.mir b/src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals.after.mir index bbb81724ccf..ae341a7b97b 100644 --- a/src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals.after.mir +++ b/src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals.after.mir @@ -1,18 +1,18 @@ // MIR for `process_void` after SimplifyLocals fn process_void(_1: *const Void) -> () { - debug input => _1; // in scope 0 at $DIR/uninhabited-enum.rs:+0:21: +0:26 - let mut _0: (); // return place in scope 0 at $DIR/uninhabited-enum.rs:+0:41: +0:41 - let _2: &Void; // in scope 0 at $DIR/uninhabited-enum.rs:+1:8: +1:14 + debug input => _1; // in scope 0 at $DIR/uninhabited_enum.rs:+0:21: +0:26 + let mut _0: (); // return place in scope 0 at $DIR/uninhabited_enum.rs:+0:41: +0:41 + let _2: &Void; // in scope 0 at $DIR/uninhabited_enum.rs:+1:8: +1:14 scope 1 { - debug _input => _2; // in scope 1 at $DIR/uninhabited-enum.rs:+1:8: +1:14 + debug _input => _2; // in scope 1 at $DIR/uninhabited_enum.rs:+1:8: +1:14 } scope 2 { } bb0: { - StorageLive(_2); // scope 0 at $DIR/uninhabited-enum.rs:+1:8: +1:14 - StorageDead(_2); // scope 0 at $DIR/uninhabited-enum.rs:+4:1: +4:2 - return; // scope 0 at $DIR/uninhabited-enum.rs:+4:2: +4:2 + StorageLive(_2); // scope 0 at $DIR/uninhabited_enum.rs:+1:8: +1:14 + StorageDead(_2); // scope 0 at $DIR/uninhabited_enum.rs:+4:1: +4:2 + return; // scope 0 at $DIR/uninhabited_enum.rs:+4:2: +4:2 } } diff --git a/src/test/mir-opt/uninhabited-enum.rs b/src/test/mir-opt/uninhabited_enum.rs similarity index 100% rename from src/test/mir-opt/uninhabited-enum.rs rename to src/test/mir-opt/uninhabited_enum.rs diff --git a/src/test/mir-opt/unusual_item_types.E-V-{constant#0}.built.after.mir b/src/test/mir-opt/unusual_item_types.E-V-{constant#0}.built.after.mir index c8b0f8e41b7..5257491f0d4 100644 --- a/src/test/mir-opt/unusual_item_types.E-V-{constant#0}.built.after.mir +++ b/src/test/mir-opt/unusual_item_types.E-V-{constant#0}.built.after.mir @@ -1,10 +1,10 @@ // MIR for `E::V::{constant#0}` after built E::V::{constant#0}: isize = { - let mut _0: isize; // return place in scope 0 at $DIR/unusual-item-types.rs:+0:9: +0:10 + let mut _0: isize; // return place in scope 0 at $DIR/unusual_item_types.rs:+0:9: +0:10 bb0: { - _0 = const 5_isize; // scope 0 at $DIR/unusual-item-types.rs:+0:9: +0:10 - return; // scope 0 at $DIR/unusual-item-types.rs:+0:9: +0:10 + _0 = const 5_isize; // scope 0 at $DIR/unusual_item_types.rs:+0:9: +0:10 + return; // scope 0 at $DIR/unusual_item_types.rs:+0:9: +0:10 } } diff --git a/src/test/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir b/src/test/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir index a46e6017377..ee029676311 100644 --- a/src/test/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir +++ b/src/test/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir @@ -1,12 +1,12 @@ // MIR for `Test::X` after built fn Test::X(_1: usize) -> Test { - let mut _0: Test; // return place in scope 0 at $DIR/unusual-item-types.rs:+0:5: +0:6 + let mut _0: Test; // return place in scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:6 bb0: { - Deinit(_0); // scope 0 at $DIR/unusual-item-types.rs:+0:5: +0:6 - ((_0 as X).0: usize) = move _1; // scope 0 at $DIR/unusual-item-types.rs:+0:5: +0:6 - discriminant(_0) = 0; // scope 0 at $DIR/unusual-item-types.rs:+0:5: +0:6 - return; // scope 0 at $DIR/unusual-item-types.rs:+0:5: +0:6 + Deinit(_0); // scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:6 + ((_0 as X).0: usize) = move _1; // scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:6 + discriminant(_0) = 0; // scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:6 + return; // scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:6 } } diff --git a/src/test/mir-opt/unusual-item-types.rs b/src/test/mir-opt/unusual_item_types.rs similarity index 100% rename from src/test/mir-opt/unusual-item-types.rs rename to src/test/mir-opt/unusual_item_types.rs diff --git a/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir b/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir index 7cb9050bc4b..90444b48122 100644 --- a/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir +++ b/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir @@ -1,10 +1,10 @@ -// MIR for `::ASSOCIATED_CONSTANT` after built +// MIR for `::ASSOCIATED_CONSTANT` after built -const ::ASSOCIATED_CONSTANT: i32 = { - let mut _0: i32; // return place in scope 0 at $DIR/unusual-item-types.rs:+0:32: +0:35 +const ::ASSOCIATED_CONSTANT: i32 = { + let mut _0: i32; // return place in scope 0 at $DIR/unusual_item_types.rs:+0:32: +0:35 bb0: { - _0 = const 2_i32; // scope 0 at $DIR/unusual-item-types.rs:+0:38: +0:39 - return; // scope 0 at $DIR/unusual-item-types.rs:+0:5: +0:40 + _0 = const 2_i32; // scope 0 at $DIR/unusual_item_types.rs:+0:38: +0:39 + return; // scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:40 } } diff --git a/src/test/mir-opt/while-storage.rs b/src/test/mir-opt/while_storage.rs similarity index 100% rename from src/test/mir-opt/while-storage.rs rename to src/test/mir-opt/while_storage.rs diff --git a/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir b/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir index a5e7d6afdf3..68aa3e5db32 100644 --- a/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir +++ b/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir @@ -1,56 +1,56 @@ // MIR for `while_loop` after PreCodegen fn while_loop(_1: bool) -> () { - debug c => _1; // in scope 0 at $DIR/while-storage.rs:+0:15: +0:16 - let mut _0: (); // return place in scope 0 at $DIR/while-storage.rs:+0:24: +0:24 - let mut _2: bool; // in scope 0 at $DIR/while-storage.rs:+1:11: +1:22 - let mut _3: bool; // in scope 0 at $DIR/while-storage.rs:+1:20: +1:21 - let mut _4: bool; // in scope 0 at $DIR/while-storage.rs:+2:12: +2:23 - let mut _5: bool; // in scope 0 at $DIR/while-storage.rs:+2:21: +2:22 + debug c => _1; // in scope 0 at $DIR/while_storage.rs:+0:15: +0:16 + let mut _0: (); // return place in scope 0 at $DIR/while_storage.rs:+0:24: +0:24 + let mut _2: bool; // in scope 0 at $DIR/while_storage.rs:+1:11: +1:22 + let mut _3: bool; // in scope 0 at $DIR/while_storage.rs:+1:20: +1:21 + let mut _4: bool; // in scope 0 at $DIR/while_storage.rs:+2:12: +2:23 + let mut _5: bool; // in scope 0 at $DIR/while_storage.rs:+2:21: +2:22 bb0: { - goto -> bb1; // scope 0 at $DIR/while-storage.rs:+1:5: +5:6 + goto -> bb1; // scope 0 at $DIR/while_storage.rs:+1:5: +5:6 } bb1: { - StorageLive(_2); // scope 0 at $DIR/while-storage.rs:+1:11: +1:22 - StorageLive(_3); // scope 0 at $DIR/while-storage.rs:+1:20: +1:21 - _3 = _1; // scope 0 at $DIR/while-storage.rs:+1:20: +1:21 - _2 = get_bool(move _3) -> bb2; // scope 0 at $DIR/while-storage.rs:+1:11: +1:22 + StorageLive(_2); // scope 0 at $DIR/while_storage.rs:+1:11: +1:22 + StorageLive(_3); // scope 0 at $DIR/while_storage.rs:+1:20: +1:21 + _3 = _1; // scope 0 at $DIR/while_storage.rs:+1:20: +1:21 + _2 = get_bool(move _3) -> bb2; // scope 0 at $DIR/while_storage.rs:+1:11: +1:22 // mir::Constant - // + span: $DIR/while-storage.rs:10:11: 10:19 + // + span: $DIR/while_storage.rs:10:11: 10:19 // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value() } } bb2: { - StorageDead(_3); // scope 0 at $DIR/while-storage.rs:+1:21: +1:22 - switchInt(move _2) -> [false: bb7, otherwise: bb3]; // scope 0 at $DIR/while-storage.rs:+1:11: +1:22 + StorageDead(_3); // scope 0 at $DIR/while_storage.rs:+1:21: +1:22 + switchInt(move _2) -> [false: bb7, otherwise: bb3]; // scope 0 at $DIR/while_storage.rs:+1:11: +1:22 } bb3: { - StorageLive(_4); // scope 0 at $DIR/while-storage.rs:+2:12: +2:23 - StorageLive(_5); // scope 0 at $DIR/while-storage.rs:+2:21: +2:22 - _5 = _1; // scope 0 at $DIR/while-storage.rs:+2:21: +2:22 - _4 = get_bool(move _5) -> bb4; // scope 0 at $DIR/while-storage.rs:+2:12: +2:23 + StorageLive(_4); // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 + StorageLive(_5); // scope 0 at $DIR/while_storage.rs:+2:21: +2:22 + _5 = _1; // scope 0 at $DIR/while_storage.rs:+2:21: +2:22 + _4 = get_bool(move _5) -> bb4; // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 // mir::Constant - // + span: $DIR/while-storage.rs:11:12: 11:20 + // + span: $DIR/while_storage.rs:11:12: 11:20 // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value() } } bb4: { - StorageDead(_5); // scope 0 at $DIR/while-storage.rs:+2:22: +2:23 - switchInt(move _4) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/while-storage.rs:+2:12: +2:23 + StorageDead(_5); // scope 0 at $DIR/while_storage.rs:+2:22: +2:23 + switchInt(move _4) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 } bb5: { - StorageDead(_4); // scope 0 at $DIR/while-storage.rs:+4:9: +4:10 + StorageDead(_4); // scope 0 at $DIR/while_storage.rs:+4:9: +4:10 goto -> bb8; // scope 0 at no-location } bb6: { - StorageDead(_4); // scope 0 at $DIR/while-storage.rs:+4:9: +4:10 - StorageDead(_2); // scope 0 at $DIR/while-storage.rs:+5:5: +5:6 - goto -> bb1; // scope 0 at $DIR/while-storage.rs:+1:5: +5:6 + StorageDead(_4); // scope 0 at $DIR/while_storage.rs:+4:9: +4:10 + StorageDead(_2); // scope 0 at $DIR/while_storage.rs:+5:5: +5:6 + goto -> bb1; // scope 0 at $DIR/while_storage.rs:+1:5: +5:6 } bb7: { @@ -58,7 +58,7 @@ fn while_loop(_1: bool) -> () { } bb8: { - StorageDead(_2); // scope 0 at $DIR/while-storage.rs:+5:5: +5:6 - return; // scope 0 at $DIR/while-storage.rs:+6:2: +6:2 + StorageDead(_2); // scope 0 at $DIR/while_storage.rs:+5:5: +5:6 + return; // scope 0 at $DIR/while_storage.rs:+6:2: +6:2 } } diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index ee883777c31..b0b11cafca5 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -31,6 +31,7 @@ fn main() { let args: Vec = env::args().skip(1).collect(); let verbose = args.iter().any(|s| *s == "--verbose"); + let bless = args.iter().any(|s| *s == "--bless"); let bad = std::sync::Arc::new(AtomicBool::new(false)); @@ -64,7 +65,7 @@ fn main() { // Checks over tests. check!(debug_artifacts, &src_path); check!(ui_tests, &src_path); - check!(mir_opt_tests, &src_path); + check!(mir_opt_tests, &src_path, bless); // Checks that only make sense for the compiler. check!(errors, &compiler_path); diff --git a/src/tools/tidy/src/mir_opt_tests.rs b/src/tools/tidy/src/mir_opt_tests.rs index f9e8b55497b..ea24fa45138 100644 --- a/src/tools/tidy/src/mir_opt_tests.rs +++ b/src/tools/tidy/src/mir_opt_tests.rs @@ -1,9 +1,9 @@ -//! Tidy check to ensure that mir opt directories do not have stale files. +//! Tidy check to ensure that mir opt directories do not have stale files or dashes in file names use std::collections::HashSet; use std::path::{Path, PathBuf}; -pub fn check(path: &Path, bad: &mut bool) { +fn check_unused_files(path: &Path, bad: &mut bool) { let mut rs_files = Vec::::new(); let mut output_files = HashSet::::new(); let files = walkdir::WalkDir::new(&path.join("test/mir-opt")).into_iter(); @@ -35,3 +35,36 @@ pub fn check(path: &Path, bad: &mut bool) { } } } + +fn check_dash_files(path: &Path, bless: bool, bad: &mut bool) { + for file in walkdir::WalkDir::new(&path.join("test/mir-opt")) + .into_iter() + .filter_map(Result::ok) + .filter(|e| e.file_type().is_file()) + { + let path = file.path(); + if path.extension() == Some("rs".as_ref()) { + if let Some(name) = path.file_name().and_then(|s| s.to_str()) { + if name.contains('-') { + if !bless { + tidy_error!( + bad, + "mir-opt test files should not have dashes in them: {}", + path.display() + ); + } else { + let new_name = name.replace('-', "_"); + let mut new_path = path.to_owned(); + new_path.set_file_name(new_name); + let _ = std::fs::rename(path, new_path); + } + } + } + } + } +} + +pub fn check(path: &Path, bless: bool, bad: &mut bool) { + check_unused_files(path, bad); + check_dash_files(path, bless, bad); +} From 331aa4509315f670803b7e232486be84d84ea686 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Wed, 2 Nov 2022 23:17:12 +0000 Subject: [PATCH 175/219] Update cargo 14 commits in 7e484fc1a766f56dbc95380f45719698e0c82749..810cbad9a123ad4ee0a55a96171b8f8478ff1c03 2022-10-27 15:20:57 +0000 to 2022-11-02 21:04:31 +0000 - Update curl-sys (rust-lang/cargo#11326) - Mention fix on build script deadlock (rust-lang/cargo#11325) - Make cargo forward pre-existing CARGO if set (rust-lang/cargo#11285) - Clean up workspace dependencies after cargo remove (rust-lang/cargo#11242) - Update the outdated link for rust-semverver (rust-lang/cargo#11322) - Fix broken link to compilation entry point (rust-lang/cargo#11317) - Only remove fingerprints and build script artifacts of the requested package (rust-lang/cargo#10621) - Newer anyhow features are required (rust-lang/cargo#11316) - Clean stale git temp files (rust-lang/cargo#11308) - Report crate size on package and publish (rust-lang/cargo#11270) - add a note that some warnings (and/or errors) can be auto-fixed (rust-lang/cargo#10989) - Update libcurl (rust-lang/cargo#11307) - artifact deps shoud works when target field specified coexists with `optional = true` (rust-lang/cargo#11183) - Fix singular verb in tests page (rust-lang/cargo#11300) --- Cargo.lock | 8 ++++---- src/tools/cargo | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 33b1299976f..c2b460d9a85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1036,9 +1036,9 @@ dependencies = [ [[package]] name = "curl" -version = "0.4.43" +version = "0.4.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d855aeef205b43f65a5001e0997d81f8efca7badad4fad7d897aa7f0d0651f" +checksum = "509bd11746c7ac09ebd19f0b17782eae80aadee26237658a6b4808afb5c11a22" dependencies = [ "curl-sys", "libc", @@ -1051,9 +1051,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.55+curl-7.83.1" +version = "0.4.59+curl-7.86.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23734ec77368ec583c2e61dd3f0b0e5c98b93abe6d2a004ca06b91dd7e3e2762" +checksum = "6cfce34829f448b08f55b7db6d0009e23e2e86a34e8c2b366269bf5799b4a407" dependencies = [ "cc", "libc", diff --git a/src/tools/cargo b/src/tools/cargo index 7e484fc1a76..810cbad9a12 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 7e484fc1a766f56dbc95380f45719698e0c82749 +Subproject commit 810cbad9a123ad4ee0a55a96171b8f8478ff1c03 From 03968a802c50decefd663692906397b44a95d8f6 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 11 Oct 2022 10:00:01 -0700 Subject: [PATCH 176/219] rustdoc: use ThinVec for cleaned generics --- Cargo.lock | 4 +- compiler/rustc_ast/Cargo.toml | 2 +- compiler/rustc_ast_lowering/Cargo.toml | 2 +- compiler/rustc_builtin_macros/Cargo.toml | 2 +- compiler/rustc_data_structures/Cargo.toml | 2 +- compiler/rustc_middle/Cargo.toml | 2 +- compiler/rustc_query_impl/Cargo.toml | 2 +- compiler/rustc_query_system/Cargo.toml | 2 +- compiler/rustc_serialize/Cargo.toml | 2 +- src/librustdoc/Cargo.toml | 2 +- src/librustdoc/clean/auto_trait.rs | 11 +-- src/librustdoc/clean/mod.rs | 96 +++++++++++------------ src/librustdoc/clean/simplify.rs | 5 +- src/librustdoc/clean/types.rs | 4 +- 14 files changed, 67 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 33b1299976f..1a91898be4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4887,9 +4887,9 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thin-vec" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "104c2cb3180b6fb6d5b2278768e9b88b578d32ba751ea6e8d026688a40d7ed87" +checksum = "ceb05e71730d396f960f8f3901cdb41be2d339b303e9d7d3a07c5ff0536e671b" [[package]] name = "thiserror" diff --git a/compiler/rustc_ast/Cargo.toml b/compiler/rustc_ast/Cargo.toml index fcbf9681825..9253b7e6891 100644 --- a/compiler/rustc_ast/Cargo.toml +++ b/compiler/rustc_ast/Cargo.toml @@ -14,5 +14,5 @@ rustc_macros = { path = "../rustc_macros" } rustc_serialize = { path = "../rustc_serialize" } rustc_span = { path = "../rustc_span" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.8" +thin-vec = "0.2.9" tracing = "0.1" diff --git a/compiler/rustc_ast_lowering/Cargo.toml b/compiler/rustc_ast_lowering/Cargo.toml index ce1c8d4997d..6a59b9e6151 100644 --- a/compiler/rustc_ast_lowering/Cargo.toml +++ b/compiler/rustc_ast_lowering/Cargo.toml @@ -21,5 +21,5 @@ rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.8" +thin-vec = "0.2.9" tracing = "0.1" diff --git a/compiler/rustc_builtin_macros/Cargo.toml b/compiler/rustc_builtin_macros/Cargo.toml index 6469d0d7b88..467fa932a15 100644 --- a/compiler/rustc_builtin_macros/Cargo.toml +++ b/compiler/rustc_builtin_macros/Cargo.toml @@ -23,5 +23,5 @@ rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.8" +thin-vec = "0.2.9" tracing = "0.1" diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml index 9daa21ef6b1..5152d5ab046 100644 --- a/compiler/rustc_data_structures/Cargo.toml +++ b/compiler/rustc_data_structures/Cargo.toml @@ -25,7 +25,7 @@ smallvec = { version = "1.8.1", features = ["const_generics", "union", "may_dang stable_deref_trait = "1.0.0" stacker = "0.1.14" tempfile = "3.2" -thin-vec = "0.2.8" +thin-vec = "0.2.9" tracing = "0.1" [dependencies.parking_lot] diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index de916ea8c49..8e7d0cf2ab1 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -32,7 +32,7 @@ rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } rustc_type_ir = { path = "../rustc_type_ir" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.8" +thin-vec = "0.2.9" tracing = "0.1" [features] diff --git a/compiler/rustc_query_impl/Cargo.toml b/compiler/rustc_query_impl/Cargo.toml index e7f12caaf33..b2111a1262a 100644 --- a/compiler/rustc_query_impl/Cargo.toml +++ b/compiler/rustc_query_impl/Cargo.toml @@ -21,7 +21,7 @@ rustc_serialize = { path = "../rustc_serialize" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } -thin-vec = "0.2.8" +thin-vec = "0.2.9" tracing = "0.1" [features] diff --git a/compiler/rustc_query_system/Cargo.toml b/compiler/rustc_query_system/Cargo.toml index faddad74171..028756b5a0a 100644 --- a/compiler/rustc_query_system/Cargo.toml +++ b/compiler/rustc_query_system/Cargo.toml @@ -22,7 +22,7 @@ rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } rustc_type_ir = { path = "../rustc_type_ir" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.8" +thin-vec = "0.2.9" tracing = "0.1" [features] diff --git a/compiler/rustc_serialize/Cargo.toml b/compiler/rustc_serialize/Cargo.toml index 3b0b3144f2c..db0ef73544f 100644 --- a/compiler/rustc_serialize/Cargo.toml +++ b/compiler/rustc_serialize/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] indexmap = "1.9.1" smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } -thin-vec = "0.2.8" +thin-vec = "0.2.9" [dev-dependencies] rustc_macros = { path = "../rustc_macros" } diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 7bc35c7d551..0da69202e67 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -20,7 +20,7 @@ serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } smallvec = "1.8.1" tempfile = "3" -thin-vec = "0.2.8" +thin-vec = "0.2.9" tracing = "0.1" tracing-tree = "0.2.0" diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 00bdbe41ee4..84e77e69ecf 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -3,6 +3,7 @@ use rustc_hir as hir; use rustc_hir::lang_items::LangItem; use rustc_middle::ty::{self, Region, RegionVid, TypeFoldable, TypeSuperFoldable}; use rustc_trait_selection::traits::auto_trait::{self, AutoTraitResult}; +use thin_vec::ThinVec; use std::fmt::Debug; @@ -110,7 +111,7 @@ where ); let params = raw_generics.params; - Generics { params, where_predicates: Vec::new() } + Generics { params, where_predicates: ThinVec::new() } } AutoTraitResult::ExplicitImpl => return None, }; @@ -183,7 +184,7 @@ where fn handle_lifetimes<'cx>( regions: &RegionConstraintData<'cx>, names_map: &FxHashMap, - ) -> Vec { + ) -> ThinVec { // Our goal is to 'flatten' the list of constraints by eliminating // all intermediate RegionVids. At the end, all constraints should // be between Regions (aka region variables). This gives us the information @@ -429,7 +430,7 @@ where &mut self, item_def_id: DefId, param_env: ty::ParamEnv<'tcx>, - mut existing_predicates: Vec, + mut existing_predicates: ThinVec, vid_to_region: FxHashMap>, ) -> Generics { debug!( @@ -663,7 +664,7 @@ where /// both for visual consistency between 'rustdoc' runs, and to /// make writing tests much easier #[inline] - fn sort_where_predicates(&self, predicates: &mut Vec) { + fn sort_where_predicates(&self, predicates: &mut [WherePredicate]) { // We should never have identical bounds - and if we do, // they're visually identical as well. Therefore, using // an unstable sort is fine. @@ -710,7 +711,7 @@ where /// approach is probably somewhat slower, but the small number of items /// involved (impls rarely have more than a few bounds) means that it /// shouldn't matter in practice. - fn unstable_debug_sort(&self, vec: &mut Vec) { + fn unstable_debug_sort(&self, vec: &mut [T]) { vec.sort_by_cached_key(|x| format!("{:?}", x)) } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 1ce0d1e4ffd..32aa49d4a59 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -601,7 +601,7 @@ pub(crate) fn clean_generics<'tcx>( }) .collect::>(); - let mut params = Vec::with_capacity(gens.params.len()); + let mut params = ThinVec::with_capacity(gens.params.len()); for p in gens.params.iter().filter(|p| !is_impl_trait(p) && !is_elided_lifetime(p)) { let p = clean_generic_param(cx, Some(gens), p); params.push(p); @@ -675,7 +675,7 @@ fn clean_ty_generics<'tcx>( } ty::GenericParamDefKind::Const { .. } => Some(clean_generic_param_def(param, cx)), }) - .collect::>(); + .collect::>(); // param index -> [(trait DefId, associated type name & generics, type, higher-ranked params)] let mut impl_trait_proj = @@ -1211,56 +1211,47 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( tcx.generics_of(assoc_item.def_id), ty::GenericPredicates { parent: None, predicates }, ); - // Move bounds that are (likely) directly attached to the associated type - // from the where clause to the associated type. - // There is no guarantee that this is what the user actually wrote but we have - // no way of knowing. - let mut bounds = generics - .where_predicates - .drain_filter(|pred| match *pred { - WherePredicate::BoundPredicate { - ty: QPath(box QPathData { ref assoc, ref self_type, ref trait_, .. }), - .. - } => { - if assoc.name != my_name { - return false; - } - if trait_.def_id() != assoc_item.container_id(tcx) { - return false; - } - match *self_type { - Generic(ref s) if *s == kw::SelfUpper => {} - _ => return false, - } - match &assoc.args { - GenericArgs::AngleBracketed { args, bindings } => { - if !bindings.is_empty() - || generics - .params - .iter() - .zip(args.iter()) - .any(|(param, arg)| !param_eq_arg(param, arg)) - { - return false; - } - } - GenericArgs::Parenthesized { .. } => { - // The only time this happens is if we're inside the rustdoc for Fn(), - // which only has one associated type, which is not a GAT, so whatever. + // Filter out the bounds that are (likely?) directly attached to the associated type, + // as opposed to being located in the where clause. + let mut bounds: Vec = Vec::new(); + generics.where_predicates.retain_mut(|pred| match *pred { + WherePredicate::BoundPredicate { + ty: QPath(box QPathData { ref assoc, ref self_type, ref trait_, .. }), + bounds: ref mut pred_bounds, + .. + } => { + if assoc.name != my_name { + return true; + } + if trait_.def_id() != assoc_item.container_id(tcx) { + return true; + } + match *self_type { + Generic(ref s) if *s == kw::SelfUpper => {} + _ => return true, + } + match &assoc.args { + GenericArgs::AngleBracketed { args, bindings } => { + if !bindings.is_empty() + || generics + .params + .iter() + .zip(args.iter()) + .any(|(param, arg)| !param_eq_arg(param, arg)) + { + return true; } } - true + GenericArgs::Parenthesized { .. } => { + // The only time this happens is if we're inside the rustdoc for Fn(), + // which only has one associated type, which is not a GAT, so whatever. + } } - _ => false, - }) - .flat_map(|pred| { - if let WherePredicate::BoundPredicate { bounds, .. } = pred { - bounds - } else { - unreachable!() - } - }) - .collect::>(); + bounds.extend(mem::replace(pred_bounds, Vec::new())); + false + } + _ => true, + }); // Our Sized/?Sized bound didn't get handled when creating the generics // because we didn't actually get our whole set of bounds until just now // (some of them may have come from the trait). If we do have a sized @@ -1276,7 +1267,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( // (generic) associated type from the where clause to the respective parameter. // There is no guarantee that this is what the user actually wrote but we have // no way of knowing. - let mut where_predicates = Vec::new(); + let mut where_predicates = ThinVec::new(); for mut pred in generics.where_predicates { if let WherePredicate::BoundPredicate { ty: Generic(arg), bounds, .. } = &mut pred && let Some(GenericParamDef { @@ -1317,7 +1308,10 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( cx, Some(assoc_item.def_id), ), - generics: Generics { params: Vec::new(), where_predicates: Vec::new() }, + generics: Generics { + params: ThinVec::new(), + where_predicates: ThinVec::new(), + }, item_type: None, }), Vec::new(), diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index 1bcb9fcd5a4..1c184f9b269 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -14,13 +14,14 @@ use rustc_data_structures::fx::FxIndexMap; use rustc_hir::def_id::DefId; use rustc_middle::ty; +use thin_vec::ThinVec; use crate::clean; use crate::clean::GenericArgs as PP; use crate::clean::WherePredicate as WP; use crate::core::DocContext; -pub(crate) fn where_clauses(cx: &DocContext<'_>, clauses: Vec) -> Vec { +pub(crate) fn where_clauses(cx: &DocContext<'_>, clauses: Vec) -> ThinVec { // First, partition the where clause into its separate components. // // We use `FxIndexMap` so that the insertion order is preserved to prevent messing up to @@ -59,7 +60,7 @@ pub(crate) fn where_clauses(cx: &DocContext<'_>, clauses: Vec) -> Vec { }); // And finally, let's reassemble everything - let mut clauses = Vec::new(); + let mut clauses = ThinVec::with_capacity(lifetimes.len() + tybounds.len() + equalities.len()); clauses.extend( lifetimes.into_iter().map(|(lt, bounds)| WP::RegionPredicate { lifetime: lt, bounds }), ); diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 439311f0640..e4a8b5c9d18 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1462,8 +1462,8 @@ impl GenericParamDef { // maybe use a Generic enum and use Vec? #[derive(Clone, Debug, Default)] pub(crate) struct Generics { - pub(crate) params: Vec, - pub(crate) where_predicates: Vec, + pub(crate) params: ThinVec, + pub(crate) where_predicates: ThinVec, } impl Generics { From 24714b84ea3f45439a980362dd6865a6b5b4405f Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 12 Oct 2022 10:51:10 -0700 Subject: [PATCH 177/219] rustdoc: remove unneeded Box from ItemKind --- src/librustdoc/clean/mod.rs | 4 ++-- src/librustdoc/clean/types.rs | 2 +- src/librustdoc/json/conversions.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 32aa49d4a59..c3d80315a4f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1080,7 +1080,7 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext hir::TraitItemKind::Type(bounds, None) => { let generics = enter_impl_trait(cx, |cx| clean_generics(trait_item.generics, cx)); let bounds = bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect(); - TyAssocTypeItem(Box::new(generics), bounds) + TyAssocTypeItem(generics, bounds) } }; Item::from_def_id_and_parts(local_did, Some(trait_item.ident.name), inner, cx) @@ -1297,7 +1297,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( bounds, ) } else { - TyAssocTypeItem(Box::new(generics), bounds) + TyAssocTypeItem(generics, bounds) } } else { // FIXME: when could this happen? Associated items in inherent impls? diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index e4a8b5c9d18..8b71274bbab 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -795,7 +795,7 @@ pub(crate) enum ItemKind { /// A required associated type in a trait declaration. /// /// The bounds may be non-empty if there is a `where` clause. - TyAssocTypeItem(Box, Vec), + TyAssocTypeItem(Generics, Vec), /// An associated type in a trait impl or a provided one in a trait declaration. AssocTypeItem(Box, Vec), /// An item that has been stripped by a rustdoc pass diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 4962eb8f8e1..4889ac25acb 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -284,7 +284,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum { ItemEnum::AssocConst { type_: ty.into_tcx(tcx), default: Some(default.expr(tcx)) } } TyAssocTypeItem(g, b) => ItemEnum::AssocType { - generics: (*g).into_tcx(tcx), + generics: g.into_tcx(tcx), bounds: b.into_tcx(tcx), default: None, }, From eb296964b35a90d77b58bb5e625f3aebd01b7926 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 12 Oct 2022 14:29:32 -0700 Subject: [PATCH 178/219] rustdoc: add size tracking for `Generics` --- src/librustdoc/clean/types.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 8b71274bbab..b667411187a 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -2594,6 +2594,7 @@ mod size_asserts { static_assert_size!(GenericArg, 48); static_assert_size!(GenericArgs, 32); static_assert_size!(GenericParamDef, 56); + static_assert_size!(Generics, 16); static_assert_size!(Item, 56); static_assert_size!(ItemKind, 88); static_assert_size!(PathSegment, 40); From a21a055ca6f0d0244cfe79ffba908987e475c946 Mon Sep 17 00:00:00 2001 From: yukang Date: Thu, 3 Nov 2022 09:22:08 +0800 Subject: [PATCH 179/219] remove 'delay_span_bug' following 'references_error' --- compiler/rustc_const_eval/src/transform/promote_consts.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_const_eval/src/transform/promote_consts.rs b/compiler/rustc_const_eval/src/transform/promote_consts.rs index f3ae16da43b..f48bcd90809 100644 --- a/compiler/rustc_const_eval/src/transform/promote_consts.rs +++ b/compiler/rustc_const_eval/src/transform/promote_consts.rs @@ -45,11 +45,10 @@ impl<'tcx> MirPass<'tcx> for PromoteTemps<'tcx> { // There's not really any point in promoting errorful MIR. // // This does not include MIR that failed const-checking, which we still try to promote. - if body.return_ty().references_error() { - tcx.sess.delay_span_bug(body.span, "PromoteTemps: MIR had errors"); + if let Err(_) = body.return_ty().error_reported() { + debug!("PromoteTemps: MIR had errors"); return; } - if body.source.promoted.is_some() { return; } From c6d23bdd328decdb0a0e98980af4c3b7aa13d9d6 Mon Sep 17 00:00:00 2001 From: yukang Date: Thu, 3 Nov 2022 09:42:34 +0800 Subject: [PATCH 180/219] code cleanup --- compiler/rustc_hir_typeck/src/cast.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index cf7587ffa0e..4ff89511938 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -216,8 +216,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { // inference is more completely known. match cast_ty.kind() { ty::Dynamic(_, _, ty::Dyn) | ty::Slice(..) => { - let reported = check.report_cast_to_unsized_type(fcx); - return Err(reported); + Err(check.report_cast_to_unsized_type(fcx)) } _ => Ok(check), } From 1adf83b128de3043ff0c24863e398c59e4ebb743 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Thu, 3 Nov 2022 11:47:05 +0100 Subject: [PATCH 181/219] check for pattern in compiletest-compile-flags-last --- src/test/ui/compiletest-compile-flags-last.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/ui/compiletest-compile-flags-last.rs b/src/test/ui/compiletest-compile-flags-last.rs index 9c78e4c5e9d..232df10f1a8 100644 --- a/src/test/ui/compiletest-compile-flags-last.rs +++ b/src/test/ui/compiletest-compile-flags-last.rs @@ -4,3 +4,4 @@ // next flag as the argument of this flag. // // compile-flags: --cap-lints +// error-pattern: Argument to option 'cap-lints' missing From 5ed753cb0db4defb4bb94178daf53f9bba707a8c Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Thu, 3 Nov 2022 11:48:33 +0100 Subject: [PATCH 182/219] move compiletest's own ui tests into a subdirectory --- .../compile-flags-last.rs} | 0 .../compile-flags-last.stderr} | 0 src/test/ui/{ => compiletest-self-test}/ui-testing-optout.rs | 0 .../ui/{ => compiletest-self-test}/ui-testing-optout.stderr | 0 src/tools/tidy/src/ui_tests.rs | 2 +- 5 files changed, 1 insertion(+), 1 deletion(-) rename src/test/ui/{compiletest-compile-flags-last.rs => compiletest-self-test/compile-flags-last.rs} (100%) rename src/test/ui/{compiletest-compile-flags-last.stderr => compiletest-self-test/compile-flags-last.stderr} (100%) rename src/test/ui/{ => compiletest-self-test}/ui-testing-optout.rs (100%) rename src/test/ui/{ => compiletest-self-test}/ui-testing-optout.stderr (100%) diff --git a/src/test/ui/compiletest-compile-flags-last.rs b/src/test/ui/compiletest-self-test/compile-flags-last.rs similarity index 100% rename from src/test/ui/compiletest-compile-flags-last.rs rename to src/test/ui/compiletest-self-test/compile-flags-last.rs diff --git a/src/test/ui/compiletest-compile-flags-last.stderr b/src/test/ui/compiletest-self-test/compile-flags-last.stderr similarity index 100% rename from src/test/ui/compiletest-compile-flags-last.stderr rename to src/test/ui/compiletest-self-test/compile-flags-last.stderr diff --git a/src/test/ui/ui-testing-optout.rs b/src/test/ui/compiletest-self-test/ui-testing-optout.rs similarity index 100% rename from src/test/ui/ui-testing-optout.rs rename to src/test/ui/compiletest-self-test/ui-testing-optout.rs diff --git a/src/test/ui/ui-testing-optout.stderr b/src/test/ui/compiletest-self-test/ui-testing-optout.stderr similarity index 100% rename from src/test/ui/ui-testing-optout.stderr rename to src/test/ui/compiletest-self-test/ui-testing-optout.stderr diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index d307d6f43b1..c600f99c2c4 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -7,7 +7,7 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. -const ROOT_ENTRY_LIMIT: usize = 949; +const ROOT_ENTRY_LIMIT: usize = 948; const ISSUES_ENTRY_LIMIT: usize = 2117; fn check_entries(path: &Path, bad: &mut bool) { From 4c55b29349e9367daad49317cef642c41d5608ac Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Thu, 3 Nov 2022 12:00:17 +0100 Subject: [PATCH 183/219] put custom flags as last in codegen and asm tests --- src/tools/compiletest/src/runtest.rs | 74 +++++++++++++++------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index ab0d568ffa7..4a59dca49fe 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -220,11 +220,13 @@ enum WillExecute { Disabled, } -/// Should `--emit metadata` be used? +/// What value should be passed to `--emit`? #[derive(Copy, Clone)] -enum EmitMetadata { - Yes, - No, +enum Emit { + None, + Metadata, + LlvmIr, + Asm, } impl<'test> TestCx<'test> { @@ -424,7 +426,7 @@ impl<'test> TestCx<'test> { } let should_run = self.run_if_enabled(); - let mut proc_res = self.compile_test(should_run, EmitMetadata::No); + let mut proc_res = self.compile_test(should_run, Emit::None); if !proc_res.status.success() { self.fatal_proc_rec("compilation failed!", &proc_res); @@ -676,7 +678,7 @@ impl<'test> TestCx<'test> { // compile test file (it should have 'compile-flags:-g' in the header) let should_run = self.run_if_enabled(); - let compile_result = self.compile_test(should_run, EmitMetadata::No); + let compile_result = self.compile_test(should_run, Emit::None); if !compile_result.status.success() { self.fatal_proc_rec("compilation failed!", &compile_result); } @@ -796,7 +798,7 @@ impl<'test> TestCx<'test> { // compile test file (it should have 'compile-flags:-g' in the header) let should_run = self.run_if_enabled(); - let compiler_run_result = self.compile_test(should_run, EmitMetadata::No); + let compiler_run_result = self.compile_test(should_run, Emit::None); if !compiler_run_result.status.success() { self.fatal_proc_rec("compilation failed!", &compiler_run_result); } @@ -1028,7 +1030,7 @@ impl<'test> TestCx<'test> { fn run_debuginfo_lldb_test_no_opt(&self) { // compile test file (it should have 'compile-flags:-g' in the header) let should_run = self.run_if_enabled(); - let compile_result = self.compile_test(should_run, EmitMetadata::No); + let compile_result = self.compile_test(should_run, Emit::None); if !compile_result.status.success() { self.fatal_proc_rec("compilation failed!", &compile_result); } @@ -1453,21 +1455,21 @@ impl<'test> TestCx<'test> { } } - fn should_emit_metadata(&self, pm: Option) -> EmitMetadata { + fn should_emit_metadata(&self, pm: Option) -> Emit { match (pm, self.props.fail_mode, self.config.mode) { - (Some(PassMode::Check), ..) | (_, Some(FailMode::Check), Ui) => EmitMetadata::Yes, - _ => EmitMetadata::No, + (Some(PassMode::Check), ..) | (_, Some(FailMode::Check), Ui) => Emit::Metadata, + _ => Emit::None, } } - fn compile_test(&self, will_execute: WillExecute, emit_metadata: EmitMetadata) -> ProcRes { - self.compile_test_general(will_execute, emit_metadata, self.props.local_pass_mode()) + fn compile_test(&self, will_execute: WillExecute, emit: Emit) -> ProcRes { + self.compile_test_general(will_execute, emit, self.props.local_pass_mode()) } fn compile_test_general( &self, will_execute: WillExecute, - emit_metadata: EmitMetadata, + emit: Emit, local_pm: Option, ) -> ProcRes { // Only use `make_exe_name` when the test ends up being executed. @@ -1502,7 +1504,7 @@ impl<'test> TestCx<'test> { let rustc = self.make_compile_args( &self.testpaths.file, output_file, - emit_metadata, + emit, allow_unused, LinkToAux::Yes, ); @@ -1735,7 +1737,7 @@ impl<'test> TestCx<'test> { let mut aux_rustc = aux_cx.make_compile_args( input_file, aux_output, - EmitMetadata::No, + Emit::None, AllowUnused::No, LinkToAux::No, ); @@ -1875,7 +1877,7 @@ impl<'test> TestCx<'test> { &self, input_file: &Path, output_file: TargetLocation, - emit_metadata: EmitMetadata, + emit: Emit, allow_unused: AllowUnused, link_to_aux: LinkToAux, ) -> Command { @@ -1992,8 +1994,18 @@ impl<'test> TestCx<'test> { } } - if let (false, EmitMetadata::Yes) = (is_rustdoc, emit_metadata) { - rustc.args(&["--emit", "metadata"]); + match emit { + Emit::None => {} + Emit::Metadata if is_rustdoc => {} + Emit::Metadata => { + rustc.args(&["--emit", "metadata"]); + } + Emit::LlvmIr => { + rustc.args(&["--emit", "llvm-ir"]); + } + Emit::Asm => { + rustc.args(&["--emit", "asm"]); + } } if !is_rustdoc { @@ -2262,14 +2274,13 @@ impl<'test> TestCx<'test> { fn compile_test_and_save_ir(&self) -> ProcRes { let output_file = TargetLocation::ThisDirectory(self.output_base_dir()); let input_file = &self.testpaths.file; - let mut rustc = self.make_compile_args( + let rustc = self.make_compile_args( input_file, output_file, - EmitMetadata::No, + Emit::LlvmIr, AllowUnused::No, LinkToAux::Yes, ); - rustc.arg("--emit=llvm-ir"); self.compose_and_run_compiler(rustc, None) } @@ -2281,17 +2292,11 @@ impl<'test> TestCx<'test> { let output_file = TargetLocation::ThisFile(output_path.clone()); let input_file = &self.testpaths.file; - let mut rustc = self.make_compile_args( - input_file, - output_file, - EmitMetadata::No, - AllowUnused::No, - LinkToAux::Yes, - ); + let mut emit = Emit::None; match self.props.assembly_output.as_ref().map(AsRef::as_ref) { Some("emit-asm") => { - rustc.arg("--emit=asm"); + emit = Emit::Asm; } Some("ptx-linker") => { @@ -2302,6 +2307,9 @@ impl<'test> TestCx<'test> { None => self.fatal("missing 'assembly-output' header"), } + let rustc = + self.make_compile_args(input_file, output_file, emit, AllowUnused::No, LinkToAux::Yes); + (self.compose_and_run_compiler(rustc, None), output_path) } @@ -2426,7 +2434,7 @@ impl<'test> TestCx<'test> { let mut rustc = new_rustdoc.make_compile_args( &new_rustdoc.testpaths.file, output_file, - EmitMetadata::No, + Emit::None, AllowUnused::Yes, LinkToAux::Yes, ); @@ -2702,7 +2710,7 @@ impl<'test> TestCx<'test> { fn run_codegen_units_test(&self) { assert!(self.revision.is_none(), "revisions not relevant here"); - let proc_res = self.compile_test(WillExecute::No, EmitMetadata::No); + let proc_res = self.compile_test(WillExecute::No, Emit::None); if !proc_res.status.success() { self.fatal_proc_rec("compilation failed!", &proc_res); @@ -3215,7 +3223,7 @@ impl<'test> TestCx<'test> { if let Some(FailMode::Build) = self.props.fail_mode { // Make sure a build-fail test cannot fail due to failing analysis (e.g. typeck). let pm = Some(PassMode::Check); - let proc_res = self.compile_test_general(WillExecute::No, EmitMetadata::Yes, pm); + let proc_res = self.compile_test_general(WillExecute::No, Emit::Metadata, pm); self.check_if_test_should_compile(&proc_res, pm); } From 87b2110f25bed1407a9aded9e263b64dc3315d45 Mon Sep 17 00:00:00 2001 From: Florian Bartels Date: Thu, 3 Nov 2022 09:19:47 +0100 Subject: [PATCH 184/219] Add howto for adding new targets --- src/doc/rustc/src/target-tier-policy.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/doc/rustc/src/target-tier-policy.md b/src/doc/rustc/src/target-tier-policy.md index 53d0470fa81..df9131ce84a 100644 --- a/src/doc/rustc/src/target-tier-policy.md +++ b/src/doc/rustc/src/target-tier-policy.md @@ -3,6 +3,7 @@ ## Table of Contents * [General](#general) +* [Adding a new target](#adding-a-new-target) * [Tier 3 target policy](#tier-3-target-policy) * [Tier 2 target policy](#tier-2-target-policy) * [Tier 2 with host tools](#tier-2-with-host-tools) @@ -104,6 +105,30 @@ indicates something entirely optional, and does not indicate guidance or recommendations. This language is based on [IETF RFC 2119](https://tools.ietf.org/html/rfc2119). +## Adding a new target + +New targets typically start as Tier 3 and then can be promoted later. +To propose addition of a new target, open a pull request on [`rust-lang/rust`]: + +- Copy the [Tier 3 target policy](#tier-3-target-policy) to the description + and fill it out, see [example][tier3example]. +- Add a new description for the target in `src/doc/rustc/src/platform-support` + using the [template][platform_template]. +- Add the target to the [SUMMARY.md][summary] (allows wildcards) and + [platform-support.md][platformsupport] (must name all targets verbatim). + Link to the created description page. +- Ensure the pull request is assigned to a member of the [Rust compiler team][rust_compiler_team] by commenting: + ```text + r? compiler-team + ``` + +[tier3example]: https://github.com/rust-lang/rust/pull/94872 +[platform_template]: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/TEMPLATE.md +[summary]: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/SUMMARY.md +[platformsupport]: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support.md +[rust_compiler_team]: https://www.rust-lang.org/governance/teams/compiler +[`rust-lang/rust`]: https://github.com/rust-lang/rust + ## Tier 3 target policy At this tier, the Rust project provides no official support for a target, so we From 29490098c2dbb9c90c5059ce7a9448dca345b0fb Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 2 Nov 2022 08:21:21 -0400 Subject: [PATCH 185/219] Fix artifact version/channel detection for stable On stable, our artifacts are uploaded with the raw version number (e.g., 1.65.0), not the channel. This adjusts our detection logic to use the version number from src/version when we detect the stable channel. --- src/bootstrap/config.rs | 55 ++++++++++++++++++++++++++++++----------- src/bootstrap/native.rs | 4 +-- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 34d5504827c..21dc11c4808 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -1380,21 +1380,46 @@ impl Config { git } - pub(crate) fn artifact_channel(&self, builder: &Builder<'_>, commit: &str) -> String { - if builder.rust_info.is_managed_git_subrepository() { + /// Bootstrap embeds a version number into the name of shared libraries it uploads in CI. + /// Return the version it would have used for the given commit. + pub(crate) fn artifact_version_part(&self, builder: &Builder<'_>, commit: &str) -> String { + let (channel, version) = if builder.rust_info.is_managed_git_subrepository() { let mut channel = self.git(); channel.arg("show").arg(format!("{}:src/ci/channel", commit)); let channel = output(&mut channel); - channel.trim().to_owned() - } else if let Ok(channel) = fs::read_to_string(builder.src.join("src/ci/channel")) { - channel.trim().to_owned() + let mut version = self.git(); + version.arg("show").arg(format!("{}:src/version", commit)); + let version = output(&mut version); + (channel.trim().to_owned(), version.trim().to_owned()) } else { - let src = builder.src.display(); - eprintln!("error: failed to determine artifact channel"); - eprintln!( - "help: either use git or ensure that {src}/src/ci/channel contains the name of the channel to use" - ); - panic!(); + let channel = fs::read_to_string(builder.src.join("src/ci/channel")); + let version = fs::read_to_string(builder.src.join("src/version")); + match (channel, version) { + (Ok(channel), Ok(version)) => { + (channel.trim().to_owned(), version.trim().to_owned()) + } + (channel, version) => { + let src = builder.src.display(); + eprintln!("error: failed to determine artifact channel and/or version"); + eprintln!( + "help: consider using a git checkout or ensure these files are readable" + ); + if let Err(channel) = channel { + eprintln!("reading {}/src/ci/channel failed: {:?}", src, channel); + } + if let Err(version) = version { + eprintln!("reading {}/src/version failed: {:?}", src, version); + } + panic!(); + } + } + }; + + match channel.as_str() { + "stable" => version, + "beta" => channel, + "nightly" => channel, + other => unreachable!("{:?} is not recognized as a valid channel", other), } } @@ -1637,7 +1662,7 @@ fn maybe_download_rustfmt(builder: &Builder<'_>) -> Option { fn download_ci_rustc(builder: &Builder<'_>, commit: &str) { builder.verbose(&format!("using downloaded stage2 artifacts from CI (commit {commit})")); - let channel = builder.config.artifact_channel(builder, commit); + let version = builder.config.artifact_version_part(builder, commit); let host = builder.config.build.triple; let bin_root = builder.out.join(host).join("ci-rustc"); let rustc_stamp = bin_root.join(".rustc-stamp"); @@ -1646,13 +1671,13 @@ fn download_ci_rustc(builder: &Builder<'_>, commit: &str) { if bin_root.exists() { t!(fs::remove_dir_all(&bin_root)); } - let filename = format!("rust-std-{channel}-{host}.tar.xz"); + let filename = format!("rust-std-{version}-{host}.tar.xz"); let pattern = format!("rust-std-{host}"); download_ci_component(builder, filename, &pattern, commit); - let filename = format!("rustc-{channel}-{host}.tar.xz"); + let filename = format!("rustc-{version}-{host}.tar.xz"); download_ci_component(builder, filename, "rustc", commit); // download-rustc doesn't need its own cargo, it can just use beta's. - let filename = format!("rustc-dev-{channel}-{host}.tar.xz"); + let filename = format!("rustc-dev-{version}-{host}.tar.xz"); download_ci_component(builder, filename, "rustc-dev", commit); builder.fix_bin_or_dylib(&bin_root.join("bin").join("rustc")); diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 2f856c2761c..94a61b727a3 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -269,8 +269,8 @@ fn download_ci_llvm(builder: &Builder<'_>, llvm_sha: &str) { } else { &builder.config.stage0_metadata.config.artifacts_server }; - let channel = builder.config.artifact_channel(builder, llvm_sha); - let filename = format!("rust-dev-{}-{}.tar.xz", channel, builder.build.build.triple); + let version = builder.config.artifact_version_part(builder, llvm_sha); + let filename = format!("rust-dev-{}-{}.tar.xz", version, builder.build.build.triple); let tarball = rustc_cache.join(&filename); if !tarball.exists() { let help_on_error = "error: failed to download llvm from ci From 634b9f8867608a591f3951e91838a1578904165f Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 3 Nov 2022 08:37:45 -0400 Subject: [PATCH 186/219] Revert "Update cargo" This reverts commit 331aa4509315f670803b7e232486be84d84ea686. This Cargo upgrade introduced a regression into dependency resolution, so reverting the upgrade until we can fix that. --- Cargo.lock | 8 ++++---- src/tools/cargo | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c2b460d9a85..33b1299976f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1036,9 +1036,9 @@ dependencies = [ [[package]] name = "curl" -version = "0.4.44" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "509bd11746c7ac09ebd19f0b17782eae80aadee26237658a6b4808afb5c11a22" +checksum = "37d855aeef205b43f65a5001e0997d81f8efca7badad4fad7d897aa7f0d0651f" dependencies = [ "curl-sys", "libc", @@ -1051,9 +1051,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.59+curl-7.86.0" +version = "0.4.55+curl-7.83.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cfce34829f448b08f55b7db6d0009e23e2e86a34e8c2b366269bf5799b4a407" +checksum = "23734ec77368ec583c2e61dd3f0b0e5c98b93abe6d2a004ca06b91dd7e3e2762" dependencies = [ "cc", "libc", diff --git a/src/tools/cargo b/src/tools/cargo index 810cbad9a12..7e484fc1a76 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 810cbad9a123ad4ee0a55a96171b8f8478ff1c03 +Subproject commit 7e484fc1a766f56dbc95380f45719698e0c82749 From ba18f16e81e568a6dfbd437edf4c949a9538c984 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 26 Oct 2022 14:40:34 -0300 Subject: [PATCH 187/219] Add visit_fn_ret_ty to hir intravisit --- compiler/rustc_hir/src/intravisit.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index d852893ad5d..3ef58d7d705 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -358,6 +358,9 @@ pub trait Visitor<'v>: Sized { fn visit_where_predicate(&mut self, predicate: &'v WherePredicate<'v>) { walk_where_predicate(self, predicate) } + fn visit_fn_ret_ty(&mut self, ret_ty: &'v FnRetTy<'v>) { + walk_fn_ret_ty(self, ret_ty) + } fn visit_fn_decl(&mut self, fd: &'v FnDecl<'v>) { walk_fn_decl(self, fd) } @@ -903,7 +906,7 @@ pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: & for ty in function_declaration.inputs { visitor.visit_ty(ty) } - walk_fn_ret_ty(visitor, &function_declaration.output) + visitor.visit_fn_ret_ty(&function_declaration.output) } pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FnRetTy<'v>) { From 30b6fe37a6d447a647f2608562aff7b1758bce54 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Thu, 27 Oct 2022 07:11:15 +0000 Subject: [PATCH 188/219] Correctly resolve Inherent Associated Types --- .../rustc_hir_analysis/src/astconv/mod.rs | 14 ++++++++ src/test/ui/assoc-inherent.rs | 20 ------------ src/test/ui/assoc-inherent.stderr | 17 ---------- .../assoc-inherent-no-body.rs | 10 ++++++ .../assoc-inherent-no-body.stderr | 10 ++++++ .../assoc-inherent-use.rs | 14 ++++++++ .../ui/resolve/resolve-self-in-impl.stderr | 32 +++++++++---------- 7 files changed, 64 insertions(+), 53 deletions(-) delete mode 100644 src/test/ui/assoc-inherent.rs delete mode 100644 src/test/ui/assoc-inherent.stderr create mode 100644 src/test/ui/associated-inherent-types/assoc-inherent-no-body.rs create mode 100644 src/test/ui/associated-inherent-types/assoc-inherent-no-body.stderr create mode 100644 src/test/ui/associated-inherent-types/assoc-inherent-use.rs diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index 9dd9bf05540..aa4f3b40fbd 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -1910,6 +1910,20 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } } } + + // see if we can satisfy using an inherent associated type + for impl_ in tcx.inherent_impls(adt_def.did()) { + let assoc_ty = tcx.associated_items(impl_).find_by_name_and_kind( + tcx, + assoc_ident, + ty::AssocKind::Type, + *impl_, + ); + if let Some(assoc_ty) = assoc_ty { + let ty = tcx.type_of(assoc_ty.def_id); + return Ok((ty, DefKind::AssocTy, assoc_ty.def_id)); + } + } } // Find the type of the associated item, and the trait where the associated diff --git a/src/test/ui/assoc-inherent.rs b/src/test/ui/assoc-inherent.rs deleted file mode 100644 index c579c962ffc..00000000000 --- a/src/test/ui/assoc-inherent.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Test that inherent associated types work with -// inherent_associated_types feature gate. - -#![feature(inherent_associated_types)] -#![allow(incomplete_features)] - -struct Foo; - -impl Foo { - type Bar = isize; -} - -impl Foo { - type Baz; //~ ERROR associated type in `impl` without body -} - -fn main() { - let x : Foo::Bar; //~ERROR ambiguous associated type - x = 0isize; -} diff --git a/src/test/ui/assoc-inherent.stderr b/src/test/ui/assoc-inherent.stderr deleted file mode 100644 index b703453fa03..00000000000 --- a/src/test/ui/assoc-inherent.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: associated type in `impl` without body - --> $DIR/assoc-inherent.rs:14:5 - | -LL | type Baz; - | ^^^^^^^^- - | | - | help: provide a definition for the type: `= ;` - -error[E0223]: ambiguous associated type - --> $DIR/assoc-inherent.rs:18:13 - | -LL | let x : Foo::Bar; - | ^^^^^^^^ help: use fully-qualified syntax: `::Bar` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0223`. diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-no-body.rs b/src/test/ui/associated-inherent-types/assoc-inherent-no-body.rs new file mode 100644 index 00000000000..71f65b92eae --- /dev/null +++ b/src/test/ui/associated-inherent-types/assoc-inherent-no-body.rs @@ -0,0 +1,10 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Foo; + +impl Foo { + type Baz; //~ ERROR associated type in `impl` without body +} + +fn main() {} diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-no-body.stderr b/src/test/ui/associated-inherent-types/assoc-inherent-no-body.stderr new file mode 100644 index 00000000000..387a5658da3 --- /dev/null +++ b/src/test/ui/associated-inherent-types/assoc-inherent-no-body.stderr @@ -0,0 +1,10 @@ +error: associated type in `impl` without body + --> $DIR/assoc-inherent-no-body.rs:7:5 + | +LL | type Baz; + | ^^^^^^^^- + | | + | help: provide a definition for the type: `= ;` + +error: aborting due to previous error + diff --git a/src/test/ui/associated-inherent-types/assoc-inherent-use.rs b/src/test/ui/associated-inherent-types/assoc-inherent-use.rs new file mode 100644 index 00000000000..7ae425e2aaa --- /dev/null +++ b/src/test/ui/associated-inherent-types/assoc-inherent-use.rs @@ -0,0 +1,14 @@ +// check-pass +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Foo; + +impl Foo { + type Bar = isize; +} + +fn main() { + let x: Foo::Bar; + x = 0isize; +} diff --git a/src/test/ui/resolve/resolve-self-in-impl.stderr b/src/test/ui/resolve/resolve-self-in-impl.stderr index 9f9ed68898f..b3042d41346 100644 --- a/src/test/ui/resolve/resolve-self-in-impl.stderr +++ b/src/test/ui/resolve/resolve-self-in-impl.stderr @@ -1,19 +1,3 @@ -error: `Self` is not valid in the self type of an impl block - --> $DIR/resolve-self-in-impl.rs:14:13 - | -LL | impl Tr for Self {} - | ^^^^ - | - = note: replace `Self` with a different type - -error: `Self` is not valid in the self type of an impl block - --> $DIR/resolve-self-in-impl.rs:15:15 - | -LL | impl Tr for S {} - | ^^^^ - | - = note: replace `Self` with a different type - error: `Self` is not valid in the self type of an impl block --> $DIR/resolve-self-in-impl.rs:16:6 | @@ -38,6 +22,22 @@ LL | impl (Self, Self) {} | = note: replace `Self` with a different type +error: `Self` is not valid in the self type of an impl block + --> $DIR/resolve-self-in-impl.rs:14:13 + | +LL | impl Tr for Self {} + | ^^^^ + | + = note: replace `Self` with a different type + +error: `Self` is not valid in the self type of an impl block + --> $DIR/resolve-self-in-impl.rs:15:15 + | +LL | impl Tr for S {} + | ^^^^ + | + = note: replace `Self` with a different type + error[E0391]: cycle detected when computing trait implemented by `` --> $DIR/resolve-self-in-impl.rs:19:1 | From 3aef6c6a54e85ac5cc5e004669404d71be22aafb Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Thu, 27 Oct 2022 17:33:41 +0000 Subject: [PATCH 189/219] roll another resolution logic in rustdoc --- src/librustdoc/clean/mod.rs | 3 ++- .../rustdoc-ui/ambiguous-inherent-assoc-ty.rs | 5 +---- .../rustdoc-ui/ambiguous-inherent-assoc-ty.stderr | 15 --------------- 3 files changed, 3 insertions(+), 20 deletions(-) delete mode 100644 src/test/rustdoc-ui/ambiguous-inherent-assoc-ty.stderr diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ad4ad4104e1..7a77aedbccf 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1381,7 +1381,8 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type ty::Projection(proj) => Res::Def(DefKind::Trait, proj.trait_ref(cx.tcx).def_id), // Rustdoc handles `ty::Error`s by turning them into `Type::Infer`s. ty::Error(_) => return Type::Infer, - _ => bug!("clean: expected associated type, found `{:?}`", ty), + // Otherwise, this is an inherent associated type. + _ => return clean_middle_ty(ty, cx, None), }; let trait_ = clean_path(&hir::Path { span, res, segments: &[] }, cx); register_res(cx, trait_.res); diff --git a/src/test/rustdoc-ui/ambiguous-inherent-assoc-ty.rs b/src/test/rustdoc-ui/ambiguous-inherent-assoc-ty.rs index e58bba64058..94ea0e93bf6 100644 --- a/src/test/rustdoc-ui/ambiguous-inherent-assoc-ty.rs +++ b/src/test/rustdoc-ui/ambiguous-inherent-assoc-ty.rs @@ -1,3 +1,4 @@ +// check-pass // This test ensures that rustdoc does not panic on inherented associated types // that are referred to without fully-qualified syntax. @@ -9,8 +10,4 @@ pub struct Struct; impl Struct { pub type AssocTy = usize; pub const AssocConst: Self::AssocTy = 42; - //~^ ERROR ambiguous associated type - //~| HELP use fully-qualified syntax - //~| ERROR ambiguous associated type - //~| HELP use fully-qualified syntax } diff --git a/src/test/rustdoc-ui/ambiguous-inherent-assoc-ty.stderr b/src/test/rustdoc-ui/ambiguous-inherent-assoc-ty.stderr deleted file mode 100644 index b963b722f66..00000000000 --- a/src/test/rustdoc-ui/ambiguous-inherent-assoc-ty.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0223]: ambiguous associated type - --> $DIR/ambiguous-inherent-assoc-ty.rs:11:27 - | -LL | pub const AssocConst: Self::AssocTy = 42; - | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `::AssocTy` - -error[E0223]: ambiguous associated type - --> $DIR/ambiguous-inherent-assoc-ty.rs:11:27 - | -LL | pub const AssocConst: Self::AssocTy = 42; - | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `::AssocTy` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0223`. From 9c79a27e23f87d60736207f06f9c030396a444b4 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Thu, 3 Nov 2022 11:44:50 -0400 Subject: [PATCH 190/219] Add note to RELEASES.md regarding issue 102754. --- RELEASES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index a3df56f1d2a..c7437f9f7e7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -87,6 +87,9 @@ Compatibility Notes This strengthens the forward compatibility lint deprecated_cfg_attr_crate_type_name to deny. - [`llvm-has-rust-patches` allows setting the build system to treat the LLVM as having Rust-specific patches](https://github.com/rust-lang/rust/pull/101072) This option may need to be set for distributions that are building Rust with a patched LLVM via `llvm-config`, not the built-in LLVM. +- Combining three or more languages (e.g. Objective C, C++ and Rust) into one binary may hit linker limitations when using `lld`. For more information, see [issue 102754][102754]. + +[102754]: https://github.com/rust-lang/rust/issues/102754 Internal Changes ---------------- From 060d4392b1679fa4f7323ee702a7669af281d5db Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 15 Sep 2022 00:18:35 +0000 Subject: [PATCH 191/219] Make obligations_for_self_ty only return an obligation --- compiler/rustc_hir_typeck/src/closure.rs | 59 +++++++----- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 96 ++++++++++--------- 2 files changed, 84 insertions(+), 71 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index a5a45f75e0e..cc1191d3245 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -225,33 +225,44 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, expected_vid: ty::TyVid, ) -> (Option>, Option) { - let expected_sig = - self.obligations_for_self_ty(expected_vid).find_map(|(_, obligation)| { - debug!(?obligation.predicate); - - let bound_predicate = obligation.predicate.kind(); - if let ty::PredicateKind::Projection(proj_predicate) = - obligation.predicate.kind().skip_binder() - { - // Given a Projection predicate, we can potentially infer - // the complete signature. - self.deduce_sig_from_projection( - Some(obligation.cause.span), - bound_predicate.rebind(proj_predicate), - ) - } else { - None - } - }); - + let mut expected_sig = None; // Even if we can't infer the full signature, we may be able to // infer the kind. This can occur when we elaborate a predicate // like `F : Fn
`. Note that due to subtyping we could encounter // many viable options, so pick the most restrictive. - let expected_kind = self - .obligations_for_self_ty(expected_vid) - .filter_map(|(tr, _)| self.tcx.fn_trait_kind_from_lang_item(tr.def_id())) - .fold(None, |best, cur| Some(best.map_or(cur, |best| cmp::min(best, cur)))); + let mut expected_kind = None; + + for obligation in self.obligations_for_self_ty(expected_vid) { + debug!(?obligation.predicate); + let bound_predicate = obligation.predicate.kind(); + + if expected_sig.is_none() + && let ty::PredicateKind::Projection(proj_predicate) = bound_predicate.skip_binder() + { + // Given a Projection predicate, we can potentially infer + // the complete signature. + expected_sig = self.deduce_sig_from_projection( + Some(obligation.cause.span), + bound_predicate.rebind(proj_predicate), + ); + } + + let trait_def_id = match bound_predicate.skip_binder() { + ty::PredicateKind::Projection(data) => { + Some(data.projection_ty.trait_def_id(self.tcx)) + } + ty::PredicateKind::Trait(data) => Some(data.def_id()), + _ => None, + }; + if let Some(closure_kind) = + trait_def_id.and_then(|def_id| self.tcx.fn_trait_kind_from_lang_item(def_id)) + { + expected_kind = Some( + expected_kind + .map_or_else(|| closure_kind, |current| cmp::min(current, closure_kind)), + ); + } + } (expected_sig, expected_kind) } @@ -689,7 +700,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let output_ty = match *ret_ty.kind() { ty::Infer(ty::TyVar(ret_vid)) => { - self.obligations_for_self_ty(ret_vid).find_map(|(_, obligation)| { + self.obligations_for_self_ty(ret_vid).find_map(|obligation| { get_future_output(obligation.predicate, obligation.cause.span) })? } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 6a1cffe3e60..d2962a3836f 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -21,8 +21,8 @@ use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMut use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::visit::TypeVisitable; use rustc_middle::ty::{ - self, AdtKind, CanonicalUserType, DefIdTree, EarlyBinder, GenericParamDefKind, ToPolyTraitRef, - ToPredicate, Ty, UserType, + self, AdtKind, CanonicalUserType, DefIdTree, EarlyBinder, GenericParamDefKind, ToPredicate, Ty, + UserType, }; use rustc_middle::ty::{GenericArgKind, InternalSubsts, SubstsRef, UserSelfTy, UserSubsts}; use rustc_session::lint; @@ -650,12 +650,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } #[instrument(skip(self), level = "debug")] - fn self_type_matches_expected_vid( - &self, - trait_ref: ty::PolyTraitRef<'tcx>, - expected_vid: ty::TyVid, - ) -> bool { - let self_ty = self.shallow_resolve(trait_ref.skip_binder().self_ty()); + fn self_type_matches_expected_vid(&self, self_ty: Ty<'tcx>, expected_vid: ty::TyVid) -> bool { + let self_ty = self.shallow_resolve(self_ty); debug!(?self_ty); match *self_ty.kind() { @@ -674,54 +670,60 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(in super::super) fn obligations_for_self_ty<'b>( &'b self, self_ty: ty::TyVid, - ) -> impl Iterator, traits::PredicateObligation<'tcx>)> - + Captures<'tcx> - + 'b { + ) -> impl Iterator> + Captures<'tcx> + 'b { // FIXME: consider using `sub_root_var` here so we // can see through subtyping. let ty_var_root = self.root_var(self_ty); trace!("pending_obligations = {:#?}", self.fulfillment_cx.borrow().pending_obligations()); - self.fulfillment_cx - .borrow() - .pending_obligations() - .into_iter() - .filter_map(move |obligation| { - let bound_predicate = obligation.predicate.kind(); - match bound_predicate.skip_binder() { - ty::PredicateKind::Projection(data) => Some(( - bound_predicate.rebind(data).required_poly_trait_ref(self.tcx), - obligation, - )), - ty::PredicateKind::Trait(data) => { - Some((bound_predicate.rebind(data).to_poly_trait_ref(), obligation)) - } - ty::PredicateKind::Subtype(..) => None, - ty::PredicateKind::Coerce(..) => None, - ty::PredicateKind::RegionOutlives(..) => None, - ty::PredicateKind::TypeOutlives(..) => None, - ty::PredicateKind::WellFormed(..) => None, - ty::PredicateKind::ObjectSafe(..) => None, - ty::PredicateKind::ConstEvaluatable(..) => None, - ty::PredicateKind::ConstEquate(..) => None, - // N.B., this predicate is created by breaking down a - // `ClosureType: FnFoo()` predicate, where - // `ClosureType` represents some `Closure`. It can't - // possibly be referring to the current closure, - // because we haven't produced the `Closure` for - // this closure yet; this is exactly why the other - // code is looking for a self type of an unresolved - // inference variable. - ty::PredicateKind::ClosureKind(..) => None, - ty::PredicateKind::TypeWellFormedFromEnv(..) => None, + self.fulfillment_cx.borrow().pending_obligations().into_iter().filter_map( + move |obligation| match &obligation.predicate.kind().skip_binder() { + ty::PredicateKind::Projection(data) + if self.self_type_matches_expected_vid( + data.projection_ty.self_ty(), + ty_var_root, + ) => + { + Some(obligation) } - }) - .filter(move |(tr, _)| self.self_type_matches_expected_vid(*tr, ty_var_root)) + ty::PredicateKind::Trait(data) + if self.self_type_matches_expected_vid(data.self_ty(), ty_var_root) => + { + Some(obligation) + } + + ty::PredicateKind::Trait(..) + | ty::PredicateKind::Projection(..) + | ty::PredicateKind::Subtype(..) + | ty::PredicateKind::Coerce(..) + | ty::PredicateKind::RegionOutlives(..) + | ty::PredicateKind::TypeOutlives(..) + | ty::PredicateKind::WellFormed(..) + | ty::PredicateKind::ObjectSafe(..) + | ty::PredicateKind::ConstEvaluatable(..) + | ty::PredicateKind::ConstEquate(..) + // N.B., this predicate is created by breaking down a + // `ClosureType: FnFoo()` predicate, where + // `ClosureType` represents some `Closure`. It can't + // possibly be referring to the current closure, + // because we haven't produced the `Closure` for + // this closure yet; this is exactly why the other + // code is looking for a self type of an unresolved + // inference variable. + | ty::PredicateKind::ClosureKind(..) + | ty::PredicateKind::TypeWellFormedFromEnv(..) => None, + }, + ) } pub(in super::super) fn type_var_is_sized(&self, self_ty: ty::TyVid) -> bool { - self.obligations_for_self_ty(self_ty) - .any(|(tr, _)| Some(tr.def_id()) == self.tcx.lang_items().sized_trait()) + let sized_did = self.tcx.lang_items().sized_trait(); + self.obligations_for_self_ty(self_ty).any(|obligation| { + match obligation.predicate.kind().skip_binder() { + ty::PredicateKind::Trait(data) => Some(data.def_id()) == sized_did, + _ => false, + } + }) } pub(in super::super) fn err_args(&self, len: usize) -> Vec> { From caa701e3c190c4d77634c9075548746e4917e56d Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 15 Sep 2022 00:35:23 +0000 Subject: [PATCH 192/219] Elaborate supertrait obligations when deducing closure signature --- compiler/rustc_hir_typeck/src/closure.rs | 18 +++++++----- ...ue-23012-supertrait-signature-inference.rs | 29 +++++++++++++++++++ .../issue-57611-trait-alias.rs | 3 +- .../issue-57611-trait-alias.stderr | 26 ----------------- 4 files changed, 41 insertions(+), 35 deletions(-) create mode 100644 src/test/ui/closures/issue-23012-supertrait-signature-inference.rs delete mode 100644 src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index cc1191d3245..4f8ac45d5a6 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -15,6 +15,7 @@ use rustc_middle::ty::visit::TypeVisitable; use rustc_middle::ty::{self, Ty}; use rustc_span::source_map::Span; use rustc_target::spec::abi::Abi; +use rustc_trait_selection::traits; use rustc_trait_selection::traits::error_reporting::ArgKind; use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _; use std::cmp; @@ -226,27 +227,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected_vid: ty::TyVid, ) -> (Option>, Option) { let mut expected_sig = None; - // Even if we can't infer the full signature, we may be able to - // infer the kind. This can occur when we elaborate a predicate - // like `F : Fn`. Note that due to subtyping we could encounter - // many viable options, so pick the most restrictive. let mut expected_kind = None; - for obligation in self.obligations_for_self_ty(expected_vid) { + for obligation in traits::elaborate_obligations( + self.tcx, + self.obligations_for_self_ty(expected_vid).collect(), + ) { debug!(?obligation.predicate); let bound_predicate = obligation.predicate.kind(); + // Given a Projection predicate, we can potentially infer + // the complete signature. if expected_sig.is_none() && let ty::PredicateKind::Projection(proj_predicate) = bound_predicate.skip_binder() { - // Given a Projection predicate, we can potentially infer - // the complete signature. expected_sig = self.deduce_sig_from_projection( Some(obligation.cause.span), bound_predicate.rebind(proj_predicate), ); } + // Even if we can't infer the full signature, we may be able to + // infer the kind. This can occur when we elaborate a predicate + // like `F : Fn`. Note that due to subtyping we could encounter + // many viable options, so pick the most restrictive. let trait_def_id = match bound_predicate.skip_binder() { ty::PredicateKind::Projection(data) => { Some(data.projection_ty.trait_def_id(self.tcx)) diff --git a/src/test/ui/closures/issue-23012-supertrait-signature-inference.rs b/src/test/ui/closures/issue-23012-supertrait-signature-inference.rs new file mode 100644 index 00000000000..5899b703e7c --- /dev/null +++ b/src/test/ui/closures/issue-23012-supertrait-signature-inference.rs @@ -0,0 +1,29 @@ +// check-pass +// Checks that we can infer a closure signature even if the `FnOnce` bound is +// a supertrait of the obligations we have currently registered for the Ty var. + +pub trait Receive: FnOnce(Result) { + fn receive(self, res: Result); +} + +impl)> Receive for F { + fn receive(self, res: Result) { + self(res) + } +} + +pub trait Async { + fn receive>(self, f: F); +} + +impl Async for Result { + fn receive>(self, f: F) { + f(self) + } +} + +pub fn main() { + Ok::(123).receive(|res| { + res.unwrap(); + }); +} diff --git a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs index 067ed7ea1e5..cad3e0f6677 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs +++ b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs @@ -1,7 +1,6 @@ +// check-pass // Regression test for issue #57611 // Ensures that we don't ICE -// FIXME: This should compile, but it currently doesn't -// known-bug: unknown #![feature(trait_alias)] #![feature(type_alias_impl_trait)] diff --git a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr deleted file mode 100644 index 6344f114a91..00000000000 --- a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-57611-trait-alias.rs:21:9 - | -LL | |x| x - | ^^^^^ one type is more general than the other - | - = note: expected trait `for<'a> Fn<(&'a X,)>` - found trait `Fn<(&X,)>` -note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-57611-trait-alias.rs:21:9 - | -LL | |x| x - | ^^^ - -error: implementation of `FnOnce` is not general enough - --> $DIR/issue-57611-trait-alias.rs:21:9 - | -LL | |x| x - | ^^^^^ implementation of `FnOnce` is not general enough - | - = note: closure with signature `fn(&'2 X) -> &X` must implement `FnOnce<(&'1 X,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 X,)>`, for some specific lifetime `'2` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. From bc3516d474a6ab5e5116a2ec32f5d236d479cab3 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 15 Oct 2022 18:48:13 +0000 Subject: [PATCH 193/219] reverse obligations for better diagnostics on multiple conflicting fn bounds --- compiler/rustc_hir_typeck/src/closure.rs | 5 ++++- compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index 4f8ac45d5a6..14f6e7d36be 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -231,7 +231,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { for obligation in traits::elaborate_obligations( self.tcx, - self.obligations_for_self_ty(expected_vid).collect(), + // Reverse the obligations here, since `elaborate_*` uses a stack, + // and we want to keep inference generally in the same order of + // the registered obligations. + self.obligations_for_self_ty(expected_vid).rev().collect(), ) { debug!(?obligation.predicate); let bound_predicate = obligation.predicate.kind(); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index d2962a3836f..7c22eaf18f8 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -670,7 +670,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(in super::super) fn obligations_for_self_ty<'b>( &'b self, self_ty: ty::TyVid, - ) -> impl Iterator> + Captures<'tcx> + 'b { + ) -> impl DoubleEndedIterator> + Captures<'tcx> + 'b + { // FIXME: consider using `sub_root_var` here so we // can see through subtyping. let ty_var_root = self.root_var(self_ty); From 35b16d01ce149716a8d1443fff6a4c6815f3e56d Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Thu, 3 Nov 2022 15:41:01 +0000 Subject: [PATCH 194/219] Move some tests from `src/test/ui` to more reasonable places --- src/test/ui/{ => macros}/attr-from-macro.rs | 0 src/test/ui/{ => macros}/auxiliary/attr-from-macro.rs | 0 src/test/ui/{ => repr}/align-with-extern-c-fn.rs | 0 src/test/ui/{ => repr}/aligned_enum_cast.rs | 0 src/test/ui/{ => repr}/repr_c_int_align.rs | 0 src/test/ui/{rfc1623.rs => rfcs/rfc1623-2.rs} | 0 src/test/ui/{rfc1623.stderr => rfcs/rfc1623-2.stderr} | 8 ++++---- src/test/ui/{rfc1623-2.rs => rfcs/rfc1623-3.rs} | 0 src/test/ui/{rfc1623-2.stderr => rfcs/rfc1623-3.stderr} | 6 +++--- src/tools/tidy/src/ui_tests.rs | 2 +- 10 files changed, 8 insertions(+), 8 deletions(-) rename src/test/ui/{ => macros}/attr-from-macro.rs (100%) rename src/test/ui/{ => macros}/auxiliary/attr-from-macro.rs (100%) rename src/test/ui/{ => repr}/align-with-extern-c-fn.rs (100%) rename src/test/ui/{ => repr}/aligned_enum_cast.rs (100%) rename src/test/ui/{ => repr}/repr_c_int_align.rs (100%) rename src/test/ui/{rfc1623.rs => rfcs/rfc1623-2.rs} (100%) rename src/test/ui/{rfc1623.stderr => rfcs/rfc1623-2.stderr} (91%) rename src/test/ui/{rfc1623-2.rs => rfcs/rfc1623-3.rs} (100%) rename src/test/ui/{rfc1623-2.stderr => rfcs/rfc1623-3.stderr} (94%) diff --git a/src/test/ui/attr-from-macro.rs b/src/test/ui/macros/attr-from-macro.rs similarity index 100% rename from src/test/ui/attr-from-macro.rs rename to src/test/ui/macros/attr-from-macro.rs diff --git a/src/test/ui/auxiliary/attr-from-macro.rs b/src/test/ui/macros/auxiliary/attr-from-macro.rs similarity index 100% rename from src/test/ui/auxiliary/attr-from-macro.rs rename to src/test/ui/macros/auxiliary/attr-from-macro.rs diff --git a/src/test/ui/align-with-extern-c-fn.rs b/src/test/ui/repr/align-with-extern-c-fn.rs similarity index 100% rename from src/test/ui/align-with-extern-c-fn.rs rename to src/test/ui/repr/align-with-extern-c-fn.rs diff --git a/src/test/ui/aligned_enum_cast.rs b/src/test/ui/repr/aligned_enum_cast.rs similarity index 100% rename from src/test/ui/aligned_enum_cast.rs rename to src/test/ui/repr/aligned_enum_cast.rs diff --git a/src/test/ui/repr_c_int_align.rs b/src/test/ui/repr/repr_c_int_align.rs similarity index 100% rename from src/test/ui/repr_c_int_align.rs rename to src/test/ui/repr/repr_c_int_align.rs diff --git a/src/test/ui/rfc1623.rs b/src/test/ui/rfcs/rfc1623-2.rs similarity index 100% rename from src/test/ui/rfc1623.rs rename to src/test/ui/rfcs/rfc1623-2.rs diff --git a/src/test/ui/rfc1623.stderr b/src/test/ui/rfcs/rfc1623-2.stderr similarity index 91% rename from src/test/ui/rfc1623.stderr rename to src/test/ui/rfcs/rfc1623-2.stderr index b15a4cb110b..d183eaaa623 100644 --- a/src/test/ui/rfc1623.stderr +++ b/src/test/ui/rfcs/rfc1623-2.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/rfc1623.rs:28:8 + --> $DIR/rfc1623-2.rs:28:8 | LL | f: &id, | ^^^ one type is more general than the other @@ -8,7 +8,7 @@ LL | f: &id, found trait `Fn<(&Foo<'_>,)>` error[E0308]: mismatched types - --> $DIR/rfc1623.rs:28:8 + --> $DIR/rfc1623-2.rs:28:8 | LL | f: &id, | ^^^ one type is more general than the other @@ -17,7 +17,7 @@ LL | f: &id, found trait `Fn<(&Foo<'_>,)>` error: implementation of `FnOnce` is not general enough - --> $DIR/rfc1623.rs:28:8 + --> $DIR/rfc1623-2.rs:28:8 | LL | f: &id, | ^^^ implementation of `FnOnce` is not general enough @@ -26,7 +26,7 @@ LL | f: &id, = note: ...but it actually implements `FnOnce<(&'2 Foo<'_>,)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough - --> $DIR/rfc1623.rs:28:8 + --> $DIR/rfc1623-2.rs:28:8 | LL | f: &id, | ^^^ implementation of `FnOnce` is not general enough diff --git a/src/test/ui/rfc1623-2.rs b/src/test/ui/rfcs/rfc1623-3.rs similarity index 100% rename from src/test/ui/rfc1623-2.rs rename to src/test/ui/rfcs/rfc1623-3.rs diff --git a/src/test/ui/rfc1623-2.stderr b/src/test/ui/rfcs/rfc1623-3.stderr similarity index 94% rename from src/test/ui/rfc1623-2.stderr rename to src/test/ui/rfcs/rfc1623-3.stderr index 945c6533c79..77fc3f0412e 100644 --- a/src/test/ui/rfc1623-2.stderr +++ b/src/test/ui/rfcs/rfc1623-3.stderr @@ -1,5 +1,5 @@ error[E0106]: missing lifetime specifier - --> $DIR/rfc1623-2.rs:8:42 + --> $DIR/rfc1623-3.rs:8:42 | LL | static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = | --- --- ^ expected named lifetime parameter @@ -12,7 +12,7 @@ LL | static NON_ELIDABLE_FN: &for<'a> fn(&'a u8, &'a u8) -> &'a u8 = | +++++++ ++ ++ ++ error[E0106]: missing lifetime specifier - --> $DIR/rfc1623-2.rs:10:39 + --> $DIR/rfc1623-3.rs:10:39 | LL | &(non_elidable as fn(&u8, &u8) -> &u8); | --- --- ^ expected named lifetime parameter @@ -24,7 +24,7 @@ LL | &(non_elidable as for<'a> fn(&'a u8, &'a u8) -> &'a u8); | +++++++ ++ ++ ++ error[E0605]: non-primitive cast: `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8 {non_elidable}` as `for<'a, 'b> fn(&'a u8, &'b u8) -> &u8` - --> $DIR/rfc1623-2.rs:10:6 + --> $DIR/rfc1623-3.rs:10:6 | LL | &(non_elidable as fn(&u8, &u8) -> &u8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index c600f99c2c4..6bf7d8206a5 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -7,7 +7,7 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. -const ROOT_ENTRY_LIMIT: usize = 948; +const ROOT_ENTRY_LIMIT: usize = 941; const ISSUES_ENTRY_LIMIT: usize = 2117; fn check_entries(path: &Path, bad: &mut bool) { From df326946ed5668bf05c37ece50e271b1c9fbdf1e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 3 Nov 2022 18:15:24 +0100 Subject: [PATCH 195/219] Remove rustdoc clean::Visibility type --- src/librustdoc/clean/inline.rs | 5 +- src/librustdoc/clean/mod.rs | 9 +- src/librustdoc/clean/types.rs | 40 ++----- src/librustdoc/clean/utils.rs | 9 +- src/librustdoc/html/format.rs | 143 +++++++++++------------ src/librustdoc/html/render/mod.rs | 8 +- src/librustdoc/html/render/print_item.rs | 41 ++++--- src/librustdoc/json/conversions.rs | 11 +- src/librustdoc/passes/stripper.rs | 8 +- 9 files changed, 125 insertions(+), 149 deletions(-) diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index ec93eefb7d1..841c4f9d530 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -19,8 +19,7 @@ use rustc_span::symbol::{kw, sym, Symbol}; use crate::clean::{ self, clean_fn_decl_from_did_and_sig, clean_generics, clean_impl_item, clean_middle_assoc_item, clean_middle_field, clean_middle_ty, clean_trait_ref_with_bindings, clean_ty, - clean_ty_generics, clean_variant_def, clean_visibility, utils, Attributes, AttributesExt, - ImplKind, ItemId, Type, + clean_ty_generics, clean_variant_def, utils, Attributes, AttributesExt, ImplKind, ItemId, Type, }; use crate::core::DocContext; use crate::formats::item_type::ItemType; @@ -654,7 +653,7 @@ fn build_macro( match CStore::from_tcx(cx.tcx).load_macro_untracked(def_id, cx.sess()) { LoadedMacro::MacroDef(item_def, _) => { if let ast::ItemKind::MacroDef(ref def) = item_def.kind { - let vis = clean_visibility(cx.tcx.visibility(import_def_id.unwrap_or(def_id))); + let vis = cx.tcx.visibility(import_def_id.unwrap_or(def_id)); clean::MacroItem(clean::Macro { source: utils::display_macro_source(cx, name, def, def_id, vis), }) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ad4ad4104e1..77cb7196cde 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1799,13 +1799,6 @@ pub(crate) fn clean_field_with_def_id( Item::from_def_id_and_parts(def_id, Some(name), StructFieldItem(ty), cx) } -pub(crate) fn clean_visibility(vis: ty::Visibility) -> Visibility { - match vis { - ty::Visibility::Public => Visibility::Public, - ty::Visibility::Restricted(module) => Visibility::Restricted(module), - } -} - pub(crate) fn clean_variant_def<'tcx>(variant: &ty::VariantDef, cx: &mut DocContext<'tcx>) -> Item { let kind = match variant.ctor_kind { CtorKind::Const => Variant::CLike(match variant.discr { @@ -1962,7 +1955,7 @@ fn clean_maybe_renamed_item<'tcx>( clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx) } ItemKind::Macro(ref macro_def, _) => { - let ty_vis = clean_visibility(cx.tcx.visibility(def_id)); + let ty_vis = cx.tcx.visibility(def_id); MacroItem(Macro { source: display_macro_source(cx, name, macro_def, def_id, ty_vis), }) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 439311f0640..8b265dda90c 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -24,7 +24,7 @@ use rustc_hir::{BodyId, Mutability}; use rustc_hir_analysis::check::intrinsic::intrinsic_operation_unsafety; use rustc_index::vec::IndexVec; use rustc_middle::ty::fast_reject::SimplifiedType; -use rustc_middle::ty::{self, DefIdTree, TyCtxt}; +use rustc_middle::ty::{self, DefIdTree, TyCtxt, Visibility}; use rustc_session::Session; use rustc_span::hygiene::MacroKind; use rustc_span::source_map::DUMMY_SP; @@ -34,7 +34,6 @@ use rustc_target::abi::VariantIdx; use rustc_target::spec::abi::Abi; use crate::clean::cfg::Cfg; -use crate::clean::clean_visibility; use crate::clean::external_path; use crate::clean::inline::{self, print_inlined_const}; use crate::clean::utils::{is_literal_expr, print_const_expr, print_evaluated_const}; @@ -51,7 +50,6 @@ pub(crate) use self::Type::{ Array, BareFunction, BorrowedRef, DynTrait, Generic, ImplTrait, Infer, Primitive, QPath, RawPointer, Slice, Tuple, }; -pub(crate) use self::Visibility::{Inherited, Public}; #[cfg(test)] mod tests; @@ -706,26 +704,28 @@ impl Item { Some(header) } - pub(crate) fn visibility(&self, tcx: TyCtxt<'_>) -> Visibility { + /// Returns the visibility of the current item. If the visibility is "inherited", then `None` + /// is returned. + pub(crate) fn visibility(&self, tcx: TyCtxt<'_>) -> Option> { let def_id = match self.item_id { // Anything but DefId *shouldn't* matter, but return a reasonable value anyway. - ItemId::Auto { .. } | ItemId::Blanket { .. } => return Visibility::Inherited, + ItemId::Auto { .. } | ItemId::Blanket { .. } => return None, // Primitives and Keywords are written in the source code as private modules. // The modules need to be private so that nobody actually uses them, but the // keywords and primitives that they are documenting are public. - ItemId::Primitive(..) => return Visibility::Public, + ItemId::Primitive(..) => return Some(Visibility::Public), ItemId::DefId(def_id) => def_id, }; match *self.kind { // Explication on `ItemId::Primitive` just above. - ItemKind::KeywordItem | ItemKind::PrimitiveItem(_) => return Visibility::Public, + ItemKind::KeywordItem | ItemKind::PrimitiveItem(_) => return Some(Visibility::Public), // Variant fields inherit their enum's visibility. StructFieldItem(..) if is_field_vis_inherited(tcx, def_id) => { - return Visibility::Inherited; + return None; } // Variants always inherit visibility - VariantItem(..) => return Visibility::Inherited, + VariantItem(..) => return None, // Trait items inherit the trait's visibility AssocConstItem(..) | TyAssocConstItem(..) | AssocTypeItem(..) | TyAssocTypeItem(..) | TyMethodItem(..) | MethodItem(..) => { @@ -739,7 +739,7 @@ impl Item { } }; if is_trait_item { - return Visibility::Inherited; + return None; } } _ => {} @@ -748,7 +748,7 @@ impl Item { Some(inlined) => inlined, None => def_id, }; - clean_visibility(tcx.visibility(def_id)) + Some(tcx.visibility(def_id)) } } @@ -2078,24 +2078,6 @@ impl From for PrimitiveType { } } -#[derive(Copy, Clone, Debug)] -pub(crate) enum Visibility { - /// `pub` - Public, - /// Visibility inherited from parent. - /// - /// For example, this is the visibility of private items and of enum variants. - Inherited, - /// `pub(crate)`, `pub(super)`, or `pub(in path::to::somewhere)` - Restricted(DefId), -} - -impl Visibility { - pub(crate) fn is_public(&self) -> bool { - matches!(self, Visibility::Public) - } -} - #[derive(Clone, Debug)] pub(crate) struct Struct { pub(crate) struct_type: CtorKind, diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 518e320235f..df20dc3fc3f 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -4,9 +4,10 @@ use crate::clean::render_macro_matchers::render_macro_matcher; use crate::clean::{ clean_doc_module, clean_middle_const, clean_middle_region, clean_middle_ty, inline, Crate, ExternalCrate, Generic, GenericArg, GenericArgs, ImportSource, Item, ItemKind, Lifetime, Path, - PathSegment, Primitive, PrimitiveType, Type, TypeBinding, Visibility, + PathSegment, Primitive, PrimitiveType, Type, TypeBinding, }; use crate::core::DocContext; +use crate::html::format::visibility_to_src_with_space; use rustc_ast as ast; use rustc_ast::tokenstream::TokenTree; @@ -583,7 +584,7 @@ pub(super) fn display_macro_source( name: Symbol, def: &ast::MacroDef, def_id: DefId, - vis: Visibility, + vis: ty::Visibility, ) -> String { let tts: Vec<_> = def.body.inner_tokens().into_trees().collect(); // Extract the spans of all matchers. They represent the "interface" of the macro. @@ -595,14 +596,14 @@ pub(super) fn display_macro_source( if matchers.len() <= 1 { format!( "{}macro {}{} {{\n ...\n}}", - vis.to_src_with_space(cx.tcx, def_id), + visibility_to_src_with_space(Some(vis), cx.tcx, def_id), name, matchers.map(|matcher| render_macro_matcher(cx.tcx, matcher)).collect::(), ) } else { format!( "{}macro {} {{\n{}}}", - vis.to_src_with_space(cx.tcx, def_id), + visibility_to_src_with_space(Some(vis), cx.tcx, def_id), name, render_macro_arms(cx.tcx, matchers, ","), ) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 37202f786ed..06db3fb0ec4 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1420,87 +1420,84 @@ impl clean::FnDecl { } } -impl clean::Visibility { - pub(crate) fn print_with_space<'a, 'tcx: 'a>( - self, - item_did: ItemId, - cx: &'a Context<'tcx>, - ) -> impl fmt::Display + 'a + Captures<'tcx> { - use std::fmt::Write as _; +pub(crate) fn visibility_print_with_space<'a, 'tcx: 'a>( + visibility: Option>, + item_did: ItemId, + cx: &'a Context<'tcx>, +) -> impl fmt::Display + 'a + Captures<'tcx> { + use std::fmt::Write as _; - let to_print: Cow<'static, str> = match self { - clean::Public => "pub ".into(), - clean::Inherited => "".into(), - clean::Visibility::Restricted(vis_did) => { - // FIXME(camelid): This may not work correctly if `item_did` is a module. - // However, rustdoc currently never displays a module's - // visibility, so it shouldn't matter. - let parent_module = find_nearest_parent_module(cx.tcx(), item_did.expect_def_id()); + let to_print: Cow<'static, str> = match visibility { + None => "".into(), + Some(ty::Visibility::Public) => "pub ".into(), + Some(ty::Visibility::Restricted(vis_did)) => { + // FIXME(camelid): This may not work correctly if `item_did` is a module. + // However, rustdoc currently never displays a module's + // visibility, so it shouldn't matter. + let parent_module = find_nearest_parent_module(cx.tcx(), item_did.expect_def_id()); - if vis_did.is_crate_root() { - "pub(crate) ".into() - } else if parent_module == Some(vis_did) { - // `pub(in foo)` where `foo` is the parent module - // is the same as no visibility modifier - "".into() - } else if parent_module - .and_then(|parent| find_nearest_parent_module(cx.tcx(), parent)) - == Some(vis_did) - { - "pub(super) ".into() - } else { - let path = cx.tcx().def_path(vis_did); - debug!("path={:?}", path); - // modified from `resolved_path()` to work with `DefPathData` - let last_name = path.data.last().unwrap().data.get_opt_name().unwrap(); - let anchor = anchor(vis_did, last_name, cx).to_string(); + if vis_did.is_crate_root() { + "pub(crate) ".into() + } else if parent_module == Some(vis_did) { + // `pub(in foo)` where `foo` is the parent module + // is the same as no visibility modifier + "".into() + } else if parent_module.and_then(|parent| find_nearest_parent_module(cx.tcx(), parent)) + == Some(vis_did) + { + "pub(super) ".into() + } else { + let path = cx.tcx().def_path(vis_did); + debug!("path={:?}", path); + // modified from `resolved_path()` to work with `DefPathData` + let last_name = path.data.last().unwrap().data.get_opt_name().unwrap(); + let anchor = anchor(vis_did, last_name, cx).to_string(); - let mut s = "pub(in ".to_owned(); - for seg in &path.data[..path.data.len() - 1] { - let _ = write!(s, "{}::", seg.data.get_opt_name().unwrap()); - } - let _ = write!(s, "{}) ", anchor); - s.into() + let mut s = "pub(in ".to_owned(); + for seg in &path.data[..path.data.len() - 1] { + let _ = write!(s, "{}::", seg.data.get_opt_name().unwrap()); } + let _ = write!(s, "{}) ", anchor); + s.into() } - }; - display_fn(move |f| write!(f, "{}", to_print)) - } + } + }; + display_fn(move |f| write!(f, "{}", to_print)) +} - /// This function is the same as print_with_space, except that it renders no links. - /// It's used for macros' rendered source view, which is syntax highlighted and cannot have - /// any HTML in it. - pub(crate) fn to_src_with_space<'a, 'tcx: 'a>( - self, - tcx: TyCtxt<'tcx>, - item_did: DefId, - ) -> impl fmt::Display + 'a + Captures<'tcx> { - let to_print = match self { - clean::Public => "pub ".to_owned(), - clean::Inherited => String::new(), - clean::Visibility::Restricted(vis_did) => { - // FIXME(camelid): This may not work correctly if `item_did` is a module. - // However, rustdoc currently never displays a module's - // visibility, so it shouldn't matter. - let parent_module = find_nearest_parent_module(tcx, item_did); +/// This function is the same as print_with_space, except that it renders no links. +/// It's used for macros' rendered source view, which is syntax highlighted and cannot have +/// any HTML in it. +pub(crate) fn visibility_to_src_with_space<'a, 'tcx: 'a>( + visibility: Option>, + tcx: TyCtxt<'tcx>, + item_did: DefId, +) -> impl fmt::Display + 'a + Captures<'tcx> { + let to_print = match visibility { + None => String::new(), + Some(ty::Visibility::Public) => "pub ".to_owned(), + Some(ty::Visibility::Restricted(vis_did)) => { + // FIXME(camelid): This may not work correctly if `item_did` is a module. + // However, rustdoc currently never displays a module's + // visibility, so it shouldn't matter. + let parent_module = find_nearest_parent_module(tcx, item_did); - if vis_did.is_crate_root() { - "pub(crate) ".to_owned() - } else if parent_module == Some(vis_did) { - // `pub(in foo)` where `foo` is the parent module - // is the same as no visibility modifier - String::new() - } else if parent_module.and_then(|parent| find_nearest_parent_module(tcx, parent)) - == Some(vis_did) - { - "pub(super) ".to_owned() - } else { - format!("pub(in {}) ", tcx.def_path_str(vis_did)) - } + if vis_did.is_crate_root() { + "pub(crate) ".to_owned() + } else if parent_module == Some(vis_did) { + // `pub(in foo)` where `foo` is the parent module + // is the same as no visibility modifier + String::new() + } else if parent_module.and_then(|parent| find_nearest_parent_module(tcx, parent)) + == Some(vis_did) + { + "pub(super) ".to_owned() + } else { + format!("pub(in {}) ", tcx.def_path_str(vis_did)) } - }; - display_fn(move |f| f.write_str(&to_print)) - } + } + }; + display_fn(move |f| f.write_str(&to_print)) } pub(crate) trait PrintWithSpace { diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index adf501a0240..3a041ae15d6 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -70,8 +70,8 @@ use crate::formats::{AssocItemRender, Impl, RenderMode}; use crate::html::escape::Escape; use crate::html::format::{ href, join_with_double_colon, print_abi_with_space, print_constness_with_space, - print_default_space, print_generic_bounds, print_where_clause, Buffer, Ending, HrefError, - PrintWithSpace, + print_default_space, print_generic_bounds, print_where_clause, visibility_print_with_space, + Buffer, Ending, HrefError, PrintWithSpace, }; use crate::html::highlight; use crate::html::markdown::{ @@ -752,7 +752,7 @@ fn assoc_const( w, "{extra}{vis}const {name}: {ty}", extra = extra, - vis = it.visibility(tcx).print_with_space(it.item_id, cx), + vis = visibility_print_with_space(it.visibility(tcx), it.item_id, cx), href = assoc_href_attr(it, link, cx), name = it.name.as_ref().unwrap(), ty = ty.print(cx), @@ -809,7 +809,7 @@ fn assoc_method( let tcx = cx.tcx(); let header = meth.fn_header(tcx).expect("Trying to get header from a non-function item"); let name = meth.name.as_ref().unwrap(); - let vis = meth.visibility(tcx).print_with_space(meth.item_id, cx).to_string(); + let vis = visibility_print_with_space(meth.visibility(tcx), meth.item_id, cx).to_string(); // FIXME: Once https://github.com/rust-lang/rust/issues/67792 is implemented, we can remove // this condition. let constness = match render_mode { diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 13df08280b5..3225ddabe2e 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -7,7 +7,7 @@ use rustc_hir::def_id::DefId; use rustc_middle::middle::stability; use rustc_middle::span_bug; use rustc_middle::ty::layout::LayoutError; -use rustc_middle::ty::{Adt, TyCtxt}; +use rustc_middle::ty::{self, Adt, TyCtxt}; use rustc_span::hygiene::MacroKind; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_target::abi::{Layout, Primitive, TagEncoding, Variants}; @@ -28,7 +28,7 @@ use crate::formats::{AssocItemRender, Impl, RenderMode}; use crate::html::escape::Escape; use crate::html::format::{ join_with_double_colon, print_abi_with_space, print_constness_with_space, print_where_clause, - Buffer, Ending, PrintWithSpace, + visibility_print_with_space, Buffer, Ending, PrintWithSpace, }; use crate::html::highlight; use crate::html::layout::Page; @@ -328,14 +328,14 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items: Some(src) => write!( w, "
{}extern crate {} as {};", - myitem.visibility(tcx).print_with_space(myitem.item_id, cx), + visibility_print_with_space(myitem.visibility(tcx), myitem.item_id, cx), anchor(myitem.item_id.expect_def_id(), src, cx), myitem.name.unwrap(), ), None => write!( w, "
{}extern crate {};", - myitem.visibility(tcx).print_with_space(myitem.item_id, cx), + visibility_print_with_space(myitem.visibility(tcx), myitem.item_id, cx), anchor(myitem.item_id.expect_def_id(), myitem.name.unwrap(), cx), ), } @@ -385,7 +385,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
\ {stab_tags_before}{stab_tags}{stab_tags_after}", stab = stab.unwrap_or_default(), - vis = myitem.visibility(tcx).print_with_space(myitem.item_id, cx), + vis = visibility_print_with_space(myitem.visibility(tcx), myitem.item_id, cx), imp = import.print(cx), ); w.write_str(ITEM_TABLE_ROW_CLOSE); @@ -410,7 +410,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items: let add = if stab.is_some() { " " } else { "" }; let visibility_emoji = match myitem.visibility(tcx) { - clean::Visibility::Restricted(_) => { + Some(ty::Visibility::Restricted(_)) => { " 🔒 " } _ => "", @@ -503,7 +503,7 @@ fn item_function(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, f: &cle let unsafety = header.unsafety.print_with_space(); let abi = print_abi_with_space(header.abi).to_string(); let asyncness = header.asyncness.print_with_space(); - let visibility = it.visibility(tcx).print_with_space(it.item_id, cx).to_string(); + let visibility = visibility_print_with_space(it.visibility(tcx), it.item_id, cx).to_string(); let name = it.name.unwrap(); let generics_len = format!("{:#}", f.generics.print(cx)).len(); @@ -561,7 +561,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean: write!( w, "{}{}{}trait {}{}{}", - it.visibility(tcx).print_with_space(it.item_id, cx), + visibility_print_with_space(it.visibility(tcx), it.item_id, cx), t.unsafety(tcx).print_with_space(), if t.is_auto(tcx) { "auto " } else { "" }, it.name.unwrap(), @@ -1086,7 +1086,7 @@ fn item_typedef(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clea fn write_content(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Typedef) { wrap_item(w, "typedef", |w| { render_attributes_in_pre(w, it, ""); - write!(w, "{}", it.visibility(cx.tcx()).print_with_space(it.item_id, cx)); + write!(w, "{}", visibility_print_with_space(it.visibility(cx.tcx()), it.item_id, cx)); write!( w, "type {}{}{where_clause} = {type_};", @@ -1183,7 +1183,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean:: write!( w, "{}enum {}{}", - it.visibility(tcx).print_with_space(it.item_id, cx), + visibility_print_with_space(it.visibility(tcx), it.item_id, cx), it.name.unwrap(), e.generics.print(cx), ); @@ -1398,7 +1398,7 @@ fn item_constant(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, c: &cle write!( w, "{vis}const {name}: {typ}", - vis = it.visibility(tcx).print_with_space(it.item_id, cx), + vis = visibility_print_with_space(it.visibility(tcx), it.item_id, cx), name = it.name.unwrap(), typ = c.type_.print(cx), ); @@ -1499,7 +1499,7 @@ fn item_static(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean write!( w, "{vis}static {mutability}{name}: {typ}", - vis = it.visibility(cx.tcx()).print_with_space(it.item_id, cx), + vis = visibility_print_with_space(it.visibility(cx.tcx()), it.item_id, cx), mutability = s.mutability.print_with_space(), name = it.name.unwrap(), typ = s.type_.print(cx) @@ -1517,7 +1517,7 @@ fn item_foreign_type(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item) { write!( w, " {}type {};\n}}", - it.visibility(cx.tcx()).print_with_space(it.item_id, cx), + visibility_print_with_space(it.visibility(cx.tcx()), it.item_id, cx), it.name.unwrap(), ); }); @@ -1671,7 +1671,12 @@ fn render_union( cx: &Context<'_>, ) { let tcx = cx.tcx(); - write!(w, "{}union {}", it.visibility(tcx).print_with_space(it.item_id, cx), it.name.unwrap(),); + write!( + w, + "{}union {}", + visibility_print_with_space(it.visibility(tcx), it.item_id, cx), + it.name.unwrap(), + ); let where_displayed = g .map(|g| { @@ -1698,7 +1703,7 @@ fn render_union( write!( w, " {}{}: {},\n{}", - field.visibility(tcx).print_with_space(field.item_id, cx), + visibility_print_with_space(field.visibility(tcx), field.item_id, cx), field.name.unwrap(), ty.print(cx), tab @@ -1729,7 +1734,7 @@ fn render_struct( write!( w, "{}{}{}", - it.visibility(tcx).print_with_space(it.item_id, cx), + visibility_print_with_space(it.visibility(tcx), it.item_id, cx), if structhead { "struct " } else { "" }, it.name.unwrap() ); @@ -1759,7 +1764,7 @@ fn render_struct( w, "\n{} {}{}: {},", tab, - field.visibility(tcx).print_with_space(field.item_id, cx), + visibility_print_with_space(field.visibility(tcx), field.item_id, cx), field.name.unwrap(), ty.print(cx), ); @@ -1791,7 +1796,7 @@ fn render_struct( write!( w, "{}{}", - field.visibility(tcx).print_with_space(field.item_id, cx), + visibility_print_with_space(field.visibility(tcx), field.item_id, cx), ty.print(cx), ) } diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 4962eb8f8e1..62ae9519e4b 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -100,13 +100,12 @@ impl JsonRenderer<'_> { } } - fn convert_visibility(&self, v: clean::Visibility) -> Visibility { - use clean::Visibility::*; + fn convert_visibility(&self, v: Option>) -> Visibility { match v { - Public => Visibility::Public, - Inherited => Visibility::Default, - Restricted(did) if did.is_crate_root() => Visibility::Crate, - Restricted(did) => Visibility::Restricted { + None => Visibility::Default, + Some(ty::Visibility::Public) => Visibility::Public, + Some(ty::Visibility::Restricted(did)) if did.is_crate_root() => Visibility::Crate, + Some(ty::Visibility::Restricted(did)) => Visibility::Restricted { parent: from_item_id(did.into(), self.tcx), path: self.tcx.def_path(did).to_string_no_crate_verbose(), }, diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index b2047360ccd..995fb5dcc1c 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -1,6 +1,6 @@ //! A collection of utility functions for the `strip_*` passes. use rustc_hir::def_id::DefId; -use rustc_middle::ty::TyCtxt; +use rustc_middle::ty::{TyCtxt, Visibility}; use rustc_span::symbol::sym; use std::mem; @@ -81,13 +81,13 @@ impl<'a, 'tcx> DocFolder for Stripper<'a, 'tcx> { } clean::StructFieldItem(..) => { - if !i.visibility(self.tcx).is_public() { + if i.visibility(self.tcx) != Some(Visibility::Public) { return Some(strip_item(i)); } } clean::ModuleItem(..) => { - if i.item_id.is_local() && !i.visibility(self.tcx).is_public() { + if i.item_id.is_local() && i.visibility(self.tcx) != Some(Visibility::Public) { debug!("Stripper: stripping module {:?}", i.name); let old = mem::replace(&mut self.update_retained, false); let ret = strip_item(self.fold_item_recur(i)); @@ -246,7 +246,7 @@ impl<'tcx> DocFolder for ImportStripper<'tcx> { fn fold_item(&mut self, i: Item) -> Option { match *i.kind { clean::ExternCrateItem { .. } | clean::ImportItem(..) - if !i.visibility(self.tcx).is_public() => + if i.visibility(self.tcx) != Some(Visibility::Public) => { None } From 3583f2758b438a9274b6b7f00bf4e586058e55d9 Mon Sep 17 00:00:00 2001 From: Boxy Date: Thu, 3 Nov 2022 18:52:08 +0000 Subject: [PATCH 196/219] Cleanups --- compiler/rustc_hir_typeck/src/method/mod.rs | 3 +- compiler/rustc_hir_typeck/src/method/probe.rs | 1 - .../rustc_hir_typeck/src/method/suggest.rs | 136 +++++------------- compiler/rustc_middle/src/traits/mod.rs | 9 +- compiler/rustc_middle/src/ty/sty.rs | 7 + .../src/traits/on_unimplemented.rs | 1 + 6 files changed, 56 insertions(+), 101 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs index a1278edefbb..2c7b3bbf31c 100644 --- a/compiler/rustc_hir_typeck/src/method/mod.rs +++ b/compiler/rustc_hir_typeck/src/method/mod.rs @@ -55,8 +55,7 @@ pub enum MethodError<'tcx> { // not-in-scope traits which may work. PrivateMatch(DefKind, DefId, Vec), - // Found a `Self: Sized` bound where `Self` is a trait object, also the caller may have - // forgotten to import a trait. + // Found a `Self: Sized` bound where `Self` is a trait object. IllegalSizedBound(Vec, bool, Span), // Found a match, but the return type is wrong diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 28aa2302f88..e88701685bc 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -1019,7 +1019,6 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { let out_of_scope_traits = match self.pick_core() { Some(Ok(p)) => vec![p.item.container_id(self.tcx)], - //Some(Ok(p)) => p.iter().map(|p| p.item.container().id()).collect(), Some(Err(MethodError::Ambiguity(v))) => v .into_iter() .map(|source| match source { diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 6c21ed902d0..04ecd2757b4 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -248,7 +248,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match error { MethodError::NoMatch(NoMatchData { - static_candidates: mut static_sources, + mut static_candidates, unsatisfied_predicates, out_of_scope_traits, lev_candidate, @@ -288,9 +288,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if generics.len() > 0 { let mut autoderef = self.autoderef(span, actual); let candidate_found = autoderef.any(|(ty, _)| { - if let ty::Adt(adt_deref, _) = ty.kind() { + if let ty::Adt(adt_def, _) = ty.kind() { self.tcx - .inherent_impls(adt_deref.did()) + .inherent_impls(adt_def.did()) .iter() .filter_map(|def_id| self.associated_value(*def_id, item_name)) .count() @@ -348,15 +348,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let ty_span = match actual.kind() { - ty::Param(param_type) => { - let generics = self.tcx.generics_of(self.body_id.owner.to_def_id()); - let type_param = generics.type_param(param_type, self.tcx); - Some(self.tcx.def_span(type_param.def_id)) - } + ty::Param(param_type) => Some( + param_type.span_from_generics(self.tcx, self.body_id.owner.to_def_id()), + ), ty::Adt(def, _) if def.did().is_local() => Some(tcx.def_span(def.did())), _ => None, }; - if let Some(span) = ty_span { err.span_label( span, @@ -386,7 +383,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut custom_span_label = false; - if !static_sources.is_empty() { + if !static_candidates.is_empty() { err.note( "found the following associated functions; to be used as methods, \ functions must have a `self` parameter", @@ -394,9 +391,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.span_label(span, "this is an associated function, not a method"); custom_span_label = true; } - if static_sources.len() == 1 { + if static_candidates.len() == 1 { let ty_str = - if let Some(CandidateSource::Impl(impl_did)) = static_sources.get(0) { + if let Some(CandidateSource::Impl(impl_did)) = static_candidates.get(0) { // When the "method" is resolved through dereferencing, we really want the // original type that has the associated function for accurate suggestions. // (#61411) @@ -422,9 +419,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.help(&format!("try with `{}::{}`", ty_str, item_name,)); } - report_candidates(span, &mut err, &mut static_sources, sugg_span); - } else if static_sources.len() > 1 { - report_candidates(span, &mut err, &mut static_sources, sugg_span); + report_candidates(span, &mut err, &mut static_candidates, sugg_span); + } else if static_candidates.len() > 1 { + report_candidates(span, &mut err, &mut static_candidates, sugg_span); } let mut bound_spans = vec![]; @@ -496,24 +493,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let (ty::Param(_), ty::PredicateKind::Trait(p)) = (self_ty.kind(), parent_pred.kind().skip_binder()) { + let hir = self.tcx.hir(); let node = match p.trait_ref.self_ty().kind() { ty::Param(_) => { // Account for `fn` items like in `issue-35677.rs` to // suggest restricting its type params. - let did = self.tcx.hir().body_owner_def_id(hir::BodyId { - hir_id: self.body_id, - }); - Some( - self.tcx - .hir() - .get(self.tcx.hir().local_def_id_to_hir_id(did)), - ) + let parent_body = + hir.body_owner(hir::BodyId { hir_id: self.body_id }); + Some(hir.get(parent_body)) + } + ty::Adt(def, _) => { + def.did().as_local().map(|def_id| hir.get_by_def_id(def_id)) } - ty::Adt(def, _) => def.did().as_local().map(|def_id| { - self.tcx - .hir() - .get(self.tcx.hir().local_def_id_to_hir_id(def_id)) - }), _ => None, }; if let Some(hir::Node::Item(hir::Item { kind, .. })) = node { @@ -605,7 +596,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .iter() .filter_map(|(p, parent, c)| c.as_ref().map(|c| (p, parent, c))) .filter_map(|(p, parent, c)| match c.code() { - ObligationCauseCode::ImplDerivedObligation(ref data) => { + ObligationCauseCode::ImplDerivedObligation(data) => { Some((&data.derived, p, parent, data.impl_def_id, data)) } _ => None, @@ -620,22 +611,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match self.tcx.hir().get_if_local(impl_def_id) { // Unmet obligation comes from a `derive` macro, point at it once to // avoid multiple span labels pointing at the same place. - Some(Node::Item(hir::Item { - kind: hir::ItemKind::Trait(..), - ident, - .. - })) if matches!( - ident.span.ctxt().outer_expn_data().kind, - ExpnKind::Macro(MacroKind::Derive, _) - ) => - { - let span = ident.span.ctxt().outer_expn_data().call_site; - let mut spans: MultiSpan = span.into(); - spans.push_span_label(span, derive_msg); - let entry = spanned_predicates.entry(spans); - entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p); - } - Some(Node::Item(hir::Item { kind: hir::ItemKind::Impl(hir::Impl { of_trait, self_ty, .. }), .. @@ -659,34 +634,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p); } - // Unmet obligation coming from a `trait`. - Some(Node::Item(hir::Item { - kind: hir::ItemKind::Trait(..), - ident, - span: item_span, - .. - })) if !matches!( - ident.span.ctxt().outer_expn_data().kind, - ExpnKind::Macro(MacroKind::Derive, _) - ) => - { - if let Some(pred) = parent_p { - // Done to add the "doesn't satisfy" `span_label`. - let _ = format_pred(*pred); - } - skip_list.insert(p); - let mut spans = if cause.span != *item_span { - let mut spans: MultiSpan = cause.span.into(); - spans.push_span_label(cause.span, unsatisfied_msg); - spans - } else { - ident.span.into() - }; - spans.push_span_label(ident.span, "in this trait"); - let entry = spanned_predicates.entry(spans); - entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p); - } - // Unmet obligation coming from an `impl`. Some(Node::Item(hir::Item { kind: @@ -695,19 +642,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }), span: item_span, .. - })) if !matches!( - self_ty.span.ctxt().outer_expn_data().kind, - ExpnKind::Macro(MacroKind::Derive, _) - ) && !matches!( - of_trait.as_ref().map(|t| t - .path - .span - .ctxt() - .outer_expn_data() - .kind), - Some(ExpnKind::Macro(MacroKind::Derive, _)) - ) => - { + })) => { let sized_pred = unsatisfied_predicates.iter().any(|(pred, _, _)| { match pred.kind().skip_binder() { @@ -759,7 +694,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let entry = spanned_predicates.entry(spans); entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p); } - _ => {} + Some(_) => unreachable!(), + None => (), } } let mut spanned_predicates: Vec<_> = spanned_predicates.into_iter().collect(); @@ -863,7 +799,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .on_unimplemented_note(trait_ref, &obligation); (message, label) }) - .unwrap_or((None, None)) + .unwrap() } else { (None, None) }; @@ -972,7 +908,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // If the method name is the name of a field with a function or closure type, // give a helping note that it has to be called as `(x.f)(...)`. if let SelfSource::MethodCall(expr) = source { - if !self.suggest_field_call(span, rcvr_ty, expr, item_name, &mut err) + if !self.suggest_calling_field_as_fn(span, rcvr_ty, expr, item_name, &mut err) && lev_candidate.is_none() && !custom_span_label { @@ -982,10 +918,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { label_span_not_found(&mut err); } - // Don't suggest (for example) `expr.field.method()` if `expr.method()` - // doesn't exist due to unsatisfied predicates. + // Don't suggest (for example) `expr.field.clone()` if `expr.clone()` + // can't be called due to `typeof(expr): Clone` not holding. if unsatisfied_predicates.is_empty() { - self.check_for_field_method(&mut err, source, span, actual, item_name); + self.suggest_calling_method_on_field(&mut err, source, span, actual, item_name); } self.check_for_inner_self(&mut err, source, span, actual, item_name); @@ -1007,7 +943,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { source, out_of_scope_traits, &unsatisfied_predicates, - &static_sources, + &static_candidates, unsatisfied_bounds, ); } @@ -1146,7 +1082,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None } - fn suggest_field_call( + /// Suggest calling a field with a type that implements the `Fn*` traits instead of a method with + /// the same name as the field i.e. `(a.my_fn_ptr)(10)` instead of `a.my_fn_ptr(10)`. + fn suggest_calling_field_as_fn( &self, span: Span, rcvr_ty: Ty<'tcx>, @@ -1408,7 +1346,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { false } - fn check_for_field_method( + /// Suggest calling a method on a field i.e. `a.field.bar()` instead of `a.bar()` + fn suggest_calling_method_on_field( &self, err: &mut Diagnostic, source: SelfSource<'tcx>, @@ -2021,7 +1960,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { let mut alt_rcvr_sugg = false; if let (SelfSource::MethodCall(rcvr), false) = (source, unsatisfied_bounds) { - debug!(?span, ?item_name, ?rcvr_ty, ?rcvr); + debug!( + "suggest_traits_to_import: span={:?}, item_name={:?}, rcvr_ty={:?}, rcvr={:?}", + span, item_name, rcvr_ty, rcvr + ); let skippable = [ self.tcx.lang_items().clone_trait(), self.tcx.lang_items().deref_trait(), @@ -2060,7 +2002,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // suggestions are generally misleading (see #94218). break; } - _ => {} + Err(_) => (), } for (rcvr_ty, pre) in &[ diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index e73d44bbb36..07ee758b32c 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -203,13 +203,20 @@ pub struct UnifyReceiverContext<'tcx> { pub substs: SubstsRef<'tcx>, } -#[derive(Clone, Debug, PartialEq, Eq, Hash, Lift, Default)] +#[derive(Clone, PartialEq, Eq, Hash, Lift, Default)] pub struct InternedObligationCauseCode<'tcx> { /// `None` for `ObligationCauseCode::MiscObligation` (a common case, occurs ~60% of /// the time). `Some` otherwise. code: Option>>, } +impl<'tcx> std::fmt::Debug for InternedObligationCauseCode<'tcx> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let cause: &ObligationCauseCode<'_> = self; + cause.fmt(f) + } +} + impl<'tcx> ObligationCauseCode<'tcx> { #[inline(always)] fn into(self) -> InternedObligationCauseCode<'tcx> { diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index cf420bafeb1..5f108bf0ef3 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -20,6 +20,7 @@ use rustc_hir::def_id::DefId; use rustc_index::vec::Idx; use rustc_macros::HashStable; use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::Span; use rustc_target::abi::VariantIdx; use rustc_target::spec::abi; use std::borrow::Cow; @@ -1282,6 +1283,12 @@ impl<'tcx> ParamTy { pub fn to_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { tcx.mk_ty_param(self.index, self.name) } + + pub fn span_from_generics(&self, tcx: TyCtxt<'tcx>, item_with_generics: DefId) -> Span { + let generics = tcx.generics_of(item_with_generics); + let type_param = generics.type_param(self, tcx); + tcx.def_span(type_param.def_id) + } } #[derive(Copy, Clone, Hash, TyEncodable, TyDecodable, Eq, PartialEq, Ord, PartialOrd)] diff --git a/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs index 4a4f34b7680..fb062ea71c4 100644 --- a/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs @@ -27,6 +27,7 @@ pub struct OnUnimplementedDirective { } #[derive(Default)] +/// For the `#[rustc_on_unimplemented]` attribute pub struct OnUnimplementedNote { pub message: Option, pub label: Option, From a777c46dff4fdb54e29a19e273d8677d485232e6 Mon Sep 17 00:00:00 2001 From: Charles Lew Date: Fri, 4 Nov 2022 03:02:09 +0800 Subject: [PATCH 197/219] Use `derive(Subdiagnostic)` for `ChangeFieldsToBeOfUnitType`. --- .../locales/en-US/passes.ftl | 3 +-- compiler/rustc_passes/src/errors.rs | 26 +++---------------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/compiler/rustc_error_messages/locales/en-US/passes.ftl b/compiler/rustc_error_messages/locales/en-US/passes.ftl index a5b002fa357..a7cb9f14e82 100644 --- a/compiler/rustc_error_messages/locales/en-US/passes.ftl +++ b/compiler/rustc_error_messages/locales/en-US/passes.ftl @@ -685,8 +685,7 @@ passes_change_fields_to_be_of_unit_type = consider changing the { $num -> [one] field *[other] fields - } to be of unit type to suppress this warning - while preserving the field numbering, or remove the { $num -> + } to be of unit type to suppress this warning while preserving the field numbering, or remove the { $num -> [one] field *[other] fields } diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index d39d7629b28..83a51bcd097 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -12,8 +12,6 @@ use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_middle::ty::{MainDefinition, Ty}; use rustc_span::{Span, Symbol, DUMMY_SP}; -use rustc_errors::{pluralize, AddToDiagnostic, Diagnostic, SubdiagnosticMessage}; - use crate::lang_items::Duplicate; #[derive(LintDiagnostic)] @@ -1502,28 +1500,10 @@ pub struct IgnoredDerivedImpls { pub trait_list_len: usize, } +#[derive(Subdiagnostic)] +#[multipart_suggestion(passes_change_fields_to_be_of_unit_type, applicability = "has-placeholders")] pub struct ChangeFieldsToBeOfUnitType { pub num: usize, + #[suggestion_part(code = "()")] pub spans: Vec, } - -// FIXME: Replace this impl with a derive. -impl AddToDiagnostic for ChangeFieldsToBeOfUnitType { - fn add_to_diagnostic_with(self, diag: &mut Diagnostic, _: F) - where - F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage, - { - diag.multipart_suggestion( - &format!( - "consider changing the field{s} to be of unit type to \ - suppress this warning while preserving the field \ - numbering, or remove the field{s}", - s = pluralize!(self.num) - ), - self.spans.iter().map(|sp| (*sp, "()".to_string())).collect(), - // "HasPlaceholders" because applying this fix by itself isn't - // enough: All constructor calls have to be adjusted as well - Applicability::HasPlaceholders, - ); - } -} From f097940da8f282b6503c5f37fd449652de285578 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 3 Nov 2022 12:29:17 -0700 Subject: [PATCH 198/219] rustdoc: clean up hardcoded CSS border color on search results Hardcoded colors in rustdoc.css should usually be avoided. --- src/librustdoc/html/static/css/rustdoc.css | 3 +-- src/test/rustdoc-gui/search-result-color.goml | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index d6f2b02afd8..0a9814ee28b 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -894,7 +894,7 @@ so that we can apply CSS-filters to change the arrow color in themes */ /* A little margin ensures the browser's outlining of focused links has room to display. */ margin-left: 2px; margin-right: 2px; - border-bottom: 1px solid #aaa3; + border-bottom: 1px solid var(--border-color); } .search-results > a > div { @@ -1875,7 +1875,6 @@ in storage.js /* Display an alternating layout on tablets and phones */ .search-results > a { - border-bottom: 1px solid #aaa9; padding: 5px 0px; } .search-results .result-name, .search-results div.desc { diff --git a/src/test/rustdoc-gui/search-result-color.goml b/src/test/rustdoc-gui/search-result-color.goml index 69bb30df954..37d7b03a099 100644 --- a/src/test/rustdoc-gui/search-result-color.goml +++ b/src/test/rustdoc-gui/search-result-color.goml @@ -75,6 +75,12 @@ assert-css: ( {"color": "rgb(0, 150, 207)"}, ) +// Checking the color of the bottom border. +assert-css: ( + ".search-results > a", + {"border-bottom-color": "rgb(92, 103, 115)"} +) + // Checking the color of "keyword" text. assert-css: ( "//*[@class='result-name']//*[text()='(keyword)']", @@ -181,6 +187,12 @@ assert-css: ( {"color": "rgb(221, 221, 221)"}, ) +// Checking the color of the bottom border. +assert-css: ( + ".search-results > a", + {"border-bottom-color": "rgb(224, 224, 224)"} +) + // Checking the color for "keyword" text. assert-css: ( "//*[@class='result-name']//*[text()='(keyword)']", @@ -272,6 +284,12 @@ assert-css: ( {"color": "rgb(0, 0, 0)"}, ) +// Checking the color of the bottom border. +assert-css: ( + ".search-results > a", + {"border-bottom-color": "rgb(224, 224, 224)"} +) + // Checking the color for "keyword" text. assert-css: ( "//*[@class='result-name']//*[text()='(keyword)']", From c51c07d30fbaa813775168bb01a678c0813a0b93 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 3 Nov 2022 13:22:54 -0700 Subject: [PATCH 199/219] rustdoc: remove no-op CSS `#main-content > .item-info { margin-top: 0 }` When this line was added in 04b4c40682c01cad8f9bc8d5b3907be91d6f81d4, it overrode a negative `margin-top` that was set on it by default. https://github.com/rust-lang/rust/blob/04b4c40682c01cad8f9bc8d5b3907be91d6f81d4/src/librustdoc/html/static/rustdoc.css#L500-L516 That negative top margin was removed in 593d6d1cb15c55c88319470dabb40126c7b7f1e2. --- src/librustdoc/html/static/css/rustdoc.css | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index d6f2b02afd8..ce9f0f4ae19 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -677,7 +677,6 @@ pre, .rustdoc.source .example-wrap { } #main-content > .item-info { - margin-top: 0; margin-left: 0; } From f65cb6868ddf7258bd153f2d02906c10abbb1a90 Mon Sep 17 00:00:00 2001 From: Douwe Schulte Date: Thu, 3 Nov 2022 21:19:02 +0000 Subject: [PATCH 200/219] Fixed typos Fixed a typo that has been found on two locations in comments. --- library/alloc/src/vec/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index bbbdc3aa2a2..834c8f58cb2 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -2588,7 +2588,7 @@ impl ExtendFromWithinSpec for Vec { let (this, spare, len) = unsafe { self.split_at_spare_mut_with_len() }; // SAFETY: - // - caller guaratees that src is a valid index + // - caller guarantees that src is a valid index let to_clone = unsafe { this.get_unchecked(src) }; iter::zip(to_clone, spare) @@ -2607,7 +2607,7 @@ impl ExtendFromWithinSpec for Vec { let (init, spare) = self.split_at_spare_mut(); // SAFETY: - // - caller guaratees that `src` is a valid index + // - caller guarantees that `src` is a valid index let source = unsafe { init.get_unchecked(src) }; // SAFETY: From e7bae89a3c739556c90758a5d73fc9565e9efdc8 Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Wed, 2 Nov 2022 12:18:00 -0500 Subject: [PATCH 201/219] Cleanup bind_pattern args --- .../rustc_mir_build/src/build/matches/mod.rs | 51 +++++-------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 3f813e0af0d..dfd8649cb97 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -364,12 +364,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let arm_block = this.bind_pattern( outer_source_info, candidate, - arm.guard.as_ref(), &fake_borrow_temps, scrutinee_span, - Some(arm.span), - Some(arm.scope), - Some(match_scope), + Some((arm, match_scope)), false, ); @@ -410,12 +407,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &mut self, outer_source_info: SourceInfo, candidate: Candidate<'_, 'tcx>, - guard: Option<&Guard<'tcx>>, fake_borrow_temps: &[(Place<'tcx>, Local)], scrutinee_span: Span, - arm_span: Option, - arm_scope: Option, - match_scope: Option, + arm_match_scope: Option<(&Arm<'tcx>, region::Scope)>, storages_alive: bool, ) -> BasicBlock { if candidate.subcandidates.is_empty() { @@ -424,11 +418,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.bind_and_guard_matched_candidate( candidate, &[], - guard, fake_borrow_temps, scrutinee_span, - arm_span, - match_scope, + arm_match_scope, true, storages_alive, ) @@ -449,6 +441,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // we lower the guard. let target_block = self.cfg.start_new_block(); let mut schedule_drops = true; + let arm = arm_match_scope.unzip().0; // We keep a stack of all of the bindings and type ascriptions // from the parent candidates that we visit, that also need to // be bound for each candidate. @@ -456,21 +449,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { candidate, &mut Vec::new(), &mut |leaf_candidate, parent_bindings| { - if let Some(arm_scope) = arm_scope { - self.clear_top_scope(arm_scope); + if let Some(arm) = arm { + self.clear_top_scope(arm.scope); } let binding_end = self.bind_and_guard_matched_candidate( leaf_candidate, parent_bindings, - guard, &fake_borrow_temps, scrutinee_span, - arm_span, - match_scope, + arm_match_scope, schedule_drops, storages_alive, ); - if arm_scope.is_none() { + if arm.is_none() { schedule_drops = false; } self.cfg.goto(binding_end, outer_source_info, target_block); @@ -636,12 +627,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.bind_pattern( self.source_info(irrefutable_pat.span), candidate, - None, &fake_borrow_temps, irrefutable_pat.span, None, - None, - None, false, ) .unit() @@ -1820,12 +1808,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let post_guard_block = self.bind_pattern( self.source_info(pat.span), guard_candidate, - None, &fake_borrow_temps, expr.span, None, - None, - None, false, ); @@ -1844,11 +1829,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &mut self, candidate: Candidate<'pat, 'tcx>, parent_bindings: &[(Vec>, Vec>)], - guard: Option<&Guard<'tcx>>, fake_borrows: &[(Place<'tcx>, Local)], scrutinee_span: Span, - arm_span: Option, - match_scope: Option, + arm_match_scope: Option<(&Arm<'tcx>, region::Scope)>, schedule_drops: bool, storages_alive: bool, ) -> BasicBlock { @@ -1960,7 +1943,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // the reference that we create for the arm. // * So we eagerly create the reference for the arm and then take a // reference to that. - if let Some(guard) = guard { + if let Some((arm, match_scope)) = arm_match_scope + && let Some(guard) = &arm.guard + { let tcx = self.tcx; let bindings = parent_bindings .iter() @@ -1981,8 +1966,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.cfg.push_assign(block, scrutinee_source_info, Place::from(temp), borrow); } - let arm_span = arm_span.unwrap(); - let match_scope = match_scope.unwrap(); let mut guard_span = rustc_span::DUMMY_SP; let (post_guard_block, otherwise_post_guard_block) = @@ -1995,13 +1978,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { e, None, match_scope, - this.source_info(arm_span), + this.source_info(arm.span), ) } Guard::IfLet(ref pat, scrutinee) => { let s = &this.thir[scrutinee]; guard_span = s.span; - this.lower_let_expr(block, s, pat, match_scope, None, arm_span) + this.lower_let_expr(block, s, pat, match_scope, None, arm.span) } }); @@ -2317,24 +2300,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let matching = this.bind_pattern( this.source_info(pattern.span), candidate, - None, &fake_borrow_temps, initializer_span, None, - None, - None, true, ); // This block is for the failure case let failure = this.bind_pattern( this.source_info(else_block_span), wildcard, - None, &fake_borrow_temps, initializer_span, None, - None, - None, true, ); this.break_for_else(failure, *let_else_scope, this.source_info(initializer_span)); From 1013ee8df512015855937615500690664399545f Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Fri, 4 Nov 2022 03:08:28 +0000 Subject: [PATCH 202/219] Fix ICE when negative impl is collected during eager mono --- compiler/rustc_monomorphize/src/collector.rs | 4 ++++ src/test/ui/traits/negative-impls/eager-mono.rs | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/test/ui/traits/negative-impls/eager-mono.rs diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 3cfddd75462..58ddb807059 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1336,6 +1336,10 @@ fn create_mono_items_for_default_impls<'tcx>( ) { match item.kind { hir::ItemKind::Impl(ref impl_) => { + if matches!(impl_.polarity, hir::ImplPolarity::Negative(_)) { + return; + } + for param in impl_.generics.params { match param.kind { hir::GenericParamKind::Lifetime { .. } => {} diff --git a/src/test/ui/traits/negative-impls/eager-mono.rs b/src/test/ui/traits/negative-impls/eager-mono.rs new file mode 100644 index 00000000000..ce770376c0b --- /dev/null +++ b/src/test/ui/traits/negative-impls/eager-mono.rs @@ -0,0 +1,12 @@ +// build-pass +// compile-flags:-C link-dead-code=y + +#![feature(negative_impls)] + +trait Foo { + fn foo() {} +} + +impl !Foo for () {} + +fn main() {} From 97ddc6343afd1f3f916d57a5c0e8fc4467c760da Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Fri, 4 Nov 2022 13:59:04 +0900 Subject: [PATCH 203/219] remove unused argument from `throw_unresolved_import_error` --- compiler/rustc_resolve/src/imports.rs | 28 ++++++++++----------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index f2cc50c199f..44965dd6db8 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -450,7 +450,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> { { // In the case of a new import line, throw a diagnostic message // for the previous line. - self.throw_unresolved_import_error(errors, None); + self.throw_unresolved_import_error(errors); errors = vec![]; } if seen_spans.insert(err.span) { @@ -482,29 +482,21 @@ impl<'a, 'b> ImportResolver<'a, 'b> { } if !errors.is_empty() { - self.throw_unresolved_import_error(errors, None); + self.throw_unresolved_import_error(errors); } } - fn throw_unresolved_import_error( - &self, - errors: Vec<(String, UnresolvedImportError)>, - span: Option, - ) { + fn throw_unresolved_import_error(&self, errors: Vec<(String, UnresolvedImportError)>) { + if errors.is_empty() { + return; + } + /// Upper limit on the number of `span_label` messages. const MAX_LABEL_COUNT: usize = 10; - let (span, msg) = if errors.is_empty() { - (span.unwrap(), "unresolved import".to_string()) - } else { - let span = MultiSpan::from_spans(errors.iter().map(|(_, err)| err.span).collect()); - - let paths = errors.iter().map(|(path, _)| format!("`{}`", path)).collect::>(); - - let msg = format!("unresolved import{} {}", pluralize!(paths.len()), paths.join(", "),); - - (span, msg) - }; + let span = MultiSpan::from_spans(errors.iter().map(|(_, err)| err.span).collect()); + let paths = errors.iter().map(|(path, _)| format!("`{}`", path)).collect::>(); + let msg = format!("unresolved import{} {}", pluralize!(paths.len()), paths.join(", "),); let mut diag = struct_span_err!(self.r.session, span, E0432, "{}", &msg); From 4c80f50fc6dce4e35eebe1beaadd5fc3ecfe6f52 Mon Sep 17 00:00:00 2001 From: Jhonny Bill Mena Date: Sun, 30 Oct 2022 15:38:37 -0400 Subject: [PATCH 204/219] UPDATE - Complete link.rs migration to new diagnostics infraestructure --- compiler/rustc_codegen_ssa/src/back/link.rs | 123 ++++++----------- compiler/rustc_codegen_ssa/src/errors.rs | 130 ++++++++++++++++++ .../locales/en-US/codegen_ssa.ftl | 51 +++++++ compiler/rustc_errors/src/diagnostic_impls.rs | 4 +- 4 files changed, 227 insertions(+), 81 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 0dc0dee862c..4c58d0b53f0 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -919,29 +919,17 @@ fn link_natively<'a>( ) .is_some(); - sess.note_without_error("`link.exe` returned an unexpected error"); + sess.emit_note(errors::LinkExeUnexpectedError); if is_vs_installed && has_linker { // the linker is broken - sess.note_without_error( - "the Visual Studio build tools may need to be repaired \ - using the Visual Studio installer", - ); - sess.note_without_error( - "or a necessary component may be missing from the \ - \"C++ build tools\" workload", - ); + sess.emit_note(errors::RepairVSBuildTools); + sess.emit_note(errors::MissingCppBuildToolComponent); } else if is_vs_installed { // the linker is not installed - sess.note_without_error( - "in the Visual Studio installer, ensure the \ - \"C++ build tools\" workload is selected", - ); + sess.emit_note(errors::SelectCppBuildToolWorkload); } else { // visual studio is not installed - sess.note_without_error( - "you may need to install Visual Studio build tools with the \ - \"C++ build tools\" workload", - ); + sess.emit_note(errors::VisualStudioNotInstalled); } } } @@ -954,35 +942,20 @@ fn link_natively<'a>( Err(e) => { let linker_not_found = e.kind() == io::ErrorKind::NotFound; - let mut linker_error = { - if linker_not_found { - sess.struct_err(&format!("linker `{}` not found", linker_path.display())) - } else { - sess.struct_err(&format!( - "could not exec the linker `{}`", - linker_path.display() - )) - } - }; - - linker_error.note(&e.to_string()); - - if !linker_not_found { - linker_error.note(&format!("{:?}", &cmd)); + if linker_not_found { + sess.emit_err(errors::LinkerNotFound { linker_path, error: e }); + } else { + sess.emit_err(errors::UnableToExeLinker { + linker_path, + error: e, + command_formatted: format!("{:?}", &cmd), + }); } - linker_error.emit(); - if sess.target.is_like_msvc && linker_not_found { - sess.note_without_error( - "the msvc targets depend on the msvc linker \ - but `link.exe` was not found", - ); - sess.note_without_error( - "please ensure that Visual Studio 2017 or later, or Build Tools \ - for Visual Studio were installed with the Visual C++ option.", - ); - sess.note_without_error("VS Code is a different product, and is not sufficient."); + sess.emit_note(errors::MsvcMissingLinker); + sess.emit_note(errors::CheckInstalledVisualStudio); + sess.emit_note(errors::UnsufficientVSCodeProduct); } sess.abort_if_errors(); } @@ -1007,15 +980,13 @@ fn link_natively<'a>( if !prog.status.success() { let mut output = prog.stderr.clone(); output.extend_from_slice(&prog.stdout); - sess.struct_warn(&format!( - "processing debug info with `dsymutil` failed: {}", - prog.status - )) - .note(&escape_string(&output)) - .emit(); + sess.emit_warning(errors::ProcessingDymutilFailed { + status: prog.status, + output: escape_string(&output), + }); } } - Err(e) => sess.fatal(&format!("unable to run `dsymutil`: {}", e)), + Err(error) => sess.emit_fatal(errors::UnableToRunDsymutil { error }), } } @@ -1092,21 +1063,21 @@ fn strip_symbols_with_external_utility<'a>( if !prog.status.success() { let mut output = prog.stderr.clone(); output.extend_from_slice(&prog.stdout); - sess.struct_warn(&format!( - "stripping debug info with `{}` failed: {}", - util, prog.status - )) - .note(&escape_string(&output)) - .emit(); + sess.emit_warning(errors::StrippingDebuInfoFailed { + util, + status: prog.status, + output: escape_string(&output), + }); } } - Err(e) => sess.fatal(&format!("unable to run `{}`: {}", util, e)), + Err(error) => sess.emit_fatal(errors::UnableToRun { util, error }), } } fn escape_string(s: &[u8]) -> String { match str::from_utf8(s) { Ok(s) => s.to_owned(), + // FIXME: return a type that can conform to IntoDiagnosticArg Err(_) => format!("Non-UTF-8 output: {}", s.escape_ascii()), } } @@ -1251,7 +1222,7 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { )), (Some(linker), None) => { let stem = linker.file_stem().and_then(|stem| stem.to_str()).unwrap_or_else(|| { - sess.fatal("couldn't extract file stem from specified linker") + sess.emit_fatal(errors::LinkerFileStem); }); let flavor = if stem == "emcc" { @@ -1378,13 +1349,9 @@ fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLib]) { }) .collect(); if !lib_args.is_empty() { - sess.note_without_error( - "Link against the following native artifacts when linking \ - against this static library. The order and any duplication \ - can be significant on some platforms.", - ); + sess.emit_note(errors::StaticLibraryNativeArtifacts); // Prefix for greppability - sess.note_without_error(&format!("native-static-libs: {}", &lib_args.join(" "))); + sess.emit_note(errors::NativeStaticLibs { arguments: lib_args.join(" ") }); } } @@ -1688,14 +1655,14 @@ fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_ty match (crate_type, &sess.target.link_script) { (CrateType::Cdylib | CrateType::Executable, Some(script)) => { if !sess.target.linker_flavor.is_gnu() { - sess.fatal("can only use link script when linking with GNU-like linker"); + sess.emit_fatal(errors::LinkScriptUnavailable); } let file_name = ["rustc", &sess.target.llvm_target, "linkfile.ld"].join("-"); let path = tmpdir.join(file_name); - if let Err(e) = fs::write(&path, script.as_ref()) { - sess.fatal(&format!("failed to write link script to {}: {}", path.display(), e)); + if let Err(error) = fs::write(&path, script.as_ref()) { + sess.emit_fatal(errors::LinkScriptWriteFailure { path, error }); } cmd.arg("--script"); @@ -1841,8 +1808,8 @@ fn add_linked_symbol_object( let path = tmpdir.join("symbols.o"); let result = std::fs::write(&path, file.write().unwrap()); - if let Err(e) = result { - sess.fatal(&format!("failed to write {}: {}", path.display(), e)); + if let Err(error) = result { + sess.emit_fatal(errors::FailedToWrite { path, error }); } cmd.add_object(&path); } @@ -2299,14 +2266,10 @@ fn collect_natvis_visualizers( visualizer_paths.push(visualizer_out_file); } Err(error) => { - sess.warn( - format!( - "Unable to write debugger visualizer file `{}`: {} ", - visualizer_out_file.display(), - error - ) - .as_str(), - ); + sess.emit_warning(errors::UnableToWriteDebuggerVisualizer { + path: visualizer_out_file, + error, + }); } }; } @@ -2641,7 +2604,7 @@ fn add_upstream_rust_crates<'a>( || !codegen_results.crate_info.is_no_builtins.contains(&cnum); let mut archive = archive_builder_builder.new_archive_builder(sess); - if let Err(e) = archive.add_archive( + if let Err(error) = archive.add_archive( cratepath, Box::new(move |f| { if f == METADATA_FILENAME { @@ -2681,7 +2644,7 @@ fn add_upstream_rust_crates<'a>( false }), ) { - sess.fatal(&format!("failed to build archive from rlib: {}", e)); + sess.emit_fatal(errors::RlibArchiveBuildFailure { error }); } if archive.build(&dst) { link_upstream(&dst); @@ -2919,7 +2882,7 @@ fn add_gcc_ld_path(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { } } } else { - sess.fatal("option `-Z gcc-ld` is used even though linker flavor is not gcc"); + sess.emit_fatal(errors::OptionGccOnly); } } } diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs index ebb531f1c43..71fac123725 100644 --- a/compiler/rustc_codegen_ssa/src/errors.rs +++ b/compiler/rustc_codegen_ssa/src/errors.rs @@ -354,3 +354,133 @@ impl IntoDiagnostic<'_> for LinkingFailed<'_> { diag } } + +#[derive(Diagnostic)] +#[diag(codegen_ssa_link_exe_unexpected_error)] +pub struct LinkExeUnexpectedError; + +#[derive(Diagnostic)] +#[diag(codegen_ssa_repair_vs_build_tools)] +pub struct RepairVSBuildTools; + +#[derive(Diagnostic)] +#[diag(codegen_ssa_missing_cpp_build_tool_component)] +pub struct MissingCppBuildToolComponent; + +#[derive(Diagnostic)] +#[diag(codegen_ssa_select_cpp_build_tool_workload)] +pub struct SelectCppBuildToolWorkload; + +#[derive(Diagnostic)] +#[diag(codegen_ssa_visual_studio_not_installed)] +pub struct VisualStudioNotInstalled; + +#[derive(Diagnostic)] +#[diag(codegen_ssa_linker_not_found)] +#[note] +pub struct LinkerNotFound { + pub linker_path: PathBuf, + pub error: Error, +} + +#[derive(Diagnostic)] +#[diag(codegen_ssa_unable_to_exe_linker)] +#[note] +#[note(command_note)] +pub struct UnableToExeLinker { + pub linker_path: PathBuf, + pub error: Error, + pub command_formatted: String, +} + +#[derive(Diagnostic)] +#[diag(codegen_ssa_msvc_missing_linker)] +pub struct MsvcMissingLinker; + +#[derive(Diagnostic)] +#[diag(codegen_ssa_check_installed_visual_studio)] +pub struct CheckInstalledVisualStudio; + +#[derive(Diagnostic)] +#[diag(codegen_ssa_unsufficient_vs_code_product)] +pub struct UnsufficientVSCodeProduct; + +#[derive(Diagnostic)] +#[diag(codegen_ssa_processing_dymutil_failed)] +#[note] +pub struct ProcessingDymutilFailed { + pub status: ExitStatus, + pub output: String, +} + +#[derive(Diagnostic)] +#[diag(codegen_ssa_unable_to_run_dsymutil)] +#[note] +pub struct UnableToRunDsymutil { + pub error: Error, +} + +#[derive(Diagnostic)] +#[diag(codegen_ssa_stripping_debu_info_failed)] +#[note] +pub struct StrippingDebuInfoFailed<'a> { + pub util: &'a str, + pub status: ExitStatus, + pub output: String, +} + +#[derive(Diagnostic)] +#[diag(codegen_ssa_unable_to_run)] +pub struct UnableToRun<'a> { + pub util: &'a str, + pub error: Error, +} + +#[derive(Diagnostic)] +#[diag(codegen_ssa_linker_file_stem)] +pub struct LinkerFileStem; + +#[derive(Diagnostic)] +#[diag(codegen_ssa_static_library_native_artifacts)] +pub struct StaticLibraryNativeArtifacts; + +#[derive(Diagnostic)] +#[diag(codegen_ssa_native_static_libs)] +pub struct NativeStaticLibs { + pub arguments: String, +} + +#[derive(Diagnostic)] +#[diag(codegen_ssa_link_script_unavailable)] +pub struct LinkScriptUnavailable; + +#[derive(Diagnostic)] +#[diag(codegen_ssa_link_script_write_failure)] +pub struct LinkScriptWriteFailure { + pub path: PathBuf, + pub error: Error, +} + +#[derive(Diagnostic)] +#[diag(codegen_ssa_failed_to_write)] +pub struct FailedToWrite { + pub path: PathBuf, + pub error: Error, +} + +#[derive(Diagnostic)] +#[diag(codegen_ssa_unable_to_write_debugger_visualizer)] +pub struct UnableToWriteDebuggerVisualizer { + pub path: PathBuf, + pub error: Error, +} + +#[derive(Diagnostic)] +#[diag(codegen_ssa_rlib_archive_build_failure)] +pub struct RlibArchiveBuildFailure { + pub error: Error, +} + +#[derive(Diagnostic)] +#[diag(codegen_ssa_option_gcc_only)] +pub struct OptionGccOnly; diff --git a/compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl b/compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl index 966a421bcf0..2e5c72ee645 100644 --- a/compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl +++ b/compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl @@ -119,3 +119,54 @@ codegen_ssa_thorin_object_read = {$error} codegen_ssa_thorin_object_write = {$error} codegen_ssa_thorin_gimli_read = {$error} codegen_ssa_thorin_gimli_write = {$error} + +codegen_ssa_link_exe_unexpected_error = `link.exe` returned an unexpected error + +codegen_ssa_repair_vs_build_tools = the Visual Studio build tools may need to be repaired using the Visual Studio installer + +codegen_ssa_missing_cpp_build_tool_component = or a necessary component may be missing from the "C++ build tools" workload + +codegen_ssa_select_cpp_build_tool_workload = in the Visual Studio installer, ensure the "C++ build tools" workload is selected + +codegen_ssa_visual_studio_not_installed = you may need to install Visual Studio build tools with the "C++ build tools" workload + +codegen_ssa_linker_not_found = linker `{$linker_path}` not found + .note = {$error} + +codegen_ssa_unable_to_exe_linker = could not exec the linker `{$linker_path}` + .note = {$error} + .command_note = {$command_formatted} + +codegen_ssa_msvc_missing_linker = the msvc targets depend on the msvc linker but `link.exe` was not found + +codegen_ssa_check_installed_visual_studio = please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option. + +codegen_ssa_unsufficient_vs_code_product = VS Code is a different product, and is not sufficient. + +codegen_ssa_processing_dymutil_failed = processing debug info with `dsymutil` failed: {$status} + .note = {$output} + +codegen_ssa_unable_to_run_dsymutil = unable to run `dsymutil`: {$error} + +codegen_ssa_stripping_debu_info_failed = stripping debug info with `{$util}` failed: {$status} + .note = {$output} + +codegen_ssa_unable_to_run = unable to run `{$util}`: {$error} + +codegen_ssa_linker_file_stem = couldn't extract file stem from specified linker + +codegen_ssa_static_library_native_artifacts = Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms. + +codegen_ssa_native_static_libs = native-static-libs: {$arguments} + +codegen_ssa_link_script_unavailable = can only use link script when linking with GNU-like linker + +codegen_ssa_link_script_write_failure = failed to write link script to {$path}: {$error} + +codegen_ssa_failed_to_write = failed to write {$path}: {$error} + +codegen_ssa_unable_to_write_debugger_visualizer = Unable to write debugger visualizer file `{$path}`: {$error} + +codegen_ssa_rlib_archive_build_failure = failed to build archive from rlib: {$error} + +codegen_ssa_option_gcc_only = option `-Z gcc-ld` is used even though linker flavor is not gcc diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index 7640b2919f7..4f32e236b2d 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -13,6 +13,7 @@ use std::borrow::Cow; use std::fmt; use std::num::ParseIntError; use std::path::{Path, PathBuf}; +use std::process::ExitStatus; pub struct DiagnosticArgFromDisplay<'a>(pub &'a dyn fmt::Display); @@ -66,7 +67,8 @@ into_diagnostic_arg_using_display!( ParseIntError, StackProtector, &TargetTriple, - SplitDebuginfo + SplitDebuginfo, + ExitStatus, ); impl IntoDiagnosticArg for bool { From 1f4c5a624fd7db58b32d6d9cfa063fbfe0a340a7 Mon Sep 17 00:00:00 2001 From: Jhonny Bill Mena Date: Mon, 31 Oct 2022 01:36:32 -0400 Subject: [PATCH 205/219] ADD - ExtractBundledLibsError. Migrated extract_bundled_libs to translatable diagnostics --- .../rustc_codegen_ssa/src/back/archive.rs | 59 +++++++++++++------ compiler/rustc_codegen_ssa/src/back/link.rs | 2 +- compiler/rustc_codegen_ssa/src/errors.rs | 48 +++++++++++++++ .../locales/en-US/codegen_ssa.ftl | 8 +++ 4 files changed, 98 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index bb76ca5d2b9..b45fa247687 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -6,11 +6,12 @@ use rustc_span::symbol::Symbol; use object::read::archive::ArchiveFile; -use std::fmt::Display; use std::fs::File; use std::io; use std::path::{Path, PathBuf}; +use crate::errors::{ExtractBundledLibsError, ExtractBundledLibsErrorKind::*}; + pub trait ArchiveBuilderBuilder { fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box + 'a>; @@ -28,32 +29,54 @@ pub trait ArchiveBuilderBuilder { is_direct_dependency: bool, ) -> PathBuf; - fn extract_bundled_libs( - &self, - rlib: &Path, + fn extract_bundled_libs<'a>( + &'a self, + rlib: &'a Path, outdir: &Path, bundled_lib_file_names: &FxHashSet, - ) -> Result<(), String> { - let message = |msg: &str, e: &dyn Display| format!("{} '{}': {}", msg, &rlib.display(), e); + ) -> Result<(), ExtractBundledLibsError<'_>> { let archive_map = unsafe { - Mmap::map(File::open(rlib).map_err(|e| message("failed to open file", &e))?) - .map_err(|e| message("failed to mmap file", &e))? + Mmap::map(File::open(rlib).map_err(|e| ExtractBundledLibsError { + kind: OpenFile, + rlib, + error: e.to_string(), + })?) + .map_err(|e| ExtractBundledLibsError { + kind: MmapFile, + rlib, + error: e.to_string(), + })? }; - let archive = ArchiveFile::parse(&*archive_map) - .map_err(|e| message("failed to parse archive", &e))?; + let archive = ArchiveFile::parse(&*archive_map).map_err(|e| ExtractBundledLibsError { + kind: ParseArchive, + rlib, + error: e.to_string(), + })?; for entry in archive.members() { - let entry = entry.map_err(|e| message("failed to read entry", &e))?; - let data = entry - .data(&*archive_map) - .map_err(|e| message("failed to get data from archive member", &e))?; - let name = std::str::from_utf8(entry.name()) - .map_err(|e| message("failed to convert name", &e))?; + let entry = entry.map_err(|e| ExtractBundledLibsError { + kind: ReadEntry, + rlib, + error: e.to_string(), + })?; + let data = entry.data(&*archive_map).map_err(|e| ExtractBundledLibsError { + kind: ArchiveMember, + rlib, + error: e.to_string(), + })?; + let name = std::str::from_utf8(entry.name()).map_err(|e| ExtractBundledLibsError { + kind: ConvertName, + rlib, + error: e.to_string(), + })?; if !bundled_lib_file_names.contains(&Symbol::intern(name)) { continue; // We need to extract only native libraries. } - std::fs::write(&outdir.join(&name), data) - .map_err(|e| message("failed to write file", &e))?; + std::fs::write(&outdir.join(&name), data).map_err(|e| ExtractBundledLibsError { + kind: WriteFile, + rlib, + error: e.to_string(), + })?; } Ok(()) } diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 4c58d0b53f0..1277294b634 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -2447,7 +2447,7 @@ fn add_upstream_rust_crates<'a>( let rlib = &src.rlib.as_ref().unwrap().0; archive_builder_builder .extract_bundled_libs(rlib, tmpdir, &bundled_libs) - .unwrap_or_else(|e| sess.fatal(e)); + .unwrap_or_else(|e| sess.emit_fatal(e)); } let mut last = (None, NativeLibKind::Unspecified, None); diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs index 71fac123725..0a2532ccc47 100644 --- a/compiler/rustc_codegen_ssa/src/errors.rs +++ b/compiler/rustc_codegen_ssa/src/errors.rs @@ -484,3 +484,51 @@ pub struct RlibArchiveBuildFailure { #[derive(Diagnostic)] #[diag(codegen_ssa_option_gcc_only)] pub struct OptionGccOnly; + +pub struct ExtractBundledLibsError<'a> { + pub kind: ExtractBundledLibsErrorKind, + pub rlib: &'a Path, + pub error: String, +} + +pub enum ExtractBundledLibsErrorKind { + OpenFile, + MmapFile, + ParseArchive, + ReadEntry, + ArchiveMember, + ConvertName, + WriteFile, +} + +impl IntoDiagnostic<'_, !> for ExtractBundledLibsError<'_> { + fn into_diagnostic(self, handler: &'_ Handler) -> DiagnosticBuilder<'_, !> { + let mut diag = match self.kind { + ExtractBundledLibsErrorKind::OpenFile => { + handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_open_file) + } + ExtractBundledLibsErrorKind::MmapFile => { + handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_mmap_file) + } + ExtractBundledLibsErrorKind::ParseArchive => { + handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_parse_archive) + } + ExtractBundledLibsErrorKind::ReadEntry => { + handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_read_entry) + } + ExtractBundledLibsErrorKind::ArchiveMember => { + handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_archive_member) + } + ExtractBundledLibsErrorKind::ConvertName => { + handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_convert_name) + } + ExtractBundledLibsErrorKind::WriteFile => { + handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_write_file) + } + }; + + diag.set_arg("rlib", self.rlib); + diag.set_arg("error", self.error); + diag + } +} diff --git a/compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl b/compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl index 2e5c72ee645..a31e1658f5f 100644 --- a/compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl +++ b/compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl @@ -170,3 +170,11 @@ codegen_ssa_unable_to_write_debugger_visualizer = Unable to write debugger visua codegen_ssa_rlib_archive_build_failure = failed to build archive from rlib: {$error} codegen_ssa_option_gcc_only = option `-Z gcc-ld` is used even though linker flavor is not gcc + +codegen_ssa_extract_bundled_libs_open_file = failed to open file '{$rlib}': {$error} +codegen_ssa_extract_bundled_libs_mmap_file = failed to mmap file '{$rlib}': {$error} +codegen_ssa_extract_bundled_libs_parse_archive = failed to parse archive '{$rlib}': {$error} +codegen_ssa_extract_bundled_libs_read_entry = failed to read entry '{$rlib}': {$error} +codegen_ssa_extract_bundled_libs_archive_member = failed to get data from archive member '{$rlib}': {$error} +codegen_ssa_extract_bundled_libs_convert_name = failed to convert name '{$rlib}': {$error} +codegen_ssa_extract_bundled_libs_write_file = failed to write file '{$rlib}': {$error} From 2678765d08df633b4804d1ba03e090c3bed878bb Mon Sep 17 00:00:00 2001 From: Jhonny Bill Mena Date: Mon, 31 Oct 2022 01:51:58 -0400 Subject: [PATCH 206/219] FIX - Migrate missing errors in link.rs --- compiler/rustc_codegen_ssa/src/back/link.rs | 8 ++++---- compiler/rustc_codegen_ssa/src/errors.rs | 13 +++++++++++++ .../locales/en-US/codegen_ssa.ftl | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 1277294b634..1e6a2b6ecaa 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -2776,14 +2776,14 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { ("arm", "watchos") => "watchos", (_, "macos") => "macosx", _ => { - sess.err(&format!("unsupported arch `{}` for os `{}`", arch, os)); + sess.emit_err(errors::UnsupportedArch { arch, os }); return; } }; let sdk_root = match get_apple_sdk_root(sdk_name) { Ok(s) => s, Err(e) => { - sess.err(&e); + sess.emit_err(e); return; } }; @@ -2799,7 +2799,7 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { } } -fn get_apple_sdk_root(sdk_name: &str) -> Result { +fn get_apple_sdk_root(sdk_name: &str) -> Result> { // Following what clang does // (https://github.com/llvm/llvm-project/blob/ // 296a80102a9b72c3eda80558fb78a3ed8849b341/clang/lib/Driver/ToolChains/Darwin.cpp#L1661-L1678) @@ -2849,7 +2849,7 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result { match res { Ok(output) => Ok(output.trim().to_string()), - Err(e) => Err(format!("failed to get {} SDK path: {}", sdk_name, e)), + Err(error) => Err(errors::AppleSdkRootError::SdkPath { sdk_name, error }), } } diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs index 0a2532ccc47..35eae30c4ba 100644 --- a/compiler/rustc_codegen_ssa/src/errors.rs +++ b/compiler/rustc_codegen_ssa/src/errors.rs @@ -532,3 +532,16 @@ impl IntoDiagnostic<'_, !> for ExtractBundledLibsError<'_> { diag } } + +#[derive(Diagnostic)] +#[diag(codegen_ssa_unsupported_arch)] +pub struct UnsupportedArch<'a> { + pub arch: &'a str, + pub os: &'a str, +} + +#[derive(Diagnostic)] +pub enum AppleSdkRootError<'a> { + #[diag(codegen_ssa_apple_sdk_error_sdk_path)] + SdkPath { sdk_name: &'a str, error: Error }, +} diff --git a/compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl b/compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl index a31e1658f5f..ad0d7582101 100644 --- a/compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl +++ b/compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl @@ -178,3 +178,7 @@ codegen_ssa_extract_bundled_libs_read_entry = failed to read entry '{$rlib}': {$ codegen_ssa_extract_bundled_libs_archive_member = failed to get data from archive member '{$rlib}': {$error} codegen_ssa_extract_bundled_libs_convert_name = failed to convert name '{$rlib}': {$error} codegen_ssa_extract_bundled_libs_write_file = failed to write file '{$rlib}': {$error} + +codegen_ssa_unsupported_arch = unsupported arch `{$arch}` for os `{$os}` + +codegen_ssa_apple_sdk_error_sdk_path = failed to get {$sdk_name} SDK path: {error} From 28491a7b36a717e42081fc6ee788433feccb72e6 Mon Sep 17 00:00:00 2001 From: Jhonny Bill Mena Date: Thu, 3 Nov 2022 01:53:06 -0400 Subject: [PATCH 207/219] UPDATE - address PR Comments FIX - StrippingDebugInfoFailed typo DELETE - unneeded FIXME comment UPDATE - only declare the error with ExtractBundledLibsError as an enum and use the Diagnostic derive macro --- .../rustc_codegen_ssa/src/back/archive.rs | 56 ++++++---------- compiler/rustc_codegen_ssa/src/back/link.rs | 3 +- compiler/rustc_codegen_ssa/src/errors.rs | 64 ++++++------------- 3 files changed, 40 insertions(+), 83 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index b45fa247687..9113ddab048 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -10,7 +10,7 @@ use std::fs::File; use std::io; use std::path::{Path, PathBuf}; -use crate::errors::{ExtractBundledLibsError, ExtractBundledLibsErrorKind::*}; +use crate::errors::ExtractBundledLibsError; pub trait ArchiveBuilderBuilder { fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box + 'a>; @@ -35,48 +35,30 @@ pub trait ArchiveBuilderBuilder { outdir: &Path, bundled_lib_file_names: &FxHashSet, ) -> Result<(), ExtractBundledLibsError<'_>> { - let archive_map = unsafe { - Mmap::map(File::open(rlib).map_err(|e| ExtractBundledLibsError { - kind: OpenFile, - rlib, - error: e.to_string(), - })?) - .map_err(|e| ExtractBundledLibsError { - kind: MmapFile, - rlib, - error: e.to_string(), - })? - }; - let archive = ArchiveFile::parse(&*archive_map).map_err(|e| ExtractBundledLibsError { - kind: ParseArchive, - rlib, - error: e.to_string(), - })?; + let archive_map = + unsafe { + Mmap::map(File::open(rlib).map_err(|e| ExtractBundledLibsError::OpenFile { + rlib, + error: e.to_string(), + })?) + .map_err(|e| ExtractBundledLibsError::MmapFile { rlib, error: e.to_string() })? + }; + let archive = ArchiveFile::parse(&*archive_map) + .map_err(|e| ExtractBundledLibsError::ParseArchive { rlib, error: e.to_string() })?; for entry in archive.members() { - let entry = entry.map_err(|e| ExtractBundledLibsError { - kind: ReadEntry, - rlib, - error: e.to_string(), - })?; - let data = entry.data(&*archive_map).map_err(|e| ExtractBundledLibsError { - kind: ArchiveMember, - rlib, - error: e.to_string(), - })?; - let name = std::str::from_utf8(entry.name()).map_err(|e| ExtractBundledLibsError { - kind: ConvertName, - rlib, - error: e.to_string(), + let entry = entry + .map_err(|e| ExtractBundledLibsError::ReadEntry { rlib, error: e.to_string() })?; + let data = entry.data(&*archive_map).map_err(|e| { + ExtractBundledLibsError::ArchiveMember { rlib, error: e.to_string() } })?; + let name = std::str::from_utf8(entry.name()) + .map_err(|e| ExtractBundledLibsError::ConvertName { rlib, error: e.to_string() })?; if !bundled_lib_file_names.contains(&Symbol::intern(name)) { continue; // We need to extract only native libraries. } - std::fs::write(&outdir.join(&name), data).map_err(|e| ExtractBundledLibsError { - kind: WriteFile, - rlib, - error: e.to_string(), - })?; + std::fs::write(&outdir.join(&name), data) + .map_err(|e| ExtractBundledLibsError::WriteFile { rlib, error: e.to_string() })?; } Ok(()) } diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 1e6a2b6ecaa..6f0a8d0a54c 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1063,7 +1063,7 @@ fn strip_symbols_with_external_utility<'a>( if !prog.status.success() { let mut output = prog.stderr.clone(); output.extend_from_slice(&prog.stdout); - sess.emit_warning(errors::StrippingDebuInfoFailed { + sess.emit_warning(errors::StrippingDebugInfoFailed { util, status: prog.status, output: escape_string(&output), @@ -1077,7 +1077,6 @@ fn strip_symbols_with_external_utility<'a>( fn escape_string(s: &[u8]) -> String { match str::from_utf8(s) { Ok(s) => s.to_owned(), - // FIXME: return a type that can conform to IntoDiagnosticArg Err(_) => format!("Non-UTF-8 output: {}", s.escape_ascii()), } } diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs index 35eae30c4ba..265f466f2ca 100644 --- a/compiler/rustc_codegen_ssa/src/errors.rs +++ b/compiler/rustc_codegen_ssa/src/errors.rs @@ -423,7 +423,7 @@ pub struct UnableToRunDsymutil { #[derive(Diagnostic)] #[diag(codegen_ssa_stripping_debu_info_failed)] #[note] -pub struct StrippingDebuInfoFailed<'a> { +pub struct StrippingDebugInfoFailed<'a> { pub util: &'a str, pub status: ExitStatus, pub output: String, @@ -485,52 +485,28 @@ pub struct RlibArchiveBuildFailure { #[diag(codegen_ssa_option_gcc_only)] pub struct OptionGccOnly; -pub struct ExtractBundledLibsError<'a> { - pub kind: ExtractBundledLibsErrorKind, - pub rlib: &'a Path, - pub error: String, -} +#[derive(Diagnostic)] +pub enum ExtractBundledLibsError<'a> { + #[diag(codegen_ssa_extract_bundled_libs_open_file)] + OpenFile { rlib: &'a Path, error: String }, -pub enum ExtractBundledLibsErrorKind { - OpenFile, - MmapFile, - ParseArchive, - ReadEntry, - ArchiveMember, - ConvertName, - WriteFile, -} + #[diag(codegen_ssa_extract_bundled_libs_mmap_file)] + MmapFile { rlib: &'a Path, error: String }, -impl IntoDiagnostic<'_, !> for ExtractBundledLibsError<'_> { - fn into_diagnostic(self, handler: &'_ Handler) -> DiagnosticBuilder<'_, !> { - let mut diag = match self.kind { - ExtractBundledLibsErrorKind::OpenFile => { - handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_open_file) - } - ExtractBundledLibsErrorKind::MmapFile => { - handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_mmap_file) - } - ExtractBundledLibsErrorKind::ParseArchive => { - handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_parse_archive) - } - ExtractBundledLibsErrorKind::ReadEntry => { - handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_read_entry) - } - ExtractBundledLibsErrorKind::ArchiveMember => { - handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_archive_member) - } - ExtractBundledLibsErrorKind::ConvertName => { - handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_convert_name) - } - ExtractBundledLibsErrorKind::WriteFile => { - handler.struct_fatal(fluent::codegen_ssa_extract_bundled_libs_write_file) - } - }; + #[diag(codegen_ssa_extract_bundled_libs_parse_archive)] + ParseArchive { rlib: &'a Path, error: String }, - diag.set_arg("rlib", self.rlib); - diag.set_arg("error", self.error); - diag - } + #[diag(codegen_ssa_extract_bundled_libs_read_entry)] + ReadEntry { rlib: &'a Path, error: String }, + + #[diag(codegen_ssa_extract_bundled_libs_archive_member)] + ArchiveMember { rlib: &'a Path, error: String }, + + #[diag(codegen_ssa_extract_bundled_libs_convert_name)] + ConvertName { rlib: &'a Path, error: String }, + + #[diag(codegen_ssa_extract_bundled_libs_write_file)] + WriteFile { rlib: &'a Path, error: String }, } #[derive(Diagnostic)] From 540c3f94d71879f413a151bc8c83c20c10b386dc Mon Sep 17 00:00:00 2001 From: Jhonny Bill Mena Date: Fri, 4 Nov 2022 01:16:16 -0400 Subject: [PATCH 208/219] UPDATE - accept dyn error and make Box conform to IntoDiagnosticArg --- .../rustc_codegen_ssa/src/back/archive.rs | 29 +++++++++---------- compiler/rustc_codegen_ssa/src/errors.rs | 14 ++++----- compiler/rustc_errors/src/diagnostic_impls.rs | 1 + 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index 9113ddab048..18789d00fd3 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -35,30 +35,29 @@ pub trait ArchiveBuilderBuilder { outdir: &Path, bundled_lib_file_names: &FxHashSet, ) -> Result<(), ExtractBundledLibsError<'_>> { - let archive_map = - unsafe { - Mmap::map(File::open(rlib).map_err(|e| ExtractBundledLibsError::OpenFile { - rlib, - error: e.to_string(), - })?) - .map_err(|e| ExtractBundledLibsError::MmapFile { rlib, error: e.to_string() })? - }; + let archive_map = unsafe { + Mmap::map( + File::open(rlib) + .map_err(|e| ExtractBundledLibsError::OpenFile { rlib, error: Box::new(e) })?, + ) + .map_err(|e| ExtractBundledLibsError::MmapFile { rlib, error: Box::new(e) })? + }; let archive = ArchiveFile::parse(&*archive_map) - .map_err(|e| ExtractBundledLibsError::ParseArchive { rlib, error: e.to_string() })?; + .map_err(|e| ExtractBundledLibsError::ParseArchive { rlib, error: Box::new(e) })?; for entry in archive.members() { let entry = entry - .map_err(|e| ExtractBundledLibsError::ReadEntry { rlib, error: e.to_string() })?; - let data = entry.data(&*archive_map).map_err(|e| { - ExtractBundledLibsError::ArchiveMember { rlib, error: e.to_string() } - })?; + .map_err(|e| ExtractBundledLibsError::ReadEntry { rlib, error: Box::new(e) })?; + let data = entry + .data(&*archive_map) + .map_err(|e| ExtractBundledLibsError::ArchiveMember { rlib, error: Box::new(e) })?; let name = std::str::from_utf8(entry.name()) - .map_err(|e| ExtractBundledLibsError::ConvertName { rlib, error: e.to_string() })?; + .map_err(|e| ExtractBundledLibsError::ConvertName { rlib, error: Box::new(e) })?; if !bundled_lib_file_names.contains(&Symbol::intern(name)) { continue; // We need to extract only native libraries. } std::fs::write(&outdir.join(&name), data) - .map_err(|e| ExtractBundledLibsError::WriteFile { rlib, error: e.to_string() })?; + .map_err(|e| ExtractBundledLibsError::WriteFile { rlib, error: Box::new(e) })?; } Ok(()) } diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs index 265f466f2ca..36c94462b0b 100644 --- a/compiler/rustc_codegen_ssa/src/errors.rs +++ b/compiler/rustc_codegen_ssa/src/errors.rs @@ -488,25 +488,25 @@ pub struct OptionGccOnly; #[derive(Diagnostic)] pub enum ExtractBundledLibsError<'a> { #[diag(codegen_ssa_extract_bundled_libs_open_file)] - OpenFile { rlib: &'a Path, error: String }, + OpenFile { rlib: &'a Path, error: Box }, #[diag(codegen_ssa_extract_bundled_libs_mmap_file)] - MmapFile { rlib: &'a Path, error: String }, + MmapFile { rlib: &'a Path, error: Box }, #[diag(codegen_ssa_extract_bundled_libs_parse_archive)] - ParseArchive { rlib: &'a Path, error: String }, + ParseArchive { rlib: &'a Path, error: Box }, #[diag(codegen_ssa_extract_bundled_libs_read_entry)] - ReadEntry { rlib: &'a Path, error: String }, + ReadEntry { rlib: &'a Path, error: Box }, #[diag(codegen_ssa_extract_bundled_libs_archive_member)] - ArchiveMember { rlib: &'a Path, error: String }, + ArchiveMember { rlib: &'a Path, error: Box }, #[diag(codegen_ssa_extract_bundled_libs_convert_name)] - ConvertName { rlib: &'a Path, error: String }, + ConvertName { rlib: &'a Path, error: Box }, #[diag(codegen_ssa_extract_bundled_libs_write_file)] - WriteFile { rlib: &'a Path, error: String }, + WriteFile { rlib: &'a Path, error: Box }, } #[derive(Diagnostic)] diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index 4f32e236b2d..83a3211c63b 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -59,6 +59,7 @@ into_diagnostic_arg_using_display!( i128, u128, std::io::Error, + std::boxed::Box, std::num::NonZeroU32, hir::Target, Edition, From d98cce19b28f37a457db3d27ff5ade33f32bcaa4 Mon Sep 17 00:00:00 2001 From: Jakob Degen Date: Thu, 3 Nov 2022 23:19:59 -0700 Subject: [PATCH 209/219] Make mir opt unused file check blessable --- src/tools/tidy/src/mir_opt_tests.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/tools/tidy/src/mir_opt_tests.rs b/src/tools/tidy/src/mir_opt_tests.rs index ea24fa45138..018573284ea 100644 --- a/src/tools/tidy/src/mir_opt_tests.rs +++ b/src/tools/tidy/src/mir_opt_tests.rs @@ -3,7 +3,7 @@ use std::collections::HashSet; use std::path::{Path, PathBuf}; -fn check_unused_files(path: &Path, bad: &mut bool) { +fn check_unused_files(path: &Path, bless: bool, bad: &mut bool) { let mut rs_files = Vec::::new(); let mut output_files = HashSet::::new(); let files = walkdir::WalkDir::new(&path.join("test/mir-opt")).into_iter(); @@ -27,11 +27,15 @@ fn check_unused_files(path: &Path, bad: &mut bool) { for extra in output_files { if extra.file_name() != Some("README.md".as_ref()) { - tidy_error!( - bad, - "the following output file is not associated with any mir-opt test, you can remove it: {}", - extra.display() - ); + if !bless { + tidy_error!( + bad, + "the following output file is not associated with any mir-opt test, you can remove it: {}", + extra.display() + ); + } else { + let _ = std::fs::remove_file(extra); + } } } } @@ -65,6 +69,6 @@ fn check_dash_files(path: &Path, bless: bool, bad: &mut bool) { } pub fn check(path: &Path, bless: bool, bad: &mut bool) { - check_unused_files(path, bad); + check_unused_files(path, bless, bad); check_dash_files(path, bless, bad); } From b7360fa23f6e029770acae390b47e828f1f08347 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Fri, 4 Nov 2022 12:25:40 +0000 Subject: [PATCH 210/219] Give a specific lint for unsafety not being inherited --- .../rustc_mir_transform/src/check_unsafety.rs | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_mir_transform/src/check_unsafety.rs b/compiler/rustc_mir_transform/src/check_unsafety.rs index 959fcf8d89e..80e1246ec6b 100644 --- a/compiler/rustc_mir_transform/src/check_unsafety.rs +++ b/compiler/rustc_mir_transform/src/check_unsafety.rs @@ -1,3 +1,4 @@ +use hir::{BlockCheckMode, ExprKind, Node}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::struct_span_err; use rustc_hir as hir; @@ -517,24 +518,49 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) { for &UnsafetyViolation { source_info, lint_root, kind, details } in violations.iter() { let (description, note) = details.description_and_note(); - // Report an error. - let unsafe_fn_msg = - if unsafe_op_in_unsafe_fn_allowed(tcx, lint_root) { " function or" } else { "" }; - match kind { UnsafetyViolationKind::General => { // once - struct_span_err!( + // Mutable statics always require an unsafe block + let unsafe_fn_msg = if unsafe_op_in_unsafe_fn_allowed(tcx, lint_root) + && details != UnsafetyViolationDetails::UseOfMutableStatic + { + " function or" + } else { + "" + }; + + let mut err = struct_span_err!( tcx.sess, source_info.span, E0133, "{} is unsafe and requires unsafe{} block", description, unsafe_fn_msg, - ) - .span_label(source_info.span, description) - .note(note) - .emit(); + ); + err.span_label(source_info.span, description).note(note); + let note_non_inherited = tcx.hir().parent_iter(lint_root).find(|(id, node)| { + if let Node::Expr(block) = node + && let ExprKind::Block(block, _) = block.kind + && let BlockCheckMode::UnsafeBlock(_) = block.rules { + true + } + else if let Some(sig) = tcx.hir().fn_sig_by_hir_id(*id) + && sig.header.is_unsafe() { + true + } else { + false + } + }); + if let Some((id, _)) = note_non_inherited { + let span = tcx.hir().span(id); + err.span_label( + tcx.sess.source_map().guess_head_span(span), + "items do not inherit unsafety from separate enclosing items", + ); + } + + err.emit(); } UnsafetyViolationKind::UnsafeFn => tcx.struct_span_lint_hir( UNSAFE_OP_IN_UNSAFE_FN, From 28819cbb7e7ae05dc83e285ca936ac16876fd701 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Fri, 4 Nov 2022 12:57:42 +0000 Subject: [PATCH 211/219] Formatting changes + add UI test --- .../rustc_mir_transform/src/check_unsafety.rs | 19 +++++++------- src/test/ui/unsafe/unsafe-not-inherited.rs | 26 +++++++++++++++++++ .../ui/unsafe/unsafe-not-inherited.stderr | 24 +++++++++++++++++ 3 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 src/test/ui/unsafe/unsafe-not-inherited.rs create mode 100644 src/test/ui/unsafe/unsafe-not-inherited.stderr diff --git a/compiler/rustc_mir_transform/src/check_unsafety.rs b/compiler/rustc_mir_transform/src/check_unsafety.rs index 80e1246ec6b..269d9f3b102 100644 --- a/compiler/rustc_mir_transform/src/check_unsafety.rs +++ b/compiler/rustc_mir_transform/src/check_unsafety.rs @@ -1,10 +1,10 @@ -use hir::{BlockCheckMode, ExprKind, Node}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::struct_span_err; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::hir_id::HirId; use rustc_hir::intravisit; +use rustc_hir::{BlockCheckMode, ExprKind, Node}; use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor}; use rustc_middle::mir::*; use rustc_middle::ty::query::Providers; @@ -521,10 +521,7 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) { match kind { UnsafetyViolationKind::General => { // once - // Mutable statics always require an unsafe block - let unsafe_fn_msg = if unsafe_op_in_unsafe_fn_allowed(tcx, lint_root) - && details != UnsafetyViolationDetails::UseOfMutableStatic - { + let unsafe_fn_msg = if unsafe_op_in_unsafe_fn_allowed(tcx, lint_root) { " function or" } else { "" @@ -542,12 +539,14 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) { let note_non_inherited = tcx.hir().parent_iter(lint_root).find(|(id, node)| { if let Node::Expr(block) = node && let ExprKind::Block(block, _) = block.kind - && let BlockCheckMode::UnsafeBlock(_) = block.rules { - true - } + && let BlockCheckMode::UnsafeBlock(_) = block.rules + { + true + } else if let Some(sig) = tcx.hir().fn_sig_by_hir_id(*id) - && sig.header.is_unsafe() { - true + && sig.header.is_unsafe() + { + true } else { false } diff --git a/src/test/ui/unsafe/unsafe-not-inherited.rs b/src/test/ui/unsafe/unsafe-not-inherited.rs new file mode 100644 index 00000000000..6d797caa0f9 --- /dev/null +++ b/src/test/ui/unsafe/unsafe-not-inherited.rs @@ -0,0 +1,26 @@ +#![allow(unused, dead_code)] + +static mut FOO: u64 = 0; + +fn static_mod() { + unsafe {static BAR: u64 = FOO;} + //~^ ERROR: use of mutable static is unsafe + //~| NOTE: use of mutable static + //~| NOTE: mutable statics can be mutated by multiple threads + //~| NOTE: items do not inherit unsafety +} + +unsafe fn unsafe_call() {} +fn foo() { + unsafe { + //~^ NOTE: items do not inherit unsafety + fn bar() { + unsafe_call(); + //~^ ERROR: call to unsafe function + //~| NOTE: call to unsafe function + //~| NOTE: consult the function's documentation + } + } +} + +fn main() {} diff --git a/src/test/ui/unsafe/unsafe-not-inherited.stderr b/src/test/ui/unsafe/unsafe-not-inherited.stderr new file mode 100644 index 00000000000..3bc5ca5c9d1 --- /dev/null +++ b/src/test/ui/unsafe/unsafe-not-inherited.stderr @@ -0,0 +1,24 @@ +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/unsafe-not-inherited.rs:6:31 + | +LL | unsafe {static BAR: u64 = FOO;} + | ------ ^^^ use of mutable static + | | + | items do not inherit unsafety from separate enclosing items + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/unsafe-not-inherited.rs:18:13 + | +LL | unsafe { + | ------ items do not inherit unsafety from separate enclosing items +... +LL | unsafe_call(); + | ^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0133`. From 18511ba1cb6199aae13d7c8dd987e328259a4702 Mon Sep 17 00:00:00 2001 From: yukang Date: Fri, 4 Nov 2022 16:56:48 +0800 Subject: [PATCH 212/219] test tidy should not count untracked paths towards entries limit --- Cargo.lock | 1 + src/tools/tidy/Cargo.toml | 1 + src/tools/tidy/src/ui_tests.rs | 59 +++++++++++++++++++--------------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dab693419a9..cea17ecc3d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4919,6 +4919,7 @@ name = "tidy" version = "0.1.0" dependencies = [ "cargo_metadata 0.14.0", + "ignore", "lazy_static", "regex", "walkdir", diff --git a/src/tools/tidy/Cargo.toml b/src/tools/tidy/Cargo.toml index 471d78a2922..8a6fbaecd69 100644 --- a/src/tools/tidy/Cargo.toml +++ b/src/tools/tidy/Cargo.toml @@ -9,6 +9,7 @@ cargo_metadata = "0.14" regex = "1" lazy_static = "1" walkdir = "2" +ignore = "0.4.18" [[bin]] name = "rust-tidy" diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index c600f99c2c4..b4ee87bb410 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -2,6 +2,8 @@ //! - the number of entries in each directory must be less than `ENTRY_LIMIT` //! - there are no stray `.stderr` files +use ignore::Walk; +use ignore::WalkBuilder; use std::fs; use std::path::Path; @@ -11,34 +13,39 @@ const ROOT_ENTRY_LIMIT: usize = 948; const ISSUES_ENTRY_LIMIT: usize = 2117; fn check_entries(path: &Path, bad: &mut bool) { - let dirs = walkdir::WalkDir::new(&path.join("test/ui")) - .into_iter() - .filter_entry(|e| e.file_type().is_dir()); - for dir in dirs { - if let Ok(dir) = dir { - let dir_path = dir.path(); + for dir in Walk::new(&path.join("test/ui")) { + if let Ok(entry) = dir { + if entry.file_type().map(|ft| ft.is_dir()).unwrap_or(false) { + let dir_path = entry.path(); + // Use special values for these dirs. + let is_root = path.join("test/ui") == dir_path; + let is_issues_dir = path.join("test/ui/issues") == dir_path; + let limit = if is_root { + ROOT_ENTRY_LIMIT + } else if is_issues_dir { + ISSUES_ENTRY_LIMIT + } else { + ENTRY_LIMIT + }; - // Use special values for these dirs. - let is_root = path.join("test/ui") == dir_path; - let is_issues_dir = path.join("test/ui/issues") == dir_path; - let limit = if is_root { - ROOT_ENTRY_LIMIT - } else if is_issues_dir { - ISSUES_ENTRY_LIMIT - } else { - ENTRY_LIMIT - }; + let count = WalkBuilder::new(&dir_path) + .max_depth(Some(1)) + .build() + .into_iter() + .collect::>() + .len() + - 1; // remove the dir itself - let count = std::fs::read_dir(dir_path).unwrap().count(); - if count > limit { - tidy_error!( - bad, - "following path contains more than {} entries, \ - you should move the test to some relevant subdirectory (current: {}): {}", - limit, - count, - dir_path.display() - ); + if count > limit { + tidy_error!( + bad, + "following path contains more than {} entries, \ + you should move the test to some relevant subdirectory (current: {}): {}", + limit, + count, + dir_path.display() + ); + } } } } From 71a3a48ee52a5cbc3fa3e3e8d322ebeb97ed109f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Fri, 28 Oct 2022 10:20:51 +0300 Subject: [PATCH 213/219] improve `filesearch::get_or_default_sysroot` r=ozkanonur MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Onur Özkan --- Cargo.lock | 5 +- compiler/rustc_codegen_ssa/src/back/link.rs | 3 +- compiler/rustc_interface/Cargo.toml | 6 - compiler/rustc_interface/src/util.rs | 97 +------------- compiler/rustc_session/Cargo.toml | 7 + compiler/rustc_session/src/config.rs | 2 +- compiler/rustc_session/src/filesearch.rs | 136 +++++++++++++++++--- compiler/rustc_session/src/session.rs | 2 +- src/tools/clippy/src/driver.rs | 79 +----------- src/tools/miri/src/bin/miri.rs | 70 ++-------- 10 files changed, 152 insertions(+), 255 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dab693419a9..cd0d14817ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3646,7 +3646,6 @@ dependencies = [ name = "rustc_interface" version = "0.0.0" dependencies = [ - "libc", "libloading", "rustc-rayon", "rustc-rayon-core", @@ -3689,7 +3688,6 @@ dependencies = [ "rustc_ty_utils", "smallvec", "tracing", - "winapi", ] [[package]] @@ -4109,6 +4107,7 @@ name = "rustc_session" version = "0.0.0" dependencies = [ "getopts", + "libc", "rustc_ast", "rustc_data_structures", "rustc_errors", @@ -4120,7 +4119,9 @@ dependencies = [ "rustc_serialize", "rustc_span", "rustc_target", + "smallvec", "tracing", + "winapi", ] [[package]] diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 0dc0dee862c..bd986c3b8e5 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1153,7 +1153,8 @@ fn link_sanitizer_runtime(sess: &Session, linker: &mut dyn Linker, name: &str) { if path.exists() { return session_tlib; } else { - let default_sysroot = filesearch::get_or_default_sysroot(); + let default_sysroot = + filesearch::get_or_default_sysroot().expect("Failed finding sysroot"); let default_tlib = filesearch::make_target_lib_path( &default_sysroot, sess.opts.target_triple.triple(), diff --git a/compiler/rustc_interface/Cargo.toml b/compiler/rustc_interface/Cargo.toml index 6a4c5b4d373..2e526733df9 100644 --- a/compiler/rustc_interface/Cargo.toml +++ b/compiler/rustc_interface/Cargo.toml @@ -48,12 +48,6 @@ rustc_resolve = { path = "../rustc_resolve" } rustc_trait_selection = { path = "../rustc_trait_selection" } rustc_ty_utils = { path = "../rustc_ty_utils" } -[target.'cfg(unix)'.dependencies] -libc = "0.2" - -[target.'cfg(windows)'.dependencies] -winapi = { version = "0.3", features = ["libloaderapi"] } - [dev-dependencies] rustc_target = { path = "../rustc_target" } diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 519b8a7fc7c..62ee72f9883 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -9,6 +9,7 @@ use rustc_session as session; use rustc_session::config::CheckCfg; use rustc_session::config::{self, CrateType}; use rustc_session::config::{ErrorOutputType, Input, OutputFilenames}; +use rustc_session::filesearch::sysroot_candidates; use rustc_session::lint::{self, BuiltinLintDiagnostics, LintBuffer}; use rustc_session::parse::CrateConfig; use rustc_session::{early_error, filesearch, output, Session}; @@ -78,7 +79,7 @@ pub fn create_session( let bundle = match rustc_errors::fluent_bundle( sopts.maybe_sysroot.clone(), - sysroot_candidates(), + sysroot_candidates().to_vec(), sopts.unstable_opts.translate_lang.clone(), sopts.unstable_opts.translate_additional_ftl.as_deref(), sopts.unstable_opts.translate_directionality_markers, @@ -273,100 +274,6 @@ fn get_rustc_path_inner(bin_path: &str) -> Option { }) } -fn sysroot_candidates() -> Vec { - let target = session::config::host_triple(); - let mut sysroot_candidates = vec![filesearch::get_or_default_sysroot()]; - let path = current_dll_path().and_then(|s| s.canonicalize().ok()); - if let Some(dll) = path { - // use `parent` twice to chop off the file name and then also the - // directory containing the dll which should be either `lib` or `bin`. - if let Some(path) = dll.parent().and_then(|p| p.parent()) { - // The original `path` pointed at the `rustc_driver` crate's dll. - // Now that dll should only be in one of two locations. The first is - // in the compiler's libdir, for example `$sysroot/lib/*.dll`. The - // other is the target's libdir, for example - // `$sysroot/lib/rustlib/$target/lib/*.dll`. - // - // We don't know which, so let's assume that if our `path` above - // ends in `$target` we *could* be in the target libdir, and always - // assume that we may be in the main libdir. - sysroot_candidates.push(path.to_owned()); - - if path.ends_with(target) { - sysroot_candidates.extend( - path.parent() // chop off `$target` - .and_then(|p| p.parent()) // chop off `rustlib` - .and_then(|p| p.parent()) // chop off `lib` - .map(|s| s.to_owned()), - ); - } - } - } - - return sysroot_candidates; - - #[cfg(unix)] - fn current_dll_path() -> Option { - use std::ffi::{CStr, OsStr}; - use std::os::unix::prelude::*; - - unsafe { - let addr = current_dll_path as usize as *mut _; - let mut info = mem::zeroed(); - if libc::dladdr(addr, &mut info) == 0 { - info!("dladdr failed"); - return None; - } - if info.dli_fname.is_null() { - info!("dladdr returned null pointer"); - return None; - } - let bytes = CStr::from_ptr(info.dli_fname).to_bytes(); - let os = OsStr::from_bytes(bytes); - Some(PathBuf::from(os)) - } - } - - #[cfg(windows)] - fn current_dll_path() -> Option { - use std::ffi::OsString; - use std::io; - use std::os::windows::prelude::*; - use std::ptr; - - use winapi::um::libloaderapi::{ - GetModuleFileNameW, GetModuleHandleExW, GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, - }; - - unsafe { - let mut module = ptr::null_mut(); - let r = GetModuleHandleExW( - GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, - current_dll_path as usize as *mut _, - &mut module, - ); - if r == 0 { - info!("GetModuleHandleExW failed: {}", io::Error::last_os_error()); - return None; - } - let mut space = Vec::with_capacity(1024); - let r = GetModuleFileNameW(module, space.as_mut_ptr(), space.capacity() as u32); - if r == 0 { - info!("GetModuleFileNameW failed: {}", io::Error::last_os_error()); - return None; - } - let r = r as usize; - if r >= space.capacity() { - info!("our buffer was too small? {}", io::Error::last_os_error()); - return None; - } - space.set_len(r); - let os = OsString::from_wide(&space); - Some(PathBuf::from(os)) - } - } -} - fn get_codegen_sysroot(maybe_sysroot: &Option, backend_name: &str) -> MakeBackendFn { // For now we only allow this function to be called once as it'll dlopen a // few things, which seems to work best if we only do that once. In diff --git a/compiler/rustc_session/Cargo.toml b/compiler/rustc_session/Cargo.toml index 6b1eaa4d399..a052f293341 100644 --- a/compiler/rustc_session/Cargo.toml +++ b/compiler/rustc_session/Cargo.toml @@ -17,3 +17,10 @@ rustc_span = { path = "../rustc_span" } rustc_fs_util = { path = "../rustc_fs_util" } rustc_ast = { path = "../rustc_ast" } rustc_lint_defs = { path = "../rustc_lint_defs" } +smallvec = "1.8.1" + +[target.'cfg(unix)'.dependencies] +libc = "0.2" + +[target.'cfg(windows)'.dependencies] +winapi = { version = "0.3", features = ["libloaderapi"] } diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index f2ee52262ad..5dfd9f00ad1 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2431,7 +2431,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { let sysroot = match &sysroot_opt { Some(s) => s, None => { - tmp_buf = crate::filesearch::get_or_default_sysroot(); + tmp_buf = crate::filesearch::get_or_default_sysroot().expect("Failed finding sysroot"); &tmp_buf } }; diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs index e8edb38f503..1b66773be6f 100644 --- a/compiler/rustc_session/src/filesearch.rs +++ b/compiler/rustc_session/src/filesearch.rs @@ -1,5 +1,6 @@ //! A module for searching for libraries +use smallvec::{smallvec, SmallVec}; use std::env; use std::fs; use std::iter::FromIterator; @@ -62,9 +63,99 @@ pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf { PathBuf::from_iter([sysroot, Path::new(&rustlib_path), Path::new("lib")]) } +#[cfg(unix)] +fn current_dll_path() -> Result { + use std::ffi::{CStr, OsStr}; + use std::os::unix::prelude::*; + + unsafe { + let addr = current_dll_path as usize as *mut _; + let mut info = std::mem::zeroed(); + if libc::dladdr(addr, &mut info) == 0 { + return Err("dladdr failed".into()); + } + if info.dli_fname.is_null() { + return Err("dladdr returned null pointer".into()); + } + let bytes = CStr::from_ptr(info.dli_fname).to_bytes(); + let os = OsStr::from_bytes(bytes); + Ok(PathBuf::from(os)) + } +} + +#[cfg(windows)] +fn current_dll_path() -> Result { + use std::ffi::OsString; + use std::io; + use std::os::windows::prelude::*; + use std::ptr; + + use winapi::um::libloaderapi::{ + GetModuleFileNameW, GetModuleHandleExW, GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, + }; + + unsafe { + let mut module = ptr::null_mut(); + let r = GetModuleHandleExW( + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, + current_dll_path as usize as *mut _, + &mut module, + ); + if r == 0 { + return Err(format!("GetModuleHandleExW failed: {}", io::Error::last_os_error())); + } + let mut space = Vec::with_capacity(1024); + let r = GetModuleFileNameW(module, space.as_mut_ptr(), space.capacity() as u32); + if r == 0 { + return Err(format!("GetModuleFileNameW failed: {}", io::Error::last_os_error())); + } + let r = r as usize; + if r >= space.capacity() { + return Err(format!("our buffer was too small? {}", io::Error::last_os_error())); + } + space.set_len(r); + let os = OsString::from_wide(&space); + Ok(PathBuf::from(os)) + } +} + +pub fn sysroot_candidates() -> SmallVec<[PathBuf; 2]> { + let target = crate::config::host_triple(); + let mut sysroot_candidates: SmallVec<[PathBuf; 2]> = + smallvec![get_or_default_sysroot().expect("Failed finding sysroot")]; + let path = current_dll_path().and_then(|s| Ok(s.canonicalize().map_err(|e| e.to_string())?)); + if let Ok(dll) = path { + // use `parent` twice to chop off the file name and then also the + // directory containing the dll which should be either `lib` or `bin`. + if let Some(path) = dll.parent().and_then(|p| p.parent()) { + // The original `path` pointed at the `rustc_driver` crate's dll. + // Now that dll should only be in one of two locations. The first is + // in the compiler's libdir, for example `$sysroot/lib/*.dll`. The + // other is the target's libdir, for example + // `$sysroot/lib/rustlib/$target/lib/*.dll`. + // + // We don't know which, so let's assume that if our `path` above + // ends in `$target` we *could* be in the target libdir, and always + // assume that we may be in the main libdir. + sysroot_candidates.push(path.to_owned()); + + if path.ends_with(target) { + sysroot_candidates.extend( + path.parent() // chop off `$target` + .and_then(|p| p.parent()) // chop off `rustlib` + .and_then(|p| p.parent()) // chop off `lib` + .map(|s| s.to_owned()), + ); + } + } + } + + return sysroot_candidates; +} + /// This function checks if sysroot is found using env::args().next(), and if it -/// is not found, uses env::current_exe() to imply sysroot. -pub fn get_or_default_sysroot() -> PathBuf { +/// is not found, finds sysroot from current rustc_driver dll. +pub fn get_or_default_sysroot() -> Result { // Follow symlinks. If the resolved path is relative, make it absolute. fn canonicalize(path: PathBuf) -> PathBuf { let path = fs::canonicalize(&path).unwrap_or(path); @@ -74,17 +165,32 @@ pub fn get_or_default_sysroot() -> PathBuf { fix_windows_verbatim_for_gcc(&path) } - // Use env::current_exe() to get the path of the executable following - // symlinks/canonicalizing components. - fn from_current_exe() -> PathBuf { - match env::current_exe() { - Ok(exe) => { - let mut p = canonicalize(exe); - p.pop(); - p.pop(); - p - } - Err(e) => panic!("failed to get current_exe: {e}"), + fn default_from_rustc_driver_dll() -> Result { + let dll = current_dll_path().and_then(|s| Ok(canonicalize(s)))?; + + // `dll` will be in one of the following two: + // - compiler's libdir: $sysroot/lib/*.dll + // - target's libdir: $sysroot/lib/rustlib/$target/lib/*.dll + // + // use `parent` twice to chop off the file name and then also the + // directory containing the dll + let dir = dll.parent().and_then(|p| p.parent()).ok_or(format!( + "Could not move 2 levels upper using `parent()` on {}", + dll.display() + ))?; + + // if `dir` points target's dir, move up to the sysroot + if dir.ends_with(crate::config::host_triple()) { + dir.parent() // chop off `$target` + .and_then(|p| p.parent()) // chop off `rustlib` + .and_then(|p| p.parent()) // chop off `lib` + .map(|s| s.to_owned()) + .ok_or(format!( + "Could not move 3 levels upper using `parent()` on {}", + dir.display() + )) + } else { + Ok(dir.to_owned()) } } @@ -118,7 +224,5 @@ pub fn get_or_default_sysroot() -> PathBuf { } } - // Check if sysroot is found using env::args().next(), and if is not found, - // use env::current_exe() to imply sysroot. - from_env_args_next().unwrap_or_else(from_current_exe) + Ok(from_env_args_next().unwrap_or(default_from_rustc_driver_dll()?)) } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 100c66f6364..5086117f921 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1280,7 +1280,7 @@ pub fn build_session( let sysroot = match &sopts.maybe_sysroot { Some(sysroot) => sysroot.clone(), - None => filesearch::get_or_default_sysroot(), + None => filesearch::get_or_default_sysroot().expect("Failed finding sysroot"), }; let target_cfg = config::build_target_config(&sopts, target_override, &sysroot); diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index b12208ac62a..46afea2c4b5 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -23,8 +23,8 @@ use std::borrow::Cow; use std::env; use std::ops::Deref; use std::panic; -use std::path::{Path, PathBuf}; -use std::process::{exit, Command}; +use std::path::Path; +use std::process::exit; use std::sync::LazyLock; /// If a command-line option matches `find_arg`, then apply the predicate `pred` on its value. If @@ -209,17 +209,6 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { interface::try_print_query_stack(&handler, num_frames); } -fn toolchain_path(home: Option, toolchain: Option) -> Option { - home.and_then(|home| { - toolchain.map(|toolchain| { - let mut path = PathBuf::from(home); - path.push("toolchains"); - path.push(toolchain); - path - }) - }) -} - #[allow(clippy::too_many_lines)] pub fn main() { rustc_driver::init_rustc_env_logger(); @@ -227,51 +216,6 @@ pub fn main() { exit(rustc_driver::catch_with_exit_code(move || { let mut orig_args: Vec = env::args().collect(); - // Get the sysroot, looking from most specific to this invocation to the least: - // - command line - // - runtime environment - // - SYSROOT - // - RUSTUP_HOME, MULTIRUST_HOME, RUSTUP_TOOLCHAIN, MULTIRUST_TOOLCHAIN - // - sysroot from rustc in the path - // - compile-time environment - // - SYSROOT - // - RUSTUP_HOME, MULTIRUST_HOME, RUSTUP_TOOLCHAIN, MULTIRUST_TOOLCHAIN - let sys_root_arg = arg_value(&orig_args, "--sysroot", |_| true); - let have_sys_root_arg = sys_root_arg.is_some(); - let sys_root = sys_root_arg - .map(PathBuf::from) - .or_else(|| std::env::var("SYSROOT").ok().map(PathBuf::from)) - .or_else(|| { - let home = std::env::var("RUSTUP_HOME") - .or_else(|_| std::env::var("MULTIRUST_HOME")) - .ok(); - let toolchain = std::env::var("RUSTUP_TOOLCHAIN") - .or_else(|_| std::env::var("MULTIRUST_TOOLCHAIN")) - .ok(); - toolchain_path(home, toolchain) - }) - .or_else(|| { - Command::new("rustc") - .arg("--print") - .arg("sysroot") - .output() - .ok() - .and_then(|out| String::from_utf8(out.stdout).ok()) - .map(|s| PathBuf::from(s.trim())) - }) - .or_else(|| option_env!("SYSROOT").map(PathBuf::from)) - .or_else(|| { - let home = option_env!("RUSTUP_HOME") - .or(option_env!("MULTIRUST_HOME")) - .map(ToString::to_string); - let toolchain = option_env!("RUSTUP_TOOLCHAIN") - .or(option_env!("MULTIRUST_TOOLCHAIN")) - .map(ToString::to_string); - toolchain_path(home, toolchain) - }) - .map(|pb| pb.to_string_lossy().to_string()) - .expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust"); - // make "clippy-driver --rustc" work like a subcommand that passes further args to "rustc" // for example `clippy-driver --rustc --version` will print the rustc version that clippy-driver // uses @@ -279,13 +223,7 @@ pub fn main() { orig_args.remove(pos); orig_args[0] = "rustc".to_string(); - // if we call "rustc", we need to pass --sysroot here as well - let mut args: Vec = orig_args.clone(); - if !have_sys_root_arg { - args.extend(vec!["--sysroot".into(), sys_root]); - }; - - return rustc_driver::RunCompiler::new(&args, &mut DefaultCallbacks).run(); + return rustc_driver::RunCompiler::new(&orig_args, &mut DefaultCallbacks).run(); } if orig_args.iter().any(|a| a == "--version" || a == "-V") { @@ -308,14 +246,6 @@ pub fn main() { exit(0); } - // this conditional check for the --sysroot flag is there so users can call - // `clippy_driver` directly - // without having to pass --sysroot or anything - let mut args: Vec = orig_args.clone(); - if !have_sys_root_arg { - args.extend(vec!["--sysroot".into(), sys_root]); - }; - let mut no_deps = false; let clippy_args_var = env::var("CLIPPY_ARGS").ok(); let clippy_args = clippy_args_var @@ -344,10 +274,11 @@ pub fn main() { let clippy_enabled = !cap_lints_allow && (!no_deps || in_primary_package); if clippy_enabled { + let mut args: Vec = orig_args.clone(); args.extend(clippy_args); rustc_driver::RunCompiler::new(&args, &mut ClippyCallbacks { clippy_args_var }).run() } else { - rustc_driver::RunCompiler::new(&args, &mut RustcCallbacks { clippy_args_var }).run() + rustc_driver::RunCompiler::new(&orig_args, &mut RustcCallbacks { clippy_args_var }).run() } })) } diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index bd01ea655dd..e673ea67dbc 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -216,76 +216,28 @@ fn init_late_loggers(tcx: TyCtxt<'_>) { } } -/// Returns the "default sysroot" that Miri will use for host things if no `--sysroot` flag is set. -/// Should be a compile-time constant. -fn host_sysroot() -> Option { - if option_env!("RUSTC_STAGE").is_some() { - // This is being built as part of rustc, and gets shipped with rustup. - // We can rely on the sysroot computation in librustc_session. - return None; - } - // For builds outside rustc, we need to ensure that we got a sysroot - // that gets used as a default. The sysroot computation in librustc_session would - // end up somewhere in the build dir (see `get_or_default_sysroot`). - // Taken from PR . - let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); - let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); - Some(match (home, toolchain) { - (Some(home), Some(toolchain)) => { - // Check that at runtime, we are still in this toolchain (if there is any toolchain). - if let Some(toolchain_runtime) = - env::var_os("RUSTUP_TOOLCHAIN").or_else(|| env::var_os("MULTIRUST_TOOLCHAIN")) - { - if toolchain_runtime != toolchain { - show_error!( - "This Miri got built with local toolchain `{toolchain}`, but now is being run under a different toolchain. \n\ - Make sure to run Miri in the toolchain it got built with, e.g. via `cargo +{toolchain} miri`." - ) - } - } - format!("{home}/toolchains/{toolchain}") - } - _ => option_env!("RUST_SYSROOT") - .unwrap_or_else(|| { - show_error!( - "To build Miri without rustup, set the `RUST_SYSROOT` env var at build time", - ) - }) - .to_owned(), - }) -} - /// Execute a compiler with the given CLI arguments and callbacks. fn run_compiler( mut args: Vec, target_crate: bool, callbacks: &mut (dyn rustc_driver::Callbacks + Send), ) -> ! { - // Make sure we use the right default sysroot. The default sysroot is wrong, - // because `get_or_default_sysroot` in `librustc_session` bases that on `current_exe`. - // - // Make sure we always call `host_sysroot` as that also does some sanity-checks - // of the environment we were built in and whether it matches what we are running in. - let host_default_sysroot = host_sysroot(); - // Now see if we even need to set something. - let sysroot_flag = "--sysroot"; - if !args.iter().any(|e| e == sysroot_flag) { - // No sysroot was set, let's see if we have a custom default we want to configure. - let default_sysroot = if target_crate { + if target_crate { + // Miri needs a custom sysroot for target crates. + // If no `--sysroot` is given, the `MIRI_SYSROOT` env var is consulted to find where + // that sysroot lives, and that is passed to rustc. + let sysroot_flag = "--sysroot"; + if !args.iter().any(|e| e == sysroot_flag) { // Using the built-in default here would be plain wrong, so we *require* // the env var to make sure things make sense. - Some(env::var("MIRI_SYSROOT").unwrap_or_else(|_| { + let miri_sysroot = env::var("MIRI_SYSROOT").unwrap_or_else(|_| { show_error!( "Miri was invoked in 'target' mode without `MIRI_SYSROOT` or `--sysroot` being set" - ) - })) - } else { - host_default_sysroot - }; - if let Some(sysroot) = default_sysroot { - // We need to overwrite the default that librustc_session would compute. + ) + }); + args.push(sysroot_flag.to_owned()); - args.push(sysroot); + args.push(miri_sysroot); } } From c15cfc91c4567c4f079c2543dd395908f30f4911 Mon Sep 17 00:00:00 2001 From: Tim Neumann Date: Fri, 4 Nov 2022 16:20:42 +0000 Subject: [PATCH 214/219] LLVM 16: Switch to using MemoryEffects --- compiler/rustc_codegen_llvm/src/asm.rs | 6 +-- compiler/rustc_codegen_llvm/src/attributes.rs | 6 +-- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 11 ++++- compiler/rustc_codegen_llvm/src/llvm/mod.rs | 7 ++++ .../rustc_llvm/llvm-wrapper/LLVMWrapper.h | 1 - .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 42 ++++++++++++++++++- src/test/codegen/ffi-const.rs | 3 +- src/test/codegen/ffi-pure.rs | 3 +- 8 files changed, 67 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index 88a4f62d93d..2f22b45e810 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -285,13 +285,13 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { let mut attrs = SmallVec::<[_; 2]>::new(); if options.contains(InlineAsmOptions::PURE) { if options.contains(InlineAsmOptions::NOMEM) { - attrs.push(llvm::AttributeKind::ReadNone.create_attr(self.cx.llcx)); + attrs.push(llvm::MemoryEffects::None.create_attr(self.cx.llcx)); } else if options.contains(InlineAsmOptions::READONLY) { - attrs.push(llvm::AttributeKind::ReadOnly.create_attr(self.cx.llcx)); + attrs.push(llvm::MemoryEffects::ReadOnly.create_attr(self.cx.llcx)); } attrs.push(llvm::AttributeKind::WillReturn.create_attr(self.cx.llcx)); } else if options.contains(InlineAsmOptions::NOMEM) { - attrs.push(llvm::AttributeKind::InaccessibleMemOnly.create_attr(self.cx.llcx)); + attrs.push(llvm::MemoryEffects::InaccessibleMemOnly.create_attr(self.cx.llcx)); } else { // LLVM doesn't have an attribute to represent ReadOnly + SideEffect } diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index eff2436d41c..d96da5cc11d 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -13,7 +13,7 @@ use smallvec::SmallVec; use crate::attributes; use crate::llvm::AttributePlace::Function; -use crate::llvm::{self, AllocKindFlags, Attribute, AttributeKind, AttributePlace}; +use crate::llvm::{self, AllocKindFlags, Attribute, AttributeKind, AttributePlace, MemoryEffects}; use crate::llvm_util; pub use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr}; @@ -303,10 +303,10 @@ pub fn from_fn_attrs<'ll, 'tcx>( to_add.push(AttributeKind::ReturnsTwice.create_attr(cx.llcx)); } if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_PURE) { - to_add.push(AttributeKind::ReadOnly.create_attr(cx.llcx)); + to_add.push(MemoryEffects::ReadOnly.create_attr(cx.llcx)); } if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_CONST) { - to_add.push(AttributeKind::ReadNone.create_attr(cx.llcx)); + to_add.push(MemoryEffects::None.create_attr(cx.llcx)); } if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) { to_add.push(AttributeKind::Naked.create_attr(cx.llcx)); diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 42cb694c0e7..e2d0390821d 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -183,7 +183,6 @@ pub enum AttributeKind { OptimizeNone = 24, ReturnsTwice = 25, ReadNone = 26, - InaccessibleMemOnly = 27, SanitizeHWAddress = 28, WillReturn = 29, StackProtectReq = 30, @@ -590,6 +589,15 @@ pub enum ChecksumKind { SHA256, } +/// LLVMRustMemoryEffects +#[derive(Copy, Clone)] +#[repr(C)] +pub enum MemoryEffects { + None, + ReadOnly, + InaccessibleMemOnly, +} + extern "C" { type Opaque; } @@ -1175,6 +1183,7 @@ extern "C" { pub fn LLVMRustCreateUWTableAttr(C: &Context, async_: bool) -> &Attribute; pub fn LLVMRustCreateAllocSizeAttr(C: &Context, size_arg: u32) -> &Attribute; pub fn LLVMRustCreateAllocKindAttr(C: &Context, size_arg: u64) -> &Attribute; + pub fn LLVMRustCreateMemoryEffectsAttr(C: &Context, effects: MemoryEffects) -> &Attribute; // Operations on functions pub fn LLVMRustGetOrInsertFunction<'a>( diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs index 6602a4ab863..f820e752371 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs @@ -185,6 +185,13 @@ impl AttributeKind { } } +impl MemoryEffects { + /// Create an LLVM Attribute with these memory effects. + pub fn create_attr(self, llcx: &Context) -> &Attribute { + unsafe { LLVMRustCreateMemoryEffectsAttr(llcx, self) } + } +} + pub fn set_section(llglobal: &Value, section_name: &str) { let section_name_cstr = CString::new(section_name).expect("unexpected CString error"); unsafe { diff --git a/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h b/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h index 015c1c52bef..727cfc4416e 100644 --- a/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h +++ b/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h @@ -76,7 +76,6 @@ enum LLVMRustAttribute { OptimizeNone = 24, ReturnsTwice = 25, ReadNone = 26, - InaccessibleMemOnly = 27, SanitizeHWAddress = 28, WillReturn = 29, StackProtectReq = 30, diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 6f36281af23..0d9b5a57b69 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -8,6 +8,9 @@ #include "llvm/IR/Intrinsics.h" #include "llvm/IR/IntrinsicsARM.h" #include "llvm/IR/Mangler.h" +#if LLVM_VERSION_GE(16, 0) +#include "llvm/IR/ModRef.h" +#endif #include "llvm/Object/Archive.h" #include "llvm/Object/COFFImportFile.h" #include "llvm/Object/ObjectFile.h" @@ -213,8 +216,6 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) { return Attribute::ReturnsTwice; case ReadNone: return Attribute::ReadNone; - case InaccessibleMemOnly: - return Attribute::InaccessibleMemOnly; case SanitizeHWAddress: return Attribute::SanitizeHWAddress; case WillReturn: @@ -379,6 +380,43 @@ extern "C" LLVMAttributeRef LLVMRustCreateAllocKindAttr(LLVMContextRef C, uint64 #endif } +// Simplified representation of `MemoryEffects` across the FFI boundary. +// +// Each variant corresponds to one of the static factory methods on `MemoryEffects`. +enum class LLVMRustMemoryEffects { + None, + ReadOnly, + InaccessibleMemOnly, +}; + +extern "C" LLVMAttributeRef LLVMRustCreateMemoryEffectsAttr(LLVMContextRef C, + LLVMRustMemoryEffects Effects) { +#if LLVM_VERSION_GE(16, 0) + switch (Effects) { + case LLVMRustMemoryEffects::None: + return wrap(Attribute::getWithMemoryEffects(*unwrap(C), MemoryEffects::none())); + case LLVMRustMemoryEffects::ReadOnly: + return wrap(Attribute::getWithMemoryEffects(*unwrap(C), MemoryEffects::readOnly())); + case LLVMRustMemoryEffects::InaccessibleMemOnly: + return wrap(Attribute::getWithMemoryEffects(*unwrap(C), + MemoryEffects::inaccessibleMemOnly())); + default: + report_fatal_error("bad MemoryEffects."); + } +#else + switch (Effects) { + case LLVMRustMemoryEffects::None: + return wrap(Attribute::get(*unwrap(C), Attribute::ReadNone)); + case LLVMRustMemoryEffects::ReadOnly: + return wrap(Attribute::get(*unwrap(C), Attribute::ReadOnly)); + case LLVMRustMemoryEffects::InaccessibleMemOnly: + return wrap(Attribute::get(*unwrap(C), Attribute::InaccessibleMemOnly)); + default: + report_fatal_error("bad MemoryEffects."); + } +#endif +} + // Enable a fast-math flag // // https://llvm.org/docs/LangRef.html#fast-math-flags diff --git a/src/test/codegen/ffi-const.rs b/src/test/codegen/ffi-const.rs index d9cfa5429b5..93720503480 100644 --- a/src/test/codegen/ffi-const.rs +++ b/src/test/codegen/ffi-const.rs @@ -7,6 +7,7 @@ pub fn bar() { unsafe { foo() } } extern "C" { // CHECK-LABEL: declare{{.*}}void @foo() // CHECK-SAME: [[ATTRS:#[0-9]+]] - // CHECK-DAG: attributes [[ATTRS]] = { {{.*}}readnone{{.*}} } + // The attribute changed from `readnone` to `memory(none)` with LLVM 16.0. + // CHECK-DAG: attributes [[ATTRS]] = { {{.*}}{{readnone|memory\(none\)}}{{.*}} } #[ffi_const] pub fn foo(); } diff --git a/src/test/codegen/ffi-pure.rs b/src/test/codegen/ffi-pure.rs index 5bdb2ee912a..2ed73581358 100644 --- a/src/test/codegen/ffi-pure.rs +++ b/src/test/codegen/ffi-pure.rs @@ -7,6 +7,7 @@ pub fn bar() { unsafe { foo() } } extern "C" { // CHECK-LABEL: declare{{.*}}void @foo() // CHECK-SAME: [[ATTRS:#[0-9]+]] - // CHECK-DAG: attributes [[ATTRS]] = { {{.*}}readonly{{.*}} } + // The attribute changed from `readonly` to `memory(read)` with LLVM 16.0. + // CHECK-DAG: attributes [[ATTRS]] = { {{.*}}{{readonly|memory\(read\)}}{{.*}} } #[ffi_pure] pub fn foo(); } From b30c4d1932f7c547a431d2a67f939a8305644fdc Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 4 Nov 2022 12:34:24 -0700 Subject: [PATCH 215/219] rustdoc: simplify search results CSS and DOM There is a layout change caused by this commit, but it's subtle. You won't notice it unless you're looking for it. --- src/librustdoc/html/static/css/rustdoc.css | 20 ++++++------------- src/librustdoc/html/static/js/search.js | 6 ++---- .../rustdoc-gui/search-result-display.goml | 2 +- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 54f6e1ed4d5..227d9ac464b 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -889,23 +889,17 @@ so that we can apply CSS-filters to change the arrow color in themes */ } .search-results > a { - display: block; + display: flex; /* A little margin ensures the browser's outlining of focused links has room to display. */ margin-left: 2px; margin-right: 2px; border-bottom: 1px solid var(--border-color); + gap: 1em; } .search-results > a > div { - display: flex; - flex-flow: row wrap; -} - -.search-results .result-name, .search-results div.desc { - width: 50%; -} -.search-results .result-name { - padding-right: 1em; + flex: 1; + overflow: hidden; } .search-results a:hover, @@ -1867,7 +1861,8 @@ in storage.js } /* Display an alternating layout on tablets and phones */ - .item-table, .item-row, .item-left, .item-right { + .item-table, .item-row, .item-left, .item-right, + .search-results > a, .search-results > a > div { display: block; } @@ -1875,9 +1870,6 @@ in storage.js .search-results > a { padding: 5px 0px; } - .search-results .result-name, .search-results div.desc { - width: 100%; - } .search-results div.desc, .item-right { padding-left: 2em; } diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index d04ec357c40..ef3c74f5faa 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -1593,7 +1593,6 @@ function initSearch(rawSearchIndex) { link.className = "result-" + type; link.href = item.href; - const wrapper = document.createElement("div"); const resultName = document.createElement("div"); resultName.className = "result-name"; @@ -1614,7 +1613,7 @@ function initSearch(rawSearchIndex) { resultName.insertAdjacentHTML( "beforeend", item.displayPath + "" + name + extra + ""); - wrapper.appendChild(resultName); + link.appendChild(resultName); const description = document.createElement("div"); description.className = "desc"; @@ -1622,8 +1621,7 @@ function initSearch(rawSearchIndex) { spanDesc.insertAdjacentHTML("beforeend", item.desc); description.appendChild(spanDesc); - wrapper.appendChild(description); - link.appendChild(wrapper); + link.appendChild(description); output.appendChild(link); }); } else if (query.error === null) { diff --git a/src/test/rustdoc-gui/search-result-display.goml b/src/test/rustdoc-gui/search-result-display.goml index 053bfd8c905..b8abd9f9062 100644 --- a/src/test/rustdoc-gui/search-result-display.goml +++ b/src/test/rustdoc-gui/search-result-display.goml @@ -7,7 +7,7 @@ press-key: 'Enter' wait-for: "#crate-search" // The width is returned by "getComputedStyle" which returns the exact number instead of the // CSS rule which is "50%"... -assert-css: (".search-results div.desc", {"width": "318px"}) +assert-css: (".search-results div.desc", {"width": "310px"}) size: (600, 100) // As counter-intuitive as it may seem, in this width, the width is "100%", which is why // when computed it's larger. From 4bd6748bb9b73c210558498070ae0b7ed8193ddf Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 4 Nov 2022 13:19:33 -0700 Subject: [PATCH 216/219] rustdoc: get rid of CSS/DOM `div.desc span`, which isn't really needed --- src/librustdoc/html/static/css/rustdoc.css | 15 +++++++-------- src/librustdoc/html/static/js/search.js | 4 +--- src/test/rustdoc-gui/search-result-color.goml | 8 ++++---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 227d9ac464b..7c0dab1c527 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -881,13 +881,6 @@ so that we can apply CSS-filters to change the arrow color in themes */ display: block; } -.search-results .desc > span { - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; - display: block; -} - .search-results > a { display: flex; /* A little margin ensures the browser's outlining of focused links has room to display. */ @@ -899,7 +892,13 @@ so that we can apply CSS-filters to change the arrow color in themes */ .search-results > a > div { flex: 1; +} + +.search-results > a > div.desc { + white-space: nowrap; + text-overflow: ellipsis; overflow: hidden; + display: block; } .search-results a:hover, @@ -1870,7 +1869,7 @@ in storage.js .search-results > a { padding: 5px 0px; } - .search-results div.desc, .item-right { + .search-results > a > div.desc, .item-right { padding-left: 2em; } diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index ef3c74f5faa..dd0531c5e70 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -1617,10 +1617,8 @@ function initSearch(rawSearchIndex) { const description = document.createElement("div"); description.className = "desc"; - const spanDesc = document.createElement("span"); - spanDesc.insertAdjacentHTML("beforeend", item.desc); + description.insertAdjacentHTML("beforeend", item.desc); - description.appendChild(spanDesc); link.appendChild(description); output.appendChild(link); }); diff --git a/src/test/rustdoc-gui/search-result-color.goml b/src/test/rustdoc-gui/search-result-color.goml index 37d7b03a099..0c3b1119074 100644 --- a/src/test/rustdoc-gui/search-result-color.goml +++ b/src/test/rustdoc-gui/search-result-color.goml @@ -67,7 +67,7 @@ reload: // Waiting for the search results to appear... wait-for: "#titles" assert-css: ( - "//*[@class='desc']//*[text()='Just a normal struct.']", + "//*[@class='desc'][text()='Just a normal struct.']", {"color": "rgb(197, 197, 197)"}, ) assert-css: ( @@ -159,7 +159,7 @@ assert-css: ( ) // Checking color and background on hover. -move-cursor-to: "//*[@class='desc']//*[text()='Just a normal struct.']" +move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']" assert-css: ( "//*[@class='result-name']/*[text()='test_docs::']", {"color": "rgb(255, 255, 255)"}, @@ -179,7 +179,7 @@ reload: // Waiting for the search results to appear... wait-for: "#titles" assert-css: ( - "//*[@class='desc']//*[text()='Just a normal struct.']", + "//*[@class='desc'][text()='Just a normal struct.']", {"color": "rgb(221, 221, 221)"}, ) assert-css: ( @@ -276,7 +276,7 @@ reload: // Waiting for the search results to appear... wait-for: "#titles" assert-css: ( - "//*[@class='desc']//*[text()='Just a normal struct.']", + "//*[@class='desc'][text()='Just a normal struct.']", {"color": "rgb(0, 0, 0)"}, ) assert-css: ( From c97fd8183a98d6a89b8fc2e02eb068298e6fb7dc Mon Sep 17 00:00:00 2001 From: Mateusz Date: Fri, 4 Nov 2022 20:33:32 +0000 Subject: [PATCH 217/219] Refactor tcx mk_const parameters. --- .../src/check/compare_method.rs | 11 ++++------ .../src/infer/canonical/canonicalizer.rs | 8 ++++---- .../rustc_infer/src/infer/canonical/mod.rs | 7 +------ compiler/rustc_infer/src/infer/combine.rs | 16 +++++++-------- .../src/infer/higher_ranked/mod.rs | 6 +++--- compiler/rustc_infer/src/infer/mod.rs | 8 ++++---- compiler/rustc_middle/src/infer/canonical.rs | 8 ++++---- compiler/rustc_middle/src/mir/mod.rs | 6 ++---- compiler/rustc_middle/src/ty/codec.rs | 3 ++- compiler/rustc_middle/src/ty/consts.rs | 13 +++++------- compiler/rustc_middle/src/ty/context.rs | 15 +++++++++----- compiler/rustc_middle/src/ty/fold.rs | 12 +++-------- compiler/rustc_middle/src/ty/relate.rs | 8 ++++---- .../rustc_middle/src/ty/structural_impls.rs | 2 +- .../src/build/expr/as_constant.rs | 3 +-- compiler/rustc_symbol_mangling/src/v0.rs | 3 +-- .../src/traits/project.rs | 11 +++------- .../src/traits/select/confirmation.rs | 8 ++++---- compiler/rustc_traits/src/chalk/db.rs | 8 ++++---- compiler/rustc_traits/src/chalk/lowering.rs | 2 +- compiler/rustc_ty_utils/src/consts.rs | 20 +++++-------------- 21 files changed, 74 insertions(+), 104 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/compare_method.rs b/compiler/rustc_hir_analysis/src/check/compare_method.rs index aeaf7a6cfe1..c6b497e9b9f 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_method.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_method.rs @@ -1655,13 +1655,10 @@ pub fn check_type_bounds<'tcx>( GenericParamDefKind::Const { .. } => { let bound_var = ty::BoundVariableKind::Const; bound_vars.push(bound_var); - tcx.mk_const(ty::ConstS { - ty: tcx.type_of(param.def_id), - kind: ty::ConstKind::Bound( - ty::INNERMOST, - ty::BoundVar::from_usize(bound_vars.len() - 1), - ), - }) + tcx.mk_const( + ty::ConstKind::Bound(ty::INNERMOST, ty::BoundVar::from_usize(bound_vars.len() - 1)), + tcx.type_of(param.def_id), + ) .into() } }); diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index a3ff7036340..365b4b1fccd 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -773,10 +773,10 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> { self.fold_const(bound_to) } else { let var = self.canonical_var(info, const_var.into()); - self.tcx().mk_const(ty::ConstS { - kind: ty::ConstKind::Bound(self.binder_index, var), - ty: self.fold_ty(const_var.ty()), - }) + self.tcx().mk_const( + ty::ConstKind::Bound(self.binder_index, var), + self.fold_ty(const_var.ty()), + ) } } } diff --git a/compiler/rustc_infer/src/infer/canonical/mod.rs b/compiler/rustc_infer/src/infer/canonical/mod.rs index cbd6481f9cb..0794792d8cb 100644 --- a/compiler/rustc_infer/src/infer/canonical/mod.rs +++ b/compiler/rustc_infer/src/infer/canonical/mod.rs @@ -147,12 +147,7 @@ impl<'tcx> InferCtxt<'tcx> { CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, name }, ty) => { let universe_mapped = universe_map(universe); let placeholder_mapped = ty::PlaceholderConst { universe: universe_mapped, name }; - self.tcx - .mk_const(ty::ConstS { - kind: ty::ConstKind::Placeholder(placeholder_mapped), - ty, - }) - .into() + self.tcx.mk_const(ty::ConstKind::Placeholder(placeholder_mapped), ty).into() } } } diff --git a/compiler/rustc_infer/src/infer/combine.rs b/compiler/rustc_infer/src/infer/combine.rs index b5427f639c1..a973bf54b05 100644 --- a/compiler/rustc_infer/src/infer/combine.rs +++ b/compiler/rustc_infer/src/infer/combine.rs @@ -741,10 +741,10 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> { substs, substs, )?; - Ok(self.tcx().mk_const(ty::ConstS { - ty: c.ty(), - kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }), - })) + Ok(self.tcx().mk_const( + ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }), + c.ty(), + )) } _ => relate::super_relate_consts(self, c, c), } @@ -955,10 +955,10 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> { substs, )?; - Ok(self.tcx().mk_const(ty::ConstS { - ty: c.ty(), - kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }), - })) + Ok(self.tcx().mk_const( + ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }), + c.ty(), + )) } _ => relate::super_relate_consts(self, c, c), } diff --git a/compiler/rustc_infer/src/infer/higher_ranked/mod.rs b/compiler/rustc_infer/src/infer/higher_ranked/mod.rs index 28c87a1159f..d739323de77 100644 --- a/compiler/rustc_infer/src/infer/higher_ranked/mod.rs +++ b/compiler/rustc_infer/src/infer/higher_ranked/mod.rs @@ -94,13 +94,13 @@ impl<'tcx> InferCtxt<'tcx> { })) }, consts: &mut |bound_var: ty::BoundVar, ty| { - self.tcx.mk_const(ty::ConstS { - kind: ty::ConstKind::Placeholder(ty::PlaceholderConst { + self.tcx.mk_const( + ty::ConstKind::Placeholder(ty::PlaceholderConst { universe: next_universe, name: bound_var, }), ty, - }) + ) }, }; diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index ffb020398b8..c2eecd9e87a 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -2065,13 +2065,13 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>( if ty.has_non_region_param() || ty.has_non_region_infer() { bug!("const `{ct}`'s type should not reference params or types"); } - tcx.mk_const(ty::ConstS { - ty, - kind: ty::ConstKind::Placeholder(ty::PlaceholderConst { + tcx.mk_const( + ty::ConstKind::Placeholder(ty::PlaceholderConst { universe: ty::UniverseIndex::ROOT, name: ty::BoundVar::from_usize(idx), }), - }) + ty, + ) .into() } _ => arg, diff --git a/compiler/rustc_middle/src/infer/canonical.rs b/compiler/rustc_middle/src/infer/canonical.rs index d3cf519b633..8d1ed4b2a52 100644 --- a/compiler/rustc_middle/src/infer/canonical.rs +++ b/compiler/rustc_middle/src/infer/canonical.rs @@ -341,10 +341,10 @@ impl<'tcx> CanonicalVarValues<'tcx> { tcx.mk_region(ty::ReLateBound(ty::INNERMOST, br)).into() } GenericArgKind::Const(ct) => tcx - .mk_const(ty::ConstS { - ty: ct.ty(), - kind: ty::ConstKind::Bound(ty::INNERMOST, ty::BoundVar::from_u32(i)), - }) + .mk_const( + ty::ConstKind::Bound(ty::INNERMOST, ty::BoundVar::from_u32(i)), + ct.ty(), + ) .into(), }) .collect(), diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 068daaadbda..0a96d23e354 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -2414,10 +2414,8 @@ impl<'tcx> ConstantKind<'tcx> { let generics = tcx.generics_of(item_def_id.to_def_id()); let index = generics.param_def_id_to_index[&def_id]; let name = tcx.hir().name(hir_id); - let ty_const = tcx.mk_const(ty::ConstS { - kind: ty::ConstKind::Param(ty::ParamConst::new(index, name)), - ty, - }); + let ty_const = + tcx.mk_const(ty::ConstKind::Param(ty::ParamConst::new(index, name)), ty); debug!(?ty_const); return Self::Ty(ty_const); diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs index 14ec88b7e0d..7263e8306cf 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -310,7 +310,8 @@ impl<'tcx, D: TyDecoder>> RefDecodable<'tcx, D> impl<'tcx, D: TyDecoder>> Decodable for ty::Const<'tcx> { fn decode(decoder: &mut D) -> Self { - decoder.interner().mk_const(Decodable::decode(decoder)) + let consts: ty::ConstS<'tcx> = Decodable::decode(decoder); + decoder.interner().mk_const(consts.kind, consts.ty) } } diff --git a/compiler/rustc_middle/src/ty/consts.rs b/compiler/rustc_middle/src/ty/consts.rs index f998e608344..33fdf1a8370 100644 --- a/compiler/rustc_middle/src/ty/consts.rs +++ b/compiler/rustc_middle/src/ty/consts.rs @@ -77,13 +77,13 @@ impl<'tcx> Const<'tcx> { match Self::try_eval_lit_or_param(tcx, ty, expr) { Some(v) => v, - None => tcx.mk_const(ty::ConstS { - kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst { + None => tcx.mk_const( + ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def: def.to_global(), substs: InternalSubsts::identity_for_item(tcx, def.did.to_def_id()), }), ty, - }), + ), } } @@ -138,10 +138,7 @@ impl<'tcx> Const<'tcx> { let generics = tcx.generics_of(item_def_id.to_def_id()); let index = generics.param_def_id_to_index[&def_id]; let name = tcx.hir().name(hir_id); - Some(tcx.mk_const(ty::ConstS { - kind: ty::ConstKind::Param(ty::ParamConst::new(index, name)), - ty, - })) + Some(tcx.mk_const(ty::ConstKind::Param(ty::ParamConst::new(index, name)), ty)) } _ => None, } @@ -150,7 +147,7 @@ impl<'tcx> Const<'tcx> { /// Interns the given value as a constant. #[inline] pub fn from_value(tcx: TyCtxt<'tcx>, val: ty::ValTree<'tcx>, ty: Ty<'tcx>) -> Self { - tcx.mk_const(ConstS { kind: ConstKind::Value(val), ty }) + tcx.mk_const(ConstKind::Value(val), ty) } /// Panics if self.kind != ty::ConstKind::Value diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index fc3b0716849..e039436fe0a 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1316,7 +1316,7 @@ impl<'tcx> TyCtxt<'tcx> { msg: &str, ) -> Const<'tcx> { let reported = self.sess.delay_span_bug(span, msg); - self.mk_const(ty::ConstS { kind: ty::ConstKind::Error(reported), ty }) + self.mk_const(ty::ConstKind::Error(reported), ty) } pub fn consider_optimizing String>(self, msg: T) -> bool { @@ -2231,7 +2231,7 @@ macro_rules! direct_interners { direct_interners! { region: mk_region(RegionKind<'tcx>): Region -> Region<'tcx>, - const_: mk_const(ConstS<'tcx>): Const -> Const<'tcx>, + const_: mk_const_internal(ConstS<'tcx>): Const -> Const<'tcx>, const_allocation: intern_const_alloc(Allocation): ConstAllocation -> ConstAllocation<'tcx>, layout: intern_layout(LayoutS<'tcx>): Layout -> Layout<'tcx>, adt_def: intern_adt_def(AdtDefData): AdtDef -> AdtDef<'tcx>, @@ -2569,9 +2569,14 @@ impl<'tcx> TyCtxt<'tcx> { self.mk_ty_infer(TyVar(v)) } + #[inline] + pub fn mk_const(self, kind: ty::ConstKind<'tcx>, ty: Ty<'tcx>) -> Const<'tcx> { + self.mk_const_internal(ty::ConstS { kind, ty }) + } + #[inline] pub fn mk_const_var(self, v: ConstVid<'tcx>, ty: Ty<'tcx>) -> Const<'tcx> { - self.mk_const(ty::ConstS { kind: ty::ConstKind::Infer(InferConst::Var(v)), ty }) + self.mk_const(ty::ConstKind::Infer(InferConst::Var(v)), ty) } #[inline] @@ -2591,7 +2596,7 @@ impl<'tcx> TyCtxt<'tcx> { #[inline] pub fn mk_const_infer(self, ic: InferConst<'tcx>, ty: Ty<'tcx>) -> ty::Const<'tcx> { - self.mk_const(ty::ConstS { kind: ty::ConstKind::Infer(ic), ty }) + self.mk_const(ty::ConstKind::Infer(ic), ty) } #[inline] @@ -2601,7 +2606,7 @@ impl<'tcx> TyCtxt<'tcx> { #[inline] pub fn mk_const_param(self, index: u32, name: Symbol, ty: Ty<'tcx>) -> Const<'tcx> { - self.mk_const(ty::ConstS { kind: ty::ConstKind::Param(ParamConst { index, name }), ty }) + self.mk_const(ty::ConstKind::Param(ParamConst { index, name }), ty) } pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> GenericArg<'tcx> { diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index 54f1499eb3d..a329753726e 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -566,10 +566,7 @@ impl<'tcx> TyCtxt<'tcx> { )) }, consts: &mut |c, ty: Ty<'tcx>| { - self.mk_const(ty::ConstS { - kind: ty::ConstKind::Bound(ty::INNERMOST, shift_bv(c)), - ty, - }) + self.mk_const(ty::ConstKind::Bound(ty::INNERMOST, shift_bv(c)), ty) }, }, ) @@ -648,7 +645,7 @@ impl<'tcx> TyCtxt<'tcx> { let index = entry.index(); let var = ty::BoundVar::from_usize(index); let () = entry.or_insert_with(|| ty::BoundVariableKind::Const).expect_const(); - self.tcx.mk_const(ty::ConstS { ty, kind: ty::ConstKind::Bound(ty::INNERMOST, var) }) + self.tcx.mk_const(ty::ConstKind::Bound(ty::INNERMOST, var), ty) } } @@ -732,10 +729,7 @@ impl<'tcx> TypeFolder<'tcx> for Shifter<'tcx> { ct } else { let debruijn = debruijn.shifted_in(self.amount); - self.tcx.mk_const(ty::ConstS { - kind: ty::ConstKind::Bound(debruijn, bound_ct), - ty: ct.ty(), - }) + self.tcx.mk_const(ty::ConstKind::Bound(debruijn, bound_ct), ct.ty()) } } else { ct.super_fold_with(self) diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index b25b4bd4fe3..c083a405e3c 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -639,10 +639,10 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>( au.substs, bu.substs, )?; - return Ok(tcx.mk_const(ty::ConstS { - kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def: au.def, substs }), - ty: a.ty(), - })); + return Ok(tcx.mk_const( + ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def: au.def, substs }), + a.ty(), + )); } _ => false, }; diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 23cd93d6af4..f2070869ce0 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -805,7 +805,7 @@ impl<'tcx> TypeSuperFoldable<'tcx> for ty::Const<'tcx> { let ty = self.ty().try_fold_with(folder)?; let kind = self.kind().try_fold_with(folder)?; if ty != self.ty() || kind != self.kind() { - Ok(folder.tcx().mk_const(ty::ConstS { ty, kind })) + Ok(folder.tcx().mk_const(kind, ty)) } else { Ok(self) } diff --git a/compiler/rustc_mir_build/src/build/expr/as_constant.rs b/compiler/rustc_mir_build/src/build/expr/as_constant.rs index 37dc1ad9f0d..98df9c3f0e8 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_constant.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_constant.rs @@ -74,8 +74,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Constant { user_ty, span, literal } } ExprKind::ConstParam { param, def_id: _ } => { - let const_param = - tcx.mk_const(ty::ConstS { kind: ty::ConstKind::Param(param), ty: expr.ty }); + let const_param = tcx.mk_const(ty::ConstKind::Param(param), expr.ty); let literal = ConstantKind::Ty(const_param); Constant { user_ty: None, span, literal } diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index ecfe6861e84..2109b3c2496 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -654,8 +654,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> { .builtin_deref(true) .expect("tried to dereference on non-ptr type") .ty; - let dereferenced_const = - self.tcx.mk_const(ty::ConstS { kind: ct.kind(), ty: pointee_ty }); + let dereferenced_const = self.tcx.mk_const(ct.kind(), pointee_ty); self = dereferenced_const.print(self)?; } } diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index c8276854016..daee5dd8f02 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -831,9 +831,7 @@ impl<'tcx> TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> { let universe = self.universe_for(debruijn); let p = ty::PlaceholderConst { universe, name: bound_const }; self.mapped_consts.insert(p, bound_const); - self.infcx - .tcx - .mk_const(ty::ConstS { kind: ty::ConstKind::Placeholder(p), ty: ct.ty() }) + self.infcx.tcx.mk_const(ty::ConstKind::Placeholder(p), ct.ty()) } _ => ct.super_fold_with(self), } @@ -968,10 +966,7 @@ impl<'tcx> TypeFolder<'tcx> for PlaceholderReplacer<'_, 'tcx> { let db = ty::DebruijnIndex::from_usize( self.universe_indices.len() - index + self.current_index.as_usize() - 1, ); - self.tcx().mk_const(ty::ConstS { - kind: ty::ConstKind::Bound(db, *replace_var), - ty: ct.ty(), - }) + self.tcx().mk_const(ty::ConstKind::Bound(db, *replace_var), ct.ty()) } None => ct, } @@ -2173,7 +2168,7 @@ fn confirm_impl_candidate<'cx, 'tcx>( crate::traits::InternalSubsts::identity_for_item(tcx, assoc_ty.item.def_id); let did = ty::WithOptConstParam::unknown(assoc_ty.item.def_id); let kind = ty::ConstKind::Unevaluated(ty::UnevaluatedConst::new(did, identity_substs)); - ty.map_bound(|ty| tcx.mk_const(ty::ConstS { ty, kind }).into()) + ty.map_bound(|ty| tcx.mk_const(kind, ty).into()) } else { ty.map_bound(|ty| ty.into()) }; diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index ed22058c646..28b4bae7cbe 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -555,13 +555,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { GenericParamDefKind::Const { .. } => { let bound_var = ty::BoundVariableKind::Const; bound_vars.push(bound_var); - tcx.mk_const(ty::ConstS { - ty: tcx.type_of(param.def_id), - kind: ty::ConstKind::Bound( + tcx.mk_const( + ty::ConstKind::Bound( ty::INNERMOST, ty::BoundVar::from_usize(bound_vars.len() - 1), ), - }) + tcx.type_of(param.def_id), + ) .into() } }); diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 0de28b82661..2035252fe39 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -734,10 +734,10 @@ fn bound_vars_for_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx } ty::GenericParamDefKind::Const { .. } => tcx - .mk_const(ty::ConstS { - kind: ty::ConstKind::Bound(ty::INNERMOST, ty::BoundVar::from(param.index)), - ty: tcx.type_of(param.def_id), - }) + .mk_const( + ty::ConstKind::Bound(ty::INNERMOST, ty::BoundVar::from(param.index)), + tcx.type_of(param.def_id), + ) .into(), }) } diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 45d5ea93d54..0492e94b94e 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -546,7 +546,7 @@ impl<'tcx> LowerInto<'tcx, ty::Const<'tcx>> for &chalk_ir::Const unimplemented!(), chalk_ir::ConstValue::Concrete(c) => ty::ConstKind::Value(c.interned), }; - interner.tcx.mk_const(ty::ConstS { ty, kind }) + interner.tcx.mk_const(kind, ty) } } diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index e057bb66825..3cef47c0f8b 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -33,7 +33,7 @@ pub(crate) fn destructure_const<'tcx>( // construct the consts for the elements of the array/slice let field_consts = branches .iter() - .map(|b| tcx.mk_const(ty::ConstS { kind: ty::ConstKind::Value(*b), ty: *inner_ty })) + .map(|b| tcx.mk_const(ty::ConstKind::Value(*b), *inner_ty)) .collect::>(); debug!(?field_consts); @@ -52,10 +52,7 @@ pub(crate) fn destructure_const<'tcx>( for (field, field_valtree) in iter::zip(fields, branches) { let field_ty = field.ty(tcx, substs); - let field_const = tcx.mk_const(ty::ConstS { - kind: ty::ConstKind::Value(*field_valtree), - ty: field_ty, - }); + let field_const = tcx.mk_const(ty::ConstKind::Value(*field_valtree), field_ty); field_consts.push(field_const); } debug!(?field_consts); @@ -65,10 +62,7 @@ pub(crate) fn destructure_const<'tcx>( ty::Tuple(elem_tys) => { let fields = iter::zip(*elem_tys, branches) .map(|(elem_ty, elem_valtree)| { - tcx.mk_const(ty::ConstS { - kind: ty::ConstKind::Value(*elem_valtree), - ty: elem_ty, - }) + tcx.mk_const(ty::ConstKind::Value(*elem_valtree), elem_ty) }) .collect::>(); @@ -261,17 +255,13 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> { let uneval = ty::UnevaluatedConst::new(ty::WithOptConstParam::unknown(def_id), substs); - let constant = self - .tcx - .mk_const(ty::ConstS { kind: ty::ConstKind::Unevaluated(uneval), ty: node.ty }); + let constant = self.tcx.mk_const(ty::ConstKind::Unevaluated(uneval), node.ty); self.nodes.push(Node::Leaf(constant)) } ExprKind::ConstParam { param, .. } => { - let const_param = self - .tcx - .mk_const(ty::ConstS { kind: ty::ConstKind::Param(*param), ty: node.ty }); + let const_param = self.tcx.mk_const(ty::ConstKind::Param(*param), node.ty); self.nodes.push(Node::Leaf(const_param)) } From bfce227c6ad10ba57302403c188fa6e2968cb4b5 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Fri, 4 Nov 2022 23:50:44 +0000 Subject: [PATCH 218/219] Update cargo 20 commits in 7e484fc1a766f56dbc95380f45719698e0c82749..9286a1beba5b28b115bad67de2ae91fb1c61eb0b 2022-10-27 15:20:57 +0000 to 2022-11-04 06:41:49 +0000 - chore: Upgrade dependencies (rust-lang/cargo#11328) - Clean more aggressively in CI (rust-lang/cargo#11335) - Remove remove_dir_all (rust-lang/cargo#11333) - test(publish): Cover more wait-for-publish cases (rust-lang/cargo#11327) - Revert rust-lang/cargo#11183 (rust-lang/cargo#11331) - fix(semver-check): adapt to a different error for variant not covered (rust-lang/cargo#11332) - Update curl-sys (rust-lang/cargo#11326) - Mention fix on build script deadlock (rust-lang/cargo#11325) - Make cargo forward pre-existing CARGO if set (rust-lang/cargo#11285) - Clean up workspace dependencies after cargo remove (rust-lang/cargo#11242) - Update the outdated link for rust-semverver (rust-lang/cargo#11322) - Fix broken link to compilation entry point (rust-lang/cargo#11317) - Only remove fingerprints and build script artifacts of the requested package (rust-lang/cargo#10621) - Newer anyhow features are required (rust-lang/cargo#11316) - Clean stale git temp files (rust-lang/cargo#11308) - Report crate size on package and publish (rust-lang/cargo#11270) - add a note that some warnings (and/or errors) can be auto-fixed (rust-lang/cargo#10989) - Update libcurl (rust-lang/cargo#11307) - artifact deps shoud works when target field specified coexists with `optional = true` (rust-lang/cargo#11183) - Fix singular verb in tests page (rust-lang/cargo#11300) --- Cargo.lock | 91 ++++++++++++++++++++++++++++++++++++++----------- src/tools/cargo | 2 +- 2 files changed, 72 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b73a4d6f2da..55433a55a18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -427,7 +427,6 @@ dependencies = [ "glob", "itertools", "lazy_static", - "remove_dir_all", "serde_json", "snapbox", "tar", @@ -449,7 +448,7 @@ dependencies = [ "jobserver", "libc", "log", - "miow", + "miow 0.4.0", "same-file", "shell-escape", "tempfile", @@ -815,7 +814,7 @@ dependencies = [ "lazy_static", "lazycell", "libc", - "miow", + "miow 0.3.7", "miropt-test-tools", "regex", "rustfix", @@ -840,7 +839,7 @@ dependencies = [ "lazy_static", "libc", "log", - "miow", + "miow 0.3.7", "regex", "rustfix", "serde", @@ -853,9 +852,9 @@ dependencies = [ [[package]] name = "concolor" -version = "0.0.8" +version = "0.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "015267563b1df20adccdd00cb05257b1dfbea70a04928e9cf88ffb850c1a40af" +checksum = "b90f9dcd9490a97db91a85ccd79e38a87e14323f0bb824659ee3274e9143ba37" dependencies = [ "atty", "bitflags", @@ -864,9 +863,9 @@ dependencies = [ [[package]] name = "concolor-query" -version = "0.0.5" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6417fe6fc03a8b533fd2177742eeb39a90c7233eedec7bac96d4d6b69a09449" +checksum = "82a90734b3d5dcf656e7624cca6bce9c3a90ee11f900e80141a7427ccfb3d317" [[package]] name = "content_inspector" @@ -1036,9 +1035,9 @@ dependencies = [ [[package]] name = "curl" -version = "0.4.43" +version = "0.4.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d855aeef205b43f65a5001e0997d81f8efca7badad4fad7d897aa7f0d0651f" +checksum = "509bd11746c7ac09ebd19f0b17782eae80aadee26237658a6b4808afb5c11a22" dependencies = [ "curl-sys", "libc", @@ -1051,9 +1050,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.55+curl-7.83.1" +version = "0.4.59+curl-7.86.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23734ec77368ec583c2e61dd3f0b0e5c98b93abe6d2a004ca06b91dd7e3e2762" +checksum = "6cfce34829f448b08f55b7db6d0009e23e2e86a34e8c2b366269bf5799b4a407" dependencies = [ "cc", "libc", @@ -2257,6 +2256,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "miow" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7377f7792b3afb6a3cba68daa54ca23c032137010460d667fda53a8d66be00e" +dependencies = [ + "windows-sys 0.28.0", +] + [[package]] name = "miri" version = "0.1.0" @@ -2541,7 +2549,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -4628,9 +4636,9 @@ checksum = "da73c8f77aebc0e40c300b93f0a5f1bece7a248a36eee287d4e095f35c7b7d6e" [[package]] name = "snapbox" -version = "0.3.3" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d199ccf8f606592df2d145db26f2aa45344e23c64b074cc5a4047f1d99b0f7" +checksum = "827c00e91b15e2674d8a5270bae91f898693cbf9561cbb58d8eaa31974597293" dependencies = [ "concolor", "content_inspector", @@ -5475,43 +5483,86 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82ca39602d5cbfa692c4b67e3bcbb2751477355141c1ed434c94da4186836ff6" +dependencies = [ + "windows_aarch64_msvc 0.28.0", + "windows_i686_gnu 0.28.0", + "windows_i686_msvc 0.28.0", + "windows_x86_64_gnu 0.28.0", + "windows_x86_64_msvc 0.28.0", +] + [[package]] name = "windows-sys" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", ] +[[package]] +name = "windows_aarch64_msvc" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52695a41e536859d5308cc613b4a022261a274390b25bd29dfff4bf08505f3c2" + [[package]] name = "windows_aarch64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +[[package]] +name = "windows_i686_gnu" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f54725ac23affef038fecb177de6c9bf065787c2f432f79e3c373da92f3e1d8a" + [[package]] name = "windows_i686_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +[[package]] +name = "windows_i686_msvc" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d5158a43cc43623c0729d1ad6647e62fa384a3d135fd15108d37c683461f64" + [[package]] name = "windows_i686_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +[[package]] +name = "windows_x86_64_gnu" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc31f409f565611535130cfe7ee8e6655d3fa99c1c61013981e491921b5ce954" + [[package]] name = "windows_x86_64_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +[[package]] +name = "windows_x86_64_msvc" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f2b8c7cbd3bfdddd9ab98769f9746a7fad1bca236554cd032b78d768bc0e89f" + [[package]] name = "windows_x86_64_msvc" version = "0.36.1" diff --git a/src/tools/cargo b/src/tools/cargo index 7e484fc1a76..9286a1beba5 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 7e484fc1a766f56dbc95380f45719698e0c82749 +Subproject commit 9286a1beba5b28b115bad67de2ae91fb1c61eb0b From 2f882c014f3bfabb811177d24bfb72e3f6b6d271 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Sat, 5 Nov 2022 01:11:50 +0000 Subject: [PATCH 219/219] Specify that `break` cannot be used outside of loop *or* labeled block --- compiler/rustc_error_messages/locales/en-US/passes.ftl | 10 ++++++++-- compiler/rustc_passes/src/errors.rs | 1 + compiler/rustc_passes/src/loops.rs | 2 +- src/test/ui/array-slice-vec/array-break-length.stderr | 4 ++-- src/test/ui/closures/closure-array-break-length.stderr | 4 ++-- src/test/ui/error-codes/E0268.stderr | 4 ++-- src/test/ui/for-loop-while/break-outside-loop.stderr | 8 ++++---- src/test/ui/issues/issue-28105.stderr | 4 ++-- src/test/ui/issues/issue-43162.stderr | 8 ++++---- src/test/ui/issues/issue-50576.stderr | 8 ++++---- src/test/ui/issues/issue-50581.stderr | 4 ++-- src/test/ui/issues/issue-83048.rs | 2 +- src/test/ui/issues/issue-83048.stderr | 4 ++-- src/test/ui/track-diagnostics/track.stderr | 4 ++-- 14 files changed, 37 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_error_messages/locales/en-US/passes.ftl b/compiler/rustc_error_messages/locales/en-US/passes.ftl index 88286c15f9e..5239ff9dc05 100644 --- a/compiler/rustc_error_messages/locales/en-US/passes.ftl +++ b/compiler/rustc_error_messages/locales/en-US/passes.ftl @@ -451,8 +451,14 @@ passes_break_inside_async_block = .async_block_label = enclosing `async` block passes_outside_loop = - `{$name}` outside of a loop - .label = cannot `{$name}` outside of a loop + `{$name}` outside of a loop{$is_break -> + [true] {" or labeled block"} + *[false] {""} + } + .label = cannot `{$name}` outside of a loop{$is_break -> + [true] {" or labeled block"} + *[false] {""} + } passes_unlabeled_in_labeled_block = unlabeled `{$cf_type}` inside of a labeled block diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index d8bed700f52..1dbf0d642e2 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -956,6 +956,7 @@ pub struct OutsideLoop<'a> { #[label] pub span: Span, pub name: &'a str, + pub is_break: bool, } #[derive(Diagnostic)] diff --git a/compiler/rustc_passes/src/loops.rs b/compiler/rustc_passes/src/loops.rs index 077194ec687..b4cf19e4a34 100644 --- a/compiler/rustc_passes/src/loops.rs +++ b/compiler/rustc_passes/src/loops.rs @@ -193,7 +193,7 @@ impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> { self.sess.emit_err(BreakInsideAsyncBlock { span, closure_span, name }); } Normal | AnonConst => { - self.sess.emit_err(OutsideLoop { span, name }); + self.sess.emit_err(OutsideLoop { span, name, is_break: name == "break" }); } } } diff --git a/src/test/ui/array-slice-vec/array-break-length.stderr b/src/test/ui/array-slice-vec/array-break-length.stderr index 93f1c238bcc..2df7b6d7f63 100644 --- a/src/test/ui/array-slice-vec/array-break-length.stderr +++ b/src/test/ui/array-slice-vec/array-break-length.stderr @@ -1,8 +1,8 @@ -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/array-break-length.rs:3:17 | LL | |_: [_; break]| {} - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error[E0268]: `continue` outside of a loop --> $DIR/array-break-length.rs:7:17 diff --git a/src/test/ui/closures/closure-array-break-length.stderr b/src/test/ui/closures/closure-array-break-length.stderr index 2b8ab9bfc44..7e0b0027a6f 100644 --- a/src/test/ui/closures/closure-array-break-length.stderr +++ b/src/test/ui/closures/closure-array-break-length.stderr @@ -10,11 +10,11 @@ error[E0268]: `continue` outside of a loop LL | while |_: [_; continue]| {} {} | ^^^^^^^^ cannot `continue` outside of a loop -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/closure-array-break-length.rs:6:19 | LL | while |_: [_; break]| {} {} - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error: aborting due to 3 previous errors diff --git a/src/test/ui/error-codes/E0268.stderr b/src/test/ui/error-codes/E0268.stderr index c926f9e4874..6422e8a9490 100644 --- a/src/test/ui/error-codes/E0268.stderr +++ b/src/test/ui/error-codes/E0268.stderr @@ -1,8 +1,8 @@ -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/E0268.rs:2:5 | LL | break; - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error: aborting due to previous error diff --git a/src/test/ui/for-loop-while/break-outside-loop.stderr b/src/test/ui/for-loop-while/break-outside-loop.stderr index 287bf9af62e..9092f34df35 100644 --- a/src/test/ui/for-loop-while/break-outside-loop.stderr +++ b/src/test/ui/for-loop-while/break-outside-loop.stderr @@ -9,11 +9,11 @@ LL | break 'lab; | = note: labels are unreachable through functions, closures, async blocks and modules -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/break-outside-loop.rs:10:15 | LL | let pth = break; - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error[E0268]: `continue` outside of a loop --> $DIR/break-outside-loop.rs:11:17 @@ -38,11 +38,11 @@ LL | if cond() { break } LL | if cond() { continue } | ^^^^^^^^ cannot `continue` inside of a closure -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/break-outside-loop.rs:24:25 | LL | let unconstrained = break; - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error[E0267]: `break` inside of a closure --> $DIR/break-outside-loop.rs:30:13 diff --git a/src/test/ui/issues/issue-28105.stderr b/src/test/ui/issues/issue-28105.stderr index 42ed838d7c0..f450256f3ec 100644 --- a/src/test/ui/issues/issue-28105.stderr +++ b/src/test/ui/issues/issue-28105.stderr @@ -4,11 +4,11 @@ error[E0268]: `continue` outside of a loop LL | continue | ^^^^^^^^ cannot `continue` outside of a loop -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-28105.rs:6:5 | LL | break - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-43162.stderr b/src/test/ui/issues/issue-43162.stderr index a443db40732..40d9200058e 100644 --- a/src/test/ui/issues/issue-43162.stderr +++ b/src/test/ui/issues/issue-43162.stderr @@ -1,14 +1,14 @@ -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-43162.rs:3:5 | LL | break true; - | ^^^^^^^^^^ cannot `break` outside of a loop + | ^^^^^^^^^^ cannot `break` outside of a loop or labeled block -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-43162.rs:7:5 | LL | break {}; - | ^^^^^^^^ cannot `break` outside of a loop + | ^^^^^^^^ cannot `break` outside of a loop or labeled block error[E0308]: mismatched types --> $DIR/issue-43162.rs:1:13 diff --git a/src/test/ui/issues/issue-50576.stderr b/src/test/ui/issues/issue-50576.stderr index 9fea1411080..4ec22fde910 100644 --- a/src/test/ui/issues/issue-50576.stderr +++ b/src/test/ui/issues/issue-50576.stderr @@ -4,17 +4,17 @@ error[E0426]: use of undeclared label `'L` LL | |bool: [u8; break 'L]| 0; | ^^ undeclared label `'L` -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-50576.rs:2:17 | LL | |bool: [u8; break 'L]| 0; - | ^^^^^^^^ cannot `break` outside of a loop + | ^^^^^^^^ cannot `break` outside of a loop or labeled block -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-50576.rs:5:16 | LL | Vec::<[u8; break]>::new(); - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-50581.stderr b/src/test/ui/issues/issue-50581.stderr index 35d6fc49ced..07b6df072cb 100644 --- a/src/test/ui/issues/issue-50581.stderr +++ b/src/test/ui/issues/issue-50581.stderr @@ -1,8 +1,8 @@ -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-50581.rs:2:14 | LL | |_: [u8; break]| (); - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error: aborting due to previous error diff --git a/src/test/ui/issues/issue-83048.rs b/src/test/ui/issues/issue-83048.rs index 520ae974398..8e4fb6eae9d 100644 --- a/src/test/ui/issues/issue-83048.rs +++ b/src/test/ui/issues/issue-83048.rs @@ -1,5 +1,5 @@ // compile-flags: -Z unpretty=thir-tree pub fn main() { - break; //~ ERROR: `break` outside of a loop [E0268] + break; //~ ERROR: `break` outside of a loop or labeled block [E0268] } diff --git a/src/test/ui/issues/issue-83048.stderr b/src/test/ui/issues/issue-83048.stderr index 62d67d75844..dade9e46950 100644 --- a/src/test/ui/issues/issue-83048.stderr +++ b/src/test/ui/issues/issue-83048.stderr @@ -1,8 +1,8 @@ -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/issue-83048.rs:4:5 | LL | break; - | ^^^^^ cannot `break` outside of a loop + | ^^^^^ cannot `break` outside of a loop or labeled block error: aborting due to previous error diff --git a/src/test/ui/track-diagnostics/track.stderr b/src/test/ui/track-diagnostics/track.stderr index ba26cf7c745..8256c1f5f0f 100644 --- a/src/test/ui/track-diagnostics/track.stderr +++ b/src/test/ui/track-diagnostics/track.stderr @@ -5,11 +5,11 @@ LL | break rust | ^^^^ not found in this scope -Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC -error[E0268]: `break` outside of a loop +error[E0268]: `break` outside of a loop or labeled block --> $DIR/track.rs:LL:CC | LL | break rust - | ^^^^^^^^^^ cannot `break` outside of a loop + | ^^^^^^^^^^ cannot `break` outside of a loop or labeled block -Ztrack-diagnostics: created at compiler/rustc_passes/src/loops.rs:LL:CC error: internal compiler error: It looks like you're trying to break rust; would you like some ICE?