diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 48238c8bbf571..2fd625c2a6c26 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -637,19 +637,15 @@ pub struct Deprecation { } /// Finds the deprecation attribute. `None` if none exists. -pub fn find_deprecation(sess: &Session, attrs: &[Attribute], item_sp: Span) -> Option { - find_deprecation_generic(sess, attrs.iter(), item_sp) +pub fn find_deprecation(sess: &Session, attrs: &[Attribute]) -> Option<(Deprecation, Span)> { + find_deprecation_generic(sess, attrs.iter()) } -fn find_deprecation_generic<'a, I>( - sess: &Session, - attrs_iter: I, - item_sp: Span, -) -> Option +fn find_deprecation_generic<'a, I>(sess: &Session, attrs_iter: I) -> Option<(Deprecation, Span)> where I: Iterator, { - let mut depr: Option = None; + let mut depr: Option<(Deprecation, Span)> = None; let diagnostic = &sess.parse_sess.span_diagnostic; 'outer: for attr in attrs_iter { @@ -658,8 +654,11 @@ where continue; } - if depr.is_some() { - struct_span_err!(diagnostic, item_sp, E0550, "multiple deprecated attributes").emit(); + if let Some((_, span)) = &depr { + struct_span_err!(diagnostic, attr.span, E0550, "multiple deprecated attributes") + .span_label(attr.span, "repeated deprecation attribute") + .span_label(*span, "first deprecation attribute") + .emit(); break; } @@ -780,7 +779,7 @@ where sess.mark_attr_used(&attr); let is_since_rustc_version = sess.check_name(attr, sym::rustc_deprecated); - depr = Some(Deprecation { since, note, suggestion, is_since_rustc_version }); + depr = Some((Deprecation { since, note, suggestion, is_since_rustc_version }, attr.span)); } depr diff --git a/compiler/rustc_codegen_cranelift/.github/workflows/bootstrap_rustc.yml b/compiler/rustc_codegen_cranelift/.github/workflows/bootstrap_rustc.yml new file mode 100644 index 0000000000000..8c94a0aa5e6eb --- /dev/null +++ b/compiler/rustc_codegen_cranelift/.github/workflows/bootstrap_rustc.yml @@ -0,0 +1,44 @@ +name: Bootstrap rustc using cg_clif + +on: + - push + +jobs: + bootstrap_rustc: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Cache cargo installed crates + uses: actions/cache@v2 + with: + path: ~/.cargo/bin + key: ${{ runner.os }}-cargo-installed-crates + + - name: Cache cargo registry and index + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo target dir + uses: actions/cache@v2 + with: + path: target + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} + + - name: Prepare dependencies + run: | + git config --global user.email "user@example.com" + git config --global user.name "User" + ./prepare.sh + + - name: Test + run: | + # Enable backtraces for easier debugging + export RUST_BACKTRACE=1 + + ./scripts/test_bootstrap.sh diff --git a/compiler/rustc_codegen_cranelift/.github/workflows/main.yml b/compiler/rustc_codegen_cranelift/.github/workflows/main.yml index 841e1a0870ed3..e6d3375fb1bab 100644 --- a/compiler/rustc_codegen_cranelift/.github/workflows/main.yml +++ b/compiler/rustc_codegen_cranelift/.github/workflows/main.yml @@ -51,4 +51,13 @@ jobs: export COMPILE_RUNS=2 export RUN_RUNS=2 - ./test.sh --release + ./test.sh + + - name: Package prebuilt cg_clif + run: tar cvfJ cg_clif.tar.xz build + + - name: Upload prebuilt cg_clif + uses: actions/upload-artifact@v2 + with: + name: cg_clif-${{ runner.os }} + path: cg_clif.tar.xz diff --git a/compiler/rustc_codegen_cranelift/.gitignore b/compiler/rustc_codegen_cranelift/.gitignore index 0da9927b479b4..18196bce00945 100644 --- a/compiler/rustc_codegen_cranelift/.gitignore +++ b/compiler/rustc_codegen_cranelift/.gitignore @@ -6,7 +6,7 @@ perf.data perf.data.old *.events *.string* -/build_sysroot/sysroot +/build /build_sysroot/sysroot_src /rust /rand diff --git a/compiler/rustc_codegen_cranelift/Cargo.lock b/compiler/rustc_codegen_cranelift/Cargo.lock index 6cfbed0a5e430..2889fac77f6a4 100644 --- a/compiler/rustc_codegen_cranelift/Cargo.lock +++ b/compiler/rustc_codegen_cranelift/Cargo.lock @@ -44,7 +44,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "cranelift-entity", ] @@ -52,7 +52,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" [[package]] name = "cranelift-entity" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" [[package]] name = "cranelift-frontend" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "anyhow", "cranelift-codegen", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "cranelift-codegen", "cranelift-entity", diff --git a/compiler/rustc_codegen_cranelift/Readme.md b/compiler/rustc_codegen_cranelift/Readme.md index 680ff877656b0..f8a5e13ed54c1 100644 --- a/compiler/rustc_codegen_cranelift/Readme.md +++ b/compiler/rustc_codegen_cranelift/Readme.md @@ -2,41 +2,56 @@ > ⚠⚠⚠ Certain kinds of FFI don't work yet. ⚠⚠⚠ -The goal of this project is to create an alternative codegen backend for the rust compiler based on [Cranelift](https://github.com/bytecodealliance/wasmtime/blob/master/cranelift). This has the potential to improve compilation times in debug mode. If your project doesn't use any of the things listed under "Not yet supported", it should work fine. If not please open an issue. +The goal of this project is to create an alternative codegen backend for the rust compiler based on [Cranelift](https://github.com/bytecodealliance/wasmtime/blob/master/cranelift). +This has the potential to improve compilation times in debug mode. +If your project doesn't use any of the things listed under "Not yet supported", it should work fine. +If not please open an issue. -## Building +## Building and testing ```bash $ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git $ cd rustc_codegen_cranelift $ ./prepare.sh # download and patch sysroot src and install hyperfine for benchmarking -$ ./test.sh --release +$ ./build.sh ``` +To run the test suite replace the last command with: + +```bash +$ ./test.sh +``` + +This will implicitly build cg_clif too. Both `build.sh` and `test.sh` accept a `--debug` argument to +build in debug mode. + +Alternatively you can download a pre built version from [GHA]. It is listed in the artifacts section +of workflow runs. Unfortunately due to GHA restrictions you need to be logged in to access it. + +[GHA]: https://github.com/bjorn3/rustc_codegen_cranelift/actions?query=branch%3Amaster+event%3Apush+is%3Asuccess + ## Usage rustc_codegen_cranelift can be used as a near-drop-in replacement for `cargo build` or `cargo run` for existing projects. -Assuming `$cg_clif_dir` is the directory you cloned this repo into and you followed the instructions (`prepare.sh` and `test.sh`). +Assuming `$cg_clif_dir` is the directory you cloned this repo into and you followed the instructions (`prepare.sh` and `build.sh` or `test.sh`). ### Cargo In the directory with your project (where you can do the usual `cargo build`), run: ```bash -$ $cg_clif_dir/cargo.sh run +$ $cg_clif_dir/build/cargo.sh run ``` This should build and run your project with rustc_codegen_cranelift instead of the usual LLVM backend. -If you compiled cg_clif in debug mode (aka you didn't pass `--release` to `./test.sh`) you should set `CHANNEL="debug"`. - ### Rustc > You should prefer using the Cargo method. ```bash -$ $cg_clif_dir/target/release/cg_clif my_crate.rs +$ $cg_clif_dir/build/cg_clif my_crate.rs ``` ### Jit mode @@ -47,13 +62,13 @@ In jit mode cg_clif will immediately execute your code without creating an execu > The jit mode will probably need cargo integration to make this possible. ```bash -$ $cg_clif_dir/cargo.sh jit +$ $cg_clif_dir/build/cargo.sh jit ``` or ```bash -$ $cg_clif_dir/target/release/cg_clif --jit my_crate.rs +$ $cg_clif_dir/build/cg_clif --jit my_crate.rs ``` ### Shell @@ -62,7 +77,7 @@ These are a few functions that allow you to easily run rust code from the shell ```bash function jit_naked() { - echo "$@" | $cg_clif_dir/target/release/cg_clif - --jit + echo "$@" | $cg_clif_dir/build/cg_clif - --jit } function jit() { diff --git a/compiler/rustc_codegen_cranelift/build.sh b/compiler/rustc_codegen_cranelift/build.sh new file mode 100755 index 0000000000000..f9a87e68a046a --- /dev/null +++ b/compiler/rustc_codegen_cranelift/build.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -e + +# Settings +export CHANNEL="release" +build_sysroot=1 +target_dir='build' +while [[ $# != 0 ]]; do + case $1 in + "--debug") + export CHANNEL="debug" + ;; + "--without-sysroot") + build_sysroot=0 + ;; + "--target-dir") + target_dir=$2 + shift + ;; + *) + echo "Unknown flag '$1'" + echo "Usage: ./build.sh [--debug] [--without-sysroot] [--target-dir DIR]" + ;; + esac + shift +done + +# Build cg_clif +export RUSTFLAGS="-Zrun_dsymutil=no" +if [[ "$CHANNEL" == "release" ]]; then + cargo build --release +else + cargo build +fi + +rm -rf $target_dir +mkdir $target_dir +cp -a target/$CHANNEL/cg_clif{,_build_sysroot} target/$CHANNEL/*rustc_codegen_cranelift* $target_dir/ +cp -a rust-toolchain scripts/config.sh scripts/cargo.sh $target_dir + +if [[ "$build_sysroot" == "1" ]]; then + echo "[BUILD] sysroot" + export CG_CLIF_INCR_CACHE_DISABLED=1 + dir=$(pwd) + cd $target_dir + time $dir/build_sysroot/build_sysroot.sh +fi diff --git a/compiler/rustc_codegen_cranelift/build_sysroot/build_sysroot.sh b/compiler/rustc_codegen_cranelift/build_sysroot/build_sysroot.sh index 04c82ca2a5128..eba15c0dd4308 100755 --- a/compiler/rustc_codegen_cranelift/build_sysroot/build_sysroot.sh +++ b/compiler/rustc_codegen_cranelift/build_sysroot/build_sysroot.sh @@ -3,25 +3,28 @@ # Requires the CHANNEL env var to be set to `debug` or `release.` set -e -cd $(dirname "$0") -pushd ../ >/dev/null -source ./scripts/config.sh -popd >/dev/null +source ./config.sh -# Cleanup for previous run -# v Clean target dir except for build scripts and incremental cache -rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true -rm -r sysroot/ 2>/dev/null || true +dir=$(pwd) # Use rustc with cg_clif as hotpluggable backend instead of the custom cg_clif driver so that # build scripts are still compiled using cg_llvm. -export RUSTC=$(pwd)/../"target/"$CHANNEL"/cg_clif_build_sysroot" +export RUSTC=$dir"/cg_clif_build_sysroot" export RUSTFLAGS=$RUSTFLAGS" --clif" +cd $(dirname "$0") + +# Cleanup for previous run +# v Clean target dir except for build scripts and incremental cache +rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true + +# We expect the target dir in the default location. Guard against the user changing it. +export CARGO_TARGET_DIR=target + # Build libs export RUSTFLAGS="$RUSTFLAGS -Zforce-unstable-if-unmarked -Cpanic=abort" -if [[ "$1" == "--release" ]]; then +if [[ "$1" != "--debug" ]]; then sysroot_channel='release' # FIXME Enable incremental again once rust-lang/rust#74946 is fixed # FIXME Enable -Zmir-opt-level=2 again once it doesn't ice anymore @@ -32,5 +35,5 @@ else fi # Copy files to sysroot -mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ -cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ +mkdir -p $dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ +cp -a target/$TARGET_TRIPLE/$sysroot_channel/deps/* $dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ diff --git a/compiler/rustc_codegen_cranelift/build_sysroot/prepare_sysroot_src.sh b/compiler/rustc_codegen_cranelift/build_sysroot/prepare_sysroot_src.sh index 14aa77478f54d..d0fb09ce745d4 100755 --- a/compiler/rustc_codegen_cranelift/build_sysroot/prepare_sysroot_src.sh +++ b/compiler/rustc_codegen_cranelift/build_sysroot/prepare_sysroot_src.sh @@ -12,7 +12,7 @@ fi rm -rf $DST_DIR mkdir -p $DST_DIR/library -cp -r $SRC_DIR/library $DST_DIR/ +cp -a $SRC_DIR/library $DST_DIR/ pushd $DST_DIR echo "[GIT] init" diff --git a/compiler/rustc_codegen_cranelift/clean_all.sh b/compiler/rustc_codegen_cranelift/clean_all.sh index 3003a0ea2d102..5a69c862d016d 100755 --- a/compiler/rustc_codegen_cranelift/clean_all.sh +++ b/compiler/rustc_codegen_cranelift/clean_all.sh @@ -1,5 +1,5 @@ #!/bin/bash --verbose set -e -rm -rf target/ build_sysroot/{sysroot/,sysroot_src/,target/} perf.data{,.old} +rm -rf target/ build/ build_sysroot/{sysroot_src/,target/} perf.data{,.old} rm -rf rand/ regex/ simple-raytracer/ diff --git a/compiler/rustc_codegen_cranelift/docs/env_vars.md b/compiler/rustc_codegen_cranelift/docs/env_vars.md index 07b75622a58ef..f0a0a6ad42ef5 100644 --- a/compiler/rustc_codegen_cranelift/docs/env_vars.md +++ b/compiler/rustc_codegen_cranelift/docs/env_vars.md @@ -9,7 +9,4 @@ object files when their content should have been changed by a change to cg_clif.
CG_CLIF_DISPLAY_CG_TIME
If "1", display the time it took to perform codegen for a crate
-
CG_CLIF_FUNCTION_SECTIONS
-
Use a single section for each function. This will often reduce the executable size at the - cost of making linking significantly slower.
diff --git a/compiler/rustc_codegen_cranelift/example/mini_core.rs b/compiler/rustc_codegen_cranelift/example/mini_core.rs index a972beedaa387..ce07fe83df18f 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core.rs @@ -48,6 +48,7 @@ unsafe impl Copy for u8 {} unsafe impl Copy for u16 {} unsafe impl Copy for u32 {} unsafe impl Copy for u64 {} +unsafe impl Copy for u128 {} unsafe impl Copy for usize {} unsafe impl Copy for i8 {} unsafe impl Copy for i16 {} @@ -283,6 +284,15 @@ impl PartialEq for u64 { } } +impl PartialEq for u128 { + fn eq(&self, other: &u128) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &u128) -> bool { + (*self) != (*other) + } +} + impl PartialEq for usize { fn eq(&self, other: &usize) -> bool { (*self) == (*other) diff --git a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs index 376056e19383f..4a8375afac3ce 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs @@ -287,6 +287,8 @@ fn main() { assert_eq!(repeat[0], Some(42)); assert_eq!(repeat[1], Some(42)); + from_decimal_string(); + #[cfg(not(jit))] test_tls(); @@ -446,3 +448,23 @@ fn check_niche_behavior () { intrinsics::abort(); } } + +fn from_decimal_string() { + loop { + let multiplier = 1; + + take_multiplier_ref(&multiplier); + + if multiplier == 1 { + break; + } + + unreachable(); + } +} + +fn take_multiplier_ref(_multiplier: &u128) {} + +fn unreachable() -> ! { + panic("unreachable") +} diff --git a/compiler/rustc_codegen_cranelift/example/std_example.rs b/compiler/rustc_codegen_cranelift/example/std_example.rs index 079b429904911..cb512a4aa335e 100644 --- a/compiler/rustc_codegen_cranelift/example/std_example.rs +++ b/compiler/rustc_codegen_cranelift/example/std_example.rs @@ -315,13 +315,13 @@ fn test_checked_mul() { assert_eq!(1i8.checked_mul(-128i8), Some(-128i8)); assert_eq!((-128i8).checked_mul(-128i8), None); - assert_eq!(1u64.checked_mul(u64::max_value()), Some(u64::max_value())); - assert_eq!(u64::max_value().checked_mul(u64::max_value()), None); - assert_eq!(1i64.checked_mul(i64::max_value()), Some(i64::max_value())); - assert_eq!(i64::max_value().checked_mul(i64::max_value()), None); - assert_eq!((-1i64).checked_mul(i64::min_value() + 1), Some(i64::max_value())); - assert_eq!(1i64.checked_mul(i64::min_value()), Some(i64::min_value())); - assert_eq!(i64::min_value().checked_mul(i64::min_value()), None); + assert_eq!(1u64.checked_mul(u64::MAX), Some(u64::MAX)); + assert_eq!(u64::MAX.checked_mul(u64::MAX), None); + assert_eq!(1i64.checked_mul(i64::MAX), Some(i64::MAX)); + assert_eq!(i64::MAX.checked_mul(i64::MAX), None); + assert_eq!((-1i64).checked_mul(i64::MIN + 1), Some(i64::MAX)); + assert_eq!(1i64.checked_mul(i64::MIN), Some(i64::MIN)); + assert_eq!(i64::MIN.checked_mul(i64::MIN), None); } #[derive(PartialEq)] diff --git a/compiler/rustc_codegen_cranelift/rust-toolchain b/compiler/rustc_codegen_cranelift/rust-toolchain index 87e54719fdc76..0ca96be9ae731 100644 --- a/compiler/rustc_codegen_cranelift/rust-toolchain +++ b/compiler/rustc_codegen_cranelift/rust-toolchain @@ -1 +1 @@ -nightly-2020-10-26 +nightly-2020-10-31 diff --git a/compiler/rustc_codegen_cranelift/cargo.sh b/compiler/rustc_codegen_cranelift/scripts/cargo.sh similarity index 51% rename from compiler/rustc_codegen_cranelift/cargo.sh rename to compiler/rustc_codegen_cranelift/scripts/cargo.sh index cebc3e67363a8..e63daa40f3540 100755 --- a/compiler/rustc_codegen_cranelift/cargo.sh +++ b/compiler/rustc_codegen_cranelift/scripts/cargo.sh @@ -1,19 +1,13 @@ #!/bin/bash -if [ -z $CHANNEL ]; then -export CHANNEL='release' -fi - -pushd $(dirname "$0") >/dev/null -source scripts/config.sh +dir=$(dirname "$0") +source $dir/config.sh # read nightly compiler from rust-toolchain file -TOOLCHAIN=$(cat rust-toolchain) - -popd >/dev/null +TOOLCHAIN=$(cat $dir/rust-toolchain) cmd=$1 -shift +shift || true if [[ "$cmd" = "jit" ]]; then cargo +${TOOLCHAIN} rustc $@ -- --jit diff --git a/compiler/rustc_codegen_cranelift/scripts/config.sh b/compiler/rustc_codegen_cranelift/scripts/config.sh index 530b7f242a098..af181f4f72439 100644 --- a/compiler/rustc_codegen_cranelift/scripts/config.sh +++ b/compiler/rustc_codegen_cranelift/scripts/config.sh @@ -39,18 +39,19 @@ echo export RUSTC_WRAPPER= fi -export RUSTC=$(pwd)/"target/"$CHANNEL"/cg_clif" +dir=$(cd $(dirname "$BASH_SOURCE"); pwd) + +export RUSTC=$dir"/cg_clif" export RUSTFLAGS=$linker export RUSTDOCFLAGS=$linker' -Ztrim-diagnostic-paths=no -Cpanic=abort -Zpanic-abort-tests '\ -'-Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' +'-Zcodegen-backend='$dir'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$dir'/sysroot' # FIXME remove once the atomic shim is gone if [[ `uname` == 'Darwin' ]]; then export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup" fi -export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/"$TARGET_TRIPLE"/lib:\ -$(pwd)/target/"$CHANNEL":$(rustc --print sysroot)/lib" +export LD_LIBRARY_PATH="$dir:$(rustc --print sysroot)/lib:$dir/target/out:$dir/sysroot/lib/rustlib/"$TARGET_TRIPLE"/lib" export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH export CG_CLIF_DISPLAY_CG_TIME=1 diff --git a/compiler/rustc_codegen_cranelift/scripts/filter_profile.rs b/compiler/rustc_codegen_cranelift/scripts/filter_profile.rs index c70c3ec47f31f..3327c10089d9b 100755 --- a/compiler/rustc_codegen_cranelift/scripts/filter_profile.rs +++ b/compiler/rustc_codegen_cranelift/scripts/filter_profile.rs @@ -1,9 +1,8 @@ #!/bin/bash #![forbid(unsafe_code)]/* This line is ignored by bash # This block is ignored by rustc -CHANNEL="release" pushd $(dirname "$0")/../ -source scripts/config.sh +source build/config.sh popd PROFILE=$1 OUTPUT=$2 exec $RUSTC $RUSTFLAGS --jit $0 #*/ diff --git a/compiler/rustc_codegen_cranelift/scripts/rustup.sh b/compiler/rustc_codegen_cranelift/scripts/rustup.sh index 38991d6d47dd0..541b3c6563bab 100755 --- a/compiler/rustc_codegen_cranelift/scripts/rustup.sh +++ b/compiler/rustc_codegen_cranelift/scripts/rustup.sh @@ -26,6 +26,15 @@ case $1 in git add rust-toolchain build_sysroot/Cargo.lock git commit -m "Rustup to $(rustc -V)" ;; + "push") + cg_clif=$(pwd) + pushd ../rust + branch=update_cg_clif-$(date +%Y-%m-%d) + git checkout -b $branch + git subtree pull --prefix=compiler/rustc_codegen_cranelift/ https://github.com/bjorn3/rustc_codegen_cranelift.git master + git push -u my $branch + popd + ;; *) echo "Unknown command '$1'" echo "Usage: ./rustup.sh prepare|commit" diff --git a/compiler/rustc_codegen_cranelift/scripts/test_bootstrap.sh b/compiler/rustc_codegen_cranelift/scripts/test_bootstrap.sh new file mode 100755 index 0000000000000..7f43f81a6cdcd --- /dev/null +++ b/compiler/rustc_codegen_cranelift/scripts/test_bootstrap.sh @@ -0,0 +1,65 @@ +#!/bin/bash +set -e + +cd $(dirname "$0")/../ + +./build.sh +source build/config.sh + +echo "[TEST] Bootstrap of rustc" +git clone https://github.com/rust-lang/rust.git || true +pushd rust +git fetch +git checkout -- . +git checkout $(rustc -V | cut -d' ' -f3 | tr -d '(') + +git apply - < config.toml < res.txt + diff -u res.txt examples/regexdna-output.txt + + echo "[TEST] rust-lang/regex tests" + ../build/cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -q + popd +} + +case "$1" in + "no_sysroot") + no_sysroot_tests + ;; + "base_sysroot") + base_sysroot_tests + ;; + "extended_sysroot") + extended_sysroot_tests + ;; + *) + echo "unknown test suite" + ;; +esac diff --git a/compiler/rustc_codegen_cranelift/src/abi/comments.rs b/compiler/rustc_codegen_cranelift/src/abi/comments.rs index 7bb00c8d46a4c..01073d26e832a 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/comments.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/comments.rs @@ -11,9 +11,9 @@ use crate::abi::pass_mode::*; use crate::prelude::*; pub(super) fn add_args_header_comment(fx: &mut FunctionCx<'_, '_, impl Module>) { - fx.add_global_comment(format!( - "kind loc.idx param pass mode ty" - )); + fx.add_global_comment( + "kind loc.idx param pass mode ty".to_string(), + ); } pub(super) fn add_arg_comment<'tcx>( @@ -56,9 +56,9 @@ pub(super) fn add_arg_comment<'tcx>( pub(super) fn add_locals_header_comment(fx: &mut FunctionCx<'_, '_, impl Module>) { fx.add_global_comment(String::new()); - fx.add_global_comment(format!( - "kind local ty size align (abi,pref)" - )); + fx.add_global_comment( + "kind local ty size align (abi,pref)".to_string(), + ); } pub(super) fn add_local_place_comments<'tcx>( diff --git a/compiler/rustc_codegen_cranelift/src/abi/mod.rs b/compiler/rustc_codegen_cranelift/src/abi/mod.rs index 8016912284317..81091728692f3 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/mod.rs @@ -300,7 +300,7 @@ impl<'tcx, M: Module> FunctionCx<'_, 'tcx, M> { return_ty: Ty<'tcx>, ) -> CValue<'tcx> { let (input_tys, args): (Vec<_>, Vec<_>) = args - .into_iter() + .iter() .map(|arg| { ( self.clif_type(arg.layout().ty).unwrap(), @@ -421,34 +421,31 @@ pub(crate) fn codegen_fn_prelude<'tcx>( // While this is normally an optimization to prevent an unnecessary copy when an argument is // not mutated by the current function, this is necessary to support unsized arguments. - match arg_kind { - ArgKind::Normal(Some(val)) => { - if let Some((addr, meta)) = val.try_to_ptr() { - let local_decl = &fx.mir.local_decls[local]; - // v this ! is important - let internally_mutable = !val.layout().ty.is_freeze( - fx.tcx.at(local_decl.source_info.span), - ParamEnv::reveal_all(), - ); - if local_decl.mutability == mir::Mutability::Not && !internally_mutable { - // We wont mutate this argument, so it is fine to borrow the backing storage - // of this argument, to prevent a copy. - - let place = if let Some(meta) = meta { - CPlace::for_ptr_with_extra(addr, meta, val.layout()) - } else { - CPlace::for_ptr(addr, val.layout()) - }; - - #[cfg(debug_assertions)] - self::comments::add_local_place_comments(fx, place, local); - - assert_eq!(fx.local_map.push(place), local); - continue; - } + if let ArgKind::Normal(Some(val)) = arg_kind { + if let Some((addr, meta)) = val.try_to_ptr() { + let local_decl = &fx.mir.local_decls[local]; + // v this ! is important + let internally_mutable = !val.layout().ty.is_freeze( + fx.tcx.at(local_decl.source_info.span), + ParamEnv::reveal_all(), + ); + if local_decl.mutability == mir::Mutability::Not && !internally_mutable { + // We wont mutate this argument, so it is fine to borrow the backing storage + // of this argument, to prevent a copy. + + let place = if let Some(meta) = meta { + CPlace::for_ptr_with_extra(addr, meta, val.layout()) + } else { + CPlace::for_ptr(addr, val.layout()) + }; + + #[cfg(debug_assertions)] + self::comments::add_local_place_comments(fx, place, local); + + assert_eq!(fx.local_map.push(place), local); + continue; } } - _ => {} } let place = make_local_place(fx, local, layout, is_ssa); @@ -500,7 +497,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( .tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); - let destination = destination.map(|(place, bb)| (trans_place(fx, place), bb)); + let destination = destination.map(|(place, bb)| (codegen_place(fx, place), bb)); // Handle special calls like instrinsics and empty drop glue. let instance = if let ty::FnDef(def_id, substs) = *fn_ty.kind() { @@ -553,8 +550,8 @@ pub(crate) fn codegen_terminator_call<'tcx>( // Unpack arguments tuple for closures let args = if fn_sig.abi == Abi::RustCall { assert_eq!(args.len(), 2, "rust-call abi requires two arguments"); - let self_arg = trans_operand(fx, &args[0]); - let pack_arg = trans_operand(fx, &args[1]); + let self_arg = codegen_operand(fx, &args[0]); + let pack_arg = codegen_operand(fx, &args[1]); let tupled_arguments = match pack_arg.layout().ty.kind() { ty::Tuple(ref tupled_arguments) => tupled_arguments, @@ -568,8 +565,8 @@ pub(crate) fn codegen_terminator_call<'tcx>( } args } else { - args.into_iter() - .map(|arg| trans_operand(fx, arg)) + args.iter() + .map(|arg| codegen_operand(fx, arg)) .collect::>() }; @@ -613,7 +610,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let nop_inst = fx.bcx.ins().nop(); fx.add_comment(nop_inst, "indirect call"); } - let func = trans_operand(fx, func).load_scalar(fx); + let func = codegen_operand(fx, func).load_scalar(fx); ( Some(func), args.get(0) diff --git a/compiler/rustc_codegen_cranelift/src/allocator.rs b/compiler/rustc_codegen_cranelift/src/allocator.rs index 0735ad6f83299..6c5916550ff63 100644 --- a/compiler/rustc_codegen_cranelift/src/allocator.rs +++ b/compiler/rustc_codegen_cranelift/src/allocator.rs @@ -123,7 +123,7 @@ fn codegen_inner( .unwrap(); let mut ctx = Context::new(); - ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig.clone()); + ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig); { let mut func_ctx = FunctionBuilderContext::new(); let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); @@ -131,7 +131,7 @@ fn codegen_inner( let block = bcx.create_block(); bcx.switch_to_block(block); let args = (&[usize_ty, usize_ty]) - .into_iter() + .iter() .map(|&ty| bcx.append_block_param(block, ty)) .collect::>(); diff --git a/compiler/rustc_codegen_cranelift/src/archive.rs b/compiler/rustc_codegen_cranelift/src/archive.rs index 6382f8df3446b..9a970efbcfd0b 100644 --- a/compiler/rustc_codegen_cranelift/src/archive.rs +++ b/compiler/rustc_codegen_cranelift/src/archive.rs @@ -132,7 +132,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } // ok, don't skip this - return false; + false }) } diff --git a/compiler/rustc_codegen_cranelift/src/atomic_shim.rs b/compiler/rustc_codegen_cranelift/src/atomic_shim.rs index 92281fdacc941..2f0157c257b98 100644 --- a/compiler/rustc_codegen_cranelift/src/atomic_shim.rs +++ b/compiler/rustc_codegen_cranelift/src/atomic_shim.rs @@ -7,7 +7,7 @@ use crate::prelude::*; #[cfg(all(feature = "jit", unix))] #[no_mangle] -pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = +static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; pub(crate) fn init_global_lock( diff --git a/compiler/rustc_codegen_cranelift/src/backend.rs b/compiler/rustc_codegen_cranelift/src/backend.rs index 8b900fd0dd0c8..9e32259716f51 100644 --- a/compiler/rustc_codegen_cranelift/src/backend.rs +++ b/compiler/rustc_codegen_cranelift/src/backend.rs @@ -73,7 +73,7 @@ impl WriteDebugInfo for ObjectProduct { // FIXME use SHT_X86_64_UNWIND for .eh_frame let section_id = self.object.add_section( segment, - name.clone(), + name, if id == SectionId::EhFrame { SectionKind::ReadOnlyData } else { @@ -198,9 +198,9 @@ pub(crate) fn make_module(sess: &Session, name: String) -> ObjectModule { cranelift_module::default_libcall_names(), ) .unwrap(); - if std::env::var("CG_CLIF_FUNCTION_SECTIONS").is_ok() { - builder.per_function_section(true); - } - let module = ObjectModule::new(builder); - module + // Unlike cg_llvm, cg_clif defaults to disabling -Zfunction-sections. For cg_llvm binary size + // is important, while cg_clif cares more about compilation times. Enabling -Zfunction-sections + // can easily double the amount of time necessary to perform linking. + builder.per_function_section(sess.opts.debugging_opts.function_sections.unwrap_or(false)); + ObjectModule::new(builder) } diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index fa9b8853d39e9..5474e5960f100 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -5,7 +5,7 @@ use rustc_middle::ty::adjustment::PointerCast; use crate::prelude::*; -pub(crate) fn trans_fn<'tcx>( +pub(crate) fn codegen_fn<'tcx>( cx: &mut crate::CodegenCx<'tcx, impl Module>, instance: Instance<'tcx>, linkage: Linkage, @@ -202,7 +202,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { fx.bcx.ins().nop(); for stmt in &bb_data.statements { fx.set_debug_loc(stmt.source_info); - trans_stmt(fx, block, stmt); + codegen_stmt(fx, block, stmt); } #[cfg(debug_assertions)] @@ -258,7 +258,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { continue; } } - let cond = trans_operand(fx, cond).load_scalar(fx); + let cond = codegen_operand(fx, cond).load_scalar(fx); let target = fx.get_block(*target); let failure = fx.bcx.create_block(); @@ -276,8 +276,8 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { match msg { AssertKind::BoundsCheck { ref len, ref index } => { - let len = trans_operand(fx, len).load_scalar(fx); - let index = trans_operand(fx, index).load_scalar(fx); + let len = codegen_operand(fx, len).load_scalar(fx); + let index = codegen_operand(fx, index).load_scalar(fx); let location = fx .get_caller_location(bb_data.terminator().source_info.span) .load_scalar(fx); @@ -301,7 +301,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { switch_ty, targets, } => { - let discr = trans_operand(fx, discr).load_scalar(fx); + let discr = codegen_operand(fx, discr).load_scalar(fx); if switch_ty.kind() == fx.tcx.types.bool.kind() { assert_eq!(targets.iter().count(), 1); @@ -396,14 +396,14 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { | TerminatorKind::FalseUnwind { .. } | TerminatorKind::DropAndReplace { .. } | TerminatorKind::GeneratorDrop => { - bug!("shouldn't exist at trans {:?}", bb_data.terminator()); + bug!("shouldn't exist at codegen {:?}", bb_data.terminator()); } TerminatorKind::Drop { place, target, unwind: _, } => { - let drop_place = trans_place(fx, *place); + let drop_place = codegen_place(fx, *place); crate::abi::codegen_drop(fx, bb_data.terminator().source_info.span, drop_place); let target_block = fx.get_block(*target); @@ -416,7 +416,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { fx.bcx.finalize(); } -fn trans_stmt<'tcx>( +fn codegen_stmt<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, #[allow(unused_variables)] cur_block: Block, stmt: &Statement<'tcx>, @@ -439,19 +439,19 @@ fn trans_stmt<'tcx>( place, variant_index, } => { - let place = trans_place(fx, **place); + let place = codegen_place(fx, **place); crate::discriminant::codegen_set_discriminant(fx, place, *variant_index); } StatementKind::Assign(to_place_and_rval) => { - let lval = trans_place(fx, to_place_and_rval.0); + let lval = codegen_place(fx, to_place_and_rval.0); let dest_layout = lval.layout(); match &to_place_and_rval.1 { Rvalue::Use(operand) => { - let val = trans_operand(fx, operand); + let val = codegen_operand(fx, operand); lval.write_cvalue(fx, val); } Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { - let place = trans_place(fx, *place); + let place = codegen_place(fx, *place); let ref_ = place.place_ref(fx, lval.layout()); lval.write_cvalue(fx, ref_); } @@ -460,29 +460,29 @@ fn trans_stmt<'tcx>( lval.write_cvalue(fx, val); } Rvalue::BinaryOp(bin_op, lhs, rhs) => { - let lhs = trans_operand(fx, lhs); - let rhs = trans_operand(fx, rhs); + let lhs = codegen_operand(fx, lhs); + let rhs = codegen_operand(fx, rhs); let res = crate::num::codegen_binop(fx, *bin_op, lhs, rhs); lval.write_cvalue(fx, res); } Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { - let lhs = trans_operand(fx, lhs); - let rhs = trans_operand(fx, rhs); + let lhs = codegen_operand(fx, lhs); + let rhs = codegen_operand(fx, rhs); let res = if !fx.tcx.sess.overflow_checks() { let val = - crate::num::trans_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx); + crate::num::codegen_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx); let is_overflow = fx.bcx.ins().iconst(types::I8, 0); CValue::by_val_pair(val, is_overflow, lval.layout()) } else { - crate::num::trans_checked_int_binop(fx, *bin_op, lhs, rhs) + crate::num::codegen_checked_int_binop(fx, *bin_op, lhs, rhs) }; lval.write_cvalue(fx, res); } Rvalue::UnaryOp(un_op, operand) => { - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); let layout = operand.layout(); let val = operand.load_scalar(fx); let res = match un_op { @@ -500,7 +500,7 @@ fn trans_stmt<'tcx>( ty::Int(IntTy::I128) => { // FIXME remove this case once ineg.i128 works let zero = CValue::const_val(fx, layout, 0); - crate::num::trans_int_binop(fx, BinOp::Sub, zero, operand) + crate::num::codegen_int_binop(fx, BinOp::Sub, zero, operand) } ty::Int(_) => CValue::by_val(fx.bcx.ins().ineg(val), layout), ty::Float(_) => CValue::by_val(fx.bcx.ins().fneg(val), layout), @@ -534,11 +534,11 @@ fn trans_stmt<'tcx>( | Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), operand, to_ty) | Rvalue::Cast(CastKind::Pointer(PointerCast::ArrayToPointer), operand, to_ty) => { let to_layout = fx.layout_of(fx.monomorphize(to_ty)); - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); lval.write_cvalue(fx, operand.cast_pointer_to(to_layout)); } Rvalue::Cast(CastKind::Misc, operand, to_ty) => { - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); let from_ty = operand.layout().ty; let to_ty = fx.monomorphize(to_ty); @@ -639,7 +639,7 @@ fn trans_stmt<'tcx>( operand, _to_ty, ) => { - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); match *operand.layout().ty.kind() { ty::Closure(def_id, substs) => { let instance = Instance::resolve_closure( @@ -657,18 +657,18 @@ fn trans_stmt<'tcx>( } } Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), operand, _to_ty) => { - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); operand.unsize_value(fx, lval); } Rvalue::Discriminant(place) => { - let place = trans_place(fx, *place); + let place = codegen_place(fx, *place); let value = place.to_cvalue(fx); let discr = crate::discriminant::codegen_get_discriminant(fx, value, dest_layout); lval.write_cvalue(fx, discr); } Rvalue::Repeat(operand, times) => { - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); let times = fx .monomorphize(times) .eval(fx.tcx, ParamEnv::reveal_all()) @@ -706,7 +706,7 @@ fn trans_stmt<'tcx>( } } Rvalue::Len(place) => { - let place = trans_place(fx, *place); + let place = codegen_place(fx, *place); let usize_layout = fx.layout_of(fx.tcx.types.usize); let len = codegen_array_len(fx, place); lval.write_cvalue(fx, CValue::by_val(len, usize_layout)); @@ -753,14 +753,14 @@ fn trans_stmt<'tcx>( } Rvalue::Aggregate(kind, operands) => match **kind { AggregateKind::Array(_ty) => { - for (i, operand) in operands.into_iter().enumerate() { - let operand = trans_operand(fx, operand); + for (i, operand) in operands.iter().enumerate() { + let operand = codegen_operand(fx, operand); let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64); let to = lval.place_index(fx, index); to.write_cvalue(fx, operand); } } - _ => unreachable!("shouldn't exist at trans {:?}", to_place_and_rval.1), + _ => unreachable!("shouldn't exist at codegen {:?}", to_place_and_rval.1), }, } } @@ -813,20 +813,20 @@ fn trans_stmt<'tcx>( assert!(!alignstack); assert_eq!(inputs.len(), 2); - let leaf = trans_operand(fx, &inputs[0].1).load_scalar(fx); // %eax - let subleaf = trans_operand(fx, &inputs[1].1).load_scalar(fx); // %ecx + let leaf = codegen_operand(fx, &inputs[0].1).load_scalar(fx); // %eax + let subleaf = codegen_operand(fx, &inputs[1].1).load_scalar(fx); // %ecx let (eax, ebx, ecx, edx) = crate::intrinsics::codegen_cpuid_call(fx, leaf, subleaf); assert_eq!(outputs.len(), 4); - trans_place(fx, outputs[0]) + codegen_place(fx, outputs[0]) .write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.tcx.types.u32))); - trans_place(fx, outputs[1]) + codegen_place(fx, outputs[1]) .write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.tcx.types.u32))); - trans_place(fx, outputs[2]) + codegen_place(fx, outputs[2]) .write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.tcx.types.u32))); - trans_place(fx, outputs[3]) + codegen_place(fx, outputs[3]) .write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.tcx.types.u32))); } "xgetbv" => { @@ -892,7 +892,7 @@ fn codegen_array_len<'tcx>( } } -pub(crate) fn trans_place<'tcx>( +pub(crate) fn codegen_place<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, place: Place<'tcx>, ) -> CPlace<'tcx> { @@ -938,7 +938,7 @@ pub(crate) fn trans_place<'tcx>( let ptr = cplace.to_ptr(); cplace = CPlace::for_ptr( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * (from as i64)), - fx.layout_of(fx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))), + fx.layout_of(fx.tcx.mk_array(elem_ty, to - from)), ); } ty::Slice(elem_ty) => { @@ -964,16 +964,16 @@ pub(crate) fn trans_place<'tcx>( cplace } -pub(crate) fn trans_operand<'tcx>( +pub(crate) fn codegen_operand<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, operand: &Operand<'tcx>, ) -> CValue<'tcx> { match operand { Operand::Move(place) | Operand::Copy(place) => { - let cplace = trans_place(fx, *place); + let cplace = codegen_place(fx, *place); cplace.to_cvalue(fx) } - Operand::Constant(const_) => crate::constant::trans_constant(fx, const_), + Operand::Constant(const_) => crate::constant::codegen_constant(fx, const_), } } diff --git a/compiler/rustc_codegen_cranelift/src/bin/cg_clif.rs b/compiler/rustc_codegen_cranelift/src/bin/cg_clif.rs index 590c9ef0ce191..71ef4d2267368 100644 --- a/compiler/rustc_codegen_cranelift/src/bin/cg_clif.rs +++ b/compiler/rustc_codegen_cranelift/src/bin/cg_clif.rs @@ -24,22 +24,16 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks { self.time_passes = config.opts.prints.is_empty() && (config.opts.debugging_opts.time_passes || config.opts.debugging_opts.time); - // FIXME workaround for an ICE - config.opts.debugging_opts.trim_diagnostic_paths = false; - config.opts.cg.panic = Some(PanicStrategy::Abort); config.opts.debugging_opts.panic_abort_tests = true; config.opts.maybe_sysroot = Some( - std::env::current_exe() - .unwrap() - .parent() - .unwrap() - .parent() - .unwrap() - .parent() - .unwrap() - .join("build_sysroot") - .join("sysroot"), + config.opts.maybe_sysroot.clone().unwrap_or( + std::env::current_exe() + .unwrap() + .parent() + .unwrap() + .join("sysroot"), + ), ); } } diff --git a/compiler/rustc_codegen_cranelift/src/bin/cg_clif_build_sysroot.rs b/compiler/rustc_codegen_cranelift/src/bin/cg_clif_build_sysroot.rs index c207d98d6c197..165d33dcfb509 100644 --- a/compiler/rustc_codegen_cranelift/src/bin/cg_clif_build_sysroot.rs +++ b/compiler/rustc_codegen_cranelift/src/bin/cg_clif_build_sysroot.rs @@ -44,9 +44,6 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks { return; } - // FIXME workaround for an ICE - config.opts.debugging_opts.trim_diagnostic_paths = false; - config.opts.cg.panic = Some(PanicStrategy::Abort); config.opts.debugging_opts.panic_abort_tests = true; config.opts.maybe_sysroot = Some( diff --git a/compiler/rustc_codegen_cranelift/src/cast.rs b/compiler/rustc_codegen_cranelift/src/cast.rs index 122a36b5bf741..57204de1135be 100644 --- a/compiler/rustc_codegen_cranelift/src/cast.rs +++ b/compiler/rustc_codegen_cranelift/src/cast.rs @@ -181,12 +181,10 @@ pub(crate) fn clif_int_or_float_cast( fx.bcx.ins().select(has_overflow, max_val, val) }; fx.bcx.ins().ireduce(to_ty, val) + } else if to_signed { + fx.bcx.ins().fcvt_to_sint_sat(to_ty, from) } else { - if to_signed { - fx.bcx.ins().fcvt_to_sint_sat(to_ty, from) - } else { - fx.bcx.ins().fcvt_to_uint_sat(to_ty, from) - } + fx.bcx.ins().fcvt_to_uint_sat(to_ty, from) } } else if from_ty.is_float() && to_ty.is_float() { // float -> float diff --git a/compiler/rustc_codegen_cranelift/src/codegen_i128.rs b/compiler/rustc_codegen_cranelift/src/codegen_i128.rs index e998403dea6bb..d6a38bdafc9ba 100644 --- a/compiler/rustc_codegen_cranelift/src/codegen_i128.rs +++ b/compiler/rustc_codegen_cranelift/src/codegen_i128.rs @@ -21,9 +21,9 @@ pub(crate) fn maybe_codegen<'tcx>( match bin_op { BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => { assert!(!checked); - return None; + None } - BinOp::Add | BinOp::Sub if !checked => return None, + BinOp::Add | BinOp::Sub if !checked => None, BinOp::Add => { let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); return Some(if is_signed { @@ -57,7 +57,7 @@ pub(crate) fn maybe_codegen<'tcx>( }; fx.easy_call("__multi3", &[lhs, rhs], val_ty) }; - return Some(res); + Some(res) } BinOp::Div => { assert!(!checked); @@ -77,7 +77,7 @@ pub(crate) fn maybe_codegen<'tcx>( } BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => { assert!(!checked); - return None; + None } BinOp::Shl | BinOp::Shr => { let is_overflow = if checked { diff --git a/compiler/rustc_codegen_cranelift/src/common.rs b/compiler/rustc_codegen_cranelift/src/common.rs index 13c62add41a3b..eda77bf19d354 100644 --- a/compiler/rustc_codegen_cranelift/src/common.rs +++ b/compiler/rustc_codegen_cranelift/src/common.rs @@ -406,7 +406,7 @@ impl<'tcx, M: Module> FunctionCx<'_, 'tcx, M> { caller.line as u32, caller.col_display as u32 + 1, )); - crate::constant::trans_const_value(self, const_loc, self.tcx.caller_location_ty()) + crate::constant::codegen_const_value(self, const_loc, self.tcx.caller_location_ty()) } pub(crate) fn triple(&self) -> &target_lexicon::Triple { diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs index 1b514958a4809..ce1d5ed2e6178 100644 --- a/compiler/rustc_codegen_cranelift/src/constant.rs +++ b/compiler/rustc_codegen_cranelift/src/constant.rs @@ -106,7 +106,7 @@ fn codegen_static_ref<'tcx>( CPlace::for_ptr(crate::pointer::Pointer::new(global_ptr), layout) } -pub(crate) fn trans_constant<'tcx>( +pub(crate) fn codegen_constant<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, constant: &Constant<'tcx>, ) -> CValue<'tcx> { @@ -151,10 +151,10 @@ pub(crate) fn trans_constant<'tcx>( | ConstKind::Error(_) => unreachable!("{:?}", const_), }; - trans_const_value(fx, const_val, const_.ty) + codegen_const_value(fx, const_val, const_.ty) } -pub(crate) fn trans_const_value<'tcx>( +pub(crate) fn codegen_const_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, const_val: ConstValue<'tcx>, ty: Ty<'tcx>, @@ -164,7 +164,7 @@ pub(crate) fn trans_const_value<'tcx>( if layout.is_zst() { return CValue::by_ref( - crate::Pointer::const_addr(fx, i64::try_from(layout.align.pref.bytes()).unwrap()), + crate::Pointer::dangling(layout.align.pref), layout, ); } @@ -188,7 +188,7 @@ pub(crate) fn trans_const_value<'tcx>( match x { Scalar::Raw { data, size } => { assert_eq!(u64::from(size), layout.size.bytes()); - return CValue::const_val(fx, layout, data); + CValue::const_val(fx, layout, data) } Scalar::Ptr(ptr) => { let alloc_kind = fx.tcx.get_global_alloc(ptr.alloc_id); @@ -232,7 +232,7 @@ pub(crate) fn trans_const_value<'tcx>( } else { base_addr }; - return CValue::by_val(val, layout); + CValue::by_val(val, layout) } } } @@ -276,7 +276,7 @@ fn data_id_for_alloc_id( ) -> DataId { module .declare_data( - &format!("__alloc_{:x}", alloc_id.0), + &format!(".L__alloc_{:x}", alloc_id.0), Linkage::Local, mutability == rustc_hir::Mutability::Mut, false, @@ -293,14 +293,12 @@ fn data_id_for_static( let rlinkage = tcx.codegen_fn_attrs(def_id).linkage; let linkage = if definition { crate::linkage::get_static_linkage(tcx, def_id) + } else if rlinkage == Some(rustc_middle::mir::mono::Linkage::ExternalWeak) + || rlinkage == Some(rustc_middle::mir::mono::Linkage::WeakAny) + { + Linkage::Preemptible } else { - if rlinkage == Some(rustc_middle::mir::mono::Linkage::ExternalWeak) - || rlinkage == Some(rustc_middle::mir::mono::Linkage::WeakAny) - { - Linkage::Preemptible - } else { - Linkage::Import - } + Linkage::Import }; let instance = Instance::mono(tcx, def_id).polymorphize(tcx); diff --git a/compiler/rustc_codegen_cranelift/src/debuginfo/emit.rs b/compiler/rustc_codegen_cranelift/src/debuginfo/emit.rs index cf8fee2b1d17c..f6f795e45615c 100644 --- a/compiler/rustc_codegen_cranelift/src/debuginfo/emit.rs +++ b/compiler/rustc_codegen_cranelift/src/debuginfo/emit.rs @@ -195,9 +195,7 @@ impl Writer for WriterRelocate { }); self.write_udata(0, size) } - _ => { - return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)); - } + _ => Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)), }, } } diff --git a/compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs b/compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs index 4de8485532896..d226755d85de0 100644 --- a/compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs +++ b/compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs @@ -49,7 +49,7 @@ fn osstr_as_utf8_bytes(path: &OsStr) -> &[u8] { pub(crate) const MD5_LEN: usize = 16; -pub fn make_file_info(hash: SourceFileHash) -> Option { +pub(crate) fn make_file_info(hash: SourceFileHash) -> Option { if hash.kind == SourceFileHashAlgorithm::Md5 { let mut buf = [0u8; MD5_LEN]; buf.copy_from_slice(hash.hash_bytes()); @@ -190,7 +190,7 @@ impl<'tcx> DebugContext<'tcx> { if current_file_changed { let file_id = line_program_add_file(line_program, line_strings, &file); line_program.row().file = file_id; - last_file = Some(file.clone()); + last_file = Some(file); } line_program.row().line = line; diff --git a/compiler/rustc_codegen_cranelift/src/debuginfo/unwind.rs b/compiler/rustc_codegen_cranelift/src/debuginfo/unwind.rs index 61ebd931d2f14..68138404c2436 100644 --- a/compiler/rustc_codegen_cranelift/src/debuginfo/unwind.rs +++ b/compiler/rustc_codegen_cranelift/src/debuginfo/unwind.rs @@ -55,6 +55,7 @@ impl<'tcx> UnwindContext<'tcx> { UnwindInfo::WindowsX64(_) => { // FIXME implement this } + unwind_info => unimplemented!("{:?}", unwind_info), } } diff --git a/compiler/rustc_codegen_cranelift/src/driver/jit.rs b/compiler/rustc_codegen_cranelift/src/driver/jit.rs index b5bab3d9e1ed1..3f47df7d844b3 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/jit.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/jit.rs @@ -94,7 +94,7 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { let args = ::std::env::var("CG_CLIF_JIT_ARGS").unwrap_or_else(|_| String::new()); let args = std::iter::once(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string()) - .chain(args.split(" ")) + .chain(args.split(' ')) .map(|arg| CString::new(arg).unwrap()) .collect::>(); let mut argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); @@ -151,7 +151,7 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> { } let dlsym_name = if cfg!(target_os = "macos") { // On macOS `dlsym` expects the name without leading `_`. - assert!(name.starts_with("_"), "{:?}", name); + assert!(name.starts_with('_'), "{:?}", name); &name[1..] } else { &name diff --git a/compiler/rustc_codegen_cranelift/src/driver/mod.rs b/compiler/rustc_codegen_cranelift/src/driver/mod.rs index 2fb353ca1628a..a11dc57ee6453 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/mod.rs @@ -64,11 +64,11 @@ fn codegen_mono_items<'tcx>( for (mono_item, (linkage, visibility)) in mono_items { let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - trans_mono_item(cx, mono_item, linkage); + codegen_mono_item(cx, mono_item, linkage); } } -fn trans_mono_item<'tcx, M: Module>( +fn codegen_mono_item<'tcx, M: Module>( cx: &mut crate::CodegenCx<'tcx, M>, mono_item: MonoItem<'tcx>, linkage: Linkage, @@ -80,7 +80,7 @@ fn trans_mono_item<'tcx, M: Module>( crate::PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name)); debug_assert!(!inst.substs.needs_infer()); tcx.sess - .time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); + .time("codegen fn", || crate::base::codegen_fn(cx, inst, linkage)); } MonoItem::Static(def_id) => { crate::constant::codegen_static(&mut cx.constants_cx, def_id); diff --git a/compiler/rustc_codegen_cranelift/src/inline_asm.rs b/compiler/rustc_codegen_cranelift/src/inline_asm.rs index aa2edb2dfd4f7..04aac780125d9 100644 --- a/compiler/rustc_codegen_cranelift/src/inline_asm.rs +++ b/compiler/rustc_codegen_cranelift/src/inline_asm.rs @@ -50,7 +50,7 @@ pub(crate) fn codegen_inline_asm<'tcx>( inputs.push(( reg, new_slot(reg.reg_class()), - crate::base::trans_operand(fx, value).load_scalar(fx), + crate::base::codegen_operand(fx, value).load_scalar(fx), )); } InlineAsmOperand::Out { @@ -64,7 +64,7 @@ pub(crate) fn codegen_inline_asm<'tcx>( outputs.push(( reg, new_slot(reg.reg_class()), - crate::base::trans_place(fx, place), + crate::base::codegen_place(fx, place), )); } } @@ -79,13 +79,13 @@ pub(crate) fn codegen_inline_asm<'tcx>( inputs.push(( reg, new_slot(reg.reg_class()), - crate::base::trans_operand(fx, in_value).load_scalar(fx), + crate::base::codegen_operand(fx, in_value).load_scalar(fx), )); if let Some(out_place) = out_place { outputs.push(( reg, new_slot(reg.reg_class()), - crate::base::trans_place(fx, out_place), + crate::base::codegen_place(fx, out_place), )); } } diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/llvm.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/llvm.rs index 18d86f0c5f959..171445f2d71b6 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/llvm.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/llvm.rs @@ -53,7 +53,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( }; llvm.x86.sse2.cmp.ps | llvm.x86.sse2.cmp.pd, (c x, c y, o kind) { let kind_const = crate::constant::mir_operand_get_const_val(fx, kind).expect("llvm.x86.sse2.cmp.* kind not const"); - let flt_cc = match kind_const.val.try_to_bits(Size::from_bytes(1)).expect(&format!("kind not scalar: {:?}", kind_const)) { + let flt_cc = match kind_const.val.try_to_bits(Size::from_bytes(1)).unwrap_or_else(|| panic!("kind not scalar: {:?}", kind_const)) { 0 => FloatCC::Equal, 1 => FloatCC::LessThan, 2 => FloatCC::LessThanOrEqual, @@ -84,7 +84,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( llvm.x86.sse2.psrli.d, (c a, o imm8) { let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8).expect("llvm.x86.sse2.psrli.d imm8 not const"); simd_for_each_lane(fx, a, ret, |fx, _lane_layout, res_lane_layout, lane| { - let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).expect(&format!("imm8 not scalar: {:?}", imm8)) { + let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).unwrap_or_else(|| panic!("imm8 not scalar: {:?}", imm8)) { imm8 if imm8 < 32 => fx.bcx.ins().ushr_imm(lane, i64::from(imm8 as u8)), _ => fx.bcx.ins().iconst(types::I32, 0), }; @@ -94,7 +94,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( llvm.x86.sse2.pslli.d, (c a, o imm8) { let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8).expect("llvm.x86.sse2.psrli.d imm8 not const"); simd_for_each_lane(fx, a, ret, |fx, _lane_layout, res_lane_layout, lane| { - let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).expect(&format!("imm8 not scalar: {:?}", imm8)) { + let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).unwrap_or_else(|| panic!("imm8 not scalar: {:?}", imm8)) { imm8 if imm8 < 32 => fx.bcx.ins().ishl_imm(lane, i64::from(imm8 as u8)), _ => fx.bcx.ins().iconst(types::I32, 0), }; diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs index 9a3e4c7b56e9c..a5f45b7abf4c8 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs @@ -9,6 +9,7 @@ pub(crate) use cpuid::codegen_cpuid_call; pub(crate) use llvm::codegen_llvm_intrinsic_call; use crate::prelude::*; +use rustc_middle::ty::print::with_no_trimmed_paths; macro intrinsic_pat { (_) => { @@ -30,10 +31,10 @@ macro intrinsic_arg { $arg }, (c $fx:expr, $arg:ident) => { - trans_operand($fx, $arg) + codegen_operand($fx, $arg) }, (v $fx:expr, $arg:ident) => { - trans_operand($fx, $arg).load_scalar($fx) + codegen_operand($fx, $arg).load_scalar($fx) } } @@ -89,7 +90,7 @@ macro call_intrinsic_match { assert!($substs.is_noop()); if let [$(ref $arg),*] = *$args { let ($($arg,)*) = ( - $(trans_operand($fx, $arg),)* + $(codegen_operand($fx, $arg),)* ); let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fx.tcx.types.$ty); $ret.write_cvalue($fx, res); @@ -576,7 +577,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( "unchecked_shr" => BinOp::Shr, _ => unreachable!("intrinsic {}", intrinsic), }; - let res = crate::num::trans_int_binop(fx, bin_op, x, y); + let res = crate::num::codegen_int_binop(fx, bin_op, x, y); ret.write_cvalue(fx, res); }; _ if intrinsic.ends_with("_with_overflow"), (c x, c y) { @@ -588,7 +589,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( _ => unreachable!("intrinsic {}", intrinsic), }; - let res = crate::num::trans_checked_int_binop( + let res = crate::num::codegen_checked_int_binop( fx, bin_op, x, @@ -604,7 +605,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( "wrapping_mul" => BinOp::Mul, _ => unreachable!("intrinsic {}", intrinsic), }; - let res = crate::num::trans_int_binop( + let res = crate::num::codegen_int_binop( fx, bin_op, x, @@ -622,7 +623,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let signed = type_sign(T); - let checked_res = crate::num::trans_checked_int_binop( + let checked_res = crate::num::codegen_checked_int_binop( fx, bin_op, lhs, @@ -819,29 +820,29 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( assert_inhabited | assert_zero_valid | assert_uninit_valid, () { let layout = fx.layout_of(T); if layout.abi.is_uninhabited() { - crate::base::codegen_panic( + with_no_trimmed_paths(|| crate::base::codegen_panic( fx, &format!("attempted to instantiate uninhabited type `{}`", T), span, - ); + )); return; } if intrinsic == "assert_zero_valid" && !layout.might_permit_raw_init(fx, /*zero:*/ true).unwrap() { - crate::base::codegen_panic( + with_no_trimmed_paths(|| crate::base::codegen_panic( fx, &format!("attempted to zero-initialize type `{}`, which is invalid", T), span, - ); + )); return; } if intrinsic == "assert_uninit_valid" && !layout.might_permit_raw_init(fx, /*zero:*/ false).unwrap() { - crate::base::codegen_panic( + with_no_trimmed_paths(|| crate::base::codegen_panic( fx, &format!("attempted to leave type `{}` uninitialized, which is invalid", T), span, - ); + )); return; } }; @@ -866,7 +867,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name | variant_count, () { let const_val = fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); - let val = crate::constant::trans_const_value( + let val = crate::constant::codegen_const_value( fx, const_val, ret.layout().ty, @@ -885,12 +886,12 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; ptr_guaranteed_eq, (c a, c b) { - let val = crate::num::trans_ptr_binop(fx, BinOp::Eq, a, b); + let val = crate::num::codegen_ptr_binop(fx, BinOp::Eq, a, b); ret.write_cvalue(fx, val); }; ptr_guaranteed_ne, (c a, c b) { - let val = crate::num::trans_ptr_binop(fx, BinOp::Ne, a, b); + let val = crate::num::codegen_ptr_binop(fx, BinOp::Ne, a, b); ret.write_cvalue(fx, val); }; @@ -1068,7 +1069,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; fadd_fast | fsub_fast | fmul_fast | fdiv_fast | frem_fast, (c x, c y) { - let res = crate::num::trans_float_binop(fx, match intrinsic { + let res = crate::num::codegen_float_binop(fx, match intrinsic { "fadd_fast" => BinOp::Add, "fsub_fast" => BinOp::Sub, "fmul_fast" => BinOp::Mul, diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs index b4269f4fafa0b..2e31c4669e25b 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs @@ -127,7 +127,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( ); }; - let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); + let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).unwrap_or_else(|| panic!("kind not scalar: {:?}", idx_const)); let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, base.layout()); if idx >= lane_count.into() { fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count)); @@ -149,7 +149,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( ); }; - let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); + let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).unwrap_or_else(|| panic!("kind not scalar: {:?}", idx_const)); let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, v.layout()); if idx >= lane_count.into() { fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index fd00a2e00a6a4..ba9ee0d450ee6 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -9,6 +9,7 @@ )] #![warn(rust_2018_idioms)] #![warn(unused_lifetimes)] +#![warn(unreachable_pub)] #[cfg(feature = "jit")] extern crate libc; @@ -110,7 +111,7 @@ mod prelude { pub(crate) use cranelift_module::{self, DataContext, DataId, FuncId, Linkage, Module}; pub(crate) use crate::abi::*; - pub(crate) use crate::base::{trans_operand, trans_place}; + pub(crate) use crate::base::{codegen_operand, codegen_place}; pub(crate) use crate::cast::*; pub(crate) use crate::common::*; pub(crate) use crate::debuginfo::{DebugContext, UnwindContext}; diff --git a/compiler/rustc_codegen_cranelift/src/linkage.rs b/compiler/rustc_codegen_cranelift/src/linkage.rs index fe5d1d6444363..dc1e2107ce712 100644 --- a/compiler/rustc_codegen_cranelift/src/linkage.rs +++ b/compiler/rustc_codegen_cranelift/src/linkage.rs @@ -25,11 +25,9 @@ pub(crate) fn get_static_linkage(tcx: TyCtxt<'_>, def_id: DefId) -> Linkage { RLinkage::ExternalWeak | RLinkage::WeakAny => Linkage::Preemptible, _ => panic!("{:?}", linkage), } + } else if tcx.is_reachable_non_generic(def_id) { + Linkage::Export } else { - if tcx.is_reachable_non_generic(def_id) { - Linkage::Export - } else { - Linkage::Hidden - } + Linkage::Hidden } } diff --git a/compiler/rustc_codegen_cranelift/src/main_shim.rs b/compiler/rustc_codegen_cranelift/src/main_shim.rs index db34d89fe2be7..10f515e38ead2 100644 --- a/compiler/rustc_codegen_cranelift/src/main_shim.rs +++ b/compiler/rustc_codegen_cranelift/src/main_shim.rs @@ -76,7 +76,7 @@ pub(crate) fn maybe_create_entry_wrapper( .unwrap(); let mut ctx = Context::new(); - ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig.clone()); + ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig); { let mut func_ctx = FunctionBuilderContext::new(); let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); diff --git a/compiler/rustc_codegen_cranelift/src/metadata.rs b/compiler/rustc_codegen_cranelift/src/metadata.rs index 04369bf89fd2d..cda2a187ff9b7 100644 --- a/compiler/rustc_codegen_cranelift/src/metadata.rs +++ b/compiler/rustc_codegen_cranelift/src/metadata.rs @@ -29,7 +29,7 @@ impl MetadataLoader for CraneliftMetadataLoader { .expect("Rlib metadata file too big to load into memory."), ); ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; - let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); + let buf: OwningRef, [u8]> = OwningRef::new(buf); return Ok(rustc_erase_owner!(buf.map_owner_box())); } } @@ -47,7 +47,7 @@ impl MetadataLoader for CraneliftMetadataLoader { .data() .map_err(|e| format!("failed to read .rustc section: {:?}", e))? .to_owned(); - let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); + let buf: OwningRef, [u8]> = OwningRef::new(buf); Ok(rustc_erase_owner!(buf.map_owner_box())) } } diff --git a/compiler/rustc_codegen_cranelift/src/num.rs b/compiler/rustc_codegen_cranelift/src/num.rs index b37826d71f4e0..41f4a9b9662bc 100644 --- a/compiler/rustc_codegen_cranelift/src/num.rs +++ b/compiler/rustc_codegen_cranelift/src/num.rs @@ -89,10 +89,10 @@ pub(crate) fn codegen_binop<'tcx>( } match in_lhs.layout().ty.kind() { - ty::Bool => crate::num::trans_bool_binop(fx, bin_op, in_lhs, in_rhs), - ty::Uint(_) | ty::Int(_) => crate::num::trans_int_binop(fx, bin_op, in_lhs, in_rhs), - ty::Float(_) => crate::num::trans_float_binop(fx, bin_op, in_lhs, in_rhs), - ty::RawPtr(..) | ty::FnPtr(..) => crate::num::trans_ptr_binop(fx, bin_op, in_lhs, in_rhs), + ty::Bool => crate::num::codegen_bool_binop(fx, bin_op, in_lhs, in_rhs), + ty::Uint(_) | ty::Int(_) => crate::num::codegen_int_binop(fx, bin_op, in_lhs, in_rhs), + ty::Float(_) => crate::num::codegen_float_binop(fx, bin_op, in_lhs, in_rhs), + ty::RawPtr(..) | ty::FnPtr(..) => crate::num::codegen_ptr_binop(fx, bin_op, in_lhs, in_rhs), _ => unreachable!( "{:?}({:?}, {:?})", bin_op, @@ -102,7 +102,7 @@ pub(crate) fn codegen_binop<'tcx>( } } -pub(crate) fn trans_bool_binop<'tcx>( +pub(crate) fn codegen_bool_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -123,7 +123,7 @@ pub(crate) fn trans_bool_binop<'tcx>( CValue::by_val(res, fx.layout_of(fx.tcx.types.bool)) } -pub(crate) fn trans_int_binop<'tcx>( +pub(crate) fn codegen_int_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -196,7 +196,7 @@ pub(crate) fn trans_int_binop<'tcx>( CValue::by_val(val, in_lhs.layout()) } -pub(crate) fn trans_checked_int_binop<'tcx>( +pub(crate) fn codegen_checked_int_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -357,7 +357,7 @@ pub(crate) fn trans_checked_int_binop<'tcx>( out_place.to_cvalue(fx) } -pub(crate) fn trans_float_binop<'tcx>( +pub(crate) fn codegen_float_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -402,7 +402,7 @@ pub(crate) fn trans_float_binop<'tcx>( CValue::by_val(res, in_lhs.layout()) } -pub(crate) fn trans_ptr_binop<'tcx>( +pub(crate) fn codegen_ptr_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, diff --git a/compiler/rustc_codegen_cranelift/src/optimize/stack2reg.rs b/compiler/rustc_codegen_cranelift/src/optimize/stack2reg.rs index f368d65f7f8d8..3c939d5a58639 100644 --- a/compiler/rustc_codegen_cranelift/src/optimize/stack2reg.rs +++ b/compiler/rustc_codegen_cranelift/src/optimize/stack2reg.rs @@ -228,7 +228,8 @@ pub(super) fn optimize_function( match *potential_stores { [] => { #[cfg(debug_assertions)] - clif_comments.add_comment(load, format!("[BUG?] Reading uninitialized memory")); + clif_comments + .add_comment(load, "[BUG?] Reading uninitialized memory".to_string()); } [store] if spatial_overlap(&opt_ctx.ctx.func, store, load) == SpatialOverlap::Full diff --git a/compiler/rustc_codegen_cranelift/src/pretty_clif.rs b/compiler/rustc_codegen_cranelift/src/pretty_clif.rs index 7f8ab953d7199..ff878af7f5eef 100644 --- a/compiler/rustc_codegen_cranelift/src/pretty_clif.rs +++ b/compiler/rustc_codegen_cranelift/src/pretty_clif.rs @@ -131,11 +131,11 @@ impl FuncWriter for &'_ CommentWriter { if !comment.is_empty() { writeln!(w, "; {}", comment)?; } else { - writeln!(w, "")?; + writeln!(w)?; } } if !self.global_comments.is_empty() { - writeln!(w, "")?; + writeln!(w)?; } self.super_preamble(w, func, reg_info) @@ -153,7 +153,7 @@ impl FuncWriter for &'_ CommentWriter { if let Some(comment) = self.entity_comments.get(&entity) { writeln!(w, " ; {}", comment.replace('\n', "\n; ")) } else { - writeln!(w, "") + writeln!(w) } } @@ -261,7 +261,7 @@ pub(crate) fn write_clif_file<'tcx>( writeln!(file, "set is_pic")?; writeln!(file, "set enable_simd")?; writeln!(file, "target {} haswell", target_triple)?; - writeln!(file, "")?; + writeln!(file)?; file.write_all(clif.as_bytes())?; }; if let Err(err) = res { diff --git a/compiler/rustc_codegen_cranelift/src/trap.rs b/compiler/rustc_codegen_cranelift/src/trap.rs index 37dca77bdbd09..690d96764a8f5 100644 --- a/compiler/rustc_codegen_cranelift/src/trap.rs +++ b/compiler/rustc_codegen_cranelift/src/trap.rs @@ -67,4 +67,3 @@ pub(crate) fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, impl Module>, msg: let true_ = fx.bcx.ins().iconst(types::I32, 1); fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); } - diff --git a/compiler/rustc_codegen_cranelift/src/value_and_place.rs b/compiler/rustc_codegen_cranelift/src/value_and_place.rs index 5d513cb3ea022..2b9ea5273b608 100644 --- a/compiler/rustc_codegen_cranelift/src/value_and_place.rs +++ b/compiler/rustc_codegen_cranelift/src/value_and_place.rs @@ -27,10 +27,10 @@ fn codegen_field<'tcx>( return simple(fx); } match field_layout.ty.kind() { - ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(fx), + ty::Slice(..) | ty::Str | ty::Foreign(..) => simple(fx), ty::Adt(def, _) if def.repr.packed() => { assert_eq!(layout.align.abi.bytes(), 1); - return simple(fx); + simple(fx) } _ => { // We have to align the offset for DST's @@ -237,15 +237,12 @@ impl<'tcx> CValue<'tcx> { let clif_ty = fx.clif_type(layout.ty).unwrap(); - match layout.ty.kind() { - ty::Bool => { - assert!( - const_val == 0 || const_val == 1, - "Invalid bool 0x{:032X}", - const_val - ); - } - _ => {} + if let ty::Bool = layout.ty.kind() { + assert!( + const_val == 0 || const_val == 1, + "Invalid bool 0x{:032X}", + const_val + ); } let val = match layout.ty.kind() { @@ -335,7 +332,7 @@ impl<'tcx> CPlace<'tcx> { let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, + size: u32::try_from(layout.size.bytes()).unwrap(), offset: None, }); CPlace { @@ -533,6 +530,13 @@ impl<'tcx> CPlace<'tcx> { dst_ty: Type, ) { let src_ty = fx.bcx.func.dfg.value_type(data); + assert_eq!( + src_ty.bytes(), + dst_ty.bytes(), + "write_cvalue_transmute: {:?} -> {:?}", + src_ty, + dst_ty, + ); let data = match (src_ty, dst_ty) { (_, _) if src_ty == dst_ty => data, @@ -544,6 +548,17 @@ impl<'tcx> CPlace<'tcx> { _ if src_ty.is_vector() && dst_ty.is_vector() => { fx.bcx.ins().raw_bitcast(dst_ty, data) } + _ if src_ty.is_vector() || dst_ty.is_vector() => { + // FIXME do something more efficient for transmutes between vectors and integers. + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: src_ty.bytes(), + offset: None, + }); + let ptr = Pointer::stack_slot(stack_slot); + ptr.store(fx, data, MemFlags::trusted()); + ptr.load(fx, dst_ty, MemFlags::trusted()) + } _ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty, dst_ty), }; fx.bcx diff --git a/compiler/rustc_codegen_cranelift/src/vtable.rs b/compiler/rustc_codegen_cranelift/src/vtable.rs index bb3cf8b3f3a3a..238abc0d8bdfa 100644 --- a/compiler/rustc_codegen_cranelift/src/vtable.rs +++ b/compiler/rustc_codegen_cranelift/src/vtable.rs @@ -108,14 +108,14 @@ fn build_vtable<'tcx>( (&[]).iter() }; let methods = methods.cloned().map(|opt_mth| { - opt_mth.map_or(None, |(def_id, substs)| { - Some(import_function( + opt_mth.map(|(def_id, substs)| { + import_function( tcx, &mut fx.cx.module, Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs) .unwrap() .polymorphize(fx.tcx), - )) + ) }) }); components.extend(methods); @@ -137,15 +137,7 @@ fn build_vtable<'tcx>( } } - data_ctx.set_align( - fx.tcx - .data_layout - .pointer_align - .pref - .bytes() - .try_into() - .unwrap(), - ); + data_ctx.set_align(fx.tcx.data_layout.pointer_align.pref.bytes()); let data_id = fx .cx diff --git a/compiler/rustc_codegen_cranelift/test.sh b/compiler/rustc_codegen_cranelift/test.sh index a1c4d9f287283..3cdd4119d794c 100755 --- a/compiler/rustc_codegen_cranelift/test.sh +++ b/compiler/rustc_codegen_cranelift/test.sh @@ -1,119 +1,15 @@ #!/bin/bash set -e -# Build cg_clif export RUSTFLAGS="-Zrun_dsymutil=no" -if [[ "$1" == "--release" ]]; then - export CHANNEL='release' - cargo build --release -else - export CHANNEL='debug' - cargo build --bin cg_clif -fi -# Config -source scripts/config.sh -export CG_CLIF_INCR_CACHE_DISABLED=1 -RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo=2" +./build.sh --without-sysroot $@ -# Cleanup rm -r target/out || true -# Perform all tests -echo "[BUILD] mini_core" -$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE +scripts/tests.sh no_sysroot -echo "[BUILD] example" -$RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE +./build.sh $@ -if [[ "$JIT_SUPPORTED" = "1" ]]; then - echo "[JIT] mini_core_hello_world" - CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --jit example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE -else - echo "[JIT] mini_core_hello_world (skipped)" -fi - -echo "[AOT] mini_core_hello_world" -$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd -# (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd - -echo "[AOT] arbitrary_self_types_pointers_and_wrappers" -$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers - -echo "[BUILD] sysroot" -time ./build_sysroot/build_sysroot.sh --release - -echo "[AOT] alloc_example" -$RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/alloc_example - -if [[ "$JIT_SUPPORTED" = "1" ]]; then - echo "[JIT] std_example" - $RUSTC --jit example/std_example.rs --target $HOST_TRIPLE -else - echo "[JIT] std_example (skipped)" -fi - -echo "[AOT] dst_field_align" -# FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed. -$RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false) - -echo "[AOT] std_example" -$RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/std_example arg - -echo "[AOT] subslice-patterns-const-eval" -$RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/subslice-patterns-const-eval - -echo "[AOT] track-caller-attribute" -$RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/track-caller-attribute - -echo "[AOT] mod_bench" -$RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/mod_bench - -pushd rand -rm -r ./target || true -../cargo.sh test --workspace -popd - -pushd simple-raytracer -if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then - echo "[BENCH COMPILE] ebobby/simple-raytracer" - hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "cargo clean" \ - "RUSTC=rustc RUSTFLAGS='' cargo build" \ - "../cargo.sh build" - - echo "[BENCH RUN] ebobby/simple-raytracer" - cp ./target/debug/main ./raytracer_cg_clif - hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif -else - echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)" - echo "[COMPILE] ebobby/simple-raytracer" - ../cargo.sh build - echo "[BENCH RUN] ebobby/simple-raytracer (skipped)" -fi -popd - -pushd build_sysroot/sysroot_src/library/core/tests -echo "[TEST] libcore" -rm -r ./target || true -../../../../../cargo.sh test -popd - -pushd regex -echo "[TEST] rust-lang/regex example shootout-regex-dna" -../cargo.sh clean -# Make sure `[codegen mono items] start` doesn't poison the diff -../cargo.sh build --example shootout-regex-dna -cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna | grep -v "Spawned thread" > res.txt -diff -u res.txt examples/regexdna-output.txt - -echo "[TEST] rust-lang/regex tests" -../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -popd +scripts/tests.sh base_sysroot +scripts/tests.sh extended_sysroot diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 2dc7b7e2da383..302713a21db9e 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -299,7 +299,7 @@ pub trait Emitter { // Skip past non-macro entries, just in case there // are some which do actually involve macros. - ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None, + ExpnKind::Inlined | ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None, ExpnKind::Macro(macro_kind, _) => Some(macro_kind), } @@ -359,7 +359,10 @@ pub trait Emitter { continue; } - if always_backtrace { + if matches!(trace.kind, ExpnKind::Inlined) { + new_labels + .push((trace.call_site, "in the inlined copy of this code".to_string())); + } else if always_backtrace { new_labels.push(( trace.def_site, format!( diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index b0e43a260e91d..b435def87ac84 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -793,7 +793,7 @@ impl SyntaxExtension { allow_internal_unsafe: sess.contains_name(attrs, sym::allow_internal_unsafe), local_inner_macros, stability, - deprecation: attr::find_deprecation(&sess, attrs, span), + deprecation: attr::find_deprecation(&sess, attrs).map(|(d, _)| d), helper_attrs, edition, is_builtin, diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 048f096aabe13..a1b7c13e4c0f0 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2705,6 +2705,32 @@ declare_lint! { }; } +declare_lint! { + /// The `useless_deprecated` lint detects deprecation attributes with no effect. + /// + /// ### Example + /// + /// ```rust,compile_fail + /// struct X; + /// + /// #[deprecated = "message"] + /// impl Default for X { + /// fn default() -> Self { + /// X + /// } + /// } + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Deprecation attributes have no effect on trait implementations. + pub USELESS_DEPRECATED, + Deny, + "detects deprecation attributes with no effect", +} + declare_tool_lint! { pub rustc::INEFFECTIVE_UNSTABLE_TRAIT_IMPL, Deny, @@ -2792,6 +2818,7 @@ declare_lint_pass! { INEFFECTIVE_UNSTABLE_TRAIT_IMPL, UNINHABITED_STATIC, FUNCTION_ITEM_REFERENCES, + USELESS_DEPRECATED, ] } diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 781c1744ac62d..a61d37cc90eba 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -371,7 +371,9 @@ pub fn struct_lint_level<'s, 'd>( pub fn in_external_macro(sess: &Session, span: Span) -> bool { let expn_data = span.ctxt().outer_expn_data(); match expn_data.kind { - ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop(_)) => false, + ExpnKind::Inlined | ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop(_)) => { + false + } ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => true, // well, it's "external" ExpnKind::Macro(MacroKind::Bang, _) => { // Dummy span for the `def_site` means it's an external macro. diff --git a/compiler/rustc_mir/src/transform/function_item_references.rs b/compiler/rustc_mir/src/transform/function_item_references.rs index 61427422e4b59..d592580af9cec 100644 --- a/compiler/rustc_mir/src/transform/function_item_references.rs +++ b/compiler/rustc_mir/src/transform/function_item_references.rs @@ -51,10 +51,11 @@ impl<'a, 'tcx> Visitor<'tcx> for FunctionItemRefChecker<'a, 'tcx> { let arg_ty = args[0].ty(self.body, self.tcx); for generic_inner_ty in arg_ty.walk() { if let GenericArgKind::Type(inner_ty) = generic_inner_ty.unpack() { - if let Some(fn_id) = FunctionItemRefChecker::is_fn_ref(inner_ty) { - let ident = self.tcx.item_name(fn_id).to_ident_string(); + if let Some((fn_id, fn_substs)) = + FunctionItemRefChecker::is_fn_ref(inner_ty) + { let span = self.nth_arg_span(&args, 0); - self.emit_lint(ident, fn_id, source_info, span); + self.emit_lint(fn_id, fn_substs, source_info, span); } } } @@ -66,6 +67,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FunctionItemRefChecker<'a, 'tcx> { } self.super_terminator(terminator, location); } + /// Emits a lint for function references formatted with `fmt::Pointer::fmt` by macros. These /// cases are handled as operands instead of call terminators to avoid any dependence on /// unstable, internal formatting details like whether `fmt` is called directly or not. @@ -76,13 +78,12 @@ impl<'a, 'tcx> Visitor<'tcx> for FunctionItemRefChecker<'a, 'tcx> { if let ty::FnDef(def_id, substs_ref) = *op_ty.kind() { if self.tcx.is_diagnostic_item(sym::pointer_trait_fmt, def_id) { let param_ty = substs_ref.type_at(0); - if let Some(fn_id) = FunctionItemRefChecker::is_fn_ref(param_ty) { + if let Some((fn_id, fn_substs)) = FunctionItemRefChecker::is_fn_ref(param_ty) { // The operand's ctxt wouldn't display the lint since it's inside a macro so // we have to use the callsite's ctxt. let callsite_ctxt = source_info.span.source_callsite().ctxt(); let span = source_info.span.with_ctxt(callsite_ctxt); - let ident = self.tcx.item_name(fn_id).to_ident_string(); - self.emit_lint(ident, fn_id, source_info, span); + self.emit_lint(fn_id, fn_substs, source_info, span); } } } @@ -115,10 +116,11 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> { if TyS::same_type(inner_ty, bound_ty) { // Do a substitution using the parameters from the callsite let subst_ty = inner_ty.subst(self.tcx, substs_ref); - if let Some(fn_id) = FunctionItemRefChecker::is_fn_ref(subst_ty) { - let ident = self.tcx.item_name(fn_id).to_ident_string(); + if let Some((fn_id, fn_substs)) = + FunctionItemRefChecker::is_fn_ref(subst_ty) + { let span = self.nth_arg_span(args, arg_num); - self.emit_lint(ident, fn_id, source_info, span); + self.emit_lint(fn_id, fn_substs, source_info, span); } } } @@ -127,6 +129,7 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> { } } } + /// If the given predicate is the trait `fmt::Pointer`, returns the bound parameter type. fn is_pointer_trait(&self, bound: &PredicateAtom<'tcx>) -> Option> { if let ty::PredicateAtom::Trait(predicate, _) = bound { @@ -139,22 +142,26 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> { None } } + /// If a type is a reference or raw pointer to the anonymous type of a function definition, - /// returns that function's `DefId`. - fn is_fn_ref(ty: Ty<'tcx>) -> Option { + /// returns that function's `DefId` and `SubstsRef`. + fn is_fn_ref(ty: Ty<'tcx>) -> Option<(DefId, SubstsRef<'tcx>)> { let referent_ty = match ty.kind() { ty::Ref(_, referent_ty, _) => Some(referent_ty), ty::RawPtr(ty_and_mut) => Some(&ty_and_mut.ty), _ => None, }; referent_ty - .map( - |ref_ty| { - if let ty::FnDef(def_id, _) = *ref_ty.kind() { Some(def_id) } else { None } - }, - ) + .map(|ref_ty| { + if let ty::FnDef(def_id, substs_ref) = *ref_ty.kind() { + Some((def_id, substs_ref)) + } else { + None + } + }) .unwrap_or(None) } + fn nth_arg_span(&self, args: &Vec>, n: usize) -> Span { match &args[n] { Operand::Copy(place) | Operand::Move(place) => { @@ -163,7 +170,14 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> { Operand::Constant(constant) => constant.span, } } - fn emit_lint(&self, ident: String, fn_id: DefId, source_info: SourceInfo, span: Span) { + + fn emit_lint( + &self, + fn_id: DefId, + fn_substs: SubstsRef<'tcx>, + source_info: SourceInfo, + span: Span, + ) { let lint_root = self.body.source_scopes[source_info.scope] .local_data .as_ref() @@ -180,6 +194,10 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> { s } }; + let ident = self.tcx.item_name(fn_id).to_ident_string(); + let ty_params = fn_substs.types().map(|ty| format!("{}", ty)); + let const_params = fn_substs.consts().map(|c| format!("{}", c)); + let params = ty_params.chain(const_params).collect::>().join(", "); let num_args = fn_sig.inputs().map_bound(|inputs| inputs.len()).skip_binder(); let variadic = if fn_sig.c_variadic() { ", ..." } else { "" }; let ret = if fn_sig.output().skip_binder().is_unit() { "" } else { " -> _" }; @@ -190,7 +208,7 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> { &format!("cast `{}` to obtain a function pointer", ident), format!( "{} as {}{}fn({}{}){}", - ident, + if params.is_empty() { ident } else { format!("{}::<{}>", ident, params) }, unsafety, abi, vec!["_"; num_args].join(", "), diff --git a/compiler/rustc_mir/src/transform/inline.rs b/compiler/rustc_mir/src/transform/inline.rs index 010a7470ccd38..5407226e386cb 100644 --- a/compiler/rustc_mir/src/transform/inline.rs +++ b/compiler/rustc_mir/src/transform/inline.rs @@ -8,6 +8,7 @@ use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::subst::Subst; use rustc_middle::ty::{self, ConstKind, Instance, InstanceDef, ParamEnv, Ty, TyCtxt}; +use rustc_span::{hygiene::ExpnKind, ExpnData, Span}; use rustc_target::spec::abi::Abi; use super::simplify::{remove_dead_blocks, CfgSimplifier}; @@ -471,6 +472,8 @@ impl Inliner<'tcx> { cleanup_block: cleanup, in_cleanup_block: false, tcx: self.tcx, + callsite_span: callsite.source_info.span, + body_span: callee_body.span, }; // Map all `Local`s, `SourceScope`s and `BasicBlock`s to new ones @@ -682,6 +685,8 @@ struct Integrator<'a, 'tcx> { cleanup_block: Option, in_cleanup_block: bool, tcx: TyCtxt<'tcx>, + callsite_span: Span, + body_span: Span, } impl<'a, 'tcx> Integrator<'a, 'tcx> { @@ -726,6 +731,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> { *scope = self.map_scope(*scope); } + fn visit_span(&mut self, span: &mut Span) { + // Make sure that all spans track the fact that they were inlined. + *span = self.callsite_span.fresh_expansion(ExpnData { + def_site: self.body_span, + ..ExpnData::default(ExpnKind::Inlined, *span, self.tcx.sess.edition(), None) + }); + } + fn visit_place(&mut self, place: &mut Place<'tcx>, context: PlaceContext, location: Location) { // If this is the `RETURN_PLACE`, we need to rebase any projections onto it. let dest_proj_len = self.destination.projection.len(); diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs index e46274770be17..29fc23c324f44 100644 --- a/compiler/rustc_mir_build/src/build/matches/simplify.rs +++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs @@ -44,12 +44,36 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { candidate: &mut Candidate<'pat, 'tcx>, ) -> bool { // repeatedly simplify match pairs until fixed point is reached + debug!(?candidate, "simplify_candidate"); + + // existing_bindings and new_bindings exists to keep the semantics in order. + // Reversing the binding order for bindings after `@` changes the binding order in places + // it shouldn't be changed, for example `let (Some(a), Some(b)) = (x, y)` + // + // To avoid this, the binding occurs in the following manner: + // * the bindings for one iteration of the following loop occurs in order (i.e. left to + // right) + // * the bindings from the previous iteration of the loop is prepended to the bindings from + // the current iteration (in the implementation this is done by mem::swap and extend) + // * after all iterations, these new bindings are then appended to the bindings that were + // prexisting (i.e. `candidate.binding` when the function was called). + // + // example: + // candidate.bindings = [1, 2, 3] + // binding in iter 1: [4, 5] + // binding in iter 2: [6, 7] + // + // final binding: [1, 2, 3, 6, 7, 4, 5] + let mut existing_bindings = mem::take(&mut candidate.bindings); + let mut new_bindings = Vec::new(); loop { let match_pairs = mem::take(&mut candidate.match_pairs); if let [MatchPair { pattern: Pat { kind: box PatKind::Or { pats }, .. }, place }] = *match_pairs { + existing_bindings.extend_from_slice(&new_bindings); + mem::swap(&mut candidate.bindings, &mut existing_bindings); candidate.subcandidates = self.create_or_subcandidates(candidate, place, pats); return true; } @@ -65,13 +89,33 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } } + // Avoid issue #69971: the binding order should be right to left if there are more + // bindings after `@` to please the borrow checker + // Ex + // struct NonCopyStruct { + // copy_field: u32, + // } + // + // fn foo1(x: NonCopyStruct) { + // let y @ NonCopyStruct { copy_field: z } = x; + // // the above should turn into + // let z = x.copy_field; + // let y = x; + // } + candidate.bindings.extend_from_slice(&new_bindings); + mem::swap(&mut candidate.bindings, &mut new_bindings); + candidate.bindings.clear(); + if !changed { + existing_bindings.extend_from_slice(&new_bindings); + mem::swap(&mut candidate.bindings, &mut existing_bindings); // Move or-patterns to the end, because they can result in us // creating additional candidates, so we want to test them as // late as possible. candidate .match_pairs .sort_by_key(|pair| matches!(*pair.pattern.kind, PatKind::Or { .. })); + debug!(simplified = ?candidate, "simplify_candidate"); return false; // if we were not able to simplify any, done. } } diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index e851451269e32..bad43cd5350f2 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -611,11 +611,11 @@ fn prepend_attrs( } let mut builder = tokenstream::TokenStreamBuilder::new(); for attr in attrs { - assert_eq!( - attr.style, - ast::AttrStyle::Outer, - "inner attributes should prevent cached tokens from existing" - ); + // FIXME: Correctly handle tokens for inner attributes. + // For now, we fall back to reparsing the original AST node + if attr.style == ast::AttrStyle::Inner { + return None; + } builder.push( attr.tokens .as_ref() diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 48a635844fe70..5954b370e6d98 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -7,7 +7,7 @@ use crate::maybe_whole; use rustc_ast::ptr::P; use rustc_ast::token::{self, TokenKind}; use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; -use rustc_ast::{self as ast, AttrStyle, AttrVec, Attribute, DUMMY_NODE_ID}; +use rustc_ast::{self as ast, AttrVec, Attribute, DUMMY_NODE_ID}; use rustc_ast::{AssocItem, AssocItemKind, ForeignItemKind, Item, ItemKind, Mod}; use rustc_ast::{Async, Const, Defaultness, IsAuto, Mutability, Unsafe, UseTree, UseTreeKind}; use rustc_ast::{BindingMode, Block, FnDecl, FnSig, Param, SelfKind}; @@ -127,34 +127,19 @@ impl<'a> Parser<'a> { let (mut item, tokens) = if needs_tokens { let (item, tokens) = self.collect_tokens(parse_item)?; - (item, Some(tokens)) + (item, tokens) } else { (parse_item(self)?, None) }; - - self.unclosed_delims.append(&mut unclosed_delims); - - // Once we've parsed an item and recorded the tokens we got while - // parsing we may want to store `tokens` into the item we're about to - // return. Note, though, that we specifically didn't capture tokens - // related to outer attributes. The `tokens` field here may later be - // used with procedural macros to convert this item back into a token - // stream, but during expansion we may be removing attributes as we go - // along. - // - // If we've got inner attributes then the `tokens` we've got above holds - // these inner attributes. If an inner attribute is expanded we won't - // actually remove it from the token stream, so we'll just keep yielding - // it (bad!). To work around this case for now we just avoid recording - // `tokens` if we detect any inner attributes. This should help keep - // expansion correct, but we should fix this bug one day! - if let Some(tokens) = tokens { - if let Some(item) = &mut item { - if !item.attrs.iter().any(|attr| attr.style == AttrStyle::Inner) { - item.tokens = tokens; - } + if let Some(item) = &mut item { + // If we captured tokens during parsing (due to encountering an `NtItem`), + // use those instead + if item.tokens.is_none() { + item.tokens = tokens; } } + + self.unclosed_delims.append(&mut unclosed_delims); Ok(item) } diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index c9497f2a5b2b0..04b5c65e464fb 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -15,7 +15,7 @@ use rustc_middle::middle::privacy::AccessLevels; use rustc_middle::middle::stability::{DeprecationEntry, Index}; use rustc_middle::ty::{self, query::Providers, TyCtxt}; use rustc_session::lint; -use rustc_session::lint::builtin::INEFFECTIVE_UNSTABLE_TRAIT_IMPL; +use rustc_session::lint::builtin::{INEFFECTIVE_UNSTABLE_TRAIT_IMPL, USELESS_DEPRECATED}; use rustc_session::parse::feature_err; use rustc_session::Session; use rustc_span::symbol::{sym, Symbol}; @@ -31,6 +31,8 @@ enum AnnotationKind { Required, // Annotation is useless, reject it Prohibited, + // Deprecation annotation is useless, reject it. (Stability attribute is still required.) + DeprecationProhibited, // Annotation itself is useless, but it can be propagated to children Container, } @@ -83,14 +85,22 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { did_error = self.forbid_staged_api_attrs(hir_id, attrs, inherit_deprecation.clone()); } - let depr = - if did_error { None } else { attr::find_deprecation(&self.tcx.sess, attrs, item_sp) }; + let depr = if did_error { None } else { attr::find_deprecation(&self.tcx.sess, attrs) }; let mut is_deprecated = false; - if let Some(depr) = &depr { + if let Some((depr, span)) = &depr { is_deprecated = true; - if kind == AnnotationKind::Prohibited { - self.tcx.sess.span_err(item_sp, "This deprecation annotation is useless"); + if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited { + self.tcx.struct_span_lint_hir(USELESS_DEPRECATED, hir_id, *span, |lint| { + lint.build("this `#[deprecated]` annotation has no effect") + .span_suggestion_short( + *span, + "remove the unnecessary deprecation attribute", + String::new(), + rustc_errors::Applicability::MachineApplicable, + ) + .emit() + }); } // `Deprecation` is just two pointers, no need to intern it @@ -114,7 +124,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { } } else { self.recurse_with_stability_attrs( - depr.map(|d| DeprecationEntry::local(d, hir_id)), + depr.map(|(d, _)| DeprecationEntry::local(d, hir_id)), None, None, visit_children, @@ -139,11 +149,11 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { } } - if depr.as_ref().map_or(false, |d| d.is_since_rustc_version) { + if let Some((rustc_attr::Deprecation { is_since_rustc_version: true, .. }, span)) = &depr { if stab.is_none() { struct_span_err!( self.tcx.sess, - item_sp, + *span, E0549, "rustc_deprecated attribute must be paired with \ either stable or unstable attribute" @@ -166,7 +176,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { // Check if deprecated_since < stable_since. If it is, // this is *almost surely* an accident. if let (&Some(dep_since), &attr::Stable { since: stab_since }) = - (&depr.as_ref().and_then(|d| d.since), &stab.level) + (&depr.as_ref().and_then(|(d, _)| d.since), &stab.level) { // Explicit version of iter::order::lt to handle parse errors properly for (dep_v, stab_v) in @@ -212,7 +222,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { } self.recurse_with_stability_attrs( - depr.map(|d| DeprecationEntry::local(d, hir_id)), + depr.map(|(d, _)| DeprecationEntry::local(d, hir_id)), stab, const_stab, visit_children, @@ -322,6 +332,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { } hir::ItemKind::Impl { of_trait: Some(_), .. } => { self.in_trait_impl = true; + kind = AnnotationKind::DeprecationProhibited; } hir::ItemKind::Struct(ref sd, _) => { if let Some(ctor_hir_id) = sd.ctor_hir_id() { diff --git a/compiler/rustc_save_analysis/src/lib.rs b/compiler/rustc_save_analysis/src/lib.rs index 48d15370ee320..eed9f2eb74d4f 100644 --- a/compiler/rustc_save_analysis/src/lib.rs +++ b/compiler/rustc_save_analysis/src/lib.rs @@ -799,7 +799,9 @@ impl<'tcx> SaveContext<'tcx> { // These are not macros. // FIXME(eddyb) maybe there is a way to handle them usefully? - ExpnKind::Root | ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => return None, + ExpnKind::Inlined | ExpnKind::Root | ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => { + return None; + } }; let callee_span = self.span_from_span(callee.def_site); diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 31f3d8e379109..0f82db1d05aa1 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -766,6 +766,8 @@ pub enum ExpnKind { AstPass(AstPass), /// Desugaring done by the compiler during HIR lowering. Desugaring(DesugaringKind), + /// MIR inlining + Inlined, } impl ExpnKind { @@ -779,6 +781,7 @@ impl ExpnKind { }, ExpnKind::AstPass(kind) => kind.descr().to_string(), ExpnKind::Desugaring(kind) => format!("desugaring of {}", kind.descr()), + ExpnKind::Inlined => "inlined source".to_string(), } } } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 6c2c05ac7197e..5a73f58304501 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -970,7 +970,8 @@ impl Step for Compiletest { if builder.top_stage == 0 && env::var("COMPILETEST_FORCE_STAGE0").is_err() { eprintln!("\ error: `--stage 0` runs compiletest on the beta compiler, not your local changes, and will almost always cause tests to fail -help: use `--stage 1` instead +help: to test the compiler, use `--stage 1` instead +help: to test the standard library, use `--stage 0 library/std` instead note: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `COMPILETEST_FORCE_STAGE0=1`." ); std::process::exit(1); diff --git a/src/etc/lldb_batchmode.py b/src/etc/lldb_batchmode.py index 629c8e04ec533..fc355c87b52a2 100644 --- a/src/etc/lldb_batchmode.py +++ b/src/etc/lldb_batchmode.py @@ -28,7 +28,7 @@ import _thread as thread # Set this to True for additional output -DEBUG_OUTPUT = False +DEBUG_OUTPUT = True def print_debug(s): @@ -102,7 +102,7 @@ def execute_command(command_interpreter, command): registered_breakpoints.add(breakpoint_id) else: print("Error while trying to register breakpoint callback, id = " + - str(breakpoint_id)) + str(breakpoint_id) + ", message = " + str(res.GetError())) else: print(res.GetError()) diff --git a/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff index bba10f09c3fbb..1fbda50f783e1 100644 --- a/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff @@ -19,7 +19,7 @@ - debug z => _3; // in scope 3 at $DIR/cycle.rs:11:9: 11:10 + debug z => _4; // in scope 3 at $DIR/cycle.rs:11:9: 11:10 scope 4 (inlined std::mem::drop::) { // at $DIR/cycle.rs:14:5: 14:12 - debug _x => _6; // in scope 4 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _6; // in scope 4 at $DIR/cycle.rs:14:5: 14:12 } } } @@ -56,7 +56,7 @@ StorageLive(_6); // scope 3 at $DIR/cycle.rs:14:10: 14:11 - _6 = _1; // scope 3 at $DIR/cycle.rs:14:10: 14:11 + _6 = _4; // scope 3 at $DIR/cycle.rs:14:10: 14:11 - _5 = const (); // scope 4 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _5 = const (); // scope 4 at $DIR/cycle.rs:14:5: 14:12 StorageDead(_6); // scope 3 at $DIR/cycle.rs:14:11: 14:12 StorageDead(_5); // scope 3 at $DIR/cycle.rs:14:12: 14:13 _0 = const (); // scope 0 at $DIR/cycle.rs:8:11: 15:2 diff --git a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff index 0028e280516da..0ff3e4b2dcf7d 100644 --- a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff @@ -12,7 +12,7 @@ scope 2 { } scope 3 (inlined std::mem::drop::) { // at $DIR/union.rs:15:5: 15:27 - debug _x => _4; // in scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _4; // in scope 3 at $DIR/union.rs:15:5: 15:27 } } @@ -31,7 +31,7 @@ StorageLive(_3); // scope 1 at $DIR/union.rs:15:5: 15:27 StorageLive(_4); // scope 1 at $DIR/union.rs:15:10: 15:26 _4 = (_1.0: u32); // scope 2 at $DIR/union.rs:15:19: 15:24 - _3 = const (); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _3 = const (); // scope 3 at $DIR/union.rs:15:5: 15:27 StorageDead(_4); // scope 1 at $DIR/union.rs:15:26: 15:27 StorageDead(_3); // scope 1 at $DIR/union.rs:15:27: 15:28 _0 = const (); // scope 0 at $DIR/union.rs:8:11: 16:2 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 164e769e93b02..6da0460286b9a 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 @@ -27,8 +27,8 @@ fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 1 debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator-drop-cleanup.rs:11:13: 11:15 } scope 2 (inlined String::new) { // at $DIR/generator-drop-cleanup.rs:11:18: 11:31 - let mut _6: std::vec::Vec; // in scope 2 at $SRC_DIR/alloc/src/string.rs:LL:COL - scope 3 (inlined Vec::::new) { // at $SRC_DIR/alloc/src/string.rs:LL:COL + let mut _6: std::vec::Vec; // in scope 2 at $DIR/generator-drop-cleanup.rs:11:18: 11:31 + scope 3 (inlined Vec::::new) { // at $DIR/generator-drop-cleanup.rs:11:18: 11:31 } } 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 b2745a17e9717..815d02c73d1e2 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 @@ -9,10 +9,10 @@ fn bar() -> bool { scope 1 { debug f => _1; // in scope 1 at $DIR/inline-any-operand.rs:11:9: 11: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 x => _3; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + debug y => _4; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + let mut _5: i32; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + let mut _6: i32; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 } } @@ -28,13 +28,13 @@ fn bar() -> bool { _3 = const 1_i32; // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 StorageLive(_4); // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 _4 = const -1_i32; // scope 1 at $DIR/inline-any-operand.rs:12:5: 12: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 + StorageLive(_5); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + _5 = _3; // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + StorageLive(_6); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + _6 = _4; // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + _0 = Eq(move _5, move _6); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + StorageDead(_6); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + StorageDead(_5); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 StorageDead(_4); // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 StorageDead(_3); // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 StorageDead(_2); // scope 1 at $DIR/inline-any-operand.rs:12:12: 12:13 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 93a63c8478391..d312369d2af75 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 @@ -14,8 +14,8 @@ fn foo(_1: T, _2: i32) -> i32 { scope 1 { debug x => _3; // in scope 1 at $DIR/inline-closure.rs:11:9: 11: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:11:14: 11:16 - debug _q => _9; // in scope 2 at $DIR/inline-closure.rs:11:18: 11:20 + debug _t => _8; // in scope 2 at $DIR/inline-closure.rs:12:5: 12:12 + debug _q => _9; // in scope 2 at $DIR/inline-closure.rs:12:5: 12:12 } } @@ -34,7 +34,7 @@ fn foo(_1: T, _2: i32) -> i32 { _8 = move (_5.0: i32); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 StorageLive(_9); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 _9 = move (_5.1: i32); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 - _0 = _8; // scope 2 at $DIR/inline-closure.rs:11:22: 11:24 + _0 = _8; // scope 2 at $DIR/inline-closure.rs:12:5: 12:12 StorageDead(_9); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 StorageDead(_8); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 StorageDead(_7); // scope 1 at $DIR/inline-closure.rs:12:11: 12:12 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 c6893022be60a..db504b416fe1d 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 @@ -14,11 +14,11 @@ fn foo(_1: T, _2: &i32) -> i32 { scope 1 { debug x => _3; // in scope 1 at $DIR/inline-closure-borrows-arg.rs:12:9: 12: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:12:14: 12:15 - debug _s => _9; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:12:23: 12:25 - let _10: &i32; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:13:13: 13:21 + debug r => _8; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + debug _s => _9; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + let _10: &i32; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 scope 3 { - debug variable => _10; // in scope 3 at $DIR/inline-closure-borrows-arg.rs:13:13: 13:21 + debug variable => _10; // in scope 3 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 } } } @@ -38,10 +38,10 @@ fn foo(_1: T, _2: &i32) -> i32 { _8 = move (_5.0: &i32); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 StorageLive(_9); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 _9 = move (_5.1: &i32); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 - StorageLive(_10); // scope 2 at $DIR/inline-closure-borrows-arg.rs:13:13: 13:21 - _10 = _8; // scope 2 at $DIR/inline-closure-borrows-arg.rs:13:24: 13:27 - _0 = (*_8); // scope 3 at $DIR/inline-closure-borrows-arg.rs:14:9: 14:18 - StorageDead(_10); // scope 2 at $DIR/inline-closure-borrows-arg.rs:15:5: 15:6 + StorageLive(_10); // scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _10 = _8; // scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _0 = (*_8); // scope 3 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + StorageDead(_10); // scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 StorageDead(_9); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 StorageDead(_8); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 StorageDead(_7); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 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 2950af63d3c60..a861eab39d337 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 @@ -14,10 +14,10 @@ fn foo(_1: T, _2: i32) -> (i32, T) { scope 1 { debug x => _3; // in scope 1 at $DIR/inline-closure-captures.rs:11:9: 11: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:11:14: 11:16 - debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline-closure-captures.rs:10:23: 10:24 - debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:10:17: 10:18 - let mut _10: T; // in scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23 + debug _q => _9; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + let mut _10: T; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 } } @@ -39,11 +39,11 @@ fn foo(_1: T, _2: i32) -> (i32, T) { (_7.0: i32) = move _8; // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageLive(_9); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 _9 = move (_7.0: i32); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 - (_0.0: i32) = (*((*_6).0: &i32)); // scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20 - StorageLive(_10); // scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23 - _10 = (*((*_6).1: &T)); // scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23 - (_0.1: T) = move _10; // scope 2 at $DIR/inline-closure-captures.rs:11:18: 11:24 - StorageDead(_10); // scope 2 at $DIR/inline-closure-captures.rs:11:23: 11:24 + (_0.0: i32) = (*((*_6).0: &i32)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + StorageLive(_10); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + _10 = (*((*_6).1: &T)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + (_0.1: T) = move _10; // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + StorageDead(_10); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageDead(_9); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageDead(_8); // scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 StorageDead(_7); // scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 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 2fc908b51f39a..451ec39422fc4 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 @@ -16,7 +16,7 @@ - } - - bb1: { -+ _1 = const (); // scope 1 at $DIR/inline-compatibility.rs:39:29: 39:31 ++ _1 = const (); // scope 1 at $DIR/inline-compatibility.rs:25:5: 25:18 StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:25:18: 25:19 _0 = const (); // scope 0 at $DIR/inline-compatibility.rs:24:37: 26:2 return; // scope 0 at $DIR/inline-compatibility.rs:26:2: 26: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 c92594d08de2b..a59ddd344cb26 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 @@ -16,7 +16,7 @@ - } - - bb1: { -+ _1 = const (); // scope 1 at $DIR/inline-compatibility.rs:35:32: 35:34 ++ _1 = const (); // scope 1 at $DIR/inline-compatibility.rs:14:5: 14:21 StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:14:21: 14:22 _0 = const (); // scope 0 at $DIR/inline-compatibility.rs:13:40: 15:2 return; // scope 0 at $DIR/inline-compatibility.rs:15:2: 15:2 diff --git a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff index 49fe14babc50f..0fbafd76e209b 100644 --- a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff +++ b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff @@ -19,7 +19,7 @@ _2 = Box(std::vec::Vec); // scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 - (*_2) = Vec::::new() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 + _4 = &mut (*_2); // scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 -+ ((*_4).0: alloc::raw_vec::RawVec) = const alloc::raw_vec::RawVec:: { ptr: Unique:: { pointer: {0x4 as *const u32}, _marker: PhantomData:: }, cap: 0_usize, alloc: std::alloc::Global }; // scope 2 at $SRC_DIR/alloc/src/vec.rs:LL:COL ++ ((*_4).0: alloc::raw_vec::RawVec) = const alloc::raw_vec::RawVec:: { ptr: Unique:: { pointer: {0x4 as *const u32}, _marker: PhantomData:: }, cap: 0_usize, alloc: std::alloc::Global }; // scope 2 at $DIR/inline-into-box-place.rs:8:33: 8:43 + // ty::Const + // + ty: alloc::raw_vec::RawVec + // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) @@ -30,10 +30,10 @@ - } - - bb1: { -+ // + span: $SRC_DIR/alloc/src/vec.rs:LL:COL ++ // + span: $DIR/inline-into-box-place.rs:8:33: 8:43 + // + user_ty: UserType(0) + // + literal: Const { ty: alloc::raw_vec::RawVec, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } -+ ((*_4).1: usize) = const 0_usize; // scope 2 at $SRC_DIR/alloc/src/vec.rs:LL:COL ++ ((*_4).1: usize) = const 0_usize; // scope 2 at $DIR/inline-into-box-place.rs:8:33: 8:43 _1 = move _2; // scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 StorageDead(_2); // scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 _0 = const (); // scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2 diff --git a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff index bb8ebc30cdd88..9277e57134eca 100644 --- a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff +++ b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff @@ -19,7 +19,7 @@ _2 = Box(std::vec::Vec); // scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 - (*_2) = Vec::::new() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 + _4 = &mut (*_2); // scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 -+ ((*_4).0: alloc::raw_vec::RawVec) = const alloc::raw_vec::RawVec:: { ptr: Unique:: { pointer: {0x4 as *const u32}, _marker: PhantomData:: }, cap: 0_usize, alloc: std::alloc::Global }; // scope 2 at $SRC_DIR/alloc/src/vec.rs:LL:COL ++ ((*_4).0: alloc::raw_vec::RawVec) = const alloc::raw_vec::RawVec:: { ptr: Unique:: { pointer: {0x4 as *const u32}, _marker: PhantomData:: }, cap: 0_usize, alloc: std::alloc::Global }; // scope 2 at $DIR/inline-into-box-place.rs:8:33: 8:43 + // ty::Const + // + ty: alloc::raw_vec::RawVec + // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) @@ -30,10 +30,10 @@ - } - - bb1: { -+ // + span: $SRC_DIR/alloc/src/vec.rs:LL:COL ++ // + span: $DIR/inline-into-box-place.rs:8:33: 8:43 + // + user_ty: UserType(0) + // + literal: Const { ty: alloc::raw_vec::RawVec, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } -+ ((*_4).1: usize) = const 0_usize; // scope 2 at $SRC_DIR/alloc/src/vec.rs:LL:COL ++ ((*_4).1: usize) = const 0_usize; // scope 2 at $DIR/inline-into-box-place.rs:8:33: 8:43 _1 = move _2; // scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 StorageDead(_2); // scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 _0 = const (); // scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2 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 0cace4e32c405..b9fe84fcd0443 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 @@ -15,10 +15,10 @@ fn bar() -> bool { let mut _9: &i32; // in scope 1 at $DIR/inline-retag.rs:12:11: 12:14 let mut _10: &i32; // in scope 1 at $DIR/inline-retag.rs:12:7: 12: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 x => _3; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + debug y => _6; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + let mut _11: i32; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + let mut _12: i32; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15 } } @@ -58,15 +58,15 @@ fn bar() -> bool { Retag(_7); // scope 1 at $DIR/inline-retag.rs:12:11: 12:14 _6 = &(*_7); // scope 1 at $DIR/inline-retag.rs:12:11: 12:14 Retag(_6); // scope 1 at $DIR/inline-retag.rs:12:11: 12:14 - Retag(_3); // scope 2 at $DIR/inline-retag.rs:16:1: 18:2 - Retag(_6); // scope 2 at $DIR/inline-retag.rs:16:1: 18:2 - 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 + Retag(_3); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + Retag(_6); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + StorageLive(_11); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + _11 = (*_3); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + StorageLive(_12); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + _12 = (*_6); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + _0 = Eq(move _11, move _12); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + StorageDead(_12); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + StorageDead(_11); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 StorageDead(_6); // scope 1 at $DIR/inline-retag.rs:12:14: 12:15 StorageDead(_3); // scope 1 at $DIR/inline-retag.rs:12:14: 12:15 StorageDead(_2); // scope 1 at $DIR/inline-retag.rs:12:14: 12:15 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 96442842bd598..2a9ce446e307c 100644 --- a/src/test/mir-opt/inline/inline_specialization.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_specialization.main.Inline.diff @@ -19,7 +19,7 @@ - } - - bb1: { -+ _1 = const 123_u32; // scope 2 at $DIR/inline-specialization.rs:14:31: 14:34 ++ _1 = const 123_u32; // scope 2 at $DIR/inline-specialization.rs:5:13: 5:38 _0 = const (); // scope 0 at $DIR/inline-specialization.rs:4:11: 6:2 StorageDead(_1); // scope 0 at $DIR/inline-specialization.rs:6:1: 6:2 return; // scope 0 at $DIR/inline-specialization.rs:6:2: 6:2 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 907a56d6a0e42..01be1f3907ca2 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 @@ -6,8 +6,8 @@ fn test2(_1: &dyn X) -> bool { let mut _2: &dyn X; // in scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 let mut _3: &dyn X; // in scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5: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:6 + debug x => _2; // in scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12 + let mut _4: &dyn X; // in scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12 } bb0: { @@ -16,16 +16,16 @@ fn test2(_1: &dyn X) -> bool { _3 = &(*_1); // scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 _2 = move _3 as &dyn X (Pointer(Unsize)); // scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 StorageDead(_3); // scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 - StorageLive(_4); // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:6 - _4 = _2; // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:6 - _0 = ::y(move _4) -> bb1; // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10 + StorageLive(_4); // scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12 + _4 = _2; // scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12 + _0 = ::y(move _4) -> bb1; // scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12 // mir::Constant - // + span: $DIR/inline-trait-method_2.rs:10:7: 10:8 + // + span: $DIR/inline-trait-method_2.rs:5:5: 5:12 // + literal: Const { ty: for<'r> fn(&'r dyn X) -> bool {::y}, val: Value(Scalar()) } } bb1: { - StorageDead(_4); // scope 1 at $DIR/inline-trait-method_2.rs:10:9: 10:10 + StorageDead(_4); // scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12 StorageDead(_2); // scope 0 at $DIR/inline-trait-method_2.rs:5:11: 5:12 return; // scope 0 at $DIR/inline-trait-method_2.rs:6:2: 6: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 08f0dac2e9d05..651855f802454 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 @@ -7,8 +7,8 @@ fn a(_1: &mut [T]) -> &mut [T] { let mut _3: &mut [T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 let mut _4: &mut [T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:6 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 + debug self => _4; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 + let mut _5: &mut [T]; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 } bb0: { @@ -16,10 +16,10 @@ fn a(_1: &mut [T]) -> &mut [T] { StorageLive(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 StorageLive(_4); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:6 _4 = &mut (*_1); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:6 - 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 + StorageLive(_5); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 + _5 = &mut (*_4); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 + _3 = &mut (*_5); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 + StorageDead(_5); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 _2 = &mut (*_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 StorageDead(_4); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:14: 3:15 _0 = &mut (*_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 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 af97434f62929..c67ea7e00b760 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 @@ -7,9 +7,9 @@ fn b(_1: &mut Box) -> &mut T { let mut _3: &mut T; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 let mut _4: &mut std::boxed::Box; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:6 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 + debug self => _4; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + let mut _5: &mut T; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + let mut _6: &mut T; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 } bb0: { @@ -17,13 +17,13 @@ fn b(_1: &mut Box) -> &mut T { StorageLive(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 StorageLive(_4); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:6 _4 = &mut (*_1); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:6 - 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 - _6 = &mut (*(*_4)); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _5 = &mut (*_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _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 + StorageLive(_5); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + StorageLive(_6); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + _6 = &mut (*(*_4)); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + _5 = &mut (*_6); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + _3 = &mut (*_5); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + StorageDead(_6); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + StorageDead(_5); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 _2 = &mut (*_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 StorageDead(_4); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:14: 8:15 _0 = &mut (*_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 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 670f055dc054b..16fae453ac936 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 @@ -6,14 +6,14 @@ fn c(_1: &[T]) -> &[T] { let _2: &[T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15 let mut _3: &[T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:6 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 + debug self => _3; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15 } bb0: { StorageLive(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15 StorageLive(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:6 _3 = &(*_1); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:6 - _2 = _3; // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + _2 = _3; // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15 _0 = &(*_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15 StorageDead(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:14: 13:15 StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:14:1: 14: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 c33e859eb6b0c..e9ca7095a43ab 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 @@ -6,14 +6,14 @@ fn d(_1: &Box) -> &T { let _2: &T; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15 let mut _3: &std::boxed::Box; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:6 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 + debug self => _3; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15 } bb0: { StorageLive(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15 StorageLive(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:6 _3 = &(*_1); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:6 - _2 = &(*(*_3)); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + _2 = &(*(*_3)); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15 _0 = &(*_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15 StorageDead(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:14: 18:15 StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:19:1: 19:2 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 df5355e905eb0..3d386e3b1756b 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 @@ -10,10 +10,10 @@ fn main() -> () { scope 1 { debug f => _1; // in scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:5:9: 5: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:5:14: 5:15 - let _6: (); // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:5:23: 5:24 + debug x => _5; // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 + let _6: (); // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 scope 3 { - debug y => _6; // in scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:5:23: 5:24 + debug y => _6; // in scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 } } } @@ -27,10 +27,10 @@ fn main() -> () { (_3.0: ()) = move _4; // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 StorageLive(_5); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 _5 = move (_3.0: ()); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 - StorageLive(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:5:23: 5:24 - _6 = const (); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:5:27: 5:28 - _0 = const (); // scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:5:30: 5:31 - StorageDead(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:5:32: 5:33 + StorageLive(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 + _6 = const (); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 + _0 = const (); // scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 + StorageDead(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 StorageDead(_5); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 StorageDead(_4); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:9: 6:10 StorageDead(_3); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:9: 6:10 diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff index 23aefe07892fd..f9f30ccb20e25 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff @@ -36,30 +36,30 @@ debug arg0 => _25; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug arg1 => _28; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _25; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _24; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _23: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _24: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _25: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _25; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _24; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _23: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _24: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _25: &&i32; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL scope 7 { } } scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _28; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _27; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _26: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _28: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _28; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _27; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _26: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _28: &&i32; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL scope 9 { } } } scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug pieces => _29; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug args => _31; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _29: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug pieces => _29; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + debug args => _31; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _29: &[&str]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL } } } @@ -139,53 +139,53 @@ // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_23); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _23 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _24) -> bb3; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_23); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _23 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _24) -> bb3; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb3: { - (_21.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _25) -> bb4; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_21.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _25) -> bb4; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb4: { - (_21.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _23; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_23); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_21.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _23; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_23); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL _27 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_26); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _26 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _27) -> bb5; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_26); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _26 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _27) -> bb5; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb5: { - (_22.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _28) -> bb6; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_22.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _28) -> bb6; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb6: { - (_22.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _26; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_26); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_22.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _26; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_26); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL _16 = [move _21, move _22]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL _15 = &_16; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _31 = move _15 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_30); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - discriminant(_30) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.0: &[&str]) = move _29; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _30; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.2: &[std::fmt::ArgumentV1]) = move _31; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_30); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_30); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + discriminant(_30) = 0; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_13.0: &[&str]) = move _29; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_13.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _30; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_13.2: &[std::fmt::ArgumentV1]) = move _31; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_30); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL _12 = &_13; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL begin_panic_fmt(move _12); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff index 23aefe07892fd..f9f30ccb20e25 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff @@ -36,30 +36,30 @@ debug arg0 => _25; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug arg1 => _28; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _25; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _24; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _23: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _24: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _25: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _25; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _24; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _23: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _24: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _25: &&i32; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL scope 7 { } } scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _28; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _27; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _26: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _28: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _28; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _27; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _26: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _28: &&i32; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL scope 9 { } } } scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug pieces => _29; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug args => _31; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _29: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug pieces => _29; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + debug args => _31; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _29: &[&str]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL } } } @@ -139,53 +139,53 @@ // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_23); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _23 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _24) -> bb3; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_23); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _23 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _24) -> bb3; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb3: { - (_21.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _25) -> bb4; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_21.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _25) -> bb4; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb4: { - (_21.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _23; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_23); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_21.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _23; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_23); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL _27 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_26); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _26 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _27) -> bb5; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_26); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _26 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _27) -> bb5; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb5: { - (_22.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _28) -> bb6; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_22.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _28) -> bb6; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb6: { - (_22.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _26; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_26); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_22.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _26; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_26); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL _16 = [move _21, move _22]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL _15 = &_16; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _31 = move _15 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_30); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - discriminant(_30) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.0: &[&str]) = move _29; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _30; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.2: &[std::fmt::ArgumentV1]) = move _31; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_30); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_30); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + discriminant(_30) = 0; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_13.0: &[&str]) = move _29; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_13.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _30; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_13.2: &[std::fmt::ArgumentV1]) = move _31; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_30); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL _12 = &_13; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL begin_panic_fmt(move _12); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff index b9cb58e14c45d..a9425224ce475 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff @@ -59,32 +59,32 @@ debug arg0 => _36; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug arg1 => _37; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _39; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _40; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _46: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _47: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _49: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _39; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _40; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _46: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _47: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _49: &&i32; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL scope 7 { } } scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _42; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _43; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _50: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _51: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _53: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _42; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _43; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _50: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _51: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _53: &&i32; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL scope 9 { } } } scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug pieces => _23; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug args => _27; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _54: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug pieces => _23; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + debug args => _27; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _54: &[&str]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL } } } @@ -217,32 +217,32 @@ // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _47 = _40; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _46 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_46); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_47); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _47 = _40; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _46 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb5: { - StorageDead(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _49 = _39; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_47); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_48); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_49); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _49 = _39; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb6: { - StorageDead(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_49); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + (_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + (_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_48); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_46); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_40); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_39); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_41); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL @@ -253,32 +253,32 @@ // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _51 = _43; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _50 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_50); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_51); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _51 = _43; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _50 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb7: { - StorageDead(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _53 = _42; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_51); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_52); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_53); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _53 = _42; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb8: { - StorageDead(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_53); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + (_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + (_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_52); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_50); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_43); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_42); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL _30 = [move _38, move _41]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL @@ -290,18 +290,18 @@ _28 = _29; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _27 = move _28 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_28); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_54); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _54 = _23; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_55); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - discriminant(_55) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_56); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _56 = _27; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.0: &[&str]) = move _54; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _55; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.2: &[std::fmt::ArgumentV1]) = move _56; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_56); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_55); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_54); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_54); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + _54 = _23; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_55); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + discriminant(_55) = 0; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_56); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + _56 = _27; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_22.0: &[&str]) = move _54; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _55; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_22.2: &[std::fmt::ArgumentV1]) = move _56; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_56); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_55); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_54); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_27); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_23); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _21 = &_22; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff index b9cb58e14c45d..a9425224ce475 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff @@ -59,32 +59,32 @@ debug arg0 => _36; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug arg1 => _37; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _39; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _40; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _46: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _47: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _49: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _39; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _40; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _46: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _47: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _49: &&i32; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL scope 7 { } } scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _42; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _43; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _50: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _51: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _53: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _42; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _43; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _50: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _51: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _53: &&i32; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL scope 9 { } } } scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug pieces => _23; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug args => _27; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _54: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug pieces => _23; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + debug args => _27; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _54: &[&str]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL } } } @@ -217,32 +217,32 @@ // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _47 = _40; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _46 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_46); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_47); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _47 = _40; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _46 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb5: { - StorageDead(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _49 = _39; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_47); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_48); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_49); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _49 = _39; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb6: { - StorageDead(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_49); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + (_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + (_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_48); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_46); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_40); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_39); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_41); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL @@ -253,32 +253,32 @@ // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _51 = _43; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _50 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_50); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_51); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _51 = _43; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _50 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb7: { - StorageDead(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _53 = _42; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_51); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_52); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_53); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _53 = _42; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb8: { - StorageDead(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_53); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + (_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + (_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_52); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_50); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_43); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_42); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL _30 = [move _38, move _41]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL @@ -290,18 +290,18 @@ _28 = _29; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _27 = move _28 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_28); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_54); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _54 = _23; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_55); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - discriminant(_55) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_56); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _56 = _27; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.0: &[&str]) = move _54; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _55; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.2: &[std::fmt::ArgumentV1]) = move _56; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_56); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_55); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_54); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_54); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + _54 = _23; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_55); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + discriminant(_55) = 0; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_56); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + _56 = _27; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_22.0: &[&str]) = move _54; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _55; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_22.2: &[std::fmt::ArgumentV1]) = move _56; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_56); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_55); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_54); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_27); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_23); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _21 = &_22; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL diff --git a/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff index d84012295e4d3..e55ee287ba34f 100644 --- a/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff @@ -7,15 +7,15 @@ let _2: (); // in scope 0 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 let mut _3: T; // in scope 0 at $DIR/remove_unneeded_drops.rs:21:10: 21:11 scope 1 (inlined std::mem::drop::) { // at $DIR/remove_unneeded_drops.rs:21:5: 21:12 - debug _x => _3; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _3; // in scope 1 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 } bb0: { StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:21:10: 21:11 _3 = move _1; // scope 0 at $DIR/remove_unneeded_drops.rs:21:10: 21:11 - _2 = const (); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _2 = const (); // scope 1 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 + drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 } bb1 (cleanup): { diff --git a/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff index b0b1e80e864c4..e5ad8f1ac75a9 100644 --- a/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff @@ -7,15 +7,15 @@ let _2: (); // in scope 0 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 let mut _3: std::vec::Vec; // in scope 0 at $DIR/remove_unneeded_drops.rs:9:10: 9:11 scope 1 (inlined std::mem::drop::>) { // at $DIR/remove_unneeded_drops.rs:9:5: 9:12 - debug _x => _3; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _3; // in scope 1 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 } bb0: { StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:9:10: 9:11 _3 = move _1; // scope 0 at $DIR/remove_unneeded_drops.rs:9:10: 9:11 - _2 = const (); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _2 = const (); // scope 1 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 + drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 } bb1 (cleanup): { diff --git a/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff index 0984829435b66..bddf0e2103920 100644 --- a/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff @@ -7,15 +7,15 @@ let _2: (); // in scope 0 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 let mut _3: bool; // in scope 0 at $DIR/remove_unneeded_drops.rs:4:10: 4:11 scope 1 (inlined std::mem::drop::) { // at $DIR/remove_unneeded_drops.rs:4:5: 4:12 - debug _x => _3; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _3; // in scope 1 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 } bb0: { StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:4:10: 4:11 _3 = _1; // scope 0 at $DIR/remove_unneeded_drops.rs:4:10: 4:11 - _2 = const (); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL -- drop(_3) -> bb1; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _2 = const (); // scope 1 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 +- drop(_3) -> bb1; // scope 1 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 - } - - bb1: { diff --git a/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff index 0b0ce968af076..87fb8a295c6b0 100644 --- a/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff @@ -7,15 +7,15 @@ let _2: (); // in scope 0 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 let mut _3: T; // in scope 0 at $DIR/remove_unneeded_drops.rs:14:10: 14:11 scope 1 (inlined std::mem::drop::) { // at $DIR/remove_unneeded_drops.rs:14:5: 14:12 - debug _x => _3; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _3; // in scope 1 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 } bb0: { StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:14:10: 14:11 _3 = _1; // scope 0 at $DIR/remove_unneeded_drops.rs:14:10: 14:11 - _2 = const (); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL -- drop(_3) -> bb1; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _2 = const (); // scope 1 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 +- drop(_3) -> bb1; // scope 1 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 - } - - bb1: { diff --git a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff index 9a9395c3c8891..84d8214122ae1 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff @@ -23,13 +23,13 @@ + debug err => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify-arm.rs:24:14: 24:15 scope 3 { scope 7 (inlined >::from) { // at $DIR/simplify-arm.rs:24:14: 24:15 -- debug t => _9; // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL +- debug t => _9; // in scope 7 at $DIR/simplify-arm.rs:24:14: 24:15 ++ debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify-arm.rs:24:14: 24:15 } scope 8 (inlined as Try>::from_error) { // at $DIR/simplify-arm.rs:24:13: 24:15 -- debug v => _8; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -+ debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL +- debug v => _8; // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 ++ debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 + let mut _12: i32; // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 } } } @@ -40,7 +40,7 @@ } } scope 6 (inlined as Try>::into_result) { // at $DIR/simplify-arm.rs:24:13: 24:15 - debug self => _4; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _4; // in scope 6 at $DIR/simplify-arm.rs:24:13: 24:15 } bb0: { @@ -48,7 +48,7 @@ StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15 StorageLive(_4); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:14 _4 = _1; // scope 0 at $DIR/simplify-arm.rs:24:13: 24:14 - _3 = move _4; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + _3 = move _4; // scope 6 at $DIR/simplify-arm.rs:24:13: 24:15 StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 @@ -80,16 +80,16 @@ - StorageLive(_8); // scope 3 at $DIR/simplify-arm.rs:24:14: 24:15 - StorageLive(_9); // scope 3 at $DIR/simplify-arm.rs:24:14: 24:15 - _9 = _6; // scope 3 at $DIR/simplify-arm.rs:24:14: 24:15 -- _8 = move _9; // scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL +- _8 = move _9; // scope 7 at $DIR/simplify-arm.rs:24:14: 24:15 - StorageDead(_9); // scope 3 at $DIR/simplify-arm.rs:24:14: 24:15 -- StorageLive(_12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- _12 = move _8; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- ((_0 as Err).0: i32) = move _12; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- discriminant(_0) = 1; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- StorageDead(_12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL +- StorageLive(_12); // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 +- _12 = move _8; // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 +- ((_0 as Err).0: i32) = move _12; // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 +- discriminant(_0) = 1; // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 +- StorageDead(_12); // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 - StorageDead(_8); // scope 3 at $DIR/simplify-arm.rs:24:14: 24:15 - StorageDead(_6); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 -+ _0 = move _3; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ _0 = move _3; // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:24:15: 24:16 StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2 goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2 diff --git a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff index ed96a22f8e3d0..aa050655cdaa5 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff @@ -21,11 +21,11 @@ debug err => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify-arm.rs:24:14: 24:15 scope 3 { scope 7 (inlined >::from) { // at $DIR/simplify-arm.rs:24:14: 24:15 - debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify-arm.rs:24:14: 24:15 } scope 8 (inlined as Try>::from_error) { // at $DIR/simplify-arm.rs:24:13: 24:15 - debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 + let mut _12: i32; // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 } } } @@ -35,7 +35,7 @@ } } scope 6 (inlined as Try>::into_result) { // at $DIR/simplify-arm.rs:24:13: 24:15 - debug self => _4; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _4; // in scope 6 at $DIR/simplify-arm.rs:24:13: 24:15 } bb0: { @@ -43,7 +43,7 @@ StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15 StorageLive(_4); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:14 _4 = _1; // scope 0 at $DIR/simplify-arm.rs:24:13: 24:14 - _3 = move _4; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + _3 = move _4; // scope 6 at $DIR/simplify-arm.rs:24:13: 24:15 StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 - switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 @@ -63,7 +63,7 @@ - } - - bb3: { -- _0 = move _3; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL +- _0 = move _3; // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:24:15: 24:16 - StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:26:2: 26: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 index 38da3a8a9e8d3..3ba0af991f63b 100644 --- a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff +++ b/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff @@ -21,11 +21,11 @@ debug err => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:8:14: 8:15 scope 3 { scope 7 (inlined >::from) { // at $DIR/simplify_try.rs:8:14: 8:15 - debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 } scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 + let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } } } @@ -35,8 +35,8 @@ } } scope 6 (inlined as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 -- debug self => _4; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL -+ debug self => _0; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL +- debug self => _4; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 ++ debug self => _0; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 } bb0: { @@ -44,13 +44,13 @@ - StorageLive(_3); // scope 0 at $DIR/simplify_try.rs:8:13: 8:15 - StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:8:13: 8:14 - _4 = _1; // scope 0 at $DIR/simplify_try.rs:8:13: 8:14 -- _3 = move _4; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL +- _3 = move _4; // scope 6 at $DIR/simplify_try.rs:8:13: 8:15 - StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 - _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 + nop; // scope 0 at $DIR/simplify_try.rs:8:13: 8:15 + nop; // scope 0 at $DIR/simplify_try.rs:8:13: 8:14 + _0 = _1; // scope 0 at $DIR/simplify_try.rs:8:13: 8:14 -+ nop; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ nop; // scope 6 at $DIR/simplify_try.rs:8:13: 8:15 + nop; // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 + _5 = discriminant(_0); // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 goto -> bb1; // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff index 29b338b339b26..9c91762eb4e15 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff @@ -23,13 +23,13 @@ + debug err => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:8:14: 8:15 scope 3 { scope 7 (inlined >::from) { // at $DIR/simplify_try.rs:8:14: 8:15 -- debug t => _9; // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL +- debug t => _9; // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 ++ debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 } scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 -- debug v => _8; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -+ debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL +- debug v => _8; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 ++ debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 + let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } } } @@ -40,7 +40,7 @@ } } scope 6 (inlined as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug self => _4; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _4; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 } bb0: { @@ -48,7 +48,7 @@ StorageLive(_3); // scope 0 at $DIR/simplify_try.rs:8:13: 8:15 StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:8:13: 8:14 _4 = _1; // scope 0 at $DIR/simplify_try.rs:8:13: 8:14 - _3 = move _4; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + _3 = move _4; // scope 6 at $DIR/simplify_try.rs:8:13: 8:15 StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 @@ -76,16 +76,16 @@ - StorageLive(_8); // scope 3 at $DIR/simplify_try.rs:8:14: 8:15 - StorageLive(_9); // scope 3 at $DIR/simplify_try.rs:8:14: 8:15 - _9 = _6; // scope 3 at $DIR/simplify_try.rs:8:14: 8:15 -- _8 = move _9; // scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL +- _8 = move _9; // scope 7 at $DIR/simplify_try.rs:8:14: 8:15 - StorageDead(_9); // scope 3 at $DIR/simplify_try.rs:8:14: 8:15 -- StorageLive(_12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- _12 = move _8; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- ((_0 as Err).0: i32) = move _12; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- discriminant(_0) = 1; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- StorageDead(_12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL +- StorageLive(_12); // scope 8 at $DIR/simplify_try.rs:8:13: 8:15 +- _12 = move _8; // scope 8 at $DIR/simplify_try.rs:8:13: 8:15 +- ((_0 as Err).0: i32) = move _12; // scope 8 at $DIR/simplify_try.rs:8:13: 8:15 +- discriminant(_0) = 1; // scope 8 at $DIR/simplify_try.rs:8:13: 8:15 +- StorageDead(_12); // scope 8 at $DIR/simplify_try.rs:8:13: 8:15 - StorageDead(_8); // scope 3 at $DIR/simplify_try.rs:8:14: 8:15 - StorageDead(_6); // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 -+ _0 = move _3; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ _0 = move _3; // scope 8 at $DIR/simplify_try.rs:8:13: 8:15 StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:8:15: 8:16 StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:10:1: 10:2 return; // scope 0 at $DIR/simplify_try.rs:10:2: 10: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 index e3527b99576fd..cd8436a971ee8 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir @@ -20,11 +20,11 @@ fn try_identity(_1: std::result::Result) -> std::result::Result ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:8:14: 8:15 scope 3 { scope 7 (inlined >::from) { // at $DIR/simplify_try.rs:8:14: 8:15 - debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 } scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 + let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } } } @@ -34,7 +34,7 @@ fn try_identity(_1: std::result::Result) -> std::result::Result as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug self => _4; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _4; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 } bb0: { @@ -42,7 +42,7 @@ fn try_identity(_1: std::result::Result) -> std::result::Result bb1; // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 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 index 51029c3021a8b..73f77f35a2b92 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir @@ -10,10 +10,10 @@ fn try_identity(_1: std::result::Result) -> std::result::Result ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:8:14: 8:15 scope 3 { scope 7 (inlined >::from) { // at $DIR/simplify_try.rs:8:14: 8:15 - debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 } scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } } } @@ -23,7 +23,7 @@ fn try_identity(_1: std::result::Result) -> std::result::Result as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug self => _0; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _0; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 } bb0: { diff --git a/src/test/ui/const_prop/inline_spans.rs b/src/test/ui/const_prop/inline_spans.rs new file mode 100644 index 0000000000000..32902b49d0284 --- /dev/null +++ b/src/test/ui/const_prop/inline_spans.rs @@ -0,0 +1,14 @@ +// build-fail +// compile-flags: -Zmir-opt-level=2 + +#![deny(warnings)] + +fn main() { + let _ = add(u8::MAX, 1); + //~^ ERROR this arithmetic operation will overflow +} + +#[inline(always)] +fn add(x: u8, y: u8) -> u8 { + x + y +} diff --git a/src/test/ui/const_prop/inline_spans.stderr b/src/test/ui/const_prop/inline_spans.stderr new file mode 100644 index 0000000000000..5a54967e0d055 --- /dev/null +++ b/src/test/ui/const_prop/inline_spans.stderr @@ -0,0 +1,13 @@ +error: this arithmetic operation will overflow + --> $DIR/inline_spans.rs:7:13 + | +LL | let _ = add(u8::MAX, 1); + | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow +... +LL | x + y + | ----- in the inlined copy of this code + | + = note: `#[deny(arithmetic_overflow)]` on by default + +error: aborting due to previous error + diff --git a/src/test/ui/deprecation/deprecation-sanity.rs b/src/test/ui/deprecation/deprecation-sanity.rs index a559908b792bb..4fc3fddadb99e 100644 --- a/src/test/ui/deprecation/deprecation-sanity.rs +++ b/src/test/ui/deprecation/deprecation-sanity.rs @@ -24,10 +24,19 @@ mod bogus_attribute_types_1 { } #[deprecated(since = "a", note = "b")] -#[deprecated(since = "a", note = "b")] -fn multiple1() { } //~ ERROR multiple deprecated attributes +#[deprecated(since = "a", note = "b")] //~ ERROR multiple deprecated attributes +fn multiple1() { } #[deprecated(since = "a", since = "b", note = "c")] //~ ERROR multiple 'since' items fn f1() { } +struct X; + +#[deprecated = "hello"] //~ ERROR this `#[deprecated]` annotation has no effect +impl Default for X { + fn default() -> Self { + X + } +} + fn main() { } diff --git a/src/test/ui/deprecation/deprecation-sanity.stderr b/src/test/ui/deprecation/deprecation-sanity.stderr index 57143d6810554..7e70c35eeabdf 100644 --- a/src/test/ui/deprecation/deprecation-sanity.stderr +++ b/src/test/ui/deprecation/deprecation-sanity.stderr @@ -41,10 +41,12 @@ LL | #[deprecated("test")] | ^^^^^^ error[E0550]: multiple deprecated attributes - --> $DIR/deprecation-sanity.rs:28:1 + --> $DIR/deprecation-sanity.rs:27:1 | -LL | fn multiple1() { } - | ^^^^^^^^^^^^^^^^^^ +LL | #[deprecated(since = "a", note = "b")] + | -------------------------------------- first deprecation attribute +LL | #[deprecated(since = "a", note = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute error[E0538]: multiple 'since' items --> $DIR/deprecation-sanity.rs:30:27 @@ -52,7 +54,15 @@ error[E0538]: multiple 'since' items LL | #[deprecated(since = "a", since = "b", note = "c")] | ^^^^^^^^^^^ -error: aborting due to 9 previous errors +error: this `#[deprecated]` annotation has no effect + --> $DIR/deprecation-sanity.rs:35:1 + | +LL | #[deprecated = "hello"] + | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute + | + = note: `#[deny(useless_deprecated)]` on by default + +error: aborting due to 10 previous errors Some errors have detailed explanations: E0538, E0541, E0550, E0551, E0565. For more information about an error, try `rustc --explain E0538`. diff --git a/src/test/ui/lint/function-item-references.rs b/src/test/ui/lint/function-item-references.rs index 439b56967d072..5f7f5e66eaa9f 100644 --- a/src/test/ui/lint/function-item-references.rs +++ b/src/test/ui/lint/function-item-references.rs @@ -1,5 +1,5 @@ // check-pass -#![feature(c_variadic)] +#![feature(c_variadic, min_const_generics)] #![warn(function_item_references)] use std::fmt::Pointer; use std::fmt::Formatter; @@ -12,6 +12,10 @@ unsafe fn unsafe_fn() { } extern "C" fn c_fn() { } unsafe extern "C" fn unsafe_c_fn() { } unsafe extern fn variadic(_x: u32, _args: ...) { } +fn take_generic_ref<'a, T>(_x: &'a T) { } +fn take_generic_array(_x: [T; N]) { } +fn multiple_generic(_x: T, _y: U) { } +fn multiple_generic_arrays(_x: [T; N], _y: [U; M]) { } //function references passed to these functions should never lint fn call_fn(f: &dyn Fn(u32) -> u32, x: u32) { f(x); } @@ -109,6 +113,14 @@ fn main() { //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &variadic); //~^ WARNING taking a reference to a function item does not give a function pointer + println!("{:p}", &take_generic_ref::); + //~^ WARNING taking a reference to a function item does not give a function pointer + println!("{:p}", &take_generic_array::); + //~^ WARNING taking a reference to a function item does not give a function pointer + println!("{:p}", &multiple_generic::); + //~^ WARNING taking a reference to a function item does not give a function pointer + println!("{:p}", &multiple_generic_arrays::); + //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &std::env::var::); //~^ WARNING taking a reference to a function item does not give a function pointer @@ -132,6 +144,8 @@ fn main() { std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); //~^ WARNING taking a reference to a function item does not give a function pointer //~^^ WARNING taking a reference to a function item does not give a function pointer + std::mem::transmute::<_, usize>(&take_generic_ref::); + //~^ WARNING taking a reference to a function item does not give a function pointer //the correct way to transmute function pointers std::mem::transmute::<_, usize>(foo as fn() -> u32); diff --git a/src/test/ui/lint/function-item-references.stderr b/src/test/ui/lint/function-item-references.stderr index 610dff04e6edf..33db687df31d2 100644 --- a/src/test/ui/lint/function-item-references.stderr +++ b/src/test/ui/lint/function-item-references.stderr @@ -1,5 +1,5 @@ warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:40:18 + --> $DIR/function-item-references.rs:44:18 | LL | Pointer::fmt(&zst_ref, f) | ^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` @@ -11,166 +11,196 @@ LL | #![warn(function_item_references)] | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:77:22 + --> $DIR/function-item-references.rs:81:22 | LL | println!("{:p}", &foo); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:79:20 + --> $DIR/function-item-references.rs:83:20 | LL | print!("{:p}", &foo); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:81:21 + --> $DIR/function-item-references.rs:85:21 | LL | format!("{:p}", &foo); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:84:22 + --> $DIR/function-item-references.rs:88:22 | LL | println!("{:p}", &foo as *const _); | ^^^^^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:86:22 + --> $DIR/function-item-references.rs:90:22 | LL | println!("{:p}", zst_ref); | ^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:88:22 + --> $DIR/function-item-references.rs:92:22 | LL | println!("{:p}", cast_zst_ptr); | ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:90:22 + --> $DIR/function-item-references.rs:94:22 | LL | println!("{:p}", coerced_zst_ptr); | ^^^^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:93:22 + --> $DIR/function-item-references.rs:97:22 | LL | println!("{:p}", &fn_item); | ^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:95:22 + --> $DIR/function-item-references.rs:99:22 | LL | println!("{:p}", indirect_ref); | ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:98:22 + --> $DIR/function-item-references.rs:102:22 | LL | println!("{:p}", &nop); | ^^^^ help: cast `nop` to obtain a function pointer: `nop as fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:100:22 + --> $DIR/function-item-references.rs:104:22 | LL | println!("{:p}", &bar); | ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:102:22 + --> $DIR/function-item-references.rs:106:22 | LL | println!("{:p}", &baz); | ^^^^ help: cast `baz` to obtain a function pointer: `baz as fn(_, _) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:104:22 + --> $DIR/function-item-references.rs:108:22 | LL | println!("{:p}", &unsafe_fn); | ^^^^^^^^^^ help: cast `unsafe_fn` to obtain a function pointer: `unsafe_fn as unsafe fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:106:22 + --> $DIR/function-item-references.rs:110:22 | LL | println!("{:p}", &c_fn); | ^^^^^ help: cast `c_fn` to obtain a function pointer: `c_fn as extern "C" fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:108:22 + --> $DIR/function-item-references.rs:112:22 | LL | println!("{:p}", &unsafe_c_fn); | ^^^^^^^^^^^^ help: cast `unsafe_c_fn` to obtain a function pointer: `unsafe_c_fn as unsafe extern "C" fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:110:22 + --> $DIR/function-item-references.rs:114:22 | LL | println!("{:p}", &variadic); | ^^^^^^^^^ help: cast `variadic` to obtain a function pointer: `variadic as unsafe extern "C" fn(_, ...)` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:112:22 + --> $DIR/function-item-references.rs:116:22 + | +LL | println!("{:p}", &take_generic_ref::); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `take_generic_ref` to obtain a function pointer: `take_generic_ref:: as fn(_)` + +warning: taking a reference to a function item does not give a function pointer + --> $DIR/function-item-references.rs:118:22 + | +LL | println!("{:p}", &take_generic_array::); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `take_generic_array` to obtain a function pointer: `take_generic_array:: as fn(_)` + +warning: taking a reference to a function item does not give a function pointer + --> $DIR/function-item-references.rs:120:22 + | +LL | println!("{:p}", &multiple_generic::); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `multiple_generic` to obtain a function pointer: `multiple_generic:: as fn(_, _)` + +warning: taking a reference to a function item does not give a function pointer + --> $DIR/function-item-references.rs:122:22 + | +LL | println!("{:p}", &multiple_generic_arrays::); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `multiple_generic_arrays` to obtain a function pointer: `multiple_generic_arrays:: as fn(_, _)` + +warning: taking a reference to a function item does not give a function pointer + --> $DIR/function-item-references.rs:124:22 | LL | println!("{:p}", &std::env::var::); - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `var` to obtain a function pointer: `var as fn(_) -> _` + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `var` to obtain a function pointer: `var:: as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:115:32 + --> $DIR/function-item-references.rs:127:32 | LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); | ^^^^ help: cast `nop` to obtain a function pointer: `nop as fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:115:38 + --> $DIR/function-item-references.rs:127:38 | LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:115:44 + --> $DIR/function-item-references.rs:127:44 | LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); | ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:130:41 + --> $DIR/function-item-references.rs:142:41 | LL | std::mem::transmute::<_, usize>(&foo); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:132:50 + --> $DIR/function-item-references.rs:144:50 | LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); | ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:132:50 + --> $DIR/function-item-references.rs:144:50 | LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); | ^^^^^^^^^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:142:15 + --> $DIR/function-item-references.rs:147:41 + | +LL | std::mem::transmute::<_, usize>(&take_generic_ref::); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `take_generic_ref` to obtain a function pointer: `take_generic_ref:: as fn(_)` + +warning: taking a reference to a function item does not give a function pointer + --> $DIR/function-item-references.rs:156:15 | LL | print_ptr(&bar); | ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:144:24 + --> $DIR/function-item-references.rs:158:24 | LL | bound_by_ptr_trait(&bar); | ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:146:30 + --> $DIR/function-item-references.rs:160:30 | LL | bound_by_ptr_trait_tuple((&foo, &bar)); | ^^^^^^^^^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:146:30 + --> $DIR/function-item-references.rs:160:30 | LL | bound_by_ptr_trait_tuple((&foo, &bar)); | ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` -warning: 28 warnings emitted +warning: 33 warnings emitted diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-copy.rs b/src/test/ui/pattern/bindings-after-at/bind-by-copy.rs new file mode 100644 index 0000000000000..508e486afec72 --- /dev/null +++ b/src/test/ui/pattern/bindings-after-at/bind-by-copy.rs @@ -0,0 +1,49 @@ +// run-pass + +// Test copy + +#![feature(bindings_after_at)] + +struct A { a: i32, b: i32 } +struct B { a: i32, b: C } +struct D { a: i32, d: C } +#[derive(Copy,Clone)] +struct C { c: i32 } + +pub fn main() { + match (A {a: 10, b: 20}) { + x@A {a, b: 20} => { assert!(x.a == 10); assert!(a == 10); } + A {b: _b, ..} => { panic!(); } + } + + let mut x@B {b, ..} = B {a: 10, b: C {c: 20}}; + assert_eq!(x.a, 10); + x.b.c = 30; + assert_eq!(b.c, 20); + let mut y@D {d, ..} = D {a: 10, d: C {c: 20}}; + assert_eq!(y.a, 10); + y.d.c = 30; + assert_eq!(d.c, 20); + + let some_b = Some(B { a: 10, b: C { c: 20 } }); + + // in irrefutable pattern + if let Some(x @ B { b, .. }) = some_b { + assert_eq!(x.b.c, 20); + assert_eq!(b.c, 20); + } else { + unreachable!(); + } + + let some_b = Some(B { a: 10, b: C { c: 20 } }); + + if let Some(x @ B { b: mut b @ C { c }, .. }) = some_b { + assert_eq!(x.b.c, 20); + assert_eq!(b.c, 20); + b.c = 30; + assert_eq!(b.c, 30); + assert_eq!(c, 20); + } else { + unreachable!(); + } +} diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.rs b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.rs index ba9543bf73869..71503ecf2622b 100644 --- a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.rs +++ b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.rs @@ -12,6 +12,7 @@ fn main() { let x = Some(X { x: () }); match x { Some(ref _y @ _z) => {} //~ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value None => panic!(), } @@ -19,13 +20,13 @@ fn main() { match x { Some(_z @ ref _y) => {} //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value None => panic!(), } let mut x = Some(X { x: () }); match x { Some(ref mut _y @ _z) => {} //~ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value None => panic!(), } @@ -33,7 +34,6 @@ fn main() { match x { Some(_z @ ref mut _y) => {} //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value None => panic!(), } } diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr index 44dbcb9a75466..e50ae3e7eebd3 100644 --- a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr +++ b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr @@ -8,7 +8,7 @@ LL | Some(ref _y @ _z) => {} | value borrowed, by `_y`, here error: borrow of moved value - --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:20:14 + --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:21:14 | LL | Some(_z @ ref _y) => {} | --^^^------ @@ -27,7 +27,7 @@ LL | Some(ref mut _y @ _z) => {} | value borrowed, by `_y`, here error: borrow of moved value - --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:34:14 + --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:35:14 | LL | Some(_z @ ref mut _y) => {} | --^^^---------- @@ -37,34 +37,34 @@ LL | Some(_z @ ref mut _y) => {} | move occurs because `_z` has type `X` which does not implement the `Copy` trait error[E0382]: borrow of moved value - --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:20:19 + --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:14:14 | -LL | Some(_z @ ref _y) => {} - | -----^^^^^^ - | | | - | | value borrowed here after move - | value moved here +LL | Some(ref _y @ _z) => {} + | ^^^^^^^^^-- + | | | + | | value moved here + | value borrowed here after move | = note: move occurs because value has type `X`, which does not implement the `Copy` trait help: borrow this field in the pattern to avoid moving `x.0` | -LL | Some(ref _z @ ref _y) => {} - | ^^^ +LL | Some(ref _y @ ref _z) => {} + | ^^^ error[E0382]: borrow of moved value - --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:34:19 + --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:28:14 | -LL | Some(_z @ ref mut _y) => {} - | -----^^^^^^^^^^ - | | | - | | value borrowed here after move - | value moved here +LL | Some(ref mut _y @ _z) => {} + | ^^^^^^^^^^^^^-- + | | | + | | value moved here + | value borrowed here after move | = note: move occurs because value has type `X`, which does not implement the `Copy` trait help: borrow this field in the pattern to avoid moving `x.0` | -LL | Some(ref _z @ ref mut _y) => {} - | ^^^ +LL | Some(ref mut _y @ ref _z) => {} + | ^^^ error: aborting due to 6 previous errors diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.rs b/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.rs index 3ab6f40725cfb..08240db4472ed 100644 --- a/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.rs +++ b/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.rs @@ -7,7 +7,7 @@ fn main() {} struct A(Box); fn f(a @ A(u): A) -> Box { - //~^ ERROR use of moved value + //~^ ERROR use of partially moved value drop(a); u } diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.stderr b/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.stderr index f25d5a2d9b82d..a77b866d8373d 100644 --- a/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.stderr +++ b/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.stderr @@ -1,12 +1,13 @@ -error[E0382]: use of moved value - --> $DIR/bind-by-move-no-subbindings-fun-param.rs:9:12 +error[E0382]: use of partially moved value + --> $DIR/bind-by-move-no-subbindings-fun-param.rs:9:6 | LL | fn f(a @ A(u): A) -> Box { - | ------^- + | ^^^^^^-^ | | | - | | value used here after move - | value moved here - | move occurs because value has type `A`, which does not implement the `Copy` trait + | | value partially moved here + | value used here after partial move + | + = note: partial move occurs because value has type `Box`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs index d014c9828da2a..bce43f9df85c8 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs @@ -12,9 +12,9 @@ fn main() { let a @ b = U; //~ ERROR use of moved value - let a @ (b, c) = (U, U); //~ ERROR use of moved value + let a @ (b, c) = (U, U); //~ ERROR use of partially moved value - let a @ (b, c) = (u(), u()); //~ ERROR use of moved value + let a @ (b, c) = (u(), u()); //~ ERROR use of partially moved value match Ok(U) { a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of moved value @@ -24,10 +24,10 @@ fn main() { fn fun(a @ b: U) {} //~ ERROR use of moved value match [u(), u(), u(), u()] { - xs @ [a, .., b] => {} //~ ERROR use of moved value + xs @ [a, .., b] => {} //~ ERROR use of partially moved value } match [u(), u(), u(), u()] { - xs @ [_, ys @ .., _] => {} //~ ERROR use of moved value + xs @ [_, ys @ .., _] => {} //~ ERROR use of partially moved value } } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr index 5039f580ff6ea..bfb7b479731a6 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr @@ -1,29 +1,33 @@ error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:13:13 + --> $DIR/borrowck-move-and-move.rs:13:9 | LL | let a @ b = U; - | ----^ - move occurs because value has type `U`, which does not implement the `Copy` trait + | ^^^^- - move occurs because value has type `U`, which does not implement the `Copy` trait | | | - | | value used here after move - | value moved here + | | value moved here + | value used here after move -error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:15:17 +error[E0382]: use of partially moved value + --> $DIR/borrowck-move-and-move.rs:15:9 | LL | let a @ (b, c) = (U, U); - | --------^- ------ move occurs because value has type `(U, U)`, which does not implement the `Copy` trait + | ^^^^^^^^-^ | | | - | | value used here after move - | value moved here + | | value partially moved here + | value used here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:17:17 +error[E0382]: use of partially moved value + --> $DIR/borrowck-move-and-move.rs:17:9 | LL | let a @ (b, c) = (u(), u()); - | --------^- ---------- move occurs because value has type `(U, U)`, which does not implement the `Copy` trait + | ^^^^^^^^-^ | | | - | | value used here after move - | value moved here + | | value partially moved here + | value used here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait error[E0382]: use of moved value --> $DIR/borrowck-move-and-move.rs:20:16 @@ -47,36 +51,36 @@ LL | a @ Ok(b) | a @ Err(b) => {} | | value used here after move | value moved here -error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:27:22 +error[E0382]: use of partially moved value + --> $DIR/borrowck-move-and-move.rs:27:9 | -LL | match [u(), u(), u(), u()] { - | -------------------- move occurs because value has type `[U; 4]`, which does not implement the `Copy` trait LL | xs @ [a, .., b] => {} - | -------------^- + | ^^^^^^^^^^^^^-^ | | | - | | value used here after move - | value moved here + | | value partially moved here + | value used here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:31:18 +error[E0382]: use of partially moved value + --> $DIR/borrowck-move-and-move.rs:31:9 | -LL | match [u(), u(), u(), u()] { - | -------------------- move occurs because value has type `[U; 4]`, which does not implement the `Copy` trait LL | xs @ [_, ys @ .., _] => {} - | ---------^^^^^^^---- + | ^^^^^^^^^-------^^^^ | | | - | | value used here after move - | value moved here + | | value partially moved here + | value used here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:24:16 + --> $DIR/borrowck-move-and-move.rs:24:12 | LL | fn fun(a @ b: U) {} - | ----^ + | ^^^^- | | | - | | value used here after move - | value moved here + | | value moved here + | value used here after move | move occurs because value has type `U`, which does not implement the `Copy` trait error: aborting due to 8 previous errors diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.rs index 236710ed85493..07fac1d363133 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.rs @@ -18,22 +18,19 @@ fn nc() -> NC { fn main() { let a @ box &b = Box::new(&C); - //~^ ERROR use of moved value let a @ box b = Box::new(C); - //~^ ERROR use of moved value fn f1(a @ box &b: Box<&C>) {} - //~^ ERROR use of moved value fn f2(a @ box b: Box) {} - //~^ ERROR use of moved value match Box::new(C) { - a @ box b => {} //~ ERROR use of moved value + a @ box b => {} } let ref a @ box b = Box::new(NC); //~ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value let ref a @ box ref mut b = Box::new(nc()); //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable @@ -41,22 +38,23 @@ fn main() { //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable let ref a @ box ref mut b = Box::new(NC); //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = NC; let ref a @ box ref mut b = Box::new(NC); //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable - //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = NC; drop(a); let ref mut a @ box ref b = Box::new(NC); //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable *a = Box::new(NC); drop(b); fn f5(ref mut a @ box ref b: Box) { //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable *a = Box::new(NC); drop(b); } @@ -64,7 +62,7 @@ fn main() { match Box::new(nc()) { ref mut a @ box ref b => { //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable *a = Box::new(NC); drop(b); } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr index d9a8bbfb6b103..83da16a72a7ba 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr @@ -1,5 +1,5 @@ error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-at-and-box.rs:36:9 + --> $DIR/borrowck-pat-at-and-box.rs:32:9 | LL | let ref a @ box b = Box::new(NC); | -----^^^^^^^- @@ -8,7 +8,7 @@ LL | let ref a @ box b = Box::new(NC); | value borrowed, by `a`, here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-at-and-box.rs:38:9 + --> $DIR/borrowck-pat-at-and-box.rs:35:9 | LL | let ref a @ box ref mut b = Box::new(nc()); | -----^^^^^^^--------- @@ -17,7 +17,7 @@ LL | let ref a @ box ref mut b = Box::new(nc()); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-at-and-box.rs:40:9 + --> $DIR/borrowck-pat-at-and-box.rs:37:9 | LL | let ref a @ box ref mut b = Box::new(NC); | -----^^^^^^^--------- @@ -26,7 +26,7 @@ LL | let ref a @ box ref mut b = Box::new(NC); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-at-and-box.rs:42:9 + --> $DIR/borrowck-pat-at-and-box.rs:39:9 | LL | let ref a @ box ref mut b = Box::new(NC); | -----^^^^^^^--------- @@ -35,7 +35,7 @@ LL | let ref a @ box ref mut b = Box::new(NC); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-at-and-box.rs:45:9 + --> $DIR/borrowck-pat-at-and-box.rs:43:9 | LL | let ref a @ box ref mut b = Box::new(NC); | -----^^^^^^^--------- @@ -44,7 +44,7 @@ LL | let ref a @ box ref mut b = Box::new(NC); | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:51:9 + --> $DIR/borrowck-pat-at-and-box.rs:49:9 | LL | let ref mut a @ box ref b = Box::new(NC); | ---------^^^^^^^----- @@ -53,7 +53,7 @@ LL | let ref mut a @ box ref b = Box::new(NC); | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:65:9 + --> $DIR/borrowck-pat-at-and-box.rs:63:9 | LL | ref mut a @ box ref b => { | ---------^^^^^^^----- @@ -62,7 +62,7 @@ LL | ref mut a @ box ref b => { | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:57:11 + --> $DIR/borrowck-pat-at-and-box.rs:55:11 | LL | fn f5(ref mut a @ box ref b: Box) { | ---------^^^^^^^----- @@ -70,104 +70,78 @@ LL | fn f5(ref mut a @ box ref b: Box) { | | immutable borrow, by `b`, occurs here | mutable borrow, by `a`, occurs here -error[E0382]: use of moved value - --> $DIR/borrowck-pat-at-and-box.rs:20:18 +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-at-and-box.rs:32:9 | -LL | let a @ box &b = Box::new(&C); - | ---------^ ------------ move occurs because value has type `Box<&C>`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here - -error[E0382]: use of moved value - --> $DIR/borrowck-pat-at-and-box.rs:23:17 +LL | let ref a @ box b = Box::new(NC); + | ^^^^^^^^^^^^- + | | | + | | value moved here + | value borrowed here after move | -LL | let a @ box b = Box::new(C); - | --------^ ----------- move occurs because value has type `Box`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here + = note: move occurs because value has type `NC`, which does not implement the `Copy` trait -error[E0382]: use of moved value - --> $DIR/borrowck-pat-at-and-box.rs:33:17 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-at-and-box.rs:39:9 | -LL | match Box::new(C) { - | ----------- move occurs because value has type `Box`, which does not implement the `Copy` trait -LL | a @ box b => {} - | --------^ - | | | - | | value used here after move - | value moved here +LL | let ref a @ box ref mut b = Box::new(NC); + | ^^^^^^^^^^^^--------- + | | | + | | mutable borrow occurs here + | immutable borrow occurs here +... +LL | *b = NC; + | ------- mutable borrow later used here -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-at-and-box.rs:45:21 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-at-and-box.rs:43:9 | LL | let ref a @ box ref mut b = Box::new(NC); - | ------------^^^^^^^^^ + | ^^^^^^^^^^^^--------- | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | drop(a); - | - immutable borrow later used here +LL | *b = NC; + | ------- mutable borrow later used here -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:51:25 +error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-at-and-box.rs:49:9 | LL | let ref mut a @ box ref b = Box::new(NC); - | ----------------^^^^^ + | ^^^^^^^^^^^^^^^^----- | | | | | immutable borrow occurs here | mutable borrow occurs here ... -LL | *a = Box::new(NC); - | -- mutable borrow later used here +LL | drop(b); + | - immutable borrow later used here -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:65:25 +error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-at-and-box.rs:63:9 | LL | ref mut a @ box ref b => { - | ----------------^^^^^ + | ^^^^^^^^^^^^^^^^----- | | | | | immutable borrow occurs here | mutable borrow occurs here ... -LL | *a = Box::new(NC); - | -- mutable borrow later used here +LL | drop(b); + | - immutable borrow later used here -error[E0382]: use of moved value - --> $DIR/borrowck-pat-at-and-box.rs:26:20 - | -LL | fn f1(a @ box &b: Box<&C>) {} - | ---------^ - | | | - | | value used here after move - | value moved here - | move occurs because value has type `Box<&C>`, which does not implement the `Copy` trait - -error[E0382]: use of moved value - --> $DIR/borrowck-pat-at-and-box.rs:29:19 - | -LL | fn f2(a @ box b: Box) {} - | --------^ - | | | - | | value used here after move - | value moved here - | move occurs because value has type `Box`, which does not implement the `Copy` trait - -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:57:27 +error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-at-and-box.rs:55:11 | LL | fn f5(ref mut a @ box ref b: Box) { - | ----------------^^^^^ + | ^^^^^^^^^^^^^^^^----- | | | | | immutable borrow occurs here | mutable borrow occurs here ... -LL | *a = Box::new(NC); - | -- mutable borrow later used here +LL | drop(b); + | - immutable borrow later used here -error: aborting due to 17 previous errors +error: aborting due to 14 previous errors Some errors have detailed explanations: E0382, E0502. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs index 3e5a543c4c36a..8a574f880ed8d 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs @@ -12,18 +12,14 @@ fn main() { fn f1(a @ ref b: U) {} //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR use of moved value + //~| ERROR use of partially moved value fn f3(a @ [ref mut b, ref c]: [U; 2]) {} //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value let a @ ref b = U; //~^ ERROR borrow of moved value @@ -31,25 +27,18 @@ fn main() { //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR use of moved value + //~| ERROR use of partially moved value let a @ [ref mut b, ref c] = [U, U]; //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value let a @ ref b = u(); //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR use of moved value + //~| ERROR use of partially moved value let a @ [ref mut b, ref c] = [u(), u()]; //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value match Some(U) { a @ Some(ref b) => {} @@ -61,8 +50,6 @@ fn main() { //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR borrow of moved value //~| ERROR use of moved value None => {} } @@ -83,8 +70,6 @@ fn main() { //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR borrow of moved value //~| ERROR use of moved value None => {} } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr index 282031aeb0754..79addf9d574b6 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr @@ -1,5 +1,5 @@ error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:28:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9 | LL | let a @ ref b = U; | -^^^----- @@ -9,7 +9,7 @@ LL | let a @ ref b = U; | move occurs because `a` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:30:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:26:9 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | -^^^^^^^^^^^^---------^^^^^^-----^ @@ -20,7 +20,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:30:14 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:26:14 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | -----^^^--------- @@ -30,7 +30,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | move occurs because `b` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:30:33 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:26:33 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | -^^^----- @@ -40,7 +40,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | move occurs because `d` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:37:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:9 | LL | let a @ [ref mut b, ref c] = [U, U]; | -^^^^---------^^-----^ @@ -51,7 +51,7 @@ LL | let a @ [ref mut b, ref c] = [U, U]; | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:40:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9 | LL | let a @ ref b = u(); | -^^^----- @@ -61,7 +61,7 @@ LL | let a @ ref b = u(); | move occurs because `a` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:43:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:35:9 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | -^^^^^^^^^^^^---------^^^^^^-----^ @@ -72,7 +72,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:43:14 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:35:14 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | -----^^^--------- @@ -82,7 +82,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | move occurs because `b` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:43:33 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:35:33 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | -^^^----- @@ -92,7 +92,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | move occurs because `d` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:50:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:40:9 | LL | let a @ [ref mut b, ref c] = [u(), u()]; | -^^^^---------^^-----^ @@ -103,7 +103,7 @@ LL | let a @ [ref mut b, ref c] = [u(), u()]; | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:55:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:44:9 | LL | a @ Some(ref b) => {} | -^^^^^^^^-----^ @@ -113,7 +113,7 @@ LL | a @ Some(ref b) => {} | move occurs because `a` has type `Option` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:9 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -^^^^^^^^^^^^^^^^^---------^^^^^^-----^^ @@ -124,7 +124,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:19 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:19 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -----^^^--------- @@ -134,7 +134,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `b` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:38 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:38 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -^^^----- @@ -144,7 +144,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `d` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:70:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:57:9 | LL | mut a @ Some([ref b, ref mut c]) => {} | -----^^^^^^^^^-----^^---------^^ @@ -155,7 +155,7 @@ LL | mut a @ Some([ref b, ref mut c]) => {} | move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:76:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:63:9 | LL | a @ Some(ref b) => {} | -^^^^^^^^-----^ @@ -165,7 +165,7 @@ LL | a @ Some(ref b) => {} | move occurs because `a` has type `Option` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:82:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:9 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -^^^^^^^^^^^^^^^^^---------^^^^^^-----^^ @@ -176,7 +176,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:82:19 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:19 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -----^^^--------- @@ -186,7 +186,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `b` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:82:38 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:38 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -^^^----- @@ -196,7 +196,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `d` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:92:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:77:9 | LL | mut a @ Some([ref b, ref mut c]) => {} | -----^^^^^^^^^-----^^---------^^ @@ -217,7 +217,7 @@ LL | fn f1(a @ ref b: U) {} | move occurs because `a` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:17:11 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:16:11 | LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | -----^^^^^^^^-----^^^^^^^^^^-----^ @@ -228,7 +228,7 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:17:20 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:16:20 | LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | -^^^----- @@ -238,7 +238,7 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | move occurs because `b` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:17:31 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:16:31 | LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | -----^^^----- @@ -248,7 +248,7 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | move occurs because `d` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:11 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:21:11 | LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {} | -^^^^---------^^-----^ @@ -258,112 +258,30 @@ LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {} | value moved into `a` here | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:30:22 - | -LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); - | --------^^^^^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: use of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:30:33 +error[E0382]: use of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:26:9 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); - | ------------------------^^^^^^^^^- ------ move occurs because value has type `(U, U)`, which does not implement the `Copy` trait + | ^^^^^^^^^^^^^^^^^^^^^^^^---------^ | | | - | | value used here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:30:37 + | | value partially moved here + | value used here after partial move | -LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); - | ----^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:37:25 - | -LL | let a @ [ref mut b, ref c] = [U, U]; - | ----------------^^^^^- ------ move occurs because value has type `[U; 2]`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:40:13 - | -LL | let a @ ref b = u(); - | ----^^^^^ --- move occurs because value has type `U`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:43:22 +error[E0382]: use of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:35:9 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); - | --------^^^^^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: use of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:43:33 - | -LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); - | ------------------------^^^^^^^^^- ---------- move occurs because value has type `(U, U)`, which does not implement the `Copy` trait + | ^^^^^^^^^^^^^^^^^^^^^^^^---------^ | | | - | | value used here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:43:37 + | | value partially moved here + | value used here after partial move | -LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); - | ----^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:50:25 - | -LL | let a @ [ref mut b, ref c] = [u(), u()]; - | ----------------^^^^^- ---------- move occurs because value has type `[U; 2]`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:27 - | -LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | --------^^^^^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {} - | ^^^ + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait error[E0382]: use of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:38 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:38 | LL | match Some((U, U)) { | ------------ move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait @@ -374,22 +292,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | value moved here error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:42 - | -LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | ----^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} - | ^^^ - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:70:30 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:57:30 | LL | match Some([U, U]) { | ------------ move occurs because value has type `Option<[U; 2]>`, which does not implement the `Copy` trait @@ -400,7 +303,7 @@ LL | mut a @ Some([ref b, ref mut c]) => {} | value moved here error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:76:18 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:63:18 | LL | match Some(u()) { | --------- move occurs because value has type `Option`, which does not implement the `Copy` trait @@ -410,23 +313,8 @@ LL | a @ Some(ref b) => {} | | value borrowed here after move | value moved here -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:82:27 - | -LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | --------^^^^^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {} - | ^^^ - error[E0382]: use of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:82:38 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:38 | LL | match Some((u(), u())) { | ---------------- move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait @@ -437,22 +325,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | value moved here error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:82:42 - | -LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | ----^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} - | ^^^ - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:92:30 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:77:30 | LL | match Some([u(), u()]) { | ---------------- move occurs because value has type `Option<[U; 2]>`, which does not implement the `Copy` trait @@ -462,58 +335,17 @@ LL | mut a @ Some([ref b, ref mut c]) => {} | | value borrowed here after move | value moved here -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:13:15 - | -LL | fn f1(a @ ref b: U) {} - | ----^^^^^ - | | | - | | value borrowed here after move - | value moved here - | move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:17:24 - | -LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | ----^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: use of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:17:31 +error[E0382]: use of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:16:11 | LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | --------------------^^^^^^^^^^^^^- + | ^^^^^^^^^^^^^^^^^^^^-------------^ | | | - | | value used here after move - | value moved here - | move occurs because value has type `(U, U)`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:17:39 + | | value partially moved here + | value used here after partial move | -LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | --------^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:27 - | -LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {} - | ----------------^^^^^- - | | | - | | value borrowed here after move - | value moved here - | move occurs because value has type `[U; 2]`, which does not implement the `Copy` trait + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error: aborting due to 48 previous errors +error: aborting due to 33 previous errors For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs index 42c3290ddfbb2..b9235eabd88f4 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs @@ -12,12 +12,16 @@ fn main() { fn f1(ref a @ b: U) {} //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} //~^ ERROR cannot move out of value because it is borrowed //~| ERROR cannot move out of value because it is borrowed //~| ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value + //~| ERROR borrow of moved value fn f3(ref mut a @ [b, mut c]: [U; 2]) {} //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of partially moved value let ref a @ b = U; //~^ ERROR cannot move out of value because it is borrowed @@ -27,14 +31,19 @@ fn main() { //~| ERROR cannot move out of value because it is borrowed let ref mut a @ [b, mut c] = [U, U]; //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of partially moved value let ref a @ b = u(); //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); //~^ ERROR cannot move out of value because it is borrowed //~| ERROR cannot move out of value because it is borrowed //~| ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value + //~| ERROR borrow of moved value let ref mut a @ [b, mut c] = [u(), u()]; //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of partially moved value match Some(U) { ref a @ Some(b) => {} @@ -63,6 +72,8 @@ fn main() { //~^ ERROR cannot move out of value because it is borrowed //~| ERROR cannot move out of value because it is borrowed //~| ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value + //~| ERROR borrow of moved value None => {} } match Some([u(), u()]) { diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr index a275705b19332..50b2f8929f225 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr @@ -1,5 +1,5 @@ error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:22:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:26:9 | LL | let ref a @ b = U; | -----^^^- @@ -8,7 +8,7 @@ LL | let ref a @ b = U; | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:24:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:28:9 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); | -----^^^^^^^^^^^^-----^^^^^^^^^^-^ @@ -18,7 +18,7 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:24:18 + --> $DIR/borrowck-pat-by-move-and-ref.rs:28:18 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); | -----^^^----- @@ -27,7 +27,7 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); | value borrowed, by `b`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:24:33 + --> $DIR/borrowck-pat-by-move-and-ref.rs:28:33 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); | -----^^^- @@ -36,7 +36,7 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); | value borrowed, by `d`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:28:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:32:9 | LL | let ref mut a @ [b, mut c] = [U, U]; | ---------^^^^-^^-----^ @@ -46,7 +46,7 @@ LL | let ref mut a @ [b, mut c] = [U, U]; | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:30:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:35:9 | LL | let ref a @ b = u(); | -----^^^- @@ -55,7 +55,7 @@ LL | let ref a @ b = u(); | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:32:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:38:9 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | -----^^^^^^^^^^^^-----^^^^^^^^^^-^ @@ -65,7 +65,7 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:32:18 + --> $DIR/borrowck-pat-by-move-and-ref.rs:38:18 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | -----^^^----- @@ -74,7 +74,7 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | value borrowed, by `b`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:32:33 + --> $DIR/borrowck-pat-by-move-and-ref.rs:38:33 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | -----^^^- @@ -83,7 +83,7 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | value borrowed, by `d`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:36:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:44:9 | LL | let ref mut a @ [b, mut c] = [u(), u()]; | ---------^^^^-^^-----^ @@ -93,7 +93,7 @@ LL | let ref mut a @ [b, mut c] = [u(), u()]; | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:40:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:49:9 | LL | ref a @ Some(b) => {} | -----^^^^^^^^-^ @@ -102,7 +102,7 @@ LL | ref a @ Some(b) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:45:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:54:9 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^^^^^^^^^^^^^^^-----^^^^^^^^^^-^^ @@ -112,7 +112,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:45:23 + --> $DIR/borrowck-pat-by-move-and-ref.rs:54:23 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^----- @@ -121,7 +121,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `b`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:45:38 + --> $DIR/borrowck-pat-by-move-and-ref.rs:54:38 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^- @@ -130,7 +130,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `d`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:52:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:61:9 | LL | ref mut a @ Some([b, mut c]) => {} | ---------^^^^^^^^^-^^-----^^ @@ -140,7 +140,7 @@ LL | ref mut a @ Some([b, mut c]) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:57:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:66:9 | LL | ref a @ Some(b) => {} | -----^^^^^^^^-^ @@ -149,7 +149,7 @@ LL | ref a @ Some(b) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:62:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:9 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^^^^^^^^^^^^^^^-----^^^^^^^^^^-^^ @@ -159,7 +159,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:62:23 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:23 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^----- @@ -168,7 +168,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `b`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:62:38 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:38 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^- @@ -177,7 +177,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `d`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:69:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:80:9 | LL | ref mut a @ Some([b, mut c]) => {} | ---------^^^^^^^^^-^^-----^^ @@ -196,7 +196,7 @@ LL | fn f1(ref a @ b: U) {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:15:11 + --> $DIR/borrowck-pat-by-move-and-ref.rs:16:11 | LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | -----^^^^^^^^^^^^-----^^^^^^^^^^-^ @@ -206,7 +206,7 @@ LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:15:20 + --> $DIR/borrowck-pat-by-move-and-ref.rs:16:20 | LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | -----^^^----- @@ -215,7 +215,7 @@ LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | value borrowed, by `b`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:15:35 + --> $DIR/borrowck-pat-by-move-and-ref.rs:16:35 | LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | -----^^^- @@ -224,7 +224,7 @@ LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | value borrowed, by `d`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:19:11 + --> $DIR/borrowck-pat-by-move-and-ref.rs:22:11 | LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {} | ---------^^^^-^^-----^ @@ -233,5 +233,132 @@ LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {} | | value moved into `b` here | value borrowed, by `a`, here -error: aborting due to 25 previous errors +error[E0382]: borrow of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:32:9 + | +LL | let ref mut a @ [b, mut c] = [U, U]; + | ^^^^^^^^^^^^^^^^-----^ + | | | + | | value partially moved here + | value borrowed here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:35:9 + | +LL | let ref a @ b = u(); + | ^^^^^^^^- --- move occurs because value has type `U`, which does not implement the `Copy` trait + | | | + | | value moved here + | value borrowed here after move + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:38:18 + | +LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); + | ^^^^^^^^----- + | | | + | | value moved here + | value borrowed here after move + | + = note: move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:38:33 + | +LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); + | ^^^^^^^^- + | | | + | | value moved here + | value borrowed here after move + | + = note: move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:44:9 + | +LL | let ref mut a @ [b, mut c] = [u(), u()]; + | ^^^^^^^^^^^^^^^^-----^ + | | | + | | value partially moved here + | value borrowed here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:23 + | +LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} + | ^^^^^^^^----- + | | | + | | value moved here + | value borrowed here after move + | + = note: move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this field in the pattern to avoid moving the value + | +LL | ref a @ Some((ref b @ ref mut c, ref d @ e)) => {} + | ^^^ + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:38 + | +LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} + | ^^^^^^^^- + | | | + | | value moved here + | value borrowed here after move + | + = note: move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this field in the pattern to avoid moving the value + | +LL | ref a @ Some((ref b @ mut c, ref d @ ref e)) => {} + | ^^^ + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:13:11 + | +LL | fn f1(ref a @ b: U) {} + | ^^^^^^^^- + | | | + | | value moved here + | value borrowed here after move + | move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:16:20 + | +LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} + | ^^^^^^^^----- + | | | + | | value moved here + | value borrowed here after move + | + = note: move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:16:35 + | +LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} + | ^^^^^^^^- + | | | + | | value moved here + | value borrowed here after move + | + = note: move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:22:11 + | +LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {} + | ^^^^^^^^^^^^^^^^-----^ + | | | + | | value partially moved here + | value borrowed here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait + +error: aborting due to 36 previous errors +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs index f67cd45ca95ab..2d391cd7d0722 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs @@ -30,6 +30,7 @@ fn main() { fn f4_also_moved(ref a @ ref mut b @ c: U) {} //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable //~| ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub //~^ ERROR cannot borrow value as mutable more than once at a time @@ -46,12 +47,12 @@ fn main() { let ref mut a @ ref b = u(); //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable *a = u(); drop(b); let ref a @ ref mut b = u(); //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable - //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = u(); drop(a); @@ -117,20 +118,20 @@ fn main() { let ref a @ (ref mut b, ref mut c) = (U, U); //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = U; *c = U; let ref a @ (ref mut b, ref mut c) = (U, U); //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable - //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable - //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = U; drop(a); let ref a @ (ref mut b, ref mut c) = (U, U); - //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = U; //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable - *c = U; //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable + *c = U; drop(a); let ref mut a @ (ref b, ref c) = (U, U); //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr index e6231dd49bade..00136c2576423 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr @@ -8,7 +8,7 @@ LL | ref mut z @ &mut Some(ref a) => { | mutable borrow, by `z`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:34:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:35:9 | LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub | ---------^^^^-----------------^ @@ -18,7 +18,7 @@ LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:34:22 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:35:22 | LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub | -----^^^--------- @@ -27,7 +27,7 @@ LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub | immutable borrow, by `b`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:38:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:39:9 | LL | let ref a @ ref mut b = U; | -----^^^--------- @@ -36,7 +36,7 @@ LL | let ref a @ ref mut b = U; | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:40:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:41:9 | LL | let ref mut a @ ref b = U; | ---------^^^----- @@ -45,7 +45,7 @@ LL | let ref mut a @ ref b = U; | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:42:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:43:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -55,7 +55,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:44:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:45:9 | LL | let ref mut a @ (ref b, ref c) = (U, U); | ---------^^^^-----^^-----^ @@ -65,7 +65,7 @@ LL | let ref mut a @ (ref b, ref c) = (U, U); | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:47:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:48:9 | LL | let ref mut a @ ref b = u(); | ---------^^^----- @@ -74,7 +74,7 @@ LL | let ref mut a @ ref b = u(); | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:52:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:53:9 | LL | let ref a @ ref mut b = u(); | -----^^^--------- @@ -83,7 +83,7 @@ LL | let ref a @ ref mut b = u(); | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:58:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:59:9 | LL | let ref mut a @ ref b = U; | ---------^^^----- @@ -92,7 +92,7 @@ LL | let ref mut a @ ref b = U; | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:62:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:63:9 | LL | let ref a @ ref mut b = U; | -----^^^--------- @@ -101,7 +101,7 @@ LL | let ref a @ ref mut b = U; | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:68:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:69:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => { | ---------^^^^^^-----^ @@ -110,7 +110,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => { | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:68:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:69:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => { | ---------^^^^^^^-----^ @@ -119,7 +119,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => { | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:77:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:9 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { | -----^^^^^^---------^ @@ -128,7 +128,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:77:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:33 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { | -----^^^^^^^---------^ @@ -137,7 +137,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:88:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:9 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} | -----^^^^^^---------^ @@ -146,7 +146,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:88:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:33 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} | -----^^^^^^^---------^ @@ -155,7 +155,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:95:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} | ---------^^^^^^-----^ @@ -164,7 +164,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:95:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} | ---------^^^^^^^-----^ @@ -173,7 +173,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:102:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:9 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | -----^^^^^^---------^ @@ -182,7 +182,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:102:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:33 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | -----^^^^^^^---------^ @@ -191,7 +191,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:110:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ---------^^^^^^-----^ @@ -200,7 +200,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:110:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ---------^^^^^^^-----^ @@ -209,7 +209,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:118:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:119:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -219,7 +219,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:125:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -229,7 +229,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:130:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:131:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -239,7 +239,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:135:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:136:9 | LL | let ref mut a @ (ref b, ref c) = (U, U); | ---------^^^^-----^^-----^ @@ -306,32 +306,32 @@ LL | ref mut z @ &mut Some(ref a) => { LL | **z = None; | ---------- mutable borrow later used here -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:47:21 +error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:48:9 | LL | let ref mut a @ ref b = u(); - | ------------^^^^^ + | ^^^^^^^^^^^^----- | | | | | immutable borrow occurs here | mutable borrow occurs here ... -LL | *a = u(); - | -------- mutable borrow later used here +LL | drop(b); + | - immutable borrow later used here -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:52:17 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:53:9 | LL | let ref a @ ref mut b = u(); - | --------^^^^^^^^^ + | ^^^^^^^^--------- | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | drop(a); - | - immutable borrow later used here +LL | *b = u(); + | -------- mutable borrow later used here error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:77:20 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:20 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { | -----------^^^^^^^^^- @@ -343,7 +343,7 @@ LL | drop(a); | - immutable borrow later used here error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:77:45 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:45 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { | ------------^^^^^^^^^- @@ -355,7 +355,7 @@ LL | drop(a); | - immutable borrow later used here error[E0594]: cannot assign to `*b`, as it is immutable for the pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:88:61 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:61 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} | ^^^^^^ cannot assign @@ -363,7 +363,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } = note: variables bound in patterns are immutable until the end of the pattern guard error[E0594]: cannot assign to `*a`, as it is immutable for the pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:95:61 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:61 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} | ^^^^^^^^^^^ cannot assign @@ -371,7 +371,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa = note: variables bound in patterns are immutable until the end of the pattern guard error[E0507]: cannot move out of `b` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:102:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:66 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait @@ -379,7 +379,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `b` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:102:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:66 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait @@ -387,7 +387,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `a` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:110:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:66 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ^ move occurs because `a` has type `&mut std::result::Result`, which does not implement the `Copy` trait @@ -395,62 +395,60 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `a` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:110:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:66 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ^ move occurs because `a` has type `&mut std::result::Result`, which does not implement the `Copy` trait | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:18 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:119:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | ---------^^^^^^^^^------------ + | ^^^^^^^^^---------^^^^^^^^^^^^ | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | drop(a); - | - immutable borrow later used here +LL | *b = U; + | ------ mutable borrow later used here -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:29 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:125:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | --------------------^^^^^^^^^- - | | | - | | mutable borrow occurs here + | ^^^^^^^^^---------^^^^^^^^^^^^ + | | | + | | mutable borrow occurs here | immutable borrow occurs here ... -LL | drop(a); - | - immutable borrow later used here +LL | *b = U; + | ------ mutable borrow later used here -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:130:18 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:131:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | ---------^^^^^^^^^------------ + | ^^^^^^^^^---------^^^^^^^^^^^^ | | | | | mutable borrow occurs here | immutable borrow occurs here -... -LL | drop(a); - | - immutable borrow later used here +LL | +LL | *b = U; + | ------ mutable borrow later used here -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:130:29 +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:30:30 | -LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | --------------------^^^^^^^^^- - | | | - | | mutable borrow occurs here - | immutable borrow occurs here -... -LL | drop(a); - | - immutable borrow later used here +LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {} + | --------^^^^^^^^^^^^- + | | | | + | | | value moved here + | | value borrowed here after move + | move occurs because value has type `U`, which does not implement the `Copy` trait error: aborting due to 47 previous errors -Some errors have detailed explanations: E0502, E0507, E0594. -For more information about an error, try `rustc --explain E0502`. +Some errors have detailed explanations: E0382, E0502, E0507, E0594. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs index 8faaa1c881fbf..339814e1e3167 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs @@ -23,23 +23,24 @@ fn main() { fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} //~^ ERROR cannot borrow value as mutable more than once at a time //~| ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value let ref mut a @ ref mut b = U; //~^ ERROR cannot borrow value as mutable more than once at a time - //~| ERROR cannot borrow value as mutable more than once at a time drop(a); let ref mut a @ ref mut b = U; //~^ ERROR cannot borrow value as mutable more than once at a time + //~| ERROR cannot borrow value as mutable more than once at a time drop(b); let ref mut a @ ref mut b = U; //~^ ERROR cannot borrow value as mutable more than once at a time let ref mut a @ ref mut b = U; //~^ ERROR cannot borrow value as mutable more than once at a time - //~| ERROR cannot borrow value as mutable more than once at a time *a = U; let ref mut a @ ref mut b = U; //~^ ERROR cannot borrow value as mutable more than once at a time + //~| ERROR cannot borrow value as mutable more than once at a time *b = U; let ref mut a @ ( @@ -64,18 +65,14 @@ fn main() { let a @ (ref mut b, ref mut c) = (U, U); //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value let mut val = (U, [U, U]); let a @ (b, [c, d]) = &mut val; // Same as ^-- //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value let a @ &mut ref mut b = &mut U; //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value let a @ &mut (ref mut b, ref mut c) = &mut (U, U); //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value match Ok(U) { ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr index 2e0f5fcabddf3..0370037f24210 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr @@ -1,5 +1,5 @@ error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:27:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:28:9 | LL | let ref mut a @ ref mut b = U; | ---------^^^--------- @@ -17,7 +17,7 @@ LL | let ref mut a @ ref mut b = U; | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:34:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:35:9 | LL | let ref mut a @ ref mut b = U; | ---------^^^--------- @@ -26,7 +26,7 @@ LL | let ref mut a @ ref mut b = U; | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:37:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:38:9 | LL | let ref mut a @ ref mut b = U; | ---------^^^--------- @@ -44,7 +44,7 @@ LL | let ref mut a @ ref mut b = U; | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:45:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:46:9 | LL | let ref mut a @ ( | ^-------- @@ -66,7 +66,7 @@ LL | | ) = (U, [U, U, U]); | |_____^ error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:55:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:56:9 | LL | let ref mut a @ ( | ^-------- @@ -88,7 +88,7 @@ LL | | ) = (u(), [u(), u(), u()]); | |_________^ error: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:65:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:66:9 | LL | let a @ (ref mut b, ref mut c) = (U, U); | -^^^^---------^^---------^ @@ -111,7 +111,7 @@ LL | let a @ (b, [c, d]) = &mut val; // Same as ^-- | move occurs because `a` has type `&mut (U, [U; 2])` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:73:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:72:9 | LL | let a @ &mut ref mut b = &mut U; | -^^^^^^^^--------- @@ -121,7 +121,7 @@ LL | let a @ &mut ref mut b = &mut U; | move occurs because `a` has type `&mut U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:76:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:74:9 | LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U); | -^^^^^^^^^---------^^---------^ @@ -132,7 +132,7 @@ LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U); | move occurs because `a` has type `&mut (U, U)` which does not implement the `Copy` trait error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:81:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:78:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^---------^ @@ -141,7 +141,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:81:37 + --> $DIR/borrowck-pat-ref-mut-twice.rs:78:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^^---------^ @@ -150,7 +150,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:87:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:84:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^---------^ @@ -159,7 +159,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:87:37 + --> $DIR/borrowck-pat-ref-mut-twice.rs:84:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^^---------^ @@ -168,7 +168,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:94:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:91:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^---------^ @@ -177,7 +177,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:94:37 + --> $DIR/borrowck-pat-ref-mut-twice.rs:91:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^^---------^ @@ -186,7 +186,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:106:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:103:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^---------^ @@ -195,7 +195,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:106:37 + --> $DIR/borrowck-pat-ref-mut-twice.rs:103:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^^---------^ @@ -259,67 +259,31 @@ LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} | value borrowed, by `b`, here error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:27:21 + --> $DIR/borrowck-pat-ref-mut-twice.rs:31:9 | LL | let ref mut a @ ref mut b = U; - | ------------^^^^^^^^^ + | ^^^^^^^^^^^^--------- | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here + | | first mutable borrow occurs here + | second mutable borrow occurs here ... -LL | drop(a); +LL | drop(b); | - first borrow later used here error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:37:21 + --> $DIR/borrowck-pat-ref-mut-twice.rs:41:9 | LL | let ref mut a @ ref mut b = U; - | ------------^^^^^^^^^ + | ^^^^^^^^^^^^--------- | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here + | | first mutable borrow occurs here + | second mutable borrow occurs here ... -LL | *a = U; +LL | *b = U; | ------ first borrow later used here -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:65:25 - | -LL | let a @ (ref mut b, ref mut c) = (U, U); - | ----------------^^^^^^^^^- ------ move occurs because value has type `(U, U)`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:69:21 - | -LL | let a @ (b, [c, d]) = &mut val; // Same as ^-- - | ------------^-- -------- move occurs because value has type `&mut (U, [U; 2])`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:73:18 - | -LL | let a @ &mut ref mut b = &mut U; - | ---------^^^^^^^^^ ------ move occurs because value has type `&mut U`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:76:30 - | -LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U); - | ---------------------^^^^^^^^^- ----------- move occurs because value has type `&mut (U, U)`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:94:24 + --> $DIR/borrowck-pat-ref-mut-twice.rs:91:24 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------------^^^^^^^^^- @@ -331,7 +295,7 @@ LL | *a = Err(U); | ----------- first borrow later used here error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:94:53 + --> $DIR/borrowck-pat-ref-mut-twice.rs:91:53 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ----------------^^^^^^^^^- @@ -343,7 +307,7 @@ LL | *a = Err(U); | ----------- first borrow later used here error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:106:24 + --> $DIR/borrowck-pat-ref-mut-twice.rs:103:24 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------------^^^^^^^^^- @@ -355,7 +319,7 @@ LL | drop(a); | - first borrow later used here error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:106:53 + --> $DIR/borrowck-pat-ref-mut-twice.rs:103:53 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ----------------^^^^^^^^^- @@ -366,7 +330,17 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { LL | drop(a); | - first borrow later used here -error: aborting due to 34 previous errors +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-ref-mut-twice.rs:23:34 + | +LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} + | ------------^^^^^^^^^^^^- + | | | | + | | | value moved here + | | value borrowed here after move + | move occurs because value has type `U`, which does not implement the `Copy` trait + +error: aborting due to 31 previous errors Some errors have detailed explanations: E0382, E0499. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs index 3954d17e1c2bc..f731aa2e96327 100644 --- a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs +++ b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs @@ -8,10 +8,9 @@ struct C; struct NC(A, B); fn main() { + // this compiles let a @ NC(b, c) = NC(C, C); - //~^ ERROR use of moved value let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C)); - //~^ ERROR use of moved value - //~| ERROR use of moved value + //~^ ERROR use of partially moved value } diff --git a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr index cc2786a13f4e8..183a37176ec6c 100644 --- a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr +++ b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr @@ -1,32 +1,14 @@ -error[E0382]: use of moved value - --> $DIR/copy-and-move-mixed.rs:11:19 - | -LL | let a @ NC(b, c) = NC(C, C); - | ----------^- -------- move occurs because value has type `NC`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here - -error[E0382]: use of moved value - --> $DIR/copy-and-move-mixed.rs:14:19 +error[E0382]: use of partially moved value + --> $DIR/copy-and-move-mixed.rs:14:9 | LL | let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C)); - | ----------^^^^^^^^^^^^- --------------- move occurs because value has type `NC>`, which does not implement the `Copy` trait + | ^^^^^^^^^^------------^ | | | - | | value used here after move - | value moved here - -error[E0382]: use of moved value - --> $DIR/copy-and-move-mixed.rs:14:29 - | -LL | let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C)); - | ----------^- - | | | - | | value used here after move - | value moved here + | | value partially moved here + | value used here after partial move | - = note: move occurs because value has type `NC`, which does not implement the `Copy` trait + = note: partial move occurs because value has type `NC`, which does not implement the `Copy` trait -error: aborting due to 3 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.rs b/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.rs index 276088b9a9ee9..c15167e717592 100644 --- a/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.rs +++ b/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.rs @@ -28,7 +28,7 @@ fn main() { let _a: &NotCopy = a; let _b: NotCopy = b; let ref mut a @ b = NotCopy; //~ ERROR cannot move out of value because it is borrowed - //~^ ERROR cannot move out of value because it is borrowed + //~^ ERROR borrow of moved value let _a: &NotCopy = a; let _b: NotCopy = b; match Ok(NotCopy) { diff --git a/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr b/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr index 11d5e24f34e13..a41fec7a3f86d 100644 --- a/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr +++ b/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr @@ -44,18 +44,15 @@ LL | ref a @ b => { | | value moved into `b` here | value borrowed, by `a`, here -error[E0505]: cannot move out of value because it is borrowed - --> $DIR/default-binding-modes-both-sides-independent.rs:30:21 +error[E0382]: borrow of moved value + --> $DIR/default-binding-modes-both-sides-independent.rs:30:9 | LL | let ref mut a @ b = NotCopy; - | ------------^ + | ^^^^^^^^^^^^- ------- move occurs because value has type `NotCopy`, which does not implement the `Copy` trait | | | - | | move out of value occurs here - | borrow of value occurs here -LL | -LL | let _a: &NotCopy = a; - | - borrow later used here + | | value moved here + | value borrowed here after move error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0505`. +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.rs b/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.rs new file mode 100644 index 0000000000000..478809324ee6d --- /dev/null +++ b/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.rs @@ -0,0 +1,32 @@ +// check-pass +// edition:2018 +// compile-flags: -Z span-debug +// aux-build:test-macros.rs + +#![no_std] // Don't load unnecessary hygiene information from std +extern crate std; + +#[macro_use] extern crate test_macros; + +macro_rules! foo {( + #[fake_attr] + $item:item +) => ( + $item +)} + +macro_rules! outer {($item:item) => ( + print_bang! { // Identity proc-macro + foo! { + #[fake_attr] + $item + } + } +)} +outer! { + mod bar { + //! Foo + } +} + +fn main() {} diff --git a/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout b/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout new file mode 100644 index 0000000000000..c4ee44f654149 --- /dev/null +++ b/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout @@ -0,0 +1,86 @@ +PRINT-BANG INPUT (DISPLAY): foo ! { #[fake_attr] mod bar { + #![doc = r" Foo"] +} } +PRINT-BANG INPUT (DEBUG): TokenStream [ + Ident { + ident: "foo", + span: $DIR/issue-78675-captured-inner-attrs.rs:20:9: 20:12 (#4), + }, + Punct { + ch: '!', + spacing: Alone, + span: $DIR/issue-78675-captured-inner-attrs.rs:20:12: 20:13 (#4), + }, + Group { + delimiter: Brace, + stream: TokenStream [ + Punct { + ch: '#', + spacing: Alone, + span: $DIR/issue-78675-captured-inner-attrs.rs:21:13: 21:14 (#4), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "fake_attr", + span: $DIR/issue-78675-captured-inner-attrs.rs:21:15: 21:24 (#4), + }, + ], + span: $DIR/issue-78675-captured-inner-attrs.rs:21:14: 21:25 (#4), + }, + Group { + delimiter: None, + stream: TokenStream [ + Ident { + ident: "mod", + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + Ident { + ident: "bar", + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + Group { + delimiter: Brace, + stream: TokenStream [ + Punct { + ch: '#', + spacing: Joint, + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + Punct { + ch: '!', + spacing: Alone, + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "doc", + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + Punct { + ch: '=', + spacing: Alone, + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + Literal { + kind: StrRaw(0), + symbol: " Foo", + suffix: None, + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + ], + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + ], + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + ], + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + ], + span: $DIR/issue-78675-captured-inner-attrs.rs:20:14: 23:10 (#4), + }, +] diff --git a/src/test/ui/stability-attribute/stability-attribute-sanity.rs b/src/test/ui/stability-attribute/stability-attribute-sanity.rs index 80d7ae6dc637d..abd603b356ee6 100644 --- a/src/test/ui/stability-attribute/stability-attribute-sanity.rs +++ b/src/test/ui/stability-attribute/stability-attribute-sanity.rs @@ -59,14 +59,14 @@ fn multiple3() { } #[stable(feature = "a", since = "b")] #[rustc_deprecated(since = "b", reason = "text")] -#[rustc_deprecated(since = "b", reason = "text")] +#[rustc_deprecated(since = "b", reason = "text")] //~ ERROR multiple deprecated attributes #[rustc_const_unstable(feature = "c", issue = "none")] #[rustc_const_unstable(feature = "d", issue = "none")] //~ ERROR multiple stability levels -pub const fn multiple4() { } //~ ERROR multiple deprecated attributes +pub const fn multiple4() { } //~^ ERROR Invalid stability or deprecation version found #[rustc_deprecated(since = "a", reason = "text")] fn deprecated_without_unstable_or_stable() { } -//~^ ERROR rustc_deprecated attribute must be paired with either stable or unstable attribute +//~^^ ERROR rustc_deprecated attribute must be paired with either stable or unstable attribute fn main() { } diff --git a/src/test/ui/stability-attribute/stability-attribute-sanity.stderr b/src/test/ui/stability-attribute/stability-attribute-sanity.stderr index 134c657c62015..bf2436a535fd4 100644 --- a/src/test/ui/stability-attribute/stability-attribute-sanity.stderr +++ b/src/test/ui/stability-attribute/stability-attribute-sanity.stderr @@ -83,10 +83,12 @@ LL | #[stable(feature = "a", since = "b")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0550]: multiple deprecated attributes - --> $DIR/stability-attribute-sanity.rs:65:1 + --> $DIR/stability-attribute-sanity.rs:62:1 | -LL | pub const fn multiple4() { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_deprecated(since = "b", reason = "text")] + | ------------------------------------------------- first deprecation attribute +LL | #[rustc_deprecated(since = "b", reason = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute error[E0544]: multiple stability levels --> $DIR/stability-attribute-sanity.rs:64:1 @@ -101,10 +103,10 @@ LL | pub const fn multiple4() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0549]: rustc_deprecated attribute must be paired with either stable or unstable attribute - --> $DIR/stability-attribute-sanity.rs:69:1 + --> $DIR/stability-attribute-sanity.rs:68:1 | -LL | fn deprecated_without_unstable_or_stable() { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_deprecated(since = "a", reason = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 18 previous errors