diff options
| author | Ralf Jung <post@ralfj.de> | 2023-01-09 13:49:07 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-01-09 13:49:07 +0100 |
| commit | 236ae262bc80dabf67669a2763fda5034982b9b9 (patch) | |
| tree | 5fcef00e3290dcedd98e39e2b73c978cde47413c /src | |
| parent | 8740443c354ee1510a16017fae2104fcc39933cb (diff) | |
| parent | c54c8cbac882e149e04a9e1f2d146fd548ae30ae (diff) | |
| download | rust-236ae262bc80dabf67669a2763fda5034982b9b9.tar.gz rust-236ae262bc80dabf67669a2763fda5034982b9b9.zip | |
Merge from rustc
Diffstat (limited to 'src')
534 files changed, 5053 insertions, 2600 deletions
diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index efe8ae3169f..4a0ba592577 100644 --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock @@ -36,6 +36,7 @@ dependencies = [ name = "bootstrap" version = "0.0.0" dependencies = [ + "build_helper", "cc", "cmake", "fd-lock", @@ -71,6 +72,10 @@ dependencies = [ ] [[package]] +name = "build_helper" +version = "0.1.0" + +[[package]] name = "cc" version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index fafe82a9c12..22ceeca941e 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -30,6 +30,7 @@ path = "bin/sccache-plus-cl.rs" test = false [dependencies] +build_helper = { path = "../tools/build_helper" } cmake = "0.1.38" fd-lock = "3.0.8" filetime = "0.2" diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 9cf43fc7a21..f3998e98583 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -934,8 +934,7 @@ def main(): if len(sys.argv) > 1 and sys.argv[1] == 'help': sys.argv = [sys.argv[0], '-h'] + sys.argv[2:] - help_triggered = ( - '-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1) + help_triggered = len(sys.argv) == 1 or any(x in ["-h", "--help", "--version"] for x in sys.argv) try: bootstrap(help_triggered) if not help_triggered: diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 340aa78ebf9..68215790bed 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -2067,6 +2067,9 @@ impl Step for RustDev { builder.ensure(crate::native::Llvm { target }); + // We want to package `lld` to use it with `download-ci-llvm`. + builder.ensure(crate::native::Lld { target }); + let src_bindir = builder.llvm_out(target).join("bin"); // If updating this list, you likely want to change // src/bootstrap/download-ci-llvm-stamp as well, otherwise local users diff --git a/src/bootstrap/download-ci-llvm-stamp b/src/bootstrap/download-ci-llvm-stamp index d19a1ae95cf..94630e40f3c 100644 --- a/src/bootstrap/download-ci-llvm-stamp +++ b/src/bootstrap/download-ci-llvm-stamp @@ -1,4 +1,4 @@ Change this file to make users of the `download-ci-llvm` configuration download a new version of LLVM from CI, even if the LLVM submodule hasn’t changed. -Last change is for: https://github.com/rust-lang/rust/pull/102790 +Last change is for: https://github.com/rust-lang/rust/pull/104748 diff --git a/src/bootstrap/format.rs b/src/bootstrap/format.rs index 84e46118959..bfc57a85cdb 100644 --- a/src/bootstrap/format.rs +++ b/src/bootstrap/format.rs @@ -1,7 +1,8 @@ //! Runs rustfmt on the repository. use crate::builder::Builder; -use crate::util::{output, program_out_of_date, t}; +use crate::util::{output, output_result, program_out_of_date, t}; +use build_helper::git::updated_master_branch; use ignore::WalkBuilder; use std::collections::VecDeque; use std::path::{Path, PathBuf}; @@ -78,50 +79,24 @@ fn update_rustfmt_version(build: &Builder<'_>) { /// rust-lang/master and what is now on the disk. /// /// Returns `None` if all files should be formatted. -fn get_modified_rs_files(build: &Builder<'_>) -> Option<Vec<String>> { - let Ok(remote) = get_rust_lang_rust_remote() else { return None; }; +fn get_modified_rs_files(build: &Builder<'_>) -> Result<Option<Vec<String>>, String> { + let Ok(updated_master) = updated_master_branch(Some(&build.config.src)) else { return Ok(None); }; + if !verify_rustfmt_version(build) { - return None; + return Ok(None); } let merge_base = - output(build.config.git().arg("merge-base").arg(&format!("{remote}/master")).arg("HEAD")); - Some( - output(build.config.git().arg("diff-index").arg("--name-only").arg(merge_base.trim())) - .lines() - .map(|s| s.trim().to_owned()) - .filter(|f| Path::new(f).extension().map_or(false, |ext| ext == "rs")) - .collect(), - ) -} - -/// Finds the remote for rust-lang/rust. -/// For example for these remotes it will return `upstream`. -/// ```text -/// origin https://github.com/Nilstrieb/rust.git (fetch) -/// origin https://github.com/Nilstrieb/rust.git (push) -/// upstream https://github.com/rust-lang/rust (fetch) -/// upstream https://github.com/rust-lang/rust (push) -/// ``` -fn get_rust_lang_rust_remote() -> Result<String, String> { - let mut git = Command::new("git"); - git.args(["config", "--local", "--get-regex", "remote\\..*\\.url"]); - - let output = git.output().map_err(|err| format!("{err:?}"))?; - if !output.status.success() { - return Err("failed to execute git config command".to_owned()); - } - - let stdout = String::from_utf8(output.stdout).map_err(|err| format!("{err:?}"))?; - - let rust_lang_remote = stdout + output_result(build.config.git().arg("merge-base").arg(&updated_master).arg("HEAD"))?; + Ok(Some( + output_result( + build.config.git().arg("diff-index").arg("--name-only").arg(merge_base.trim()), + )? .lines() - .find(|remote| remote.contains("rust-lang")) - .ok_or_else(|| "rust-lang/rust remote not found".to_owned())?; - - let remote_name = - rust_lang_remote.split('.').nth(1).ok_or_else(|| "remote name not found".to_owned())?; - Ok(remote_name.into()) + .map(|s| s.trim().to_owned()) + .filter(|f| Path::new(f).extension().map_or(false, |ext| ext == "rs")) + .collect(), + )) } #[derive(serde::Deserialize)] @@ -158,6 +133,9 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) { Ok(status) => status.success(), Err(_) => false, }; + + let mut paths = paths.to_vec(); + if git_available { let in_working_tree = match build .config @@ -191,10 +169,21 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) { ignore_fmt.add(&format!("!/{}", untracked_path)).expect(&untracked_path); } if !check && paths.is_empty() { - if let Some(files) = get_modified_rs_files(build) { - for file in files { - println!("formatting modified file {file}"); - ignore_fmt.add(&format!("/{file}")).expect(&file); + match get_modified_rs_files(build) { + Ok(Some(files)) => { + for file in files { + println!("formatting modified file {file}"); + ignore_fmt.add(&format!("/{file}")).expect(&file); + } + } + Ok(None) => {} + Err(err) => { + println!( + "WARN: Something went wrong when running git commands:\n{err}\n\ + Falling back to formatting all files." + ); + // Something went wrong when getting the version. Just format all the files. + paths.push(".".into()); } } } @@ -204,6 +193,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) { } else { println!("Could not find usable git. Skipping git-aware format checks"); } + let ignore_fmt = ignore_fmt.build().unwrap(); let rustfmt_path = build.initial_rustfmt().unwrap_or_else(|| { diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 5ea41d10bc8..d44b96cfb99 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -113,6 +113,7 @@ use std::path::{Path, PathBuf}; use std::process::Command; use std::str; +use build_helper::ci::CiEnv; use channel::GitInfo; use config::{DryRun, Target}; use filetime::FileTime; @@ -121,7 +122,7 @@ use once_cell::sync::OnceCell; use crate::builder::Kind; use crate::config::{LlvmLibunwind, TargetSelection}; use crate::util::{ - exe, libdir, mtime, output, run, run_suppressed, symlink_dir, try_run_suppressed, CiEnv, + exe, libdir, mtime, output, run, run_suppressed, symlink_dir, try_run_suppressed, }; mod bolt; diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 4e503dfe864..89bb2b770f9 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -24,6 +24,8 @@ use crate::util::get_clang_cl_resource_dir; use crate::util::{self, exe, output, t, up_to_date}; use crate::{CLang, GitRepo}; +use build_helper::ci::CiEnv; + #[derive(Clone)] pub struct LlvmResult { /// Path to llvm-config binary. @@ -63,13 +65,13 @@ impl LdFlags { } } -// This returns whether we've already previously built LLVM. -// -// It's used to avoid busting caches during x.py check -- if we've already built -// LLVM, it's fine for us to not try to avoid doing so. -// -// This will return the llvm-config if it can get it (but it will not build it -// if not). +/// This returns whether we've already previously built LLVM. +/// +/// It's used to avoid busting caches during x.py check -- if we've already built +/// LLVM, it's fine for us to not try to avoid doing so. +/// +/// This will return the llvm-config if it can get it (but it will not build it +/// if not). pub fn prebuilt_llvm_config( builder: &Builder<'_>, target: TargetSelection, @@ -217,7 +219,7 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool { return false; } - if crate::util::CiEnv::is_ci() { + if CiEnv::is_ci() { // We assume we have access to git, so it's okay to unconditionally pass // `true` here. let llvm_sha = detect_llvm_sha(config, true); @@ -823,8 +825,21 @@ impl Step for Lld { } let target = self.target; - let LlvmResult { llvm_config, llvm_cmake_dir } = - builder.ensure(Llvm { target: self.target }); + let LlvmResult { llvm_config, llvm_cmake_dir } = builder.ensure(Llvm { target }); + + // The `dist` step packages LLD next to LLVM's binaries for download-ci-llvm. The root path + // we usually expect here is `./build/$triple/ci-llvm/`, with the binaries in its `bin` + // subfolder. We check if that's the case, and if LLD's binary already exists there next to + // `llvm-config`: if so, we can use it instead of building LLVM/LLD from source. + let ci_llvm_bin = llvm_config.parent().unwrap(); + if ci_llvm_bin.is_dir() && ci_llvm_bin.file_name().unwrap() == "bin" { + let lld_path = ci_llvm_bin.join(exe("lld", target)); + if lld_path.exists() { + // The following steps copying `lld` as `rust-lld` to the sysroot, expect it in the + // `bin` subfolder of this step's out dir. + return ci_llvm_bin.parent().unwrap().to_path_buf(); + } + } let out_dir = builder.lld_out(target); let done_stamp = out_dir.join("lld-finished-building"); @@ -1072,12 +1087,12 @@ fn supported_sanitizers( match &*target.triple { "aarch64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]), - "aarch64-fuchsia" => common_libs("fuchsia", "aarch64", &["asan"]), + "aarch64-unknown-fuchsia" => common_libs("fuchsia", "aarch64", &["asan"]), "aarch64-unknown-linux-gnu" => { common_libs("linux", "aarch64", &["asan", "lsan", "msan", "tsan", "hwasan"]) } "x86_64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]), - "x86_64-fuchsia" => common_libs("fuchsia", "x86_64", &["asan"]), + "x86_64-unknown-fuchsia" => common_libs("fuchsia", "x86_64", &["asan"]), "x86_64-unknown-freebsd" => common_libs("freebsd", "x86_64", &["asan", "msan", "tsan"]), "x86_64-unknown-netbsd" => { common_libs("netbsd", "x86_64", &["asan", "lsan", "msan", "tsan"]) diff --git a/src/bootstrap/run.rs b/src/bootstrap/run.rs index 05de51f8cc5..e0280854541 100644 --- a/src/bootstrap/run.rs +++ b/src/bootstrap/run.rs @@ -105,6 +105,7 @@ impl Step for BumpStage0 { fn run(self, builder: &Builder<'_>) -> Self::Output { let mut cmd = builder.tool_cmd(Tool::BumpStage0); + cmd.args(builder.config.cmd.args()); builder.run(&mut cmd); } } diff --git a/src/bootstrap/setup.rs b/src/bootstrap/setup.rs index cd360cbef96..ca4feac6fac 100644 --- a/src/bootstrap/setup.rs +++ b/src/bootstrap/setup.rs @@ -351,7 +351,7 @@ pub fn interactive_path() -> io::Result<Profile> { Ok(template) } -// install a git hook to automatically run tidy --bless, if they want +// install a git hook to automatically run tidy, if they want fn install_git_hook_maybe(config: &Config) -> io::Result<()> { let git = t!(config.git().args(&["rev-parse", "--git-common-dir"]).output().map(|output| { assert!(output.status.success(), "failed to run `git`"); @@ -367,7 +367,7 @@ fn install_git_hook_maybe(config: &Config) -> io::Result<()> { println!(); println!( "Rust's CI will automatically fail if it doesn't pass `tidy`, the internal tool for ensuring code quality. -If you'd like, x.py can install a git hook for you that will automatically run `tidy --bless` before +If you'd like, x.py can install a git hook for you that will automatically run `test tidy` before pushing your code to ensure your code is up to par. If you decide later that this behavior is undesirable, simply delete the `pre-push` file from .git/hooks." ); diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 58220783228..93e53d383cd 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -255,35 +255,6 @@ pub enum CiEnv { GitHubActions, } -impl CiEnv { - /// Obtains the current CI environment. - pub fn current() -> CiEnv { - if env::var("TF_BUILD").map_or(false, |e| e == "True") { - CiEnv::AzurePipelines - } else if env::var("GITHUB_ACTIONS").map_or(false, |e| e == "true") { - CiEnv::GitHubActions - } else { - CiEnv::None - } - } - - pub fn is_ci() -> bool { - Self::current() != CiEnv::None - } - - /// If in a CI environment, forces the command to run with colors. - pub fn force_coloring_in_ci(self, cmd: &mut Command) { - if self != CiEnv::None { - // Due to use of stamp/docker, the output stream of rustbuild is not - // a TTY in CI, so coloring is by-default turned off. - // The explicit `TERM=xterm` environment is needed for - // `--color always` to actually work. This env var was lost when - // compiling through the Makefile. Very strange. - cmd.env("TERM", "xterm").args(&["--color", "always"]); - } - } -} - pub fn forcing_clang_based_tests() -> bool { if let Some(var) = env::var_os("RUSTBUILD_FORCE_CLANG_BASED_TESTS") { match &var.to_string_lossy().to_lowercase()[..] { @@ -441,6 +412,23 @@ pub fn output(cmd: &mut Command) -> String { String::from_utf8(output.stdout).unwrap() } +pub fn output_result(cmd: &mut Command) -> Result<String, String> { + let output = match cmd.stderr(Stdio::inherit()).output() { + Ok(status) => status, + Err(e) => return Err(format!("failed to run command: {:?}: {}", cmd, e)), + }; + if !output.status.success() { + return Err(format!( + "command did not execute successfully: {:?}\n\ + expected success, got: {}\n{}", + cmd, + output.status, + String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))? + )); + } + Ok(String::from_utf8(output.stdout).map_err(|err| format!("{err:?}"))?) +} + /// Returns the last-modified time for `path`, or zero if it doesn't exist. pub fn mtime(path: &Path) -> SystemTime { fs::metadata(path).and_then(|f| f.modified()).unwrap_or(UNIX_EPOCH) diff --git a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile index 93ef7dfcbf5..0f5df95a0dd 100644 --- a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile @@ -30,18 +30,18 @@ RUN apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7 RUN add-apt-repository -y 'deb https://apt.dilos.org/dilos dilos2 main' ENV \ - AR_x86_64_fuchsia=x86_64-fuchsia-ar \ - CC_x86_64_fuchsia=x86_64-fuchsia-clang \ - CFLAGS_x86_64_fuchsia="--target=x86_64-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot -I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \ - CXX_x86_64_fuchsia=x86_64-fuchsia-clang++ \ - CXXFLAGS_x86_64_fuchsia="--target=x86_64-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot -I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \ - LDFLAGS_x86_64_fuchsia="--target=x86_64-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot -L/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/lib" \ - AR_aarch64_fuchsia=aarch64-fuchsia-ar \ - CC_aarch64_fuchsia=aarch64-fuchsia-clang \ - CFLAGS_aarch64_fuchsia="--target=aarch64-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot -I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \ - CXX_aarch64_fuchsia=aarch64-fuchsia-clang++ \ - CXXFLAGS_aarch64_fuchsia="--target=aarch64-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot -I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \ - LDFLAGS_aarch64_fuchsia="--target=aarch64-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot -L/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/lib" \ + AR_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-ar \ + CC_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang \ + CFLAGS_x86_64_unknown_fuchsia="--target=x86_64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot -I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \ + CXX_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang++ \ + CXXFLAGS_x86_64_unknown_fuchsia="--target=x86_64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot -I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \ + LDFLAGS_x86_64_unknown_fuchsia="--target=x86_64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot -L/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/lib" \ + AR_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-ar \ + CC_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang \ + CFLAGS_aarch64_unknown_fuchsia="--target=aarch64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot -I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \ + CXX_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang++ \ + CXXFLAGS_aarch64_unknown_fuchsia="--target=aarch64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot -I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \ + LDFLAGS_aarch64_unknown_fuchsia="--target=aarch64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot -L/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/lib" \ AR_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-ar \ CC_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-gcc \ CXX_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-g++ \ @@ -99,19 +99,19 @@ RUN /tmp/freebsd-toolchain.sh i686 COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -ENV CARGO_TARGET_X86_64_FUCHSIA_AR /usr/local/bin/llvm-ar -ENV CARGO_TARGET_X86_64_FUCHSIA_RUSTFLAGS \ +ENV CARGO_TARGET_X86_64_UNKNOWN_FUCHSIA_AR /usr/local/bin/llvm-ar +ENV CARGO_TARGET_X86_64_UNKNOWN_FUCHSIA_RUSTFLAGS \ -C link-arg=--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot \ -Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot/lib \ -Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/lib -ENV CARGO_TARGET_AARCH64_FUCHSIA_AR /usr/local/bin/llvm-ar -ENV CARGO_TARGET_AARCH64_FUCHSIA_RUSTFLAGS \ +ENV CARGO_TARGET_AARCH64_UNKNOWN_FUCHSIA_AR /usr/local/bin/llvm-ar +ENV CARGO_TARGET_AARCH64_UNKNOWN_FUCHSIA_RUSTFLAGS \ -C link-arg=--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot \ -Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot/lib \ -Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/lib -ENV TARGETS=x86_64-fuchsia -ENV TARGETS=$TARGETS,aarch64-fuchsia +ENV TARGETS=x86_64-unknown-fuchsia +ENV TARGETS=$TARGETS,aarch64-unknown-fuchsia ENV TARGETS=$TARGETS,wasm32-unknown-unknown ENV TARGETS=$TARGETS,wasm32-wasi ENV TARGETS=$TARGETS,sparcv9-sun-solaris diff --git a/src/ci/docker/host-x86_64/dist-various-2/build-fuchsia-toolchain.sh b/src/ci/docker/host-x86_64/dist-various-2/build-fuchsia-toolchain.sh index 80db9257754..d762b4672c6 100755 --- a/src/ci/docker/host-x86_64/dist-various-2/build-fuchsia-toolchain.sh +++ b/src/ci/docker/host-x86_64/dist-various-2/build-fuchsia-toolchain.sh @@ -29,9 +29,9 @@ install_clang() { # CFLAGS and CXXFLAGS env variables in main Dockerfile handle sysroot linking for arch in x86_64 aarch64; do for tool in clang clang++; do - ln -s /usr/local/bin/${tool} /usr/local/bin/${arch}-fuchsia-${tool} + ln -s /usr/local/bin/${tool} /usr/local/bin/${arch}-unknown-fuchsia-${tool} done - ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-fuchsia-ar + ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-unknown-fuchsia-ar done popd > /dev/null diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version index 475434e5aef..c39e9c5fbc9 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version +++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version @@ -1 +1 @@ -0.13.4 \ No newline at end of file +0.14.1 \ No newline at end of file diff --git a/src/ci/docker/scripts/fuchsia-test-runner.py b/src/ci/docker/scripts/fuchsia-test-runner.py index 3e86339859d..c8d1ff9aefb 100755 --- a/src/ci/docker/scripts/fuchsia-test-runner.py +++ b/src/ci/docker/scripts/fuchsia-test-runner.py @@ -4,7 +4,7 @@ The Rust toolchain test runner for Fuchsia. For instructions on running the compiler test suite, see -https://doc.rust-lang.org/stable/rustc/platform-support/fuchsia.html#aarch64-fuchsia-and-x86_64-fuchsia +https://doc.rust-lang.org/stable/rustc/platform-support/fuchsia.html#aarch64-unknown-fuchsia-and-x86_64-unknown-fuchsia """ import argparse @@ -110,9 +110,9 @@ class TestEnvironment: def rustlib_dir(self): if self.target_arch == "x64": - return "x86_64-fuchsia" + return "x86_64-unknown-fuchsia" if self.target_arch == "arm64": - return "aarch64-fuchsia" + return "aarch64-unknown-fuchsia" raise Exception(f"Unrecognized target architecture {self.target_arch}") def libs_dir(self): diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index 2d3b8309461..752f1cc4aba 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -22,10 +22,11 @@ - [armv4t-none-eabi](platform-support/armv4t-none-eabi.md) - [armv5te-none-eabi](platform-support/armv5te-none-eabi.md) - [armv6k-nintendo-3ds](platform-support/armv6k-nintendo-3ds.md) + - [armv7-sony-vita-newlibeabihf](platform-support/armv7-sony-vita-newlibeabihf.md) - [armv7-unknown-linux-uclibceabi](platform-support/armv7-unknown-linux-uclibceabi.md) - [armv7-unknown-linux-uclibceabihf](platform-support/armv7-unknown-linux-uclibceabihf.md) - [\*-android and \*-androideabi](platform-support/android.md) - - [\*-fuchsia](platform-support/fuchsia.md) + - [\*-unknown-fuchsia](platform-support/fuchsia.md) - [\*-kmc-solid_\*](platform-support/kmc-solid.md) - [m68k-unknown-linux-gnu](platform-support/m68k-unknown-linux-gnu.md) - [mips64-openwrt-linux-musl](platform-support/mips64-openwrt-linux-musl.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index d0c3ddf2606..7ff26e420f1 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -124,7 +124,7 @@ target | std | notes -------|:---:|------- `aarch64-apple-ios` | ✓ | ARM64 iOS [`aarch64-apple-ios-sim`](platform-support/aarch64-apple-ios-sim.md) | ✓ | Apple iOS Simulator on ARM64 -`aarch64-fuchsia` | ✓ | ARM64 Fuchsia +`aarch64-unknown-fuchsia` | ✓ | ARM64 Fuchsia [`aarch64-linux-android`](platform-support/android.md) | ✓ | ARM64 Android `aarch64-unknown-none-softfloat` | * | Bare ARM64, softfloat `aarch64-unknown-none` | * | Bare ARM64, hardfloat @@ -177,7 +177,7 @@ target | std | notes `wasm32-wasi` | ✓ | WebAssembly with WASI `x86_64-apple-ios` | ✓ | 64-bit x86 iOS [`x86_64-fortanix-unknown-sgx`](platform-support/x86_64-fortanix-unknown-sgx.md) | ✓ | [Fortanix ABI] for 64-bit Intel SGX -`x86_64-fuchsia` | ✓ | 64-bit Fuchsia +`x86_64-unknown-fuchsia` | ✓ | 64-bit Fuchsia [`x86_64-linux-android`](platform-support/android.md) | ✓ | 64-bit x86 Android `x86_64-pc-solaris` | ✓ | 64-bit Solaris 10/11, illumos `x86_64-unknown-linux-gnux32` | ✓ | 64-bit Linux (x32 ABI) (kernel 4.15, glibc 2.27) @@ -235,6 +235,7 @@ target | std | host | notes `armv6-unknown-netbsd-eabihf` | ? | | [`armv6k-nintendo-3ds`](platform-support/armv6k-nintendo-3ds.md) | ? | | ARMv6K Nintendo 3DS, Horizon (Requires devkitARM toolchain) `armv7-apple-ios` | ✓ | | ARMv7 iOS, Cortex-a8 +[`armv7-sony-vita-newlibeabihf`](platform-support/armv7-sony-vita-newlibeabihf.md) | ? | | ARM Cortex-A9 Sony PlayStation Vita (requires VITASDK toolchain) [`armv7-unknown-linux-uclibceabi`](platform-support/armv7-unknown-linux-uclibceabi.md) | ✓ | ✓ | ARMv7 Linux with uClibc, softfloat [`armv7-unknown-linux-uclibceabihf`](platform-support/armv7-unknown-linux-uclibceabihf.md) | ✓ | ? | ARMv7 Linux with uClibc, hardfloat `armv7-unknown-freebsd` | ✓ | ✓ | ARMv7 FreeBSD diff --git a/src/doc/rustc/src/platform-support/armv7-sony-vita-eabihf.md b/src/doc/rustc/src/platform-support/armv7-sony-vita-eabihf.md new file mode 100644 index 00000000000..6619c90b849 --- /dev/null +++ b/src/doc/rustc/src/platform-support/armv7-sony-vita-eabihf.md @@ -0,0 +1,127 @@ +# armv7-sony-vita-eabihf + +**Tier: 3** + +This tier supports the ARM Cortex A9 processor running on a PlayStation Vita console. `armv7-vita-newlibeabihf` aims to have support for `std` crate using `newlib` as a bridge. + +## Designated Developers + +* [@amg98](https://github.com/amg98) + +## Requirements + +This target is cross compiled, and requires installing [VITASDK](https://vitasdk.org/) toolchain on your system. + +## Building + +You can build Rust with support for the target by adding it to the `target` +list in `config.toml`: + +```toml +[build] +build-stage = 1 +target = ["armv7-sony-vita-newlibeabihf"] +``` + +## Cross-compilation + +This target can be cross-compiled from `x86_64` on either Windows, MacOS or Linux systems. Other hosts are not supported for cross-compilation. + +## Testing + +Currently there is no support to run the rustc test suite for this target. + +## Building and Running Rust Programs + +To test your developed rust programs for PlayStation Vita, first you have to prepare a proper executable for the device using the resulting ELF file you get from compilation step. The needed steps can be automated using tools like `cargo-make`. Use the example below as a template for your project: + +```toml +[env] +TITLE = "Rust Hello World" +TITLEID = "RUST00001" +# At least a "sce_sys" folder should be place there for app metadata (title, icons, description...) +# You can find sample assets for that on $VITASDK/share/gcc-arm-vita-eabi/samples/hello_world/sce_sys/ +STATIC_DIR = "static" # Folder where static assets should be placed (sce_sys folder is at $STATIC_DIR/sce_sys) +CARGO_TARGET_DIR = { script = ["echo ${CARGO_TARGET_DIR:=target}"] } +RUST_TARGET_PATH = { script = ["echo $(pwd)"]} +RUST_TARGET = "armv7-sony-vita-newlibeabihf" +CARGO_OUT_DIR = "${CARGO_TARGET_DIR}/${RUST_TARGET}/release" + +[tasks.xbuild] +# This is the command where you get the ELF executable file (e.g. call to cargo build) + +[tasks.strip] +description = "Strip the produced ELF executable." +dependencies = ["xbuild"] +command = "arm-vita-eabi-strip" +args = ["-g", '${CARGO_OUT_DIR}/${CARGO_MAKE_CRATE_FS_NAME}.elf'] + +[tasks.velf] +description = "Build an VELF executable from the obtained ELF file." +dependencies = ["strip"] +command = "vita-elf-create" +args = ['${CARGO_OUT_DIR}/${CARGO_MAKE_CRATE_NAME}.elf', '${CARGO_OUT_DIR}/${CARGO_MAKE_CRATE_NAME}.velf'] + +[tasks.eboot-bin] +description = "Build an `eboot.bin` file from the obtained VELF file." +dependencies = ["velf"] +command = "vita-make-fself" +args = ["-s", '${CARGO_OUT_DIR}/${CARGO_MAKE_CRATE_NAME}.velf', '${CARGO_OUT_DIR}/eboot.bin'] + +[tasks.param-sfo] +description = "Build the `param.sfo` manifest using with given TITLE and TITLEID." +command = "vita-mksfoex" +args = ["-s", 'TITLE_ID=${TITLEID}', '${TITLE}', '${CARGO_OUT_DIR}/param.sfo'] + +[tasks.manifest] +description = "List all static resources into a manifest file." +script = [ + 'mkdir -p "${CARGO_OUT_DIR}"', + ''' + if [ -d "${STATIC_DIR}" ]; then + find "${STATIC_DIR}" -type f > "${CARGO_OUT_DIR}/MANIFEST" + else + touch "${CARGO_OUT_DIR}/MANIFEST" + fi + ''' +] + +[tasks.vpk] +description = "Build a VPK distribution of the project executable and resources." +dependencies = ["eboot-bin", "param-sfo", "manifest"] +script_runner = "@rust" +script = [ + ''' + use std::io::BufRead; + use std::fs::File; + + fn main() { + + let crate_name = env!("CARGO_MAKE_CRATE_NAME"); + let static_dir = env!("STATIC_DIR"); + let out_dir = std::path::PathBuf::from(env!("CARGO_OUT_DIR")); + + let mut cmd = ::std::process::Command::new("vita-pack-vpk"); + cmd.arg("-s").arg(out_dir.join("param.sfo")); + cmd.arg("-b").arg(out_dir.join("eboot.bin")); + + // Add files from MANIFEST + if let Ok(file) = File::open(out_dir.join("MANIFEST")) { + let mut reader = ::std::io::BufReader::new(file); + let mut lines = reader.lines(); + while let Some(Ok(line)) = lines.next() { + let p1 = ::std::path::PathBuf::from(line); // path on FS + let p2 = p1.strip_prefix(static_dir).unwrap(); // path in VPK + cmd.arg("--add").arg(format!("{}={}", p1.display(), p2.display())); + } + } + + cmd.arg(out_dir.join(format!("{}.vpk", crate_name))) + .output() + .expect("command failed."); + } + ''' +] +``` + +After running the above script, you should be able to get a *.vpk file in the same folder your *.elf executable resides. Now you can pick it and install it on your own PlayStation Vita using, for example, [VitaShell](https://github.com/TheOfficialFloW/VitaShell/releases) or you can use an emulator. For the time being, the most mature emulator for PlayStation Vita is [Vita3K](https://vita3k.org/), although I personally recommend testing your programs in real hardware, as the emulator is quite experimental. diff --git a/src/doc/rustc/src/platform-support/fuchsia.md b/src/doc/rustc/src/platform-support/fuchsia.md index cc4ee2e67b1..95c242cc161 100644 --- a/src/doc/rustc/src/platform-support/fuchsia.md +++ b/src/doc/rustc/src/platform-support/fuchsia.md @@ -1,4 +1,4 @@ -# `aarch64-fuchsia` and `x86_64-fuchsia` +# `aarch64-unknown-fuchsia` and `x86_64-unknown-fuchsia` **Tier: 2** @@ -67,7 +67,7 @@ This walkthrough will cover: 1. Building a Fuchsia package. 1. Publishing and running a Fuchsia package to a Fuchsia emulator. -For the purposes of this walkthrough, we will only target `x86_64-fuchsia`. +For the purposes of this walkthrough, we will only target `x86_64-unknown-fuchsia`. ## Compiling a Rust binary targeting Fuchsia @@ -83,8 +83,8 @@ to handle the installation of Fuchsia targets for you. This can be done by issui the following commands: ```sh -rustup target add x86_64-fuchsia -rustup target add aarch64-fuchsia +rustup target add x86_64-unknown-fuchsia +rustup target add aarch64-unknown-fuchsia ``` After installing our Fuchsia targets, we can now compile a Rust binary that targets @@ -127,7 +127,7 @@ during compilation: **`.cargo/config.toml`** ```txt -[target.x86_64-fuchsia] +[target.x86_64-unknown-fuchsia] rustflags = [ "-Lnative=<SDK_PATH>/arch/x64/lib", @@ -159,10 +159,10 @@ hello_fuchsia/ Finally, we can build our rust binary as: ```sh -cargo build --target x86_64-fuchsia +cargo build --target x86_64-unknown-fuchsia ``` -Now we have a Rust binary at `target/x86_64-fuchsia/debug/hello_fuchsia`, +Now we have a Rust binary at `target/x86_64-unknown-fuchsia/debug/hello_fuchsia`, targeting our desired Fuchsia target. **Current directory structure** @@ -171,7 +171,7 @@ hello_fuchsia/ ┣━ src/ ┃ ┗━ main.rs ┣━ target/ -┃ ┗━ x86_64-fuchsia/ +┃ ┗━ x86_64-unknown-fuchsia/ ┃ ┗━ debug/ ┃ ┗━ hello_fuchsia ┣━ Cargo.toml @@ -193,16 +193,19 @@ configuration in `config.toml`: ```toml [build] -target = ["<host_platform>", "aarch64-fuchsia", "x86_64-fuchsia"] +target = ["<host_platform>", "aarch64-unknown-fuchsia", "x86_64-unknown-fuchsia"] [rust] lld = true -[target.x86_64-fuchsia] +[llvm] +download-ci-llvm = false + +[target.x86_64-unknown-fuchsia] cc = "clang" cxx = "clang++" -[target.aarch64-fuchsia] +[target.aarch64-unknown-fuchsia] cc = "clang" cxx = "clang++" ``` @@ -233,14 +236,14 @@ a script we name `config-env.sh`: # Configure this environment variable to be the path to the downloaded SDK export SDK_PATH="<SDK path goes here>" -export CFLAGS_aarch64_fuchsia="--target=aarch64-fuchsia --sysroot=${SDK_PATH}/arch/arm64/sysroot -I${SDK_PATH}/pkg/fdio/include" -export CXXFLAGS_aarch64_fuchsia="--target=aarch64-fuchsia --sysroot=${SDK_PATH}/arch/arm64/sysroot -I${SDK_PATH}/pkg/fdio/include" -export LDFLAGS_aarch64_fuchsia="--target=aarch64-fuchsia --sysroot=${SDK_PATH}/arch/arm64/sysroot -L${SDK_PATH}/arch/arm64/lib" -export CARGO_TARGET_AARCH64_FUCHSIA_RUSTFLAGS="-C link-arg=--sysroot=${SDK_PATH}/arch/arm64/sysroot -Lnative=${SDK_PATH}/arch/arm64/sysroot/lib -Lnative=${SDK_PATH}/arch/arm64/lib" -export CFLAGS_x86_64_fuchsia="--target=x86_64-fuchsia --sysroot=${SDK_PATH}/arch/x64/sysroot -I${SDK_PATH}/pkg/fdio/include" -export CXXFLAGS_x86_64_fuchsia="--target=x86_64-fuchsia --sysroot=${SDK_PATH}/arch/x64/sysroot -I${SDK_PATH}/pkg/fdio/include" -export LDFLAGS_x86_64_fuchsia="--target=x86_64-fuchsia --sysroot=${SDK_PATH}/arch/x64/sysroot -L${SDK_PATH}/arch/x64/lib" -export CARGO_TARGET_X86_64_FUCHSIA_RUSTFLAGS="-C link-arg=--sysroot=${SDK_PATH}/arch/x64/sysroot -Lnative=${SDK_PATH}/arch/x64/sysroot/lib -Lnative=${SDK_PATH}/arch/x64/lib" +export CFLAGS_aarch64_unknown_fuchsia="--target=aarch64-unknown-fuchsia --sysroot=${SDK_PATH}/arch/arm64/sysroot -I${SDK_PATH}/pkg/fdio/include" +export CXXFLAGS_aarch64_unknown_fuchsia="--target=aarch64-unknown-fuchsia --sysroot=${SDK_PATH}/arch/arm64/sysroot -I${SDK_PATH}/pkg/fdio/include" +export LDFLAGS_aarch64_unknown_fuchsia="--target=aarch64-unknown-fuchsia --sysroot=${SDK_PATH}/arch/arm64/sysroot -L${SDK_PATH}/arch/arm64/lib" +export CARGO_TARGET_AARCH64_UNKNOWN_FUCHSIA_RUSTFLAGS="-C link-arg=--sysroot=${SDK_PATH}/arch/arm64/sysroot -Lnative=${SDK_PATH}/arch/arm64/sysroot/lib -Lnative=${SDK_PATH}/arch/arm64/lib" +export CFLAGS_x86_64_unknown_fuchsia="--target=x86_64-unknown-fuchsia --sysroot=${SDK_PATH}/arch/x64/sysroot -I${SDK_PATH}/pkg/fdio/include" +export CXXFLAGS_x86_64_unknown_fuchsia="--target=x86_64-unknown-fuchsia --sysroot=${SDK_PATH}/arch/x64/sysroot -I${SDK_PATH}/pkg/fdio/include" +export LDFLAGS_x86_64_unknown_fuchsia="--target=x86_64-unknown-fuchsia --sysroot=${SDK_PATH}/arch/x64/sysroot -L${SDK_PATH}/arch/x64/lib" +export CARGO_TARGET_X86_64_UNKNOWN_FUCHSIA_RUSTFLAGS="-C link-arg=--sysroot=${SDK_PATH}/arch/x64/sysroot -Lnative=${SDK_PATH}/arch/x64/sysroot/lib -Lnative=${SDK_PATH}/arch/x64/lib" ``` Finally, the Rust compiler can be built and installed: @@ -285,7 +288,7 @@ hello_fuchsia/ Using your freshly installed `rustc`, you can compile a binary for Fuchsia using the following options: -* `--target x86_64-fuchsia`/`--target aarch64-fuchsia`: Targets the Fuchsia +* `--target x86_64-unknown-fuchsia`/`--target aarch64-unknown-fuchsia`: Targets the Fuchsia platform of your choice * `-Lnative ${SDK_PATH}/arch/${ARCH}/lib`: Link against Fuchsia libraries from the SDK @@ -296,7 +299,7 @@ Putting it all together: ```sh # Configure these for the Fuchsia target of your choice -TARGET_ARCH="<x86_64-fuchsia|aarch64-fuchsia>" +TARGET_ARCH="<x86_64-unknown-fuchsia|aarch64-unknown-fuchsia>" ARCH="<x64|aarch64>" rustc \ @@ -322,16 +325,16 @@ Before moving on, double check your directory structure: **Current directory structure** ```txt hello_fuchsia/ -┣━ src/ (if using rustc) -┃ ┗━ hello_fuchsia.rs ... -┣━ bin/ ... -┃ ┗━ hello_fuchsia ... -┣━ src/ (if using cargo) -┃ ┗━ main.rs ... -┗━ target/ ... - ┗━ x86_64-fuchsia/ ... - ┗━ debug/ ... - ┗━ hello_fuchsia ... +┣━ src/ (if using rustc) +┃ ┗━ hello_fuchsia.rs ... +┣━ bin/ ... +┃ ┗━ hello_fuchsia ... +┣━ src/ (if using cargo) +┃ ┗━ main.rs ... +┗━ target/ ... + ┗━ x86_64-unknown-fuchsia/ ... + ┗━ debug/ ... + ┗━ hello_fuchsia ... ``` With our Rust binary built, we can move to creating a Fuchsia package. @@ -368,7 +371,7 @@ package must contain one. **`pkg/hello_fuchsia.manifest` if using cargo** ```txt -bin/hello_fuchsia=target/x86_64-fuchsia/debug/hello_fuchsia +bin/hello_fuchsia=target/x86_64-unknown-fuchsia/debug/hello_fuchsia lib/ld.so.1=<SDK_PATH>/arch/x64/sysroot/dist/lib/ld.so.1 lib/libfdio.so=<SDK_PATH>/arch/x64/dist/libfdio.so meta/package=pkg/meta/package @@ -543,16 +546,16 @@ structure will look like: **Final directory structure** ```txt hello_fuchsia/ -┣━ src/ (if using rustc) -┃ ┗━ hello_fuchsia.rs ... -┣━ bin/ ... -┃ ┗━ hello_fuchsia ... -┣━ src/ (if using cargo) -┃ ┗━ main.rs ... -┣━ target/ ... -┃ ┗━ x86_64-fuchsia/ ... -┃ ┗━ debug/ ... -┃ ┗━ hello_fuchsia ... +┣━ src/ (if using rustc) +┃ ┗━ hello_fuchsia.rs ... +┣━ bin/ ... +┃ ┗━ hello_fuchsia ... +┣━ src/ (if using cargo) +┃ ┗━ main.rs ... +┣━ target/ ... +┃ ┗━ x86_64-unknown-fuchsia/ ... +┃ ┗━ debug/ ... +┃ ┗━ hello_fuchsia ... ┗━ pkg/ ┣━ meta/ ┃ ┣━ package @@ -641,8 +644,8 @@ Tests can be run in the same way as a regular binary. * If using `cargo`, you can simply pass `test --no-run` to the `cargo` invocation and then repackage and rerun the Fuchsia package. From our previous example, -this would look like `cargo test --target x86_64-fuchsia --no-run`, and moving the executable -binary path found from the line `Executable unittests src/main.rs (target/x86_64-fuchsia/debug/deps/hello_fuchsia-<HASH>)` +this would look like `cargo test --target x86_64-unknown-fuchsia --no-run`, and moving the executable +binary path found from the line `Executable unittests src/main.rs (target/x86_64-unknown-fuchsia/debug/deps/hello_fuchsia-<HASH>)` into `pkg/hello_fuchsia.manifest`. * If using the compiled `rustc`, you can simply pass `--test` @@ -711,7 +714,7 @@ run the full `src/test/ui` test suite: --config config.toml \ --stage=2 \ test src/test/ui \ - --target x86_64-fuchsia \ + --target x86_64-unknown-fuchsia \ --run=always --jobs 1 \ --test-args --target-rustcflags \ --test-args -L \ @@ -755,7 +758,7 @@ directory to launch `zxdb`: **In separate terminal** ```sh ${SDK_PATH}/tools/${ARCH}/ffx debug connect -- \ - --symbol-path target/x86_64-fuchsia/debug + --symbol-path target/x86_64-unknown-fuchsia/debug ``` * `--symbol-path` gets required symbol paths, which are @@ -851,7 +854,7 @@ source code: ```sh ${SDK_PATH}/tools/${ARCH}/ffx debug connect -- \ - --symbol-path target/x86_64-fuchsia/debug \ + --symbol-path target/x86_64-unknown-fuchsia/debug \ --build-dir ${RUST_SRC_PATH}/rust \ --build-dir ${FUCHSIA_SRC_PATH}/fuchsia/out/default ``` diff --git a/src/doc/unstable-book/src/compiler-flags/dump-mono-stats-format.md b/src/doc/unstable-book/src/compiler-flags/dump-mono-stats-format.md new file mode 100644 index 00000000000..a497a75261f --- /dev/null +++ b/src/doc/unstable-book/src/compiler-flags/dump-mono-stats-format.md @@ -0,0 +1,6 @@ +# `dump-mono-stats-format` + +-------------------- + +The `-Z dump-mono-stats-format` compiler flag controls what file format to use for `-Z dump-mono-stats`. +The default is markdown; currently JSON is also supported. JSON can be useful for programatically manipulating the results (e.g. to find the item that took the longest to compile). diff --git a/src/doc/unstable-book/src/compiler-flags/dump-mono-stats.md b/src/doc/unstable-book/src/compiler-flags/dump-mono-stats.md new file mode 100644 index 00000000000..4c8bc8b4578 --- /dev/null +++ b/src/doc/unstable-book/src/compiler-flags/dump-mono-stats.md @@ -0,0 +1,14 @@ +# `dump-mono-stats` + +-------------------- + +The `-Z dump-mono-stats` compiler flag generates a file with a list of the monomorphized items in the current crate. +It is useful for investigating compile times. + +It accepts an optional directory where the file will be located. If no directory is specified, the file will be placed in the current directory. + +See also `-Z dump-mono-stats-format` and `-Z print-mono-items`. Unlike `print-mono-items`, +`dump-mono-stats` aggregates monomorphized items by definition and includes a size estimate of how +large the item is when codegened. + +See <https://rustc-dev-guide.rust-lang.org/backend/monomorph.html> for an overview of monomorphized items. diff --git a/src/doc/unstable-book/src/compiler-flags/sanitizer.md b/src/doc/unstable-book/src/compiler-flags/sanitizer.md index a9616c34bff..70c3a445b86 100644 --- a/src/doc/unstable-book/src/compiler-flags/sanitizer.md +++ b/src/doc/unstable-book/src/compiler-flags/sanitizer.md @@ -50,10 +50,10 @@ with runtime flag `ASAN_OPTIONS=detect_leaks=1` on macOS. AddressSanitizer is supported on the following targets: * `aarch64-apple-darwin` -* `aarch64-fuchsia` +* `aarch64-unknown-fuchsia` * `aarch64-unknown-linux-gnu` * `x86_64-apple-darwin` -* `x86_64-fuchsia` +* `x86_64-unknown-fuchsia` * `x86_64-unknown-freebsd` * `x86_64-unknown-linux-gnu` diff --git a/src/etc/pre-push.sh b/src/etc/pre-push.sh index 2a3086338b4..7a846d44ad6 100755 --- a/src/etc/pre-push.sh +++ b/src/etc/pre-push.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Call `tidy --bless` before git push +# Call `tidy` before git push # Copy this script to .git/hooks to activate, # and remove it from .git/hooks to deactivate. # diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 07a9c48365f..025a4379f45 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1960,7 +1960,6 @@ pub(crate) fn clean_variant_def<'tcx>(variant: &ty::VariantDef, cx: &mut DocCont variant.fields.iter().map(|field| clean_middle_field(field, cx)).collect(), ), None => VariantKind::Struct(VariantStruct { - ctor_kind: None, fields: variant.fields.iter().map(|field| clean_middle_field(field, cx)).collect(), }), }; @@ -1985,7 +1984,6 @@ fn clean_variant_data<'tcx>( let kind = match variant { hir::VariantData::Struct(..) => VariantKind::Struct(VariantStruct { - ctor_kind: None, fields: variant.fields().iter().map(|x| clean_field(x, cx)).collect(), }), hir::VariantData::Tuple(..) => { diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 77ec0242621..827afafbba3 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -2111,7 +2111,6 @@ impl Union { /// only as a variant in an enum. #[derive(Clone, Debug)] pub(crate) struct VariantStruct { - pub(crate) ctor_kind: Option<CtorKind>, pub(crate) fields: Vec<Item>, } @@ -2495,6 +2494,17 @@ impl Import { pub(crate) fn new_glob(source: ImportSource, should_be_displayed: bool) -> Self { Self { kind: ImportKind::Glob, source, should_be_displayed } } + + pub(crate) fn imported_item_is_doc_hidden(&self, tcx: TyCtxt<'_>) -> bool { + match self.source.did { + Some(did) => tcx + .get_attrs(did, sym::doc) + .filter_map(ast::Attribute::meta_item_list) + .flatten() + .has_word(sym::hidden), + None => false, + } + } } #[derive(Clone, Debug)] diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index d4d3e4f6ea7..c8899ee62b5 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -309,7 +309,7 @@ impl<'tcx> Context<'tcx> { pub(crate) fn href_from_span(&self, span: clean::Span, with_lines: bool) -> Option<String> { let mut root = self.root_path(); - let mut path = String::new(); + let mut path: String; let cnum = span.cnum(self.sess()); // We can safely ignore synthetic `SourceFile`s. @@ -340,10 +340,24 @@ impl<'tcx> Context<'tcx> { ExternalLocation::Unknown => return None, }; - sources::clean_path(&src_root, file, false, |component| { - path.push_str(&component.to_string_lossy()); + let href = RefCell::new(PathBuf::new()); + sources::clean_path( + &src_root, + file, + |component| { + href.borrow_mut().push(component); + }, + || { + href.borrow_mut().pop(); + }, + ); + + path = href.into_inner().to_string_lossy().to_string(); + + if let Some(c) = path.as_bytes().last() && *c != b'/' { path.push('/'); - }); + } + let mut fname = file.file_name().expect("source has no filename").to_os_string(); fname.push(".html"); path.push_str(&fname.to_string_lossy()); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 40dfb069750..c16d6477fc3 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -1229,16 +1229,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean:: w.write_str(")"); } clean::VariantKind::Struct(ref s) => { - render_struct( - w, - v, - None, - s.ctor_kind, - &s.fields, - " ", - false, - cx, - ); + render_struct(w, v, None, None, &s.fields, " ", false, cx); } }, _ => unreachable!(), diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index eaf149a4300..3ea4c4bea88 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -1,8 +1,9 @@ +use std::cell::RefCell; use std::fs::{self, File}; use std::io::prelude::*; use std::io::{self, BufReader}; use std::path::{Component, Path}; -use std::rc::Rc; +use std::rc::{Rc, Weak}; use itertools::Itertools; use rustc_data_structures::flock; @@ -184,23 +185,26 @@ pub(super) fn write_shared( use std::ffi::OsString; - #[derive(Debug)] + #[derive(Debug, Default)] struct Hierarchy { + parent: Weak<Self>, elem: OsString, - children: FxHashMap<OsString, Hierarchy>, - elems: FxHashSet<OsString>, + children: RefCell<FxHashMap<OsString, Rc<Self>>>, + elems: RefCell<FxHashSet<OsString>>, } impl Hierarchy { - fn new(elem: OsString) -> Hierarchy { - Hierarchy { elem, children: FxHashMap::default(), elems: FxHashSet::default() } + fn with_parent(elem: OsString, parent: &Rc<Self>) -> Self { + Self { elem, parent: Rc::downgrade(parent), ..Self::default() } } fn to_json_string(&self) -> String { - let mut subs: Vec<&Hierarchy> = self.children.values().collect(); + let borrow = self.children.borrow(); + let mut subs: Vec<_> = borrow.values().collect(); subs.sort_unstable_by(|a, b| a.elem.cmp(&b.elem)); let mut files = self .elems + .borrow() .iter() .map(|s| format!("\"{}\"", s.to_str().expect("invalid osstring conversion"))) .collect::<Vec<_>>(); @@ -220,36 +224,52 @@ pub(super) fn write_shared( files = files ) } - } - if cx.include_sources { - let mut hierarchy = Hierarchy::new(OsString::new()); - for source in cx - .shared - .local_sources - .iter() - .filter_map(|p| p.0.strip_prefix(&cx.shared.src_root).ok()) - { - let mut h = &mut hierarchy; - let mut elems = source + fn add_path(self: &Rc<Self>, path: &Path) { + let mut h = Rc::clone(&self); + let mut elems = path .components() .filter_map(|s| match s { Component::Normal(s) => Some(s.to_owned()), + Component::ParentDir => Some(OsString::from("..")), _ => None, }) .peekable(); loop { let cur_elem = elems.next().expect("empty file path"); + if cur_elem == ".." { + if let Some(parent) = h.parent.upgrade() { + h = parent; + } + continue; + } if elems.peek().is_none() { - h.elems.insert(cur_elem); + h.elems.borrow_mut().insert(cur_elem); break; } else { - let e = cur_elem.clone(); - h = h.children.entry(cur_elem.clone()).or_insert_with(|| Hierarchy::new(e)); + let entry = Rc::clone( + h.children + .borrow_mut() + .entry(cur_elem.clone()) + .or_insert_with(|| Rc::new(Self::with_parent(cur_elem, &h))), + ); + h = entry; } } } + } + if cx.include_sources { + let hierarchy = Rc::new(Hierarchy::default()); + for source in cx + .shared + .local_sources + .iter() + .filter_map(|p| p.0.strip_prefix(&cx.shared.src_root).ok()) + { + hierarchy.add_path(source); + } + let hierarchy = Rc::try_unwrap(hierarchy).unwrap(); let dst = cx.dst.join(&format!("source-files{}.js", cx.shared.resource_suffix)); let make_sources = || { let (mut all_sources, _krates) = diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index e639fadeb96..799c497d137 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -13,6 +13,7 @@ use rustc_middle::ty::TyCtxt; use rustc_session::Session; use rustc_span::source_map::FileName; +use std::cell::RefCell; use std::ffi::OsStr; use std::fs; use std::path::{Component, Path, PathBuf}; @@ -72,12 +73,22 @@ impl LocalSourcesCollector<'_, '_> { return; } - let mut href = String::new(); - clean_path(self.src_root, &p, false, |component| { - href.push_str(&component.to_string_lossy()); - href.push('/'); - }); + let href = RefCell::new(PathBuf::new()); + clean_path( + &self.src_root, + &p, + |component| { + href.borrow_mut().push(component); + }, + || { + href.borrow_mut().pop(); + }, + ); + let mut href = href.into_inner().to_string_lossy().to_string(); + if let Some(c) = href.as_bytes().last() && *c != b'/' { + href.push('/'); + } let mut src_fname = p.file_name().expect("source has no filename").to_os_string(); src_fname.push(".html"); href.push_str(&src_fname.to_string_lossy()); @@ -180,13 +191,28 @@ impl SourceCollector<'_, '_> { let shared = Rc::clone(&self.cx.shared); // Create the intermediate directories - let mut cur = self.dst.clone(); - let mut root_path = String::from("../../"); - clean_path(&shared.src_root, &p, false, |component| { - cur.push(component); - root_path.push_str("../"); - }); + let cur = RefCell::new(PathBuf::new()); + let root_path = RefCell::new(PathBuf::new()); + + clean_path( + &shared.src_root, + &p, + |component| { + cur.borrow_mut().push(component); + root_path.borrow_mut().push(".."); + }, + || { + cur.borrow_mut().pop(); + root_path.borrow_mut().pop(); + }, + ); + let root_path = PathBuf::from("../../").join(root_path.into_inner()); + let mut root_path = root_path.to_string_lossy(); + if let Some(c) = root_path.as_bytes().last() && *c != b'/' { + root_path += "/"; + } + let mut cur = self.dst.join(cur.into_inner()); shared.ensure_dir(&cur)?; let src_fname = p.file_name().expect("source has no filename").to_os_string(); @@ -232,11 +258,13 @@ impl SourceCollector<'_, '_> { /// Takes a path to a source file and cleans the path to it. This canonicalizes /// things like ".." to components which preserve the "top down" hierarchy of a /// static HTML tree. Each component in the cleaned path will be passed as an -/// argument to `f`. The very last component of the path (ie the file name) will -/// be passed to `f` if `keep_filename` is true, and ignored otherwise. -pub(crate) fn clean_path<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F) +/// argument to `f`. The very last component of the path (ie the file name) is ignored. +/// If a `..` is encountered, the `parent` closure will be called to allow the callee to +/// handle it. +pub(crate) fn clean_path<F, P>(src_root: &Path, p: &Path, mut f: F, mut parent: P) where F: FnMut(&OsStr), + P: FnMut(), { // make it relative, if possible let p = p.strip_prefix(src_root).unwrap_or(p); @@ -244,12 +272,12 @@ where let mut iter = p.components().peekable(); while let Some(c) = iter.next() { - if !keep_filename && iter.peek().is_none() { + if iter.peek().is_none() { break; } match c { - Component::ParentDir => f("up".as_ref()), + Component::ParentDir => parent(), Component::Normal(c) => f(c), _ => continue, } diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index bc0458bcd28..77401e8b76e 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -76,8 +76,6 @@ } * { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; box-sizing: border-box; } @@ -110,11 +108,7 @@ body { /* Then override it with `anywhere`, which is required to make non-Safari browsers break more aggressively when we want them to. */ overflow-wrap: anywhere; - - -webkit-font-feature-settings: "kern", "liga"; - -moz-font-feature-settings: "kern", "liga"; font-feature-settings: "kern", "liga"; - background-color: var(--main-background-color); color: var(--main-color); } @@ -358,6 +352,7 @@ img { .sub-logo-container, .logo-container { /* zero text boxes so that computed line height = image height exactly */ line-height: 0; + display: block; } .sub-logo-container { @@ -501,7 +496,7 @@ ul.block, .block li { color: var(--sidebar-link-color); } .sidebar .current, -.sidebar a:hover { +.sidebar a:hover:not(.logo-container) { background-color: var(--sidebar-current-link-background-color); } @@ -543,8 +538,6 @@ ul.block, .block li { overflow: initial; text-align: right; -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; user-select: none; padding: 14px 8px; color: var(--src-line-numbers-span-color); @@ -1374,7 +1367,7 @@ kbd { vertical-align: middle; border: solid 1px var(--border-color); border-radius: 3px; - color: var(--kbd--color); + color: var(--kbd-color); background-color: var(--kbd-background); box-shadow: inset 0 -1px 0 var(--kbd-box-shadow-color); } @@ -1576,7 +1569,7 @@ in storage.js /* Hide the logo and item name from the sidebar. Those are displayed in the mobile-topbar instead. */ - .sidebar .sidebar-logo, + .sidebar .logo-container, .sidebar .location { display: none; } @@ -1605,14 +1598,10 @@ in storage.js .sidebar.shown, .source-sidebar-expanded .source .sidebar, - .sidebar:focus-within { + .rustdoc:not(.source) .sidebar:focus-within { left: 0; } - .rustdoc.source > .sidebar { - width: 0; - } - .mobile-topbar h2 { padding-bottom: 0; margin: auto 0.5em auto auto; @@ -1662,10 +1651,6 @@ in storage.js margin-top: 1em; } - .content { - margin-left: 0px; - } - .anchor { display: none !important; } diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 60e4e749224..51aee8e7c89 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -563,7 +563,7 @@ function loadCss(cssUrl) { onEachLazy(code.getElementsByTagName("a"), elem => { const href = elem.getAttribute("href"); - if (href && href.indexOf("http") !== 0) { + if (href && !/^(?:[a-z+]+:)?\/\//.test(href)) { elem.setAttribute("href", window.rootPath + href); } }); @@ -1040,9 +1040,6 @@ function loadCss(cssUrl) { help_button.appendChild(container); container.onblur = helpBlurHandler; - container.onclick = event => { - event.preventDefault(); - }; help_button.onblur = helpBlurHandler; help_button.children[0].onblur = helpBlurHandler; } diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html index bcaff957af2..fddda293b9a 100644 --- a/src/librustdoc/html/templates/page.html +++ b/src/librustdoc/html/templates/page.html @@ -72,28 +72,24 @@ {%- if page.css_class != "source" -%} <nav class="mobile-topbar"> {#- -#} <button class="sidebar-menu-toggle">☰</button> {#- -#} - <a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#} - <div class="logo-container"> {#- -#} - {%- if !layout.logo.is_empty() -%} - <img src="{{layout.logo}}" alt="logo"> {#- -#} - {%- else -%} - <img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {#- -#} - {%- endif -%} - </div> {#- -#} + <a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#} + {%- if !layout.logo.is_empty() -%} + <img src="{{layout.logo}}" alt="logo"> {#- -#} + {%- else -%} + <img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {#- -#} + {%- endif -%} </a> {#- -#} <h2></h2> {#- -#} </nav> {#- -#} {%- endif -%} <nav class="sidebar"> {#- -#} {%- if page.css_class != "source" -%} - <a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#} - <div class="logo-container"> {#- -#} - {%- if !layout.logo.is_empty() %} - <img src="{{layout.logo}}" alt="logo"> {#- -#} - {%- else -%} - <img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {#- -#} - {%- endif -%} - </div> {#- -#} + <a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#} + {%- if !layout.logo.is_empty() %} + <img src="{{layout.logo}}" alt="logo"> {#- -#} + {%- else -%} + <img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {#- -#} + {%- endif -%} </a> {#- -#} {%- endif -%} {{- sidebar|safe -}} diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 84af194904d..56283b2c0ef 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -8,8 +8,9 @@ use std::convert::From; use std::fmt; use rustc_ast::ast; -use rustc_hir::{def::CtorKind, def_id::DefId}; +use rustc_hir::{def::CtorKind, def::DefKind, def_id::DefId}; use rustc_middle::ty::{self, TyCtxt}; +use rustc_span::symbol::sym; use rustc_span::{Pos, Symbol}; use rustc_target::spec::abi::Abi as RustcAbi; @@ -217,13 +218,27 @@ pub(crate) fn from_item_id_with_name(item_id: ItemId, tcx: TyCtxt<'_>, name: Opt impl<'a> fmt::Display for DisplayDefId<'a> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let name = match self.2 { + let DisplayDefId(def_id, tcx, name) = self; + let name = match name { Some(name) => format!(":{}", name.as_u32()), - None => self - .1 - .opt_item_name(self.0) - .map(|n| format!(":{}", n.as_u32())) - .unwrap_or_default(), + None => { + // We need this workaround because primitive types' DefId actually refers to + // their parent module, which isn't present in the output JSON items. So + // instead, we directly get the primitive symbol and convert it to u32 to + // generate the ID. + if matches!(tcx.def_kind(def_id), DefKind::Mod) && + let Some(prim) = tcx.get_attrs(*def_id, sym::doc) + .flat_map(|attr| attr.meta_item_list().unwrap_or_default()) + .filter(|attr| attr.has_name(sym::primitive)) + .find_map(|attr| attr.value_str()) { + format!(":{}", prim.as_u32()) + } else { + tcx + .opt_item_name(*def_id) + .map(|n| format!(":{}", n.as_u32())) + .unwrap_or_default() + } + } }; write!(f, "{}:{}{}", self.0.krate.as_u32(), u32::from(self.0.index), name) } @@ -237,7 +252,7 @@ pub(crate) fn from_item_id_with_name(item_id: ItemId, tcx: TyCtxt<'_>, name: Opt ItemId::Auto { for_, trait_ } => { Id(format!("a:{}-{}", DisplayDefId(trait_, tcx, None), DisplayDefId(for_, tcx, name))) } - ItemId::Primitive(ty, krate) => Id(format!("p:{}:{}", krate.as_u32(), ty.as_sym())), + ItemId::Primitive(_, _) => unreachable!(), } } diff --git a/src/librustdoc/passes/check_doc_test_visibility.rs b/src/librustdoc/passes/check_doc_test_visibility.rs index 057d2fdd9d5..6aa2dda980c 100644 --- a/src/librustdoc/passes/check_doc_test_visibility.rs +++ b/src/librustdoc/passes/check_doc_test_visibility.rs @@ -82,7 +82,7 @@ pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) - let hir_id = cx.tcx.hir().local_def_id_to_hir_id(item.item_id.expect_def_id().expect_local()); // check if parent is trait impl - if let Some(parent_hir_id) = cx.tcx.hir().find_parent_node(hir_id) { + if let Some(parent_hir_id) = cx.tcx.hir().opt_parent_id(hir_id) { if let Some(parent_node) = cx.tcx.hir().find(parent_hir_id) { if matches!( parent_node, diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index bf111133b9f..f8a0d77538d 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -248,6 +248,7 @@ pub(crate) struct ImportStripper<'tcx> { impl<'tcx> DocFolder for ImportStripper<'tcx> { fn fold_item(&mut self, i: Item) -> Option<Item> { match *i.kind { + clean::ImportItem(imp) if imp.imported_item_is_doc_hidden(self.tcx) => None, clean::ExternCrateItem { .. } | clean::ImportItem(..) if i.visibility(self.tcx) != Some(Visibility::Public) => { diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 310a01194ea..7db47035967 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -410,7 +410,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { /// This method will create a new module and push it onto the "modules stack" then call /// `visit_mod_contents`. Once done, it'll remove it from the "modules stack" and instead - /// add into into the list of modules of the current module. + /// add into the list of modules of the current module. fn enter_mod(&mut self, id: hir::HirId, m: &'tcx hir::Mod<'tcx>, name: Symbol) { self.modules.push(Module::new(name, id, m.spans.inner_span)); diff --git a/src/test/assembly/stack-protector/stack-protector-target-support.rs b/src/test/assembly/stack-protector/stack-protector-target-support.rs index 2fb62e93ea3..d5b48105ef2 100644 --- a/src/test/assembly/stack-protector/stack-protector-target-support.rs +++ b/src/test/assembly/stack-protector/stack-protector-target-support.rs @@ -26,7 +26,7 @@ // [r9] needs-llvm-components: aarch64 // [r10] compile-flags: --target aarch64-apple-ios // [r10] needs-llvm-components: aarch64 -// [r11] compile-flags: --target aarch64-fuchsia +// [r11] compile-flags: --target aarch64-unknown-fuchsia // [r11] needs-llvm-components: aarch64 // [r12] compile-flags: --target aarch64-linux-android // [r12] needs-llvm-components: aarch64 @@ -156,7 +156,7 @@ // [r74] needs-llvm-components: x86 // [r75] compile-flags:--target x86_64-fortanix-unknown-sgx // [r75] needs-llvm-components: x86 -// [r76] compile-flags:--target x86_64-fuchsia +// [r76] compile-flags:--target x86_64-unknown-fuchsia // [r76] needs-llvm-components: x86 // [r77] compile-flags:--target x86_64-linux-android // [r77] needs-llvm-components: x86 diff --git a/src/test/codegen/box-maybe-uninit-llvm14.rs b/src/test/codegen/box-maybe-uninit-llvm14.rs index bd1a6599c33..7b5ae894311 100644 --- a/src/test/codegen/box-maybe-uninit-llvm14.rs +++ b/src/test/codegen/box-maybe-uninit-llvm14.rs @@ -2,7 +2,7 @@ // Once we're done with llvm 14 and earlier, this test can be deleted. -#![crate_type="lib"] +#![crate_type = "lib"] use std::mem::MaybeUninit; @@ -17,8 +17,16 @@ pub fn box_uninitialized() -> Box<MaybeUninit<usize>> { Box::new(MaybeUninit::uninit()) } -// FIXME: add a test for a bigger box. Currently broken, see -// https://github.com/rust-lang/rust/issues/58201. +// https://github.com/rust-lang/rust/issues/58201 +#[no_mangle] +pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> { + // CHECK-LABEL: @box_uninitialized2 + // CHECK-NOT: store + // CHECK-NOT: alloca + // CHECK-NOT: memcpy + // CHECK-NOT: memset + Box::new(MaybeUninit::uninit()) +} // Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above. We don't check the attributes here because we can't rely diff --git a/src/test/codegen/box-maybe-uninit.rs b/src/test/codegen/box-maybe-uninit.rs index e105e26f16a..c82b56a71f5 100644 --- a/src/test/codegen/box-maybe-uninit.rs +++ b/src/test/codegen/box-maybe-uninit.rs @@ -1,6 +1,6 @@ // compile-flags: -O // min-llvm-version: 15.0 -#![crate_type="lib"] +#![crate_type = "lib"] use std::mem::MaybeUninit; @@ -15,8 +15,16 @@ pub fn box_uninitialized() -> Box<MaybeUninit<usize>> { Box::new(MaybeUninit::uninit()) } -// FIXME: add a test for a bigger box. Currently broken, see -// https://github.com/rust-lang/rust/issues/58201. +// https://github.com/rust-lang/rust/issues/58201 +#[no_mangle] +pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> { + // CHECK-LABEL: @box_uninitialized2 + // CHECK-NOT: store + // CHECK-NOT: alloca + // CHECK-NOT: memcpy + // CHECK-NOT: memset + Box::new(MaybeUninit::uninit()) +} // Hide the `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above, and also verify the attributes got set reasonably. diff --git a/src/test/codegen/issue-86106.rs b/src/test/codegen/issue-86106.rs new file mode 100644 index 00000000000..9ccbcb24f56 --- /dev/null +++ b/src/test/codegen/issue-86106.rs @@ -0,0 +1,62 @@ +// min-llvm-version: 15.0 +// compile-flags: -C opt-level=3 -Z merge-functions=disabled + +// The below two functions ensure that both `String::new()` and `"".to_string()` +// produce the identical code. + +#![crate_type = "lib"] + +// CHECK-LABEL: define void @string_new +#[no_mangle] +pub fn string_new() -> String { + // CHECK-NOT: load i8 + // CHECK: store i{{32|64}} + // CHECK-NEXT: getelementptr + // CHECK-NEXT: store ptr + // CHECK-NEXT: getelementptr + // CHECK-NEXT: store i{{32|64}} + // CHECK-NEXT: ret void + String::new() +} + +// CHECK-LABEL: define void @empty_to_string +#[no_mangle] +pub fn empty_to_string() -> String { + // CHECK-NOT: load i8 + // CHECK: store i{{32|64}} + // CHECK-NEXT: getelementptr + // CHECK-NEXT: store ptr + // CHECK-NEXT: getelementptr + // CHECK-NEXT: store i{{32|64}} + // CHECK-NEXT: ret void + "".to_string() +} + +// The below two functions ensure that both `vec![]` and `vec![].clone()` +// produce the identical code. + +// CHECK-LABEL: @empty_vec +#[no_mangle] +pub fn empty_vec() -> Vec<u8> { + // CHECK: store i{{32|64}} + // CHECK-NOT: load i8 + // CHECK-NEXT: getelementptr + // CHECK-NEXT: store ptr + // CHECK-NEXT: getelementptr + // CHECK-NEXT: store i{{32|64}} + // CHECK-NEXT: ret void + vec![] +} + +// CHECK-LABEL: @empty_vec_clone +#[no_mangle] +pub fn empty_vec_clone() -> Vec<u8> { + // CHECK: store i{{32|64}} + // CHECK-NOT: load i8 + // CHECK-NEXT: getelementptr + // CHECK-NEXT: store ptr + // CHECK-NEXT: getelementptr + // CHECK-NEXT: store i{{32|64}} + // CHECK-NEXT: ret void + vec![].clone() +} diff --git a/src/test/codegen/noalias-flag.rs b/src/test/codegen/noalias-flag.rs new file mode 100644 index 00000000000..a9ec61e286d --- /dev/null +++ b/src/test/codegen/noalias-flag.rs @@ -0,0 +1,23 @@ +// compile-flags: -O -Zmutable-noalias=no + +#![crate_type = "lib"] + +// `-Zmutable-noalias=no` should disable noalias on mut refs... + +// CHECK-LABEL: @test_mut_ref( +// CHECK-NOT: noalias +// CHECK-SAME: %x +#[no_mangle] +pub fn test_mut_ref(x: &mut i32) -> &mut i32 { + x +} + +// ...but not on shared refs + +// CHECK-LABEL: @test_ref( +// CHECK-SAME: noalias +// CHECK-SAME: %x +#[no_mangle] +pub fn test_ref(x: &i32) -> &i32 { + x +} diff --git a/src/test/codegen/zst-offset.rs b/src/test/codegen/zst-offset.rs index 29d2a1754a3..844d5870a84 100644 --- a/src/test/codegen/zst-offset.rs +++ b/src/test/codegen/zst-offset.rs @@ -15,7 +15,7 @@ pub fn helper(_: usize) { pub fn scalar_layout(s: &(u64, ())) { // CHECK: getelementptr i8, {{.+}}, [[USIZE]] 8 let x = &s.1; - &x; // keep variable in an alloca + witness(&x); // keep variable in an alloca } // Check that we correctly generate a GEP for a ZST that is not included in ScalarPair layout @@ -24,7 +24,7 @@ pub fn scalar_layout(s: &(u64, ())) { pub fn scalarpair_layout(s: &(u64, u32, ())) { // CHECK: getelementptr i8, {{.+}}, [[USIZE]] 12 let x = &s.2; - &x; // keep variable in an alloca + witness(&x); // keep variable in an alloca } #[repr(simd)] @@ -36,5 +36,8 @@ pub struct U64x4(u64, u64, u64, u64); pub fn vector_layout(s: &(U64x4, ())) { // CHECK: getelementptr i8, {{.+}}, [[USIZE]] 32 let x = &s.1; - &x; // keep variable in an alloca + witness(&x); // keep variable in an alloca } + +#[inline(never)] +fn witness(_: &impl Sized) {} diff --git a/src/test/incremental/hashes/closure_expressions.rs b/src/test/incremental/hashes/closure_expressions.rs index 7bf99f6112e..927bcd96e6f 100644 --- a/src/test/incremental/hashes/closure_expressions.rs +++ b/src/test/incremental/hashes/closure_expressions.rs @@ -42,9 +42,9 @@ pub fn add_parameter() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")] +#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")] +#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, typeck")] #[rustc_clean(cfg="cfail6")] pub fn add_parameter() { let x = 0u32; diff --git a/src/test/mir-opt/const_allocation.main.ConstProp.after.32bit.mir b/src/test/mir-opt/const_allocation.main.ConstProp.after.32bit.mir index da5a64cac65..6140fc52f65 100644 --- a/src/test/mir-opt/const_allocation.main.ConstProp.after.32bit.mir +++ b/src/test/mir-opt/const_allocation.main.ConstProp.after.32bit.mir @@ -10,12 +10,12 @@ fn main() -> () { StorageLive(_2); // scope 0 at $DIR/const_allocation.rs:+1:5: +1:8 _2 = const {alloc1: &&[(Option<i32>, &[&str])]}; // scope 0 at $DIR/const_allocation.rs:+1:5: +1:8 // mir::Constant - // + span: $DIR/const_allocation.rs:8:5: 8:8 + // + span: $DIR/const_allocation.rs:9:5: 9:8 // + literal: Const { ty: &&[(Option<i32>, &[&str])], val: Value(Scalar(alloc1)) } _1 = (*_2); // scope 0 at $DIR/const_allocation.rs:+1:5: +1:8 StorageDead(_2); // scope 0 at $DIR/const_allocation.rs:+1:8: +1:9 StorageDead(_1); // scope 0 at $DIR/const_allocation.rs:+1:8: +1:9 - nop; // scope 0 at $DIR/const_allocation.rs:+0:11: +2:2 + _0 = const (); // scope 0 at $DIR/const_allocation.rs:+0:11: +2:2 return; // scope 0 at $DIR/const_allocation.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/const_allocation.main.ConstProp.after.64bit.mir b/src/test/mir-opt/const_allocation.main.ConstProp.after.64bit.mir index febd990681e..b2ed23c6873 100644 --- a/src/test/mir-opt/const_allocation.main.ConstProp.after.64bit.mir +++ b/src/test/mir-opt/const_allocation.main.ConstProp.after.64bit.mir @@ -10,12 +10,12 @@ fn main() -> () { StorageLive(_2); // scope 0 at $DIR/const_allocation.rs:+1:5: +1:8 _2 = const {alloc1: &&[(Option<i32>, &[&str])]}; // scope 0 at $DIR/const_allocation.rs:+1:5: +1:8 // mir::Constant - // + span: $DIR/const_allocation.rs:8:5: 8:8 + // + span: $DIR/const_allocation.rs:9:5: 9:8 // + literal: Const { ty: &&[(Option<i32>, &[&str])], val: Value(Scalar(alloc1)) } _1 = (*_2); // scope 0 at $DIR/const_allocation.rs:+1:5: +1:8 StorageDead(_2); // scope 0 at $DIR/const_allocation.rs:+1:8: +1:9 StorageDead(_1); // scope 0 at $DIR/const_allocation.rs:+1:8: +1:9 - nop; // scope 0 at $DIR/const_allocation.rs:+0:11: +2:2 + _0 = const (); // scope 0 at $DIR/const_allocation.rs:+0:11: +2:2 return; // scope 0 at $DIR/const_allocation.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/const_allocation.rs b/src/test/mir-opt/const_allocation.rs index b0fcb86fcee..91a2455eb83 100644 --- a/src/test/mir-opt/const_allocation.rs +++ b/src/test/mir-opt/const_allocation.rs @@ -1,3 +1,4 @@ +// unit-test: ConstProp // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH static FOO: &[(Option<i32>, &[&str])] = diff --git a/src/test/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir b/src/test/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir index 389641f20f4..aab005c52d6 100644 --- a/src/test/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir +++ b/src/test/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir @@ -10,12 +10,12 @@ fn main() -> () { StorageLive(_2); // scope 0 at $DIR/const_allocation2.rs:+1:5: +1:8 _2 = const {alloc1: &&[(Option<i32>, &[&u8])]}; // scope 0 at $DIR/const_allocation2.rs:+1:5: +1:8 // mir::Constant - // + span: $DIR/const_allocation2.rs:5:5: 5:8 + // + span: $DIR/const_allocation2.rs:6:5: 6:8 // + literal: Const { ty: &&[(Option<i32>, &[&u8])], val: Value(Scalar(alloc1)) } _1 = (*_2); // scope 0 at $DIR/const_allocation2.rs:+1:5: +1:8 StorageDead(_2); // scope 0 at $DIR/const_allocation2.rs:+1:8: +1:9 StorageDead(_1); // scope 0 at $DIR/const_allocation2.rs:+1:8: +1:9 - nop; // scope 0 at $DIR/const_allocation2.rs:+0:11: +2:2 + _0 = const (); // scope 0 at $DIR/const_allocation2.rs:+0:11: +2:2 return; // scope 0 at $DIR/const_allocation2.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir b/src/test/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir index ce3848e9216..0eff9474c20 100644 --- a/src/test/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir +++ b/src/test/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir @@ -10,12 +10,12 @@ fn main() -> () { StorageLive(_2); // scope 0 at $DIR/const_allocation2.rs:+1:5: +1:8 _2 = const {alloc1: &&[(Option<i32>, &[&u8])]}; // scope 0 at $DIR/const_allocation2.rs:+1:5: +1:8 // mir::Constant - // + span: $DIR/const_allocation2.rs:5:5: 5:8 + // + span: $DIR/const_allocation2.rs:6:5: 6:8 // + literal: Const { ty: &&[(Option<i32>, &[&u8])], val: Value(Scalar(alloc1)) } _1 = (*_2); // scope 0 at $DIR/const_allocation2.rs:+1:5: +1:8 StorageDead(_2); // scope 0 at $DIR/const_allocation2.rs:+1:8: +1:9 StorageDead(_1); // scope 0 at $DIR/const_allocation2.rs:+1:8: +1:9 - nop; // scope 0 at $DIR/const_allocation2.rs:+0:11: +2:2 + _0 = const (); // scope 0 at $DIR/const_allocation2.rs:+0:11: +2:2 return; // scope 0 at $DIR/const_allocation2.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/const_allocation2.rs b/src/test/mir-opt/const_allocation2.rs index 30afedffb39..f2870aa47c5 100644 --- a/src/test/mir-opt/const_allocation2.rs +++ b/src/test/mir-opt/const_allocation2.rs @@ -1,3 +1,4 @@ +// unit-test: ConstProp // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR const_allocation2.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir b/src/test/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir index b72519159d7..55c6db5d0ce 100644 --- a/src/test/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir +++ b/src/test/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir @@ -10,12 +10,12 @@ fn main() -> () { StorageLive(_2); // scope 0 at $DIR/const_allocation3.rs:+1:5: +1:8 _2 = const {alloc1: &&Packed}; // scope 0 at $DIR/const_allocation3.rs:+1:5: +1:8 // mir::Constant - // + span: $DIR/const_allocation3.rs:5:5: 5:8 + // + span: $DIR/const_allocation3.rs:6:5: 6:8 // + literal: Const { ty: &&Packed, val: Value(Scalar(alloc1)) } _1 = (*_2); // scope 0 at $DIR/const_allocation3.rs:+1:5: +1:8 StorageDead(_2); // scope 0 at $DIR/const_allocation3.rs:+1:8: +1:9 StorageDead(_1); // scope 0 at $DIR/const_allocation3.rs:+1:8: +1:9 - nop; // scope 0 at $DIR/const_allocation3.rs:+0:11: +2:2 + _0 = const (); // scope 0 at $DIR/const_allocation3.rs:+0:11: +2:2 return; // scope 0 at $DIR/const_allocation3.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir b/src/test/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir index 6bd047c7d9f..27492a7fd22 100644 --- a/src/test/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir +++ b/src/test/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir @@ -10,12 +10,12 @@ fn main() -> () { StorageLive(_2); // scope 0 at $DIR/const_allocation3.rs:+1:5: +1:8 _2 = const {alloc1: &&Packed}; // scope 0 at $DIR/const_allocation3.rs:+1:5: +1:8 // mir::Constant - // + span: $DIR/const_allocation3.rs:5:5: 5:8 + // + span: $DIR/const_allocation3.rs:6:5: 6:8 // + literal: Const { ty: &&Packed, val: Value(Scalar(alloc1)) } _1 = (*_2); // scope 0 at $DIR/const_allocation3.rs:+1:5: +1:8 StorageDead(_2); // scope 0 at $DIR/const_allocation3.rs:+1:8: +1:9 StorageDead(_1); // scope 0 at $DIR/const_allocation3.rs:+1:8: +1:9 - nop; // scope 0 at $DIR/const_allocation3.rs:+0:11: +2:2 + _0 = const (); // scope 0 at $DIR/const_allocation3.rs:+0:11: +2:2 return; // scope 0 at $DIR/const_allocation3.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/const_allocation3.rs b/src/test/mir-opt/const_allocation3.rs index ddeb32ab9a5..da3fd089b02 100644 --- a/src/test/mir-opt/const_allocation3.rs +++ b/src/test/mir-opt/const_allocation3.rs @@ -1,3 +1,4 @@ +// unit-test: ConstProp // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR const_allocation3.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff b/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff index e959e1b2f2c..dd548adde7e 100644 --- a/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff +++ b/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff @@ -8,8 +8,8 @@ let mut _6: u8; // in scope 0 at $DIR/const_debuginfo.rs:+4:15: +4:16 let mut _7: u8; // in scope 0 at $DIR/const_debuginfo.rs:+4:19: +4:20 let mut _8: u8; // in scope 0 at $DIR/const_debuginfo.rs:+4:23: +4:24 - let mut _14: u32; // in scope 0 at $DIR/const_debuginfo.rs:+13:13: +13:16 - let mut _15: u32; // in scope 0 at $DIR/const_debuginfo.rs:+13:19: +13:22 + let mut _12: u32; // in scope 0 at $DIR/const_debuginfo.rs:+13:13: +13:16 + let mut _13: u32; // in scope 0 at $DIR/const_debuginfo.rs:+13:19: +13:22 scope 1 { - debug x => _1; // in scope 1 at $DIR/const_debuginfo.rs:+1:9: +1:10 + debug x => const 1_u8; // in scope 1 at $DIR/const_debuginfo.rs:+1:9: +1:10 @@ -29,23 +29,21 @@ scope 5 { - debug s => _9; // in scope 5 at $DIR/const_debuginfo.rs:+6:9: +6:10 + debug s => const "hello, world!"; // in scope 5 at $DIR/const_debuginfo.rs:+6:9: +6:10 - let _10: (bool, bool, u32); // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 - let _16: bool; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 - let _17: bool; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 - let _18: u32; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 + let _14: bool; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 + let _15: bool; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 + let _16: u32; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 scope 6 { - debug f => (bool, bool, u32){ .0 => _16, .1 => _17, .2 => _18, }; // in scope 6 at $DIR/const_debuginfo.rs:+8:9: +8:10 - let _11: std::option::Option<u16>; // in scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10 + debug f => (bool, bool, u32){ .0 => _14, .1 => _15, .2 => _16, }; // in scope 6 at $DIR/const_debuginfo.rs:+8:9: +8:10 + let _10: std::option::Option<u16>; // in scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10 scope 7 { - debug o => _11; // in scope 7 at $DIR/const_debuginfo.rs:+10:9: +10:10 - let _12: Point; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 - let _19: u32; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 - let _20: u32; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 + debug o => _10; // in scope 7 at $DIR/const_debuginfo.rs:+10:9: +10:10 + let _17: u32; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 + let _18: u32; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 scope 8 { - debug p => Point{ .0 => _19, .1 => _20, }; // in scope 8 at $DIR/const_debuginfo.rs:+12:9: +12:10 - let _13: u32; // in scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10 + debug p => Point{ .0 => _17, .1 => _18, }; // in scope 8 at $DIR/const_debuginfo.rs:+12:9: +12:10 + let _11: u32; // in scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10 scope 9 { -- debug a => _13; // in scope 9 at $DIR/const_debuginfo.rs:+13:9: +13:10 +- debug a => _11; // in scope 9 at $DIR/const_debuginfo.rs:+13:9: +13:10 + debug a => const 64_u32; // in scope 9 at $DIR/const_debuginfo.rs:+13:9: +13:10 } } @@ -83,41 +81,40 @@ // mir::Constant // + span: $DIR/const_debuginfo.rs:14:13: 14:28 // + literal: Const { ty: &str, val: Value(Slice(..)) } + StorageLive(_14); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 + StorageLive(_15); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 StorageLive(_16); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 - StorageLive(_17); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 - StorageLive(_18); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 + Deinit(_14); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 + Deinit(_15); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 Deinit(_16); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 - Deinit(_17); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 - Deinit(_18); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 - _16 = const true; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 - _17 = const false; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 - _18 = const 123_u32; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 - StorageLive(_11); // scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10 - Deinit(_11); // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 - ((_11 as Some).0: u16) = const 99_u16; // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 - discriminant(_11) = 1; // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 - StorageLive(_19); // scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 - StorageLive(_20); // scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 - Deinit(_19); // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 - Deinit(_20); // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 - _19 = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 - _20 = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 - StorageLive(_13); // scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10 - StorageLive(_14); // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:16 - _14 = const 32_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:16 - StorageLive(_15); // scope 8 at $DIR/const_debuginfo.rs:+13:19: +13:22 - _15 = const 32_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:19: +13:22 - _13 = const 64_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:22 - StorageDead(_15); // scope 8 at $DIR/const_debuginfo.rs:+13:21: +13:22 - StorageDead(_14); // scope 8 at $DIR/const_debuginfo.rs:+13:21: +13:22 - nop; // scope 0 at $DIR/const_debuginfo.rs:+0:11: +14:2 - StorageDead(_13); // scope 8 at $DIR/const_debuginfo.rs:+14:1: +14:2 - StorageDead(_19); // scope 7 at $DIR/const_debuginfo.rs:+14:1: +14:2 - StorageDead(_20); // scope 7 at $DIR/const_debuginfo.rs:+14:1: +14:2 - StorageDead(_11); // scope 6 at $DIR/const_debuginfo.rs:+14:1: +14:2 + _14 = const true; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 + _15 = const false; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 + _16 = const 123_u32; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 + StorageLive(_10); // scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10 + Deinit(_10); // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 + ((_10 as Some).0: u16) = const 99_u16; // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 + discriminant(_10) = 1; // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 + StorageLive(_17); // scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 + StorageLive(_18); // scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 + Deinit(_17); // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 + Deinit(_18); // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 + _17 = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 + _18 = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 + StorageLive(_11); // scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10 + StorageLive(_12); // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:16 + _12 = const 32_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:16 + StorageLive(_13); // scope 8 at $DIR/const_debuginfo.rs:+13:19: +13:22 + _13 = const 32_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:19: +13:22 + _11 = const 64_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:22 + StorageDead(_13); // scope 8 at $DIR/const_debuginfo.rs:+13:21: +13:22 + StorageDead(_12); // scope 8 at $DIR/const_debuginfo.rs:+13:21: +13:22 + StorageDead(_11); // scope 8 at $DIR/const_debuginfo.rs:+14:1: +14:2 + StorageDead(_17); // scope 7 at $DIR/const_debuginfo.rs:+14:1: +14:2 + StorageDead(_18); // scope 7 at $DIR/const_debuginfo.rs:+14:1: +14:2 + StorageDead(_10); // scope 6 at $DIR/const_debuginfo.rs:+14:1: +14:2 + StorageDead(_14); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2 + StorageDead(_15); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2 StorageDead(_16); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2 - StorageDead(_17); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2 - StorageDead(_18); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2 StorageDead(_9); // scope 4 at $DIR/const_debuginfo.rs:+14:1: +14:2 StorageDead(_4); // scope 3 at $DIR/const_debuginfo.rs:+14:1: +14:2 StorageDead(_3); // scope 2 at $DIR/const_debuginfo.rs:+14:1: +14:2 diff --git a/src/test/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff b/src/test/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff index 22151304259..8485703e39f 100644 --- a/src/test/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff @@ -45,7 +45,6 @@ - _2 = Rem(const 1_i32, move _3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _2 = Rem(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 StorageDead(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 - nop; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+0:11: +3:2 StorageDead(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2 StorageDead(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2 return; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:2: +3:2 diff --git a/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff index c27b19679a8..27e41d4869d 100644 --- a/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff @@ -6,17 +6,16 @@ let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:26: +1:35 - let _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - let mut _7: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - let mut _8: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - let mut _9: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + let _5: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 + let mut _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + let mut _7: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + let mut _8: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 scope 1 { debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 scope 2 { - let _5: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 + let _4: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 scope 3 { - debug _b => _5; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 + debug _b => _4; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 } } } @@ -25,30 +24,29 @@ StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - _9 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + _8 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 // mir::Constant // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } - _3 = _9; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + _3 = _8; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35 StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:35: +1:36 - StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 - StorageLive(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _7 = Len((*_1)); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -- _8 = Lt(_6, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ _8 = Lt(const 3_usize, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + StorageLive(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 + StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 + _5 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 + _6 = Len((*_1)); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 +- _7 = Lt(_5, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 +- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ _7 = Lt(const 3_usize, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 } bb1: { - _5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26 - nop; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+2:5: +4:6 - StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6 + _4 = (*_1)[_5]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26 + StorageDead(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6 StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:1: +5:2 return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:2: +5:2 } diff --git a/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff index c27b19679a8..27e41d4869d 100644 --- a/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff @@ -6,17 +6,16 @@ let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:26: +1:35 - let _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - let mut _7: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - let mut _8: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - let mut _9: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + let _5: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 + let mut _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + let mut _7: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + let mut _8: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 scope 1 { debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 scope 2 { - let _5: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 + let _4: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 scope 3 { - debug _b => _5; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 + debug _b => _4; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 } } } @@ -25,30 +24,29 @@ StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - _9 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + _8 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 // mir::Constant // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } - _3 = _9; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + _3 = _8; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35 StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:35: +1:36 - StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 - StorageLive(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _7 = Len((*_1)); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -- _8 = Lt(_6, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ _8 = Lt(const 3_usize, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + StorageLive(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 + StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 + _5 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 + _6 = Len((*_1)); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 +- _7 = Lt(_5, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 +- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ _7 = Lt(const 3_usize, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 } bb1: { - _5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26 - nop; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+2:5: +4:6 - StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6 + _4 = (*_1)[_5]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26 + StorageDead(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6 StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:1: +5:2 return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:2: +5:2 } diff --git a/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff b/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff index 147670f8a91..f270ab8b69f 100644 --- a/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff +++ b/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff @@ -25,7 +25,6 @@ } bb2: { - nop; // scope 0 at $DIR/control_flow_simplification.rs:+3:6: +3:6 StorageDead(_1); // scope 0 at $DIR/control_flow_simplification.rs:+3:5: +3:6 return; // scope 0 at $DIR/control_flow_simplification.rs:+4:2: +4:2 } diff --git a/src/test/mir-opt/const_prop/invalid_constant.main.ConstProp.diff b/src/test/mir-opt/const_prop/invalid_constant.main.ConstProp.diff index 67a4dc3c092..6c4757c1a81 100644 --- a/src/test/mir-opt/const_prop/invalid_constant.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/invalid_constant.main.ConstProp.diff @@ -7,8 +7,6 @@ let mut _2: main::InvalidChar; // in scope 0 at $DIR/invalid_constant.rs:+6:34: +6:63 let mut _4: E; // in scope 0 at $DIR/invalid_constant.rs:+13:25: +13:59 let mut _5: main::InvalidTag; // in scope 0 at $DIR/invalid_constant.rs:+13:34: +13:55 - let mut _7: Empty; // in scope 0 at $DIR/invalid_constant.rs:+20:35: +20:73 - let mut _8: main::NoVariants; // in scope 0 at $DIR/invalid_constant.rs:+20:44: +20:65 scope 1 { debug _invalid_char => _1; // in scope 1 at $DIR/invalid_constant.rs:+6:9: +6:22 let _3: [E; 1]; // in scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21 @@ -17,9 +15,9 @@ let _6: [Empty; 1]; // in scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 scope 5 { debug _enum_without_variants => _6; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31 - let _9: main::Str<"���">; // in scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 + let _7: main::Str<"���">; // in scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 scope 7 { - debug _non_utf8_str => _9; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22 + debug _non_utf8_str => _7; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22 } } scope 6 { @@ -57,17 +55,8 @@ StorageDead(_4); // scope 1 at $DIR/invalid_constant.rs:+13:59: +13:60 StorageDead(_5); // scope 1 at $DIR/invalid_constant.rs:+13:60: +13:61 StorageLive(_6); // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 - StorageLive(_7); // scope 3 at $DIR/invalid_constant.rs:+20:35: +20:73 - StorageLive(_8); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 - Deinit(_8); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 - (_8.0: u32) = const 0_u32; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 - nop; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:71 - nop; // scope 3 at $DIR/invalid_constant.rs:+20:34: +20:74 - StorageDead(_7); // scope 3 at $DIR/invalid_constant.rs:+20:73: +20:74 - StorageDead(_8); // scope 3 at $DIR/invalid_constant.rs:+20:74: +20:75 - StorageLive(_9); // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 - nop; // scope 0 at $DIR/invalid_constant.rs:+0:11: +27:2 - StorageDead(_9); // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 + StorageLive(_7); // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 + StorageDead(_7); // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 StorageDead(_6); // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2 StorageDead(_3); // scope 1 at $DIR/invalid_constant.rs:+27:1: +27:2 StorageDead(_1); // scope 0 at $DIR/invalid_constant.rs:+27:1: +27:2 diff --git a/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff index 7d8e647cbce..488e772d0ea 100644 --- a/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff @@ -5,18 +5,13 @@ let mut _0: (); // return place in scope 0 at $DIR/issue_66971.rs:+0:11: +0:11 let _1: (); // in scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 let mut _2: ((), u8, u8); // in scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - let mut _3: (); // in scope 0 at $DIR/issue_66971.rs:+1:13: +1:15 bb0: { StorageLive(_1); // scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 StorageLive(_2); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - StorageLive(_3); // scope 0 at $DIR/issue_66971.rs:+1:13: +1:15 - nop; // scope 0 at $DIR/issue_66971.rs:+1:13: +1:15 Deinit(_2); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - nop; // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 (_2.1: u8) = const 0_u8; // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 (_2.2: u8) = const 0_u8; // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - StorageDead(_3); // scope 0 at $DIR/issue_66971.rs:+1:21: +1:22 _1 = encode(move _2) -> bb1; // scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 // mir::Constant // + span: $DIR/issue_66971.rs:17:5: 17:11 @@ -26,7 +21,6 @@ bb1: { StorageDead(_2); // scope 0 at $DIR/issue_66971.rs:+1:22: +1:23 StorageDead(_1); // scope 0 at $DIR/issue_66971.rs:+1:23: +1:24 - nop; // scope 0 at $DIR/issue_66971.rs:+0:11: +2:2 return; // scope 0 at $DIR/issue_66971.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff index 79cd8bf4839..cd53048597b 100644 --- a/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff @@ -27,7 +27,6 @@ bb1: { StorageDead(_2); // scope 0 at $DIR/issue_67019.rs:+1:19: +1:20 StorageDead(_1); // scope 0 at $DIR/issue_67019.rs:+1:20: +1:21 - nop; // scope 0 at $DIR/issue_67019.rs:+0:11: +2:2 return; // scope 0 at $DIR/issue_67019.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff index 96de39258e4..5331e5b8212 100644 --- a/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff @@ -29,7 +29,6 @@ _1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 - nop; // scope 0 at $DIR/large_array_index.rs:+0:11: +3:2 StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:+3:1: +3:2 return; // scope 0 at $DIR/large_array_index.rs:+3:2: +3:2 } diff --git a/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff index 96de39258e4..5331e5b8212 100644 --- a/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff @@ -29,7 +29,6 @@ _1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 - nop; // scope 0 at $DIR/large_array_index.rs:+0:11: +3:2 StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:+3:1: +3:2 return; // scope 0 at $DIR/large_array_index.rs:+3:2: +3:2 } diff --git a/src/test/mir-opt/const_prop/mutable_variable.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable.main.ConstProp.diff index 3bbd6a87f97..a672c457a72 100644 --- a/src/test/mir-opt/const_prop/mutable_variable.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable.main.ConstProp.diff @@ -19,7 +19,6 @@ StorageLive(_2); // scope 1 at $DIR/mutable_variable.rs:+3:9: +3:10 - _2 = _1; // scope 1 at $DIR/mutable_variable.rs:+3:13: +3:14 + _2 = const 99_i32; // scope 1 at $DIR/mutable_variable.rs:+3:13: +3:14 - nop; // scope 0 at $DIR/mutable_variable.rs:+0:11: +4:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable.rs:+4:1: +4:2 return; // scope 0 at $DIR/mutable_variable.rs:+4:2: +4:2 diff --git a/src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff index fed6a98b9f3..f6bf522065b 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff @@ -21,7 +21,6 @@ StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 - _2 = _1; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 + _2 = const (42_i32, 99_i32); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 - nop; // scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +4:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 return; // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:2: +4:2 diff --git a/src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff index 90eebd8feac..213a70227d8 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff @@ -26,7 +26,6 @@ ((*_2).1: i32) = const 99_i32; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+3:5: +3:13 StorageLive(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 _3 = _1; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14 - nop; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+0:11: +5:2 StorageDead(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 diff --git a/src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff index 6eda503c1ee..149aa6290d0 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff @@ -26,7 +26,6 @@ StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:9: +4:10 - _2 = (_1.1: i32); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:13: +4:16 + _2 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:13: +4:16 - nop; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+0:11: +5:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:1: +5:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:1: +5:2 return; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:2: +5:2 diff --git a/src/test/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff index eb3a7bc96d8..b9d551c5e5f 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff @@ -4,39 +4,34 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_no_prop.rs:+0:11: +0:11 let mut _1: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 - let _2: (); // in scope 0 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6 - let mut _3: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - let mut _4: *mut u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + let mut _2: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + let mut _3: *mut u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 scope 1 { debug x => _1; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 - let _5: u32; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 + let _4: u32; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 scope 2 { } scope 3 { - debug y => _5; // in scope 3 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 + debug y => _4; // in scope 3 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 } } bb0: { StorageLive(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 _1 = const 42_u32; // scope 0 at $DIR/mutable_variable_no_prop.rs:+1:17: +1:19 - StorageLive(_2); // scope 1 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6 + StorageLive(_2); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 StorageLive(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - StorageLive(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - _4 = const {alloc1: *mut u32}; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + _3 = const {alloc1: *mut u32}; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 // mir::Constant // + span: $DIR/mutable_variable_no_prop.rs:10:13: 10:19 // + literal: Const { ty: *mut u32, val: Value(Scalar(alloc1)) } - _3 = (*_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - _1 = move _3; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:9: +3:19 - StorageDead(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:18: +3:19 - StorageDead(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:19: +3:20 - nop; // scope 2 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6 - StorageDead(_2); // scope 1 at $DIR/mutable_variable_no_prop.rs:+4:5: +4:6 - StorageLive(_5); // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 - _5 = _1; // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:13: +5:14 - nop; // scope 0 at $DIR/mutable_variable_no_prop.rs:+0:11: +6:2 - StorageDead(_5); // scope 1 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 + _2 = (*_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + _1 = move _2; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:9: +3:19 + StorageDead(_2); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:18: +3:19 + StorageDead(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:19: +3:20 + StorageLive(_4); // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 + _4 = _1; // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:13: +5:14 + StorageDead(_4); // scope 1 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 return; // scope 0 at $DIR/mutable_variable_no_prop.rs:+6:2: +6:2 } diff --git a/src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff index 2e4b0e79e9f..c3f77b960a2 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff @@ -4,20 +4,19 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +0:11 let _1: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 - let mut _3: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 + let mut _2: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 scope 1 { debug a => _1; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 - let mut _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 + let mut _5: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 let mut _6: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - let mut _7: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 scope 2 { - debug x => (i32, i32){ .0 => _6, .1 => _7, }; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - let _4: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 + debug x => (i32, i32){ .0 => _5, .1 => _6, }; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 + let _3: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 scope 3 { - debug y => _4; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 - let _5: i32; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 + debug y => _3; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 + let _4: i32; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 scope 4 { - debug z => _5; // in scope 4 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 + debug z => _4; // in scope 4 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 } } } @@ -32,26 +31,25 @@ } bb1: { + StorageLive(_5); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 StorageLive(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - StorageLive(_7); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 + Deinit(_5); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 Deinit(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - Deinit(_7); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - _6 = const 1_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - _7 = const 2_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - _3 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - _7 = move _3; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12 - StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - StorageLive(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 - _4 = _7; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16 - StorageLive(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 -- _5 = _6; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 -+ _5 = const 1_i32; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 - nop; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +6:2 - StorageDead(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 - StorageDead(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 + _5 = const 1_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 + _6 = const 2_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 + StorageLive(_2); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 + _2 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 + _6 = move _2; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12 + StorageDead(_2); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 + StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 + _3 = _6; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16 + StorageLive(_4); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 +- _4 = _5; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 ++ _4 = const 1_i32; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 + StorageDead(_4); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 + StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 + StorageDead(_5); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 StorageDead(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 - StorageDead(_7); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 return; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:2: +6:2 } diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff index 7e8ebd31ad1..7c7aeac4c45 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff @@ -9,9 +9,7 @@ let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:32: +2:33 let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 - let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - let mut _10: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - let mut _11: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + let mut _9: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 scope 1 { debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 @@ -53,17 +51,12 @@ StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35 StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35 StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - StorageLive(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - StorageLive(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - Deinit(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - Deinit(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - _10 = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - _11 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -- _8 = _11; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 + StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + Deinit(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + _9 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 +- _8 = _9; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 + _8 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 - StorageDead(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 - StorageDead(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 - nop; // scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +4:2 + StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff index 7e8ebd31ad1..7c7aeac4c45 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff @@ -9,9 +9,7 @@ let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:32: +2:33 let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 - let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - let mut _10: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - let mut _11: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + let mut _9: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 scope 1 { debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 @@ -53,17 +51,12 @@ StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35 StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35 StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - StorageLive(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - StorageLive(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - Deinit(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - Deinit(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - _10 = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - _11 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -- _8 = _11; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 + StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + Deinit(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + _9 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 +- _8 = _9; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 + _8 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 - StorageDead(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 - StorageDead(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 - nop; // scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +4:2 + StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals.after.32bit.mir b/src/test/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir index 75cea8ad2ce..d926b9df733 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals.after.32bit.mir +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after SimplifyLocals +// MIR for `main` after SimplifyLocals-final fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals.after.64bit.mir b/src/test/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir index 75cea8ad2ce..d926b9df733 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals.after.64bit.mir +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after SimplifyLocals +// MIR for `main` after SimplifyLocals-final fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable.rs b/src/test/mir-opt/const_prop/optimizes_into_variable.rs index 02566654818..abea07e2025 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.rs +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.rs @@ -9,7 +9,7 @@ struct Point { // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR optimizes_into_variable.main.ScalarReplacementOfAggregates.diff // EMIT_MIR optimizes_into_variable.main.ConstProp.diff -// EMIT_MIR optimizes_into_variable.main.SimplifyLocals.after.mir +// EMIT_MIR optimizes_into_variable.main.SimplifyLocals-final.after.mir // EMIT_MIR optimizes_into_variable.main.PreCodegen.after.mir fn main() { let x = 2 + 2; diff --git a/src/test/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff b/src/test/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff index b9c283a5482..388c6ca810b 100644 --- a/src/test/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff @@ -36,7 +36,6 @@ StorageDead(_2); // scope 0 at $DIR/read_immutable_static.rs:+1:21: +1:22 StorageDead(_5); // scope 0 at $DIR/read_immutable_static.rs:+1:22: +1:23 StorageDead(_3); // scope 0 at $DIR/read_immutable_static.rs:+1:22: +1:23 - nop; // scope 0 at $DIR/read_immutable_static.rs:+0:11: +2:2 StorageDead(_1); // scope 0 at $DIR/read_immutable_static.rs:+2:1: +2:2 return; // scope 0 at $DIR/read_immutable_static.rs:+2:2: +2:2 } diff --git a/src/test/mir-opt/const_prop/ref_deref.main.ConstProp.diff b/src/test/mir-opt/const_prop/ref_deref.main.ConstProp.diff index 09ce67ff15d..8a73f0390e1 100644 --- a/src/test/mir-opt/const_prop/ref_deref.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/ref_deref.main.ConstProp.diff @@ -13,7 +13,7 @@ StorageLive(_2); // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 _4 = const _; // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 // mir::Constant - // + span: $DIR/ref_deref.rs:5:6: 5:10 + // + span: $DIR/ref_deref.rs:6:6: 6:10 // + literal: Const { ty: &i32, val: Unevaluated(main, [], Some(promoted[0])) } _2 = _4; // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 - _1 = (*_2); // scope 0 at $DIR/ref_deref.rs:+1:5: +1:10 diff --git a/src/test/mir-opt/const_prop/ref_deref.main.PromoteTemps.diff b/src/test/mir-opt/const_prop/ref_deref.main.PromoteTemps.diff index 902cd785031..015ec4d078c 100644 --- a/src/test/mir-opt/const_prop/ref_deref.main.PromoteTemps.diff +++ b/src/test/mir-opt/const_prop/ref_deref.main.PromoteTemps.diff @@ -16,7 +16,7 @@ - _2 = &_3; // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 + _4 = const _; // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 + // mir::Constant -+ // + span: $DIR/ref_deref.rs:5:6: 5:10 ++ // + span: $DIR/ref_deref.rs:6:6: 6:10 + // + literal: Const { ty: &i32, val: Unevaluated(main, [], Some(promoted[0])) } + _2 = &(*_4); // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 _1 = (*_2); // scope 0 at $DIR/ref_deref.rs:+1:5: +1:10 diff --git a/src/test/mir-opt/const_prop/ref_deref.rs b/src/test/mir-opt/const_prop/ref_deref.rs index 30ec9766367..d2549c8b6aa 100644 --- a/src/test/mir-opt/const_prop/ref_deref.rs +++ b/src/test/mir-opt/const_prop/ref_deref.rs @@ -1,3 +1,4 @@ +// compile-flags: -Zmir-enable-passes=-SimplifyLocals-before-const-prop // EMIT_MIR ref_deref.main.PromoteTemps.diff // EMIT_MIR ref_deref.main.ConstProp.diff diff --git a/src/test/mir-opt/const_prop/ref_deref_project.rs b/src/test/mir-opt/const_prop/ref_deref_project.rs index 659c11d9b0c..2fdd4e15319 100644 --- a/src/test/mir-opt/const_prop/ref_deref_project.rs +++ b/src/test/mir-opt/const_prop/ref_deref_project.rs @@ -1,4 +1,4 @@ -// unit-test +// compile-flags: -Zmir-enable-passes=-SimplifyLocals-before-const-prop // EMIT_MIR ref_deref_project.main.PromoteTemps.diff // EMIT_MIR ref_deref_project.main.ConstProp.diff diff --git a/src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff b/src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff index 237a6f94aa7..15c93f270d7 100644 --- a/src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff @@ -3,26 +3,21 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/reify_fn_ptr.rs:+0:11: +0:11 - let mut _1: *const fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41 - let mut _2: usize; // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 - let mut _3: fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 + let mut _1: usize; // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 + let mut _2: fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 scope 1 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41 - StorageLive(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 - StorageLive(_3); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 - _3 = main as fn() (Pointer(ReifyFnPointer)); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 + StorageLive(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 + StorageLive(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 + _2 = main as fn() (Pointer(ReifyFnPointer)); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 // mir::Constant // + span: $DIR/reify_fn_ptr.rs:4:13: 4:17 // + literal: Const { ty: fn() {main}, val: Value(<ZST>) } - _2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 - StorageDead(_3); // scope 0 at $DIR/reify_fn_ptr.rs:+1:25: +1:26 - _1 = move _2 as *const fn() (PointerFromExposedAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41 - StorageDead(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:40: +1:41 - StorageDead(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:41: +1:42 - nop; // scope 0 at $DIR/reify_fn_ptr.rs:+0:11: +2:2 + _1 = move _2 as usize (PointerExposeAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 + StorageDead(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:25: +1:26 + StorageDead(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:40: +1:41 return; // scope 0 at $DIR/reify_fn_ptr.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff index 7c497799691..636032adb81 100644 --- a/src/test/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff @@ -35,7 +35,6 @@ StorageDead(_2); // scope 0 at $DIR/repeat.rs:+1:31: +1:32 StorageDead(_4); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 StorageDead(_3); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 - nop; // scope 0 at $DIR/repeat.rs:+0:11: +2:2 StorageDead(_1); // scope 0 at $DIR/repeat.rs:+2:1: +2:2 return; // scope 0 at $DIR/repeat.rs:+2:2: +2:2 } diff --git a/src/test/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff index 7c497799691..636032adb81 100644 --- a/src/test/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff @@ -35,7 +35,6 @@ StorageDead(_2); // scope 0 at $DIR/repeat.rs:+1:31: +1:32 StorageDead(_4); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 StorageDead(_3); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 - nop; // scope 0 at $DIR/repeat.rs:+0:11: +2:2 StorageDead(_1); // scope 0 at $DIR/repeat.rs:+2:1: +2:2 return; // scope 0 at $DIR/repeat.rs:+2:2: +2:2 } diff --git a/src/test/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff b/src/test/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff index 5920937e0fd..d518eff04eb 100644 --- a/src/test/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff @@ -27,7 +27,6 @@ bb1: { StorageDead(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:14: +2:15 StorageDead(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:15: +2:16 - nop; // scope 0 at $DIR/scalar_literal_propagation.rs:+0:11: +3:2 StorageDead(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+3:1: +3:2 return; // scope 0 at $DIR/scalar_literal_propagation.rs:+3:2: +3:2 } diff --git a/src/test/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff index 44445731e72..9017fd18e48 100644 --- a/src/test/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff @@ -20,7 +20,7 @@ StorageLive(_4); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 _9 = const _; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 // mir::Constant - // + span: $DIR/slice_len.rs:5:6: 5:19 + // + span: $DIR/slice_len.rs:6:6: 6:19 // + literal: Const { ty: &[u32; 3], val: Unevaluated(main, [], Some(promoted[0])) } _4 = _9; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 _3 = _4; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 diff --git a/src/test/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff index 44445731e72..9017fd18e48 100644 --- a/src/test/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff @@ -20,7 +20,7 @@ StorageLive(_4); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 _9 = const _; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 // mir::Constant - // + span: $DIR/slice_len.rs:5:6: 5:19 + // + span: $DIR/slice_len.rs:6:6: 6:19 // + literal: Const { ty: &[u32; 3], val: Unevaluated(main, [], Some(promoted[0])) } _4 = _9; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 _3 = _4; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 diff --git a/src/test/mir-opt/const_prop/slice_len.rs b/src/test/mir-opt/const_prop/slice_len.rs index fa9eafa8b0b..eaaf34b960e 100644 --- a/src/test/mir-opt/const_prop/slice_len.rs +++ b/src/test/mir-opt/const_prop/slice_len.rs @@ -1,3 +1,4 @@ +// compile-flags: -Zmir-enable-passes=-SimplifyLocals-before-const-prop // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR slice_len.main.ConstProp.diff diff --git a/src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff b/src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff index a0603c60dc7..e4c92b617c6 100644 --- a/src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff @@ -28,7 +28,6 @@ bb1: { StorageDead(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:14: +3:15 StorageDead(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:15: +3:16 - nop; // scope 0 at $DIR/tuple_literal_propagation.rs:+0:11: +4:2 StorageDead(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+4:1: +4:2 return; // scope 0 at $DIR/tuple_literal_propagation.rs:+4:2: +4:2 } diff --git a/src/test/mir-opt/const_prop_miscompile.bar.ConstProp.diff b/src/test/mir-opt/const_prop_miscompile.bar.ConstProp.diff index 459da2e3358..ea9fec0aa15 100644 --- a/src/test/mir-opt/const_prop_miscompile.bar.ConstProp.diff +++ b/src/test/mir-opt/const_prop_miscompile.bar.ConstProp.diff @@ -4,16 +4,15 @@ fn bar() -> () { let mut _0: (); // return place in scope 0 at $DIR/const_prop_miscompile.rs:+0:10: +0:10 let mut _1: (i32,); // in scope 0 at $DIR/const_prop_miscompile.rs:+1:9: +1:14 - let _2: (); // in scope 0 at $DIR/const_prop_miscompile.rs:+2:5: +4:6 - let mut _3: *mut i32; // in scope 0 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 - let mut _5: i32; // in scope 0 at $DIR/const_prop_miscompile.rs:+5:13: +5:20 + let mut _2: *mut i32; // in scope 0 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 + let mut _4: i32; // in scope 0 at $DIR/const_prop_miscompile.rs:+5:13: +5:20 scope 1 { debug v => _1; // in scope 1 at $DIR/const_prop_miscompile.rs:+1:9: +1:14 - let _4: bool; // in scope 1 at $DIR/const_prop_miscompile.rs:+5:9: +5:10 + let _3: bool; // in scope 1 at $DIR/const_prop_miscompile.rs:+5:9: +5:10 scope 2 { } scope 3 { - debug y => _4; // in scope 3 at $DIR/const_prop_miscompile.rs:+5:9: +5:10 + debug y => _3; // in scope 3 at $DIR/const_prop_miscompile.rs:+5:9: +5:10 } } @@ -21,20 +20,16 @@ StorageLive(_1); // scope 0 at $DIR/const_prop_miscompile.rs:+1:9: +1:14 Deinit(_1); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 (_1.0: i32) = const 1_i32; // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 - StorageLive(_2); // scope 1 at $DIR/const_prop_miscompile.rs:+2:5: +4:6 - StorageLive(_3); // scope 2 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 - _3 = &raw mut (_1.0: i32); // scope 2 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 - (*_3) = const 5_i32; // scope 2 at $DIR/const_prop_miscompile.rs:+3:9: +3:26 - StorageDead(_3); // scope 2 at $DIR/const_prop_miscompile.rs:+3:26: +3:27 - nop; // scope 2 at $DIR/const_prop_miscompile.rs:+2:5: +4:6 - StorageDead(_2); // scope 1 at $DIR/const_prop_miscompile.rs:+4:5: +4:6 - StorageLive(_4); // scope 1 at $DIR/const_prop_miscompile.rs:+5:9: +5:10 - StorageLive(_5); // scope 1 at $DIR/const_prop_miscompile.rs:+5:13: +5:20 - _5 = (_1.0: i32); // scope 1 at $DIR/const_prop_miscompile.rs:+5:15: +5:18 - _4 = Eq(move _5, const 5_i32); // scope 1 at $DIR/const_prop_miscompile.rs:+5:13: +5:25 - StorageDead(_5); // scope 1 at $DIR/const_prop_miscompile.rs:+5:24: +5:25 - nop; // scope 0 at $DIR/const_prop_miscompile.rs:+0:10: +6:2 - StorageDead(_4); // scope 1 at $DIR/const_prop_miscompile.rs:+6:1: +6:2 + StorageLive(_2); // scope 2 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 + _2 = &raw mut (_1.0: i32); // scope 2 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 + (*_2) = const 5_i32; // scope 2 at $DIR/const_prop_miscompile.rs:+3:9: +3:26 + StorageDead(_2); // scope 2 at $DIR/const_prop_miscompile.rs:+3:26: +3:27 + StorageLive(_3); // scope 1 at $DIR/const_prop_miscompile.rs:+5:9: +5:10 + StorageLive(_4); // scope 1 at $DIR/const_prop_miscompile.rs:+5:13: +5:20 + _4 = (_1.0: i32); // scope 1 at $DIR/const_prop_miscompile.rs:+5:15: +5:18 + _3 = Eq(move _4, const 5_i32); // scope 1 at $DIR/const_prop_miscompile.rs:+5:13: +5:25 + StorageDead(_4); // scope 1 at $DIR/const_prop_miscompile.rs:+5:24: +5:25 + StorageDead(_3); // scope 1 at $DIR/const_prop_miscompile.rs:+6:1: +6:2 StorageDead(_1); // scope 0 at $DIR/const_prop_miscompile.rs:+6:1: +6:2 return; // scope 0 at $DIR/const_prop_miscompile.rs:+6:2: +6:2 } diff --git a/src/test/mir-opt/const_prop_miscompile.foo.ConstProp.diff b/src/test/mir-opt/const_prop_miscompile.foo.ConstProp.diff index e8bd98cf8cb..043f4047417 100644 --- a/src/test/mir-opt/const_prop_miscompile.foo.ConstProp.diff +++ b/src/test/mir-opt/const_prop_miscompile.foo.ConstProp.diff @@ -27,7 +27,6 @@ _4 = (_1.0: i32); // scope 1 at $DIR/const_prop_miscompile.rs:+3:15: +3:18 _3 = Eq(move _4, const 5_i32); // scope 1 at $DIR/const_prop_miscompile.rs:+3:13: +3:25 StorageDead(_4); // scope 1 at $DIR/const_prop_miscompile.rs:+3:24: +3:25 - nop; // scope 0 at $DIR/const_prop_miscompile.rs:+0:10: +4:2 StorageDead(_3); // scope 1 at $DIR/const_prop_miscompile.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/const_prop_miscompile.rs:+4:1: +4:2 return; // scope 0 at $DIR/const_prop_miscompile.rs:+4:2: +4:2 diff --git a/src/test/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff index bf4557ed3d9..02aafd7acc4 100644 --- a/src/test/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff +++ b/src/test/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff @@ -5,40 +5,34 @@ let mut _0: (); // return place in scope 0 at $DIR/inherit_overflow.rs:+0:11: +0:11 let mut _1: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 let mut _2: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - let mut _3: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 scope 1 { } scope 2 (inlined <u8 as Add>::add) { // at $DIR/inherit_overflow.rs:7:13: 7:47 - debug self => _2; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - debug other => _3; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + debug self => _1; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + debug other => _2; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + let mut _3: u8; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL let mut _4: u8; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - let mut _5: u8; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - let mut _6: (u8, bool); // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + let mut _5: (u8, bool); // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL } bb0: { StorageLive(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + _1 = const u8::MAX; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 StorageLive(_2); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - _2 = const u8::MAX; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - StorageLive(_3); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - _3 = const 1_u8; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + _2 = const 1_u8; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + StorageLive(_3); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + _3 = const u8::MAX; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL StorageLive(_4); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - _4 = const u8::MAX; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - StorageLive(_5); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - _5 = const 1_u8; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - _6 = CheckedAdd(const u8::MAX, const 1_u8); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - assert(!move (_6.1: bool), "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> bb1; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + _4 = const 1_u8; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + _5 = CheckedAdd(const u8::MAX, const 1_u8); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> bb1; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL } bb1: { -- _1 = move (_6.0: u8); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL -+ _1 = const 0_u8; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - StorageDead(_5); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL StorageDead(_4); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - StorageDead(_3); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + StorageDead(_3); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL StorageDead(_2); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - StorageDead(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:47: +3:48 - nop; // scope 0 at $DIR/inherit_overflow.rs:+0:11: +4:2 + StorageDead(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 return; // scope 0 at $DIR/inherit_overflow.rs:+4:2: +4:2 } } diff --git a/src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff b/src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff index 80f8905adc9..cd3b792fb75 100644 --- a/src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff +++ b/src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff @@ -59,14 +59,6 @@ - _4 = const (); // scope 0 at $DIR/cycle.rs:+3:18: +8:6 - StorageDead(_6); // scope 0 at $DIR/cycle.rs:+8:5: +8:6 + StorageLive(_5); // scope 0 at $DIR/cycle.rs:+4:13: +4:17 -+ nop; // scope 0 at $DIR/cycle.rs:+4:20: +4:21 -+ nop; // scope 1 at $DIR/cycle.rs:+5:13: +5:14 -+ nop; // scope 1 at $DIR/cycle.rs:+5:9: +5:14 -+ nop; // scope 1 at $DIR/cycle.rs:+6:13: +6:14 -+ nop; // scope 1 at $DIR/cycle.rs:+6:9: +6:14 -+ nop; // scope 1 at $DIR/cycle.rs:+7:13: +7:17 -+ nop; // scope 1 at $DIR/cycle.rs:+7:9: +7:17 -+ nop; // scope 0 at $DIR/cycle.rs:+3:18: +8:6 StorageDead(_5); // scope 0 at $DIR/cycle.rs:+8:5: +8:6 + StorageDead(_4); // scope 0 at $DIR/cycle.rs:+8:5: +8:6 goto -> bb1; // scope 0 at $DIR/cycle.rs:+3:5: +8:6 diff --git a/src/test/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir b/src/test/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir index ba7f76d2841..26068931aaf 100644 --- a/src/test/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir +++ b/src/test/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir @@ -13,7 +13,6 @@ fn f(_1: usize) -> usize { bb0: { nop; // scope 0 at $DIR/dead_stores_better.rs:+1:9: +1:10 nop; // scope 0 at $DIR/dead_stores_better.rs:+1:13: +1:14 - nop; // scope 1 at $DIR/dead_stores_better.rs:+2:5: +2:10 nop; // scope 1 at $DIR/dead_stores_better.rs:+3:9: +3:10 nop; // scope 1 at $DIR/dead_stores_better.rs:+3:9: +3:10 nop; // scope 1 at $DIR/dead_stores_better.rs:+3:5: +3:10 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 85d994bc8b9..fbed3178801 100644 --- a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff @@ -25,11 +25,8 @@ } bb1: { - nop; // scope 0 at $DIR/union.rs:+5:14: +5:30 - nop; // scope 0 at $DIR/union.rs:+5:14: +5:30 StorageDead(_2); // scope 0 at $DIR/union.rs:+5:29: +5:30 StorageLive(_3); // scope 1 at $DIR/union.rs:+7:10: +7:26 - nop; // scope 2 at $DIR/union.rs:+7:19: +7:24 StorageDead(_3); // scope 1 at $DIR/union.rs:+7:26: +7:27 StorageDead(_1); // scope 0 at $DIR/union.rs:+8:1: +8:2 return; // scope 0 at $DIR/union.rs:+8:2: +8:2 diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff index 17b81633991..bf3bcfdb594 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff @@ -7,41 +7,36 @@ let mut _2: std::option::Option<i32>; // in scope 0 at $DIR/issue_73223.rs:+1:23: +1:30 let mut _3: isize; // in scope 0 at $DIR/issue_73223.rs:+2:9: +2:16 let _4: i32; // in scope 0 at $DIR/issue_73223.rs:+2:14: +2:15 - let mut _5: !; // in scope 0 at $DIR/issue_73223.rs:+3:17: +3:23 - let mut _7: i32; // in scope 0 at $DIR/issue_73223.rs:+6:22: +6:27 - let _8: (); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _9: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _10: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _11: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _12: i32; // in scope 0 at $DIR/issue_73223.rs:+7:23: +7:24 - let mut _15: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _16: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _17: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _18: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _19: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _21: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _22: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _23: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _24: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _6: i32; // in scope 0 at $DIR/issue_73223.rs:+6:22: +6:27 + let mut _7: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _8: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _11: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _12: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _13: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _14: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _16: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _17: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _18: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _19: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _20: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _21: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _22: std::option::Option<std::fmt::Arguments<'_>>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _24: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _25: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _26: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _27: std::option::Option<std::fmt::Arguments<'_>>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _29: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _30: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 { debug split => _1; // in scope 1 at $DIR/issue_73223.rs:+1:9: +1:14 - let _6: std::option::Option<i32>; // in scope 1 at $DIR/issue_73223.rs:+6:9: +6:14 + let _5: std::option::Option<i32>; // in scope 1 at $DIR/issue_73223.rs:+6:9: +6:14 scope 3 { - debug _prev => _6; // in scope 3 at $DIR/issue_73223.rs:+6:9: +6:14 - let _13: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _14: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _28: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug _prev => _5; // in scope 3 at $DIR/issue_73223.rs:+6:9: +6:14 + let _9: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _10: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _23: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 4 { - debug left_val => _13; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug right_val => _14; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _20: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug left_val => _9; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug right_val => _10; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _15: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 5 { - debug kind => _20; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug kind => _15; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } } } @@ -61,7 +56,6 @@ } bb1: { - nop; // scope 0 at $DIR/issue_73223.rs:+3:17: +3:23 StorageDead(_2); // scope 0 at $DIR/issue_73223.rs:+4:6: +4:7 StorageDead(_1); // scope 0 at $DIR/issue_73223.rs:+8:1: +8:2 return; // scope 0 at $DIR/issue_73223.rs:+8:2: +8:2 @@ -77,70 +71,69 @@ _1 = _4; // scope 2 at $DIR/issue_73223.rs:+2:20: +2:21 StorageDead(_4); // scope 0 at $DIR/issue_73223.rs:+2:20: +2:21 StorageDead(_2); // scope 0 at $DIR/issue_73223.rs:+4:6: +4:7 - StorageLive(_6); // scope 1 at $DIR/issue_73223.rs:+6:9: +6:14 - StorageLive(_7); // scope 1 at $DIR/issue_73223.rs:+6:22: +6:27 - _7 = _1; // scope 1 at $DIR/issue_73223.rs:+6:22: +6:27 - Deinit(_6); // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28 - ((_6 as Some).0: i32) = move _7; // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28 - discriminant(_6) = 1; // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28 - StorageDead(_7); // scope 1 at $DIR/issue_73223.rs:+6:27: +6:28 + StorageLive(_5); // scope 1 at $DIR/issue_73223.rs:+6:9: +6:14 + StorageLive(_6); // scope 1 at $DIR/issue_73223.rs:+6:22: +6:27 + _6 = _1; // scope 1 at $DIR/issue_73223.rs:+6:22: +6:27 + Deinit(_5); // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28 + ((_5 as Some).0: i32) = move _6; // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28 + discriminant(_5) = 1; // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28 + StorageDead(_6); // scope 1 at $DIR/issue_73223.rs:+6:27: +6:28 + StorageLive(_24); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_25); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _7 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_29); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_30); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _10 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _28 = const _; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _23 = const _; // scope 3 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: &i32, val: Unevaluated(main, [], Some(promoted[0])) } - _11 = _28; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Deinit(_29); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Deinit(_30); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _29 = move _10; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _30 = move _11; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _13 = _29; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _14 = _30; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _17 = (*_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _18 = const 1_i32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _16 = Eq(move _17, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(move _15) -> [0: bb5, otherwise: bb4]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _8 = _23; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + Deinit(_24); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + Deinit(_25); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _24 = move _7; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _25 = move _8; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _9 = _24; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _10 = _25; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _13 = (*_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_14); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _14 = const 1_i32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _12 = Eq(move _13, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_14); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _11 = Not(move _12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + switchInt(move _11) -> [0: bb5, otherwise: bb4]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb4: { - StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Deinit(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_20) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_21); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_22); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _22 = const core::panicking::AssertKind::Eq; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + Deinit(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_15) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_16); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_17); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _17 = const core::panicking::AssertKind::Eq; // 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: core::panicking::AssertKind, val: Value(Scalar(0x00)) } - StorageLive(_23); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_24); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _24 = _13; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _23 = _24; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_25); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_26); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _26 = _14; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _25 = _26; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Deinit(_27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_27) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _21 = core::panicking::assert_failed::<i32, i32>(const core::panicking::AssertKind::Eq, move _23, move _25, move _27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_19); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _19 = _9; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _18 = _19; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_20); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_21); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _21 = _10; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _20 = _21; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_22); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + Deinit(_22); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_22) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _16 = core::panicking::assert_failed::<i32, i32>(const core::panicking::AssertKind::Eq, move _18, move _20, move _22); // 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<'a, 'b, 'c> fn(core::panicking::AssertKind, &'a i32, &'b i32, Option<Arguments<'c>>) -> ! {core::panicking::assert_failed::<i32, i32>}, val: Value(<ZST>) } @@ -150,15 +143,12 @@ } bb5: { - nop; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_29); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_30); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - nop; // scope 0 at $DIR/issue_73223.rs:+0:11: +8:2 - StorageDead(_6); // scope 1 at $DIR/issue_73223.rs:+8:1: +8:2 + StorageDead(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_24); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_25); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_5); // scope 1 at $DIR/issue_73223.rs:+8:1: +8:2 StorageDead(_1); // scope 0 at $DIR/issue_73223.rs:+8:1: +8:2 return; // scope 0 at $DIR/issue_73223.rs:+8:2: +8:2 } diff --git a/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff b/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff index e97b46f6ecc..c24543daeac 100644 --- a/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff @@ -11,26 +11,19 @@ let mut _6: T; // in scope 0 at $DIR/issue_76432.rs:+1:21: +1:22 let mut _7: T; // in scope 0 at $DIR/issue_76432.rs:+1:24: +1:25 let mut _8: T; // in scope 0 at $DIR/issue_76432.rs:+1:27: +1:28 - let _9: [*const T; 3]; // in scope 0 at $DIR/issue_76432.rs:+2:5: +5:6 + let mut _9: usize; // in scope 0 at $DIR/issue_76432.rs:+3:9: +3:33 let mut _10: usize; // in scope 0 at $DIR/issue_76432.rs:+3:9: +3:33 - let mut _11: usize; // in scope 0 at $DIR/issue_76432.rs:+3:9: +3:33 - let mut _12: bool; // in scope 0 at $DIR/issue_76432.rs:+3:9: +3:33 - let mut _16: *const T; // in scope 0 at $DIR/issue_76432.rs:+3:38: +3:52 - let mut _17: *const T; // in scope 0 at $DIR/issue_76432.rs:+3:38: +3:52 - let mut _18: *const T; // in scope 0 at $DIR/issue_76432.rs:+3:54: +3:68 - let mut _19: *const T; // in scope 0 at $DIR/issue_76432.rs:+3:54: +3:68 - let mut _20: *const T; // in scope 0 at $DIR/issue_76432.rs:+3:70: +3:84 - let mut _21: *const T; // in scope 0 at $DIR/issue_76432.rs:+3:70: +3:84 - let mut _22: !; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL + let mut _11: bool; // in scope 0 at $DIR/issue_76432.rs:+3:9: +3:33 + let mut _15: !; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL scope 1 { debug v => _2; // in scope 1 at $DIR/issue_76432.rs:+1:9: +1:10 - let _13: &T; // in scope 1 at $DIR/issue_76432.rs:+3:10: +3:16 - let _14: &T; // in scope 1 at $DIR/issue_76432.rs:+3:18: +3:24 - let _15: &T; // in scope 1 at $DIR/issue_76432.rs:+3:26: +3:32 + let _12: &T; // in scope 1 at $DIR/issue_76432.rs:+3:10: +3:16 + let _13: &T; // in scope 1 at $DIR/issue_76432.rs:+3:18: +3:24 + let _14: &T; // in scope 1 at $DIR/issue_76432.rs:+3:26: +3:32 scope 2 { - debug v1 => _13; // in scope 2 at $DIR/issue_76432.rs:+3:10: +3:16 - debug v2 => _14; // in scope 2 at $DIR/issue_76432.rs:+3:18: +3:24 - debug v3 => _15; // in scope 2 at $DIR/issue_76432.rs:+3:26: +3:32 + debug v1 => _12; // in scope 2 at $DIR/issue_76432.rs:+3:10: +3:16 + debug v2 => _13; // in scope 2 at $DIR/issue_76432.rs:+3:18: +3:24 + debug v3 => _14; // in scope 2 at $DIR/issue_76432.rs:+3:26: +3:32 } } @@ -54,18 +47,17 @@ _2 = move _3 as &[T] (Pointer(Unsize)); // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29 StorageDead(_3); // scope 0 at $DIR/issue_76432.rs:+1:28: +1:29 StorageDead(_4); // scope 0 at $DIR/issue_76432.rs:+1:29: +1:30 - StorageLive(_9); // scope 1 at $DIR/issue_76432.rs:+2:5: +5:6 - _10 = Len((*_2)); // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 - _11 = const 3_usize; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 -- _12 = Eq(move _10, const 3_usize); // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 -- switchInt(move _12) -> [0: bb1, otherwise: bb2]; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 + _9 = Len((*_2)); // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 + _10 = const 3_usize; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 +- _11 = Eq(move _9, const 3_usize); // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 +- switchInt(move _11) -> [0: bb1, otherwise: bb2]; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 + nop; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 -+ switchInt(move _10) -> [3: bb2, otherwise: bb1]; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 ++ switchInt(move _9) -> [3: bb2, otherwise: bb1]; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 } bb1: { - StorageLive(_22); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL - _22 = core::panicking::panic(const "internal error: entered unreachable code"); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL + StorageLive(_15); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL + _15 = core::panicking::panic(const "internal error: entered unreachable code"); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/panic.rs:LL:COL // + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(<ZST>) } @@ -75,36 +67,15 @@ } bb2: { - StorageLive(_13); // scope 1 at $DIR/issue_76432.rs:+3:10: +3:16 - _13 = &(*_2)[0 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:10: +3:16 - StorageLive(_14); // scope 1 at $DIR/issue_76432.rs:+3:18: +3:24 - _14 = &(*_2)[1 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:18: +3:24 - StorageLive(_15); // scope 1 at $DIR/issue_76432.rs:+3:26: +3:32 - _15 = &(*_2)[2 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:26: +3:32 - StorageLive(_16); // scope 2 at $DIR/issue_76432.rs:+3:38: +3:52 - StorageLive(_17); // scope 2 at $DIR/issue_76432.rs:+3:38: +3:52 - _17 = &raw const (*_13); // scope 2 at $DIR/issue_76432.rs:+3:38: +3:40 - _16 = _17; // scope 2 at $DIR/issue_76432.rs:+3:38: +3:52 - StorageLive(_18); // scope 2 at $DIR/issue_76432.rs:+3:54: +3:68 - StorageLive(_19); // scope 2 at $DIR/issue_76432.rs:+3:54: +3:68 - _19 = &raw const (*_14); // scope 2 at $DIR/issue_76432.rs:+3:54: +3:56 - _18 = _19; // scope 2 at $DIR/issue_76432.rs:+3:54: +3:68 - StorageLive(_20); // scope 2 at $DIR/issue_76432.rs:+3:70: +3:84 - StorageLive(_21); // scope 2 at $DIR/issue_76432.rs:+3:70: +3:84 - _21 = &raw const (*_15); // scope 2 at $DIR/issue_76432.rs:+3:70: +3:72 - _20 = _21; // scope 2 at $DIR/issue_76432.rs:+3:70: +3:84 - _9 = [move _16, move _18, move _20]; // scope 2 at $DIR/issue_76432.rs:+3:37: +3:85 - StorageDead(_21); // scope 2 at $DIR/issue_76432.rs:+3:84: +3:85 - StorageDead(_20); // scope 2 at $DIR/issue_76432.rs:+3:84: +3:85 - StorageDead(_19); // scope 2 at $DIR/issue_76432.rs:+3:84: +3:85 - StorageDead(_18); // scope 2 at $DIR/issue_76432.rs:+3:84: +3:85 - StorageDead(_17); // scope 2 at $DIR/issue_76432.rs:+3:84: +3:85 - StorageDead(_16); // scope 2 at $DIR/issue_76432.rs:+3:84: +3:85 - StorageDead(_15); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85 + StorageLive(_12); // scope 1 at $DIR/issue_76432.rs:+3:10: +3:16 + _12 = &(*_2)[0 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:10: +3:16 + StorageLive(_13); // scope 1 at $DIR/issue_76432.rs:+3:18: +3:24 + _13 = &(*_2)[1 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:18: +3:24 + StorageLive(_14); // scope 1 at $DIR/issue_76432.rs:+3:26: +3:32 + _14 = &(*_2)[2 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:26: +3:32 StorageDead(_14); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85 StorageDead(_13); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85 - StorageDead(_9); // scope 1 at $DIR/issue_76432.rs:+5:6: +5:7 - nop; // scope 0 at $DIR/issue_76432.rs:+0:44: +6:2 + StorageDead(_12); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85 StorageDead(_5); // scope 0 at $DIR/issue_76432.rs:+6:1: +6:2 StorageDead(_2); // scope 0 at $DIR/issue_76432.rs:+6:1: +6:2 return; // scope 0 at $DIR/issue_76432.rs:+6:2: +6:2 diff --git a/src/test/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff b/src/test/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff index aea01147443..f9e22866bee 100644 --- a/src/test/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff +++ b/src/test/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff @@ -23,12 +23,10 @@ bb2: { StorageDead(_2); // scope 0 at $DIR/simplify_if.rs:+2:15: +2:16 - nop; // scope 0 at $DIR/simplify_if.rs:+1:14: +3:6 goto -> bb4; // scope 0 at $DIR/simplify_if.rs:+1:5: +3:6 } bb3: { - nop; // scope 0 at $DIR/simplify_if.rs:+3:6: +3:6 goto -> bb4; // scope 0 at $DIR/simplify_if.rs:+1:5: +3:6 } diff --git a/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.c.SimplifyLocals-before-const-prop.diff index 1a5143aa0fa..1be27e96397 100644 --- a/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.c.SimplifyLocals-before-const-prop.diff @@ -1,5 +1,5 @@ -- // MIR for `c` before SimplifyLocals -+ // MIR for `c` after SimplifyLocals +- // MIR for `c` before SimplifyLocals-before-const-prop ++ // MIR for `c` after SimplifyLocals-before-const-prop fn c() -> () { let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:8: +0:8 diff --git a/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.d1.SimplifyLocals-before-const-prop.diff index 6426bf926a4..98173803018 100644 --- a/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.d1.SimplifyLocals-before-const-prop.diff @@ -1,5 +1,5 @@ -- // MIR for `d1` before SimplifyLocals -+ // MIR for `d1` after SimplifyLocals +- // MIR for `d1` before SimplifyLocals-before-const-prop ++ // MIR for `d1` after SimplifyLocals-before-const-prop fn d1() -> () { let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9 diff --git a/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.d2.SimplifyLocals-before-const-prop.diff index db5ab182d6f..b152dc8cca3 100644 --- a/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.d2.SimplifyLocals-before-const-prop.diff @@ -1,5 +1,5 @@ -- // MIR for `d2` before SimplifyLocals -+ // MIR for `d2` after SimplifyLocals +- // MIR for `d2` before SimplifyLocals-before-const-prop ++ // MIR for `d2` after SimplifyLocals-before-const-prop fn d2() -> () { let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9 diff --git a/src/test/mir-opt/simplify_locals.expose_addr.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.expose_addr.SimplifyLocals-before-const-prop.diff index c707b0da07e..9ca1dbbd071 100644 --- a/src/test/mir-opt/simplify_locals.expose_addr.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.expose_addr.SimplifyLocals-before-const-prop.diff @@ -1,5 +1,5 @@ -- // MIR for `expose_addr` before SimplifyLocals -+ // MIR for `expose_addr` after SimplifyLocals +- // MIR for `expose_addr` before SimplifyLocals-before-const-prop ++ // MIR for `expose_addr` after SimplifyLocals-before-const-prop fn expose_addr(_1: *const usize) -> () { debug p => _1; // in scope 0 at $DIR/simplify_locals.rs:+0:16: +0:17 diff --git a/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.r.SimplifyLocals-before-const-prop.diff index ff6eb2cff5e..19dacb427f5 100644 --- a/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.r.SimplifyLocals-before-const-prop.diff @@ -1,5 +1,5 @@ -- // MIR for `r` before SimplifyLocals -+ // MIR for `r` after SimplifyLocals +- // MIR for `r` before SimplifyLocals-before-const-prop ++ // MIR for `r` after SimplifyLocals-before-const-prop fn r() -> () { let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:8: +0:8 diff --git a/src/test/mir-opt/simplify_locals.rs b/src/test/mir-opt/simplify_locals.rs index 89d9391f832..7bbc0481c68 100644 --- a/src/test/mir-opt/simplify_locals.rs +++ b/src/test/mir-opt/simplify_locals.rs @@ -1,4 +1,4 @@ -// unit-test: SimplifyLocals +// unit-test: SimplifyLocals-before-const-prop #![feature(thread_local)] @@ -9,26 +9,26 @@ enum E { B, } -// EMIT_MIR simplify_locals.c.SimplifyLocals.diff +// EMIT_MIR simplify_locals.c.SimplifyLocals-before-const-prop.diff fn c() { let bytes = [0u8; 10]; // Unused cast let _: &[u8] = &bytes; } -// EMIT_MIR simplify_locals.d1.SimplifyLocals.diff +// EMIT_MIR simplify_locals.d1.SimplifyLocals-before-const-prop.diff fn d1() { // Unused set discriminant let _ = E::A; } -// EMIT_MIR simplify_locals.d2.SimplifyLocals.diff +// EMIT_MIR simplify_locals.d2.SimplifyLocals-before-const-prop.diff fn d2() { // Unused set discriminant {(10, E::A)}.1 = E::B; } -// EMIT_MIR simplify_locals.r.SimplifyLocals.diff +// EMIT_MIR simplify_locals.r.SimplifyLocals-before-const-prop.diff fn r() { let mut a = 1; // Unused references @@ -38,31 +38,31 @@ fn r() { #[thread_local] static mut X: u32 = 0; -// EMIT_MIR simplify_locals.t1.SimplifyLocals.diff +// EMIT_MIR simplify_locals.t1.SimplifyLocals-before-const-prop.diff fn t1() { // Unused thread local unsafe { X }; } -// EMIT_MIR simplify_locals.t2.SimplifyLocals.diff +// EMIT_MIR simplify_locals.t2.SimplifyLocals-before-const-prop.diff fn t2() { // Unused thread local unsafe { &mut X }; } -// EMIT_MIR simplify_locals.t3.SimplifyLocals.diff +// EMIT_MIR simplify_locals.t3.SimplifyLocals-before-const-prop.diff fn t3() { // Unused thread local unsafe { *&mut X }; } -// EMIT_MIR simplify_locals.t4.SimplifyLocals.diff +// EMIT_MIR simplify_locals.t4.SimplifyLocals-before-const-prop.diff fn t4() -> u32 { // Used thread local unsafe { X + 1 } } -// EMIT_MIR simplify_locals.expose_addr.SimplifyLocals.diff +// EMIT_MIR simplify_locals.expose_addr.SimplifyLocals-before-const-prop.diff fn expose_addr(p: *const usize) { // Used pointer to address cast. Has a side effect of exposing the provenance. p as usize; diff --git a/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t1.SimplifyLocals-before-const-prop.diff index 49db7747963..1b2e1158e45 100644 --- a/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.t1.SimplifyLocals-before-const-prop.diff @@ -1,5 +1,5 @@ -- // MIR for `t1` before SimplifyLocals -+ // MIR for `t1` after SimplifyLocals +- // MIR for `t1` before SimplifyLocals-before-const-prop ++ // MIR for `t1` after SimplifyLocals-before-const-prop fn t1() -> () { let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9 diff --git a/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t2.SimplifyLocals-before-const-prop.diff index e3f4ae3701b..cf019357be7 100644 --- a/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.t2.SimplifyLocals-before-const-prop.diff @@ -1,5 +1,5 @@ -- // MIR for `t2` before SimplifyLocals -+ // MIR for `t2` after SimplifyLocals +- // MIR for `t2` before SimplifyLocals-before-const-prop ++ // MIR for `t2` after SimplifyLocals-before-const-prop fn t2() -> () { let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9 diff --git a/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t3.SimplifyLocals-before-const-prop.diff index f1ce7778e19..90ee215808c 100644 --- a/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.t3.SimplifyLocals-before-const-prop.diff @@ -1,5 +1,5 @@ -- // MIR for `t3` before SimplifyLocals -+ // MIR for `t3` after SimplifyLocals +- // MIR for `t3` before SimplifyLocals-before-const-prop ++ // MIR for `t3` after SimplifyLocals-before-const-prop fn t3() -> () { let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9 diff --git a/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t4.SimplifyLocals-before-const-prop.diff index 71cf9594b9e..9add9a6c5e0 100644 --- a/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.t4.SimplifyLocals-before-const-prop.diff @@ -1,5 +1,5 @@ -- // MIR for `t4` before SimplifyLocals -+ // MIR for `t4` after SimplifyLocals +- // MIR for `t4` before SimplifyLocals-before-const-prop ++ // MIR for `t4` after SimplifyLocals-before-const-prop fn t4() -> u32 { let mut _0: u32; // return place in scope 0 at $DIR/simplify_locals.rs:+0:12: +0:15 diff --git a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff index a2b55229303..f888c622d90 100644 --- a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff @@ -1,5 +1,5 @@ -- // MIR for `foo` before SimplifyLocals -+ // MIR for `foo` after SimplifyLocals +- // MIR for `foo` before SimplifyLocals-final ++ // MIR for `foo` after SimplifyLocals-final fn foo() -> () { let mut _0: (); // return place in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+0:13: +0:13 diff --git a/src/test/mir-opt/simplify_locals_fixedpoint.rs b/src/test/mir-opt/simplify_locals_fixedpoint.rs index 78b1f9f55e5..1fdba6e99e3 100644 --- a/src/test/mir-opt/simplify_locals_fixedpoint.rs +++ b/src/test/mir-opt/simplify_locals_fixedpoint.rs @@ -12,4 +12,4 @@ fn main() { foo::<()>(); } -// EMIT_MIR simplify_locals_fixedpoint.foo.SimplifyLocals.diff +// EMIT_MIR simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff diff --git a/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff index 78272272b07..efb2b0961cc 100644 --- a/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before SimplifyLocals -+ // MIR for `main` after SimplifyLocals +- // MIR for `main` before SimplifyLocals-before-const-prop ++ // MIR for `main` after SimplifyLocals-before-const-prop fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+0:11: +0:11 diff --git a/src/test/mir-opt/simplify_locals_removes_unused_consts.rs b/src/test/mir-opt/simplify_locals_removes_unused_consts.rs index 39b7911d4ae..7a03a2837ae 100644 --- a/src/test/mir-opt/simplify_locals_removes_unused_consts.rs +++ b/src/test/mir-opt/simplify_locals_removes_unused_consts.rs @@ -1,4 +1,4 @@ -// unit-test: SimplifyLocals +// unit-test: SimplifyLocals-before-const-prop // compile-flags: -C overflow-checks=no fn use_zst(_: ((), ())) {} @@ -9,7 +9,7 @@ struct Temp { fn use_u8(_: u8) {} -// EMIT_MIR simplify_locals_removes_unused_consts.main.SimplifyLocals.diff +// EMIT_MIR simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff fn main() { let ((), ()) = ((), ()); use_zst(((), ())); diff --git a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff index 9ec138dd82f..027c983e6b4 100644 --- a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff @@ -1,5 +1,5 @@ -- // MIR for `map` before SimplifyLocals -+ // MIR for `map` after SimplifyLocals +- // MIR for `map` before SimplifyLocals-before-const-prop ++ // MIR for `map` after SimplifyLocals-before-const-prop fn map(_1: Option<Box<()>>) -> Option<Box<()>> { debug x => _1; // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+0:8: +0:9 diff --git a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs index d09bd92c4e8..de65857412c 100644 --- a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs +++ b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs @@ -1,4 +1,4 @@ -// unit-test: SimplifyLocals +// unit-test: SimplifyLocals-before-const-prop fn map(x: Option<Box<()>>) -> Option<Box<()>> { match x { @@ -11,4 +11,4 @@ fn main() { map(None); } -// EMIT_MIR simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff +// EMIT_MIR simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff diff --git a/src/test/mir-opt/simplify_match.main.ConstProp.diff b/src/test/mir-opt/simplify_match.main.ConstProp.diff index f00ac5716a7..70bfbf1b3e3 100644 --- a/src/test/mir-opt/simplify_match.main.ConstProp.diff +++ b/src/test/mir-opt/simplify_match.main.ConstProp.diff @@ -21,7 +21,6 @@ } bb1: { - nop; // scope 0 at $DIR/simplify_match.rs:+3:18: +3:20 goto -> bb3; // scope 0 at $DIR/simplify_match.rs:+3:18: +3:20 } diff --git a/src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals.after.mir b/src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals-final.after.mir index 2c0fcc6621a..b4fb330f3df 100644 --- a/src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals.after.mir +++ b/src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals-final.after.mir @@ -1,4 +1,4 @@ -// MIR for `process_never` after SimplifyLocals +// MIR for `process_never` after SimplifyLocals-final fn process_never(_1: *const !) -> () { debug input => _1; // in scope 0 at $DIR/uninhabited_enum.rs:+0:22: +0:27 diff --git a/src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals.after.mir b/src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals-final.after.mir index ae341a7b97b..2af864998cb 100644 --- a/src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals.after.mir +++ b/src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals-final.after.mir @@ -1,4 +1,4 @@ -// MIR for `process_void` after SimplifyLocals +// MIR for `process_void` after SimplifyLocals-final fn process_void(_1: *const Void) -> () { debug input => _1; // in scope 0 at $DIR/uninhabited_enum.rs:+0:21: +0:26 diff --git a/src/test/mir-opt/uninhabited_enum.rs b/src/test/mir-opt/uninhabited_enum.rs index 97c6e8cd531..19db548157a 100644 --- a/src/test/mir-opt/uninhabited_enum.rs +++ b/src/test/mir-opt/uninhabited_enum.rs @@ -2,13 +2,13 @@ pub enum Void {} -// EMIT_MIR uninhabited_enum.process_never.SimplifyLocals.after.mir +// EMIT_MIR uninhabited_enum.process_never.SimplifyLocals-final.after.mir #[no_mangle] pub fn process_never(input: *const !) { let _input = unsafe { &*input }; } -// EMIT_MIR uninhabited_enum.process_void.SimplifyLocals.after.mir +// EMIT_MIR uninhabited_enum.process_void.SimplifyLocals-final.after.mir #[no_mangle] pub fn process_void(input: *const Void) { let _input = unsafe { &*input }; diff --git a/src/test/mir-opt/while_let_loops.change_loop_body.ConstProp.diff b/src/test/mir-opt/while_let_loops.change_loop_body.ConstProp.diff index 984ef476e10..bb1de59d4a7 100644 --- a/src/test/mir-opt/while_let_loops.change_loop_body.ConstProp.diff +++ b/src/test/mir-opt/while_let_loops.change_loop_body.ConstProp.diff @@ -4,13 +4,8 @@ fn change_loop_body() -> () { let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:+0:27: +0:27 let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15 - let mut _2: (); // in scope 0 at $DIR/while_let_loops.rs:+0:1: +6:2 - let mut _3: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:+2:28: +2:32 - let mut _4: isize; // in scope 0 at $DIR/while_let_loops.rs:+2:15: +2:25 - let mut _5: !; // in scope 0 at $DIR/while_let_loops.rs:+2:33: +5:6 - let mut _6: !; // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6 - let _7: (); // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6 - let mut _8: !; // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6 + let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:+2:28: +2:32 + let mut _3: isize; // in scope 0 at $DIR/while_let_loops.rs:+2:15: +2:25 scope 1 { debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:+1:9: +1:15 scope 2 { @@ -20,34 +15,30 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15 _1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:+1:18: +1:19 - StorageLive(_3); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 - Deinit(_3); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 - discriminant(_3) = 0; // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 -- _4 = discriminant(_3); // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 -- switchInt(move _4) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 -+ _4 = const 0_isize; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 + StorageLive(_2); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 + Deinit(_2); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 + discriminant(_2) = 0; // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 +- _3 = discriminant(_2); // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 +- switchInt(move _3) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 ++ _3 = const 0_isize; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 + switchInt(const 0_isize) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 } bb1: { - switchInt(((_3 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 + switchInt(((_2 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 } bb2: { _1 = const 1_i32; // scope 2 at $DIR/while_let_loops.rs:+3:9: +3:15 - nop; // scope 2 at $DIR/while_let_loops.rs:+4:9: +4:14 goto -> bb4; // scope 2 at $DIR/while_let_loops.rs:+4:9: +4:14 } bb3: { - StorageLive(_7); // scope 1 at $DIR/while_let_loops.rs:+2:5: +5:6 - nop; // scope 1 at $DIR/while_let_loops.rs:+2:5: +5:6 - StorageDead(_7); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6 goto -> bb4; // scope 1 at no-location } bb4: { - StorageDead(_3); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6 + StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6 StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:+6:1: +6:2 return; // scope 0 at $DIR/while_let_loops.rs:+6:2: +6:2 } diff --git a/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir b/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir index 1556c240dc5..b95d91b13dd 100644 --- a/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir +++ b/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir @@ -44,7 +44,7 @@ fn while_loop(_1: bool) -> () { bb5: { StorageDead(_4); // scope 0 at $DIR/while_storage.rs:+4:9: +4:10 - goto -> bb8; // scope 0 at no-location + goto -> bb7; // scope 0 at no-location } bb6: { @@ -54,10 +54,6 @@ fn while_loop(_1: bool) -> () { } bb7: { - goto -> bb8; // scope 0 at no-location - } - - bb8: { StorageDead(_2); // scope 0 at $DIR/while_storage.rs:+5:5: +5:6 return; // scope 0 at $DIR/while_storage.rs:+6:2: +6:2 } diff --git a/src/test/run-make/dump-mono-stats/Makefile b/src/test/run-make/dump-mono-stats/Makefile new file mode 100644 index 00000000000..fe1112fb0a4 --- /dev/null +++ b/src/test/run-make/dump-mono-stats/Makefile @@ -0,0 +1,5 @@ +include ../../run-make-fulldeps/tools.mk + +all: + $(RUSTC) --crate-type lib foo.rs -Z dump-mono-stats=$(TMPDIR) -Zdump-mono-stats-format=json + cat $(TMPDIR)/foo.mono_items.json | $(CGREP) '"name":"bar"' diff --git a/src/test/run-make/dump-mono-stats/foo.rs b/src/test/run-make/dump-mono-stats/foo.rs new file mode 100644 index 00000000000..c5c0bc606cd --- /dev/null +++ b/src/test/run-make/dump-mono-stats/foo.rs @@ -0,0 +1 @@ +pub fn bar() {} diff --git a/src/test/rustdoc-gui/anchors.goml b/src/test/rustdoc-gui/anchors.goml index fb8e288fae8..c9b53a1a0f7 100644 --- a/src/test/rustdoc-gui/anchors.goml +++ b/src/test/rustdoc-gui/anchors.goml @@ -3,70 +3,72 @@ define-function: ( "check-colors", (theme, main_color, title_color, fqn_color, fqn_type_color, src_link_color, sidebar_link_color), - [ - ("goto", "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html"), + block { + goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" // This is needed to ensure that the text color is computed. - ("show-text", true), + show-text: true // Setting the theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. - ("reload"), + reload: - ("assert-css", ("#toggle-all-docs", {"color": |main_color|})), - ("assert-css", (".fqn a:nth-of-type(1)", {"color": |fqn_color|})), - ("assert-css", (".fqn a:nth-of-type(2)", {"color": |fqn_type_color|})), - ("assert-css", ( + assert-css: ("#toggle-all-docs", {"color": |main_color|}) + assert-css: (".fqn a:nth-of-type(1)", {"color": |fqn_color|}) + assert-css: (".fqn a:nth-of-type(2)", {"color": |fqn_type_color|}) + assert-css: ( ".rightside .srclink", {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, ALL, - )), - ( - "compare-elements-css", - (".rightside .srclink", ".rightside.srclink", ["color", "text-decoration"]), - ), - ( - "compare-elements-css", - (".main-heading .srclink", ".rightside.srclink", ["color", "text-decoration"]), - ), + ) + compare-elements-css: ( + ".rightside .srclink", + ".rightside.srclink", + ["color", "text-decoration"], + ) + compare-elements-css: ( + ".main-heading .srclink", + ".rightside.srclink", + ["color", "text-decoration"], + ) - ("move-cursor-to", ".main-heading .srclink"), - ("assert-css", ( + move-cursor-to: ".main-heading .srclink" + assert-css: ( ".main-heading .srclink", {"color": |src_link_color|, "text-decoration": "underline solid " + |src_link_color|}, - )), - ("move-cursor-to", ".impl-items .rightside .srclink"), - ("assert-css", ( + ) + move-cursor-to: ".impl-items .rightside .srclink" + assert-css: ( ".impl-items .rightside .srclink", {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, - )), - ("move-cursor-to", ".impl-items .rightside.srclink"), - ("assert-css", ( + ) + move-cursor-to: ".impl-items .rightside.srclink" + assert-css: ( ".impl-items .rightside.srclink", {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, - )), + ) - ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"), + goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" // Since we changed page, we need to set the theme again. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. - ("reload"), + reload: - ("assert-css", ("#top-doc-prose-title", {"color": |title_color|})), + assert-css: ("#top-doc-prose-title", {"color": |title_color|}) - ("assert-css", (".sidebar a", {"color": |sidebar_link_color|})), - ("assert-css", ("h1.fqn a", {"color": |title_color|})), + assert-css: (".sidebar a", {"color": |sidebar_link_color|}) + assert-css: ("h1.fqn a", {"color": |title_color|}) // We move the cursor over the "Implementations" title so the anchor is displayed. - ("move-cursor-to", "h2#implementations"), - ("assert-css", ("h2#implementations a.anchor", {"color": |main_color|})), + move-cursor-to: "h2#implementations" + assert-css: ("h2#implementations a.anchor", {"color": |main_color|}) // Same thing with the impl block title. - ("move-cursor-to", "#impl-HeavilyDocumentedStruct"), - ("assert-css", ("#impl-HeavilyDocumentedStruct a.anchor", {"color": |main_color|})), + move-cursor-to: "#impl-HeavilyDocumentedStruct" + assert-css: ("#impl-HeavilyDocumentedStruct a.anchor", {"color": |main_color|}) - ("assert-css", ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})), - ], + assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"}) + }, ) call-function: ( diff --git a/src/test/rustdoc-gui/code-color.goml b/src/test/rustdoc-gui/code-color.goml index 118f04ad6dc..cb550a4573a 100644 --- a/src/test/rustdoc-gui/code-color.goml +++ b/src/test/rustdoc-gui/code-color.goml @@ -9,14 +9,14 @@ show-text: true define-function: ( "check-colors", (theme, doc_code_color, doc_inline_code_color), - [ + block { // Set the theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. - ("reload"), - ("assert-css", (".docblock pre > code", {"color": |doc_code_color|}, ALL)), - ("assert-css", (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL)), - ], + reload: + assert-css: (".docblock pre > code", {"color": |doc_code_color|}, ALL) + assert-css: (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL) + }, ) call-function: ("check-colors", ("ayu", "rgb(230, 225, 207)", "rgb(255, 180, 84)")) diff --git a/src/test/rustdoc-gui/codeblock-tooltip.goml b/src/test/rustdoc-gui/codeblock-tooltip.goml index d4443f821d2..a3ef4e77b54 100644 --- a/src/test/rustdoc-gui/codeblock-tooltip.goml +++ b/src/test/rustdoc-gui/codeblock-tooltip.goml @@ -5,32 +5,32 @@ show-text: true define-function: ( "check-colors", (theme, background, color, border), - [ + block { // Setting the theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: // compile_fail block - ("assert-css", ( + assert-css: ( ".docblock .example-wrap.compile_fail .tooltip", {"color": "rgba(255, 0, 0, 0.5)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}, - )), + ) - ("move-cursor-to", ".docblock .example-wrap.compile_fail .tooltip"), + move-cursor-to: ".docblock .example-wrap.compile_fail .tooltip" - ("assert-css", ( + assert-css: ( ".docblock .example-wrap.compile_fail .tooltip", {"color": "rgb(255, 0, 0)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgb(255, 0, 0)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.compile_fail .tooltip::after", { "content": '"This example deliberately fails to compile"', @@ -39,37 +39,37 @@ define-function: ( "color": |color|, "border": "1px solid " + |border|, }, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.compile_fail .tooltip::before", { "border-width": "5px", "border-style": "solid", "border-color": "rgba(0, 0, 0, 0) " + |background| + " rgba(0, 0, 0, 0) rgba(0, 0, 0, 0)", }, - )), + ) // should_panic block - ("assert-css", ( + assert-css: ( ".docblock .example-wrap.should_panic .tooltip", {"color": "rgba(255, 0, 0, 0.5)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.should_panic", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}, - )), + ) - ("move-cursor-to", ".docblock .example-wrap.should_panic .tooltip"), + move-cursor-to: ".docblock .example-wrap.should_panic .tooltip" - ("assert-css", ( + assert-css: ( ".docblock .example-wrap.should_panic .tooltip", {"color": "rgb(255, 0, 0)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.should_panic", {"border-left": "2px solid rgb(255, 0, 0)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.should_panic .tooltip::after", { "content": '"This example panics"', @@ -78,37 +78,37 @@ define-function: ( "color": |color|, "border": "1px solid " + |border|, }, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.should_panic .tooltip::before", { "border-width": "5px", "border-style": "solid", "border-color": "rgba(0, 0, 0, 0) " + |background| + " rgba(0, 0, 0, 0) rgba(0, 0, 0, 0)", }, - )), + ) // ignore block - ("assert-css", ( + assert-css: ( ".docblock .example-wrap.ignore .tooltip", {"color": "rgba(255, 142, 0, 0.6)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.ignore", {"border-left": "2px solid rgba(255, 142, 0, 0.6)"}, - )), + ) - ("move-cursor-to", ".docblock .example-wrap.ignore .tooltip"), + move-cursor-to: ".docblock .example-wrap.ignore .tooltip" - ("assert-css", ( + assert-css: ( ".docblock .example-wrap.ignore .tooltip", {"color": "rgb(255, 142, 0)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.ignore", {"border-left": "2px solid rgb(255, 142, 0)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.ignore .tooltip::after", { "content": '"This example is not tested"', @@ -117,16 +117,16 @@ define-function: ( "color": |color|, "border": "1px solid " + |border|, }, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.ignore .tooltip::before", { "border-width": "5px", "border-style": "solid", "border-color": "rgba(0, 0, 0, 0) " + |background| + " rgba(0, 0, 0, 0) rgba(0, 0, 0, 0)", }, - )), - ], + ) + }, ) call-function: ("check-colors", { diff --git a/src/test/rustdoc-gui/docblock-code-block-line-number.goml b/src/test/rustdoc-gui/docblock-code-block-line-number.goml index a3ed008719c..69bcf5339ef 100644 --- a/src/test/rustdoc-gui/docblock-code-block-line-number.goml +++ b/src/test/rustdoc-gui/docblock-code-block-line-number.goml @@ -11,19 +11,19 @@ assert-false: "pre.example-line-numbers" define-function: ( "check-colors", (theme, color), - [ + block { // We now set the setting to show the line numbers on code examples. - ("local-storage", { + local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", "rustdoc-line-numbers": "true" - }), + } // We reload to make the line numbers appear and change theme. - ("reload"), + reload: // We wait for them to be added into the DOM by the JS... - ("wait-for", "pre.example-line-numbers"), + wait-for: "pre.example-line-numbers" // If the test didn't fail, it means that it was found! - ("assert-css", ( + assert-css: ( "pre.example-line-numbers", { "color": |color|, @@ -32,8 +32,8 @@ define-function: ( "text-align": "right", }, ALL, - )), - ], + ) + }, ) call-function: ("check-colors", { "theme": "ayu", diff --git a/src/test/rustdoc-gui/docblock-table.goml b/src/test/rustdoc-gui/docblock-table.goml index 6f9209e0ab4..3dcb8abd415 100644 --- a/src/test/rustdoc-gui/docblock-table.goml +++ b/src/test/rustdoc-gui/docblock-table.goml @@ -7,32 +7,32 @@ compare-elements-css: (".impl-items .docblock table td", ".top-doc .docblock tab define-function: ( "check-colors", (theme, border_color, zebra_stripe_color), - [ - ("local-storage", {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}), - ("reload"), - ("assert-css", (".top-doc .docblock table tbody tr:nth-child(1)", { + block { + local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} + reload: + assert-css: (".top-doc .docblock table tbody tr:nth-child(1)", { "background-color": "rgba(0, 0, 0, 0)", - })), - ("assert-css", (".top-doc .docblock table tbody tr:nth-child(2)", { + }) + assert-css: (".top-doc .docblock table tbody tr:nth-child(2)", { "background-color": |zebra_stripe_color|, - })), - ("assert-css", (".top-doc .docblock table tbody tr:nth-child(3)", { + }) + assert-css: (".top-doc .docblock table tbody tr:nth-child(3)", { "background-color": "rgba(0, 0, 0, 0)", - })), - ("assert-css", (".top-doc .docblock table tbody tr:nth-child(4)", { + }) + assert-css: (".top-doc .docblock table tbody tr:nth-child(4)", { "background-color": |zebra_stripe_color|, - })), - ("assert-css", (".top-doc .docblock table td", { + }) + assert-css: (".top-doc .docblock table td", { "border-style": "solid", "border-width": "1px", "border-color": |border_color|, - })), - ("assert-css", (".top-doc .docblock table th", { + }) + assert-css: (".top-doc .docblock table th", { "border-style": "solid", "border-width": "1px", "border-color": |border_color|, - })), - ] + }) + } ) call-function: ("check-colors", { diff --git a/src/test/rustdoc-gui/escape-key.goml b/src/test/rustdoc-gui/escape-key.goml index 78e9f23093e..5d80d24969d 100644 --- a/src/test/rustdoc-gui/escape-key.goml +++ b/src/test/rustdoc-gui/escape-key.goml @@ -5,7 +5,7 @@ goto: "file://" + |DOC_PATH| + "/test_docs/index.html" write: (".search-input", "test") // To be SURE that the search will be run. press-key: 'Enter' -wait-for: "#search h1" // The search element is empty before the first search +wait-for: "#search h1" // The search element is empty before the first search // Check that the currently displayed element is search. wait-for: "#alternative-display #search" assert-attribute: ("#main-content", {"class": "content hidden"}) diff --git a/src/test/rustdoc-gui/headers-color.goml b/src/test/rustdoc-gui/headers-color.goml index c80a49c52f0..92cf050a514 100644 --- a/src/test/rustdoc-gui/headers-color.goml +++ b/src/test/rustdoc-gui/headers-color.goml @@ -3,39 +3,39 @@ define-function: ( "check-colors", (theme, color, code_header_color, focus_background_color, headings_color), - [ - ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"), + block { + goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" // This is needed so that the text color is computed. - ("show-text", true), - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("assert-css", ( + show-text: true + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + assert-css: ( ".impl", {"color": |color|, "background-color": "rgba(0, 0, 0, 0)"}, ALL, - )), - ("assert-css", ( + ) + assert-css: ( ".impl .code-header", {"color": |code_header_color|, "background-color": "rgba(0, 0, 0, 0)"}, ALL, - )), - ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo"), - ("assert-css", ( + ) + goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo" + assert-css: ( "#impl-Foo", {"color": |color|, "background-color": |focus_background_color|}, - )), - ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use"), - ("assert-css", ( + ) + goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use" + assert-css: ( "#method\.must_use", {"color": |color|, "background-color": |focus_background_color|}, ALL, - )), - ("goto", "file://" + |DOC_PATH| + "/test_docs/index.html"), - ("assert-css", (".small-section-header a", {"color": |color|}, ALL)), - ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"), + ) + goto: "file://" + |DOC_PATH| + "/test_docs/index.html" + assert-css: (".small-section-header a", {"color": |color|}, ALL) + goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" // We select headings (h2, h3, h...). - ("assert-css", (".docblock > :not(p) > a", {"color": |headings_color|}, ALL)), - ], + assert-css: (".docblock > :not(p) > a", {"color": |headings_color|}, ALL) + }, ) call-function: ( diff --git a/src/test/rustdoc-gui/headings.goml b/src/test/rustdoc-gui/headings.goml index 85e17ca9551..45b3fee26e4 100644 --- a/src/test/rustdoc-gui/headings.goml +++ b/src/test/rustdoc-gui/headings.goml @@ -157,38 +157,38 @@ goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" define-function: ( "check-colors", (theme, heading_color, small_heading_color, heading_border_color), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("assert-css", ( + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + assert-css: ( ".top-doc .docblock h2", {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, - )), - ("assert-css", ( + ) + assert-css: ( ".top-doc .docblock h3", {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, - )), - ("assert-css", ( + ) + assert-css: ( ".top-doc .docblock h4", {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, - )), - ("assert-css", ( + ) + assert-css: ( ".top-doc .docblock h5", {"color": |small_heading_color|, "border-bottom-width": "0px"}, - )), - ("assert-css", ( + ) + assert-css: ( "#implementations-list .docblock h4", {"color": |heading_color|, "border-bottom-width": "0px"}, - )), - ("assert-css", ( + ) + assert-css: ( "#implementations-list .docblock h5", {"color": |small_heading_color|, "border-bottom-width": "0px"}, - )), - ("assert-css", ( + ) + assert-css: ( "#implementations-list .docblock h6", {"color": |small_heading_color|, "border-bottom-width": "0px"}, - )), - ], + ) + }, ) call-function: ( "check-colors", @@ -221,11 +221,11 @@ call-function: ( define-function: ( "check-since-color", (theme), - [ - ("local-storage", {"rustdoc-theme": |theme|}), - ("reload"), - ("assert-css", (".since", {"color": "rgb(128, 128, 128)"}, ALL)), - ], + block { + local-storage: {"rustdoc-theme": |theme|} + reload: + assert-css: (".since", {"color": "rgb(128, 128, 128)"}, ALL) + }, ) goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" diff --git a/src/test/rustdoc-gui/help-page.goml b/src/test/rustdoc-gui/help-page.goml index 80203901ed3..5f4c1ba2f85 100644 --- a/src/test/rustdoc-gui/help-page.goml +++ b/src/test/rustdoc-gui/help-page.goml @@ -18,17 +18,17 @@ show-text: true define-function: ( "check-colors", (theme, color, background, box_shadow), - [ + block { // Setting the theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. - ("reload"), - ("assert-css", ("#help kbd", { + reload: + assert-css: ("#help kbd", { "color": |color|, "background-color": |background|, "box-shadow": |box_shadow| + " 0px -1px 0px 0px inset", - }, ALL)), - ], + }, ALL) + }, ) call-function: ("check-colors", { @@ -39,7 +39,7 @@ call-function: ("check-colors", { }) call-function: ("check-colors", { "theme": "dark", - "color": "rgb(221, 221, 221)", + "color": "rgb(0, 0, 0)", "background": "rgb(250, 251, 252)", "box_shadow": "rgb(198, 203, 209)", }) @@ -61,3 +61,12 @@ click: "#help-button > a" assert-css: ("#help", {"display": "none"}) compare-elements-property-false: (".sub", "#help", ["offsetWidth"]) compare-elements-position-false: (".sub", "#help", ("x")) + +// This test ensures that the "the rustdoc book" anchor link within the help popover works. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +size: (1000, 1000) // Popover only appears when the screen width is >700px. +assert-false: "#help" +click: "#help-button > a" +click: ".popover a[href='https://doc.rust-lang.org/rustdoc/']" +wait-for: 2000 +assert-document-property: {"URL": "https://doc.rust-lang.org/rustdoc/"} diff --git a/src/test/rustdoc-gui/highlight-colors.goml b/src/test/rustdoc-gui/highlight-colors.goml index ff1be389dcb..b182150a577 100644 --- a/src/test/rustdoc-gui/highlight-colors.goml +++ b/src/test/rustdoc-gui/highlight-colors.goml @@ -21,24 +21,24 @@ define-function: ( comment, doc_comment, ), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("assert-css", ("pre.rust .kw", {"color": |kw|}, ALL)), - ("assert-css", ("pre.rust .kw-2", {"color": |kw2|}, ALL)), - ("assert-css", ("pre.rust .prelude-ty", {"color": |prelude_ty|}, ALL)), - ("assert-css", ("pre.rust .prelude-val", {"color": |prelude_val|}, ALL)), - ("assert-css", ("pre.rust .lifetime", {"color": |lifetime|}, ALL)), - ("assert-css", ("pre.rust .number", {"color": |number|}, ALL)), - ("assert-css", ("pre.rust .string", {"color": |string|}, ALL)), - ("assert-css", ("pre.rust .bool-val", {"color": |bool_val|}, ALL)), - ("assert-css", ("pre.rust .self", {"color": |self|}, ALL)), - ("assert-css", ("pre.rust .attr", {"color": |attr|}, ALL)), - ("assert-css", ("pre.rust .macro", {"color": |macro|}, ALL)), - ("assert-css", ("pre.rust .question-mark", {"color": |question_mark|}, ALL)), - ("assert-css", ("pre.rust .comment", {"color": |comment|}, ALL)), - ("assert-css", ("pre.rust .doccomment", {"color": |doc_comment|}, ALL)), - ], + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + assert-css: ("pre.rust .kw", {"color": |kw|}, ALL) + assert-css: ("pre.rust .kw-2", {"color": |kw2|}, ALL) + assert-css: ("pre.rust .prelude-ty", {"color": |prelude_ty|}, ALL) + assert-css: ("pre.rust .prelude-val", {"color": |prelude_val|}, ALL) + assert-css: ("pre.rust .lifetime", {"color": |lifetime|}, ALL) + assert-css: ("pre.rust .number", {"color": |number|}, ALL) + assert-css: ("pre.rust .string", {"color": |string|}, ALL) + assert-css: ("pre.rust .bool-val", {"color": |bool_val|}, ALL) + assert-css: ("pre.rust .self", {"color": |self|}, ALL) + assert-css: ("pre.rust .attr", {"color": |attr|}, ALL) + assert-css: ("pre.rust .macro", {"color": |macro|}, ALL) + assert-css: ("pre.rust .question-mark", {"color": |question_mark|}, ALL) + assert-css: ("pre.rust .comment", {"color": |comment|}, ALL) + assert-css: ("pre.rust .doccomment", {"color": |doc_comment|}, ALL) + }, ) call-function: ("check-colors", { diff --git a/src/test/rustdoc-gui/impl-doc.goml b/src/test/rustdoc-gui/impl-doc.goml index 7322032b3f5..6caffb9c39f 100644 --- a/src/test/rustdoc-gui/impl-doc.goml +++ b/src/test/rustdoc-gui/impl-doc.goml @@ -3,7 +3,7 @@ goto: "file://" + |DOC_PATH| + "/test_docs/struct.TypeWithImplDoc.html" // The text is about 24px tall, so if there's a margin, then their position will be >24px apart compare-elements-position-near-false: ( - "#implementations-list > .implementors-toggle > .docblock > p", - "#implementations-list > .implementors-toggle > .impl-items", - {"y": 24} + "#implementations-list > .implementors-toggle > .docblock > p", + "#implementations-list > .implementors-toggle > .impl-items", + {"y": 24} ) diff --git a/src/test/rustdoc-gui/implementors.goml b/src/test/rustdoc-gui/implementors.goml index 4999283dc8b..997c0ed8f01 100644 --- a/src/test/rustdoc-gui/implementors.goml +++ b/src/test/rustdoc-gui/implementors.goml @@ -33,3 +33,9 @@ goto: "file://" + |DOC_PATH| + "/lib2/trait.TraitToReexport.html" assert-count: ("#implementors-list .impl", 1) goto: "file://" + |DOC_PATH| + "/implementors/trait.TraitToReexport.html" assert-count: ("#implementors-list .impl", 1) + +// Now check that the link is properly rewritten for a crate called `http`. +// An older version of rustdoc had a buggy check for absolute links. +goto: "file://" + |DOC_PATH| + "/http/trait.HttpTrait.html" +assert-count: ("#implementors-list .impl", 1) +assert-attribute: ("#implementors-list .impl a.trait", {"href": "../http/trait.HttpTrait.html"}) diff --git a/src/test/rustdoc-gui/item-decl-colors.goml b/src/test/rustdoc-gui/item-decl-colors.goml index 2e07f19b13d..c58e3eb7c23 100644 --- a/src/test/rustdoc-gui/item-decl-colors.goml +++ b/src/test/rustdoc-gui/item-decl-colors.goml @@ -17,22 +17,23 @@ define-function: ( fn_color, assoc_type_color, ), - [ - ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html"), - ("show-text", true), - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("assert-css", (".item-decl .code-attribute", {"color": |attr_color|}, ALL)), - ("assert-css", (".item-decl .trait", {"color": |trait_color|}, ALL)), + block { + goto: "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html" + show-text: true + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + assert-css: (".item-decl .code-attribute", {"color": |attr_color|}, ALL) + assert-css: (".item-decl .trait", {"color": |trait_color|}, ALL) // We need to add `code` here because otherwise it would select the parent too. - ("assert-css", (".item-decl code .struct", {"color": |struct_color|}, ALL)), - ("assert-css", (".item-decl .enum", {"color": |enum_color|}, ALL)), - ("assert-css", (".item-decl .primitive", {"color": |primitive_color|}, ALL)), - ("goto", "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithoutGenerics.html"), - ("assert-css", (".item-decl .constant", {"color": |constant_color|}, ALL)), - ("assert-css", (".item-decl .fn", {"color": |fn_color|}, ALL)), - ("assert-css", (".item-decl .associatedtype", {"color": |assoc_type_color|}, ALL)), - ], + assert-css: (".item-decl code .struct", {"color": |struct_color|}, ALL) + assert-css: (".item-decl .enum", {"color": |enum_color|}, ALL) + assert-css: (".item-decl .primitive", {"color": |primitive_color|}, ALL) + + goto: "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithoutGenerics.html" + assert-css: (".item-decl .constant", {"color": |constant_color|}, ALL) + assert-css: (".item-decl .fn", {"color": |fn_color|}, ALL) + assert-css: (".item-decl .associatedtype", {"color": |assoc_type_color|}, ALL) + }, ) call-function: ( diff --git a/src/test/rustdoc-gui/jump-to-def-background.goml b/src/test/rustdoc-gui/jump-to-def-background.goml index b65faf13d0c..8ee3ccf4a21 100644 --- a/src/test/rustdoc-gui/jump-to-def-background.goml +++ b/src/test/rustdoc-gui/jump-to-def-background.goml @@ -4,17 +4,17 @@ goto: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" define-function: ( "check-background-color", (theme, background_color), - [ + block { // Set the theme. - ("local-storage", { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" }), + local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" } // We reload the page so the local storage settings are being used. - ("reload"), - ("assert-css", ( + reload: + assert-css: ( "body.source .example-wrap pre.rust a", {"background-color": |background_color|}, ALL, - )), - ], + ) + }, ) call-function: ("check-background-color", ("ayu", "rgb(51, 51, 51)")) diff --git a/src/test/rustdoc-gui/links-color.goml b/src/test/rustdoc-gui/links-color.goml index 9402c09eb69..14f7d99351a 100644 --- a/src/test/rustdoc-gui/links-color.goml +++ b/src/test/rustdoc-gui/links-color.goml @@ -8,29 +8,29 @@ define-function: ( "check-colors", (theme, mod, macro, struct, enum, trait, fn, type, union, keyword, sidebar, sidebar_current, sidebar_current_background), - [ - ("local-storage", { + block { + local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", - }), - ("reload"), + } + reload: // Checking results colors. - ("assert-css", (".item-table .mod", {"color": |mod|}, ALL)), - ("assert-css", (".item-table .macro", {"color": |macro|}, ALL)), - ("assert-css", (".item-table .struct", {"color": |struct|}, ALL)), - ("assert-css", (".item-table .enum", {"color": |enum|}, ALL)), - ("assert-css", (".item-table .trait", {"color": |trait|}, ALL)), - ("assert-css", (".item-table .fn", {"color": |fn|}, ALL)), - ("assert-css", (".item-table .type", {"color": |type|}, ALL)), - ("assert-css", (".item-table .union", {"color": |union|}, ALL)), - ("assert-css", (".item-table .keyword", {"color": |keyword|}, ALL)), + assert-css: (".item-table .mod", {"color": |mod|}, ALL) + assert-css: (".item-table .macro", {"color": |macro|}, ALL) + assert-css: (".item-table .struct", {"color": |struct|}, ALL) + assert-css: (".item-table .enum", {"color": |enum|}, ALL) + assert-css: (".item-table .trait", {"color": |trait|}, ALL) + assert-css: (".item-table .fn", {"color": |fn|}, ALL) + assert-css: (".item-table .type", {"color": |type|}, ALL) + assert-css: (".item-table .union", {"color": |union|}, ALL) + assert-css: (".item-table .keyword", {"color": |keyword|}, ALL) // Checking sidebar elements. - ("assert-css", ( + assert-css: ( ".sidebar-elems a:not(.current)", {"color": |sidebar|, "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"}, ALL, - )), - ("assert-css", ( + ) + assert-css: ( ".sidebar-elems a.current", { "color": |sidebar_current|, @@ -38,8 +38,8 @@ define-function: ( "font-weight": "500", }, ALL, - )), - ], + ) + }, ) call-function: ( diff --git a/src/test/rustdoc-gui/mobile.goml b/src/test/rustdoc-gui/mobile.goml index 704542a39d2..895864d8944 100644 --- a/src/test/rustdoc-gui/mobile.goml +++ b/src/test/rustdoc-gui/mobile.goml @@ -27,4 +27,8 @@ assert-css-false: (".content .out-of-band .since::before", { "content": "\"Since goto: "file://" + |DOC_PATH| + "/settings.html" size: (400, 600) // Ignored for now https://github.com/rust-lang/rust/issues/93784. -// compare-elements-position-near-false: ("#preferred-light-theme .setting-name", "#preferred-light-theme .choice", {"y": 16}) +// compare-elements-position-near-false: ( +// "#preferred-light-theme .setting-name", +// "#preferred-light-theme .choice", +// {"y": 16}, +// ) diff --git a/src/test/rustdoc-gui/notable-trait.goml b/src/test/rustdoc-gui/notable-trait.goml index 7d4bd27d42d..b4fa7d0dbf0 100644 --- a/src/test/rustdoc-gui/notable-trait.goml +++ b/src/test/rustdoc-gui/notable-trait.goml @@ -123,40 +123,40 @@ assert-count: ("//*[@class='notable popover']", 0) define-function: ( "check-colors", (theme, header_color, content_color, type_color, trait_color), - [ - ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"), + block { + goto: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html" // This is needed to ensure that the text color is computed. - ("show-text", true), + show-text: true // Setting the theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. - ("reload"), + reload: - ("move-cursor-to", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"), - ("assert-count", (".notable.popover", 1)), + move-cursor-to: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']" + assert-count: (".notable.popover", 1) - ("assert-css", ( + assert-css: ( ".notable.popover h3", {"color": |header_color|}, ALL, - )), - ("assert-css", ( + ) + assert-css: ( ".notable.popover pre", {"color": |content_color|}, ALL, - )), - ("assert-css", ( + ) + assert-css: ( ".notable.popover pre a.struct", {"color": |type_color|}, ALL, - )), - ("assert-css", ( + ) + assert-css: ( ".notable.popover pre a.trait", {"color": |trait_color|}, ALL, - )), - ] + ) + }, ) call-function: ( diff --git a/src/test/rustdoc-gui/run-on-hover.goml b/src/test/rustdoc-gui/run-on-hover.goml index 57d63049f28..8dcb62c10aa 100644 --- a/src/test/rustdoc-gui/run-on-hover.goml +++ b/src/test/rustdoc-gui/run-on-hover.goml @@ -8,27 +8,27 @@ show-text: true define-function: ( "check-run-button", (theme, color, background, hover_color, hover_background), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("assert-css", (".test-arrow", {"visibility": "hidden"})), - ("move-cursor-to", ".example-wrap"), - ("assert-css", (".test-arrow", { + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + assert-css: (".test-arrow", {"visibility": "hidden"}) + move-cursor-to: ".example-wrap" + assert-css: (".test-arrow", { "visibility": "visible", "color": |color|, "background-color": |background|, "font-size": "22px", "border-radius": "5px", - })), - ("move-cursor-to", ".test-arrow"), - ("assert-css", (".test-arrow:hover", { + }) + move-cursor-to: ".test-arrow" + assert-css: (".test-arrow:hover", { "visibility": "visible", "color": |hover_color|, "background-color": |hover_background|, "font-size": "22px", "border-radius": "5px", - })), - ], + }) + }, ) call-function: ("check-run-button", { diff --git a/src/test/rustdoc-gui/rust-logo.goml b/src/test/rustdoc-gui/rust-logo.goml index 816cc9abd69..2d15e8b9699 100644 --- a/src/test/rustdoc-gui/rust-logo.goml +++ b/src/test/rustdoc-gui/rust-logo.goml @@ -4,40 +4,55 @@ goto: "file://" + |DOC_PATH| + "/test_docs/index.html" define-function: ( "check-logo", (theme, filter), - [ + block { // Going to the doc page. - ("goto", "file://" + |DOC_PATH| + "/test_docs/index.html"), + goto: "file://" + |DOC_PATH| + "/test_docs/index.html" // Changing theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("assert-css", (".rust-logo", {"filter": |filter|})), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + assert-css: (".rust-logo", {"filter": |filter|}) // Going to the source code page. - ("goto", "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"), + goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" // Changing theme (since it's local files, the local storage works by folder). - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("assert-css", (".rust-logo", {"filter": |filter|})), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + assert-css: (".rust-logo", {"filter": |filter|}) // Now we check that the non-rust logos don't have a CSS filter set. - ("goto", "file://" + |DOC_PATH| + "/huge_logo/index.html"), + goto: "file://" + |DOC_PATH| + "/huge_logo/index.html" // Changing theme on the new page (again...). - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: // Check there is no rust logo - ("assert-false", ".rust-logo"), + assert-false: ".rust-logo" // Check there is no filter. - ("assert-css", (".sidebar .logo-container img", {"filter": "none"})), - ], + assert-css: (".sidebar .logo-container img", {"filter": "none"}) + }, ) call-function: ( "check-logo", - ("ayu", "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"), + { + "theme": "ayu", + "filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) " + + "drop-shadow(rgb(255, 255, 255) 0px 1px 0px) " + + "drop-shadow(rgb(255, 255, 255) -1px 0px 0px) " + + "drop-shadow(rgb(255, 255, 255) 0px -1px 0px)", + }, ) call-function: ( "check-logo", - ("dark", "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"), + { + "theme": "dark", + "filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) " + + "drop-shadow(rgb(255, 255, 255) 0px 1px 0px) " + + "drop-shadow(rgb(255, 255, 255) -1px 0px 0px) " + + "drop-shadow(rgb(255, 255, 255) 0px -1px 0px)", + }, ) call-function: ( "check-logo", - ("light", "none"), + { + "theme": "light", + "filter": "none", + }, ) diff --git a/src/test/rustdoc-gui/scrape-examples-button-focus.goml b/src/test/rustdoc-gui/scrape-examples-button-focus.goml index bba518db099..10651a3f669 100644 --- a/src/test/rustdoc-gui/scrape-examples-button-focus.goml +++ b/src/test/rustdoc-gui/scrape-examples-button-focus.goml @@ -5,25 +5,25 @@ store-property: (initialScrollTop, ".scraped-example-list > .scraped-example pre focus: ".scraped-example-list > .scraped-example .next" press-key: "Enter" assert-property-false: (".scraped-example-list > .scraped-example pre", { - "scrollTop": |initialScrollTop| + "scrollTop": |initialScrollTop| }) focus: ".scraped-example-list > .scraped-example .prev" press-key: "Enter" assert-property: (".scraped-example-list > .scraped-example pre", { - "scrollTop": |initialScrollTop| + "scrollTop": |initialScrollTop| }) // The expand button increases the scrollHeight of the minimized code viewport store-property: (smallOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight") assert-property-false: (".scraped-example-list > .scraped-example pre", { - "scrollHeight": |smallOffsetHeight| + "scrollHeight": |smallOffsetHeight| }) focus: ".scraped-example-list > .scraped-example .expand" press-key: "Enter" assert-property-false: (".scraped-example-list > .scraped-example pre", { - "offsetHeight": |smallOffsetHeight| + "offsetHeight": |smallOffsetHeight| }) store-property: (fullOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight") assert-property: (".scraped-example-list > .scraped-example pre", { - "scrollHeight": |fullOffsetHeight| + "scrollHeight": |fullOffsetHeight| }) diff --git a/src/test/rustdoc-gui/scrape-examples-color.goml b/src/test/rustdoc-gui/scrape-examples-color.goml index 360e2af8ba4..40f31b2771b 100644 --- a/src/test/rustdoc-gui/scrape-examples-color.goml +++ b/src/test/rustdoc-gui/scrape-examples-color.goml @@ -6,29 +6,29 @@ define-function: ( "check-colors", (theme, highlight, highlight_focus, help_border, help_color, help_hover_border, help_hover_color), - [ - ("local-storage", { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }), - ("reload"), - ("wait-for", ".more-examples-toggle"), - ("assert-css", (".scraped-example .example-wrap .rust span.highlight:not(.focus)", { + block { + local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", } + reload: + wait-for: ".more-examples-toggle" + assert-css: (".scraped-example .example-wrap .rust span.highlight:not(.focus)", { "background-color": |highlight|, - }, ALL)), - ("assert-css", (".scraped-example .example-wrap .rust span.highlight.focus", { + }, ALL) + assert-css: (".scraped-example .example-wrap .rust span.highlight.focus", { "background-color": |highlight_focus|, - }, ALL)), + }, ALL) - ("assert-css", (".scraped-example-list .scrape-help", { + assert-css: (".scraped-example-list .scrape-help", { "border-color": |help_border|, "color": |help_color|, - })), - ("move-cursor-to", ".scraped-example-list .scrape-help"), - ("assert-css", (".scraped-example-list .scrape-help:hover", { + }) + move-cursor-to: ".scraped-example-list .scrape-help" + assert-css: (".scraped-example-list .scrape-help:hover", { "border-color": |help_hover_border|, "color": |help_hover_color|, - })), + }) // Moving the cursor to another item to not break next runs. - ("move-cursor-to", ".search-input"), - ] + move-cursor-to: ".search-input" + } ) call-function: ("check-colors", { diff --git a/src/test/rustdoc-gui/scrape-examples-toggle.goml b/src/test/rustdoc-gui/scrape-examples-toggle.goml index 8c84fbc0c30..2d5df6a5d25 100644 --- a/src/test/rustdoc-gui/scrape-examples-toggle.goml +++ b/src/test/rustdoc-gui/scrape-examples-toggle.goml @@ -6,24 +6,24 @@ show-text: true define-function: ( "check-color", (theme, toggle_line_color, toggle_line_hover_color), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: // Clicking "More examples..." will open additional examples - ("assert-attribute-false", (".more-examples-toggle", {"open": ""})), - ("click", ".more-examples-toggle"), - ("assert-attribute", (".more-examples-toggle", {"open": ""})), + assert-attribute-false: (".more-examples-toggle", {"open": ""}) + click: ".more-examples-toggle" + assert-attribute: (".more-examples-toggle", {"open": ""}) - ("assert-css", (".toggle-line-inner", {"background-color": |toggle_line_color|}, ALL)), - ("move-cursor-to", ".toggle-line"), - ("assert-css", ( + assert-css: (".toggle-line-inner", {"background-color": |toggle_line_color|}, ALL) + move-cursor-to: ".toggle-line" + assert-css: ( ".toggle-line:hover .toggle-line-inner", {"background-color": |toggle_line_hover_color|}, - )), + ) // Moving cursor away from the toggle line to prevent disrupting next test. - ("move-cursor-to", ".search-input"), - ], + move-cursor-to: ".search-input" + }, ) call-function: ("check-color", { diff --git a/src/test/rustdoc-gui/search-filter.goml b/src/test/rustdoc-gui/search-filter.goml index e556da0c54e..5bc6e87d6d2 100644 --- a/src/test/rustdoc-gui/search-filter.goml +++ b/src/test/rustdoc-gui/search-filter.goml @@ -15,6 +15,7 @@ click: "#crate-search" press-key: "ArrowDown" press-key: "ArrowDown" press-key: "ArrowDown" +press-key: "ArrowDown" press-key: "Enter" // Waiting for the search results to appear... wait-for: "#search-tabs" @@ -39,6 +40,7 @@ click: "#crate-search" press-key: "ArrowUp" press-key: "ArrowUp" press-key: "ArrowUp" +press-key: "ArrowUp" press-key: "Enter" // Waiting for the search results to appear... wait-for: "#search-tabs" diff --git a/src/test/rustdoc-gui/search-no-result.goml b/src/test/rustdoc-gui/search-no-result.goml index b88be32c94a..b76a44fa992 100644 --- a/src/test/rustdoc-gui/search-no-result.goml +++ b/src/test/rustdoc-gui/search-no-result.goml @@ -5,18 +5,18 @@ show-text: true define-function: ( "check-no-result", (theme, link, link_hover), - [ + block { // Changing theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("wait-for", "#results"), - ("assert", ".search-failed.active"), - ("assert-css", ("#results a", {"color": |link|}, ALL)), - ("move-cursor-to", "#results a"), - ("assert-css", ("#results a:hover", {"color": |link_hover|})), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + wait-for: "#results" + assert: ".search-failed.active" + assert-css: ("#results a", {"color": |link|}, ALL) + move-cursor-to: "#results a" + assert-css: ("#results a:hover", {"color": |link_hover|}) // Moving the cursor to some other place to not create issues with next function run. - ("move-cursor-to", ".search-input"), - ] + move-cursor-to: ".search-input" + }, ) call-function: ("check-no-result", { diff --git a/src/test/rustdoc-gui/search-result-color.goml b/src/test/rustdoc-gui/search-result-color.goml index 3c5fe9b74b7..d6d54ec4bee 100644 --- a/src/test/rustdoc-gui/search-result-color.goml +++ b/src/test/rustdoc-gui/search-result-color.goml @@ -3,53 +3,32 @@ define-function: ( "check-result-color", (result_kind, color, hover_color), - [ - ( - "assert-css", - (".result-" + |result_kind| + " ." + |result_kind|, {"color": |color|}, ALL), - ), - ( - "assert-css", - ( - ".result-" + |result_kind|, - {"color": |entry_color|, "background-color": |background_color|}, - ), - ), - ( - "move-cursor-to", + block { + assert-css: (".result-" + |result_kind| + " ." + |result_kind|, {"color": |color|}, ALL) + assert-css: ( ".result-" + |result_kind|, - ), - ( - "assert-css", - ( - ".result-" + |result_kind| + ":hover", - {"color": |hover_entry_color|, "background-color": |hover_background_color|}, - ), - ), - ( - "assert-css", - (".result-" + |result_kind| + ":hover ." + |result_kind|, {"color": |hover_color|}), - ), - ( - "move-cursor-to", - ".search-input", - ), - ( - "focus", - ".result-" + |result_kind|, - ), - ( - "assert-css", - ( - ".result-" + |result_kind| + ":focus", - {"color": |hover_entry_color|, "background-color": |hover_background_color|}, - ), - ), - ( - "assert-css", - (".result-" + |result_kind| + ":focus ." + |result_kind|, {"color": |hover_color|}), - ), - ], + {"color": |entry_color|, "background-color": |background_color|}, + ) + move-cursor-to: ".result-" + |result_kind| + assert-css: ( + ".result-" + |result_kind| + ":hover", + {"color": |hover_entry_color|, "background-color": |hover_background_color|}, + ) + assert-css: ( + ".result-" + |result_kind| + ":hover ." + |result_kind|, + {"color": |hover_color|}, + ) + move-cursor-to: ".search-input" + focus: ".result-" + |result_kind| + assert-css: ( + ".result-" + |result_kind| + ":focus", + {"color": |hover_entry_color|, "background-color": |hover_background_color|}, + ) + assert-css: ( + ".result-" + |result_kind| + ":focus ." + |result_kind|, + {"color": |hover_color|}, + ) + }, ) goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo" @@ -389,20 +368,20 @@ show-text: true define-function: ( "check-alias", (theme, alias, grey), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("write", (".search-input", "thisisanalias")), + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + write: (".search-input", "thisisanalias") // To be SURE that the search will be run. - ("press-key", 'Enter'), + press-key: 'Enter' // Waiting for the search results to appear... - ("wait-for", "#search-tabs"), + wait-for: "#search-tabs" // Checking that the colors for the alias element are the ones expected. - ("assert-css", (".result-name > .alias", {"color": |alias|})), - ("assert-css", (".result-name > .alias > .grey", {"color": |grey|})), + assert-css: (".result-name > .alias", {"color": |alias|}) + assert-css: (".result-name > .alias > .grey", {"color": |grey|}) // Leave the search results to prevent reloading with an already filled search input. - ("press-key", "Escape"), - ], + press-key: "Escape" + }, ) call-function: ("check-alias", { diff --git a/src/test/rustdoc-gui/search-result-display.goml b/src/test/rustdoc-gui/search-result-display.goml index 13a5e4c717b..43e608228d8 100644 --- a/src/test/rustdoc-gui/search-result-display.goml +++ b/src/test/rustdoc-gui/search-result-display.goml @@ -42,17 +42,17 @@ show-text: true define-function: ( "check-filter", (theme, border, filter, hover_border, hover_filter), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("wait-for", "#crate-search"), - ("assert-css", ("#crate-search", {"border": "1px solid " + |border|})), - ("assert-css", ("#crate-search-div::after", {"filter": |filter|})), - ("move-cursor-to", "#crate-search"), - ("assert-css", ("#crate-search", {"border": "1px solid " + |hover_border|})), - ("assert-css", ("#crate-search-div::after", {"filter": |hover_filter|})), - ("move-cursor-to", ".search-input"), - ], + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + wait-for: "#crate-search" + assert-css: ("#crate-search", {"border": "1px solid " + |border|}) + assert-css: ("#crate-search-div::after", {"filter": |filter|}) + move-cursor-to: "#crate-search" + assert-css: ("#crate-search", {"border": "1px solid " + |hover_border|}) + assert-css: ("#crate-search-div::after", {"filter": |hover_filter|}) + move-cursor-to: ".search-input" + }, ) call-function: ("check-filter", { diff --git a/src/test/rustdoc-gui/search-tab.goml b/src/test/rustdoc-gui/search-tab.goml index c2634a04c8a..36958f70044 100644 --- a/src/test/rustdoc-gui/search-tab.goml +++ b/src/test/rustdoc-gui/search-tab.goml @@ -7,35 +7,35 @@ define-function: ( (theme, background, background_selected, background_hover, border_bottom, border_bottom_selected, border_bottom_hover, border_top, border_top_selected, border_top_hover), - [ + block { // Setting the theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: // These two commands are used to be sure the search will be run. - ("focus", ".search-input"), - ("press-key", "Enter"), + focus: ".search-input" + press-key: "Enter" - ("wait-for", "#search-tabs"), - ("assert-css", ("#search-tabs > button:not(.selected)", { + wait-for: "#search-tabs" + assert-css: ("#search-tabs > button:not(.selected)", { "background-color": |background|, "border-bottom": |border_bottom|, "border-top": |border_top|, - })), - ("assert-css", ("#search-tabs > button.selected", { + }) + assert-css: ("#search-tabs > button.selected", { "background-color": |background_selected|, "border-bottom": |border_bottom_selected|, "border-top": |border_top_selected|, - })), - ("move-cursor-to", "#search-tabs > button:not(.selected)"), - ("assert-css", ("#search-tabs > button:not(.selected):hover", { + }) + move-cursor-to: "#search-tabs > button:not(.selected)" + assert-css: ("#search-tabs > button:not(.selected):hover", { "background-color": |background_hover|, "border-bottom": |border_bottom_hover|, "border-top": |border_top_hover|, - })), + }) // To prevent disrupting next run of this function. - ("move-cursor-to", ".search-input"), - ], + move-cursor-to: ".search-input" + }, ) call-function: ("check-colors", { diff --git a/src/test/rustdoc-gui/sidebar-links-color.goml b/src/test/rustdoc-gui/sidebar-links-color.goml index 7ef7ec90cd2..1d5fdb7a48f 100644 --- a/src/test/rustdoc-gui/sidebar-links-color.goml +++ b/src/test/rustdoc-gui/sidebar-links-color.goml @@ -12,80 +12,80 @@ define-function: ( trait_hover_background, fn, fn_hover, fn_hover_background, type, type_hover, type_hover_background, keyword, keyword_hover, keyword_hover_background, ), - [ - ("local-storage", { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" }), - ("reload"), + block { + local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" } + reload: // Struct - ("assert-css", ( + assert-css: ( ".sidebar .block.struct a:not(.current)", {"color": |struct|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.struct a:not(.current)"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.struct a:not(.current)" + assert-css: ( ".sidebar .block.struct a:hover", {"color": |struct_hover|, "background-color": |struct_hover_background|}, - )), + ) // Enum - ("assert-css", ( + assert-css: ( ".sidebar .block.enum a", {"color": |enum|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.enum a"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.enum a" + assert-css: ( ".sidebar .block.enum a:hover", {"color": |enum_hover|, "background-color": |enum_hover_background|}, - )), + ) // Union - ("assert-css", ( + assert-css: ( ".sidebar .block.union a", {"color": |union|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.union a"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.union a" + assert-css: ( ".sidebar .block.union a:hover", {"color": |union_hover|, "background-color": |union_hover_background|}, - )), + ) // Trait - ("assert-css", ( + assert-css: ( ".sidebar .block.trait a", {"color": |trait|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.trait a"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.trait a" + assert-css: ( ".sidebar .block.trait a:hover", {"color": |trait_hover|, "background-color": |trait_hover_background|}, - )), + ) // Function - ("assert-css", ( + assert-css: ( ".sidebar .block.fn a", {"color": |fn|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.fn a"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.fn a" + assert-css: ( ".sidebar .block.fn a:hover", {"color": |fn_hover|, "background-color": |fn_hover_background|}, - )), + ) // Type definition - ("assert-css", ( + assert-css: ( ".sidebar .block.type a", {"color": |type|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.type a"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.type a" + assert-css: ( ".sidebar .block.type a:hover", {"color": |type_hover|, "background-color": |type_hover_background|}, - )), + ) // Keyword - ("assert-css", ( + assert-css: ( ".sidebar .block.keyword a", {"color": |keyword|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.keyword a"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.keyword a" + assert-css: ( ".sidebar .block.keyword a:hover", {"color": |keyword_hover|, "background-color": |keyword_hover_background|}, - )), - ] + ) + } ) call-function: ( diff --git a/src/test/rustdoc-gui/sidebar-mobile.goml b/src/test/rustdoc-gui/sidebar-mobile.goml index 38d01f7f612..d5f4b619629 100644 --- a/src/test/rustdoc-gui/sidebar-mobile.goml +++ b/src/test/rustdoc-gui/sidebar-mobile.goml @@ -58,17 +58,17 @@ show-text: true define-function: ( "check-colors", (theme, color, background), - [ - ("local-storage", {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}), - ("reload"), + block { + local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} + reload: // Open the sidebar menu. - ("click", ".sidebar-menu-toggle"), - ("assert-css", (".sidebar", { + click: ".sidebar-menu-toggle" + assert-css: (".sidebar", { "background-color": |background|, "color": |color|, - })), - ], + }) + }, ) call-function: ("check-colors", { diff --git a/src/test/rustdoc-gui/sidebar-source-code-display.goml b/src/test/rustdoc-gui/sidebar-source-code-display.goml index df4506e1119..f3eb8ff76a3 100644 --- a/src/test/rustdoc-gui/sidebar-source-code-display.goml +++ b/src/test/rustdoc-gui/sidebar-source-code-display.goml @@ -35,88 +35,88 @@ define-function: ( theme, color, color_hover, background, background_hover, background_toggle, background_toggle_hover, ), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("wait-for-css", ("#src-sidebar-toggle", {"visibility": "visible"})), - ("assert-css", ( + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) + assert-css: ( "#source-sidebar details[open] > .files a.selected", {"color": |color_hover|, "background-color": |background|}, - )), + ) // Without hover or focus. - ("assert-css", ("#src-sidebar-toggle > button", {"background-color": |background_toggle|})), + assert-css: ("#src-sidebar-toggle > button", {"background-color": |background_toggle|}) // With focus. - ("focus", "#src-sidebar-toggle > button"), - ("assert-css", ( + focus: "#src-sidebar-toggle > button" + assert-css: ( "#src-sidebar-toggle > button:focus", {"background-color": |background_toggle_hover|}, - )), - ("focus", ".search-input"), + ) + focus: ".search-input" // With hover. - ("move-cursor-to", "#src-sidebar-toggle > button"), - ("assert-css", ( + move-cursor-to: "#src-sidebar-toggle > button" + assert-css: ( "#src-sidebar-toggle > button:hover", {"background-color": |background_toggle_hover|}, - )), + ) // Without hover or focus. - ("assert-css", ( + assert-css: ( "#source-sidebar details[open] > .files a:not(.selected)", {"color": |color|, "background-color": |background_toggle|}, - )), + ) // With focus. - ("focus", "#source-sidebar details[open] > .files a:not(.selected)"), - ("wait-for-css", ( + focus: "#source-sidebar details[open] > .files a:not(.selected)" + wait-for-css: ( "#source-sidebar details[open] > .files a:not(.selected):focus", {"color": |color_hover|, "background-color": |background_hover|}, - )), - ("focus", ".search-input"), + ) + focus: ".search-input" // With hover. - ("move-cursor-to", "#source-sidebar details[open] > .files a:not(.selected)"), - ("assert-css", ( + move-cursor-to: "#source-sidebar details[open] > .files a:not(.selected)" + assert-css: ( "#source-sidebar details[open] > .files a:not(.selected):hover", {"color": |color_hover|, "background-color": |background_hover|}, - )), + ) // Without hover or focus. - ("assert-css", ( + assert-css: ( "#source-sidebar .dir-entry summary", {"color": |color|, "background-color": |background_toggle|}, - )), + ) // With focus. - ("focus", "#source-sidebar .dir-entry summary"), - ("wait-for-css", ( + focus: "#source-sidebar .dir-entry summary" + wait-for-css: ( "#source-sidebar .dir-entry summary:focus", {"color": |color_hover|, "background-color": |background_hover|}, - )), - ("focus", ".search-input"), + ) + focus: ".search-input" // With hover. - ("move-cursor-to", "#source-sidebar .dir-entry summary"), - ("assert-css", ( + move-cursor-to: "#source-sidebar .dir-entry summary" + assert-css: ( "#source-sidebar .dir-entry summary:hover", {"color": |color_hover|, "background-color": |background_hover|}, - )), + ) // Without hover or focus. - ("assert-css", ( + assert-css: ( "#source-sidebar details[open] > .folders > details > summary", {"color": |color|, "background-color": |background_toggle|}, - )), + ) // With focus. - ("focus", "#source-sidebar details[open] > .folders > details > summary"), - ("wait-for-css", ( + focus: "#source-sidebar details[open] > .folders > details > summary" + wait-for-css: ( "#source-sidebar details[open] > .folders > details > summary:focus", {"color": |color_hover|, "background-color": |background_hover|}, - )), - ("focus", ".search-input"), + ) + focus: ".search-input" // With hover. - ("move-cursor-to", "#source-sidebar details[open] > .folders > details > summary"), - ("assert-css", ( + move-cursor-to: "#source-sidebar details[open] > .folders > details > summary" + assert-css: ( "#source-sidebar details[open] > .folders > details > summary:hover", {"color": |color_hover|, "background-color": |background_hover|}, - )), - ], + ) + }, ) call-function: ("check-colors", { @@ -171,15 +171,15 @@ assert-css: ( // We now check that the scroll position is kept when opening the sidebar. click: "#src-sidebar-toggle" -wait-for-css: (".sidebar", {"width": "0px"}) +wait-for-css: (".sidebar", {"left": "-1000px"}) // We scroll to line 117 to change the scroll position. scroll-to: '//*[@id="117"]' assert-window-property: {"pageYOffset": "2542"} // Expanding the sidebar... click: "#src-sidebar-toggle" -wait-for-css: (".sidebar", {"width": "500px"}) +wait-for-css: (".sidebar", {"left": "0px"}) click: "#src-sidebar-toggle" -wait-for-css: (".sidebar", {"width": "0px"}) +wait-for-css: (".sidebar", {"left": "-1000px"}) // The "scrollTop" property should be the same. assert-window-property: {"pageYOffset": "2542"} diff --git a/src/test/rustdoc-gui/sidebar-source-code.goml b/src/test/rustdoc-gui/sidebar-source-code.goml index d5f57ed6102..c8a29b58d34 100644 --- a/src/test/rustdoc-gui/sidebar-source-code.goml +++ b/src/test/rustdoc-gui/sidebar-source-code.goml @@ -7,43 +7,43 @@ show-text: true define-function: ( "check-colors", (theme, color, background_color), - [ - ("local-storage", { + block { + local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", - }), - ("reload"), + } + reload: // Checking results colors. - ("assert-css", (".source .sidebar", { - "color": |color|, - "background-color": |background_color| - }, ALL)), - ], + assert-css: (".source .sidebar", { + "color": |color|, + "background-color": |background_color| + }, ALL) + }, ) call-function: ( - "check-colors", - { - "theme": "ayu", - "color": "rgb(197, 197, 197)", - "background_color": "rgb(20, 25, 31)", - } + "check-colors", + { + "theme": "ayu", + "color": "rgb(197, 197, 197)", + "background_color": "rgb(20, 25, 31)", + } ) call-function: ( - "check-colors", - { - "theme": "dark", - "color": "rgb(221, 221, 221)", - "background_color": "rgb(80, 80, 80)", - } + "check-colors", + { + "theme": "dark", + "color": "rgb(221, 221, 221)", + "background_color": "rgb(80, 80, 80)", + } ) call-function: ( - "check-colors", - { - "theme": "light", - "color": "rgb(0, 0, 0)", - "background_color": "rgb(245, 245, 245)", - } + "check-colors", + { + "theme": "light", + "color": "rgb(0, 0, 0)", + "background_color": "rgb(245, 245, 245)", + } ) // Next, desktop mode layout. @@ -73,15 +73,15 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']" // Only "another_folder" should be "open" in "lib2". assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']" // All other trees should be collapsed. -assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 7) +assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 8) // We now switch to mobile mode. size: (600, 600) -wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "600px"}) +wait-for-css: (".source-sidebar-expanded nav.sidebar", {"left": "0px"}) // We collapse the sidebar. click: (10, 10) -// We check that the sidebar has the expected width (0). -assert-css: ("nav.sidebar", {"width": "0px"}) +// We check that the sidebar has been moved off-screen. +assert-css: ("nav.sidebar", {"left": "-1000px"}) // We ensure that the class has been removed. assert-false: ".source-sidebar-expanded" assert: "nav.sidebar" diff --git a/src/test/rustdoc-gui/sidebar.goml b/src/test/rustdoc-gui/sidebar.goml index bfd7567a224..9c742be0587 100644 --- a/src/test/rustdoc-gui/sidebar.goml +++ b/src/test/rustdoc-gui/sidebar.goml @@ -7,43 +7,43 @@ show-text: true define-function: ( "check-colors", (theme, color, background_color), - [ - ("local-storage", { + block { + local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", - }), - ("reload"), + } + reload: // Checking results colors. - ("assert-css", (".sidebar", { - "color": |color|, - "background-color": |background_color| - }, ALL)), - ], + assert-css: (".sidebar", { + "color": |color|, + "background-color": |background_color| + }, ALL) + }, ) call-function: ( - "check-colors", - { - "theme": "ayu", - "color": "rgb(197, 197, 197)", - "background_color": "rgb(20, 25, 31)", - } + "check-colors", + { + "theme": "ayu", + "color": "rgb(197, 197, 197)", + "background_color": "rgb(20, 25, 31)", + } ) call-function: ( - "check-colors", - { - "theme": "dark", - "color": "rgb(221, 221, 221)", - "background_color": "rgb(80, 80, 80)", - } + "check-colors", + { + "theme": "dark", + "color": "rgb(221, 221, 221)", + "background_color": "rgb(80, 80, 80)", + } ) call-function: ( - "check-colors", - { - "theme": "light", - "color": "rgb(0, 0, 0)", - "background_color": "rgb(245, 245, 245)", - } + "check-colors", + { + "theme": "light", + "color": "rgb(0, 0, 0)", + "background_color": "rgb(245, 245, 245)", + } ) local-storage: {"rustdoc-theme": "light"} @@ -148,4 +148,4 @@ assert-text: ("#toggle-all-docs", "[+]") assert-property: (".sidebar", {"clientWidth": "200"}) click: "#toggle-all-docs" assert-text: ("#toggle-all-docs", "[−]") -assert-property: (".sidebar", {"clientWidth": "200"}) \ No newline at end of file +assert-property: (".sidebar", {"clientWidth": "200"}) diff --git a/src/test/rustdoc-gui/source-code-page.goml b/src/test/rustdoc-gui/source-code-page.goml index aa792196960..7c35119e695 100644 --- a/src/test/rustdoc-gui/source-code-page.goml +++ b/src/test/rustdoc-gui/source-code-page.goml @@ -22,20 +22,20 @@ assert-attribute-false: (".src-line-numbers > a:nth-child(7)", {"class": "line-h define-function: ( "check-colors", (theme, color, background_color, highlight_color, highlight_background_color), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("assert-css", ( + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + assert-css: ( ".src-line-numbers > a:not(.line-highlighted)", {"color": |color|, "background-color": |background_color|}, ALL, - )), - ("assert-css", ( + ) + assert-css: ( ".src-line-numbers > a.line-highlighted", {"color": |highlight_color|, "background-color": |highlight_background_color|}, ALL, - )), - ], + ) + }, ) call-function: ("check-colors", { @@ -102,7 +102,7 @@ assert: ".source-sidebar-expanded" // We check that the first entry of the sidebar is collapsed assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) -assert-text: ("#source-sidebar details:first-of-type > summary", "huge_logo") +assert-text: ("#source-sidebar details:first-of-type > summary", "http") // We now click on it. click: "#source-sidebar details:first-of-type > summary" assert-property: ("#source-sidebar details:first-of-type", {"open": "true"}) @@ -124,28 +124,28 @@ store-property: ( define-function: ( "check-sidebar-dir-entry", (x, y), - [ - ("assert", "details:first-of-type.dir-entry[open] > summary::marker"), - ("assert-css", ("#source-sidebar > details:first-of-type.dir-entry", {"padding-left": "4px"})), + block { + assert: "details:first-of-type.dir-entry[open] > summary::marker" + assert-css: ("#source-sidebar > details:first-of-type.dir-entry", {"padding-left": "4px"}) // This check ensures that the summary is only one line. - ("assert-property", ( + assert-property: ( "#source-sidebar > details:first-of-type.dir-entry[open] > summary", {"offsetHeight": |link_height|} - )), - ("assert-position", ( + ) + assert-position: ( "#source-sidebar > details:first-of-type.dir-entry[open] > summary", {"x": |x|, "y": |y|} - )), - ("assert-property", ( + ) + assert-property: ( "#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", {"offsetHeight": |link_height|} - )), - ("assert-position", ( + ) + assert-position: ( "#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", // left margin {"x": |x| + 27, "y": |y| + |link_height|} - )), - ] + ) + } ) store-property: ( source_sidebar_title_height, diff --git a/src/test/rustdoc-gui/src/lib2/Cargo.lock b/src/test/rustdoc-gui/src/lib2/Cargo.lock index a5873ceb325..425a3ae7e5c 100644 --- a/src/test/rustdoc-gui/src/lib2/Cargo.lock +++ b/src/test/rustdoc-gui/src/lib2/Cargo.lock @@ -3,12 +3,20 @@ version = 3 [[package]] +name = "http" +version = "0.1.0" + +[[package]] name = "implementors" version = "0.1.0" +dependencies = [ + "http", +] [[package]] name = "lib2" version = "0.1.0" dependencies = [ + "http", "implementors", ] diff --git a/src/test/rustdoc-gui/src/lib2/Cargo.toml b/src/test/rustdoc-gui/src/lib2/Cargo.toml index 2e37f3f667a..8bca77ff834 100644 --- a/src/test/rustdoc-gui/src/lib2/Cargo.toml +++ b/src/test/rustdoc-gui/src/lib2/Cargo.toml @@ -8,3 +8,4 @@ path = "lib.rs" [dependencies] implementors = { path = "./implementors" } +http = { path = "./http" } diff --git a/src/test/rustdoc-gui/src/lib2/http/Cargo.toml b/src/test/rustdoc-gui/src/lib2/http/Cargo.toml new file mode 100644 index 00000000000..fa719efa526 --- /dev/null +++ b/src/test/rustdoc-gui/src/lib2/http/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "http" +version = "0.1.0" +edition = "2018" + +[lib] +path = "lib.rs" diff --git a/src/test/rustdoc-gui/src/lib2/http/lib.rs b/src/test/rustdoc-gui/src/lib2/http/lib.rs new file mode 100644 index 00000000000..204e0749427 --- /dev/null +++ b/src/test/rustdoc-gui/src/lib2/http/lib.rs @@ -0,0 +1 @@ +pub trait HttpTrait {} diff --git a/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml b/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml index 7ef1052c49f..9dafc43df5f 100644 --- a/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml +++ b/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml @@ -5,3 +5,6 @@ edition = "2018" [lib] path = "lib.rs" + +[dependencies] +http = { path = "../http/" } diff --git a/src/test/rustdoc-gui/src/lib2/implementors/lib.rs b/src/test/rustdoc-gui/src/lib2/implementors/lib.rs index 1620e842291..2842ac50dc1 100644 --- a/src/test/rustdoc-gui/src/lib2/implementors/lib.rs +++ b/src/test/rustdoc-gui/src/lib2/implementors/lib.rs @@ -10,6 +10,8 @@ impl Whatever for Struct { type Foo = u8; } +impl http::HttpTrait for Struct {} + mod traits { pub trait TraitToReexport { fn method() {} diff --git a/src/test/rustdoc-gui/stab-badge.goml b/src/test/rustdoc-gui/stab-badge.goml index aaed8440a40..50ba1ba62db 100644 --- a/src/test/rustdoc-gui/stab-badge.goml +++ b/src/test/rustdoc-gui/stab-badge.goml @@ -2,40 +2,40 @@ goto: "file://" + |DOC_PATH| + "/test_docs/index.html" show-text: true define-function: ( - "check-badge", - (theme, background, color), - [ - ("local-storage", {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}), - ("goto", "file://" + |DOC_PATH| + "/test_docs/index.html"), - ("assert", (".docblock .stab")), - ("assert", (".item-table .stab")), - ("assert-css", (".stab", { - "border-radius": "3px", - "color": |color|, - "background-color": |background|, - })), - ("goto", "file://" + |DOC_PATH| + "/test_docs/fn.replaced_function.html"), - ("assert", (".item-info .stab")), - ("assert-css", (".stab", { - "border-radius": "3px", - "color": |color|, - "background-color": |background|, - })), - ] + "check-badge", + (theme, background, color), + block { + local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} + goto: "file://" + |DOC_PATH| + "/test_docs/index.html" + assert: ".docblock .stab" + assert: ".item-table .stab" + assert-css: (".stab", { + "border-radius": "3px", + "color": |color|, + "background-color": |background|, + }) + goto: "file://" + |DOC_PATH| + "/test_docs/fn.replaced_function.html" + assert: (".item-info .stab") + assert-css: (".stab", { + "border-radius": "3px", + "color": |color|, + "background-color": |background|, + }) + }, ) call-function: ("check-badge", { - "theme": "ayu", - "color": "rgb(197, 197, 197)", - "background": "rgb(49, 69, 89)", + "theme": "ayu", + "color": "rgb(197, 197, 197)", + "background": "rgb(49, 69, 89)", }) call-function: ("check-badge", { - "theme": "dark", - "color": "rgb(221, 221, 221)", - "background": "rgb(49, 69, 89)", + "theme": "dark", + "color": "rgb(221, 221, 221)", + "background": "rgb(49, 69, 89)", }) call-function: ("check-badge", { - "theme": "light", - "color": "rgb(0, 0, 0)", - "background": "rgb(255, 245, 214)", + "theme": "light", + "color": "rgb(0, 0, 0)", + "background": "rgb(255, 245, 214)", }) diff --git a/src/test/rustdoc-gui/target.goml b/src/test/rustdoc-gui/target.goml index 3e5c30dc7ea..ca393ee5891 100644 --- a/src/test/rustdoc-gui/target.goml +++ b/src/test/rustdoc-gui/target.goml @@ -8,14 +8,14 @@ assert: "#method\.a_method:target" define-function: ( "check-style", (theme, background, border), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("assert-css", ("#method\.a_method:target", { + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + assert-css: ("#method\.a_method:target", { "background-color": |background|, "border-right": "3px solid " + |border|, - })), - ], + }) + }, ) call-function: ("check-style", { diff --git a/src/test/rustdoc-gui/toggle-docs.goml b/src/test/rustdoc-gui/toggle-docs.goml index 45bb8daf1f2..89ce78e3aab 100644 --- a/src/test/rustdoc-gui/toggle-docs.goml +++ b/src/test/rustdoc-gui/toggle-docs.goml @@ -50,24 +50,24 @@ show-text: true define-function: ( "check-color", (theme, filter), - [ + block { // Setting the theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. - ("reload"), + reload: - ("assert-css", ("details.rustdoc-toggle > summary::before", { + assert-css: ("details.rustdoc-toggle > summary::before", { "opacity": "0.5", "filter": |filter|, - }, ALL)), - ("move-cursor-to", "details.rustdoc-toggle summary"), - ("assert-css", ("details.rustdoc-toggle > summary:hover::before", { + }, ALL) + move-cursor-to: "details.rustdoc-toggle summary" + assert-css: ("details.rustdoc-toggle > summary:hover::before", { "opacity": "1", "filter": |filter|, - })), + }) // moving the cursor somewhere else to not mess with next function calls. - ("move-cursor-to", ".search-input"), - ] + move-cursor-to: ".search-input" + }, ) call-function: ("check-color", {"theme": "ayu", "filter": "invert(1)"}) diff --git a/src/test/rustdoc-gui/type-declation-overflow.goml b/src/test/rustdoc-gui/type-declation-overflow.goml index c014eb52e71..9b60bc04738 100644 --- a/src/test/rustdoc-gui/type-declation-overflow.goml +++ b/src/test/rustdoc-gui/type-declation-overflow.goml @@ -1,3 +1,4 @@ +// ignore-tidy-linelength // This test ensures that the items declaration content overflow is handled inside the <pre> directly. // We need to disable this check because diff --git a/src/test/rustdoc-gui/unsafe-fn.goml b/src/test/rustdoc-gui/unsafe-fn.goml index 5e43b85fce0..d3a672ddde6 100644 --- a/src/test/rustdoc-gui/unsafe-fn.goml +++ b/src/test/rustdoc-gui/unsafe-fn.goml @@ -14,13 +14,13 @@ define-function: ( // `theme` is the theme being tested. // `color` is the expected color of the `<sup>` element. (theme, color), - [ + block { // Set the theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. - ("reload"), - ("assert-css", (".item-left sup", {"color": |color|})), - ], + reload: + assert-css: (".item-left sup", {"color": |color|}) + }, ) call-function: ("sup-check", ("dark", "rgb(221, 221, 221)")) diff --git a/src/test/rustdoc-json/doc_hidden_failure.rs b/src/test/rustdoc-json/doc_hidden_failure.rs index 6573166c47f..0d2c6b2209b 100644 --- a/src/test/rustdoc-json/doc_hidden_failure.rs +++ b/src/test/rustdoc-json/doc_hidden_failure.rs @@ -14,7 +14,8 @@ mod auto { } } -// @count "$.index[*][?(@.name=='builders')]" 2 +// @count "$.index[*][?(@.name=='builders')]" 1 +// @has "$.index[*][?(@.name == 'ActionRowBuilder')"] pub use auto::*; pub mod builders { diff --git a/src/test/rustdoc-json/primitives/local_primitive.rs b/src/test/rustdoc-json/primitives/local_primitive.rs new file mode 100644 index 00000000000..f27e6a2adec --- /dev/null +++ b/src/test/rustdoc-json/primitives/local_primitive.rs @@ -0,0 +1,21 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/104064>. + +#![feature(no_core)] +#![feature(rustc_attrs)] +#![feature(rustdoc_internals)] +#![no_core] +#![rustc_coherence_is_core] + +//! Link to [i32][prim@i32] [i64][prim@i64] + +#[doc(primitive = "i32")] +mod prim_i32 {} + +// @set local_i32 = "$.index[*][?(@.name=='i32')].id" + +// @has "$.index[*][?(@.name=='local_primitive')]" +// @ismany "$.index[*][?(@.name=='local_primitive')].inner.items[*]" $local_i32 +// @is "$.index[*][?(@.name=='local_primitive')].links['prim@i32']" $local_i32 + +// Let's ensure the `prim_i32` module isn't present in the output JSON: +// @!has "$.index[*][?(@.name=='prim_i32')]" diff --git a/src/test/rustdoc-json/reexport/pub_use_doc_hidden.rs b/src/test/rustdoc-json/reexport/pub_use_doc_hidden.rs new file mode 100644 index 00000000000..a2a25d08448 --- /dev/null +++ b/src/test/rustdoc-json/reexport/pub_use_doc_hidden.rs @@ -0,0 +1,15 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/106379> + +#![feature(no_core)] +#![no_core] + +mod repeat_n { + #[doc(hidden)] + pub struct RepeatN {} +} + +pub use repeat_n::RepeatN; + +// @count "$.index[*][?(@.name=='pub_use_doc_hidden')].inner.items[*]" 0 +// @!has "$.index[*][?(@.kind=='struct')]" +// @!has "$.index[*][?(@.kind=='import')]" diff --git a/src/test/rustdoc-ui/issue-105742.stderr b/src/test/rustdoc-ui/issue-105742.stderr index cc101b7ff37..ffb602cf861 100644 --- a/src/test/rustdoc-ui/issue-105742.stderr +++ b/src/test/rustdoc-ui/issue-105742.stderr @@ -12,7 +12,7 @@ LL | type Item<'a, T>; help: add missing lifetime argument | LL | <Self as SVec>::Item<'a>, - | ~~~~~~~~ + | ++++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:13:21 @@ -28,7 +28,7 @@ LL | type Item<'a, T>; help: add missing generic argument | LL | <Self as SVec>::Item<T>, - | ~~~~~~~ + | +++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:18:37 @@ -44,7 +44,7 @@ LL | type Item<'a, T>; help: add missing lifetime argument | LL | Output = <Index<<Self as SVec>::Item<'a>, - | ~~~~~~~~ + | ++++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:18:37 @@ -60,7 +60,7 @@ LL | type Item<'a, T>; help: add missing generic argument | LL | Output = <Index<<Self as SVec>::Item<T>, - | ~~~~~~~ + | +++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:23:30 @@ -76,7 +76,7 @@ LL | type Item<'a, T>; help: add missing lifetime argument | LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, - | ~~~~~~~~ + | ++++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:23:30 @@ -92,7 +92,7 @@ LL | type Item<'a, T>; help: add missing generic argument | LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, - | ~~~~~~~ + | +++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:23:46 @@ -108,7 +108,7 @@ LL | type Item<'a, T>; help: add missing lifetime argument | LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, - | ~~~~~~~~ + | ++++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:23:46 @@ -124,7 +124,7 @@ LL | type Item<'a, T>; help: add missing generic argument | LL | Output = <Self as SVec>::Item> as SVec>::Item<T>, - | ~~~~~~~ + | +++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:5:40 @@ -140,7 +140,7 @@ LL | type Item<'a, T>; help: add missing lifetime argument | LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<'_> = T, Output = T>) { - | ~~~~~~~~ + | ++++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:5:40 @@ -156,7 +156,7 @@ LL | type Item<'a, T>; help: add missing generic argument | LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<T> = T, Output = T>) { - | ~~~~~~~ + | +++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:13:21 @@ -172,7 +172,7 @@ LL | type Item<'a, T>; help: add missing lifetime argument | LL | <Self as SVec>::Item<'a>, - | ~~~~~~~~ + | ++++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:13:21 @@ -188,7 +188,7 @@ LL | type Item<'a, T>; help: add missing generic argument | LL | <Self as SVec>::Item<T>, - | ~~~~~~~ + | +++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:18:37 @@ -204,7 +204,7 @@ LL | type Item<'a, T>; help: add missing lifetime argument | LL | Output = <Index<<Self as SVec>::Item<'a>, - | ~~~~~~~~ + | ++++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:18:37 @@ -220,7 +220,7 @@ LL | type Item<'a, T>; help: add missing generic argument | LL | Output = <Index<<Self as SVec>::Item<T>, - | ~~~~~~~ + | +++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:23:30 @@ -236,7 +236,7 @@ LL | type Item<'a, T>; help: add missing lifetime argument | LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, - | ~~~~~~~~ + | ++++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:23:30 @@ -252,7 +252,7 @@ LL | type Item<'a, T>; help: add missing generic argument | LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, - | ~~~~~~~ + | +++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:23:46 @@ -268,7 +268,7 @@ LL | type Item<'a, T>; help: add missing lifetime argument | LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, - | ~~~~~~~~ + | ++++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:23:46 @@ -284,7 +284,7 @@ LL | type Item<'a, T>; help: add missing generic argument | LL | Output = <Self as SVec>::Item> as SVec>::Item<T>, - | ~~~~~~~ + | +++ error[E0038]: the trait `SVec` cannot be made into an object --> $DIR/issue-105742.rs:5:31 @@ -329,7 +329,7 @@ LL | type Item<'a, T>; help: add missing lifetime argument | LL | fn len(&self) -> <Self as SVec>::Item<'_>; - | ~~~~~~~~ + | ++++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:35:38 @@ -345,7 +345,7 @@ LL | type Item<'a, T>; help: add missing generic argument | LL | fn len(&self) -> <Self as SVec>::Item<T>; - | ~~~~~~~ + | +++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:35:38 @@ -361,7 +361,7 @@ LL | type Item<'a, T>; help: add missing lifetime argument | LL | fn len(&self) -> <Self as SVec>::Item<'_>; - | ~~~~~~~~ + | ++++ error[E0107]: missing generics for associated type `SVec::Item` --> $DIR/issue-105742.rs:35:38 @@ -377,7 +377,7 @@ LL | type Item<'a, T>; help: add missing generic argument | LL | fn len(&self) -> <Self as SVec>::Item<T>; - | ~~~~~~~ + | +++ error: aborting due to 23 previous errors diff --git a/src/test/rustdoc-ui/z-help.stdout b/src/test/rustdoc-ui/z-help.stdout index 53677b18377..537dc92be19 100644 --- a/src/test/rustdoc-ui/z-help.stdout +++ b/src/test/rustdoc-ui/z-help.stdout @@ -8,7 +8,6 @@ -Z branch-protection=val -- set options for branch target identification and pointer authentication on AArch64 -Z cf-protection=val -- instrument control-flow architecture protection -Z cgu-partitioning-strategy=val -- the codegen unit partitioning strategy to use - -Z chalk=val -- enable the experimental Chalk-based trait solving engine -Z codegen-backend=val -- the backend to use -Z combine-cgu=val -- combine CGUs into a single one -Z crate-attr=val -- inject the given attribute in the crate @@ -35,7 +34,8 @@ -Z dump-mir-exclude-pass-number=val -- exclude the pass number when dumping MIR (used in tests) (default: no) -Z dump-mir-graphviz=val -- in addition to `.mir` files, create graphviz `.dot` files (and with `-Z instrument-coverage`, also create a `.dot` file for the MIR-derived coverage graph) (default: no) -Z dump-mir-spanview=val -- in addition to `.mir` files, create `.html` files to view spans for all `statement`s (including terminators), only `terminator` spans, or computed `block` spans (one span encompassing a block's terminator and all statements). If `-Z instrument-coverage` is also enabled, create an additional `.html` file showing the computed coverage spans. - -Z dump-mono-stats=val -- output statistics about monomorphization collection (format: markdown) + -Z dump-mono-stats=val -- output statistics about monomorphization collection + -Z dump-mono-stats-format=val -- the format to use for -Z dump-mono-stats (`markdown` (default) or `json`) -Z dwarf-version=val -- version of DWARF debug information to emit (default: 2 or 4, depending on platform) -Z dylib-lto=val -- enables LTO for dylib crate type -Z emit-stack-sizes=val -- emit a section containing stack size metadata (default: no) @@ -174,6 +174,7 @@ -Z tls-model=val -- choose the TLS model to use (`rustc --print tls-models` for details) -Z trace-macros=val -- for every macro invocation, print its name and arguments (default: no) -Z track-diagnostics=val -- tracks where in rustc a diagnostic was emitted + -Z trait-solver=val -- specify the trait solver mode used by rustc (default: classic) -Z translate-additional-ftl=val -- additional fluent translation to preferentially use (for testing translation) -Z translate-directionality-markers=val -- emit directionality isolation markers in translated diagnostics -Z translate-lang=val -- language identifier for diagnostic output diff --git a/src/test/rustdoc/src-links.rs b/src/test/rustdoc/src-links.rs index 353ce10243e..7a6c733d464 100644 --- a/src/test/rustdoc/src-links.rs +++ b/src/test/rustdoc/src-links.rs @@ -7,6 +7,11 @@ #[path = "src-links/mod.rs"] pub mod qux; +// @has src/foo/src-links.rs.html +// @has foo/fizz/index.html '//a/@href' '../src/foo/src-links/fizz.rs.html' +#[path = "src-links/../src-links/fizz.rs"] +pub mod fizz; + // @has foo/bar/index.html '//a/@href' '../../src/foo/src-links.rs.html' pub mod bar { diff --git a/src/test/rustdoc/src-links/fizz.rs b/src/test/rustdoc/src-links/fizz.rs new file mode 100644 index 00000000000..d2b76b1cec8 --- /dev/null +++ b/src/test/rustdoc/src-links/fizz.rs @@ -0,0 +1 @@ +pub struct Buzz; diff --git a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.rs b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.rs index 8430fabe84d..ea9ad39a70d 100644 --- a/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.rs +++ b/src/test/ui/alloc-error/alloc-error-handler-bad-signature-3.rs @@ -7,7 +7,7 @@ struct Layout; #[alloc_error_handler] -fn oom() -> ! { //~ ERROR this function takes 0 arguments but 1 argument was supplied +fn oom() -> ! { //~ ERROR function takes 0 arguments but 1 argument was supplied loop {} } diff --git a/src/test/ui/argument-suggestions/basic.rs b/src/test/ui/argument-suggestions/basic.rs index 3e96322d67e..961e7a50e56 100644 --- a/src/test/ui/argument-suggestions/basic.rs +++ b/src/test/ui/argument-suggestions/basic.rs @@ -18,11 +18,11 @@ fn permuted(_x: X, _y: Y, _z: Z) {} fn main() { invalid(1.0); //~ ERROR mismatched types - extra(""); //~ ERROR this function takes - missing(); //~ ERROR this function takes + extra(""); //~ ERROR function takes + missing(); //~ ERROR function takes swapped("", 1); //~ ERROR arguments to this function are incorrect permuted(Y {}, Z {}, X {}); //~ ERROR arguments to this function are incorrect let closure = |x| x; - closure(); //~ ERROR this function takes + closure(); //~ ERROR function takes } diff --git a/src/test/ui/argument-suggestions/display-is-suggestable.rs b/src/test/ui/argument-suggestions/display-is-suggestable.rs index d765bc4f74d..acb61f54308 100644 --- a/src/test/ui/argument-suggestions/display-is-suggestable.rs +++ b/src/test/ui/argument-suggestions/display-is-suggestable.rs @@ -4,5 +4,5 @@ fn foo(x: &(dyn Display + Send)) {} fn main() { foo(); - //~^ ERROR this function takes 1 argument but 0 arguments were supplied + //~^ ERROR function takes 1 argument but 0 arguments were supplied } diff --git a/src/test/ui/argument-suggestions/exotic-calls.rs b/src/test/ui/argument-suggestions/exotic-calls.rs index a18e967668d..569a39a2b45 100644 --- a/src/test/ui/argument-suggestions/exotic-calls.rs +++ b/src/test/ui/argument-suggestions/exotic-calls.rs @@ -1,11 +1,11 @@ fn foo<T: Fn()>(t: T) { t(1i32); - //~^ ERROR this function takes 0 arguments but 1 argument was supplied + //~^ ERROR function takes 0 arguments but 1 argument was supplied } fn bar(t: impl Fn()) { t(1i32); - //~^ ERROR this function takes 0 arguments but 1 argument was supplied + //~^ ERROR function takes 0 arguments but 1 argument was supplied } fn baz() -> impl Fn() { @@ -14,13 +14,13 @@ fn baz() -> impl Fn() { fn baz2() { baz()(1i32) - //~^ ERROR this function takes 0 arguments but 1 argument was supplied + //~^ ERROR function takes 0 arguments but 1 argument was supplied } fn qux() { let x = || {}; x(1i32); - //~^ ERROR this function takes 0 arguments but 1 argument was supplied + //~^ ERROR function takes 0 arguments but 1 argument was supplied } fn main() {} diff --git a/src/test/ui/argument-suggestions/extern-fn-arg-names.rs b/src/test/ui/argument-suggestions/extern-fn-arg-names.rs index 6c925a3d653..df2fd6624cd 100644 --- a/src/test/ui/argument-suggestions/extern-fn-arg-names.rs +++ b/src/test/ui/argument-suggestions/extern-fn-arg-names.rs @@ -5,5 +5,5 @@ extern "Rust" { fn main() { dstfn(1); - //~^ ERROR this function takes 2 arguments but 1 argument was supplied + //~^ ERROR function takes 2 arguments but 1 argument was supplied } diff --git a/src/test/ui/argument-suggestions/extra_arguments.rs b/src/test/ui/argument-suggestions/extra_arguments.rs index 3706ac4e8e1..3f83de95e2d 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.rs +++ b/src/test/ui/argument-suggestions/extra_arguments.rs @@ -4,30 +4,30 @@ fn two_arg_same(_a: i32, _b: i32) {} fn two_arg_diff(_a: i32, _b: &str) {} fn main() { - empty(""); //~ ERROR this function takes + empty(""); //~ ERROR function takes - one_arg(1, 1); //~ ERROR this function takes - one_arg(1, ""); //~ ERROR this function takes - one_arg(1, "", 1.0); //~ ERROR this function takes + one_arg(1, 1); //~ ERROR function takes + one_arg(1, ""); //~ ERROR function takes + one_arg(1, "", 1.0); //~ ERROR function takes - two_arg_same(1, 1, 1); //~ ERROR this function takes - two_arg_same(1, 1, 1.0); //~ ERROR this function takes + two_arg_same(1, 1, 1); //~ ERROR function takes + two_arg_same(1, 1, 1.0); //~ ERROR function takes - two_arg_diff(1, 1, ""); //~ ERROR this function takes - two_arg_diff(1, "", ""); //~ ERROR this function takes - two_arg_diff(1, 1, "", ""); //~ ERROR this function takes - two_arg_diff(1, "", 1, ""); //~ ERROR this function takes + two_arg_diff(1, 1, ""); //~ ERROR function takes + two_arg_diff(1, "", ""); //~ ERROR function takes + two_arg_diff(1, 1, "", ""); //~ ERROR function takes + two_arg_diff(1, "", 1, ""); //~ ERROR function takes // Check with weird spacing and newlines - two_arg_same(1, 1, ""); //~ ERROR this function takes - two_arg_diff(1, 1, ""); //~ ERROR this function takes - two_arg_same( //~ ERROR this function takes + two_arg_same(1, 1, ""); //~ ERROR function takes + two_arg_diff(1, 1, ""); //~ ERROR function takes + two_arg_same( //~ ERROR function takes 1, 1, "" ); - two_arg_diff( //~ ERROR this function takes + two_arg_diff( //~ ERROR function takes 1, 1, "" diff --git a/src/test/ui/argument-suggestions/issue-100154.rs b/src/test/ui/argument-suggestions/issue-100154.rs index 4446b4bc2fc..fb0af05e9dc 100644 --- a/src/test/ui/argument-suggestions/issue-100154.rs +++ b/src/test/ui/argument-suggestions/issue-100154.rs @@ -2,6 +2,6 @@ fn foo(i: impl std::fmt::Display) {} fn main() { foo::<()>(()); - //~^ ERROR this function takes 0 generic arguments but 1 generic argument was supplied + //~^ ERROR function takes 0 generic arguments but 1 generic argument was supplied //~| ERROR `()` doesn't implement `std::fmt::Display` } diff --git a/src/test/ui/argument-suggestions/issue-100478.rs b/src/test/ui/argument-suggestions/issue-100478.rs index 6bef6ad1038..fb50fa11537 100644 --- a/src/test/ui/argument-suggestions/issue-100478.rs +++ b/src/test/ui/argument-suggestions/issue-100478.rs @@ -31,7 +31,7 @@ fn three_diff(_a: T1, _b: T2, _c: T3) {} fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {} fn main() { - three_diff(T2::new(0)); //~ ERROR this function takes + three_diff(T2::new(0)); //~ ERROR function takes four_shuffle(T3::default(), T4::default(), T1::default(), T2::default()); //~ ERROR 35:5: 35:17: arguments to this function are incorrect [E0308] four_shuffle(T3::default(), T2::default(), T1::default(), T3::default()); //~ ERROR 36:5: 36:17: arguments to this function are incorrect [E0308] diff --git a/src/test/ui/argument-suggestions/issue-101097.rs b/src/test/ui/argument-suggestions/issue-101097.rs index 7994d3cd995..25f7f583799 100644 --- a/src/test/ui/argument-suggestions/issue-101097.rs +++ b/src/test/ui/argument-suggestions/issue-101097.rs @@ -13,7 +13,7 @@ fn f( ) {} fn main() { - f(C, A, A, A, B, B, C); //~ ERROR this function takes 6 arguments but 7 arguments were supplied [E0061] + f(C, A, A, A, B, B, C); //~ ERROR function takes 6 arguments but 7 arguments were supplied [E0061] f(C, C, A, A, B, B); //~ ERROR arguments to this function are incorrect [E0308] f(A, A, D, D, B, B); //~ arguments to this function are incorrect [E0308] f(C, C, B, B, A, A); //~ arguments to this function are incorrect [E0308] diff --git a/src/test/ui/argument-suggestions/issue-96638.rs b/src/test/ui/argument-suggestions/issue-96638.rs index 9c6e81ab8cc..5e720f174c2 100644 --- a/src/test/ui/argument-suggestions/issue-96638.rs +++ b/src/test/ui/argument-suggestions/issue-96638.rs @@ -5,5 +5,5 @@ fn arg<T>() -> T { todo!() } fn main() { let x = arg(); // `x` must be inferred // The reference on `&x` is important to reproduce the ICE - f(&x, ""); //~ ERROR this function takes 3 arguments but 2 arguments were supplied + f(&x, ""); //~ ERROR function takes 3 arguments but 2 arguments were supplied } diff --git a/src/test/ui/argument-suggestions/issue-97197.rs b/src/test/ui/argument-suggestions/issue-97197.rs index 6f9f4293e49..4c22608ae6a 100644 --- a/src/test/ui/argument-suggestions/issue-97197.rs +++ b/src/test/ui/argument-suggestions/issue-97197.rs @@ -1,6 +1,6 @@ fn main() { g((), ()); - //~^ ERROR this function takes 6 arguments but 2 arguments were supplied + //~^ ERROR function takes 6 arguments but 2 arguments were supplied } pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {} diff --git a/src/test/ui/argument-suggestions/issue-97484.rs b/src/test/ui/argument-suggestions/issue-97484.rs index bb383ab1f8b..9e537b0c35f 100644 --- a/src/test/ui/argument-suggestions/issue-97484.rs +++ b/src/test/ui/argument-suggestions/issue-97484.rs @@ -10,5 +10,5 @@ fn foo(a: &A, d: D, e: &E, g: G) {} fn main() { foo(&&A, B, C, D, E, F, G); - //~^ ERROR this function takes 4 arguments but 7 arguments were supplied + //~^ ERROR function takes 4 arguments but 7 arguments were supplied } diff --git a/src/test/ui/argument-suggestions/issue-98894.rs b/src/test/ui/argument-suggestions/issue-98894.rs index c2618a96716..e421eba9775 100644 --- a/src/test/ui/argument-suggestions/issue-98894.rs +++ b/src/test/ui/argument-suggestions/issue-98894.rs @@ -1,4 +1,4 @@ fn main() { (|_, ()| ())(if true {} else {return;}); - //~^ ERROR this function takes 2 arguments but 1 argument was supplied + //~^ ERROR function takes 2 arguments but 1 argument was supplied } diff --git a/src/test/ui/argument-suggestions/issue-98897.rs b/src/test/ui/argument-suggestions/issue-98897.rs index c55f495d698..27734f74dee 100644 --- a/src/test/ui/argument-suggestions/issue-98897.rs +++ b/src/test/ui/argument-suggestions/issue-98897.rs @@ -1,4 +1,4 @@ fn main() { (|_, ()| ())([return, ()]); - //~^ ERROR this function takes 2 arguments but 1 argument was supplied + //~^ ERROR function takes 2 arguments but 1 argument was supplied } diff --git a/src/test/ui/argument-suggestions/issue-99482.rs b/src/test/ui/argument-suggestions/issue-99482.rs index 731b863069b..7bbb39f8d62 100644 --- a/src/test/ui/argument-suggestions/issue-99482.rs +++ b/src/test/ui/argument-suggestions/issue-99482.rs @@ -1,5 +1,5 @@ fn main() { let f = |_: (), f: fn()| f; let _f = f(main); - //~^ ERROR this function takes 2 arguments but 1 argument was supplied + //~^ ERROR function takes 2 arguments but 1 argument was supplied } diff --git a/src/test/ui/argument-suggestions/missing_arguments.rs b/src/test/ui/argument-suggestions/missing_arguments.rs index ae0dabf27b1..c26564641cb 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.rs +++ b/src/test/ui/argument-suggestions/missing_arguments.rs @@ -7,34 +7,34 @@ fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} fn main() { - one_arg(); //~ ERROR this function takes + one_arg(); //~ ERROR function takes // The headers here show the types expected, // with formatting to emphasize which arguments are missing /* i32 f32 */ - two_same( ); //~ ERROR this function takes - two_same( 1 ); //~ ERROR this function takes - two_diff( ); //~ ERROR this function takes - two_diff( 1 ); //~ ERROR this function takes - two_diff( 1.0 ); //~ ERROR this function takes + two_same( ); //~ ERROR function takes + two_same( 1 ); //~ ERROR function takes + two_diff( ); //~ ERROR function takes + two_diff( 1 ); //~ ERROR function takes + two_diff( 1.0 ); //~ ERROR function takes /* i32 i32 i32 */ - three_same( ); //~ ERROR this function takes - three_same( 1 ); //~ ERROR this function takes - three_same( 1, 1 ); //~ ERROR this function takes + three_same( ); //~ ERROR function takes + three_same( 1 ); //~ ERROR function takes + three_same( 1, 1 ); //~ ERROR function takes /* i32 f32 &str */ - three_diff( 1.0, "" ); //~ ERROR this function takes - three_diff( 1, "" ); //~ ERROR this function takes - three_diff( 1, 1.0 ); //~ ERROR this function takes - three_diff( "" ); //~ ERROR this function takes - three_diff( 1.0 ); //~ ERROR this function takes - three_diff( 1 ); //~ ERROR this function takes + three_diff( 1.0, "" ); //~ ERROR function takes + three_diff( 1, "" ); //~ ERROR function takes + three_diff( 1, 1.0 ); //~ ERROR function takes + three_diff( "" ); //~ ERROR function takes + three_diff( 1.0 ); //~ ERROR function takes + three_diff( 1 ); //~ ERROR function takes /* i32 f32 f32 &str */ - four_repeated( ); //~ ERROR this function takes - four_repeated( 1, "" ); //~ ERROR this function takes + four_repeated( ); //~ ERROR function takes + four_repeated( 1, "" ); //~ ERROR function takes /* i32 f32 i32 f32 &str */ - complex( ); //~ ERROR this function takes - complex( 1, "" ); //~ ERROR this function takes + complex( ); //~ ERROR function takes + complex( 1, "" ); //~ ERROR function takes } diff --git a/src/test/ui/argument-suggestions/mixed_cases.rs b/src/test/ui/argument-suggestions/mixed_cases.rs index 73678482b30..86e94a4382c 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.rs +++ b/src/test/ui/argument-suggestions/mixed_cases.rs @@ -7,11 +7,11 @@ fn three_args(_a: i32, _b: f32, _c: &str) {} fn main() { // Extra + Invalid - two_args(1, "", X {}); //~ ERROR this function takes - three_args(1, "", X {}, ""); //~ ERROR this function takes + two_args(1, "", X {}); //~ ERROR function takes + three_args(1, "", X {}, ""); //~ ERROR function takes // Missing and Invalid - three_args(1, X {}); //~ ERROR this function takes + three_args(1, X {}); //~ ERROR function takes // Missing and Extra three_args(1, "", X {}); //~ ERROR arguments to this function are incorrect @@ -20,5 +20,5 @@ fn main() { three_args("", X {}, 1); //~ ERROR arguments to this function are incorrect // Swapped and missing - three_args("", 1); //~ ERROR this function takes + three_args("", 1); //~ ERROR function takes } diff --git a/src/test/ui/argument-suggestions/too-long.stderr b/src/test/ui/argument-suggestions/too-long.stderr index bd430194c5e..4928943294b 100644 --- a/src/test/ui/argument-suggestions/too-long.stderr +++ b/src/test/ui/argument-suggestions/too-long.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types LL | qux.foo(a, b, c, d, e, f, g, h, i, j, k, l); | --- ^ expected `i32`, found `&i32` | | - | arguments to this function are incorrect + | arguments to this method are incorrect | note: associated function defined here --> $DIR/too-long.rs:4:8 diff --git a/src/test/ui/issues/issue-105330.rs b/src/test/ui/associated-consts/issue-105330.rs index 86e45f10b0e..86e45f10b0e 100644 --- a/src/test/ui/issues/issue-105330.rs +++ b/src/test/ui/associated-consts/issue-105330.rs diff --git a/src/test/ui/issues/issue-105330.stderr b/src/test/ui/associated-consts/issue-105330.stderr index 30c380152a5..30c380152a5 100644 --- a/src/test/ui/issues/issue-105330.stderr +++ b/src/test/ui/associated-consts/issue-105330.stderr diff --git a/src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr b/src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr index e761c6c62a6..d6b18d4ed32 100644 --- a/src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr +++ b/src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr @@ -32,7 +32,7 @@ error[E0308]: mismatched types LL | fn f() { ModelT.chip_paint(Blue); } | ---------- ^^^^ expected struct `Black`, found struct `Blue` | | - | arguments to this function are incorrect + | arguments to this method are incorrect | note: associated function defined here --> $DIR/associated-type-projection-from-supertrait.rs:12:8 @@ -46,7 +46,7 @@ error[E0308]: mismatched types LL | fn g() { ModelU.chip_paint(Black); } | ---------- ^^^^^ expected struct `Blue`, found struct `Black` | | - | arguments to this function are incorrect + | arguments to this method are incorrect | note: associated function defined here --> $DIR/associated-type-projection-from-supertrait.rs:12:8 diff --git a/src/test/ui/associated-types/associated-types-for-unimpl-trait.stderr b/src/test/ui/associated-types/associated-types-for-unimpl-trait.stderr index 389cc7beddd..6552c8be780 100644 --- a/src/test/ui/associated-types/associated-types-for-unimpl-trait.stderr +++ b/src/test/ui/associated-types/associated-types-for-unimpl-trait.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `Self: Get` is not satisfied - --> $DIR/associated-types-for-unimpl-trait.rs:10:5 + --> $DIR/associated-types-for-unimpl-trait.rs:10:40 | LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` + | ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` | help: consider further restricting `Self` | diff --git a/src/test/ui/associated-types/associated-types-no-suitable-bound.stderr b/src/test/ui/associated-types/associated-types-no-suitable-bound.stderr index 1feaa612ee6..b2ee1b5e6d0 100644 --- a/src/test/ui/associated-types/associated-types-no-suitable-bound.stderr +++ b/src/test/ui/associated-types/associated-types-no-suitable-bound.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `T: Get` is not satisfied - --> $DIR/associated-types-no-suitable-bound.rs:11:5 + --> $DIR/associated-types-no-suitable-bound.rs:11:21 | LL | fn uhoh<T>(foo: <T as Get>::Value) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `T` + | ^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `T` | help: consider restricting type parameter `T` | diff --git a/src/test/ui/associated-types/associated-types-no-suitable-supertrait-2.stderr b/src/test/ui/associated-types/associated-types-no-suitable-supertrait-2.stderr index cc3ed556115..2e40dbd065d 100644 --- a/src/test/ui/associated-types/associated-types-no-suitable-supertrait-2.stderr +++ b/src/test/ui/associated-types/associated-types-no-suitable-supertrait-2.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `Self: Get` is not satisfied - --> $DIR/associated-types-no-suitable-supertrait-2.rs:17:5 + --> $DIR/associated-types-no-suitable-supertrait-2.rs:17:40 | LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` + | ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` | help: consider further restricting `Self` | diff --git a/src/test/ui/associated-types/associated-types-no-suitable-supertrait.stderr b/src/test/ui/associated-types/associated-types-no-suitable-supertrait.stderr index 18f2830d8b2..bd3ee2abd2c 100644 --- a/src/test/ui/associated-types/associated-types-no-suitable-supertrait.stderr +++ b/src/test/ui/associated-types/associated-types-no-suitable-supertrait.stderr @@ -1,14 +1,14 @@ error[E0277]: the trait bound `(T, U): Get` is not satisfied - --> $DIR/associated-types-no-suitable-supertrait.rs:22:5 + --> $DIR/associated-types-no-suitable-supertrait.rs:22:40 | LL | fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `(T, U)` + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `(T, U)` error[E0277]: the trait bound `Self: Get` is not satisfied - --> $DIR/associated-types-no-suitable-supertrait.rs:17:5 + --> $DIR/associated-types-no-suitable-supertrait.rs:17:40 | LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` + | ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` | help: consider further restricting `Self` | diff --git a/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr b/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr index 66d59bccdbb..2e67c21940f 100644 --- a/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr +++ b/src/test/ui/associated-types/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `Self: Get` is not satisfied - --> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:10:5 + --> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:10:40 | LL | fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` + | ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` | help: consider further restricting `Self` | diff --git a/src/test/ui/associated-types/defaults-specialization.stderr b/src/test/ui/associated-types/defaults-specialization.stderr index 8df326351fa..7e21f7fc306 100644 --- a/src/test/ui/associated-types/defaults-specialization.stderr +++ b/src/test/ui/associated-types/defaults-specialization.stderr @@ -22,8 +22,8 @@ note: type in trait | LL | fn make() -> Self::Ty { | ^^^^^^^^ - = note: expected fn pointer `fn() -> <A<T> as Tr>::Ty` - found fn pointer `fn() -> u8` + = note: expected signature `fn() -> <A<T> as Tr>::Ty` + found signature `fn() -> u8` error[E0053]: method `make` has an incompatible type for trait --> $DIR/defaults-specialization.rs:35:18 @@ -42,8 +42,8 @@ note: type in trait | LL | fn make() -> Self::Ty { | ^^^^^^^^ - = note: expected fn pointer `fn() -> <B<T> as Tr>::Ty` - found fn pointer `fn() -> bool` + = note: expected signature `fn() -> <B<T> as Tr>::Ty` + found signature `fn() -> bool` error[E0308]: mismatched types --> $DIR/defaults-specialization.rs:10:9 diff --git a/src/test/ui/issues/issue-25700-1.rs b/src/test/ui/associated-types/issue-25700-1.rs index 5e71a52ba4e..5e71a52ba4e 100644 --- a/src/test/ui/issues/issue-25700-1.rs +++ b/src/test/ui/associated-types/issue-25700-1.rs diff --git a/src/test/ui/issues/issue-25700-2.rs b/src/test/ui/associated-types/issue-25700-2.rs index 89b1db496f9..89b1db496f9 100644 --- a/src/test/ui/issues/issue-25700-2.rs +++ b/src/test/ui/associated-types/issue-25700-2.rs diff --git a/src/test/ui/issues/issue-25700.rs b/src/test/ui/associated-types/issue-25700.rs index e5b9a97523d..e5b9a97523d 100644 --- a/src/test/ui/issues/issue-25700.rs +++ b/src/test/ui/associated-types/issue-25700.rs diff --git a/src/test/ui/issues/issue-25700.stderr b/src/test/ui/associated-types/issue-25700.stderr index fa309a55c3c..fa309a55c3c 100644 --- a/src/test/ui/issues/issue-25700.stderr +++ b/src/test/ui/associated-types/issue-25700.stderr diff --git a/src/test/ui/associated-types/issue-59324.rs b/src/test/ui/associated-types/issue-59324.rs index 9e68e9e7751..551f13ee178 100644 --- a/src/test/ui/associated-types/issue-59324.rs +++ b/src/test/ui/associated-types/issue-59324.rs @@ -15,9 +15,9 @@ pub trait ThriftService<Bug: NotFoo>: { fn get_service( //~^ ERROR the trait bound `Bug: Foo` is not satisfied - //~| ERROR the trait bound `Bug: Foo` is not satisfied &self, ) -> Self::AssocType; + //~^ ERROR the trait bound `Bug: Foo` is not satisfied } fn with_factory<H>(factory: dyn ThriftService<()>) {} diff --git a/src/test/ui/associated-types/issue-59324.stderr b/src/test/ui/associated-types/issue-59324.stderr index 62cf1f37a77..a84b599b52b 100644 --- a/src/test/ui/associated-types/issue-59324.stderr +++ b/src/test/ui/associated-types/issue-59324.stderr @@ -20,7 +20,7 @@ LL | | LL | | LL | | Service<AssocType = <Bug as Foo>::OnlyFoo> ... | -LL | | ) -> Self::AssocType; +LL | | LL | | } | |_^ the trait `Foo` is not implemented for `Bug` | @@ -34,7 +34,6 @@ error[E0277]: the trait bound `Bug: Foo` is not satisfied | LL | / fn get_service( LL | | -LL | | LL | | &self, LL | | ) -> Self::AssocType; | |_________________________^ the trait `Foo` is not implemented for `Bug` @@ -45,20 +44,16 @@ LL | pub trait ThriftService<Bug: NotFoo + Foo>: | +++++ error[E0277]: the trait bound `(): Foo` is not satisfied - --> $DIR/issue-59324.rs:23:1 + --> $DIR/issue-59324.rs:23:29 | LL | fn with_factory<H>(factory: dyn ThriftService<()>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` + | ^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` error[E0277]: the trait bound `Bug: Foo` is not satisfied - --> $DIR/issue-59324.rs:16:5 + --> $DIR/issue-59324.rs:19:10 | -LL | / fn get_service( -LL | | -LL | | -LL | | &self, -LL | | ) -> Self::AssocType; - | |_________________________^ the trait `Foo` is not implemented for `Bug` +LL | ) -> Self::AssocType; + | ^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bug` | help: consider further restricting this bound | diff --git a/src/test/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr b/src/test/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr index 22d2928f2f5..13e7222551a 100644 --- a/src/test/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr +++ b/src/test/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr @@ -9,8 +9,8 @@ note: type in trait | LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: expected fn pointer `fn(&i32) -> Pin<Box<dyn Future<Output = i32>>>` - found fn pointer `fn(&i32) -> impl Future<Output = i32>` + = note: expected signature `fn(&i32) -> Pin<Box<dyn Future<Output = i32>>>` + found signature `fn(&i32) -> impl Future<Output = i32>` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-drop-from-guard.rs b/src/test/ui/borrowck/borrowck-drop-from-guard.rs index 4995029a70f..0f320af2657 100644 --- a/src/test/ui/borrowck/borrowck-drop-from-guard.rs +++ b/src/test/ui/borrowck/borrowck-drop-from-guard.rs @@ -1,3 +1,5 @@ +#![feature(if_let_guard)] + fn foo(_:String) {} fn main() @@ -8,4 +10,11 @@ fn main() Some(_) => {} None => { foo(my_str); } //~ ERROR [E0382] } + + let my_str = "hello".to_owned(); + match Some(42) { + Some(_) if let Some(()) = { drop(my_str); None } => {} + Some(_) => {} + None => { foo(my_str); } //~ ERROR [E0382] + } } diff --git a/src/test/ui/borrowck/borrowck-drop-from-guard.stderr b/src/test/ui/borrowck/borrowck-drop-from-guard.stderr index eaf4bb38bc5..9fa28efd855 100644 --- a/src/test/ui/borrowck/borrowck-drop-from-guard.stderr +++ b/src/test/ui/borrowck/borrowck-drop-from-guard.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `my_str` - --> $DIR/borrowck-drop-from-guard.rs:9:23 + --> $DIR/borrowck-drop-from-guard.rs:11:23 | LL | let my_str = "hello".to_owned(); | ------ move occurs because `my_str` has type `String`, which does not implement the `Copy` trait @@ -15,6 +15,23 @@ help: consider cloning the value if the performance cost is acceptable LL | Some(_) if { drop(my_str.clone()); false } => {} | ++++++++ -error: aborting due to previous error +error[E0382]: use of moved value: `my_str` + --> $DIR/borrowck-drop-from-guard.rs:18:23 + | +LL | let my_str = "hello".to_owned(); + | ------ move occurs because `my_str` has type `String`, which does not implement the `Copy` trait +LL | match Some(42) { +LL | Some(_) if let Some(()) = { drop(my_str); None } => {} + | ------ value moved here +LL | Some(_) => {} +LL | None => { foo(my_str); } + | ^^^^^^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | Some(_) if let Some(()) = { drop(my_str.clone()); None } => {} + | ++++++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-mutate-in-guard.rs b/src/test/ui/borrowck/borrowck-mutate-in-guard.rs index 9cbceeb945c..d80a9e81576 100644 --- a/src/test/ui/borrowck/borrowck-mutate-in-guard.rs +++ b/src/test/ui/borrowck/borrowck-mutate-in-guard.rs @@ -1,9 +1,11 @@ +#![feature(if_let_guard)] + enum Enum<'a> { A(&'a isize), B(bool), } -fn foo() -> isize { +fn if_guard() -> isize { let mut n = 42; let mut x = Enum::A(&mut n); match x { @@ -16,6 +18,17 @@ fn foo() -> isize { } } -fn main() { - foo(); +fn if_let_guard() -> isize { + let mut n = 42; + let mut x = Enum::A(&mut n); + match x { + Enum::A(_) if let Some(()) = { x = Enum::B(false); None } => 1, + //~^ ERROR cannot assign `x` in match guard + Enum::A(_) if let Some(()) = { let y = &mut x; *y = Enum::B(false); None } => 1, + //~^ ERROR cannot mutably borrow `x` in match guard + Enum::A(p) => *p, + Enum::B(_) => 2, + } } + +fn main() {} diff --git a/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr b/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr index 6d05e97252d..dbb3272fdc3 100644 --- a/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr +++ b/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr @@ -1,5 +1,5 @@ error[E0510]: cannot assign `x` in match guard - --> $DIR/borrowck-mutate-in-guard.rs:10:25 + --> $DIR/borrowck-mutate-in-guard.rs:12:25 | LL | match x { | - value is immutable in match guard @@ -7,7 +7,7 @@ LL | Enum::A(_) if { x = Enum::B(false); false } => 1, | ^^^^^^^^^^^^^^^^^^ cannot assign error[E0510]: cannot mutably borrow `x` in match guard - --> $DIR/borrowck-mutate-in-guard.rs:12:33 + --> $DIR/borrowck-mutate-in-guard.rs:14:33 | LL | match x { | - value is immutable in match guard @@ -15,6 +15,23 @@ LL | match x { LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, | ^^^^^^ cannot mutably borrow -error: aborting due to 2 previous errors +error[E0510]: cannot assign `x` in match guard + --> $DIR/borrowck-mutate-in-guard.rs:25:40 + | +LL | match x { + | - value is immutable in match guard +LL | Enum::A(_) if let Some(()) = { x = Enum::B(false); None } => 1, + | ^^^^^^^^^^^^^^^^^^ cannot assign + +error[E0510]: cannot mutably borrow `x` in match guard + --> $DIR/borrowck-mutate-in-guard.rs:27:48 + | +LL | match x { + | - value is immutable in match guard +... +LL | Enum::A(_) if let Some(()) = { let y = &mut x; *y = Enum::B(false); None } => 1, + | ^^^^^^ cannot mutably borrow + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0510`. diff --git a/src/test/ui/borrowck/issue-31287-drop-in-guard.rs b/src/test/ui/borrowck/issue-31287-drop-in-guard.rs index 07125b98a1f..5b824adc6e2 100644 --- a/src/test/ui/borrowck/issue-31287-drop-in-guard.rs +++ b/src/test/ui/borrowck/issue-31287-drop-in-guard.rs @@ -1,8 +1,15 @@ +#![feature(if_let_guard)] + fn main() { let a = Some("...".to_owned()); let b = match a { Some(_) if { drop(a); false } => None, x => x, //~ ERROR use of moved value: `a` }; - println!("{:?}", b); + + let a = Some("...".to_owned()); + let b = match a { + Some(_) if let Some(()) = { drop(a); None } => None, + x => x, //~ ERROR use of moved value: `a` + }; } diff --git a/src/test/ui/borrowck/issue-31287-drop-in-guard.stderr b/src/test/ui/borrowck/issue-31287-drop-in-guard.stderr index ad898fcabd9..18f371c2073 100644 --- a/src/test/ui/borrowck/issue-31287-drop-in-guard.stderr +++ b/src/test/ui/borrowck/issue-31287-drop-in-guard.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `a` - --> $DIR/issue-31287-drop-in-guard.rs:5:9 + --> $DIR/issue-31287-drop-in-guard.rs:7:9 | LL | let a = Some("...".to_owned()); | - move occurs because `a` has type `Option<String>`, which does not implement the `Copy` trait @@ -14,6 +14,22 @@ help: consider cloning the value if the performance cost is acceptable LL | Some(_) if { drop(a.clone()); false } => None, | ++++++++ -error: aborting due to previous error +error[E0382]: use of moved value: `a` + --> $DIR/issue-31287-drop-in-guard.rs:13:9 + | +LL | let a = Some("...".to_owned()); + | - move occurs because `a` has type `Option<String>`, which does not implement the `Copy` trait +LL | let b = match a { +LL | Some(_) if let Some(()) = { drop(a); None } => None, + | - value moved here +LL | x => x, + | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | Some(_) if let Some(()) = { drop(a.clone()); None } => None, + | ++++++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/issue-93078.rs b/src/test/ui/borrowck/issue-93078.rs new file mode 100644 index 00000000000..2e608c5db3e --- /dev/null +++ b/src/test/ui/borrowck/issue-93078.rs @@ -0,0 +1,15 @@ +trait Modify { + fn modify(&mut self) ; +} + +impl<T> Modify for T { + fn modify(&mut self) {} +} + +trait Foo { + fn mute(&mut self) { + self.modify(); //~ ERROR cannot borrow `self` as mutable + } +} + +fn main() {} diff --git a/src/test/ui/borrowck/issue-93078.stderr b/src/test/ui/borrowck/issue-93078.stderr new file mode 100644 index 00000000000..771a652a173 --- /dev/null +++ b/src/test/ui/borrowck/issue-93078.stderr @@ -0,0 +1,12 @@ +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-93078.rs:11:9 + | +LL | self.modify(); + | ^^^^^^^^^^^^^ cannot borrow as mutable + | + = note: as `Self` may be unsized, this call attempts to take `&mut &mut self` + = note: however, `&mut self` expands to `self: &mut Self`, therefore `self` cannot be borrowed mutably + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.stderr b/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.stderr index 1e3b071ef92..930fea9158d 100644 --- a/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.stderr +++ b/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.stderr @@ -22,8 +22,8 @@ error[E0308]: method not compatible with trait LL | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | - = note: expected fn pointer `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'_>)` - found fn pointer `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'_>)` + = note: expected signature `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'_>)` + found signature `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'_>)` note: the lifetime `'c` as defined here... --> $DIR/regions-bound-missing-bound-in-impl.rs:27:24 | @@ -41,8 +41,8 @@ error[E0308]: method not compatible with trait LL | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | - = note: expected fn pointer `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'_>)` - found fn pointer `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'_>)` + = note: expected signature `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'_>)` + found signature `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'_>)` note: the lifetime `'c` as defined here... --> $DIR/regions-bound-missing-bound-in-impl.rs:27:24 | diff --git a/src/test/ui/c-variadic/variadic-ffi-1.rs b/src/test/ui/c-variadic/variadic-ffi-1.rs index 24407a71ce6..acd8a25dc53 100644 --- a/src/test/ui/c-variadic/variadic-ffi-1.rs +++ b/src/test/ui/c-variadic/variadic-ffi-1.rs @@ -19,8 +19,8 @@ extern "C" fn bar(f: isize, x: u8) {} fn main() { unsafe { - foo(); //~ ERROR this function takes at least 2 arguments but 0 arguments were supplied - foo(1); //~ ERROR this function takes at least 2 arguments but 1 argument was supplied + foo(); //~ ERROR function takes at least 2 arguments but 0 arguments were supplied + foo(1); //~ ERROR function takes at least 2 arguments but 1 argument was supplied let x: unsafe extern "C" fn(f: isize, x: u8) = foo; //~ ERROR mismatched types let y: extern "C" fn(f: isize, x: u8, ...) = bar; //~ ERROR mismatched types diff --git a/src/test/ui/chalkify/arithmetic.rs b/src/test/ui/chalkify/arithmetic.rs index a20acce4c76..6c78a71b0fc 100644 --- a/src/test/ui/chalkify/arithmetic.rs +++ b/src/test/ui/chalkify/arithmetic.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk fn main() { 1 + 2; diff --git a/src/test/ui/chalkify/assert.rs b/src/test/ui/chalkify/assert.rs index f4ebf91924c..834c8935e76 100644 --- a/src/test/ui/chalkify/assert.rs +++ b/src/test/ui/chalkify/assert.rs @@ -1,5 +1,5 @@ // run-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk fn main() { assert_eq!(1, 1); diff --git a/src/test/ui/chalkify/basic.rs b/src/test/ui/chalkify/basic.rs index dbd60fc8bb1..4a7cd939669 100644 --- a/src/test/ui/chalkify/basic.rs +++ b/src/test/ui/chalkify/basic.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo {} diff --git a/src/test/ui/chalkify/bugs/async.rs b/src/test/ui/chalkify/bugs/async.rs index ae5224dbd6f..ed0f5dc9bd3 100644 --- a/src/test/ui/chalkify/bugs/async.rs +++ b/src/test/ui/chalkify/bugs/async.rs @@ -1,6 +1,6 @@ // check-fail // known-bug: unknown -// compile-flags: -Z chalk --edition=2021 +// compile-flags: -Z trait-solver=chalk --edition=2021 fn main() -> () {} diff --git a/src/test/ui/chalkify/builtin-copy-clone.rs b/src/test/ui/chalkify/builtin-copy-clone.rs index 7712e946542..a478c006ef1 100644 --- a/src/test/ui/chalkify/builtin-copy-clone.rs +++ b/src/test/ui/chalkify/builtin-copy-clone.rs @@ -1,5 +1,5 @@ // run-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk // Test that `Clone` is correctly implemented for builtin types. diff --git a/src/test/ui/chalkify/chalk_initial_program.rs b/src/test/ui/chalkify/chalk_initial_program.rs index df25bad622b..21de72b6fcc 100644 --- a/src/test/ui/chalkify/chalk_initial_program.rs +++ b/src/test/ui/chalkify/chalk_initial_program.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo { } diff --git a/src/test/ui/chalkify/closure.rs b/src/test/ui/chalkify/closure.rs index 568e2e30c41..a908a1e97ec 100644 --- a/src/test/ui/chalkify/closure.rs +++ b/src/test/ui/chalkify/closure.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk fn main() -> () { let t = || {}; diff --git a/src/test/ui/chalkify/generic_impls.rs b/src/test/ui/chalkify/generic_impls.rs index d70c6f8055d..7d33e12d8be 100644 --- a/src/test/ui/chalkify/generic_impls.rs +++ b/src/test/ui/chalkify/generic_impls.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo { } diff --git a/src/test/ui/chalkify/impl_wf.rs b/src/test/ui/chalkify/impl_wf.rs index 66f57c2d110..c8dfd4c3a5b 100644 --- a/src/test/ui/chalkify/impl_wf.rs +++ b/src/test/ui/chalkify/impl_wf.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo: Sized { } diff --git a/src/test/ui/chalkify/impl_wf_2.rs b/src/test/ui/chalkify/impl_wf_2.rs index 758a7185e39..325044ad634 100644 --- a/src/test/ui/chalkify/impl_wf_2.rs +++ b/src/test/ui/chalkify/impl_wf_2.rs @@ -1,6 +1,6 @@ // Split out of impl_wf.rs to work around rust aborting compilation early -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo: Sized { } diff --git a/src/test/ui/chalkify/inherent_impl.rs b/src/test/ui/chalkify/inherent_impl.rs index a2730219fbe..f0f24d485cd 100644 --- a/src/test/ui/chalkify/inherent_impl.rs +++ b/src/test/ui/chalkify/inherent_impl.rs @@ -1,5 +1,5 @@ // run-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo { } diff --git a/src/test/ui/chalkify/inherent_impl_min.rs b/src/test/ui/chalkify/inherent_impl_min.rs index 774c46e401c..3eda7102dec 100644 --- a/src/test/ui/chalkify/inherent_impl_min.rs +++ b/src/test/ui/chalkify/inherent_impl_min.rs @@ -1,5 +1,5 @@ // run-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo { } diff --git a/src/test/ui/chalkify/lower_env1.rs b/src/test/ui/chalkify/lower_env1.rs index e3c75695921..c8762001e6a 100644 --- a/src/test/ui/chalkify/lower_env1.rs +++ b/src/test/ui/chalkify/lower_env1.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk #![allow(dead_code)] diff --git a/src/test/ui/chalkify/lower_env2.rs b/src/test/ui/chalkify/lower_env2.rs index b5432ce0e30..7d4f81f12ea 100644 --- a/src/test/ui/chalkify/lower_env2.rs +++ b/src/test/ui/chalkify/lower_env2.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk #![allow(dead_code)] diff --git a/src/test/ui/chalkify/lower_env3.rs b/src/test/ui/chalkify/lower_env3.rs index 673f08d78ab..5b70c4abbb5 100644 --- a/src/test/ui/chalkify/lower_env3.rs +++ b/src/test/ui/chalkify/lower_env3.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk #![allow(dead_code)] diff --git a/src/test/ui/chalkify/lower_impl.rs b/src/test/ui/chalkify/lower_impl.rs index f586cf08391..6f79b3ba386 100644 --- a/src/test/ui/chalkify/lower_impl.rs +++ b/src/test/ui/chalkify/lower_impl.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo { } diff --git a/src/test/ui/chalkify/lower_struct.rs b/src/test/ui/chalkify/lower_struct.rs index 94a0716d383..6be0d4dd5bd 100644 --- a/src/test/ui/chalkify/lower_struct.rs +++ b/src/test/ui/chalkify/lower_struct.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk struct Foo<'a, T> where Box<T>: Clone { _x: std::marker::PhantomData<&'a T>, diff --git a/src/test/ui/chalkify/lower_trait.rs b/src/test/ui/chalkify/lower_trait.rs index d8f6180ceb3..8f5b358220b 100644 --- a/src/test/ui/chalkify/lower_trait.rs +++ b/src/test/ui/chalkify/lower_trait.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Bar { } diff --git a/src/test/ui/chalkify/lower_trait_higher_rank.rs b/src/test/ui/chalkify/lower_trait_higher_rank.rs index a48979491a1..f04a1deea87 100644 --- a/src/test/ui/chalkify/lower_trait_higher_rank.rs +++ b/src/test/ui/chalkify/lower_trait_higher_rank.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo<F: ?Sized> where for<'a> F: Fn(&'a (u8, u16)) -> &'a u8 { diff --git a/src/test/ui/chalkify/lower_trait_where_clause.rs b/src/test/ui/chalkify/lower_trait_where_clause.rs index 19cff8db7cb..a21d2f31963 100644 --- a/src/test/ui/chalkify/lower_trait_where_clause.rs +++ b/src/test/ui/chalkify/lower_trait_where_clause.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk use std::borrow::Borrow; diff --git a/src/test/ui/chalkify/println.rs b/src/test/ui/chalkify/println.rs index 0f0df29019e..edddc382152 100644 --- a/src/test/ui/chalkify/println.rs +++ b/src/test/ui/chalkify/println.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk fn main() { println!("hello"); diff --git a/src/test/ui/chalkify/projection.rs b/src/test/ui/chalkify/projection.rs index d6a8dd7a4a2..19bb2ae1497 100644 --- a/src/test/ui/chalkify/projection.rs +++ b/src/test/ui/chalkify/projection.rs @@ -1,5 +1,5 @@ // run-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo { } diff --git a/src/test/ui/chalkify/recursive_where_clause_on_type.rs b/src/test/ui/chalkify/recursive_where_clause_on_type.rs index 87324a5f79b..c2c8aa6aabe 100644 --- a/src/test/ui/chalkify/recursive_where_clause_on_type.rs +++ b/src/test/ui/chalkify/recursive_where_clause_on_type.rs @@ -1,6 +1,6 @@ // FIXME(chalk): should fail, see comments // check-fail -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk #![feature(trivial_bounds)] @@ -25,6 +25,6 @@ fn foo<T: Foo>() { fn main() { // For some reason, the error is duplicated... - foo::<S>() //~ ERROR the type `S` is not well-formed (chalk) - //~^ ERROR the type `S` is not well-formed (chalk) + foo::<S>() //~ ERROR the type `S` is not well-formed + //~^ ERROR the type `S` is not well-formed } diff --git a/src/test/ui/chalkify/recursive_where_clause_on_type.stderr b/src/test/ui/chalkify/recursive_where_clause_on_type.stderr index fddd5895927..cead5adeaaa 100644 --- a/src/test/ui/chalkify/recursive_where_clause_on_type.stderr +++ b/src/test/ui/chalkify/recursive_where_clause_on_type.stderr @@ -1,10 +1,10 @@ -error: the type `S` is not well-formed (chalk) +error: the type `S` is not well-formed --> $DIR/recursive_where_clause_on_type.rs:28:11 | LL | foo::<S>() | ^ -error: the type `S` is not well-formed (chalk) +error: the type `S` is not well-formed --> $DIR/recursive_where_clause_on_type.rs:28:5 | LL | foo::<S>() diff --git a/src/test/ui/chalkify/super_trait.rs b/src/test/ui/chalkify/super_trait.rs index eeff9fd9b80..540ae51e57f 100644 --- a/src/test/ui/chalkify/super_trait.rs +++ b/src/test/ui/chalkify/super_trait.rs @@ -1,5 +1,5 @@ // run-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo { } trait Bar: Foo { } diff --git a/src/test/ui/chalkify/trait-objects.rs b/src/test/ui/chalkify/trait-objects.rs index d56abc42bf5..144d9788b82 100644 --- a/src/test/ui/chalkify/trait-objects.rs +++ b/src/test/ui/chalkify/trait-objects.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk use std::fmt::Display; diff --git a/src/test/ui/chalkify/trait_implied_bound.rs b/src/test/ui/chalkify/trait_implied_bound.rs index 8a2e1cf5990..f97dbf6b7e7 100644 --- a/src/test/ui/chalkify/trait_implied_bound.rs +++ b/src/test/ui/chalkify/trait_implied_bound.rs @@ -1,5 +1,5 @@ // run-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo { } trait Bar<U> where U: Foo { } diff --git a/src/test/ui/chalkify/type_implied_bound.rs b/src/test/ui/chalkify/type_implied_bound.rs index 8673f5319bd..70f1b4265e4 100644 --- a/src/test/ui/chalkify/type_implied_bound.rs +++ b/src/test/ui/chalkify/type_implied_bound.rs @@ -1,5 +1,5 @@ // run-pass -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Eq { } trait Hash: Eq { } diff --git a/src/test/ui/chalkify/type_inference.rs b/src/test/ui/chalkify/type_inference.rs index 369777a7904..d7167d0dc57 100644 --- a/src/test/ui/chalkify/type_inference.rs +++ b/src/test/ui/chalkify/type_inference.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo { } impl Foo for i32 { } diff --git a/src/test/ui/chalkify/type_wf.rs b/src/test/ui/chalkify/type_wf.rs index eeeefcfb7dd..37d2f5ca832 100644 --- a/src/test/ui/chalkify/type_wf.rs +++ b/src/test/ui/chalkify/type_wf.rs @@ -1,5 +1,5 @@ // check-fail -// compile-flags: -Z chalk +// compile-flags: -Z trait-solver=chalk trait Foo { } diff --git a/src/test/ui/check-cfg/well-known-values.stderr b/src/test/ui/check-cfg/well-known-values.stderr index 29ececea5d3..69d799783a9 100644 --- a/src/test/ui/check-cfg/well-known-values.stderr +++ b/src/test/ui/check-cfg/well-known-values.stderr @@ -6,7 +6,7 @@ LL | #[cfg(target_os = "linuz")] | | | help: did you mean: `"linux"` | - = note: expected values for `target_os` are: aix, android, cuda, dragonfly, emscripten, espidf, freebsd, fuchsia, haiku, hermit, horizon, illumos, ios, l4re, linux, macos, netbsd, none, nto, openbsd, psp, redox, solaris, solid_asp3, tvos, uefi, unknown, vxworks, wasi, watchos, windows, xous + = note: expected values for `target_os` are: aix, android, cuda, dragonfly, emscripten, espidf, freebsd, fuchsia, haiku, hermit, horizon, illumos, ios, l4re, linux, macos, netbsd, none, nto, openbsd, psp, redox, solaris, solid_asp3, tvos, uefi, unknown, vita, vxworks, wasi, watchos, windows, xous = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value diff --git a/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.rs b/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.rs index bdd6cb79b60..00f50c33e1c 100644 --- a/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.rs +++ b/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.rs @@ -8,10 +8,9 @@ struct Point { fn main() { let mut c = { let mut p = Point {x: "1".to_string(), y: "2".to_string() }; - || { + || { //~ ERROR closure may outlive the current block, but it borrows `p` let x = &mut p.x; println!("{:?}", p); - //~^ ERROR `p` does not live long enough } }; c(); diff --git a/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.stderr b/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.stderr index dab1809a381..ee923804786 100644 --- a/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.stderr +++ b/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.stderr @@ -1,18 +1,22 @@ -error[E0597]: `p` does not live long enough - --> $DIR/borrowck-3.rs:13:29 +error[E0373]: closure may outlive the current block, but it borrows `p`, which is owned by the current block + --> $DIR/borrowck-3.rs:11:9 | -LL | let mut c = { - | ----- borrow later stored here -LL | let mut p = Point {x: "1".to_string(), y: "2".to_string() }; LL | || { - | -- value captured here + | ^^ may outlive borrowed value `p` LL | let x = &mut p.x; LL | println!("{:?}", p); - | ^ borrowed value does not live long enough -... -LL | }; - | - `p` dropped here while still borrowed + | - `p` is borrowed here + | +note: block requires argument type to outlive `'1` + --> $DIR/borrowck-3.rs:9:9 + | +LL | let mut c = { + | ^^^^^ +help: to force the closure to take ownership of `p` (and any other referenced variables), use the `move` keyword + | +LL | move || { + | ++++ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/closures/supertrait-hint-cycle-2.rs b/src/test/ui/closures/supertrait-hint-cycle-2.rs new file mode 100644 index 00000000000..fda81b18d1e --- /dev/null +++ b/src/test/ui/closures/supertrait-hint-cycle-2.rs @@ -0,0 +1,18 @@ +// check-pass + +trait Foo<'a> { + type Input; +} + +impl<F: Fn(u32)> Foo<'_> for F { + type Input = u32; +} + +trait SuperFn: for<'a> Foo<'a> + for<'a> Fn(<Self as Foo<'a>>::Input) {} +impl<T> SuperFn for T where T: for<'a> Fn(<Self as Foo<'a>>::Input) + for<'a> Foo<'a> {} + +fn needs_super(_: impl SuperFn) {} + +fn main() { + needs_super(|_: u32| {}); +} diff --git a/src/test/ui/closures/supertrait-hint-cycle-3.rs b/src/test/ui/closures/supertrait-hint-cycle-3.rs new file mode 100644 index 00000000000..8149474df19 --- /dev/null +++ b/src/test/ui/closures/supertrait-hint-cycle-3.rs @@ -0,0 +1,16 @@ +// check-pass + + +trait Foo<'a> { + type Input; +} + +impl<F: Fn(u32)> Foo<'_> for F { + type Input = u32; +} + +fn needs_super<F: for<'a> Fn(<F as Foo<'a>>::Input) + for<'a> Foo<'a>>(_: F) {} + +fn main() { + needs_super(|_: u32| {}); +} diff --git a/src/test/ui/closures/supertrait-hint-cycle.rs b/src/test/ui/closures/supertrait-hint-cycle.rs new file mode 100644 index 00000000000..dbb06b2ef7a --- /dev/null +++ b/src/test/ui/closures/supertrait-hint-cycle.rs @@ -0,0 +1,65 @@ +// edition:2021 +// check-pass + +#![feature(type_alias_impl_trait)] +#![feature(closure_lifetime_binder)] + +use std::future::Future; + +trait AsyncFn<I, R>: FnMut(I) -> Self::Fut { + type Fut: Future<Output = R>; +} + +impl<F, I, R, Fut> AsyncFn<I, R> for F +where + Fut: Future<Output = R>, + F: FnMut(I) -> Fut, +{ + type Fut = Fut; +} + +async fn call<C, R, F>(mut ctx: C, mut f: F) -> Result<R, ()> +where + F: for<'a> AsyncFn<&'a mut C, Result<R, ()>>, +{ + loop { + match f(&mut ctx).await { + Ok(val) => return Ok(val), + Err(_) => continue, + } + } +} + +trait Cap<'a> {} +impl<T> Cap<'_> for T {} + +fn works(ctx: &mut usize) { + let mut inner = 0; + + type Ret<'a, 'b: 'a> = impl Future<Output = Result<usize, ()>> + 'a + Cap<'b>; + + let callback = for<'a, 'b> |c: &'a mut &'b mut usize| -> Ret<'a, 'b> { + inner += 1; + async move { + let _c = c; + Ok(1usize) + } + }; + call(ctx, callback); +} + +fn doesnt_work_but_should(ctx: &mut usize) { + let mut inner = 0; + + type Ret<'a, 'b: 'a> = impl Future<Output = Result<usize, ()>> + 'a + Cap<'b>; + + call(ctx, for<'a, 'b> |c: &'a mut &'b mut usize| -> Ret<'a, 'b> { + inner += 1; + async move { + let _c = c; + Ok(1usize) + } + }); +} + +fn main() {} diff --git a/src/test/ui/issues/issue-82859-slice-miscompile.rs b/src/test/ui/codegen/issue-82859-slice-miscompile.rs index b64eb499071..b64eb499071 100644 --- a/src/test/ui/issues/issue-82859-slice-miscompile.rs +++ b/src/test/ui/codegen/issue-82859-slice-miscompile.rs diff --git a/src/test/ui/coherence/coherence-default-trait-impl.stderr b/src/test/ui/coherence/coherence-default-trait-impl.stderr index 63201878272..7be5b92a7de 100644 --- a/src/test/ui/coherence/coherence-default-trait-impl.stderr +++ b/src/test/ui/coherence/coherence-default-trait-impl.stderr @@ -2,7 +2,7 @@ error[E0199]: implementing the trait `MySafeTrait` is not unsafe --> $DIR/coherence-default-trait-impl.rs:8:1 | LL | unsafe impl MySafeTrait for Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove `unsafe` from this trait implementation | @@ -14,7 +14,7 @@ error[E0200]: the trait `MyUnsafeTrait` requires an `unsafe impl` declaration --> $DIR/coherence-default-trait-impl.rs:13:1 | LL | impl MyUnsafeTrait for Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the trait `MyUnsafeTrait` enforces invariants that the compiler can't check. Review the trait documentation and make sure this implementation upholds those invariants before adding the `unsafe` keyword help: add `unsafe` to this trait implementation diff --git a/src/test/ui/issues/issue-10626.rs b/src/test/ui/command/issue-10626.rs index 696a2dd1657..696a2dd1657 100644 --- a/src/test/ui/issues/issue-10626.rs +++ b/src/test/ui/command/issue-10626.rs diff --git a/src/test/ui/compare-method/bad-self-type.stderr b/src/test/ui/compare-method/bad-self-type.stderr index 90e907157a5..cad942e646e 100644 --- a/src/test/ui/compare-method/bad-self-type.stderr +++ b/src/test/ui/compare-method/bad-self-type.stderr @@ -7,8 +7,8 @@ LL | fn poll(self, _: &mut Context<'_>) -> Poll<()> { | expected struct `Pin`, found struct `MyFuture` | help: change the self-receiver type to match the trait: `self: Pin<&mut MyFuture>` | - = note: expected fn pointer `fn(Pin<&mut MyFuture>, &mut Context<'_>) -> Poll<_>` - found fn pointer `fn(MyFuture, &mut Context<'_>) -> Poll<_>` + = note: expected signature `fn(Pin<&mut MyFuture>, &mut Context<'_>) -> Poll<_>` + found signature `fn(MyFuture, &mut Context<'_>) -> Poll<_>` error[E0053]: method `foo` has an incompatible type for trait --> $DIR/bad-self-type.rs:22:18 @@ -24,8 +24,8 @@ note: type in trait | LL | fn foo(self); | ^^^^ - = note: expected fn pointer `fn(MyFuture)` - found fn pointer `fn(Box<MyFuture>)` + = note: expected signature `fn(MyFuture)` + found signature `fn(Box<MyFuture>)` error[E0053]: method `bar` has an incompatible type for trait --> $DIR/bad-self-type.rs:24:18 @@ -38,8 +38,8 @@ note: type in trait | LL | fn bar(self) -> Option<()>; | ^^^^^^^^^^ - = note: expected fn pointer `fn(MyFuture) -> Option<()>` - found fn pointer `fn(MyFuture)` + = note: expected signature `fn(MyFuture) -> Option<()>` + found signature `fn(MyFuture)` help: change the output type to match the trait | LL | fn bar(self) -> Option<()> {} diff --git a/src/test/ui/compare-method/issue-90444.stderr b/src/test/ui/compare-method/issue-90444.stderr index ee63f34b799..52e23d03b14 100644 --- a/src/test/ui/compare-method/issue-90444.stderr +++ b/src/test/ui/compare-method/issue-90444.stderr @@ -7,8 +7,8 @@ LL | fn from(_: fn((), (), &mut ())) -> Self { | types differ in mutability | help: change the parameter type to match the trait: `for<'a> fn((), (), &'a ())` | - = note: expected fn pointer `fn(for<'a> fn((), (), &'a ())) -> A` - found fn pointer `fn(for<'a> fn((), (), &'a mut ())) -> A` + = note: expected signature `fn(for<'a> fn((), (), &'a ())) -> A` + found signature `fn(for<'a> fn((), (), &'a mut ())) -> A` error[E0053]: method `from` has an incompatible type for trait --> $DIR/issue-90444.rs:11:16 @@ -19,8 +19,8 @@ LL | fn from(_: fn((), (), u64)) -> Self { | expected `u32`, found `u64` | help: change the parameter type to match the trait: `fn((), (), u32)` | - = note: expected fn pointer `fn(fn((), (), u32)) -> B` - found fn pointer `fn(fn((), (), u64)) -> B` + = note: expected signature `fn(fn((), (), u32)) -> B` + found signature `fn(fn((), (), u64)) -> B` error: aborting due to 2 previous errors diff --git a/src/test/ui/compare-method/reordered-type-param.stderr b/src/test/ui/compare-method/reordered-type-param.stderr index 49b5b1b92cd..1552d542d15 100644 --- a/src/test/ui/compare-method/reordered-type-param.stderr +++ b/src/test/ui/compare-method/reordered-type-param.stderr @@ -14,8 +14,8 @@ note: type in trait | LL | fn b<C:Clone,D>(&self, x: C) -> C; | ^ - = note: expected fn pointer `fn(&E, F) -> F` - found fn pointer `fn(&E, G) -> G` + = note: expected signature `fn(&E, F) -> F` + found signature `fn(&E, G) -> G` = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters diff --git a/src/test/ui/const-generics/assoc_const_eq_diagnostic.rs b/src/test/ui/const-generics/assoc_const_eq_diagnostic.rs new file mode 100644 index 00000000000..4d0aaf88e40 --- /dev/null +++ b/src/test/ui/const-generics/assoc_const_eq_diagnostic.rs @@ -0,0 +1,18 @@ +#![feature(associated_const_equality)] + +pub enum Mode { + Cool, +} + +pub trait Parse { + const MODE: Mode; +} + +pub trait CoolStuff: Parse<MODE = Mode::Cool> {} +//~^ ERROR expected associated constant bound +//~| ERROR expected type + +fn no_help() -> Mode::Cool {} +//~^ ERROR expected type, found variant + +fn main() {} diff --git a/src/test/ui/const-generics/assoc_const_eq_diagnostic.stderr b/src/test/ui/const-generics/assoc_const_eq_diagnostic.stderr new file mode 100644 index 00000000000..ba727ee0ea3 --- /dev/null +++ b/src/test/ui/const-generics/assoc_const_eq_diagnostic.stderr @@ -0,0 +1,33 @@ +error[E0573]: expected type, found variant `Mode::Cool` + --> $DIR/assoc_const_eq_diagnostic.rs:11:35 + | +LL | pub trait CoolStuff: Parse<MODE = Mode::Cool> {} + | ^^^^^^^^^^ + | | + | not a type + | help: try using the variant's enum: `Mode` + +error[E0573]: expected type, found variant `Mode::Cool` + --> $DIR/assoc_const_eq_diagnostic.rs:15:17 + | +LL | fn no_help() -> Mode::Cool {} + | ^^^^^^^^^^ + | | + | not a type + | help: try using the variant's enum: `Mode` + +error: expected associated constant bound, found type + --> $DIR/assoc_const_eq_diagnostic.rs:11:28 + | +LL | pub trait CoolStuff: Parse<MODE = Mode::Cool> {} + | ^^^^^^^^^^^^^^^^^ help: if equating a const, try wrapping with braces: `MODE = { const }` + | +note: associated constant defined here + --> $DIR/assoc_const_eq_diagnostic.rs:8:5 + | +LL | const MODE: Mode; + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0573`. diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-76595.rs b/src/test/ui/const-generics/generic_const_exprs/issue-76595.rs index faa8b3d10de..10247ce6bca 100644 --- a/src/test/ui/const-generics/generic_const_exprs/issue-76595.rs +++ b/src/test/ui/const-generics/generic_const_exprs/issue-76595.rs @@ -13,5 +13,5 @@ fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True { fn main() { test::<2>(); - //~^ ERROR this function takes 2 generic arguments + //~^ ERROR function takes 2 generic arguments } diff --git a/src/test/ui/const-generics/incorrect-number-of-const-args.rs b/src/test/ui/const-generics/incorrect-number-of-const-args.rs index de2d126afd7..8660cb2fb54 100644 --- a/src/test/ui/const-generics/incorrect-number-of-const-args.rs +++ b/src/test/ui/const-generics/incorrect-number-of-const-args.rs @@ -4,8 +4,8 @@ fn foo<const X: usize, const Y: usize>() -> usize { fn main() { foo::<0>(); - //~^ ERROR this function takes 2 + //~^ ERROR function takes 2 foo::<0, 0, 0>(); - //~^ ERROR this function takes 2 + //~^ ERROR function takes 2 } diff --git a/src/test/ui/consts/invalid-union.32bit.stderr b/src/test/ui/consts/invalid-union.32bit.stderr index 4758ea4ae88..0dd18a55786 100644 --- a/src/test/ui/consts/invalid-union.32bit.stderr +++ b/src/test/ui/consts/invalid-union.32bit.stderr @@ -21,12 +21,6 @@ note: erroneous constant used LL | let _: &'static _ = &C; | ^^ -note: erroneous constant used - --> $DIR/invalid-union.rs:43:25 - | -LL | let _: &'static _ = &C; - | ^^ - error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/invalid-union.64bit.stderr b/src/test/ui/consts/invalid-union.64bit.stderr index 22b85d20ce9..07f36ee2832 100644 --- a/src/test/ui/consts/invalid-union.64bit.stderr +++ b/src/test/ui/consts/invalid-union.64bit.stderr @@ -21,12 +21,6 @@ note: erroneous constant used LL | let _: &'static _ = &C; | ^^ -note: erroneous constant used - --> $DIR/invalid-union.rs:43:25 - | -LL | let _: &'static _ = &C; - | ^^ - error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/issue-103790.stderr b/src/test/ui/consts/issue-103790.stderr index 41b0816dc32..34d8ee281cf 100644 --- a/src/test/ui/consts/issue-103790.stderr +++ b/src/test/ui/consts/issue-103790.stderr @@ -20,7 +20,7 @@ LL | struct S<const S: (), const S: S = { S }>; help: add missing generic argument | LL | struct S<const S: (), const S: S<S> = { S }>; - | ~~~~ + | +++ error[E0391]: cycle detected when computing type of `S::S` --> $DIR/issue-103790.rs:4:32 diff --git a/src/test/ui/issues/issue-2734.rs b/src/test/ui/drop/issue-2734.rs index df4f394dc37..df4f394dc37 100644 --- a/src/test/ui/issues/issue-2734.rs +++ b/src/test/ui/drop/issue-2734.rs diff --git a/src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.stderr b/src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.stderr index 82169ee01be..5cec2bcb038 100644 --- a/src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.stderr +++ b/src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.stderr @@ -1,13 +1,8 @@ error[E0569]: requires an `unsafe impl` declaration due to `#[may_dangle]` attribute --> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:21:1 | -LL | / impl<#[may_dangle] A, B: fmt::Debug> Drop for Pt<A, B> { -LL | | -LL | | -LL | | // (unsafe to access self.1 due to #[may_dangle] on A) -LL | | fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); } -LL | | } - | |_^ +LL | impl<#[may_dangle] A, B: fmt::Debug> Drop for Pt<A, B> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the trait `Drop` enforces invariants that the compiler can't check. Review the trait documentation and make sure this implementation upholds those invariants before adding the `unsafe` keyword help: add `unsafe` to this trait implementation @@ -18,13 +13,8 @@ LL | unsafe impl<#[may_dangle] A, B: fmt::Debug> Drop for Pt<A, B> { error[E0569]: requires an `unsafe impl` declaration due to `#[may_dangle]` attribute --> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:27:1 | -LL | / impl<#[may_dangle] 'a, 'b, B: fmt::Debug> Drop for Pr<'a, 'b, B> { -LL | | -LL | | -LL | | // (unsafe to access self.1 due to #[may_dangle] on 'a) -LL | | fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); } -LL | | } - | |_^ +LL | impl<#[may_dangle] 'a, 'b, B: fmt::Debug> Drop for Pr<'a, 'b, B> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the trait `Drop` enforces invariants that the compiler can't check. Review the trait documentation and make sure this implementation upholds those invariants before adding the `unsafe` keyword help: add `unsafe` to this trait implementation diff --git a/src/test/ui/issues/issue-34053.rs b/src/test/ui/dropck/issue-34053.rs index fa23ae8f95b..fa23ae8f95b 100644 --- a/src/test/ui/issues/issue-34053.rs +++ b/src/test/ui/dropck/issue-34053.rs diff --git a/src/test/ui/issues/issue-72554.rs b/src/test/ui/enum-discriminant/issue-72554.rs index 54f7e9ac592..54f7e9ac592 100644 --- a/src/test/ui/issues/issue-72554.rs +++ b/src/test/ui/enum-discriminant/issue-72554.rs diff --git a/src/test/ui/issues/issue-72554.stderr b/src/test/ui/enum-discriminant/issue-72554.stderr index d12be539f7c..d12be539f7c 100644 --- a/src/test/ui/issues/issue-72554.stderr +++ b/src/test/ui/enum-discriminant/issue-72554.stderr diff --git a/src/test/ui/error-codes/E0013.rs b/src/test/ui/error-codes/E0013.rs new file mode 100644 index 00000000000..9b3982a785b --- /dev/null +++ b/src/test/ui/error-codes/E0013.rs @@ -0,0 +1,4 @@ +static X: i32 = 42; +const Y: i32 = X; //~ ERROR constants cannot refer to statics [E0013] + +fn main() {} diff --git a/src/test/ui/error-codes/E0013.stderr b/src/test/ui/error-codes/E0013.stderr new file mode 100644 index 00000000000..dc22053a638 --- /dev/null +++ b/src/test/ui/error-codes/E0013.stderr @@ -0,0 +1,11 @@ +error[E0013]: constants cannot refer to statics + --> $DIR/E0013.rs:2:16 + | +LL | const Y: i32 = X; + | ^ + | + = help: consider extracting the value of the `static` to a `const`, and referring to that + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0013`. diff --git a/src/test/ui/error-codes/E0015.rs b/src/test/ui/error-codes/E0015.rs new file mode 100644 index 00000000000..b0211358d81 --- /dev/null +++ b/src/test/ui/error-codes/E0015.rs @@ -0,0 +1,8 @@ +fn create_some() -> Option<u8> { + Some(1) +} + +const FOO: Option<u8> = create_some(); +//~^ ERROR cannot call non-const fn `create_some` in constants [E0015] + +fn main() {} diff --git a/src/test/ui/error-codes/E0015.stderr b/src/test/ui/error-codes/E0015.stderr new file mode 100644 index 00000000000..ec1ce47b2ce --- /dev/null +++ b/src/test/ui/error-codes/E0015.stderr @@ -0,0 +1,11 @@ +error[E0015]: cannot call non-const fn `create_some` in constants + --> $DIR/E0015.rs:5:25 + | +LL | const FOO: Option<u8> = create_some(); + | ^^^^^^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0015`. diff --git a/src/test/ui/error-codes/E0199.stderr b/src/test/ui/error-codes/E0199.stderr index 99d808c0d4b..68c308b15cc 100644 --- a/src/test/ui/error-codes/E0199.stderr +++ b/src/test/ui/error-codes/E0199.stderr @@ -2,7 +2,7 @@ error[E0199]: implementing the trait `Bar` is not unsafe --> $DIR/E0199.rs:6:1 | LL | unsafe impl Bar for Foo { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove `unsafe` from this trait implementation | diff --git a/src/test/ui/error-codes/E0200.stderr b/src/test/ui/error-codes/E0200.stderr index 1fd86aecee1..c70a2d4f3d1 100644 --- a/src/test/ui/error-codes/E0200.stderr +++ b/src/test/ui/error-codes/E0200.stderr @@ -2,7 +2,7 @@ error[E0200]: the trait `Bar` requires an `unsafe impl` declaration --> $DIR/E0200.rs:5:1 | LL | impl Bar for Foo { } - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = note: the trait `Bar` enforces invariants that the compiler can't check. Review the trait documentation and make sure this implementation upholds those invariants before adding the `unsafe` keyword help: add `unsafe` to this trait implementation diff --git a/src/test/ui/error-codes/E0637.stderr b/src/test/ui/error-codes/E0637.stderr index 35a4b34fb0a..78341735e19 100644 --- a/src/test/ui/error-codes/E0637.stderr +++ b/src/test/ui/error-codes/E0637.stderr @@ -21,6 +21,12 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here | LL | T: Into<&u32>, | ^ explicit lifetime name needed here + | +help: consider introducing a higher-ranked lifetime here with `for<'a>` + --> $DIR/E0637.rs:13:8 + | +LL | T: Into<&u32>, + | ^ error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-13655.rs b/src/test/ui/extern/issue-13655.rs index 6dd1847995f..6dd1847995f 100644 --- a/src/test/ui/issues/issue-13655.rs +++ b/src/test/ui/extern/issue-13655.rs diff --git a/src/test/ui/fmt/ifmt-bad-arg.stderr b/src/test/ui/fmt/ifmt-bad-arg.stderr index a8a2a47fe46..c2619d6df58 100644 --- a/src/test/ui/fmt/ifmt-bad-arg.stderr +++ b/src/test/ui/fmt/ifmt-bad-arg.stderr @@ -170,7 +170,7 @@ LL | format!("foo %s baz", "bar"); | | | help: format specifiers use curly braces: `{}` | - = note: printf formatting not supported; see the documentation for `std::fmt` + = note: printf formatting is not supported; see the documentation for `std::fmt` error: invalid format string: expected `'}'`, found `'t'` --> $DIR/ifmt-bad-arg.rs:75:1 diff --git a/src/test/ui/fmt/issue-89173.rs b/src/test/ui/fmt/issue-89173.rs index 96277d4d0d9..fc99af40859 100644 --- a/src/test/ui/fmt/issue-89173.rs +++ b/src/test/ui/fmt/issue-89173.rs @@ -10,5 +10,5 @@ fn main() { //~| NOTE: argument never used //~| NOTE: argument never used //~| NOTE: format specifiers use curly braces, and you have to use a positional or named parameter for the width - //~| NOTE: printf formatting not supported + //~| NOTE: printf formatting is not supported } diff --git a/src/test/ui/fmt/issue-89173.stderr b/src/test/ui/fmt/issue-89173.stderr index 7b21e0a4fc8..ddeb769eadc 100644 --- a/src/test/ui/fmt/issue-89173.stderr +++ b/src/test/ui/fmt/issue-89173.stderr @@ -12,7 +12,7 @@ note: format specifiers use curly braces, and you have to use a positional or na | LL | print!("%0*x", width, num); | ^^^^ - = note: printf formatting not supported; see the documentation for `std::fmt` + = note: printf formatting is not supported; see the documentation for `std::fmt` error: aborting due to previous error diff --git a/src/test/ui/fn/issue-3044.rs b/src/test/ui/fn/issue-3044.rs index 7c626a01b12..19bee733ec0 100644 --- a/src/test/ui/fn/issue-3044.rs +++ b/src/test/ui/fn/issue-3044.rs @@ -1,6 +1,6 @@ fn main() { let needlesArr: Vec<char> = vec!['a', 'f']; needlesArr.iter().fold(|x, y| { - //~^ ERROR this function takes 2 arguments but 1 argument was supplied + //~^ ERROR this method takes 2 arguments but 1 argument was supplied }); } diff --git a/src/test/ui/fn/issue-3044.stderr b/src/test/ui/fn/issue-3044.stderr index 1232b83c391..2690ad71176 100644 --- a/src/test/ui/fn/issue-3044.stderr +++ b/src/test/ui/fn/issue-3044.stderr @@ -1,4 +1,4 @@ -error[E0061]: this function takes 2 arguments but 1 argument was supplied +error[E0061]: this method takes 2 arguments but 1 argument was supplied --> $DIR/issue-3044.rs:3:23 | LL | needlesArr.iter().fold(|x, y| { diff --git a/src/test/ui/fn/issue-80179.rs b/src/test/ui/fn/issue-80179.rs index fcef6f1b60e..35e39bebb29 100644 --- a/src/test/ui/fn/issue-80179.rs +++ b/src/test/ui/fn/issue-80179.rs @@ -18,9 +18,9 @@ fn returns_fn_ptr() -> _ { fn returns_closure() -> _ { //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] //~| NOTE not allowed in type signatures -//~| HELP consider using an `Fn`, `FnMut`, or `FnOnce` trait bound -//~| NOTE for more information on `Fn` traits and closure types, see -// https://doc.rust-lang.org/book/ch13-01-closures.html +//~| HELP replace with an appropriate return type +//~| SUGGESTION impl Fn() -> i32 +//~| NOTE for more information on `Fn` traits and closure types || 0 } diff --git a/src/test/ui/fn/issue-80179.stderr b/src/test/ui/fn/issue-80179.stderr index 2ca4ae982d9..f5d6c44db75 100644 --- a/src/test/ui/fn/issue-80179.stderr +++ b/src/test/ui/fn/issue-80179.stderr @@ -11,9 +11,11 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/issue-80179.rs:18:25 | LL | fn returns_closure() -> _ { - | ^ not allowed in type signatures + | ^ + | | + | not allowed in type signatures + | help: replace with an appropriate return type: `impl Fn() -> i32` | - = help: consider using an `Fn`, `FnMut`, or `FnOnce` trait bound = note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html error: aborting due to 2 previous errors diff --git a/src/test/ui/fn/suggest-return-closure.rs b/src/test/ui/fn/suggest-return-closure.rs new file mode 100644 index 00000000000..33daa1ea0b4 --- /dev/null +++ b/src/test/ui/fn/suggest-return-closure.rs @@ -0,0 +1,34 @@ +fn fn_once() -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] + //~| NOTE not allowed in type signatures + //~| HELP replace with an appropriate return type + //~| SUGGESTION impl FnOnce() + //~| NOTE for more information on `Fn` traits and closure types + let x = String::new(); + || { + drop(x); + } +} + +fn fn_mut() -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] + //~| NOTE not allowed in type signatures + //~| HELP replace with an appropriate return type + //~| SUGGESTION impl FnMut(char) + //~| NOTE for more information on `Fn` traits and closure types + let x = String::new(); + |c| { + x.push(c); + } +} + +fn fun() -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] + //~| NOTE not allowed in type signatures + //~| HELP replace with an appropriate return type + //~| SUGGESTION impl Fn() -> i32 + //~| NOTE for more information on `Fn` traits and closure types + || 1i32 +} + +fn main() {} diff --git a/src/test/ui/fn/suggest-return-closure.stderr b/src/test/ui/fn/suggest-return-closure.stderr new file mode 100644 index 00000000000..341044469ea --- /dev/null +++ b/src/test/ui/fn/suggest-return-closure.stderr @@ -0,0 +1,36 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/suggest-return-closure.rs:1:17 + | +LL | fn fn_once() -> _ { + | ^ + | | + | not allowed in type signatures + | help: replace with an appropriate return type: `impl FnOnce()` + | + = note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/suggest-return-closure.rs:13:16 + | +LL | fn fn_mut() -> _ { + | ^ + | | + | not allowed in type signatures + | help: replace with an appropriate return type: `impl FnMut(char)` + | + = note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/suggest-return-closure.rs:25:13 + | +LL | fn fun() -> _ { + | ^ + | | + | not allowed in type signatures + | help: replace with an appropriate return type: `impl Fn() -> i32` + | + = note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0121`. diff --git a/src/test/ui/fn/suggest-return-future.rs b/src/test/ui/fn/suggest-return-future.rs new file mode 100644 index 00000000000..750740d9426 --- /dev/null +++ b/src/test/ui/fn/suggest-return-future.rs @@ -0,0 +1,23 @@ +// edition: 2021 + +async fn a() -> i32 { + 0 +} + +fn foo() -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] + //~| NOTE not allowed in type signatures + //~| HELP replace with an appropriate return type + //~| SUGGESTION impl Future<Output = i32> + a() +} + +fn bar() -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] + //~| NOTE not allowed in type signatures + //~| HELP replace with an appropriate return type + //~| SUGGESTION impl Future<Output = i32> + async { a().await } +} + +fn main() {} diff --git a/src/test/ui/fn/suggest-return-future.stderr b/src/test/ui/fn/suggest-return-future.stderr new file mode 100644 index 00000000000..a4c8b5d8c4b --- /dev/null +++ b/src/test/ui/fn/suggest-return-future.stderr @@ -0,0 +1,21 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/suggest-return-future.rs:7:13 + | +LL | fn foo() -> _ { + | ^ + | | + | not allowed in type signatures + | help: replace with an appropriate return type: `impl Future<Output = i32>` + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/suggest-return-future.rs:15:13 + | +LL | fn bar() -> _ { + | ^ + | | + | not allowed in type signatures + | help: replace with an appropriate return type: `impl Future<Output = i32>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0121`. diff --git a/src/test/ui/generator/issue-102645.rs b/src/test/ui/generator/issue-102645.rs index 0589c5a009a..35acd5cd727 100644 --- a/src/test/ui/generator/issue-102645.rs +++ b/src/test/ui/generator/issue-102645.rs @@ -14,7 +14,7 @@ fn main() { a = d; }; Pin::new(&mut b).resume(); - //~^ ERROR this function takes 1 argument but 0 arguments were supplied + //~^ ERROR this method takes 1 argument but 0 arguments were supplied // This type error is required to reproduce the ICE... } diff --git a/src/test/ui/generator/issue-102645.stderr b/src/test/ui/generator/issue-102645.stderr index afb39c9e594..f6d2440295e 100644 --- a/src/test/ui/generator/issue-102645.stderr +++ b/src/test/ui/generator/issue-102645.stderr @@ -1,4 +1,4 @@ -error[E0061]: this function takes 1 argument but 0 arguments were supplied +error[E0061]: this method takes 1 argument but 0 arguments were supplied --> $DIR/issue-102645.rs:16:22 | LL | Pin::new(&mut b).resume(); diff --git a/src/test/ui/generic-associated-types/elided-in-expr-position.stderr b/src/test/ui/generic-associated-types/elided-in-expr-position.stderr index a9996123f23..842b23bd49d 100644 --- a/src/test/ui/generic-associated-types/elided-in-expr-position.stderr +++ b/src/test/ui/generic-associated-types/elided-in-expr-position.stderr @@ -12,7 +12,7 @@ LL | type Assoc<'a> where Self: 'a; help: add missing lifetime argument | LL | fn g(&self) -> Self::Assoc<'_>; - | ~~~~~~~~~ + | ++++ error[E0107]: missing generics for associated type `Trait::Assoc` --> $DIR/elided-in-expr-position.rs:31:26 @@ -28,7 +28,7 @@ LL | type Assoc<'a> where Self: 'a; help: add missing lifetime argument | LL | fn g(&self) -> Self::Assoc<'_> { - | ~~~~~~~~~ + | ++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.stderr b/src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.stderr index 452dfefd1e3..499221637ba 100644 --- a/src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.stderr +++ b/src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.stderr @@ -12,7 +12,7 @@ LL | type Y<'a>; help: add missing lifetime argument | LL | fn foo<'a, T1: X<Y<'a> = T1>>(t : T1) -> T1::Y<'a> { - | ~~~~~ + | ++++ error[E0107]: missing generics for associated type `X::Y` --> $DIR/gat-trait-path-missing-lifetime.rs:8:20 @@ -28,7 +28,7 @@ LL | type Y<'a>; help: add missing lifetime argument | LL | fn foo<'a, T1: X<Y<'a> = T1>>(t : T1) -> T1::Y<'a> { - | ~~~~~ + | ++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/generic-associated-types/issue-71176.stderr b/src/test/ui/generic-associated-types/issue-71176.stderr index 386c97161c8..4b4fe43e8c4 100644 --- a/src/test/ui/generic-associated-types/issue-71176.stderr +++ b/src/test/ui/generic-associated-types/issue-71176.stderr @@ -12,7 +12,7 @@ LL | type A<'a>; help: add missing lifetime argument | LL | inner: Box<dyn Provider<A<'a> = B>>, - | ~~~~~ + | ++++ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/issue-76535.base.stderr b/src/test/ui/generic-associated-types/issue-76535.base.stderr index 088f69b09f7..52c6e3eec60 100644 --- a/src/test/ui/generic-associated-types/issue-76535.base.stderr +++ b/src/test/ui/generic-associated-types/issue-76535.base.stderr @@ -12,7 +12,7 @@ LL | type SubType<'a>: SubTrait where Self: 'a; help: add missing lifetime argument | LL | let sub: Box<dyn SuperTrait<SubType<'a> = SubStruct>> = Box::new(SuperStruct::new(0)); - | ~~~~~~~~~~~ + | ++++ error[E0038]: the trait `SuperTrait` cannot be made into an object --> $DIR/issue-76535.rs:39:14 diff --git a/src/test/ui/generic-associated-types/issue-76535.extended.stderr b/src/test/ui/generic-associated-types/issue-76535.extended.stderr index e79f0a73f5b..369b86d2928 100644 --- a/src/test/ui/generic-associated-types/issue-76535.extended.stderr +++ b/src/test/ui/generic-associated-types/issue-76535.extended.stderr @@ -12,7 +12,7 @@ LL | type SubType<'a>: SubTrait where Self: 'a; help: add missing lifetime argument | LL | let sub: Box<dyn SuperTrait<SubType<'a> = SubStruct>> = Box::new(SuperStruct::new(0)); - | ~~~~~~~~~~~ + | ++++ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/issue-78671.base.stderr b/src/test/ui/generic-associated-types/issue-78671.base.stderr index 514f8d45a15..bad8c1c9dba 100644 --- a/src/test/ui/generic-associated-types/issue-78671.base.stderr +++ b/src/test/ui/generic-associated-types/issue-78671.base.stderr @@ -12,7 +12,7 @@ LL | type Member<T>; help: add missing generic argument | LL | Box::new(Family) as &dyn CollectionFamily<Member<T>=usize> - | ~~~~~~~~~ + | +++ error[E0038]: the trait `CollectionFamily` cannot be made into an object --> $DIR/issue-78671.rs:10:25 diff --git a/src/test/ui/generic-associated-types/issue-78671.extended.stderr b/src/test/ui/generic-associated-types/issue-78671.extended.stderr index 6fa09a4c7e5..1d8a3d410f8 100644 --- a/src/test/ui/generic-associated-types/issue-78671.extended.stderr +++ b/src/test/ui/generic-associated-types/issue-78671.extended.stderr @@ -12,7 +12,7 @@ LL | type Member<T>; help: add missing generic argument | LL | Box::new(Family) as &dyn CollectionFamily<Member<T>=usize> - | ~~~~~~~~~ + | +++ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/issue-79422.base.stderr b/src/test/ui/generic-associated-types/issue-79422.base.stderr index 3c1a29d48b2..f1de77bc3c0 100644 --- a/src/test/ui/generic-associated-types/issue-79422.base.stderr +++ b/src/test/ui/generic-associated-types/issue-79422.base.stderr @@ -12,7 +12,7 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a; help: add missing lifetime argument | LL | as Box<dyn MapLike<u8, u8, VRefCont<'a> = dyn RefCont<'_, u8>>>; - | ~~~~~~~~~~~~ + | ++++ error[E0038]: the trait `MapLike` cannot be made into an object --> $DIR/issue-79422.rs:47:12 diff --git a/src/test/ui/generic-associated-types/issue-79422.extended.stderr b/src/test/ui/generic-associated-types/issue-79422.extended.stderr index 58c921bf09f..d79de0ca627 100644 --- a/src/test/ui/generic-associated-types/issue-79422.extended.stderr +++ b/src/test/ui/generic-associated-types/issue-79422.extended.stderr @@ -12,7 +12,7 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a; help: add missing lifetime argument | LL | as Box<dyn MapLike<u8, u8, VRefCont<'a> = dyn RefCont<'_, u8>>>; - | ~~~~~~~~~~~~ + | ++++ error[E0271]: type mismatch resolving `<BTreeMap<u8, u8> as MapLike<u8, u8>>::VRefCont<'_> == (dyn RefCont<'_, u8> + 'static)` --> $DIR/issue-79422.rs:44:13 diff --git a/src/test/ui/generic-associated-types/issue-79636-1.stderr b/src/test/ui/generic-associated-types/issue-79636-1.stderr index 155477048ca..6e0d2ff4ded 100644 --- a/src/test/ui/generic-associated-types/issue-79636-1.stderr +++ b/src/test/ui/generic-associated-types/issue-79636-1.stderr @@ -12,7 +12,7 @@ LL | type Wrapped<B>; help: add missing generic argument | LL | MInner: Monad<Unwrapped = A, Wrapped<B> = MOuter::Wrapped<A>>, - | ~~~~~~~~~~ + | +++ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/issue-79636-2.stderr b/src/test/ui/generic-associated-types/issue-79636-2.stderr index 6a36bfc37f2..16287323995 100644 --- a/src/test/ui/generic-associated-types/issue-79636-2.stderr +++ b/src/test/ui/generic-associated-types/issue-79636-2.stderr @@ -12,7 +12,7 @@ LL | type Wrapped<A>: SomeTrait; help: add missing generic argument | LL | W: SomeTrait<Wrapped<A> = W>, - | ~~~~~~~~~~ + | +++ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/issue-80433.stderr b/src/test/ui/generic-associated-types/issue-80433.stderr index 20a407dd412..4f4f96a4b92 100644 --- a/src/test/ui/generic-associated-types/issue-80433.stderr +++ b/src/test/ui/generic-associated-types/issue-80433.stderr @@ -12,7 +12,7 @@ LL | type Output<'a>; help: add missing lifetime argument | LL | fn test_simpler<'a>(dst: &'a mut impl TestMut<Output<'a> = &'a mut f32>) - | ~~~~~~~~~~ + | ++++ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/issue-81712-cyclic-traits.stderr b/src/test/ui/generic-associated-types/issue-81712-cyclic-traits.stderr index c8961e28ede..e0fc225f463 100644 --- a/src/test/ui/generic-associated-types/issue-81712-cyclic-traits.stderr +++ b/src/test/ui/generic-associated-types/issue-81712-cyclic-traits.stderr @@ -12,7 +12,7 @@ LL | type DType<T>: D<T, CType = Self>; help: add missing generic argument | LL | type CType: C<DType<T> = Self>; - | ~~~~~~~~ + | +++ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/issue-81862.stderr b/src/test/ui/generic-associated-types/issue-81862.stderr index 9e21c567c73..df30be65ec5 100644 --- a/src/test/ui/generic-associated-types/issue-81862.stderr +++ b/src/test/ui/generic-associated-types/issue-81862.stderr @@ -12,7 +12,7 @@ LL | type Item<'a>; help: add missing lifetime argument | LL | fn next(&mut self) -> Option<Self::Item<'_>>; - | ~~~~~~~~ + | ++++ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/missing_lifetime_args.stderr b/src/test/ui/generic-associated-types/missing_lifetime_args.stderr index 752587c25a7..8f74b12c008 100644 --- a/src/test/ui/generic-associated-types/missing_lifetime_args.stderr +++ b/src/test/ui/generic-associated-types/missing_lifetime_args.stderr @@ -12,7 +12,7 @@ LL | type Y<'a, 'b>; help: add missing lifetime arguments | LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y<'_, '_> = (&'c u32, &'d u32)>>) {} - | ~~~~~~~~~ + | ++++++++ error[E0107]: this struct takes 3 lifetime arguments but 2 lifetime arguments were supplied --> $DIR/missing_lifetime_args.rs:14:26 diff --git a/src/test/ui/generics/generic-type-less-params-with-defaults.stderr b/src/test/ui/generics/generic-type-less-params-with-defaults.stderr index e45a0d9ca77..6450bbd8b43 100644 --- a/src/test/ui/generics/generic-type-less-params-with-defaults.stderr +++ b/src/test/ui/generics/generic-type-less-params-with-defaults.stderr @@ -12,7 +12,7 @@ LL | struct Vec<T, A = Heap>( help: add missing generic argument | LL | let _: Vec<T>; - | ~~~~~~ + | +++ error: aborting due to previous error diff --git a/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr index e45387acaf3..9d859fddf56 100644 --- a/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr +++ b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr @@ -3,6 +3,12 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here | LL | fn should_error<T>() where T : Into<&u32> {} | ^ explicit lifetime name needed here + | +help: consider introducing a higher-ranked lifetime here with `for<'a>` + --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:5:32 + | +LL | fn should_error<T>() where T : Into<&u32> {} + | ^ error[E0106]: missing lifetime specifier --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:9:20 diff --git a/src/test/ui/generics/wrong-number-of-args.stderr b/src/test/ui/generics/wrong-number-of-args.stderr index b48966a1a1e..75e33f680ea 100644 --- a/src/test/ui/generics/wrong-number-of-args.stderr +++ b/src/test/ui/generics/wrong-number-of-args.stderr @@ -251,7 +251,7 @@ LL | struct Ty<A, B>; help: add missing generic arguments | LL | type A = Ty<A, B>; - | ~~~~~~~~ + | ++++++ error[E0107]: this struct takes 2 generic arguments but 1 generic argument was supplied --> $DIR/wrong-number-of-args.rs:30:14 @@ -315,7 +315,7 @@ LL | struct Ty<'a, T>; help: add missing generic argument | LL | type A = Ty<T>; - | ~~~~~ + | +++ error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied --> $DIR/wrong-number-of-args.rs:54:14 @@ -391,7 +391,7 @@ LL | struct Ty<A, B, C = &'static str>; help: add missing generic arguments | LL | type A = Ty<A, B>; - | ~~~~~~~~ + | ++++++ error[E0107]: this struct takes at least 2 generic arguments but 1 generic argument was supplied --> $DIR/wrong-number-of-args.rs:84:14 @@ -483,7 +483,7 @@ LL | trait GenericType<A> { help: add missing generic argument | LL | type D = Box<dyn GenericType<A>>; - | ~~~~~~~~~~~~~~ + | +++ error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied --> $DIR/wrong-number-of-args.rs:133:22 @@ -892,7 +892,7 @@ LL | type A = HashMap; help: add missing generic arguments | LL | type A = HashMap<K, V>; - | ~~~~~~~~~~~~~ + | ++++++ error[E0107]: this struct takes at least 2 generic arguments but 1 generic argument was supplied --> $DIR/wrong-number-of-args.rs:314:18 @@ -954,7 +954,7 @@ LL | type A = Result; help: add missing generic arguments | LL | type A = Result<T, E>; - | ~~~~~~~~~~~~ + | ++++++ error[E0107]: this enum takes 2 generic arguments but 1 generic argument was supplied --> $DIR/wrong-number-of-args.rs:338:18 diff --git a/src/test/ui/higher-rank-trait-bounds/issue-58451.rs b/src/test/ui/higher-rank-trait-bounds/issue-58451.rs index f36d549e476..6006a108c5c 100644 --- a/src/test/ui/higher-rank-trait-bounds/issue-58451.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-58451.rs @@ -9,5 +9,5 @@ where {} fn main() { - f(&[f()]); //~ ERROR this function takes 1 argument + f(&[f()]); //~ ERROR function takes 1 argument } diff --git a/src/test/ui/illegal-sized-bound/mutability-mismatch-arg.fixed b/src/test/ui/illegal-sized-bound/mutability-mismatch-arg.fixed new file mode 100644 index 00000000000..74f3c887f02 --- /dev/null +++ b/src/test/ui/illegal-sized-bound/mutability-mismatch-arg.fixed @@ -0,0 +1,9 @@ +// run-rustfix +fn test(t: &mut dyn Iterator<Item=&u64>) -> u64 { + *t.min().unwrap() //~ ERROR the `min` method cannot be invoked on +} + +fn main() { + let array = [0u64]; + test(&mut array.iter()); +} diff --git a/src/test/ui/illegal-sized-bound/mutability-mismatch-arg.rs b/src/test/ui/illegal-sized-bound/mutability-mismatch-arg.rs new file mode 100644 index 00000000000..3b02c5a5ad1 --- /dev/null +++ b/src/test/ui/illegal-sized-bound/mutability-mismatch-arg.rs @@ -0,0 +1,9 @@ +// run-rustfix +fn test(t: &dyn Iterator<Item=&u64>) -> u64 { + *t.min().unwrap() //~ ERROR the `min` method cannot be invoked on +} + +fn main() { + let array = [0u64]; + test(&mut array.iter()); +} diff --git a/src/test/ui/illegal-sized-bound/mutability-mismatch-arg.stderr b/src/test/ui/illegal-sized-bound/mutability-mismatch-arg.stderr new file mode 100644 index 00000000000..89613bd5c20 --- /dev/null +++ b/src/test/ui/illegal-sized-bound/mutability-mismatch-arg.stderr @@ -0,0 +1,13 @@ +error: the `min` method cannot be invoked on `&dyn Iterator<Item = &u64>` + --> $DIR/mutability-mismatch-arg.rs:3:9 + | +LL | *t.min().unwrap() + | ^^^ + | +help: you need `&mut dyn Iterator<Item = &u64>` instead of `&dyn Iterator<Item = &u64>` + | +LL | fn test(t: &mut dyn Iterator<Item=&u64>) -> u64 { + | +++ + +error: aborting due to previous error + diff --git a/src/test/ui/illegal-sized-bound/mutability-mismatch.rs b/src/test/ui/illegal-sized-bound/mutability-mismatch.rs index deb84f6fe97..01bb3537c2d 100644 --- a/src/test/ui/illegal-sized-bound/mutability-mismatch.rs +++ b/src/test/ui/illegal-sized-bound/mutability-mismatch.rs @@ -4,7 +4,6 @@ pub trait MutTrait { fn function(&mut self) where Self: Sized; - //~^ this has a `Sized` requirement } impl MutTrait for MutType { @@ -17,7 +16,6 @@ pub trait Trait { fn function(&self) where Self: Sized; - //~^ this has a `Sized` requirement } impl Trait for Type { @@ -26,9 +24,9 @@ impl Trait for Type { fn main() { (&MutType as &dyn MutTrait).function(); - //~^ ERROR the `function` method cannot be invoked on a trait object - //~| NOTE you need `&mut dyn MutTrait` instead of `&dyn MutTrait` + //~^ ERROR the `function` method cannot be invoked on `&dyn MutTrait` + //~| HELP you need `&mut dyn MutTrait` instead of `&dyn MutTrait` (&mut Type as &mut dyn Trait).function(); - //~^ ERROR the `function` method cannot be invoked on a trait object - //~| NOTE you need `&dyn Trait` instead of `&mut dyn Trait` + //~^ ERROR the `function` method cannot be invoked on `&mut dyn Trait` + //~| HELP you need `&dyn Trait` instead of `&mut dyn Trait` } diff --git a/src/test/ui/illegal-sized-bound/mutability-mismatch.stderr b/src/test/ui/illegal-sized-bound/mutability-mismatch.stderr index dbbf79a4f1a..2ca571d9b79 100644 --- a/src/test/ui/illegal-sized-bound/mutability-mismatch.stderr +++ b/src/test/ui/illegal-sized-bound/mutability-mismatch.stderr @@ -1,24 +1,18 @@ -error: the `function` method cannot be invoked on a trait object - --> $DIR/mutability-mismatch.rs:28:33 +error: the `function` method cannot be invoked on `&dyn MutTrait` + --> $DIR/mutability-mismatch.rs:26:33 | -LL | Self: Sized; - | ----- this has a `Sized` requirement -... LL | (&MutType as &dyn MutTrait).function(); | ^^^^^^^^ | - = note: you need `&mut dyn MutTrait` instead of `&dyn MutTrait` + = help: you need `&mut dyn MutTrait` instead of `&dyn MutTrait` -error: the `function` method cannot be invoked on a trait object - --> $DIR/mutability-mismatch.rs:31:35 +error: the `function` method cannot be invoked on `&mut dyn Trait` + --> $DIR/mutability-mismatch.rs:29:35 | -LL | Self: Sized; - | ----- this has a `Sized` requirement -... LL | (&mut Type as &mut dyn Trait).function(); | ^^^^^^^^ | - = note: you need `&dyn Trait` instead of `&mut dyn Trait` + = help: you need `&dyn Trait` instead of `&mut dyn Trait` error: aborting due to 2 previous errors diff --git a/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.rs b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.rs index 7249a36f5fe..a93bdb1788f 100644 --- a/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.rs +++ b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.rs @@ -2,5 +2,5 @@ fn f<T: ?Sized, U: ?Sized>(_: impl AsRef<T>, _: impl AsRef<U>) {} fn main() { f::<[u8]>("a", b"a"); - //~^ ERROR: this function takes 2 generic arguments but 1 generic argument was supplied + //~^ ERROR function takes 2 generic arguments but 1 generic argument was supplied } diff --git a/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr b/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr index acf768d5795..db97fc2bdc4 100644 --- a/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr +++ b/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr @@ -13,8 +13,8 @@ note: type in trait | LL | fn foo<A: Debug>(&self, a: &A, b: &impl Debug); | ^^ - = note: expected fn pointer `fn(&(), &B, &impl Debug)` - found fn pointer `fn(&(), &impl Debug, &B)` + = note: expected signature `fn(&(), &B, &impl Debug)` + found signature `fn(&(), &impl Debug, &B)` = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters diff --git a/src/test/ui/impl-trait/in-trait/box-coerce-span-in-default.rs b/src/test/ui/impl-trait/in-trait/box-coerce-span-in-default.rs new file mode 100644 index 00000000000..a4d483dee7a --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/box-coerce-span-in-default.rs @@ -0,0 +1,49 @@ +// check-pass + +#![feature(return_position_impl_trait_in_trait)] +//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete + +struct TestA {} +struct TestB {} + +impl TestTrait for TestA { + type Output = (); +} +impl TestTrait for TestB { + type Output = (); +} + +trait TestTrait { + type Output; +} + +impl<A, B> TestTrait for GreeterOutput<A, B> +where + A: TestTrait<Output = ()>, + B: TestTrait<Output = ()>, +{ + type Output = (); +} + +enum GreeterOutput<A, B> +where + A: TestTrait<Output = ()>, + B: TestTrait<Output = ()>, +{ + SayHello(A), + SayGoodbye(B), +} + +trait Greeter { + fn test_func(&self, func: &str) -> impl TestTrait<Output = ()> { + match func { + "SayHello" => GreeterOutput::SayHello(TestA {}), + "SayGoodbye" => GreeterOutput::SayGoodbye(TestB {}), + _ => GreeterOutput::SayHello(TestA {}), + } + } +} + +fn main() { + println!("Hello, world!"); +} diff --git a/src/test/ui/impl-trait/in-trait/box-coerce-span-in-default.stderr b/src/test/ui/impl-trait/in-trait/box-coerce-span-in-default.stderr new file mode 100644 index 00000000000..d681ecf25e8 --- /dev/null +++ b/src/test/ui/impl-trait/in-trait/box-coerce-span-in-default.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/box-coerce-span-in-default.rs:3:12 + | +LL | #![feature(return_position_impl_trait_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/src/test/ui/impl-trait/in-trait/method-signature-matches.stderr b/src/test/ui/impl-trait/in-trait/method-signature-matches.stderr index 2b32c52c829..4dfd772222e 100644 --- a/src/test/ui/impl-trait/in-trait/method-signature-matches.stderr +++ b/src/test/ui/impl-trait/in-trait/method-signature-matches.stderr @@ -12,8 +12,8 @@ note: type in trait | LL | fn owo(x: ()) -> impl Sized; | ^^ - = note: expected fn pointer `fn(())` - found fn pointer `fn(u8)` + = note: expected signature `fn(())` + found signature `fn(u8)` error[E0053]: method `owo` has an incompatible type for trait --> $DIR/method-signature-matches.rs:20:21 @@ -39,8 +39,8 @@ note: type in trait | LL | async fn owo(x: ()) {} | ^^ - = note: expected fn pointer `fn(()) -> _` - found fn pointer `fn(u8) -> _` + = note: expected signature `fn(()) -> _` + found signature `fn(u8) -> _` error[E0050]: method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0 --> $DIR/method-signature-matches.rs:29:28 @@ -75,8 +75,8 @@ note: type in trait | LL | fn early<'early, T>(x: &'early T) -> impl Sized; | ^^^^^^^^^ - = note: expected fn pointer `fn(&'early T)` - found fn pointer `fn(&())` + = note: expected signature `fn(&'early T)` + found signature `fn(&())` error: aborting due to 5 previous errors diff --git a/src/test/ui/impl-trait/in-trait/signature-mismatch.stderr b/src/test/ui/impl-trait/in-trait/signature-mismatch.stderr index 6663d7faa1e..e105660173b 100644 --- a/src/test/ui/impl-trait/in-trait/signature-mismatch.stderr +++ b/src/test/ui/impl-trait/in-trait/signature-mismatch.stderr @@ -7,8 +7,8 @@ LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>; LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2` | - = note: expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + 'static` - found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2` + = note: expected signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + 'static` + found signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2` = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output diff --git a/src/test/ui/impl-trait/in-trait/specialization-broken.stderr b/src/test/ui/impl-trait/in-trait/specialization-broken.stderr index a30e6346b29..37cfd74498d 100644 --- a/src/test/ui/impl-trait/in-trait/specialization-broken.stderr +++ b/src/test/ui/impl-trait/in-trait/specialization-broken.stderr @@ -15,8 +15,8 @@ note: type in trait | LL | fn bar(&self) -> impl Sized; | ^^^^^^^^^^ - = note: expected fn pointer `fn(&U) -> impl Sized` - found fn pointer `fn(&U) -> U` + = note: expected signature `fn(&U) -> impl Sized` + found signature `fn(&U) -> U` error: aborting due to previous error diff --git a/src/test/ui/impl-trait/issues/issue-92305.stderr b/src/test/ui/impl-trait/issues/issue-92305.stderr index f09c14d3df1..86d7184da7a 100644 --- a/src/test/ui/impl-trait/issues/issue-92305.stderr +++ b/src/test/ui/impl-trait/issues/issue-92305.stderr @@ -7,7 +7,7 @@ LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec> { help: add missing generic argument | LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec<T>> { - | ~~~~~~ + | +++ error: aborting due to previous error diff --git a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr index 3ee26f74a78..c7c6ca44012 100644 --- a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr +++ b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr @@ -18,8 +18,8 @@ LL | fn eq(&self, _other: &(Foo, i32)) -> bool { | expected struct `Bar`, found opaque type | help: change the parameter type to match the trait: `&(a::Bar, i32)` | - = note: expected fn pointer `fn(&a::Bar, &(a::Bar, i32)) -> _` - found fn pointer `fn(&a::Bar, &(a::Foo, i32)) -> _` + = note: expected signature `fn(&a::Bar, &(a::Bar, i32)) -> _` + found signature `fn(&a::Bar, &(a::Foo, i32)) -> _` error: unconstrained opaque type --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:18:16 @@ -41,8 +41,8 @@ LL | fn eq(&self, _other: &(Bar, i32)) -> bool { | expected opaque type, found struct `Bar` | help: change the parameter type to match the trait: `&(b::Foo, i32)` | - = note: expected fn pointer `fn(&b::Bar, &(b::Foo, i32)) -> _` - found fn pointer `fn(&b::Bar, &(b::Bar, i32)) -> _` + = note: expected signature `fn(&b::Bar, &(b::Foo, i32)) -> _` + found signature `fn(&b::Bar, &(b::Bar, i32)) -> _` error: aborting due to 4 previous errors diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.rs b/src/test/ui/impl-trait/static-return-lifetime-infered.rs index f940c1949d0..36ef9ea4443 100644 --- a/src/test/ui/impl-trait/static-return-lifetime-infered.rs +++ b/src/test/ui/impl-trait/static-return-lifetime-infered.rs @@ -6,12 +6,10 @@ impl A { fn iter_values_anon(&self) -> impl Iterator<Item=u32> { self.x.iter().map(|a| a.0) //~^ ERROR: captures lifetime that does not appear in bounds - //~| ERROR: captures lifetime that does not appear in bounds } fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> { self.x.iter().map(|a| a.0) //~^ ERROR: captures lifetime that does not appear in bounds - //~| ERROR: captures lifetime that does not appear in bounds } } diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.stderr b/src/test/ui/impl-trait/static-return-lifetime-infered.stderr index b365bd88454..c451f8e37c4 100644 --- a/src/test/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/src/test/ui/impl-trait/static-return-lifetime-infered.stderr @@ -12,36 +12,10 @@ LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ { | ++++ error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that does not appear in bounds - --> $DIR/static-return-lifetime-infered.rs:7:9 - | -LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> { - | ----- hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30]>` captures the anonymous lifetime defined here -LL | self.x.iter().map(|a| a.0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: to declare that `impl Iterator<Item = u32>` captures `'_`, you can add an explicit `'_` lifetime bound - | -LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ { - | ++++ - -error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that does not appear in bounds - --> $DIR/static-return-lifetime-infered.rs:12:9 - | -LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> { - | -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:12:27: 12:30]>` captures the lifetime `'a` as defined here -LL | self.x.iter().map(|a| a.0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: to declare that `impl Iterator<Item = u32>` captures `'a`, you can add an explicit `'a` lifetime bound - | -LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a { - | ++++ - -error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that does not appear in bounds - --> $DIR/static-return-lifetime-infered.rs:12:9 + --> $DIR/static-return-lifetime-infered.rs:11:9 | LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> { - | -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:12:27: 12:30]>` captures the lifetime `'a` as defined here + | -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:11:27: 11:30]>` captures the lifetime `'a` as defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -50,6 +24,6 @@ help: to declare that `impl Iterator<Item = u32>` captures `'a`, you can add an LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a { | ++++ -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/impl-trait/trait_type.stderr b/src/test/ui/impl-trait/trait_type.stderr index bea24339837..81e4c933e53 100644 --- a/src/test/ui/impl-trait/trait_type.stderr +++ b/src/test/ui/impl-trait/trait_type.stderr @@ -7,8 +7,8 @@ LL | fn fmt(&self, x: &str) -> () { } | types differ in mutability | help: change the parameter type to match the trait: `&mut Formatter<'_>` | - = note: expected fn pointer `fn(&MyType, &mut Formatter<'_>) -> Result<(), std::fmt::Error>` - found fn pointer `fn(&MyType, &str)` + = note: expected signature `fn(&MyType, &mut Formatter<'_>) -> Result<(), std::fmt::Error>` + found signature `fn(&MyType, &str)` error[E0050]: method `fmt` has 1 parameter but the declaration in trait `std::fmt::Display::fmt` has 2 --> $DIR/trait_type.rs:12:11 diff --git a/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs b/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs index 79844dcbdac..c177655c5ac 100644 --- a/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs +++ b/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs @@ -1,5 +1,5 @@ // A test exploiting the bug behind #25860 except with -// implied trait bounds which currently don't exist without `-Zchalk`. +// implied trait bounds which currently don't exist without `-Ztrait-solver=chalk`. use std::marker::PhantomData; struct Foo<'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>) where diff --git a/src/test/ui/issues/issue-11374.stderr b/src/test/ui/issues/issue-11374.stderr index 15b2bbeb7c2..ace77814a3a 100644 --- a/src/test/ui/issues/issue-11374.stderr +++ b/src/test/ui/issues/issue-11374.stderr @@ -6,7 +6,7 @@ LL | c.read_to(v); | | | | | expected `&mut [u8]`, found struct `Vec` | | help: consider mutably borrowing here: `&mut v` - | arguments to this function are incorrect + | arguments to this method are incorrect | = note: expected mutable reference `&mut [u8]` found struct `Vec<_>` diff --git a/src/test/ui/issues/issue-13033.rs b/src/test/ui/issues/issue-13033.rs index 7631831a81a..fdb356e70c5 100644 --- a/src/test/ui/issues/issue-13033.rs +++ b/src/test/ui/issues/issue-13033.rs @@ -7,8 +7,8 @@ struct Baz; impl Foo for Baz { fn bar(&mut self, other: &dyn Foo) {} //~^ ERROR method `bar` has an incompatible type for trait - //~| expected fn pointer `fn(&mut Baz, &mut dyn Foo)` - //~| found fn pointer `fn(&mut Baz, &dyn Foo)` + //~| expected signature `fn(&mut Baz, &mut dyn Foo)` + //~| found signature `fn(&mut Baz, &dyn Foo)` } fn main() {} diff --git a/src/test/ui/issues/issue-13033.stderr b/src/test/ui/issues/issue-13033.stderr index 72e549813e8..db2c1189e1e 100644 --- a/src/test/ui/issues/issue-13033.stderr +++ b/src/test/ui/issues/issue-13033.stderr @@ -12,8 +12,8 @@ note: type in trait | LL | fn bar(&mut self, other: &mut dyn Foo); | ^^^^^^^^^^^^ - = note: expected fn pointer `fn(&mut Baz, &mut dyn Foo)` - found fn pointer `fn(&mut Baz, &dyn Foo)` + = note: expected signature `fn(&mut Baz, &mut dyn Foo)` + found signature `fn(&mut Baz, &dyn Foo)` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-14092.stderr b/src/test/ui/issues/issue-14092.stderr index 132e2b101a5..3a43627e691 100644 --- a/src/test/ui/issues/issue-14092.stderr +++ b/src/test/ui/issues/issue-14092.stderr @@ -7,7 +7,7 @@ LL | fn fn1(0: Box) {} help: add missing generic argument | LL | fn fn1(0: Box<T>) {} - | ~~~~~~ + | +++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-15094.rs b/src/test/ui/issues/issue-15094.rs index 71b75a6e7e0..cb27e2bcfb6 100644 --- a/src/test/ui/issues/issue-15094.rs +++ b/src/test/ui/issues/issue-15094.rs @@ -10,8 +10,8 @@ impl<T: fmt::Debug> ops::FnOnce<(),> for Debuger<T> { type Output = (); fn call_once(self, _args: ()) { //~^ ERROR `call_once` has an incompatible type for trait - //~| expected fn pointer `extern "rust-call" fn - //~| found fn pointer `fn + //~| expected signature `extern "rust-call" fn + //~| found signature `fn println!("{:?}", self.x); } } diff --git a/src/test/ui/issues/issue-15094.stderr b/src/test/ui/issues/issue-15094.stderr index 2dcdaba170a..b7c950892dc 100644 --- a/src/test/ui/issues/issue-15094.stderr +++ b/src/test/ui/issues/issue-15094.stderr @@ -4,8 +4,8 @@ error[E0053]: method `call_once` has an incompatible type for trait LL | fn call_once(self, _args: ()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "rust-call" fn, found "Rust" fn | - = note: expected fn pointer `extern "rust-call" fn(Debuger<_>, ())` - found fn pointer `fn(Debuger<_>, ())` + = note: expected signature `extern "rust-call" fn(Debuger<_>, ())` + found signature `fn(Debuger<_>, ())` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18611.stderr b/src/test/ui/issues/issue-18611.stderr index 22c3470b61e..bd18d46223e 100644 --- a/src/test/ui/issues/issue-18611.stderr +++ b/src/test/ui/issues/issue-18611.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `isize: HasState` is not satisfied - --> $DIR/issue-18611.rs:1:1 + --> $DIR/issue-18611.rs:1:18 | -LL | / fn add_state(op: <isize as HasState>::State) { -LL | | -LL | | } - | |_^ the trait `HasState` is not implemented for `isize` +LL | fn add_state(op: <isize as HasState>::State) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasState` is not implemented for `isize` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20225.stderr b/src/test/ui/issues/issue-20225.stderr index 6f4813ca623..5822160107c 100644 --- a/src/test/ui/issues/issue-20225.stderr +++ b/src/test/ui/issues/issue-20225.stderr @@ -9,8 +9,8 @@ LL | extern "rust-call" fn call(&self, (_,): (T,)) {} | expected `&T`, found type parameter `T` | help: change the parameter type to match the trait: `(&'a T,)` | - = note: expected fn pointer `extern "rust-call" fn(&Foo, (&'a T,))` - found fn pointer `extern "rust-call" fn(&Foo, (T,))` + = note: expected signature `extern "rust-call" fn(&Foo, (&'a T,))` + found signature `extern "rust-call" fn(&Foo, (T,))` error[E0053]: method `call_mut` has an incompatible type for trait --> $DIR/issue-20225.rs:11:51 @@ -23,8 +23,8 @@ LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {} | expected `&T`, found type parameter `T` | help: change the parameter type to match the trait: `(&'a T,)` | - = note: expected fn pointer `extern "rust-call" fn(&mut Foo, (&'a T,))` - found fn pointer `extern "rust-call" fn(&mut Foo, (T,))` + = note: expected signature `extern "rust-call" fn(&mut Foo, (&'a T,))` + found signature `extern "rust-call" fn(&mut Foo, (T,))` error[E0053]: method `call_once` has an incompatible type for trait --> $DIR/issue-20225.rs:18:47 @@ -38,8 +38,8 @@ LL | extern "rust-call" fn call_once(self, (_,): (T,)) {} | expected `&T`, found type parameter `T` | help: change the parameter type to match the trait: `(&'a T,)` | - = note: expected fn pointer `extern "rust-call" fn(Foo, (&'a T,))` - found fn pointer `extern "rust-call" fn(Foo, (T,))` + = note: expected signature `extern "rust-call" fn(Foo, (&'a T,))` + found signature `extern "rust-call" fn(Foo, (T,))` error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-20831-debruijn.stderr b/src/test/ui/issues/issue-20831-debruijn.stderr index ef62dece836..c3af1f6786b 100644 --- a/src/test/ui/issues/issue-20831-debruijn.stderr +++ b/src/test/ui/issues/issue-20831-debruijn.stderr @@ -1,14 +1,8 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/issue-20831-debruijn.rs:28:5 + --> $DIR/issue-20831-debruijn.rs:28:33 | -LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { -LL | | // Not obvious, but there is an implicit lifetime here -------^ -LL | | -LL | | // -... | -LL | | self.sub = t; -LL | | } - | |_____^ +LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the anonymous lifetime defined here... --> $DIR/issue-20831-debruijn.rs:28:58 @@ -21,16 +15,10 @@ note: ...but the lifetime must also be valid for the lifetime `'a` as defined he LL | impl<'a> Publisher<'a> for MyStruct<'a> { | ^^ note: ...so that the types are compatible - --> $DIR/issue-20831-debruijn.rs:28:5 + --> $DIR/issue-20831-debruijn.rs:28:33 | -LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { -LL | | // Not obvious, but there is an implicit lifetime here -------^ -LL | | -LL | | // -... | -LL | | self.sub = t; -LL | | } - | |_____^ +LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected `<MyStruct<'a> as Publisher<'_>>` found `<MyStruct<'_> as Publisher<'_>>` diff --git a/src/test/ui/issues/issue-21332.stderr b/src/test/ui/issues/issue-21332.stderr index d92966da17c..0e1beebf293 100644 --- a/src/test/ui/issues/issue-21332.stderr +++ b/src/test/ui/issues/issue-21332.stderr @@ -7,8 +7,8 @@ LL | fn next(&mut self) -> Result<i32, i32> { Ok(7) } | expected enum `Option`, found enum `Result` | help: change the output type to match the trait: `Option<i32>` | - = note: expected fn pointer `fn(&mut S) -> Option<i32>` - found fn pointer `fn(&mut S) -> Result<i32, i32>` + = note: expected signature `fn(&mut S) -> Option<i32>` + found signature `fn(&mut S) -> Result<i32, i32>` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-23024.stderr b/src/test/ui/issues/issue-23024.stderr index 014eb2897b4..2c325ffccee 100644 --- a/src/test/ui/issues/issue-23024.stderr +++ b/src/test/ui/issues/issue-23024.stderr @@ -16,7 +16,7 @@ LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); help: add missing generic argument | LL | println!("{:?}",(vfnfer[0] as dyn Fn<Args>)(3)); - | ~~~~~~~~ + | ++++++ error[E0191]: the value of the associated type `Output` (from trait `FnOnce`) must be specified --> $DIR/issue-23024.rs:8:39 diff --git a/src/test/ui/issues/issue-25386.rs b/src/test/ui/issues/issue-25386.rs index a76d8a615f6..b26cc77680d 100644 --- a/src/test/ui/issues/issue-25386.rs +++ b/src/test/ui/issues/issue-25386.rs @@ -24,5 +24,4 @@ macro_rules! check_ptr_exist { fn main() { let item = stuff::Item::new(); println!("{}", check_ptr_exist!(item, name)); - //~^ ERROR field `name` of struct `CObj` is private } diff --git a/src/test/ui/issues/issue-25386.stderr b/src/test/ui/issues/issue-25386.stderr index bce269393ee..727b9690829 100644 --- a/src/test/ui/issues/issue-25386.stderr +++ b/src/test/ui/issues/issue-25386.stderr @@ -9,12 +9,6 @@ LL | println!("{}", check_ptr_exist!(item, name)); | = note: this error originates in the macro `check_ptr_exist` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0616]: field `name` of struct `CObj` is private - --> $DIR/issue-25386.rs:26:43 - | -LL | println!("{}", check_ptr_exist!(item, name)); - | ^^^^ private field - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0616`. diff --git a/src/test/ui/issues/issue-25439.stderr b/src/test/ui/issues/issue-25439.stderr index 325c28c15e2..dadae23fdf3 100644 --- a/src/test/ui/issues/issue-25439.stderr +++ b/src/test/ui/issues/issue-25439.stderr @@ -2,12 +2,17 @@ error[E0644]: closure/generator type that references itself --> $DIR/issue-25439.rs:8:9 | LL | fix(|_, x| x); - | ^^^^^^^^ cyclic type of infinite size + | ^^^^^^ cyclic type of infinite size | = note: closures cannot capture themselves or take themselves as argument; this error may be the result of a recent compiler bug-fix, see issue #46062 <https://github.com/rust-lang/rust/issues/46062> for more information +note: required by a bound in `fix` + --> $DIR/issue-25439.rs:3:33 + | +LL | fn fix<F>(f: F) -> i32 where F: Fn(Helper<F>, i32) -> i32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `fix` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-26094.rs b/src/test/ui/issues/issue-26094.rs index df8c2f73910..d3d670aa92a 100644 --- a/src/test/ui/issues/issue-26094.rs +++ b/src/test/ui/issues/issue-26094.rs @@ -8,6 +8,6 @@ fn some_function() {} //~ NOTE defined here fn main() { some_macro!(some_function); - //~^ ERROR this function takes 0 arguments but 1 argument was supplied + //~^ ERROR function takes 0 arguments but 1 argument was supplied //~| NOTE in this expansion of some_macro! } diff --git a/src/test/ui/issues/issue-29723.rs b/src/test/ui/issues/issue-29723.rs index ce91022f093..399e9ba0df7 100644 --- a/src/test/ui/issues/issue-29723.rs +++ b/src/test/ui/issues/issue-29723.rs @@ -1,5 +1,7 @@ // test for https://github.com/rust-lang/rust/issues/29723 +#![feature(if_let_guard)] + fn main() { let s = String::new(); let _s = match 0 { @@ -11,4 +13,10 @@ fn main() { //~^ ERROR use of moved value: `s` } }; + + let s = String::new(); + let _s = match 0 { + 0 if let Some(()) = { drop(s); None } => String::from("oops"), + _ => s //~ ERROR use of moved value: `s` + }; } diff --git a/src/test/ui/issues/issue-29723.stderr b/src/test/ui/issues/issue-29723.stderr index 92ee5cf22b7..044d8a9b5dd 100644 --- a/src/test/ui/issues/issue-29723.stderr +++ b/src/test/ui/issues/issue-29723.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `s` - --> $DIR/issue-29723.rs:10:13 + --> $DIR/issue-29723.rs:12:13 | LL | let s = String::new(); | - move occurs because `s` has type `String`, which does not implement the `Copy` trait @@ -15,6 +15,22 @@ help: consider cloning the value if the performance cost is acceptable LL | 0 if { drop(s.clone()); false } => String::from("oops"), | ++++++++ -error: aborting due to previous error +error[E0382]: use of moved value: `s` + --> $DIR/issue-29723.rs:20:14 + | +LL | let s = String::new(); + | - move occurs because `s` has type `String`, which does not implement the `Copy` trait +LL | let _s = match 0 { +LL | 0 if let Some(()) = { drop(s); None } => String::from("oops"), + | - value moved here +LL | _ => s + | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | 0 if let Some(()) = { drop(s.clone()); None } => String::from("oops"), + | ++++++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/issues/issue-35570.stderr b/src/test/ui/issues/issue-35570.stderr index ebc40f6786f..3dc33729d8f 100644 --- a/src/test/ui/issues/issue-35570.stderr +++ b/src/test/ui/issues/issue-35570.stderr @@ -1,4 +1,10 @@ error[E0277]: the trait bound `for<'a> (): Trait2<'a>` is not satisfied + --> $DIR/issue-35570.rs:8:40 + | +LL | fn _ice(param: Box<dyn for <'a> Trait1<<() as Trait2<'a>>::Ty>>) { + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Trait2<'a>` is not implemented for `()` + +error[E0277]: the trait bound `for<'a> (): Trait2<'a>` is not satisfied --> $DIR/issue-35570.rs:8:1 | LL | / fn _ice(param: Box<dyn for <'a> Trait1<<() as Trait2<'a>>::Ty>>) { @@ -8,12 +14,6 @@ LL | | let _e: (usize, usize) = unsafe{mem::transmute(param)}; LL | | } | |_^ the trait `for<'a> Trait2<'a>` is not implemented for `()` -error[E0277]: the trait bound `for<'a> (): Trait2<'a>` is not satisfied - --> $DIR/issue-35570.rs:8:40 - | -LL | fn _ice(param: Box<dyn for <'a> Trait1<<() as Trait2<'a>>::Ty>>) { - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Trait2<'a>` is not implemented for `()` - error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/issues/issue-37884.stderr b/src/test/ui/issues/issue-37884.stderr index e9f50b41f6a..7ddb36c8e6f 100644 --- a/src/test/ui/issues/issue-37884.stderr +++ b/src/test/ui/issues/issue-37884.stderr @@ -4,8 +4,8 @@ error[E0308]: method not compatible with trait LL | fn next(&'a mut self) -> Option<Self::Item> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | - = note: expected fn pointer `fn(&mut RepeatMut<'a, T>) -> Option<_>` - found fn pointer `fn(&'a mut RepeatMut<'a, T>) -> Option<_>` + = note: expected signature `fn(&mut RepeatMut<'a, T>) -> Option<_>` + found signature `fn(&'a mut RepeatMut<'a, T>) -> Option<_>` note: the anonymous lifetime as defined here... --> $DIR/issue-37884.rs:6:5 | diff --git a/src/test/ui/issues/issue-48364.stderr b/src/test/ui/issues/issue-48364.stderr index da3e62e35dc..60bbfc0c6e2 100644 --- a/src/test/ui/issues/issue-48364.stderr +++ b/src/test/ui/issues/issue-48364.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types LL | b"".starts_with(stringify!(foo)) | ----------- ^^^^^^^^^^^^^^^ expected slice `[u8]`, found `str` | | - | arguments to this function are incorrect + | arguments to this method are incorrect | = note: expected reference `&[u8]` found reference `&'static str` diff --git a/src/test/ui/issues/issue-4935.rs b/src/test/ui/issues/issue-4935.rs index b342bbb1b8e..c95020a0c00 100644 --- a/src/test/ui/issues/issue-4935.rs +++ b/src/test/ui/issues/issue-4935.rs @@ -3,4 +3,4 @@ fn foo(a: usize) {} //~^ defined here fn main() { foo(5, 6) } -//~^ ERROR this function takes 1 argument but 2 arguments were supplied +//~^ ERROR function takes 1 argument but 2 arguments were supplied diff --git a/src/test/ui/issues/issue-86756.stderr b/src/test/ui/issues/issue-86756.stderr index 693cfecedc4..6c5917bdf6e 100644 --- a/src/test/ui/issues/issue-86756.stderr +++ b/src/test/ui/issues/issue-86756.stderr @@ -42,7 +42,7 @@ LL | trait Foo<T, T = T> {} help: add missing generic argument | LL | eq::<dyn, Foo<T>> - | ~~~~~~ + | +++ error: aborting due to 3 previous errors; 1 warning emitted diff --git a/src/test/ui/layout/thin-meta-implies-thin-ptr.rs b/src/test/ui/layout/thin-meta-implies-thin-ptr.rs new file mode 100644 index 00000000000..972579ea8be --- /dev/null +++ b/src/test/ui/layout/thin-meta-implies-thin-ptr.rs @@ -0,0 +1,11 @@ +// check-pass + +#![feature(ptr_metadata)] + +use std::ptr::Thin; + +fn main() {} + +fn foo<T: ?Sized + Thin>(t: *const T) -> *const () { + unsafe { std::mem::transmute(t) } +} diff --git a/src/test/ui/lexer/error-stage.stderr b/src/test/ui/lexer/error-stage.stderr index 697a7c28da1..ecbdb14dc86 100644 --- a/src/test/ui/lexer/error-stage.stderr +++ b/src/test/ui/lexer/error-stage.stderr @@ -49,6 +49,8 @@ error: integer literal is too large | LL | 999340282366920938463463374607431768211455999; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: value exceeds limit of `340282366920938463463374607431768211455` error: aborting due to 8 previous errors diff --git a/src/test/ui/lexer/lex-bad-numeric-literals.rs b/src/test/ui/lexer/lex-bad-numeric-literals.rs index cf8440ca488..56bdc50e40d 100644 --- a/src/test/ui/lexer/lex-bad-numeric-literals.rs +++ b/src/test/ui/lexer/lex-bad-numeric-literals.rs @@ -1,3 +1,5 @@ +// ignore-tidy-linelength + fn main() { 0o1.0; //~ ERROR: octal float literal is not supported 0o2f32; //~ ERROR: octal float literal is not supported @@ -15,6 +17,12 @@ fn main() { //~^ ERROR: integer literal is too large 9900000000000000000000000000999999999999999999999999999999; //~^ ERROR: integer literal is too large + 0b111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110; + //~^ ERROR: integer literal is too large + 0o37777777777777777777777777777777777777777770; + //~^ ERROR: integer literal is too large + 0xffffffffffffffffffffffffffffffff0; + //~^ ERROR: integer literal is too large 0x; //~ ERROR: no valid digits 0xu32; //~ ERROR: no valid digits 0ou32; //~ ERROR: no valid digits diff --git a/src/test/ui/lexer/lex-bad-numeric-literals.stderr b/src/test/ui/lexer/lex-bad-numeric-literals.stderr index f05d6160302..1457541970a 100644 --- a/src/test/ui/lexer/lex-bad-numeric-literals.stderr +++ b/src/test/ui/lexer/lex-bad-numeric-literals.stderr @@ -1,141 +1,169 @@ error: octal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:2:5 + --> $DIR/lex-bad-numeric-literals.rs:4:5 | LL | 0o1.0; | ^^^^^ error: octal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:4:5 + --> $DIR/lex-bad-numeric-literals.rs:6:5 | LL | 0o3.0f32; | ^^^^^ error: octal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:5:5 + --> $DIR/lex-bad-numeric-literals.rs:7:5 | LL | 0o4e4; | ^^^^^ error: octal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:6:5 + --> $DIR/lex-bad-numeric-literals.rs:8:5 | LL | 0o5.0e5; | ^^^^^^^ error: octal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:7:5 + --> $DIR/lex-bad-numeric-literals.rs:9:5 | LL | 0o6e6f32; | ^^^^^ error: octal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:8:5 + --> $DIR/lex-bad-numeric-literals.rs:10:5 | LL | 0o7.0e7f64; | ^^^^^^^ error: hexadecimal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:9:5 + --> $DIR/lex-bad-numeric-literals.rs:11:5 | LL | 0x8.0e+9; | ^^^^^^^^ error: hexadecimal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:10:5 + --> $DIR/lex-bad-numeric-literals.rs:12:5 | LL | 0x9.0e-9; | ^^^^^^^^ error[E0768]: no valid digits found for number - --> $DIR/lex-bad-numeric-literals.rs:11:5 + --> $DIR/lex-bad-numeric-literals.rs:13:5 | LL | 0o; | ^^ error: expected at least one digit in exponent - --> $DIR/lex-bad-numeric-literals.rs:12:5 + --> $DIR/lex-bad-numeric-literals.rs:14:5 | LL | 1e+; | ^^^ error: hexadecimal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:13:5 + --> $DIR/lex-bad-numeric-literals.rs:15:5 | LL | 0x539.0; | ^^^^^^^ error[E0768]: no valid digits found for number - --> $DIR/lex-bad-numeric-literals.rs:18:5 + --> $DIR/lex-bad-numeric-literals.rs:26:5 | LL | 0x; | ^^ error[E0768]: no valid digits found for number - --> $DIR/lex-bad-numeric-literals.rs:19:5 + --> $DIR/lex-bad-numeric-literals.rs:27:5 | LL | 0xu32; | ^^ error[E0768]: no valid digits found for number - --> $DIR/lex-bad-numeric-literals.rs:20:5 + --> $DIR/lex-bad-numeric-literals.rs:28:5 | LL | 0ou32; | ^^ error[E0768]: no valid digits found for number - --> $DIR/lex-bad-numeric-literals.rs:21:5 + --> $DIR/lex-bad-numeric-literals.rs:29:5 | LL | 0bu32; | ^^ error[E0768]: no valid digits found for number - --> $DIR/lex-bad-numeric-literals.rs:22:5 + --> $DIR/lex-bad-numeric-literals.rs:30:5 | LL | 0b; | ^^ error: octal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:24:5 + --> $DIR/lex-bad-numeric-literals.rs:32:5 | LL | 0o123.456; | ^^^^^^^^^ error: binary float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:26:5 + --> $DIR/lex-bad-numeric-literals.rs:34:5 | LL | 0b111.101; | ^^^^^^^^^ error: octal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:3:5 + --> $DIR/lex-bad-numeric-literals.rs:5:5 | LL | 0o2f32; | ^^^^^^ not supported error: integer literal is too large - --> $DIR/lex-bad-numeric-literals.rs:14:5 + --> $DIR/lex-bad-numeric-literals.rs:16:5 | LL | 9900000000000000000000000000999999999999999999999999999999; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: value exceeds limit of `340282366920938463463374607431768211455` error: integer literal is too large - --> $DIR/lex-bad-numeric-literals.rs:16:5 + --> $DIR/lex-bad-numeric-literals.rs:18:5 | LL | 9900000000000000000000000000999999999999999999999999999999; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: value exceeds limit of `340282366920938463463374607431768211455` + +error: integer literal is too large + --> $DIR/lex-bad-numeric-literals.rs:20:5 + | +LL | 0b111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: value exceeds limit of `0b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111` + +error: integer literal is too large + --> $DIR/lex-bad-numeric-literals.rs:22:5 + | +LL | 0o37777777777777777777777777777777777777777770; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: value exceeds limit of `0o3777777777777777777777777777777777777777777` + +error: integer literal is too large + --> $DIR/lex-bad-numeric-literals.rs:24:5 + | +LL | 0xffffffffffffffffffffffffffffffff0; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: value exceeds limit of `0xffffffffffffffffffffffffffffffff` error: octal float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:23:5 + --> $DIR/lex-bad-numeric-literals.rs:31:5 | LL | 0o123f64; | ^^^^^^^^ not supported error: binary float literal is not supported - --> $DIR/lex-bad-numeric-literals.rs:25:5 + --> $DIR/lex-bad-numeric-literals.rs:33:5 | LL | 0b101f64; | ^^^^^^^^ not supported -error: aborting due to 23 previous errors +error: aborting due to 26 previous errors For more information about this error, try `rustc --explain E0768`. diff --git a/src/test/ui/lifetimes/issue-105227.fixed b/src/test/ui/lifetimes/issue-105227.fixed new file mode 100644 index 00000000000..f6ed9c82e91 --- /dev/null +++ b/src/test/ui/lifetimes/issue-105227.fixed @@ -0,0 +1,26 @@ +// Regression test for issue #105227. + +// run-rustfix +#![allow(warnings)] +fn chars0<'a>(v :(&'a str, &'a str)) -> impl Iterator<Item = char> + 'a { +//~^ HELP to declare that `impl Iterator<Item = char>` captures `'_`, you can introduce a named lifetime parameter `'a` + v.0.chars().chain(v.1.chars()) + //~^ ERROR hidden type for `impl Iterator<Item = char>` captures lifetime that does not appear in bounds +} + +fn chars1<'a>(v0 : &'a str, v1 : &'a str) -> impl Iterator<Item = char> + 'a { +//~^ HELP to declare that `impl Iterator<Item = char>` captures `'_`, you can introduce a named lifetime parameter `'a` + v0.chars().chain(v1.chars()) + //~^ ERROR hidden type for `impl Iterator<Item = char>` captures lifetime that does not appear in bound +} + +fn chars2<'b>(v0 : &'b str, v1 : &'b str, v2 : &'b str) -> +//~^ HELP to declare that `impl Iterator<Item = char>` captures `'_`, you can use the named lifetime parameter `'b` + (impl Iterator<Item = char> + 'b , &'b str) +{ + (v0.chars().chain(v1.chars()), v2) + //~^ ERROR hidden type for `impl Iterator<Item = char>` captures lifetime that does not appear in bound +} + +fn main() { +} diff --git a/src/test/ui/lifetimes/issue-105227.rs b/src/test/ui/lifetimes/issue-105227.rs new file mode 100644 index 00000000000..6427a50bb87 --- /dev/null +++ b/src/test/ui/lifetimes/issue-105227.rs @@ -0,0 +1,26 @@ +// Regression test for issue #105227. + +// run-rustfix +#![allow(warnings)] +fn chars0(v :(& str, &str)) -> impl Iterator<Item = char> { +//~^ HELP to declare that `impl Iterator<Item = char>` captures `'_`, you can introduce a named lifetime parameter `'a` + v.0.chars().chain(v.1.chars()) + //~^ ERROR hidden type for `impl Iterator<Item = char>` captures lifetime that does not appear in bounds +} + +fn chars1(v0 : & str, v1 : &str) -> impl Iterator<Item = char> { +//~^ HELP to declare that `impl Iterator<Item = char>` captures `'_`, you can introduce a named lifetime parameter `'a` + v0.chars().chain(v1.chars()) + //~^ ERROR hidden type for `impl Iterator<Item = char>` captures lifetime that does not appear in bound +} + +fn chars2<'b>(v0 : &str, v1 : &'_ str, v2 : &'b str) -> +//~^ HELP to declare that `impl Iterator<Item = char>` captures `'_`, you can use the named lifetime parameter `'b` + (impl Iterator<Item = char>, &'b str) +{ + (v0.chars().chain(v1.chars()), v2) + //~^ ERROR hidden type for `impl Iterator<Item = char>` captures lifetime that does not appear in bound +} + +fn main() { +} diff --git a/src/test/ui/lifetimes/issue-105227.stderr b/src/test/ui/lifetimes/issue-105227.stderr new file mode 100644 index 00000000000..d2114593735 --- /dev/null +++ b/src/test/ui/lifetimes/issue-105227.stderr @@ -0,0 +1,47 @@ +error[E0700]: hidden type for `impl Iterator<Item = char>` captures lifetime that does not appear in bounds + --> $DIR/issue-105227.rs:7:5 + | +LL | fn chars0(v :(& str, &str)) -> impl Iterator<Item = char> { + | ----- hidden type `std::iter::Chain<Chars<'_>, Chars<'_>>` captures the anonymous lifetime defined here +LL | +LL | v.0.chars().chain(v.1.chars()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: to declare that `impl Iterator<Item = char>` captures `'_`, you can introduce a named lifetime parameter `'a` + | +LL | fn chars0<'a>(v :(&'a str, &'a str)) -> impl Iterator<Item = char> + 'a { + | ++++ ++ ++ ++++ + +error[E0700]: hidden type for `impl Iterator<Item = char>` captures lifetime that does not appear in bounds + --> $DIR/issue-105227.rs:13:5 + | +LL | fn chars1(v0 : & str, v1 : &str) -> impl Iterator<Item = char> { + | ----- hidden type `std::iter::Chain<Chars<'_>, Chars<'_>>` captures the anonymous lifetime defined here +LL | +LL | v0.chars().chain(v1.chars()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: to declare that `impl Iterator<Item = char>` captures `'_`, you can introduce a named lifetime parameter `'a` + | +LL | fn chars1<'a>(v0 : &'a str, v1 : &'a str) -> impl Iterator<Item = char> + 'a { + | ++++ ++ ++ ++++ + +error[E0700]: hidden type for `impl Iterator<Item = char>` captures lifetime that does not appear in bounds + --> $DIR/issue-105227.rs:21:5 + | +LL | fn chars2<'b>(v0 : &str, v1 : &'_ str, v2 : &'b str) -> + | ---- hidden type `std::iter::Chain<Chars<'_>, Chars<'_>>` captures the anonymous lifetime defined here +... +LL | (v0.chars().chain(v1.chars()), v2) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: to declare that `impl Iterator<Item = char>` captures `'_`, you can use the named lifetime parameter `'b` + | +LL ~ fn chars2<'b>(v0 : &'b str, v1 : &'b str, v2 : &'b str) -> +LL | +LL ~ (impl Iterator<Item = char> + 'b , &'b str) + | + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/lifetimes/issue-26638.rs b/src/test/ui/lifetimes/issue-26638.rs index 000ab6492bb..4bec3b3415b 100644 --- a/src/test/ui/lifetimes/issue-26638.rs +++ b/src/test/ui/lifetimes/issue-26638.rs @@ -5,7 +5,7 @@ fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next() fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } //~^ ERROR missing lifetime specifier [E0106] //~| ERROR mismatched types -//~| ERROR this function takes 1 argument but 0 arguments were supplied +//~| ERROR function takes 1 argument but 0 arguments were supplied fn parse_type_3() -> &str { unimplemented!() } //~^ ERROR missing lifetime specifier [E0106] diff --git a/src/test/ui/lifetimes/lifetime-mismatch-between-trait-and-impl.stderr b/src/test/ui/lifetimes/lifetime-mismatch-between-trait-and-impl.stderr index 3040a8512ce..9c61d5a0c25 100644 --- a/src/test/ui/lifetimes/lifetime-mismatch-between-trait-and-impl.stderr +++ b/src/test/ui/lifetimes/lifetime-mismatch-between-trait-and-impl.stderr @@ -7,8 +7,8 @@ LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32; LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 i32, &'1 i32) -> &'1 i32` | - = note: expected `fn(&'1 i32, &'a i32) -> &'a i32` - found `fn(&'1 i32, &'1 i32) -> &'1 i32` + = note: expected signature `fn(&'1 i32, &'a i32) -> &'a i32` + found signature `fn(&'1 i32, &'1 i32) -> &'1 i32` = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output diff --git a/src/test/ui/lifetimes/missing-lifetime-in-alias.stderr b/src/test/ui/lifetimes/missing-lifetime-in-alias.stderr index 428b8f14b6f..20159e14407 100644 --- a/src/test/ui/lifetimes/missing-lifetime-in-alias.stderr +++ b/src/test/ui/lifetimes/missing-lifetime-in-alias.stderr @@ -39,7 +39,7 @@ LL | type Bar<'b> help: add missing lifetime argument | LL | type C<'a, 'b> = <A<'a> as Trait>::Bar<'a>; - | ~~~~~~~ + | ++++ error: aborting due to 3 previous errors diff --git a/src/test/ui/macros/format-foreign.stderr b/src/test/ui/macros/format-foreign.stderr index ff5236dc949..7971c2ab2b9 100644 --- a/src/test/ui/macros/format-foreign.stderr +++ b/src/test/ui/macros/format-foreign.stderr @@ -8,7 +8,7 @@ LL | println!("%.*3$s %s!\n", "Hello,", "World", 4); | | argument never used | multiple missing formatting specifiers | - = note: printf formatting not supported; see the documentation for `std::fmt` + = note: printf formatting is not supported; see the documentation for `std::fmt` help: format specifiers use curly braces | LL | println!("{:.2$} {}!\n", "Hello,", "World", 4); @@ -22,7 +22,7 @@ LL | println!("%1$*2$.*3$f", 123.456); | | | help: format specifiers use curly braces: `{0:1$.2$}` | - = note: printf formatting not supported; see the documentation for `std::fmt` + = note: printf formatting is not supported; see the documentation for `std::fmt` error: multiple unused formatting arguments --> $DIR/format-foreign.rs:6:7 @@ -37,7 +37,7 @@ LL | | "###, "Hello,", "World", 4); | |____| argument never used | multiple missing formatting specifiers | - = note: printf formatting not supported; see the documentation for `std::fmt` + = note: printf formatting is not supported; see the documentation for `std::fmt` help: format specifiers use curly braces | LL ~ println!(r###"{:.2$} @@ -60,7 +60,7 @@ LL | println!("Hi there, $NAME.", NAME="Tim"); | | | help: format specifiers use curly braces: `{NAME}` | - = note: shell formatting not supported; see the documentation for `std::fmt` + = note: shell formatting is not supported; see the documentation for `std::fmt` error: multiple unused formatting arguments --> $DIR/format-foreign.rs:15:32 @@ -72,7 +72,7 @@ LL | println!("$1 $0 $$ $NAME", 1, 2, NAME=3); | | argument never used | multiple missing formatting specifiers | - = note: shell formatting not supported; see the documentation for `std::fmt` + = note: shell formatting is not supported; see the documentation for `std::fmt` help: format specifiers use curly braces | LL | println!("{1} {0} $$ {NAME}", 1, 2, NAME=3); diff --git a/src/test/ui/macros/format-unused-lables.stderr b/src/test/ui/macros/format-unused-lables.stderr index 7423c7b7c8b..fad87fa2aee 100644 --- a/src/test/ui/macros/format-unused-lables.stderr +++ b/src/test/ui/macros/format-unused-lables.stderr @@ -44,7 +44,7 @@ LL | "things" LL | , UNUSED="args"); | ^^^^^^ named argument never used | - = note: shell formatting not supported; see the documentation for `std::fmt` + = note: shell formatting is not supported; see the documentation for `std::fmt` error: aborting due to 4 previous errors diff --git a/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.stderr b/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.stderr index 8d70faa494d..8807279c27f 100644 --- a/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.stderr +++ b/src/test/ui/macros/issue-104769-concat_bytes-invalid-literal.stderr @@ -11,6 +11,8 @@ error: integer literal is too large | LL | concat_bytes!(888888888888888888888888888888888888888); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: value exceeds limit of `340282366920938463463374607431768211455` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-10536.rs b/src/test/ui/macros/issue-10536.rs index f536d8f940a..f536d8f940a 100644 --- a/src/test/ui/issues/issue-10536.rs +++ b/src/test/ui/macros/issue-10536.rs diff --git a/src/test/ui/issues/issue-10536.stderr b/src/test/ui/macros/issue-10536.stderr index cc048445871..cc048445871 100644 --- a/src/test/ui/issues/issue-10536.stderr +++ b/src/test/ui/macros/issue-10536.stderr diff --git a/src/test/ui/macros/issue-92267.stderr b/src/test/ui/macros/issue-92267.stderr index d2d66c81198..5359f68cd55 100644 --- a/src/test/ui/macros/issue-92267.stderr +++ b/src/test/ui/macros/issue-92267.stderr @@ -10,7 +10,7 @@ note: format specifiers use curly braces, and the conversion specifier ` | LL | pub fn main() { println!("🦀%%%", 0) } | ^^ - = note: printf formatting not supported; see the documentation for `std::fmt` + = note: printf formatting is not supported; see the documentation for `std::fmt` error: aborting due to previous error diff --git a/src/test/ui/methods/issues/issue-61525.stderr b/src/test/ui/methods/issues/issue-61525.stderr index aec968d7c44..3e73b950a14 100644 --- a/src/test/ui/methods/issues/issue-61525.stderr +++ b/src/test/ui/methods/issues/issue-61525.stderr @@ -23,7 +23,7 @@ error[E0308]: mismatched types LL | 1.query::<dyn ToString>("") | --------------------- ^^ expected trait object `dyn ToString`, found `&str` | | - | arguments to this function are incorrect + | arguments to this method are incorrect | = note: expected trait object `dyn ToString` found reference `&'static str` diff --git a/src/test/ui/methods/method-call-err-msg.rs b/src/test/ui/methods/method-call-err-msg.rs index d53ef445afc..4807a956aa2 100644 --- a/src/test/ui/methods/method-call-err-msg.rs +++ b/src/test/ui/methods/method-call-err-msg.rs @@ -10,13 +10,13 @@ impl Foo { fn main() { let x = Foo; - x.zero(0) //~ ERROR this function takes 0 arguments but 1 argument was supplied - .one() //~ ERROR this function takes 1 argument but 0 arguments were supplied - .two(0); //~ ERROR this function takes 2 arguments but 1 argument was supplied + x.zero(0) //~ ERROR this method takes 0 arguments but 1 argument was supplied + .one() //~ ERROR this method takes 1 argument but 0 arguments were supplied + .two(0); //~ ERROR this method takes 2 arguments but 1 argument was supplied let y = Foo; y.zero() .take() //~ ERROR not an iterator .one(0); - y.three::<usize>(); //~ ERROR this function takes 3 arguments but 0 arguments were supplied + y.three::<usize>(); //~ ERROR this method takes 3 arguments but 0 arguments were supplied } diff --git a/src/test/ui/methods/method-call-err-msg.stderr b/src/test/ui/methods/method-call-err-msg.stderr index 3f4e647491e..81269b73b9a 100644 --- a/src/test/ui/methods/method-call-err-msg.stderr +++ b/src/test/ui/methods/method-call-err-msg.stderr @@ -1,4 +1,4 @@ -error[E0061]: this function takes 0 arguments but 1 argument was supplied +error[E0061]: this method takes 0 arguments but 1 argument was supplied --> $DIR/method-call-err-msg.rs:13:7 | LL | x.zero(0) @@ -14,7 +14,7 @@ help: remove the extra argument LL | x.zero() | ~~ -error[E0061]: this function takes 1 argument but 0 arguments were supplied +error[E0061]: this method takes 1 argument but 0 arguments were supplied --> $DIR/method-call-err-msg.rs:14:7 | LL | .one() @@ -30,7 +30,7 @@ help: provide the argument LL | .one(/* isize */) | ~~~~~~~~~~~~~ -error[E0061]: this function takes 2 arguments but 1 argument was supplied +error[E0061]: this method takes 2 arguments but 1 argument was supplied --> $DIR/method-call-err-msg.rs:15:7 | LL | .two(0); @@ -67,7 +67,7 @@ note: the trait `Iterator` must be implemented = note: the following trait defines an item `take`, perhaps you need to implement it: candidate #1: `Iterator` -error[E0061]: this function takes 3 arguments but 0 arguments were supplied +error[E0061]: this method takes 3 arguments but 0 arguments were supplied --> $DIR/method-call-err-msg.rs:21:7 | LL | y.three::<usize>(); diff --git a/src/test/ui/mismatched_types/E0053.stderr b/src/test/ui/mismatched_types/E0053.stderr index 54b41926451..154f2fcbee0 100644 --- a/src/test/ui/mismatched_types/E0053.stderr +++ b/src/test/ui/mismatched_types/E0053.stderr @@ -12,8 +12,8 @@ note: type in trait | LL | fn foo(x: u16); | ^^^ - = note: expected fn pointer `fn(u16)` - found fn pointer `fn(i16)` + = note: expected signature `fn(u16)` + found signature `fn(i16)` error[E0053]: method `bar` has an incompatible type for trait --> $DIR/E0053.rs:11:12 @@ -29,8 +29,8 @@ note: type in trait | LL | fn bar(&self); | ^^^^^ - = note: expected fn pointer `fn(&Bar)` - found fn pointer `fn(&mut Bar)` + = note: expected signature `fn(&Bar)` + found signature `fn(&mut Bar)` error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/issue-74918-missing-lifetime.stderr b/src/test/ui/mismatched_types/issue-74918-missing-lifetime.stderr index b75c7a99fdd..9ddea162944 100644 --- a/src/test/ui/mismatched_types/issue-74918-missing-lifetime.stderr +++ b/src/test/ui/mismatched_types/issue-74918-missing-lifetime.stderr @@ -18,8 +18,8 @@ LL | fn next(&mut self) -> Option<IteratorChunk<T, S>> { | = note: expected `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'static, T, S>>` | - = note: expected `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'static, T, S>>` - found `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'1, T, S>>` + = note: expected signature `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'static, T, S>>` + found signature `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'1, T, S>>` = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output diff --git a/src/test/ui/mismatched_types/issue-75361-mismatched-impl.stderr b/src/test/ui/mismatched_types/issue-75361-mismatched-impl.stderr index 2a2c23c9421..88416ba4bb6 100644 --- a/src/test/ui/mismatched_types/issue-75361-mismatched-impl.stderr +++ b/src/test/ui/mismatched_types/issue-75361-mismatched-impl.stderr @@ -7,8 +7,8 @@ LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType>>; LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType> + '_> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + '1)>` | - = note: expected `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + 'static)>` - found `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + '1)>` + = note: expected signature `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + 'static)>` + found signature `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + '1)>` help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` --> $DIR/issue-75361-mismatched-impl.rs:12:55 | diff --git a/src/test/ui/mismatched_types/overloaded-calls-bad.rs b/src/test/ui/mismatched_types/overloaded-calls-bad.rs index 232cd2ba88c..5b1804d825d 100644 --- a/src/test/ui/mismatched_types/overloaded-calls-bad.rs +++ b/src/test/ui/mismatched_types/overloaded-calls-bad.rs @@ -33,9 +33,9 @@ fn main() { let ans = s("what"); //~^ ERROR mismatched types let ans = s(); - //~^ ERROR this function takes 1 argument but 0 arguments were supplied + //~^ ERROR function takes 1 argument but 0 arguments were supplied let ans = s("burma", "shave"); - //~^ ERROR this function takes 1 argument but 2 arguments were supplied + //~^ ERROR function takes 1 argument but 2 arguments were supplied F(""); //~^ ERROR mismatched types diff --git a/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr b/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr index 6b2ba53daa0..6e7bf5eb46d 100644 --- a/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr +++ b/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr @@ -12,8 +12,8 @@ note: type in trait | LL | fn foo(x: u16); | ^^^ - = note: expected fn pointer `fn(u16)` - found fn pointer `fn(i16)` + = note: expected signature `fn(u16)` + found signature `fn(i16)` error[E0053]: method `bar` has an incompatible type for trait --> $DIR/trait-impl-fn-incompatibility.rs:10:28 @@ -29,8 +29,8 @@ note: type in trait | LL | fn bar(&mut self, bar: &mut Bar); | ^^^^^^^^ - = note: expected fn pointer `fn(&mut Bar, &mut Bar)` - found fn pointer `fn(&mut Bar, &Bar)` + = note: expected signature `fn(&mut Bar, &mut Bar)` + found signature `fn(&mut Bar, &Bar)` error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/issue-24535-allow-mutable-borrow-in-match-guard.rs b/src/test/ui/nll/issue-24535-allow-mutable-borrow-in-match-guard.rs index 7253d35ed2d..ccfc8937fd7 100644 --- a/src/test/ui/nll/issue-24535-allow-mutable-borrow-in-match-guard.rs +++ b/src/test/ui/nll/issue-24535-allow-mutable-borrow-in-match-guard.rs @@ -5,6 +5,8 @@ // See further discussion on rust-lang/rust#24535, // rust-lang/rfcs#1006, and rust-lang/rfcs#107 +#![feature(if_let_guard)] + fn main() { rust_issue_24535(); rfcs_issue_1006_1(); @@ -23,6 +25,12 @@ fn rust_issue_24535() { 3 if compare(&a, &mut 3) => (), _ => panic!("nope"), } + + match a { + 0 => panic!("nope"), + 3 if let true = compare(&a, &mut 3) => (), + _ => panic!("nope"), + } } fn rfcs_issue_1006_1() { diff --git a/src/test/ui/nll/issue-27282-move-match-input-into-guard.rs b/src/test/ui/nll/issue-27282-move-match-input-into-guard.rs index 4109c10e2e4..85feda5824b 100644 --- a/src/test/ui/nll/issue-27282-move-match-input-into-guard.rs +++ b/src/test/ui/nll/issue-27282-move-match-input-into-guard.rs @@ -7,6 +7,8 @@ // reaches the panic code when executed, despite the compiler warning // about that match arm being unreachable. +#![feature(if_let_guard)] + fn main() { let b = &mut true; match b { @@ -17,4 +19,16 @@ fn main() { &mut true => { println!("You might think we should get here"); }, _ => panic!("surely we could never get here, since rustc warns it is unreachable."), } + + let b = &mut true; + match b { + //~^ ERROR use of moved value: `b` [E0382] + &mut false => {} + _ if let Some(()) = { + (|| { let bar = b; *bar = false; })(); + None + } => {} + &mut true => {} + _ => {} + } } diff --git a/src/test/ui/nll/issue-27282-move-match-input-into-guard.stderr b/src/test/ui/nll/issue-27282-move-match-input-into-guard.stderr index 9be1a927999..ae797800457 100644 --- a/src/test/ui/nll/issue-27282-move-match-input-into-guard.stderr +++ b/src/test/ui/nll/issue-27282-move-match-input-into-guard.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `b` - --> $DIR/issue-27282-move-match-input-into-guard.rs:12:5 + --> $DIR/issue-27282-move-match-input-into-guard.rs:14:5 | LL | let b = &mut true; | - move occurs because `b` has type `&mut bool`, which does not implement the `Copy` trait @@ -11,6 +11,19 @@ LL | _ if { (|| { let bar = b; *bar = false; })(); | | | value moved into closure here -error: aborting due to previous error +error[E0382]: use of moved value: `b` + --> $DIR/issue-27282-move-match-input-into-guard.rs:24:5 + | +LL | let b = &mut true; + | - move occurs because `b` has type `&mut bool`, which does not implement the `Copy` trait +LL | match b { + | ^^^^^^^ value used here after move +... +LL | (|| { let bar = b; *bar = false; })(); + | -- - variable moved due to use in closure + | | + | value moved into closure here + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/nll/issue-27282-move-ref-mut-into-guard.rs b/src/test/ui/nll/issue-27282-move-ref-mut-into-guard.rs index afa0ba780de..833ca8afd61 100644 --- a/src/test/ui/nll/issue-27282-move-ref-mut-into-guard.rs +++ b/src/test/ui/nll/issue-27282-move-ref-mut-into-guard.rs @@ -2,6 +2,8 @@ // mutable borrows in match guards by hiding the mutable borrow in a // guard behind a move (of the ref mut pattern id) within a closure. +#![feature(if_let_guard)] + fn main() { match Some(&4) { None => {}, @@ -10,4 +12,12 @@ fn main() { //~^ ERROR cannot move out of `foo` in pattern guard [E0507] Some(s) => std::process::exit(*s), } + + match Some(&4) { + None => {}, + ref mut foo + if let Some(()) = { (|| { let bar = foo; bar.take() })(); None } => {}, + //~^ ERROR cannot move out of `foo` in pattern guard [E0507] + Some(s) => std::process::exit(*s), + } } diff --git a/src/test/ui/nll/issue-27282-move-ref-mut-into-guard.stderr b/src/test/ui/nll/issue-27282-move-ref-mut-into-guard.stderr index a0d32616f83..45119018d4e 100644 --- a/src/test/ui/nll/issue-27282-move-ref-mut-into-guard.stderr +++ b/src/test/ui/nll/issue-27282-move-ref-mut-into-guard.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/issue-27282-move-ref-mut-into-guard.rs:9:19 + --> $DIR/issue-27282-move-ref-mut-into-guard.rs:11:19 | LL | if { (|| { let bar = foo; bar.take() })(); false } => {}, | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait @@ -8,6 +8,16 @@ LL | if { (|| { let bar = foo; bar.take() })(); false } => {}, | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -error: aborting due to previous error +error[E0507]: cannot move out of `foo` in pattern guard + --> $DIR/issue-27282-move-ref-mut-into-guard.rs:19:34 + | +LL | if let Some(()) = { (|| { let bar = foo; bar.take() })(); None } => {}, + | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait + | | + | move out of `foo` occurs here + | + = note: variables bound in patterns cannot be moved from until after the end of the pattern guard + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/nll/issue-27282-mutation-in-guard.rs b/src/test/ui/nll/issue-27282-mutation-in-guard.rs index 395c7d214d0..4f41fc23fc3 100644 --- a/src/test/ui/nll/issue-27282-mutation-in-guard.rs +++ b/src/test/ui/nll/issue-27282-mutation-in-guard.rs @@ -1,3 +1,5 @@ +#![feature(if_let_guard)] + fn main() { match Some(&4) { None => {}, @@ -10,4 +12,15 @@ fn main() { Some(ref _s) => println!("Note this arm is bogus; the `Some` became `None` in the guard."), _ => println!("Here is some supposedly unreachable code."), } + + match Some(&4) { + None => {}, + ref mut foo + if let Some(()) = { + (|| { let bar = foo; bar.take() })(); + //~^ ERROR cannot move out of `foo` in pattern guard + None + } => {}, + Some(_) => {}, + } } diff --git a/src/test/ui/nll/issue-27282-mutation-in-guard.stderr b/src/test/ui/nll/issue-27282-mutation-in-guard.stderr index c4ce7e62fda..1ba696593af 100644 --- a/src/test/ui/nll/issue-27282-mutation-in-guard.stderr +++ b/src/test/ui/nll/issue-27282-mutation-in-guard.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/issue-27282-mutation-in-guard.rs:6:18 + --> $DIR/issue-27282-mutation-in-guard.rs:8:18 | LL | (|| { let bar = foo; bar.take() })(); | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait @@ -8,6 +8,16 @@ LL | (|| { let bar = foo; bar.take() })(); | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -error: aborting due to previous error +error[E0507]: cannot move out of `foo` in pattern guard + --> $DIR/issue-27282-mutation-in-guard.rs:20:18 + | +LL | (|| { let bar = foo; bar.take() })(); + | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait + | | + | move out of `foo` occurs here + | + = note: variables bound in patterns cannot be moved from until after the end of the pattern guard + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/nll/issue-27282-reborrow-ref-mut-in-guard.rs b/src/test/ui/nll/issue-27282-reborrow-ref-mut-in-guard.rs index 82d8b9e9ed9..ac06b2b0102 100644 --- a/src/test/ui/nll/issue-27282-reborrow-ref-mut-in-guard.rs +++ b/src/test/ui/nll/issue-27282-reborrow-ref-mut-in-guard.rs @@ -3,7 +3,9 @@ // It reborrows instead of moving the `ref mut` pattern borrow. This // means that our conservative check for mutation in guards will // reject it. But I want to make sure that we continue to reject it -// (under NLL) even when that conservaive check goes away. +// (under NLL) even when that conservative check goes away. + +#![feature(if_let_guard)] fn main() { let mut b = &mut true; @@ -15,4 +17,14 @@ fn main() { &mut true => { println!("You might think we should get here"); }, _ => panic!("surely we could never get here, since rustc warns it is unreachable."), } + + let mut b = &mut true; + match b { + &mut false => {}, + ref mut r if let Some(()) = { (|| { let bar = &mut *r; **bar = false; })(); + //~^ ERROR cannot borrow `r` as mutable, as it is immutable for the pattern guard + None } => { &mut *r; }, + &mut true => {}, + _ => {}, + } } diff --git a/src/test/ui/nll/issue-27282-reborrow-ref-mut-in-guard.stderr b/src/test/ui/nll/issue-27282-reborrow-ref-mut-in-guard.stderr index 48433432de1..5eb7a25bf9f 100644 --- a/src/test/ui/nll/issue-27282-reborrow-ref-mut-in-guard.stderr +++ b/src/test/ui/nll/issue-27282-reborrow-ref-mut-in-guard.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `r` as mutable, as it is immutable for the pattern guard - --> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:12:25 + --> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:14:25 | LL | ref mut r if { (|| { let bar = &mut *r; **bar = false; })(); | ^^ -- mutable borrow occurs due to use of `r` in closure @@ -8,6 +8,16 @@ LL | ref mut r if { (|| { let bar = &mut *r; **bar = false; })(); | = note: variables bound in patterns are immutable until the end of the pattern guard -error: aborting due to previous error +error[E0596]: cannot borrow `r` as mutable, as it is immutable for the pattern guard + --> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:24:40 + | +LL | ref mut r if let Some(()) = { (|| { let bar = &mut *r; **bar = false; })(); + | ^^ -- mutable borrow occurs due to use of `r` in closure + | | + | cannot borrow as mutable + | + = note: variables bound in patterns are immutable until the end of the pattern guard + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-54189.rs b/src/test/ui/nll/issue-54189.rs index 70aecc384ef..70aecc384ef 100644 --- a/src/test/ui/issues/issue-54189.rs +++ b/src/test/ui/nll/issue-54189.rs diff --git a/src/test/ui/issues/issue-54189.stderr b/src/test/ui/nll/issue-54189.stderr index 4787abd49d1..4787abd49d1 100644 --- a/src/test/ui/issues/issue-54189.stderr +++ b/src/test/ui/nll/issue-54189.stderr diff --git a/src/test/ui/nll/match-cfg-fake-edges.rs b/src/test/ui/nll/match-cfg-fake-edges.rs index 252f7f8ba07..1afc7931a6b 100644 --- a/src/test/ui/nll/match-cfg-fake-edges.rs +++ b/src/test/ui/nll/match-cfg-fake-edges.rs @@ -1,6 +1,8 @@ // Test that we have enough false edges to avoid exposing the exact matching // algorithm in borrow checking. +#![feature(if_let_guard)] + fn guard_always_precedes_arm(y: i32) { let mut x; // x should always be initialized, as the only way to reach the arm is @@ -9,6 +11,12 @@ fn guard_always_precedes_arm(y: i32) { 0 | 2 if { x = 2; true } => x, _ => 2, }; + + let mut x; + match y { + 0 | 2 if let Some(()) = { x = 2; Some(()) } => x, + _ => 2, + }; } fn guard_may_be_skipped(y: i32) { @@ -23,6 +31,16 @@ fn guard_may_be_skipped(y: i32) { } => 2, _ => 3, }; + + let x; + match y { + _ if let Some(()) = { x = 2; Some(()) } => 1, + _ if let Some(()) = { + x; //~ ERROR E0381 + None + } => 2, + _ => 3, + }; } fn guard_may_be_taken(y: bool) { @@ -37,6 +55,16 @@ fn guard_may_be_taken(y: bool) { } false => 3, }; + + let x = String::new(); + match y { + false if let Some(()) = { drop(x); Some(()) } => 1, + true => { + x; //~ ERROR use of moved value: `x` + 2 + } + false => 3, + }; } fn main() {} diff --git a/src/test/ui/nll/match-cfg-fake-edges.stderr b/src/test/ui/nll/match-cfg-fake-edges.stderr index f72ed3af718..a6261345cea 100644 --- a/src/test/ui/nll/match-cfg-fake-edges.stderr +++ b/src/test/ui/nll/match-cfg-fake-edges.stderr @@ -1,5 +1,5 @@ error[E0381]: used binding `x` isn't initialized - --> $DIR/match-cfg-fake-edges.rs:21:13 + --> $DIR/match-cfg-fake-edges.rs:29:13 | LL | let x; | - binding declared here but left uninitialized @@ -15,8 +15,25 @@ help: consider assigning a value LL | let x = 0; | +++ +error[E0381]: used binding `x` isn't initialized + --> $DIR/match-cfg-fake-edges.rs:39:13 + | +LL | let x; + | - binding declared here but left uninitialized +LL | match y { +LL | _ if let Some(()) = { x = 2; Some(()) } => 1, + | ----- binding initialized here in some conditions +LL | _ if let Some(()) = { +LL | x; + | ^ `x` used here but it isn't initialized + | +help: consider assigning a value + | +LL | let x = 0; + | +++ + error[E0382]: use of moved value: `x` - --> $DIR/match-cfg-fake-edges.rs:35:13 + --> $DIR/match-cfg-fake-edges.rs:53:13 | LL | let x = String::new(); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait @@ -32,7 +49,24 @@ help: consider cloning the value if the performance cost is acceptable LL | false if { drop(x.clone()); true } => 1, | ++++++++ -error: aborting due to 2 previous errors +error[E0382]: use of moved value: `x` + --> $DIR/match-cfg-fake-edges.rs:63:13 + | +LL | let x = String::new(); + | - move occurs because `x` has type `String`, which does not implement the `Copy` trait +LL | match y { +LL | false if let Some(()) = { drop(x); Some(()) } => 1, + | - value moved here +LL | true => { +LL | x; + | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | false if let Some(()) = { drop(x.clone()); Some(()) } => 1, + | ++++++++ + +error: aborting due to 4 previous errors Some errors have detailed explanations: E0381, E0382. For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/nll/match-guards-always-borrow.rs b/src/test/ui/nll/match-guards-always-borrow.rs index 87dba187ba2..ff63cc09273 100644 --- a/src/test/ui/nll/match-guards-always-borrow.rs +++ b/src/test/ui/nll/match-guards-always-borrow.rs @@ -1,3 +1,5 @@ +#![feature(if_let_guard)] + // Here is arielb1's basic example from rust-lang/rust#27282 // that AST borrowck is flummoxed by: @@ -10,6 +12,15 @@ fn should_reject_destructive_mutate_in_guard() { false } => { }, Some(s) => std::process::exit(*s), } + + match Some(&4) { + None => {}, + ref mut foo if let Some(()) = { + (|| { let bar = foo; bar.take() })(); + //~^ ERROR cannot move out of `foo` in pattern guard [E0507] + None } => { }, + Some(s) => std::process::exit(*s), + } } // Here below is a case that needs to keep working: we only use the @@ -18,7 +29,13 @@ fn should_reject_destructive_mutate_in_guard() { fn allow_mutate_in_arm_body() { match Some(&4) { None => {}, - ref mut foo if foo.is_some() && false => { foo.take(); () } + ref mut foo if foo.is_some() => { foo.take(); () } + Some(s) => std::process::exit(*s), + } + + match Some(&4) { + None => {}, + ref mut foo if let Some(_) = foo => { foo.take(); () } Some(s) => std::process::exit(*s), } } @@ -29,7 +46,13 @@ fn allow_mutate_in_arm_body() { fn allow_move_into_arm_body() { match Some(&4) { None => {}, - mut foo if foo.is_some() && false => { foo.take(); () } + mut foo if foo.is_some() => { foo.unwrap(); () } + Some(s) => std::process::exit(*s), + } + + match Some(&4) { + None => {}, + mut foo if let Some(_) = foo => { foo.unwrap(); () } Some(s) => std::process::exit(*s), } } diff --git a/src/test/ui/nll/match-guards-always-borrow.stderr b/src/test/ui/nll/match-guards-always-borrow.stderr index c0fb5f65382..fa01d3a6fd1 100644 --- a/src/test/ui/nll/match-guards-always-borrow.stderr +++ b/src/test/ui/nll/match-guards-always-borrow.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/match-guards-always-borrow.rs:8:14 + --> $DIR/match-guards-always-borrow.rs:10:14 | LL | (|| { let bar = foo; bar.take() })(); | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait @@ -8,6 +8,16 @@ LL | (|| { let bar = foo; bar.take() })(); | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -error: aborting due to previous error +error[E0507]: cannot move out of `foo` in pattern guard + --> $DIR/match-guards-always-borrow.rs:19:14 + | +LL | (|| { let bar = foo; bar.take() })(); + | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait + | | + | move out of `foo` occurs here + | + = note: variables bound in patterns cannot be moved from until after the end of the pattern guard + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/nll/match-guards-partially-borrow.rs b/src/test/ui/nll/match-guards-partially-borrow.rs index 81ae19ebf8a..3a9e1654b1c 100644 --- a/src/test/ui/nll/match-guards-partially-borrow.rs +++ b/src/test/ui/nll/match-guards-partially-borrow.rs @@ -5,7 +5,9 @@ // Test that we don't allow mutating the value being matched on in a way that // changes which patterns it matches, until we have chosen an arm. -fn ok_mutation_in_guard(mut q: i32) { +#![feature(if_let_guard)] + +fn ok_mutation_in_if_guard(mut q: i32) { match q { // OK, mutation doesn't change which patterns g matches _ if { q = 1; false } => (), @@ -13,7 +15,15 @@ fn ok_mutation_in_guard(mut q: i32) { } } -fn ok_mutation_in_guard2(mut u: bool) { +fn ok_mutation_in_if_let_guard(mut q: i32) { + match q { + // OK, mutation doesn't change which patterns g matches + _ if let Some(()) = { q = 1; None } => (), + _ => (), + } +} + +fn ok_mutation_in_if_guard2(mut u: bool) { // OK value of u is unused before modification match u { _ => (), @@ -25,7 +35,19 @@ fn ok_mutation_in_guard2(mut u: bool) { } } -fn ok_mutation_in_guard4(mut w: (&mut bool,)) { +fn ok_mutation_in_if_let_guard2(mut u: bool) { + // OK value of u is unused before modification + match u { + _ => (), + _ if let Some(()) = { + u = true; + None + } => (), + x => (), + } +} + +fn ok_mutation_in_if_guard4(mut w: (&mut bool,)) { // OK value of u is unused before modification match w { _ => (), @@ -37,7 +59,19 @@ fn ok_mutation_in_guard4(mut w: (&mut bool,)) { } } -fn ok_indirect_mutation_in_guard(mut p: &bool) { +fn ok_mutation_in_if_let_guard4(mut w: (&mut bool,)) { + // OK value of u is unused before modification + match w { + _ => (), + _ if let Some(()) = { + *w.0 = true; + None + } => (), + x => (), + } +} + +fn ok_indirect_mutation_in_if_guard(mut p: &bool) { match *p { // OK, mutation doesn't change which patterns s matches _ if { @@ -48,7 +82,18 @@ fn ok_indirect_mutation_in_guard(mut p: &bool) { } } -fn mutation_invalidates_pattern_in_guard(mut q: bool) { +fn ok_indirect_mutation_in_if_let_guard(mut p: &bool) { + match *p { + // OK, mutation doesn't change which patterns s matches + _ if let Some(()) = { + p = &true; + None + } => (), + _ => (), + } +} + +fn mutation_invalidates_pattern_in_if_guard(mut q: bool) { match q { // q doesn't match the pattern with the guard by the end of the guard. false if { @@ -59,7 +104,18 @@ fn mutation_invalidates_pattern_in_guard(mut q: bool) { } } -fn mutation_invalidates_previous_pattern_in_guard(mut r: bool) { +fn mutation_invalidates_pattern_in_if_let_guard(mut q: bool) { + match q { + // q doesn't match the pattern with the guard by the end of the guard. + false if let Some(()) = { + q = true; //~ ERROR + Some(()) + } => (), + _ => (), + } +} + +fn mutation_invalidates_previous_pattern_in_if_guard(mut r: bool) { match r { // r matches a previous pattern by the end of the guard. true => (), @@ -71,7 +127,19 @@ fn mutation_invalidates_previous_pattern_in_guard(mut r: bool) { } } -fn match_on_borrowed_early_end(mut s: bool) { +fn mutation_invalidates_previous_pattern_in_if_let_guard(mut r: bool) { + match r { + // r matches a previous pattern by the end of the guard. + true => (), + _ if let Some(()) = { + r = true; //~ ERROR + Some(()) + } => (), + _ => (), + } +} + +fn match_on_borrowed_early_end_if_guard(mut s: bool) { let h = &mut s; // OK value of s is unused before modification. match s { @@ -84,7 +152,20 @@ fn match_on_borrowed_early_end(mut s: bool) { } } -fn bad_mutation_in_guard(mut t: bool) { +fn match_on_borrowed_early_end_if_let_guard(mut s: bool) { + let h = &mut s; + // OK value of s is unused before modification. + match s { + _ if let Some(()) = { + *h = !*h; + None + } => (), + true => (), + false => (), + } +} + +fn bad_mutation_in_if_guard(mut t: bool) { match t { true => (), false if { @@ -95,7 +176,18 @@ fn bad_mutation_in_guard(mut t: bool) { } } -fn bad_mutation_in_guard2(mut x: Option<Option<&i32>>) { +fn bad_mutation_in_if_let_guard(mut t: bool) { + match t { + true => (), + false if let Some(()) = { + t = true; //~ ERROR + None + } => (), + false => (), + } +} + +fn bad_mutation_in_if_guard2(mut x: Option<Option<&i32>>) { // Check that nested patterns are checked. match x { None => (), @@ -111,7 +203,23 @@ fn bad_mutation_in_guard2(mut x: Option<Option<&i32>>) { } } -fn bad_mutation_in_guard3(mut t: bool) { +fn bad_mutation_in_if_let_guard2(mut x: Option<Option<&i32>>) { + // Check that nested patterns are checked. + match x { + None => (), + Some(None) => (), + _ if let Some(()) = { + match x { + Some(ref mut r) => *r = None, //~ ERROR + _ => return, + }; + None + } => (), + Some(Some(r)) => println!("{}", r), + } +} + +fn bad_mutation_in_if_guard3(mut t: bool) { match t { s if { t = !t; //~ ERROR @@ -121,7 +229,17 @@ fn bad_mutation_in_guard3(mut t: bool) { } } -fn bad_indirect_mutation_in_guard(mut y: &bool) { +fn bad_mutation_in_if_let_guard3(mut t: bool) { + match t { + s if let Some(()) = { + t = !t; //~ ERROR + None + } => (), // What value should `s` have in the arm? + _ => (), + } +} + +fn bad_indirect_mutation_in_if_guard(mut y: &bool) { match *y { true => (), false if { @@ -132,7 +250,18 @@ fn bad_indirect_mutation_in_guard(mut y: &bool) { } } -fn bad_indirect_mutation_in_guard2(mut z: &bool) { +fn bad_indirect_mutation_in_if_let_guard(mut y: &bool) { + match *y { + true => (), + false if let Some(()) = { + y = &true; //~ ERROR + None + } => (), + false => (), + } +} + +fn bad_indirect_mutation_in_if_guard2(mut z: &bool) { match z { &true => (), &false if { @@ -143,8 +272,19 @@ fn bad_indirect_mutation_in_guard2(mut z: &bool) { } } -fn bad_indirect_mutation_in_guard3(mut a: &bool) { - // Same as bad_indirect_mutation_in_guard2, but using match ergonomics +fn bad_indirect_mutation_in_if_let_guard2(mut z: &bool) { + match z { + &true => (), + &false if let Some(()) = { + z = &true; //~ ERROR + None + } => (), + &false => (), + } +} + +fn bad_indirect_mutation_in_if_guard3(mut a: &bool) { + // Same as bad_indirect_mutation_in_if_guard2, but using match ergonomics match a { true => (), false if { @@ -155,7 +295,19 @@ fn bad_indirect_mutation_in_guard3(mut a: &bool) { } } -fn bad_indirect_mutation_in_guard4(mut b: &bool) { +fn bad_indirect_mutation_in_if_let_guard3(mut a: &bool) { + // Same as bad_indirect_mutation_in_if_guard2, but using match ergonomics + match a { + true => (), + false if let Some(()) = { + a = &true; //~ ERROR + None + } => (), + false => (), + } +} + +fn bad_indirect_mutation_in_if_guard4(mut b: &bool) { match b { &_ => (), &_ if { @@ -166,4 +318,15 @@ fn bad_indirect_mutation_in_guard4(mut b: &bool) { } } +fn bad_indirect_mutation_in_if_let_guard4(mut b: &bool) { + match b { + &_ => (), + &_ if let Some(()) = { + b = &true; //~ ERROR + None + } => (), + &b => (), + } +} + fn main() {} diff --git a/src/test/ui/nll/match-guards-partially-borrow.stderr b/src/test/ui/nll/match-guards-partially-borrow.stderr index 48e3a7c6993..60b8dee71a8 100644 --- a/src/test/ui/nll/match-guards-partially-borrow.stderr +++ b/src/test/ui/nll/match-guards-partially-borrow.stderr @@ -1,5 +1,5 @@ error[E0510]: cannot assign `q` in match guard - --> $DIR/match-guards-partially-borrow.rs:55:13 + --> $DIR/match-guards-partially-borrow.rs:100:13 | LL | match q { | - value is immutable in match guard @@ -7,8 +7,26 @@ LL | match q { LL | q = true; | ^^^^^^^^ cannot assign +error[E0510]: cannot assign `q` in match guard + --> $DIR/match-guards-partially-borrow.rs:111:13 + | +LL | match q { + | - value is immutable in match guard +... +LL | q = true; + | ^^^^^^^^ cannot assign + +error[E0510]: cannot assign `r` in match guard + --> $DIR/match-guards-partially-borrow.rs:123:13 + | +LL | match r { + | - value is immutable in match guard +... +LL | r = true; + | ^^^^^^^^ cannot assign + error[E0510]: cannot assign `r` in match guard - --> $DIR/match-guards-partially-borrow.rs:67:13 + --> $DIR/match-guards-partially-borrow.rs:135:13 | LL | match r { | - value is immutable in match guard @@ -17,7 +35,16 @@ LL | r = true; | ^^^^^^^^ cannot assign error[E0510]: cannot assign `t` in match guard - --> $DIR/match-guards-partially-borrow.rs:91:13 + --> $DIR/match-guards-partially-borrow.rs:172:13 + | +LL | match t { + | - value is immutable in match guard +... +LL | t = true; + | ^^^^^^^^ cannot assign + +error[E0510]: cannot assign `t` in match guard + --> $DIR/match-guards-partially-borrow.rs:183:13 | LL | match t { | - value is immutable in match guard @@ -26,7 +53,16 @@ LL | t = true; | ^^^^^^^^ cannot assign error[E0510]: cannot mutably borrow `x.0` in match guard - --> $DIR/match-guards-partially-borrow.rs:105:22 + --> $DIR/match-guards-partially-borrow.rs:197:22 + | +LL | match x { + | - value is immutable in match guard +... +LL | Some(ref mut r) => *r = None, + | ^^^^^^^^^ cannot mutably borrow + +error[E0510]: cannot mutably borrow `x.0` in match guard + --> $DIR/match-guards-partially-borrow.rs:213:22 | LL | match x { | - value is immutable in match guard @@ -35,7 +71,7 @@ LL | Some(ref mut r) => *r = None, | ^^^^^^^^^ cannot mutably borrow error[E0506]: cannot assign to `t` because it is borrowed - --> $DIR/match-guards-partially-borrow.rs:117:13 + --> $DIR/match-guards-partially-borrow.rs:225:13 | LL | s if { | - borrow of `t` occurs here @@ -45,8 +81,28 @@ LL | false LL | } => (), // What value should `s` have in the arm? | - borrow later used here +error[E0506]: cannot assign to `t` because it is borrowed + --> $DIR/match-guards-partially-borrow.rs:235:13 + | +LL | s if let Some(()) = { + | - borrow of `t` occurs here +LL | t = !t; + | ^^^^^^ assignment to borrowed `t` occurs here +LL | None +LL | } => (), // What value should `s` have in the arm? + | - borrow later used here + +error[E0510]: cannot assign `y` in match guard + --> $DIR/match-guards-partially-borrow.rs:246:13 + | +LL | match *y { + | -- value is immutable in match guard +... +LL | y = &true; + | ^^^^^^^^^ cannot assign + error[E0510]: cannot assign `y` in match guard - --> $DIR/match-guards-partially-borrow.rs:128:13 + --> $DIR/match-guards-partially-borrow.rs:257:13 | LL | match *y { | -- value is immutable in match guard @@ -55,7 +111,16 @@ LL | y = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `z` in match guard - --> $DIR/match-guards-partially-borrow.rs:139:13 + --> $DIR/match-guards-partially-borrow.rs:268:13 + | +LL | match z { + | - value is immutable in match guard +... +LL | z = &true; + | ^^^^^^^^^ cannot assign + +error[E0510]: cannot assign `z` in match guard + --> $DIR/match-guards-partially-borrow.rs:279:13 | LL | match z { | - value is immutable in match guard @@ -64,7 +129,16 @@ LL | z = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `a` in match guard - --> $DIR/match-guards-partially-borrow.rs:151:13 + --> $DIR/match-guards-partially-borrow.rs:291:13 + | +LL | match a { + | - value is immutable in match guard +... +LL | a = &true; + | ^^^^^^^^^ cannot assign + +error[E0510]: cannot assign `a` in match guard + --> $DIR/match-guards-partially-borrow.rs:303:13 | LL | match a { | - value is immutable in match guard @@ -73,7 +147,16 @@ LL | a = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `b` in match guard - --> $DIR/match-guards-partially-borrow.rs:162:13 + --> $DIR/match-guards-partially-borrow.rs:314:13 + | +LL | match b { + | - value is immutable in match guard +... +LL | b = &true; + | ^^^^^^^^^ cannot assign + +error[E0510]: cannot assign `b` in match guard + --> $DIR/match-guards-partially-borrow.rs:325:13 | LL | match b { | - value is immutable in match guard @@ -81,7 +164,7 @@ LL | match b { LL | b = &true; | ^^^^^^^^^ cannot assign -error: aborting due to 9 previous errors +error: aborting due to 18 previous errors Some errors have detailed explanations: E0506, E0510. For more information about an error, try `rustc --explain E0506`. diff --git a/src/test/ui/nll/normalization-bounds-error.stderr b/src/test/ui/nll/normalization-bounds-error.stderr index 6abe53127c3..0fc3670d6c5 100644 --- a/src/test/ui/nll/normalization-bounds-error.stderr +++ b/src/test/ui/nll/normalization-bounds-error.stderr @@ -1,8 +1,8 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'d` due to conflicting requirements - --> $DIR/normalization-bounds-error.rs:12:1 + --> $DIR/normalization-bounds-error.rs:12:31 | LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'d` as defined here... --> $DIR/normalization-bounds-error.rs:12:14 @@ -15,10 +15,10 @@ note: ...but the lifetime must also be valid for the lifetime `'a` as defined he LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {} | ^^ note: ...so that the types are compatible - --> $DIR/normalization-bounds-error.rs:12:1 + --> $DIR/normalization-bounds-error.rs:12:31 | LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected `Visitor<'d>` found `Visitor<'_>` diff --git a/src/test/ui/not-enough-arguments.rs b/src/test/ui/not-enough-arguments.rs index 42476255188..4a2ea5e44c7 100644 --- a/src/test/ui/not-enough-arguments.rs +++ b/src/test/ui/not-enough-arguments.rs @@ -25,7 +25,7 @@ fn bar( fn main() { foo(1, 2, 3); - //~^ ERROR this function takes 4 arguments but 3 + //~^ ERROR function takes 4 arguments but 3 bar(1, 2, 3); - //~^ ERROR this function takes 6 arguments but 3 + //~^ ERROR function takes 6 arguments but 3 } diff --git a/src/test/ui/parser/int-literal-too-large-span.stderr b/src/test/ui/parser/int-literal-too-large-span.stderr index 7cae85fc9fe..49d6aa5eff8 100644 --- a/src/test/ui/parser/int-literal-too-large-span.stderr +++ b/src/test/ui/parser/int-literal-too-large-span.stderr @@ -3,6 +3,8 @@ error: integer literal is too large | LL | 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: value exceeds limit of `340282366920938463463374607431768211455` error: aborting due to previous error diff --git a/src/test/ui/parser/issues/issue-5544-a.stderr b/src/test/ui/parser/issues/issue-5544-a.stderr index de579c3c134..6e68c75850a 100644 --- a/src/test/ui/parser/issues/issue-5544-a.stderr +++ b/src/test/ui/parser/issues/issue-5544-a.stderr @@ -3,6 +3,8 @@ error: integer literal is too large | LL | let __isize = 340282366920938463463374607431768211456; // 2^128 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: value exceeds limit of `340282366920938463463374607431768211455` error: aborting due to previous error diff --git a/src/test/ui/parser/issues/issue-5544-b.stderr b/src/test/ui/parser/issues/issue-5544-b.stderr index 7df212dedfe..5d0e76d5d94 100644 --- a/src/test/ui/parser/issues/issue-5544-b.stderr +++ b/src/test/ui/parser/issues/issue-5544-b.stderr @@ -3,6 +3,8 @@ error: integer literal is too large | LL | let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: value exceeds limit of `0xffffffffffffffffffffffffffffffff` error: aborting due to previous error diff --git a/src/test/ui/parser/nested-bad-turbofish.rs b/src/test/ui/parser/nested-bad-turbofish.rs new file mode 100644 index 00000000000..02099fde212 --- /dev/null +++ b/src/test/ui/parser/nested-bad-turbofish.rs @@ -0,0 +1,3 @@ +fn main() { + foo<<S as T>::V>(); //~ ERROR +} diff --git a/src/test/ui/parser/nested-bad-turbofish.stderr b/src/test/ui/parser/nested-bad-turbofish.stderr new file mode 100644 index 00000000000..d82fa80e594 --- /dev/null +++ b/src/test/ui/parser/nested-bad-turbofish.stderr @@ -0,0 +1,11 @@ +error: comparison operators cannot be chained + --> $DIR/nested-bad-turbofish.rs:2:16 + | +LL | foo<<S as T>::V>(); + | ^ ^ + | + = help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + = help: or use `(...)` if you meant to specify fn arguments + +error: aborting due to previous error + diff --git a/src/test/ui/privacy/private-field-ty-err.rs b/src/test/ui/privacy/private-field-ty-err.rs new file mode 100644 index 00000000000..10db6069567 --- /dev/null +++ b/src/test/ui/privacy/private-field-ty-err.rs @@ -0,0 +1,20 @@ +fn main() { + let x = foo::Foo::default(); + if x.len { + //~^ ERROR field `len` of struct `Foo` is private + println!("foo"); + } +} + +mod foo { + #[derive(Default)] + pub struct Foo { + len: String, + } + + impl Foo { + pub fn len(&self) -> usize { + 42 + } + } +} diff --git a/src/test/ui/privacy/private-field-ty-err.stderr b/src/test/ui/privacy/private-field-ty-err.stderr new file mode 100644 index 00000000000..e583a25fd8f --- /dev/null +++ b/src/test/ui/privacy/private-field-ty-err.stderr @@ -0,0 +1,14 @@ +error[E0616]: field `len` of struct `Foo` is private + --> $DIR/private-field-ty-err.rs:3:10 + | +LL | if x.len { + | ^^^ private field + | +help: a method `len` also exists, call it with parentheses + | +LL | if x.len() { + | ++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0616`. diff --git a/src/test/ui/process/process-panic-after-fork.rs b/src/test/ui/process/process-panic-after-fork.rs index 6d4d2492225..da268312173 100644 --- a/src/test/ui/process/process-panic-after-fork.rs +++ b/src/test/ui/process/process-panic-after-fork.rs @@ -84,42 +84,47 @@ fn expect_aborted(status: ExitStatus) { #[cfg(target_os = "android")] { - // Android signals an abort() call with SIGSEGV at address 0xdeadbaad - // See e.g. https://groups.google.com/g/android-ndk/c/laW1CJc7Icc - assert!(signal == libc::SIGSEGV); - - // Additional checks performed: - // 1. Find last tombstone (similar to coredump but in text format) from the - // same executable (path) as we are (must be because of usage of fork): - // This ensures that we look into the correct tombstone. - // 2. Cause of crash is a SIGSEGV with address 0xdeadbaad. - // 3. libc::abort call is in one of top two functions on callstack. - // The last two steps distinguish between a normal SIGSEGV and one caused - // by libc::abort. - - let this_exe = std::env::current_exe().unwrap().into_os_string().into_string().unwrap(); - let exe_string = format!(">>> {this_exe} <<<"); - let tombstone = (0..100) - .map(|n| format!("/data/tombstones/tombstone_{n:02}")) - .filter(|f| std::path::Path::new(&f).exists()) - .map(|f| std::fs::read_to_string(&f).expect("Cannot read tombstone file")) - .filter(|f| f.contains(&exe_string)) - .last() - .expect("no tombstone found"); - - println!("Content of tombstone:\n{tombstone}"); - - assert!( - tombstone.contains("signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad") - ); - let abort_on_top = tombstone - .lines() - .skip_while(|l| !l.contains("backtrace:")) - .skip(1) - .take_while(|l| l.starts_with(" #")) - .take(2) - .any(|f| f.contains("/system/lib/libc.so (abort")); - assert!(abort_on_top); + assert!(signal == libc::SIGABRT || signal == libc::SIGSEGV); + + if signal == libc::SIGSEGV { + // Pre-KitKat versions of Android signal an abort() with SIGSEGV at address 0xdeadbaad + // See e.g. https://groups.google.com/g/android-ndk/c/laW1CJc7Icc + // + // This behavior was changed in KitKat to send a standard SIGABRT signal. + // See: https://r.android.com/60341 + // + // Additional checks performed: + // 1. Find last tombstone (similar to coredump but in text format) from the + // same executable (path) as we are (must be because of usage of fork): + // This ensures that we look into the correct tombstone. + // 2. Cause of crash is a SIGSEGV with address 0xdeadbaad. + // 3. libc::abort call is in one of top two functions on callstack. + // The last two steps distinguish between a normal SIGSEGV and one caused + // by libc::abort. + + let this_exe = std::env::current_exe().unwrap().into_os_string().into_string().unwrap(); + let exe_string = format!(">>> {this_exe} <<<"); + let tombstone = (0..100) + .map(|n| format!("/data/tombstones/tombstone_{n:02}")) + .filter(|f| std::path::Path::new(&f).exists()) + .map(|f| std::fs::read_to_string(&f).expect("Cannot read tombstone file")) + .filter(|f| f.contains(&exe_string)) + .last() + .expect("no tombstone found"); + + println!("Content of tombstone:\n{tombstone}"); + + assert!(tombstone + .contains("signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad")); + let abort_on_top = tombstone + .lines() + .skip_while(|l| !l.contains("backtrace:")) + .skip(1) + .take_while(|l| l.starts_with(" #")) + .take(2) + .any(|f| f.contains("/system/lib/libc.so (abort")); + assert!(abort_on_top); + } } } diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr index 66f592c34dd..3fd39810d44 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr @@ -1,12 +1,8 @@ error[E0277]: the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied - --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:1 + --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:49 | -LL | / fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) -LL | | -LL | | -LL | | { -LL | | } - | |_^ the trait `for<'z> Trait2<'y, 'z>` is not implemented for `T` +LL | fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'z> Trait2<'y, 'z>` is not implemented for `T` | help: consider restricting type parameter `T` | @@ -14,10 +10,14 @@ LL | fn callee<'x, 'y, T: for<'z> Trait2<'y, 'z>>(t: &'x dyn for<'z> Trait1< <T | ++++++++++++++++++++++++ error[E0277]: the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied - --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:49 + --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:1 | -LL | fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'z> Trait2<'y, 'z>` is not implemented for `T` +LL | / fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) +LL | | +LL | | +LL | | { +LL | | } + | |_^ the trait `for<'z> Trait2<'y, 'z>` is not implemented for `T` | help: consider restricting type parameter `T` | diff --git a/src/test/ui/resolve/resolve-primitive-fallback.rs b/src/test/ui/resolve/resolve-primitive-fallback.rs index 992bcd7977f..05cabd9e3cd 100644 --- a/src/test/ui/resolve/resolve-primitive-fallback.rs +++ b/src/test/ui/resolve/resolve-primitive-fallback.rs @@ -2,7 +2,7 @@ fn main() { // Make sure primitive type fallback doesn't work in value namespace std::mem::size_of(u16); //~^ ERROR expected value, found builtin type `u16` - //~| ERROR this function takes 0 arguments but 1 argument was supplied + //~| ERROR function takes 0 arguments but 1 argument was supplied // Make sure primitive type fallback doesn't work with global paths let _: ::u8; diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs index d1f685f3e7a..6f0d2b04591 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs @@ -1,6 +1,8 @@ +#![feature(if_let_guard)] + enum VecWrapper { A(Vec<i32>) } -fn foo(x: VecWrapper) -> usize { +fn if_guard(x: VecWrapper) -> usize { match x { VecWrapper::A(v) if { drop(v); false } => 1, //~^ ERROR cannot move out of `v` in pattern guard @@ -8,6 +10,15 @@ fn foo(x: VecWrapper) -> usize { } } +fn if_let_guard(x: VecWrapper) -> usize { + match x { + VecWrapper::A(v) if let Some(()) = { drop(v); None } => 1, + //~^ ERROR cannot move out of `v` in pattern guard + VecWrapper::A(v) => v.len() + } +} + fn main() { - foo(VecWrapper::A(vec![107])); + if_guard(VecWrapper::A(vec![107])); + if_let_guard(VecWrapper::A(vec![107])); } diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr index 6c3d1caf807..a749361bf30 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr @@ -1,11 +1,19 @@ error[E0507]: cannot move out of `v` in pattern guard - --> $DIR/rfc-reject-double-move-across-arms.rs:5:36 + --> $DIR/rfc-reject-double-move-across-arms.rs:7:36 | LL | VecWrapper::A(v) if { drop(v); false } => 1, | ^ move occurs because `v` has type `Vec<i32>`, 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: aborting due to previous error +error[E0507]: cannot move out of `v` in pattern guard + --> $DIR/rfc-reject-double-move-across-arms.rs:15:51 + | +LL | VecWrapper::A(v) if let Some(()) = { drop(v); None } => 1, + | ^ move occurs because `v` has type `Vec<i32>`, 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: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs index 571f51c9001..827335f6a84 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs @@ -1,6 +1,8 @@ +#![feature(if_let_guard)] + struct A { a: Box<i32> } -fn foo(n: i32) { +fn if_guard(n: i32) { let x = A { a: Box::new(n) }; let _y = match x { A { a: v } if { drop(v); true } => v, @@ -9,6 +11,16 @@ fn foo(n: i32) { }; } +fn if_let_guard(n: i32) { + let x = A { a: Box::new(n) }; + let _y = match x { + A { a: v } if let Some(()) = { drop(v); Some(()) } => v, + //~^ ERROR cannot move out of `v` in pattern guard + _ => Box::new(0), + }; +} + fn main() { - foo(107); + if_guard(107); + if_let_guard(107); } diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr index d1204bc2601..9285492b224 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr @@ -1,11 +1,19 @@ error[E0507]: cannot move out of `v` in pattern guard - --> $DIR/rfc-reject-double-move-in-first-arm.rs:6:30 + --> $DIR/rfc-reject-double-move-in-first-arm.rs:8:30 | LL | A { a: v } if { drop(v); true } => v, | ^ move occurs because `v` has type `Box<i32>`, 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: aborting due to previous error +error[E0507]: cannot move out of `v` in pattern guard + --> $DIR/rfc-reject-double-move-in-first-arm.rs:17:45 + | +LL | A { a: v } if let Some(()) = { drop(v); Some(()) } => v, + | ^ move occurs because `v` has type `Box<i32>`, 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: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/span/issue-34264.rs b/src/test/ui/span/issue-34264.rs index 5b8fc71384e..9227ee482df 100644 --- a/src/test/ui/span/issue-34264.rs +++ b/src/test/ui/span/issue-34264.rs @@ -4,8 +4,8 @@ fn bar(x, y: usize) {} //~ ERROR expected one of fn main() { foo(Some(42), 2); - foo(Some(42), 2, ""); //~ ERROR this function takes + foo(Some(42), 2, ""); //~ ERROR function takes bar("", ""); //~ ERROR mismatched types bar(1, 2); - bar(1, 2, 3); //~ ERROR this function takes + bar(1, 2, 3); //~ ERROR function takes } diff --git a/src/test/ui/span/missing-unit-argument.rs b/src/test/ui/span/missing-unit-argument.rs index 5b9861da6e8..db96ae223d9 100644 --- a/src/test/ui/span/missing-unit-argument.rs +++ b/src/test/ui/span/missing-unit-argument.rs @@ -9,9 +9,9 @@ impl S { fn main() { let _: Result<(), String> = Ok(); //~ ERROR this enum variant takes - foo(); //~ ERROR this function takes - foo(()); //~ ERROR this function takes - bar(); //~ ERROR this function takes - S.baz(); //~ ERROR this function takes - S.generic::<()>(); //~ ERROR this function takes + foo(); //~ ERROR function takes + foo(()); //~ ERROR function takes + bar(); //~ ERROR function takes + S.baz(); //~ ERROR this method takes + S.generic::<()>(); //~ ERROR this method takes } diff --git a/src/test/ui/span/missing-unit-argument.stderr b/src/test/ui/span/missing-unit-argument.stderr index 48a2e763af6..ef4d732b51d 100644 --- a/src/test/ui/span/missing-unit-argument.stderr +++ b/src/test/ui/span/missing-unit-argument.stderr @@ -59,7 +59,7 @@ help: provide the argument LL | bar(()); | ~~~~ -error[E0061]: this function takes 1 argument but 0 arguments were supplied +error[E0061]: this method takes 1 argument but 0 arguments were supplied --> $DIR/missing-unit-argument.rs:15:7 | LL | S.baz(); @@ -75,7 +75,7 @@ help: provide the argument LL | S.baz(()); | ~~~~ -error[E0061]: this function takes 1 argument but 0 arguments were supplied +error[E0061]: this method takes 1 argument but 0 arguments were supplied --> $DIR/missing-unit-argument.rs:16:7 | LL | S.generic::<()>(); diff --git a/src/test/ui/specialization/min_specialization/issue-79224.rs b/src/test/ui/specialization/min_specialization/issue-79224.rs index 408732fe944..104bddd076e 100644 --- a/src/test/ui/specialization/min_specialization/issue-79224.rs +++ b/src/test/ui/specialization/min_specialization/issue-79224.rs @@ -15,8 +15,10 @@ impl ToString for Cow<'_, str> { } } -impl<B: ?Sized> Display for Cow<'_, B> { //~ ERROR: the trait bound `B: Clone` is not satisfied [E0277] - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { //~ ERROR: the trait bound `B: Clone` is not satisfied [E0277] +impl<B: ?Sized> Display for Cow<'_, B> { + //~^ ERROR: the trait bound `B: Clone` is not satisfied [E0277] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + //~^ ERROR: the trait bound `B: Clone` is not satisfied [E0277] write!(f, "foo") } } diff --git a/src/test/ui/specialization/min_specialization/issue-79224.stderr b/src/test/ui/specialization/min_specialization/issue-79224.stderr index fd34a59d2bd..be6f04ae62a 100644 --- a/src/test/ui/specialization/min_specialization/issue-79224.stderr +++ b/src/test/ui/specialization/min_specialization/issue-79224.stderr @@ -1,12 +1,8 @@ error[E0277]: the trait bound `B: Clone` is not satisfied - --> $DIR/issue-79224.rs:18:1 + --> $DIR/issue-79224.rs:18:17 | -LL | / impl<B: ?Sized> Display for Cow<'_, B> { -LL | | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { -LL | | write!(f, "foo") -LL | | } -LL | | } - | |_^ the trait `Clone` is not implemented for `B` +LL | impl<B: ?Sized> Display for Cow<'_, B> { + | ^^^^^^^ the trait `Clone` is not implemented for `B` | = note: required for `B` to implement `ToOwned` help: consider further restricting this bound @@ -15,12 +11,10 @@ LL | impl<B: ?Sized + std::clone::Clone> Display for Cow<'_, B> { | +++++++++++++++++++ error[E0277]: the trait bound `B: Clone` is not satisfied - --> $DIR/issue-79224.rs:19:5 + --> $DIR/issue-79224.rs:20:12 | -LL | / fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { -LL | | write!(f, "foo") -LL | | } - | |_____^ the trait `Clone` is not implemented for `B` +LL | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + | ^^^^^ the trait `Clone` is not implemented for `B` | = note: required for `B` to implement `ToOwned` help: consider further restricting this bound diff --git a/src/test/ui/suggestions/args-instead-of-tuple-errors.rs b/src/test/ui/suggestions/args-instead-of-tuple-errors.rs index 5403b8d6d28..f5931a1baea 100644 --- a/src/test/ui/suggestions/args-instead-of-tuple-errors.rs +++ b/src/test/ui/suggestions/args-instead-of-tuple-errors.rs @@ -6,7 +6,7 @@ fn main() { let _: Option<(i32, bool)> = Some(1, 2); //~^ ERROR this enum variant takes 1 argument but 2 arguments were supplied int_bool(1, 2); - //~^ ERROR this function takes 1 argument but 2 arguments were supplied + //~^ ERROR function takes 1 argument but 2 arguments were supplied let _: Option<(i8,)> = Some(); //~^ ERROR this enum variant takes 1 argument but 0 arguments were supplied diff --git a/src/test/ui/suggestions/args-instead-of-tuple.fixed b/src/test/ui/suggestions/args-instead-of-tuple.fixed index 66e53f9ce2c..f913995d7e2 100644 --- a/src/test/ui/suggestions/args-instead-of-tuple.fixed +++ b/src/test/ui/suggestions/args-instead-of-tuple.fixed @@ -5,11 +5,11 @@ fn main() { let _: Result<(i32, i8), ()> = Ok((1, 2)); - //~^ ERROR this enum variant takes 1 argument but 2 arguments were supplied + //~^ ERROR enum variant takes 1 argument but 2 arguments were supplied let _: Option<(i32, i8, &'static str)> = Some((1, 2, "hi")); - //~^ ERROR this enum variant takes 1 argument but 3 arguments were supplied + //~^ ERROR enum variant takes 1 argument but 3 arguments were supplied let _: Option<()> = Some(()); - //~^ ERROR this enum variant takes 1 argument but 0 arguments were supplied + //~^ ERROR enum variant takes 1 argument but 0 arguments were supplied let _: Option<(i32,)> = Some((3,)); //~^ ERROR mismatched types @@ -17,9 +17,9 @@ fn main() { let _: Option<(i32,)> = Some((3,)); //~^ ERROR mismatched types - two_ints((1, 2)); //~ ERROR this function takes 1 argument + two_ints((1, 2)); //~ ERROR function takes 1 argument - with_generic((3, 4)); //~ ERROR this function takes 1 argument + with_generic((3, 4)); //~ ERROR function takes 1 argument } fn two_ints(_: (i32, i32)) { @@ -28,6 +28,6 @@ fn two_ints(_: (i32, i32)) { fn with_generic<T: Copy + Send>((a, b): (i32, T)) { if false { // test generics/bound handling - with_generic((a, b)); //~ ERROR this function takes 1 argument + with_generic((a, b)); //~ ERROR function takes 1 argument } } diff --git a/src/test/ui/suggestions/args-instead-of-tuple.rs b/src/test/ui/suggestions/args-instead-of-tuple.rs index a15bff07ebf..1c65407b395 100644 --- a/src/test/ui/suggestions/args-instead-of-tuple.rs +++ b/src/test/ui/suggestions/args-instead-of-tuple.rs @@ -5,11 +5,11 @@ fn main() { let _: Result<(i32, i8), ()> = Ok(1, 2); - //~^ ERROR this enum variant takes 1 argument but 2 arguments were supplied + //~^ ERROR enum variant takes 1 argument but 2 arguments were supplied let _: Option<(i32, i8, &'static str)> = Some(1, 2, "hi"); - //~^ ERROR this enum variant takes 1 argument but 3 arguments were supplied + //~^ ERROR enum variant takes 1 argument but 3 arguments were supplied let _: Option<()> = Some(); - //~^ ERROR this enum variant takes 1 argument but 0 arguments were supplied + //~^ ERROR enum variant takes 1 argument but 0 arguments were supplied let _: Option<(i32,)> = Some(3); //~^ ERROR mismatched types @@ -17,9 +17,9 @@ fn main() { let _: Option<(i32,)> = Some((3)); //~^ ERROR mismatched types - two_ints(1, 2); //~ ERROR this function takes 1 argument + two_ints(1, 2); //~ ERROR function takes 1 argument - with_generic(3, 4); //~ ERROR this function takes 1 argument + with_generic(3, 4); //~ ERROR function takes 1 argument } fn two_ints(_: (i32, i32)) { @@ -28,6 +28,6 @@ fn two_ints(_: (i32, i32)) { fn with_generic<T: Copy + Send>((a, b): (i32, T)) { if false { // test generics/bound handling - with_generic(a, b); //~ ERROR this function takes 1 argument + with_generic(a, b); //~ ERROR function takes 1 argument } } diff --git a/src/test/ui/suggestions/args-instead-of-tuple.stderr b/src/test/ui/suggestions/args-instead-of-tuple.stderr index c8499010d68..3ed9dbf4abb 100644 --- a/src/test/ui/suggestions/args-instead-of-tuple.stderr +++ b/src/test/ui/suggestions/args-instead-of-tuple.stderr @@ -1,4 +1,4 @@ -error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied +error[E0061]: enum variant takes 1 argument but 2 arguments were supplied --> $DIR/args-instead-of-tuple.rs:7:36 | LL | let _: Result<(i32, i8), ()> = Ok(1, 2); @@ -11,7 +11,7 @@ help: wrap these arguments in parentheses to construct a tuple LL | let _: Result<(i32, i8), ()> = Ok((1, 2)); | + + -error[E0061]: this enum variant takes 1 argument but 3 arguments were supplied +error[E0061]: enum variant takes 1 argument but 3 arguments were supplied --> $DIR/args-instead-of-tuple.rs:9:46 | LL | let _: Option<(i32, i8, &'static str)> = Some(1, 2, "hi"); @@ -71,7 +71,7 @@ help: use a trailing comma to create a tuple with one element LL | let _: Option<(i32,)> = Some((3,)); | + -error[E0061]: this function takes 1 argument but 2 arguments were supplied +error[E0061]: function takes 1 argument but 2 arguments were supplied --> $DIR/args-instead-of-tuple.rs:20:5 | LL | two_ints(1, 2); @@ -87,7 +87,7 @@ help: wrap these arguments in parentheses to construct a tuple LL | two_ints((1, 2)); | + + -error[E0061]: this function takes 1 argument but 2 arguments were supplied +error[E0061]: function takes 1 argument but 2 arguments were supplied --> $DIR/args-instead-of-tuple.rs:22:5 | LL | with_generic(3, 4); @@ -103,7 +103,7 @@ help: wrap these arguments in parentheses to construct a tuple LL | with_generic((3, 4)); | + + -error[E0061]: this function takes 1 argument but 2 arguments were supplied +error[E0061]: function takes 1 argument but 2 arguments were supplied --> $DIR/args-instead-of-tuple.rs:31:9 | LL | with_generic(a, b); diff --git a/src/test/ui/suggestions/imm-ref-trait-object.rs b/src/test/ui/suggestions/imm-ref-trait-object.rs index 288d6c699f5..c1c969b90e4 100644 --- a/src/test/ui/suggestions/imm-ref-trait-object.rs +++ b/src/test/ui/suggestions/imm-ref-trait-object.rs @@ -1,5 +1,5 @@ fn test(t: &dyn Iterator<Item=&u64>) -> u64 { - t.min().unwrap() //~ ERROR the `min` method cannot be invoked on a trait object + t.min().unwrap() //~ ERROR the `min` method cannot be invoked on `&dyn Iterator<Item = &u64>` } fn main() { diff --git a/src/test/ui/suggestions/imm-ref-trait-object.stderr b/src/test/ui/suggestions/imm-ref-trait-object.stderr index 7791b308d5d..f7f7902c17d 100644 --- a/src/test/ui/suggestions/imm-ref-trait-object.stderr +++ b/src/test/ui/suggestions/imm-ref-trait-object.stderr @@ -1,13 +1,13 @@ -error: the `min` method cannot be invoked on a trait object +error: the `min` method cannot be invoked on `&dyn Iterator<Item = &u64>` --> $DIR/imm-ref-trait-object.rs:2:8 | LL | t.min().unwrap() | ^^^ - --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | - = note: this has a `Sized` requirement +help: you need `&mut dyn Iterator<Item = &u64>` instead of `&dyn Iterator<Item = &u64>` | - = note: you need `&mut dyn Iterator<Item = &u64>` instead of `&dyn Iterator<Item = &u64>` +LL | fn test(t: &mut dyn Iterator<Item=&u64>) -> u64 { + | +++ error: aborting due to previous error diff --git a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs index 9839e973bdf..a1a51c4814e 100644 --- a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs +++ b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs @@ -60,4 +60,9 @@ mod in_path { //~| ERROR missing lifetime specifier } +// This must not err, as the `&` actually resolves to `'a`. +fn resolved_anonymous<'a, T>(f: impl Fn(&'a str) -> &T) { + f("f") +} + fn main() {} diff --git a/src/test/ui/suggestions/issue-106443-sugg-clone-for-arg.rs b/src/test/ui/suggestions/issue-106443-sugg-clone-for-arg.rs new file mode 100644 index 00000000000..48efdb82c46 --- /dev/null +++ b/src/test/ui/suggestions/issue-106443-sugg-clone-for-arg.rs @@ -0,0 +1,23 @@ +#[derive(Clone)] +struct S; + +// without Clone +struct T; + +fn foo(_: S) {} + +fn test1() { + let s = &S; + foo(s); //~ ERROR mismatched types +} + +fn bar(_: T) {} +fn test2() { + let t = &T; + bar(t); //~ ERROR mismatched types +} + +fn main() { + test1(); + test2(); +} diff --git a/src/test/ui/suggestions/issue-106443-sugg-clone-for-arg.stderr b/src/test/ui/suggestions/issue-106443-sugg-clone-for-arg.stderr new file mode 100644 index 00000000000..1e66fe3af24 --- /dev/null +++ b/src/test/ui/suggestions/issue-106443-sugg-clone-for-arg.stderr @@ -0,0 +1,35 @@ +error[E0308]: mismatched types + --> $DIR/issue-106443-sugg-clone-for-arg.rs:11:9 + | +LL | foo(s); + | --- ^ expected struct `S`, found `&S` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/issue-106443-sugg-clone-for-arg.rs:7:4 + | +LL | fn foo(_: S) {} + | ^^^ ---- +help: consider using clone here + | +LL | foo(s.clone()); + | ++++++++ + +error[E0308]: mismatched types + --> $DIR/issue-106443-sugg-clone-for-arg.rs:17:9 + | +LL | bar(t); + | --- ^ expected struct `T`, found `&T` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/issue-106443-sugg-clone-for-arg.rs:14:4 + | +LL | fn bar(_: T) {} + | ^^^ ---- + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/suggestions/issue-106443-sugg-clone-for-bound.rs b/src/test/ui/suggestions/issue-106443-sugg-clone-for-bound.rs new file mode 100644 index 00000000000..3b2e316b296 --- /dev/null +++ b/src/test/ui/suggestions/issue-106443-sugg-clone-for-bound.rs @@ -0,0 +1,20 @@ +#[derive(Clone)] +struct S; + +trait X {} + +impl X for S {} + +fn foo<T: X>(_: T) {} +fn bar<T: X>(s: &T) { + foo(s); //~ ERROR the trait bound `&T: X` is not satisfied +} + +fn bar_with_clone<T: X + Clone>(s: &T) { + foo(s); //~ ERROR the trait bound `&T: X` is not satisfied +} + +fn main() { + let s = &S; + bar(s); +} diff --git a/src/test/ui/suggestions/issue-106443-sugg-clone-for-bound.stderr b/src/test/ui/suggestions/issue-106443-sugg-clone-for-bound.stderr new file mode 100644 index 00000000000..8607917ede6 --- /dev/null +++ b/src/test/ui/suggestions/issue-106443-sugg-clone-for-bound.stderr @@ -0,0 +1,29 @@ +error[E0277]: the trait bound `&T: X` is not satisfied + --> $DIR/issue-106443-sugg-clone-for-bound.rs:10:9 + | +LL | foo(s); + | ^ the trait `X` is not implemented for `&T` + | +help: consider further restricting this bound + | +LL | fn bar<T: X + Clone>(s: &T) { + | +++++++ +help: consider using clone here + | +LL | foo(s.clone()); + | ++++++++ + +error[E0277]: the trait bound `&T: X` is not satisfied + --> $DIR/issue-106443-sugg-clone-for-bound.rs:14:9 + | +LL | foo(s); + | ^ the trait `X` is not implemented for `&T` + | +help: consider using clone here + | +LL | foo(s.clone()); + | ++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/suggestions/missing-type-param-used-in-param.fixed b/src/test/ui/suggestions/missing-type-param-used-in-param.fixed index cc4120041b9..be439403104 100644 --- a/src/test/ui/suggestions/missing-type-param-used-in-param.fixed +++ b/src/test/ui/suggestions/missing-type-param-used-in-param.fixed @@ -3,6 +3,6 @@ fn two_type_params<A, B>(_: B) {} fn main() { - two_type_params::<String, _>(100); //~ ERROR this function takes 2 generic arguments + two_type_params::<String, _>(100); //~ ERROR function takes 2 generic arguments two_type_params::<String, _>(100); } diff --git a/src/test/ui/suggestions/missing-type-param-used-in-param.rs b/src/test/ui/suggestions/missing-type-param-used-in-param.rs index 19286331b60..d444998d35b 100644 --- a/src/test/ui/suggestions/missing-type-param-used-in-param.rs +++ b/src/test/ui/suggestions/missing-type-param-used-in-param.rs @@ -3,6 +3,6 @@ fn two_type_params<A, B>(_: B) {} fn main() { - two_type_params::<String>(100); //~ ERROR this function takes 2 generic arguments + two_type_params::<String>(100); //~ ERROR function takes 2 generic arguments two_type_params::<String, _>(100); } diff --git a/src/test/ui/suggestions/sugg-else-for-closure.stderr b/src/test/ui/suggestions/sugg-else-for-closure.stderr index da4db46aad3..5f59d0f541c 100644 --- a/src/test/ui/suggestions/sugg-else-for-closure.stderr +++ b/src/test/ui/suggestions/sugg-else-for-closure.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types LL | let _s = y.unwrap_or(|| x.split('.').nth(1).unwrap()); | --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&str`, found closure | | - | arguments to this function are incorrect + | arguments to this method are incorrect | = note: expected reference `&str` found closure `[closure@$DIR/sugg-else-for-closure.rs:6:26: 6:28]` diff --git a/src/test/ui/suggestions/trait-with-missing-associated-type-restriction.stderr b/src/test/ui/suggestions/trait-with-missing-associated-type-restriction.stderr index 7583c875a1a..f520d88c6ba 100644 --- a/src/test/ui/suggestions/trait-with-missing-associated-type-restriction.stderr +++ b/src/test/ui/suggestions/trait-with-missing-associated-type-restriction.stderr @@ -78,7 +78,7 @@ error[E0308]: mismatched types LL | x.funk(3); | ---- ^ expected associated type, found integer | | - | arguments to this function are incorrect + | arguments to this method are incorrect | = note: expected associated type `<T as Trait<i32>>::A` found type `{integer}` diff --git a/src/test/ui/tag-type-args.stderr b/src/test/ui/tag-type-args.stderr index 107af76413d..5b54880a685 100644 --- a/src/test/ui/tag-type-args.stderr +++ b/src/test/ui/tag-type-args.stderr @@ -12,7 +12,7 @@ LL | enum Quux<T> { Bar } help: add missing generic argument | LL | fn foo(c: Quux<T>) { assert!((false)); } - | ~~~~~~~ + | +++ error: aborting due to previous error diff --git a/src/test/ui/traits/impl-method-mismatch.rs b/src/test/ui/traits/impl-method-mismatch.rs index 683b1c1aa43..62580755c81 100644 --- a/src/test/ui/traits/impl-method-mismatch.rs +++ b/src/test/ui/traits/impl-method-mismatch.rs @@ -6,8 +6,8 @@ impl Mumbo for usize { // Cannot have a larger effect than the trait: unsafe fn jumbo(&self, x: &usize) { *self + *x; } //~^ ERROR method `jumbo` has an incompatible type for trait - //~| expected fn pointer `fn - //~| found fn pointer `unsafe fn + //~| expected signature `fn + //~| found signature `unsafe fn } fn main() {} diff --git a/src/test/ui/traits/impl-method-mismatch.stderr b/src/test/ui/traits/impl-method-mismatch.stderr index 30aa97d2934..252b5aff96a 100644 --- a/src/test/ui/traits/impl-method-mismatch.stderr +++ b/src/test/ui/traits/impl-method-mismatch.stderr @@ -9,8 +9,8 @@ note: type in trait | LL | fn jumbo(&self, x: &usize) -> usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: expected fn pointer `fn(&usize, &usize) -> usize` - found fn pointer `unsafe fn(&usize, &usize)` + = note: expected signature `fn(&usize, &usize) -> usize` + found signature `unsafe fn(&usize, &usize)` error: aborting due to previous error diff --git a/src/test/ui/traits/issue-35869.stderr b/src/test/ui/traits/issue-35869.stderr index 0780109b843..6d985bdeaf8 100644 --- a/src/test/ui/traits/issue-35869.stderr +++ b/src/test/ui/traits/issue-35869.stderr @@ -12,8 +12,8 @@ note: type in trait | LL | fn foo(_: fn(u8) -> ()); | ^^^^^^^^^^^^ - = note: expected fn pointer `fn(fn(u8))` - found fn pointer `fn(fn(u16))` + = note: expected signature `fn(fn(u8))` + found signature `fn(fn(u16))` error[E0053]: method `bar` has an incompatible type for trait --> $DIR/issue-35869.rs:13:15 @@ -29,8 +29,8 @@ note: type in trait | LL | fn bar(_: Option<u8>); | ^^^^^^^^^^ - = note: expected fn pointer `fn(Option<u8>)` - found fn pointer `fn(Option<u16>)` + = note: expected signature `fn(Option<u8>)` + found signature `fn(Option<u16>)` error[E0053]: method `baz` has an incompatible type for trait --> $DIR/issue-35869.rs:15:15 @@ -46,8 +46,8 @@ note: type in trait | LL | fn baz(_: (u8, u16)); | ^^^^^^^^^ - = note: expected fn pointer `fn((u8, _))` - found fn pointer `fn((u16, _))` + = note: expected signature `fn((u8, _))` + found signature `fn((u16, _))` error[E0053]: method `qux` has an incompatible type for trait --> $DIR/issue-35869.rs:17:17 @@ -63,8 +63,8 @@ note: type in trait | LL | fn qux() -> u8; | ^^ - = note: expected fn pointer `fn() -> u8` - found fn pointer `fn() -> u16` + = note: expected signature `fn() -> u8` + found signature `fn() -> u16` error: aborting due to 4 previous errors diff --git a/src/test/ui/traits/issue-52893.stderr b/src/test/ui/traits/issue-52893.stderr index 0ee44921bf5..7924d3db06f 100644 --- a/src/test/ui/traits/issue-52893.stderr +++ b/src/test/ui/traits/issue-52893.stderr @@ -7,7 +7,7 @@ LL | impl<F, Name, P> AddClass<Name, F> for Class<P> LL | builder.push(output); | ---- ^^^^^^ expected type parameter `F`, found struct `Class` | | - | arguments to this function are incorrect + | arguments to this method are incorrect | = note: expected type parameter `F` found struct `Class<P>` diff --git a/src/test/ui/traits/issue-91594.stderr b/src/test/ui/traits/issue-91594.stderr index 5fcd090a834..9f9acf85113 100644 --- a/src/test/ui/traits/issue-91594.stderr +++ b/src/test/ui/traits/issue-91594.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `Foo: HasComponent<()>` is not satisfied - --> $DIR/issue-91594.rs:10:1 + --> $DIR/issue-91594.rs:10:6 | LL | impl HasComponent<<Foo as Component<Foo>>::Interface> for Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasComponent<()>` is not implemented for `Foo` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasComponent<()>` is not implemented for `Foo` | = help: the trait `HasComponent<<Foo as Component<Foo>>::Interface>` is implemented for `Foo` note: required for `Foo` to implement `Component<Foo>` diff --git a/src/test/ui/issues/issue-99875.rs b/src/test/ui/traits/issue-99875.rs index cf73fd8d31f..cf73fd8d31f 100644 --- a/src/test/ui/issues/issue-99875.rs +++ b/src/test/ui/traits/issue-99875.rs diff --git a/src/test/ui/issues/issue-99875.stderr b/src/test/ui/traits/issue-99875.stderr index 3ff8f12f1b8..3ff8f12f1b8 100644 --- a/src/test/ui/issues/issue-99875.stderr +++ b/src/test/ui/traits/issue-99875.stderr diff --git a/src/test/ui/traits/matching-lifetimes.stderr b/src/test/ui/traits/matching-lifetimes.stderr index de1c878a513..f8119ed415d 100644 --- a/src/test/ui/traits/matching-lifetimes.stderr +++ b/src/test/ui/traits/matching-lifetimes.stderr @@ -4,8 +4,8 @@ error[E0308]: method not compatible with trait LL | fn foo(x: Foo<'b,'a>) { | ^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | - = note: expected fn pointer `fn(Foo<'a, 'b>)` - found fn pointer `fn(Foo<'b, 'a>)` + = note: expected signature `fn(Foo<'a, 'b>)` + found signature `fn(Foo<'b, 'a>)` note: the lifetime `'b` as defined here... --> $DIR/matching-lifetimes.rs:13:9 | @@ -23,8 +23,8 @@ error[E0308]: method not compatible with trait LL | fn foo(x: Foo<'b,'a>) { | ^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | - = note: expected fn pointer `fn(Foo<'a, 'b>)` - found fn pointer `fn(Foo<'b, 'a>)` + = note: expected signature `fn(Foo<'a, 'b>)` + found signature `fn(Foo<'b, 'a>)` note: the lifetime `'a` as defined here... --> $DIR/matching-lifetimes.rs:13:6 | diff --git a/src/test/ui/traits/param-without-lifetime-constraint.stderr b/src/test/ui/traits/param-without-lifetime-constraint.stderr index 118b2cf3ecd..b128b6518ce 100644 --- a/src/test/ui/traits/param-without-lifetime-constraint.stderr +++ b/src/test/ui/traits/param-without-lifetime-constraint.stderr @@ -7,8 +7,8 @@ LL | fn get_relation(&self) -> To; LL | fn get_relation(&self) -> &ProofReader { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Article) -> &'1 ProofReader` | - = note: expected `fn(&'1 Article) -> &'2 ProofReader` - found `fn(&'1 Article) -> &'1 ProofReader` + = note: expected signature `fn(&'1 Article) -> &'2 ProofReader` + found signature `fn(&'1 Article) -> &'1 ProofReader` help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` --> $DIR/param-without-lifetime-constraint.rs:10:31 | diff --git a/src/test/ui/traits/safety-trait-impl-cc.stderr b/src/test/ui/traits/safety-trait-impl-cc.stderr index 0b1fb30478f..0ca565787f6 100644 --- a/src/test/ui/traits/safety-trait-impl-cc.stderr +++ b/src/test/ui/traits/safety-trait-impl-cc.stderr @@ -1,12 +1,8 @@ error[E0200]: the trait `Foo` requires an `unsafe impl` declaration --> $DIR/safety-trait-impl-cc.rs:9:1 | -LL | / impl lib::Foo for Bar { -LL | | fn foo(&self) -> isize { -LL | | panic!(); -LL | | } -LL | | } - | |_^ +LL | impl lib::Foo for Bar { + | ^^^^^^^^^^^^^^^^^^^^^ | = note: the trait `Foo` enforces invariants that the compiler can't check. Review the trait documentation and make sure this implementation upholds those invariants before adding the `unsafe` keyword help: add `unsafe` to this trait implementation diff --git a/src/test/ui/traits/safety-trait-impl.stderr b/src/test/ui/traits/safety-trait-impl.stderr index 721e2b48b95..e78e0e3a6ba 100644 --- a/src/test/ui/traits/safety-trait-impl.stderr +++ b/src/test/ui/traits/safety-trait-impl.stderr @@ -2,7 +2,7 @@ error[E0200]: the trait `UnsafeTrait` requires an `unsafe impl` declaration --> $DIR/safety-trait-impl.rs:14:1 | LL | impl UnsafeTrait for u16 { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the trait `UnsafeTrait` enforces invariants that the compiler can't check. Review the trait documentation and make sure this implementation upholds those invariants before adding the `unsafe` keyword help: add `unsafe` to this trait implementation @@ -14,7 +14,7 @@ error[E0199]: implementing the trait `SafeTrait` is not unsafe --> $DIR/safety-trait-impl.rs:16:1 | LL | unsafe impl SafeTrait for u32 { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove `unsafe` from this trait implementation | diff --git a/src/test/ui/traits/self-without-lifetime-constraint.stderr b/src/test/ui/traits/self-without-lifetime-constraint.stderr index 85fada3b87c..05a49820a82 100644 --- a/src/test/ui/traits/self-without-lifetime-constraint.stderr +++ b/src/test/ui/traits/self-without-lifetime-constraint.stderr @@ -7,8 +7,8 @@ LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self, &Self>; LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>` | - = note: expected `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), FromSqlError>` - found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>` + = note: expected signature `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), FromSqlError>` + found signature `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>` help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` --> $DIR/self-without-lifetime-constraint.rs:41:60 | diff --git a/src/test/ui/tuple/add-tuple-within-arguments.rs b/src/test/ui/tuple/add-tuple-within-arguments.rs index 089c703fda5..01b13b29fb4 100644 --- a/src/test/ui/tuple/add-tuple-within-arguments.rs +++ b/src/test/ui/tuple/add-tuple-within-arguments.rs @@ -4,7 +4,7 @@ fn bar(s: &str, a: (&str,), s2: &str) {} fn main() { foo("hi", 1, 2, "hi"); - //~^ ERROR this function takes 3 arguments but 4 arguments were supplied + //~^ ERROR function takes 3 arguments but 4 arguments were supplied bar("hi", "hi", "hi"); //~^ ERROR mismatched types } diff --git a/src/test/ui/tuple/add-tuple-within-arguments.stderr b/src/test/ui/tuple/add-tuple-within-arguments.stderr index 7029d298d71..2e20a4cca08 100644 --- a/src/test/ui/tuple/add-tuple-within-arguments.stderr +++ b/src/test/ui/tuple/add-tuple-within-arguments.stderr @@ -1,4 +1,4 @@ -error[E0061]: this function takes 3 arguments but 4 arguments were supplied +error[E0061]: function takes 3 arguments but 4 arguments were supplied --> $DIR/add-tuple-within-arguments.rs:6:5 | LL | foo("hi", 1, 2, "hi"); diff --git a/src/test/ui/tuple/wrong_argument_ice-2.rs b/src/test/ui/tuple/wrong_argument_ice-2.rs index b0f814616f2..e1c1d748fec 100644 --- a/src/test/ui/tuple/wrong_argument_ice-2.rs +++ b/src/test/ui/tuple/wrong_argument_ice-2.rs @@ -11,7 +11,7 @@ impl Foo { fn bar() { let x = Foo; test(x.qux(), x.qux()); - //~^ ERROR this function takes 1 argument but 2 arguments were supplied + //~^ ERROR function takes 1 argument but 2 arguments were supplied } fn main() {} diff --git a/src/test/ui/tuple/wrong_argument_ice-2.stderr b/src/test/ui/tuple/wrong_argument_ice-2.stderr index 0c2a4c41461..41244209214 100644 --- a/src/test/ui/tuple/wrong_argument_ice-2.stderr +++ b/src/test/ui/tuple/wrong_argument_ice-2.stderr @@ -1,4 +1,4 @@ -error[E0061]: this function takes 1 argument but 2 arguments were supplied +error[E0061]: function takes 1 argument but 2 arguments were supplied --> $DIR/wrong_argument_ice-2.rs:13:5 | LL | test(x.qux(), x.qux()); diff --git a/src/test/ui/tuple/wrong_argument_ice-3.rs b/src/test/ui/tuple/wrong_argument_ice-3.rs index 951687c3759..96633180b57 100644 --- a/src/test/ui/tuple/wrong_argument_ice-3.rs +++ b/src/test/ui/tuple/wrong_argument_ice-3.rs @@ -7,7 +7,7 @@ fn test(process: &Process, groups: Vec<Group>) -> Vec<Group> { if groups.capacity() == 0 { groups.push(new_group, vec![process]); - //~^ ERROR this function takes 1 argument but 2 arguments were supplied + //~^ ERROR this method takes 1 argument but 2 arguments were supplied return groups; } diff --git a/src/test/ui/tuple/wrong_argument_ice-3.stderr b/src/test/ui/tuple/wrong_argument_ice-3.stderr index fe3712ef839..0a503e1fe58 100644 --- a/src/test/ui/tuple/wrong_argument_ice-3.stderr +++ b/src/test/ui/tuple/wrong_argument_ice-3.stderr @@ -1,4 +1,4 @@ -error[E0061]: this function takes 1 argument but 2 arguments were supplied +error[E0061]: this method takes 1 argument but 2 arguments were supplied --> $DIR/wrong_argument_ice-3.rs:9:16 | LL | groups.push(new_group, vec![process]); diff --git a/src/test/ui/tuple/wrong_argument_ice-4.rs b/src/test/ui/tuple/wrong_argument_ice-4.rs index 479bd0d819f..883d92dcce1 100644 --- a/src/test/ui/tuple/wrong_argument_ice-4.rs +++ b/src/test/ui/tuple/wrong_argument_ice-4.rs @@ -1,6 +1,6 @@ fn main() { (|| {})(|| { - //~^ ERROR this function takes 0 arguments but 1 argument was supplied + //~^ ERROR function takes 0 arguments but 1 argument was supplied let b = 1; }); } diff --git a/src/test/ui/tuple/wrong_argument_ice.rs b/src/test/ui/tuple/wrong_argument_ice.rs index da967d8c146..b7e0225feb7 100644 --- a/src/test/ui/tuple/wrong_argument_ice.rs +++ b/src/test/ui/tuple/wrong_argument_ice.rs @@ -9,7 +9,7 @@ pub struct BuildPlanBuilder { impl BuildPlanBuilder { pub fn or(&mut self) -> &mut Self { self.acc.push_back(self.current_provides, self.current_requires); - //~^ ERROR this function takes 1 argument but 2 arguments were supplied + //~^ ERROR method takes 1 argument but 2 arguments were supplied self } } diff --git a/src/test/ui/tuple/wrong_argument_ice.stderr b/src/test/ui/tuple/wrong_argument_ice.stderr index 452413fc516..f1b00ae0b92 100644 --- a/src/test/ui/tuple/wrong_argument_ice.stderr +++ b/src/test/ui/tuple/wrong_argument_ice.stderr @@ -1,4 +1,4 @@ -error[E0061]: this function takes 1 argument but 2 arguments were supplied +error[E0061]: method takes 1 argument but 2 arguments were supplied --> $DIR/wrong_argument_ice.rs:11:18 | LL | self.acc.push_back(self.current_provides, self.current_requires); diff --git a/src/test/ui/type/ascription/issue-34255-1.stderr b/src/test/ui/type/ascription/issue-34255-1.stderr index fd43e1114c8..fafff19f8f6 100644 --- a/src/test/ui/type/ascription/issue-34255-1.stderr +++ b/src/test/ui/type/ascription/issue-34255-1.stderr @@ -28,7 +28,7 @@ LL | input_cells: Vec::new() help: add missing generic argument | LL | input_cells: Vec<T>::new() - | ~~~~~~ + | +++ error: aborting due to 3 previous errors diff --git a/src/test/ui/type/binding-assigned-block-without-tail-expression.rs b/src/test/ui/type/binding-assigned-block-without-tail-expression.rs new file mode 100644 index 00000000000..09afd27a079 --- /dev/null +++ b/src/test/ui/type/binding-assigned-block-without-tail-expression.rs @@ -0,0 +1,22 @@ +struct S; +fn main() { + let x = { + println!("foo"); + 42; + }; + let y = {}; + let z = { + "hi"; + }; + let s = { + S; + }; + println!("{}", x); //~ ERROR E0277 + println!("{}", y); //~ ERROR E0277 + println!("{}", z); //~ ERROR E0277 + println!("{}", s); //~ ERROR E0277 + let _: i32 = x; //~ ERROR E0308 + let _: i32 = y; //~ ERROR E0308 + let _: i32 = z; //~ ERROR E0308 + let _: i32 = s; //~ ERROR E0308 +} diff --git a/src/test/ui/type/binding-assigned-block-without-tail-expression.stderr b/src/test/ui/type/binding-assigned-block-without-tail-expression.stderr new file mode 100644 index 00000000000..3e96d7f317b --- /dev/null +++ b/src/test/ui/type/binding-assigned-block-without-tail-expression.stderr @@ -0,0 +1,109 @@ +error[E0277]: `()` doesn't implement `std::fmt::Display` + --> $DIR/binding-assigned-block-without-tail-expression.rs:14:20 + | +LL | 42; + | - help: remove this semicolon +... +LL | println!("{}", x); + | ^ `()` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `()` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `()` doesn't implement `std::fmt::Display` + --> $DIR/binding-assigned-block-without-tail-expression.rs:15:20 + | +LL | let y = {}; + | -- this empty block is missing a tail expression +... +LL | println!("{}", y); + | ^ `()` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `()` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `()` doesn't implement `std::fmt::Display` + --> $DIR/binding-assigned-block-without-tail-expression.rs:16:20 + | +LL | "hi"; + | - help: remove this semicolon +... +LL | println!("{}", z); + | ^ `()` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `()` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `()` doesn't implement `std::fmt::Display` + --> $DIR/binding-assigned-block-without-tail-expression.rs:17:20 + | +LL | let s = { + | _____________- +LL | | S; +LL | | }; + | |_____- this block is missing a tail expression +... +LL | println!("{}", s); + | ^ `()` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `()` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/binding-assigned-block-without-tail-expression.rs:18:18 + | +LL | 42; + | - help: remove this semicolon +... +LL | let _: i32 = x; + | --- ^ expected `i32`, found `()` + | | + | expected due to this + +error[E0308]: mismatched types + --> $DIR/binding-assigned-block-without-tail-expression.rs:19:18 + | +LL | let y = {}; + | -- this empty block is missing a tail expression +... +LL | let _: i32 = y; + | --- ^ expected `i32`, found `()` + | | + | expected due to this + +error[E0308]: mismatched types + --> $DIR/binding-assigned-block-without-tail-expression.rs:20:18 + | +LL | let z = { + | _____________- +LL | | "hi"; +LL | | }; + | |_____- this block is missing a tail expression +... +LL | let _: i32 = z; + | --- ^ expected `i32`, found `()` + | | + | expected due to this + +error[E0308]: mismatched types + --> $DIR/binding-assigned-block-without-tail-expression.rs:21:18 + | +LL | let s = { + | _____________- +LL | | S; +LL | | }; + | |_____- this block is missing a tail expression +... +LL | let _: i32 = s; + | --- ^ expected `i32`, found `()` + | | + | expected due to this + +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/type/closure-with-wrong-borrows.rs b/src/test/ui/type/closure-with-wrong-borrows.rs new file mode 100644 index 00000000000..5f6a78351a2 --- /dev/null +++ b/src/test/ui/type/closure-with-wrong-borrows.rs @@ -0,0 +1,10 @@ +struct S<'a>(&'a str); + +fn f(inner: fn(&str, &S)) { +} + +#[allow(unreachable_code)] +fn main() { + let inner: fn(_, _) = unimplemented!(); + f(inner); //~ ERROR mismatched types +} diff --git a/src/test/ui/type/closure-with-wrong-borrows.stderr b/src/test/ui/type/closure-with-wrong-borrows.stderr new file mode 100644 index 00000000000..7370bc76467 --- /dev/null +++ b/src/test/ui/type/closure-with-wrong-borrows.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/closure-with-wrong-borrows.rs:9:7 + | +LL | f(inner); + | - ^^^^^ one type is more general than the other + | | + | arguments to this function are incorrect + | + = note: expected fn pointer `for<'a, 'b, 'c> fn(&'a str, &'b S<'c>)` + found fn pointer `fn(_, _)` +note: function defined here + --> $DIR/closure-with-wrong-borrows.rs:3:4 + | +LL | fn f(inner: fn(&str, &S)) { + | ^ ------------------- + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type/issue-58355.rs b/src/test/ui/type/issue-58355.rs new file mode 100644 index 00000000000..3b62fdece40 --- /dev/null +++ b/src/test/ui/type/issue-58355.rs @@ -0,0 +1,7 @@ +#![crate_type = "lib"] + +pub fn foo(callback: fn() -> dyn ToString) { + let mut x: Option<Box<dyn Fn() -> dyn ToString>> = None; + x = Some(Box::new(callback)); + //~^ ERROR: the size for values of type `dyn ToString` cannot be known at compilation time +} diff --git a/src/test/ui/type/issue-58355.stderr b/src/test/ui/type/issue-58355.stderr new file mode 100644 index 00000000000..6f89a7b0049 --- /dev/null +++ b/src/test/ui/type/issue-58355.stderr @@ -0,0 +1,13 @@ +error[E0277]: the size for values of type `dyn ToString` cannot be known at compilation time + --> $DIR/issue-58355.rs:5:14 + | +LL | x = Some(Box::new(callback)); + | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `fn() -> dyn ToString`, the trait `Sized` is not implemented for `dyn ToString` + = note: required because it appears within the type `fn() -> dyn ToString` + = note: required for the cast from `fn() -> dyn ToString` to the object type `dyn Fn() -> (dyn ToString + 'static)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type/type-ascription-instead-of-initializer.rs b/src/test/ui/type/type-ascription-instead-of-initializer.rs index 9f9b6f06bbc..8978c85ed49 100644 --- a/src/test/ui/type/type-ascription-instead-of-initializer.rs +++ b/src/test/ui/type/type-ascription-instead-of-initializer.rs @@ -1,4 +1,4 @@ fn main() { let x: Vec::with_capacity(10, 20); //~ ERROR expected type, found `10` - //~^ ERROR this function takes 1 argument + //~^ ERROR function takes 1 argument } diff --git a/src/test/ui/type/type-check/assignment-in-if.stderr b/src/test/ui/type/type-check/assignment-in-if.stderr index 9f4558adab1..de133e5599c 100644 --- a/src/test/ui/type/type-check/assignment-in-if.stderr +++ b/src/test/ui/type/type-check/assignment-in-if.stderr @@ -67,6 +67,9 @@ LL | x == 5 error[E0308]: mismatched types --> $DIR/assignment-in-if.rs:44:18 | +LL | if y = (Foo { foo: x }) { + | - here the type of `x` is inferred to be `usize` +... LL | if x == x && x = x && x == x { | ------ ^ expected `bool`, found `usize` | | @@ -75,6 +78,9 @@ LL | if x == x && x = x && x == x { error[E0308]: mismatched types --> $DIR/assignment-in-if.rs:44:22 | +LL | if y = (Foo { foo: x }) { + | - here the type of `x` is inferred to be `usize` +... LL | if x == x && x = x && x == x { | ^ expected `bool`, found `usize` @@ -92,6 +98,9 @@ LL | if x == x && x == x && x == x { error[E0308]: mismatched types --> $DIR/assignment-in-if.rs:51:28 | +LL | if y = (Foo { foo: x }) { + | - here the type of `x` is inferred to be `usize` +... LL | if x == x && x == x && x = x { | ---------------- ^ expected `bool`, found `usize` | | diff --git a/src/test/ui/type/type-check/point-at-inference-2.rs b/src/test/ui/type/type-check/point-at-inference-2.rs new file mode 100644 index 00000000000..6557d7fa191 --- /dev/null +++ b/src/test/ui/type/type-check/point-at-inference-2.rs @@ -0,0 +1,13 @@ +fn bar(_: Vec<i32>) {} +fn baz(_: &Vec<&i32>) {} +fn main() { + let v = vec![&1]; + bar(v); //~ ERROR E0308 + let v = vec![]; + baz(&v); + baz(&v); + bar(v); //~ ERROR E0308 + let v = vec![]; + baz(&v); + bar(v); //~ ERROR E0308 +} diff --git a/src/test/ui/type/type-check/point-at-inference-2.stderr b/src/test/ui/type/type-check/point-at-inference-2.stderr new file mode 100644 index 00000000000..13227c5e245 --- /dev/null +++ b/src/test/ui/type/type-check/point-at-inference-2.stderr @@ -0,0 +1,56 @@ +error[E0308]: mismatched types + --> $DIR/point-at-inference-2.rs:5:9 + | +LL | bar(v); + | --- ^ expected `i32`, found `&{integer}` + | | + | arguments to this function are incorrect + | + = note: expected struct `Vec<i32>` + found struct `Vec<&{integer}>` +note: function defined here + --> $DIR/point-at-inference-2.rs:1:4 + | +LL | fn bar(_: Vec<i32>) {} + | ^^^ ----------- + +error[E0308]: mismatched types + --> $DIR/point-at-inference-2.rs:9:9 + | +LL | baz(&v); + | - here the type of `v` is inferred to be `Vec<&i32>` +LL | baz(&v); +LL | bar(v); + | --- ^ expected `i32`, found `&i32` + | | + | arguments to this function are incorrect + | + = note: expected struct `Vec<i32>` + found struct `Vec<&i32>` +note: function defined here + --> $DIR/point-at-inference-2.rs:1:4 + | +LL | fn bar(_: Vec<i32>) {} + | ^^^ ----------- + +error[E0308]: mismatched types + --> $DIR/point-at-inference-2.rs:12:9 + | +LL | baz(&v); + | - here the type of `v` is inferred to be `Vec<&i32>` +LL | bar(v); + | --- ^ expected `i32`, found `&i32` + | | + | arguments to this function are incorrect + | + = note: expected struct `Vec<i32>` + found struct `Vec<&i32>` +note: function defined here + --> $DIR/point-at-inference-2.rs:1:4 + | +LL | fn bar(_: Vec<i32>) {} + | ^^^ ----------- + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type/type-check/point-at-inference-3.fixed b/src/test/ui/type/type-check/point-at-inference-3.fixed new file mode 100644 index 00000000000..1a960133ceb --- /dev/null +++ b/src/test/ui/type/type-check/point-at-inference-3.fixed @@ -0,0 +1,12 @@ +// run-rustfix +fn main() { + let mut v = Vec::new(); + v.push(0i32); + //~^ NOTE this is of type `i32`, which causes `v` to be inferred as `Vec<i32>` + v.push(0); + v.push(1i32); //~ ERROR mismatched types + //~^ NOTE expected `i32`, found `u32` + //~| NOTE arguments to this method are incorrect + //~| NOTE associated function defined here + //~| HELP change the type of the numeric literal from `u32` to `i32` +} diff --git a/src/test/ui/type/type-check/point-at-inference-3.rs b/src/test/ui/type/type-check/point-at-inference-3.rs new file mode 100644 index 00000000000..92910ae1a31 --- /dev/null +++ b/src/test/ui/type/type-check/point-at-inference-3.rs @@ -0,0 +1,12 @@ +// run-rustfix +fn main() { + let mut v = Vec::new(); + v.push(0i32); + //~^ NOTE this is of type `i32`, which causes `v` to be inferred as `Vec<i32>` + v.push(0); + v.push(1u32); //~ ERROR mismatched types + //~^ NOTE expected `i32`, found `u32` + //~| NOTE arguments to this method are incorrect + //~| NOTE associated function defined here + //~| HELP change the type of the numeric literal from `u32` to `i32` +} diff --git a/src/test/ui/type/type-check/point-at-inference-3.stderr b/src/test/ui/type/type-check/point-at-inference-3.stderr new file mode 100644 index 00000000000..999c3148362 --- /dev/null +++ b/src/test/ui/type/type-check/point-at-inference-3.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/point-at-inference-3.rs:7:12 + | +LL | v.push(0i32); + | ---- this is of type `i32`, which causes `v` to be inferred as `Vec<i32>` +... +LL | v.push(1u32); + | ---- ^^^^ expected `i32`, found `u32` + | | + | arguments to this method are incorrect + | +note: associated function defined here + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL +help: change the type of the numeric literal from `u32` to `i32` + | +LL | v.push(1i32); + | ~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type/type-check/point-at-inference.fixed b/src/test/ui/type/type-check/point-at-inference.fixed new file mode 100644 index 00000000000..f41fbe59fba --- /dev/null +++ b/src/test/ui/type/type-check/point-at-inference.fixed @@ -0,0 +1,13 @@ +// run-rustfix +fn bar(_: Vec<i32>) {} +fn baz(_: &impl std::any::Any) {} +fn main() { + let v = vec![1, 2, 3, 4, 5]; + let mut foo = vec![]; + baz(&foo); + for i in &v { + foo.push(*i); + } + baz(&foo); + bar(foo); //~ ERROR E0308 +} diff --git a/src/test/ui/type/type-check/point-at-inference.rs b/src/test/ui/type/type-check/point-at-inference.rs new file mode 100644 index 00000000000..6419e42e70d --- /dev/null +++ b/src/test/ui/type/type-check/point-at-inference.rs @@ -0,0 +1,13 @@ +// run-rustfix +fn bar(_: Vec<i32>) {} +fn baz(_: &impl std::any::Any) {} +fn main() { + let v = vec![1, 2, 3, 4, 5]; + let mut foo = vec![]; + baz(&foo); + for i in &v { + foo.push(i); + } + baz(&foo); + bar(foo); //~ ERROR E0308 +} diff --git a/src/test/ui/type/type-check/point-at-inference.stderr b/src/test/ui/type/type-check/point-at-inference.stderr new file mode 100644 index 00000000000..70428fe841b --- /dev/null +++ b/src/test/ui/type/type-check/point-at-inference.stderr @@ -0,0 +1,26 @@ +error[E0308]: mismatched types + --> $DIR/point-at-inference.rs:12:9 + | +LL | foo.push(i); + | - this is of type `&{integer}`, which causes `foo` to be inferred as `Vec<&{integer}>` +... +LL | bar(foo); + | --- ^^^ expected `i32`, found `&{integer}` + | | + | arguments to this function are incorrect + | + = note: expected struct `Vec<i32>` + found struct `Vec<&{integer}>` +note: function defined here + --> $DIR/point-at-inference.rs:2:4 + | +LL | fn bar(_: Vec<i32>) {} + | ^^^ ----------- +help: consider dereferencing the borrow + | +LL | foo.push(*i); + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/typeck/issue-105946.rs b/src/test/ui/typeck/issue-105946.rs new file mode 100644 index 00000000000..bf01751d5f6 --- /dev/null +++ b/src/test/ui/typeck/issue-105946.rs @@ -0,0 +1,12 @@ +fn digit() -> str { + return {}; + //~^ ERROR: mismatched types [E0308] +} +fn main() { + let [_y..] = [box 1, box 2]; + //~^ ERROR: cannot find value `_y` in this scope [E0425] + //~| ERROR: `X..` patterns in slices are experimental [E0658] + //~| ERROR: box expression syntax is experimental; you can call `Box::new` instead [E0658] + //~| ERROR: box expression syntax is experimental; you can call `Box::new` instead [E0658] + //~| ERROR: pattern requires 1 element but array has 2 [E0527] +} diff --git a/src/test/ui/typeck/issue-105946.stderr b/src/test/ui/typeck/issue-105946.stderr new file mode 100644 index 00000000000..d803de4df47 --- /dev/null +++ b/src/test/ui/typeck/issue-105946.stderr @@ -0,0 +1,49 @@ +error[E0425]: cannot find value `_y` in this scope + --> $DIR/issue-105946.rs:6:10 + | +LL | let [_y..] = [box 1, box 2]; + | ^^ not found in this scope + +error[E0658]: `X..` patterns in slices are experimental + --> $DIR/issue-105946.rs:6:10 + | +LL | let [_y..] = [box 1, box 2]; + | ^^^^ + | + = note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information + = help: add `#![feature(half_open_range_patterns_in_slices)]` to the crate attributes to enable + +error[E0658]: box expression syntax is experimental; you can call `Box::new` instead + --> $DIR/issue-105946.rs:6:19 + | +LL | let [_y..] = [box 1, box 2]; + | ^^^^^ + | + = note: see issue #49733 <https://github.com/rust-lang/rust/issues/49733> for more information + = help: add `#![feature(box_syntax)]` to the crate attributes to enable + +error[E0658]: box expression syntax is experimental; you can call `Box::new` instead + --> $DIR/issue-105946.rs:6:26 + | +LL | let [_y..] = [box 1, box 2]; + | ^^^^^ + | + = note: see issue #49733 <https://github.com/rust-lang/rust/issues/49733> for more information + = help: add `#![feature(box_syntax)]` to the crate attributes to enable + +error[E0308]: mismatched types + --> $DIR/issue-105946.rs:2:10 + | +LL | return {}; + | ^^ expected `str`, found `()` + +error[E0527]: pattern requires 1 element but array has 2 + --> $DIR/issue-105946.rs:6:9 + | +LL | let [_y..] = [box 1, box 2]; + | ^^^^^^ expected 2 elements + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0308, E0425, E0527, E0658. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-18937-1.rs b/src/test/ui/typeck/issue-18937-1.rs index 57e56d832c6..57e56d832c6 100644 --- a/src/test/ui/issues/issue-18937-1.rs +++ b/src/test/ui/typeck/issue-18937-1.rs diff --git a/src/test/ui/issues/issue-18937.rs b/src/test/ui/typeck/issue-18937.rs index af85e5b2b02..af85e5b2b02 100644 --- a/src/test/ui/issues/issue-18937.rs +++ b/src/test/ui/typeck/issue-18937.rs diff --git a/src/test/ui/issues/issue-18937.stderr b/src/test/ui/typeck/issue-18937.stderr index 5e2ba0ef4fc..5e2ba0ef4fc 100644 --- a/src/test/ui/issues/issue-18937.stderr +++ b/src/test/ui/typeck/issue-18937.stderr diff --git a/src/test/ui/issues/issue-31173.rs b/src/test/ui/typeck/issue-31173.rs index f678df5b42b..f678df5b42b 100644 --- a/src/test/ui/issues/issue-31173.rs +++ b/src/test/ui/typeck/issue-31173.rs diff --git a/src/test/ui/issues/issue-31173.stderr b/src/test/ui/typeck/issue-31173.stderr index f3be99f9bcb..f3be99f9bcb 100644 --- a/src/test/ui/issues/issue-31173.stderr +++ b/src/test/ui/typeck/issue-31173.stderr diff --git a/src/test/ui/typeck/remove-extra-argument.fixed b/src/test/ui/typeck/remove-extra-argument.fixed index a9338c76cdc..d09306bf794 100644 --- a/src/test/ui/typeck/remove-extra-argument.fixed +++ b/src/test/ui/typeck/remove-extra-argument.fixed @@ -4,6 +4,6 @@ fn l(_a: Vec<u8>) {} fn main() { l(vec![]) - //~^ ERROR this function takes 1 argument but 2 arguments were supplied + //~^ ERROR function takes 1 argument but 2 arguments were supplied //~| HELP remove the extra argument } diff --git a/src/test/ui/typeck/remove-extra-argument.rs b/src/test/ui/typeck/remove-extra-argument.rs index 659cb8b267f..2181c37cee9 100644 --- a/src/test/ui/typeck/remove-extra-argument.rs +++ b/src/test/ui/typeck/remove-extra-argument.rs @@ -4,6 +4,6 @@ fn l(_a: Vec<u8>) {} fn main() { l(vec![], vec![]) - //~^ ERROR this function takes 1 argument but 2 arguments were supplied + //~^ ERROR function takes 1 argument but 2 arguments were supplied //~| HELP remove the extra argument } diff --git a/src/test/ui/ufcs/ufcs-qpath-missing-params.stderr b/src/test/ui/ufcs/ufcs-qpath-missing-params.stderr index a832964d220..d0ec47d6132 100644 --- a/src/test/ui/ufcs/ufcs-qpath-missing-params.stderr +++ b/src/test/ui/ufcs/ufcs-qpath-missing-params.stderr @@ -12,7 +12,7 @@ LL | pub trait IntoCow<'a, B: ?Sized> where B: ToOwned { help: add missing generic argument | LL | <String as IntoCow<B>>::into_cow("foo".to_string()); - | ~~~~~~~~~~ + | +++ error[E0107]: missing generics for trait `IntoCow` --> $DIR/ufcs-qpath-missing-params.rs:17:16 @@ -28,7 +28,7 @@ LL | pub trait IntoCow<'a, B: ?Sized> where B: ToOwned { help: add missing generic argument | LL | <String as IntoCow<B>>::into_cow::<str>("foo".to_string()); - | ~~~~~~~~~~ + | +++ error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied --> $DIR/ufcs-qpath-missing-params.rs:17:26 diff --git a/src/test/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr b/src/test/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr index 167479270b5..6d5dbca0558 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr @@ -2,12 +2,17 @@ error[E0644]: closure/generator type that references itself --> $DIR/unboxed-closure-no-cyclic-sig.rs:8:7 | LL | g(|_| { }); - | ^^^^^^^^ cyclic type of infinite size + | ^^^ cyclic type of infinite size | = note: closures cannot capture themselves or take themselves as argument; this error may be the result of a recent compiler bug-fix, see issue #46062 <https://github.com/rust-lang/rust/issues/46062> for more information +note: required by a bound in `g` + --> $DIR/unboxed-closure-no-cyclic-sig.rs:5:24 + | +LL | fn g<F>(_: F) where F: FnOnce(Option<F>) {} + | ^^^^^^^^^^^^^^^^^ required by this bound in `g` error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closure-region.rs b/src/test/ui/unboxed-closures/unboxed-closure-region.rs index f202492eda5..51fe118c93f 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-region.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-region.rs @@ -5,7 +5,7 @@ fn main() { let _f = { let x = 0; - || x //~ ERROR `x` does not live long enough + || x //~ ERROR closure may outlive the current block, but it borrows `x` }; _f; } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-region.stderr b/src/test/ui/unboxed-closures/unboxed-closure-region.stderr index b40b2f67d9b..43e9af24a7c 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-region.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-region.stderr @@ -1,16 +1,21 @@ -error[E0597]: `x` does not live long enough - --> $DIR/unboxed-closure-region.rs:8:12 +error[E0373]: closure may outlive the current block, but it borrows `x`, which is owned by the current block + --> $DIR/unboxed-closure-region.rs:8:9 | -LL | let _f = { - | -- borrow later stored here -LL | let x = 0; LL | || x - | -- ^ borrowed value does not live long enough + | ^^ - `x` is borrowed here | | - | value captured here -LL | }; - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` + | +note: block requires argument type to outlive `'1` + --> $DIR/unboxed-closure-region.rs:6:9 + | +LL | let _f = { + | ^^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | move || x + | ++++ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr index fe726cb49c7..f4d14b5f87b 100644 --- a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr +++ b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr @@ -3,6 +3,12 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here | LL | T: WithType<&u32> | ^ explicit lifetime name needed here + | +help: consider introducing a higher-ranked lifetime here with `for<'a>` + --> $DIR/where-clause-inherent-impl-ampersand.rs:13:8 + | +LL | T: WithType<&u32> + | ^ error: aborting due to previous error diff --git a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr index fe726cb49c7..f4d14b5f87b 100644 --- a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr +++ b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr @@ -3,6 +3,12 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here | LL | T: WithType<&u32> | ^ explicit lifetime name needed here + | +help: consider introducing a higher-ranked lifetime here with `for<'a>` + --> $DIR/where-clause-inherent-impl-ampersand.rs:13:8 + | +LL | T: WithType<&u32> + | ^ error: aborting due to previous error diff --git a/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr b/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr index fbd14de2107..63fc1a19b93 100644 --- a/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr +++ b/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr @@ -3,6 +3,12 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here | LL | T: WithType<&u32> | ^ explicit lifetime name needed here + | +help: consider introducing a higher-ranked lifetime here with `for<'a>` + --> $DIR/where-clause-trait-impl-region.rs:11:8 + | +LL | T: WithType<&u32> + | ^ error: aborting due to previous error diff --git a/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr b/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr index fbd14de2107..63fc1a19b93 100644 --- a/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr +++ b/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr @@ -3,6 +3,12 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here | LL | T: WithType<&u32> | ^ explicit lifetime name needed here + | +help: consider introducing a higher-ranked lifetime here with `for<'a>` + --> $DIR/where-clause-trait-impl-region.rs:11:8 + | +LL | T: WithType<&u32> + | ^ error: aborting due to previous error diff --git a/src/test/ui/unsafe/auxiliary/issue-106126.rs b/src/test/ui/unsafe/auxiliary/issue-106126.rs new file mode 100644 index 00000000000..091a3edb756 --- /dev/null +++ b/src/test/ui/unsafe/auxiliary/issue-106126.rs @@ -0,0 +1,9 @@ +#[macro_export] +macro_rules! foo { + () => { + unsafe fn __unsf() {} + unsafe fn __foo() { + __unsf(); + } + }; +} diff --git a/src/test/ui/unsafe/issue-106126-good-path-bug.rs b/src/test/ui/unsafe/issue-106126-good-path-bug.rs new file mode 100644 index 00000000000..93f478ee358 --- /dev/null +++ b/src/test/ui/unsafe/issue-106126-good-path-bug.rs @@ -0,0 +1,12 @@ +// Regression test for #106126. +// check-pass +// aux-build:issue-106126.rs + +#![deny(unsafe_op_in_unsafe_fn)] + +#[macro_use] +extern crate issue_106126; + +foo!(); + +fn main() {} diff --git a/src/test/ui/unsafe/unsafe-trait-impl.rs b/src/test/ui/unsafe/unsafe-trait-impl.rs index 03a251be1a9..1fc84ca0256 100644 --- a/src/test/ui/unsafe/unsafe-trait-impl.rs +++ b/src/test/ui/unsafe/unsafe-trait-impl.rs @@ -7,8 +7,8 @@ trait Foo { impl Foo for u32 { fn len(&self) -> u32 { *self } //~^ ERROR method `len` has an incompatible type for trait - //~| expected fn pointer `unsafe fn(&u32) -> _` - //~| found fn pointer `fn(&u32) -> _` + //~| expected signature `unsafe fn(&u32) -> _` + //~| found signature `fn(&u32) -> _` } fn main() { } diff --git a/src/test/ui/unsafe/unsafe-trait-impl.stderr b/src/test/ui/unsafe/unsafe-trait-impl.stderr index 8a0cba1fac5..18ba79404b7 100644 --- a/src/test/ui/unsafe/unsafe-trait-impl.stderr +++ b/src/test/ui/unsafe/unsafe-trait-impl.stderr @@ -9,8 +9,8 @@ note: type in trait | LL | unsafe fn len(&self) -> u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: expected fn pointer `unsafe fn(&u32) -> _` - found fn pointer `fn(&u32) -> _` + = note: expected signature `unsafe fn(&u32) -> _` + found signature `fn(&u32) -> _` error: aborting due to previous error diff --git a/src/test/ui/wf/issue-103573.stderr b/src/test/ui/wf/issue-103573.stderr index fcf3f15e4d3..5227badb77d 100644 --- a/src/test/ui/wf/issue-103573.stderr +++ b/src/test/ui/wf/issue-103573.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `<<Self as TraitC<E>>::TypeC<'a> as TraitB>::TypeB: TraitA` is not satisfied - --> $DIR/issue-103573.rs:18:5 + --> $DIR/issue-103573.rs:18:18 | LL | fn g<'a>(_: &<<Self::TypeC<'a> as TraitB>::TypeB as TraitA>::TypeA); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TraitA` is not implemented for `<<Self as TraitC<E>>::TypeC<'a> as TraitB>::TypeB` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TraitA` is not implemented for `<<Self as TraitC<E>>::TypeC<'a> as TraitB>::TypeB` | help: consider further restricting the associated type | diff --git a/src/test/ui/wf/wf-foreign-fn-decl-ret.stderr b/src/test/ui/wf/wf-foreign-fn-decl-ret.stderr index 78312a09105..b03023b5fd1 100644 --- a/src/test/ui/wf/wf-foreign-fn-decl-ret.stderr +++ b/src/test/ui/wf/wf-foreign-fn-decl-ret.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `(): Foo` is not satisfied - --> $DIR/wf-foreign-fn-decl-ret.rs:11:5 + --> $DIR/wf-foreign-fn-decl-ret.rs:11:25 | LL | pub fn lint_me() -> <() as Foo>::Assoc; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` + | ^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` error[E0277]: the trait bound `u32: Unsatisfied` is not satisfied --> $DIR/wf-foreign-fn-decl-ret.rs:14:32 diff --git a/src/test/ui/wrong-mul-method-signature.stderr b/src/test/ui/wrong-mul-method-signature.stderr index 8338f61b22a..504a6032b01 100644 --- a/src/test/ui/wrong-mul-method-signature.stderr +++ b/src/test/ui/wrong-mul-method-signature.stderr @@ -7,8 +7,8 @@ LL | fn mul(self, s: &f64) -> Vec1 { | expected `f64`, found `&f64` | help: change the parameter type to match the trait: `f64` | - = note: expected fn pointer `fn(Vec1, f64) -> Vec1` - found fn pointer `fn(Vec1, &f64) -> Vec1` + = note: expected signature `fn(Vec1, f64) -> Vec1` + found signature `fn(Vec1, &f64) -> Vec1` error[E0053]: method `mul` has an incompatible type for trait --> $DIR/wrong-mul-method-signature.rs:33:21 @@ -19,8 +19,8 @@ LL | fn mul(self, s: f64) -> Vec2 { | expected struct `Vec2`, found `f64` | help: change the parameter type to match the trait: `Vec2` | - = note: expected fn pointer `fn(Vec2, Vec2) -> f64` - found fn pointer `fn(Vec2, f64) -> Vec2` + = note: expected signature `fn(Vec2, Vec2) -> f64` + found signature `fn(Vec2, f64) -> Vec2` error[E0053]: method `mul` has an incompatible type for trait --> $DIR/wrong-mul-method-signature.rs:52:29 @@ -31,8 +31,8 @@ LL | fn mul(self, s: f64) -> f64 { | expected `i32`, found `f64` | help: change the output type to match the trait: `i32` | - = note: expected fn pointer `fn(Vec3, _) -> i32` - found fn pointer `fn(Vec3, _) -> f64` + = note: expected signature `fn(Vec3, _) -> i32` + found signature `fn(Vec3, _) -> f64` error[E0308]: mismatched types --> $DIR/wrong-mul-method-signature.rs:63:45 diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 0551e835bb0..21dad9eb74a 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -51,7 +51,7 @@ static TARGETS: &[&str] = &[ "aarch64-apple-darwin", "aarch64-apple-ios", "aarch64-apple-ios-sim", - "aarch64-fuchsia", + "aarch64-unknown-fuchsia", "aarch64-linux-android", "aarch64-pc-windows-msvc", "aarch64-unknown-hermit", @@ -138,7 +138,7 @@ static TARGETS: &[&str] = &[ "x86_64-apple-darwin", "x86_64-apple-ios", "x86_64-fortanix-unknown-sgx", - "x86_64-fuchsia", + "x86_64-unknown-fuchsia", "x86_64-linux-android", "x86_64-pc-windows-gnu", "x86_64-pc-windows-msvc", diff --git a/src/tools/build_helper/Cargo.toml b/src/tools/build_helper/Cargo.toml new file mode 100644 index 00000000000..99f6fea2ecf --- /dev/null +++ b/src/tools/build_helper/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "build_helper" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/build_helper/src/ci.rs b/src/tools/build_helper/src/ci.rs new file mode 100644 index 00000000000..9f113c72b93 --- /dev/null +++ b/src/tools/build_helper/src/ci.rs @@ -0,0 +1,40 @@ +use std::process::Command; + +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +pub enum CiEnv { + /// Not a CI environment. + None, + /// The Azure Pipelines environment, for Linux (including Docker), Windows, and macOS builds. + AzurePipelines, + /// The GitHub Actions environment, for Linux (including Docker), Windows and macOS builds. + GitHubActions, +} + +impl CiEnv { + /// Obtains the current CI environment. + pub fn current() -> CiEnv { + if std::env::var("TF_BUILD").map_or(false, |e| e == "True") { + CiEnv::AzurePipelines + } else if std::env::var("GITHUB_ACTIONS").map_or(false, |e| e == "true") { + CiEnv::GitHubActions + } else { + CiEnv::None + } + } + + pub fn is_ci() -> bool { + Self::current() != CiEnv::None + } + + /// If in a CI environment, forces the command to run with colors. + pub fn force_coloring_in_ci(self, cmd: &mut Command) { + if self != CiEnv::None { + // Due to use of stamp/docker, the output stream of rustbuild is not + // a TTY in CI, so coloring is by-default turned off. + // The explicit `TERM=xterm` environment is needed for + // `--color always` to actually work. This env var was lost when + // compiling through the Makefile. Very strange. + cmd.env("TERM", "xterm").args(&["--color", "always"]); + } + } +} diff --git a/src/tools/build_helper/src/git.rs b/src/tools/build_helper/src/git.rs new file mode 100644 index 00000000000..dc62051cb85 --- /dev/null +++ b/src/tools/build_helper/src/git.rs @@ -0,0 +1,75 @@ +use std::{path::Path, process::Command}; + +/// Finds the remote for rust-lang/rust. +/// For example for these remotes it will return `upstream`. +/// ```text +/// origin https://github.com/Nilstrieb/rust.git (fetch) +/// origin https://github.com/Nilstrieb/rust.git (push) +/// upstream https://github.com/rust-lang/rust (fetch) +/// upstream https://github.com/rust-lang/rust (push) +/// ``` +pub fn get_rust_lang_rust_remote(git_dir: Option<&Path>) -> Result<String, String> { + let mut git = Command::new("git"); + if let Some(git_dir) = git_dir { + git.current_dir(git_dir); + } + git.args(["config", "--local", "--get-regex", "remote\\..*\\.url"]); + + let output = git.output().map_err(|err| format!("{err:?}"))?; + if !output.status.success() { + return Err("failed to execute git config command".to_owned()); + } + + let stdout = String::from_utf8(output.stdout).map_err(|err| format!("{err:?}"))?; + + let rust_lang_remote = stdout + .lines() + .find(|remote| remote.contains("rust-lang")) + .ok_or_else(|| "rust-lang/rust remote not found".to_owned())?; + + let remote_name = + rust_lang_remote.split('.').nth(1).ok_or_else(|| "remote name not found".to_owned())?; + Ok(remote_name.into()) +} + +pub fn rev_exists(rev: &str, git_dir: Option<&Path>) -> Result<bool, String> { + let mut git = Command::new("git"); + if let Some(git_dir) = git_dir { + git.current_dir(git_dir); + } + git.args(["rev-parse", rev]); + let output = git.output().map_err(|err| format!("{err:?}"))?; + + match output.status.code() { + Some(0) => Ok(true), + Some(128) => Ok(false), + None => { + return Err(format!( + "git didn't exit properly: {}", + String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))? + )); + } + Some(code) => { + return Err(format!( + "git command exited with status code: {code}: {}", + String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))? + )); + } + } +} + +/// Returns the master branch from which we can take diffs to see changes. +/// This will usually be rust-lang/rust master, but sometimes this might not exist. +/// This could be because the user is updating their forked master branch using the GitHub UI +/// and therefore doesn't need an upstream master branch checked out. +/// We will then fall back to origin/master in the hope that at least this exists. +pub fn updated_master_branch(git_dir: Option<&Path>) -> Result<String, String> { + let upstream_remote = get_rust_lang_rust_remote(git_dir)?; + let upstream_master = format!("{upstream_remote}/master"); + if rev_exists(&upstream_master, git_dir)? { + return Ok(upstream_master); + } + + // We could implement smarter logic here in the future. + Ok("origin/master".into()) +} diff --git a/src/tools/build_helper/src/lib.rs b/src/tools/build_helper/src/lib.rs new file mode 100644 index 00000000000..d3d2323db85 --- /dev/null +++ b/src/tools/build_helper/src/lib.rs @@ -0,0 +1,2 @@ +pub mod ci; +pub mod git; diff --git a/src/tools/bump-stage0/src/main.rs b/src/tools/bump-stage0/src/main.rs index aa346daf7e5..530a80b1ed3 100644 --- a/src/tools/bump-stage0/src/main.rs +++ b/src/tools/bump-stage0/src/main.rs @@ -1,4 +1,4 @@ -use anyhow::Error; +use anyhow::{Context, Error}; use curl::easy::Easy; use indexmap::IndexMap; use std::collections::HashMap; @@ -13,12 +13,13 @@ struct Tool { comments: Vec<String>, channel: Channel, + date: Option<String>, version: [u16; 3], checksums: IndexMap<String, String>, } impl Tool { - fn new() -> Result<Self, Error> { + fn new(date: Option<String>) -> Result<Self, Error> { let channel = match std::fs::read_to_string("src/ci/channel")?.trim() { "stable" => Channel::Stable, "beta" => Channel::Beta, @@ -40,6 +41,7 @@ impl Tool { Ok(Self { channel, version, + date, config: existing.config, comments: existing.comments, checksums: IndexMap::new(), @@ -84,7 +86,7 @@ impl Tool { Channel::Nightly => "beta".to_string(), }; - let manifest = fetch_manifest(&self.config, &channel)?; + let manifest = fetch_manifest(&self.config, &channel, self.date.as_deref())?; self.collect_checksums(&manifest, COMPILER_COMPONENTS)?; Ok(Stage0Toolchain { date: manifest.date, @@ -110,7 +112,7 @@ impl Tool { return Ok(None); } - let manifest = fetch_manifest(&self.config, "nightly")?; + let manifest = fetch_manifest(&self.config, "nightly", self.date.as_deref())?; self.collect_checksums(&manifest, RUSTFMT_COMPONENTS)?; Ok(Some(Stage0Toolchain { date: manifest.date, version: "nightly".into() })) } @@ -141,16 +143,19 @@ impl Tool { } fn main() -> Result<(), Error> { - let tool = Tool::new()?; + let tool = Tool::new(std::env::args().nth(1))?; tool.update_json()?; Ok(()) } -fn fetch_manifest(config: &Config, channel: &str) -> Result<Manifest, Error> { - Ok(toml::from_slice(&http_get(&format!( - "{}/dist/channel-rust-{}.toml", - config.dist_server, channel - ))?)?) +fn fetch_manifest(config: &Config, channel: &str, date: Option<&str>) -> Result<Manifest, Error> { + let url = if let Some(date) = date { + format!("{}/dist/{}/channel-rust-{}.toml", config.dist_server, date, channel) + } else { + format!("{}/dist/channel-rust-{}.toml", config.dist_server, channel) + }; + + Ok(toml::from_slice(&http_get(&url)?)?) } fn http_get(url: &str) -> Result<Vec<u8>, Error> { @@ -164,7 +169,7 @@ fn http_get(url: &str) -> Result<Vec<u8>, Error> { data.extend_from_slice(new_data); Ok(new_data.len()) })?; - transfer.perform()?; + transfer.perform().context(format!("failed to fetch {url}"))?; } Ok(data) } diff --git a/src/tools/cargo b/src/tools/cargo -Subproject 2381cbdb4e9b07090f552d34a44a529b6e620e4 +Subproject 8c460b2237a6359a7e3335890db8da049bdd62f diff --git a/src/tools/clippy/clippy_lints/src/casts/cast_slice_different_sizes.rs b/src/tools/clippy/clippy_lints/src/casts/cast_slice_different_sizes.rs index c8e54d7b8e0..27cc5a1c3f0 100644 --- a/src/tools/clippy/clippy_lints/src/casts/cast_slice_different_sizes.rs +++ b/src/tools/clippy/clippy_lints/src/casts/cast_slice_different_sizes.rs @@ -68,7 +68,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: &Msrv fn is_child_of_cast(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { let map = cx.tcx.hir(); if_chain! { - if let Some(parent_id) = map.find_parent_node(expr.hir_id); + if let Some(parent_id) = map.opt_parent_id(expr.hir_id); if let Some(parent) = map.find(parent_id); then { let expr = match parent { diff --git a/src/tools/clippy/clippy_lints/src/escape.rs b/src/tools/clippy/clippy_lints/src/escape.rs index 1d09adec12f..dfb43893326 100644 --- a/src/tools/clippy/clippy_lints/src/escape.rs +++ b/src/tools/clippy/clippy_lints/src/escape.rs @@ -131,7 +131,7 @@ fn is_argument(map: rustc_middle::hir::map::Map<'_>, id: HirId) -> bool { _ => return false, } - matches!(map.find(map.get_parent_node(id)), Some(Node::Param(_))) + matches!(map.find_parent(id), Some(Node::Param(_))) } impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { @@ -156,8 +156,8 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { let map = &self.cx.tcx.hir(); if is_argument(*map, cmt.hir_id) { // Skip closure arguments - let parent_id = map.get_parent_node(cmt.hir_id); - if let Some(Node::Expr(..)) = map.find(map.get_parent_node(parent_id)) { + let parent_id = map.parent_id(cmt.hir_id); + if let Some(Node::Expr(..)) = map.find_parent(parent_id) { return; } diff --git a/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs b/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs index cf35b1f175c..bdeddf44df7 100644 --- a/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs +++ b/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs @@ -251,7 +251,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> { let map = cx.tcx.hir(); // Checking for slice indexing - let parent_id = map.get_parent_node(expr.hir_id); + let parent_id = map.parent_id(expr.hir_id); if let Some(hir::Node::Expr(parent_expr)) = map.find(parent_id); if let hir::ExprKind::Index(_, index_expr) = parent_expr.kind; if let Some((Constant::Int(index_value), _)) = constant(cx, cx.typeck_results(), index_expr); @@ -259,7 +259,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> { if index_value < max_suggested_slice; // Make sure that this slice index is read only - let maybe_addrof_id = map.get_parent_node(parent_id); + let maybe_addrof_id = map.parent_id(parent_id); if let Some(hir::Node::Expr(maybe_addrof_expr)) = map.find(maybe_addrof_id); if let hir::ExprKind::AddrOf(_kind, hir::Mutability::Not, _inner_expr) = maybe_addrof_expr.kind; then { diff --git a/src/tools/clippy/clippy_lints/src/loops/same_item_push.rs b/src/tools/clippy/clippy_lints/src/loops/same_item_push.rs index 07edee46fa6..540656a2cd9 100644 --- a/src/tools/clippy/clippy_lints/src/loops/same_item_push.rs +++ b/src/tools/clippy/clippy_lints/src/loops/same_item_push.rs @@ -63,7 +63,7 @@ pub(super) fn check<'tcx>( if let Node::Pat(pat) = node; if let PatKind::Binding(bind_ann, ..) = pat.kind; if !matches!(bind_ann, BindingAnnotation(_, Mutability::Mut)); - let parent_node = cx.tcx.hir().get_parent_node(hir_id); + let parent_node = cx.tcx.hir().parent_id(hir_id); if let Some(Node::Local(parent_let_expr)) = cx.tcx.hir().find(parent_node); if let Some(init) = parent_let_expr.init; then { diff --git a/src/tools/clippy/clippy_lints/src/manual_rem_euclid.rs b/src/tools/clippy/clippy_lints/src/manual_rem_euclid.rs index 8d447c37150..38f41d077c1 100644 --- a/src/tools/clippy/clippy_lints/src/manual_rem_euclid.rs +++ b/src/tools/clippy/clippy_lints/src/manual_rem_euclid.rs @@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualRemEuclid { && let Some(hir_id) = path_to_local(expr3) && let Some(Node::Pat(_)) = cx.tcx.hir().find(hir_id) { // Apply only to params or locals with annotated types - match cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { + match cx.tcx.hir().find_parent(hir_id) { Some(Node::Param(..)) => (), Some(Node::Local(local)) => { let Some(ty) = local.ty else { return }; diff --git a/src/tools/clippy/clippy_lints/src/matches/match_single_binding.rs b/src/tools/clippy/clippy_lints/src/matches/match_single_binding.rs index c94a1f76330..065a5c72621 100644 --- a/src/tools/clippy/clippy_lints/src/matches/match_single_binding.rs +++ b/src/tools/clippy/clippy_lints/src/matches/match_single_binding.rs @@ -140,8 +140,8 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e fn opt_parent_assign_span<'a>(cx: &LateContext<'a>, ex: &Expr<'a>) -> Option<AssignmentExpr> { let map = &cx.tcx.hir(); - if let Some(Node::Expr(parent_arm_expr)) = map.find(map.get_parent_node(ex.hir_id)) { - return match map.find(map.get_parent_node(parent_arm_expr.hir_id)) { + if let Some(Node::Expr(parent_arm_expr)) = map.find_parent(ex.hir_id) { + return match map.find_parent(parent_arm_expr.hir_id) { Some(Node::Local(parent_let_expr)) => Some(AssignmentExpr::Local { span: parent_let_expr.span, pat_span: parent_let_expr.pat.span(), @@ -183,8 +183,7 @@ fn sugg_with_curlies<'a>( // If the parent is already an arm, and the body is another match statement, // we need curly braces around suggestion - let parent_node_id = cx.tcx.hir().get_parent_node(match_expr.hir_id); - if let Node::Arm(arm) = &cx.tcx.hir().get(parent_node_id) { + if let Node::Arm(arm) = &cx.tcx.hir().get_parent(match_expr.hir_id) { if let ExprKind::Match(..) = arm.body.kind { cbrace_end = format!("\n{indent}}}"); // Fix body indent due to the match diff --git a/src/tools/clippy/clippy_lints/src/mixed_read_write_in_expression.rs b/src/tools/clippy/clippy_lints/src/mixed_read_write_in_expression.rs index 321fa4b7f99..f0be7771bb1 100644 --- a/src/tools/clippy/clippy_lints/src/mixed_read_write_in_expression.rs +++ b/src/tools/clippy/clippy_lints/src/mixed_read_write_in_expression.rs @@ -186,7 +186,7 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) { let map = &vis.cx.tcx.hir(); let mut cur_id = vis.write_expr.hir_id; loop { - let parent_id = map.get_parent_node(cur_id); + let parent_id = map.parent_id(cur_id); if parent_id == cur_id { break; } diff --git a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs index 2f0b7ce16e5..1249db5dc47 100644 --- a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs +++ b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs @@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { } // Exclude non-inherent impls - if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { + if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) { if matches!( item.kind, ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..) diff --git a/src/tools/clippy/clippy_lints/src/non_copy_const.rs b/src/tools/clippy/clippy_lints/src/non_copy_const.rs index 2a3bd4ee6ce..07fd321d69f 100644 --- a/src/tools/clippy/clippy_lints/src/non_copy_const.rs +++ b/src/tools/clippy/clippy_lints/src/non_copy_const.rs @@ -366,7 +366,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst { let mut dereferenced_expr = expr; let mut needs_check_adjustment = true; loop { - let parent_id = cx.tcx.hir().get_parent_node(cur_expr.hir_id); + let parent_id = cx.tcx.hir().parent_id(cur_expr.hir_id); if parent_id == cur_expr.hir_id { break; } diff --git a/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs b/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs index 75add4ee4aa..870a1c7d88d 100644 --- a/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs +++ b/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs @@ -299,7 +299,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue { } // Exclude non-inherent impls - if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { + if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) { if matches!( item.kind, ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..) diff --git a/src/tools/clippy/clippy_lints/src/unit_types/unit_arg.rs b/src/tools/clippy/clippy_lints/src/unit_types/unit_arg.rs index ef9f740f704..dd120599c04 100644 --- a/src/tools/clippy/clippy_lints/src/unit_types/unit_arg.rs +++ b/src/tools/clippy/clippy_lints/src/unit_types/unit_arg.rs @@ -21,7 +21,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { return; } let map = &cx.tcx.hir(); - let opt_parent_node = map.find(map.get_parent_node(expr.hir_id)); + let opt_parent_node = map.find_parent(expr.hir_id); if_chain! { if let Some(hir::Node::Expr(parent_expr)) = opt_parent_node; if is_questionmark_desugar_marked_call(parent_expr); @@ -192,7 +192,7 @@ fn fmt_stmts_and_call( let mut stmts_and_call_snippet = stmts_and_call.join(&format!("{}{}", ";\n", " ".repeat(call_expr_indent))); // expr is not in a block statement or result expression position, wrap in a block - let parent_node = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(call_expr.hir_id)); + let parent_node = cx.tcx.hir().find_parent(call_expr.hir_id); if !matches!(parent_node, Some(Node::Block(_))) && !matches!(parent_node, Some(Node::Stmt(_))) { let block_indent = call_expr_indent + 4; stmts_and_call_snippet = diff --git a/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs b/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs index 60b46854b4f..84ec0d0fb1c 100644 --- a/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs +++ b/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs @@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps { } // Abort if the method is implementing a trait or of it a trait method. - if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { + if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) { if matches!( item.kind, ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..) diff --git a/src/tools/clippy/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/src/tools/clippy/clippy_lints/src/utils/internal_lints/metadata_collector.rs index 929544cd69d..c86f24cbd37 100644 --- a/src/tools/clippy/clippy_lints/src/utils/internal_lints/metadata_collector.rs +++ b/src/tools/clippy/clippy_lints/src/utils/internal_lints/metadata_collector.rs @@ -1058,7 +1058,7 @@ fn get_parent_local<'hir>(cx: &LateContext<'hir>, expr: &'hir hir::Expr<'hir>) - fn get_parent_local_hir_id<'hir>(cx: &LateContext<'hir>, hir_id: hir::HirId) -> Option<&'hir hir::Local<'hir>> { let map = cx.tcx.hir(); - match map.find(map.get_parent_node(hir_id)) { + match map.find_parent((hir_id)) { Some(hir::Node::Local(local)) => Some(local), Some(hir::Node::Pat(pattern)) => get_parent_local_hir_id(cx, pattern.hir_id), _ => None, diff --git a/src/tools/clippy/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs b/src/tools/clippy/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs index 393988dbad3..7144363637a 100644 --- a/src/tools/clippy/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs +++ b/src/tools/clippy/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs @@ -219,7 +219,7 @@ fn path_to_matched_type(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option<Ve match peel_hir_expr_refs(expr).0.kind { ExprKind::Path(ref qpath) => match cx.qpath_res(qpath, expr.hir_id) { Res::Local(hir_id) => { - let parent_id = cx.tcx.hir().get_parent_node(hir_id); + let parent_id = cx.tcx.hir().parent_id(hir_id); if let Some(Node::Local(Local { init: Some(init), .. })) = cx.tcx.hir().find(parent_id) { path_to_matched_type(cx, init) } else { diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index d863609b6a7..8290fe9ecb4 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -174,7 +174,7 @@ pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option< if_chain! { if let Some(Node::Pat(pat)) = hir.find(hir_id); if matches!(pat.kind, PatKind::Binding(BindingAnnotation::NONE, ..)); - let parent = hir.get_parent_node(hir_id); + let parent = hir.parent_id(hir_id); if let Some(Node::Local(local)) = hir.find(parent); then { return local.init; @@ -1287,7 +1287,7 @@ pub fn contains_return(expr: &hir::Expr<'_>) -> bool { /// Gets the parent node, if any. pub fn get_parent_node(tcx: TyCtxt<'_>, id: HirId) -> Option<Node<'_>> { - tcx.hir().parent_iter(id).next().map(|(_, node)| node) + tcx.hir().find_parent(id) } /// Gets the parent expression, if any –- this is useful to constrain a lint. @@ -2075,7 +2075,7 @@ pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool { /// } /// ``` pub fn is_trait_impl_item(cx: &LateContext<'_>, hir_id: HirId) -> bool { - if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { + if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) { matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. })) } else { false diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 7a3c0d28fc3..7e48dd20660 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2011,7 +2011,7 @@ impl<'test> TestCx<'test> { rustc.args(&["-Zpolonius"]); } Some(CompareMode::Chalk) => { - rustc.args(&["-Zchalk"]); + rustc.args(&["-Ztrait-solver=chalk"]); } Some(CompareMode::SplitDwarf) if self.config.target.contains("windows") => { rustc.args(&["-Csplit-debuginfo=unpacked", "-Zunstable-options"]); diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index ccba313ee35..6c63b760ff6 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -11,7 +11,7 @@ mod tests; pub const ASAN_SUPPORTED_TARGETS: &[&str] = &[ "aarch64-apple-darwin", - "aarch64-fuchsia", + "aarch64-unknown-fuchsia", "aarch64-linux-android", "aarch64-unknown-linux-gnu", "arm-linux-androideabi", @@ -19,7 +19,7 @@ pub const ASAN_SUPPORTED_TARGETS: &[&str] = &[ "i686-linux-android", "i686-unknown-linux-gnu", "x86_64-apple-darwin", - "x86_64-fuchsia", + "x86_64-unknown-fuchsia", "x86_64-linux-android", "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu", @@ -28,12 +28,12 @@ pub const ASAN_SUPPORTED_TARGETS: &[&str] = &[ // FIXME(rcvalle): More targets are likely supported. pub const CFI_SUPPORTED_TARGETS: &[&str] = &[ "aarch64-apple-darwin", - "aarch64-fuchsia", + "aarch64-unknown-fuchsia", "aarch64-linux-android", "aarch64-unknown-freebsd", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", - "x86_64-fuchsia", + "x86_64-unknown-fuchsia", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", diff --git a/src/tools/error_index_generator/book_config.toml b/src/tools/error_index_generator/book_config.toml index 885100ae3a4..2701ad917bb 100644 --- a/src/tools/error_index_generator/book_config.toml +++ b/src/tools/error_index_generator/book_config.toml @@ -7,6 +7,7 @@ src = "" git-repository-url = "https://github.com/rust-lang/rust/" additional-css = ["error-index.css"] additional-js = ["error-index.js"] +input-404 = "" [output.html.search] enable = true diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index 1bde8e00782..98eda97e236 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -98,8 +98,7 @@ fn add_rust_attribute_on_codeblock(explanation: &str) -> String { fn render_html(output_path: &Path) -> Result<(), Box<dyn Error>> { let mut introduction = format!( - "<script src='redirect.js'></script> -# Rust error codes index + "# Rust error codes index This page lists all the error codes emitted by the Rust compiler. @@ -149,7 +148,12 @@ This page lists all the error codes emitted by the Rust compiler. book.book.sections.push(BookItem::Chapter(chapter)); book.build()?; - // We can't put this content into another file, otherwise `mbdbook` will also put it into the + // The error-index used to be generated manually (without mdbook), and the + // index was located at the top level. Now that it is generated with + // mdbook, error-index.html has moved to error_codes/error-index.html. + // This adds a redirect so that old links go to the new location. + // + // We can't put this content into another file, otherwise `mdbook` will also put it into the // output directory, making a duplicate. fs::write( output_path.join("error-index.html"), @@ -163,14 +167,10 @@ This page lists all the error codes emitted by the Rust compiler. </head> <body> <div>If you are not automatically redirected to the error code index, please <a id="index-link" href="./error_codes/error-index.html">here</a>. - <script>document.getElementById("index-link").click()</script> </body> </html>"#, )?; - // No need for a 404 file, it's already handled by the server. - fs::remove_file(output_path.join("error_codes/404.html"))?; - Ok(()) } diff --git a/src/tools/error_index_generator/redirect.js b/src/tools/error_index_generator/redirect.js index 8c907f5795d..c80cbf297af 100644 --- a/src/tools/error_index_generator/redirect.js +++ b/src/tools/error_index_generator/redirect.js @@ -3,14 +3,10 @@ let code = window.location.hash.replace(/^#/, ''); // We have to make sure this pattern matches to avoid inadvertently creating an // open redirect. - if (!/^E[0-9]+$/.test(code)) { + if (/^E[0-9]+$/.test(code)) { + window.location.replace('./error_codes/' + code + '.html'); return; } - if (window.location.pathname.indexOf("/error_codes/") !== -1) { - // We're not at the top level, so we don't prepend with "./error_codes/". - window.location = './' + code + '.html'; - } else { - window.location = './error_codes/' + code + '.html'; - } } + window.location.replace('./error_codes/error-index.html'); })() diff --git a/src/tools/jsondoclint/Cargo.toml b/src/tools/jsondoclint/Cargo.toml index 84a6c7f96c4..8990310a4f4 100644 --- a/src/tools/jsondoclint/Cargo.toml +++ b/src/tools/jsondoclint/Cargo.toml @@ -7,6 +7,8 @@ edition = "2021" [dependencies] anyhow = "1.0.62" +clap = { version = "4.0.15", features = ["derive"] } fs-err = "2.8.1" rustdoc-json-types = { version = "0.1.0", path = "../../rustdoc-json-types" } +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.85" diff --git a/src/tools/jsondoclint/src/json_find.rs b/src/tools/jsondoclint/src/json_find.rs index 70e7440f730..a183c4068ce 100644 --- a/src/tools/jsondoclint/src/json_find.rs +++ b/src/tools/jsondoclint/src/json_find.rs @@ -1,8 +1,9 @@ use std::fmt::Write; +use serde::Serialize; use serde_json::Value; -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] pub enum SelectorPart { Field(String), Index(usize), diff --git a/src/tools/jsondoclint/src/main.rs b/src/tools/jsondoclint/src/main.rs index fc54c421b4b..05e938f4f7d 100644 --- a/src/tools/jsondoclint/src/main.rs +++ b/src/tools/jsondoclint/src/main.rs @@ -1,59 +1,103 @@ -use std::env; +use std::io::{BufWriter, Write}; -use anyhow::{anyhow, bail, Result}; +use anyhow::{bail, Result}; +use clap::Parser; use fs_err as fs; use rustdoc_json_types::{Crate, Id, FORMAT_VERSION}; +use serde::Serialize; use serde_json::Value; pub(crate) mod item_kind; mod json_find; mod validator; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Serialize, Clone)] struct Error { kind: ErrorKind, id: Id, } -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Serialize, Clone)] enum ErrorKind { - NotFound, + NotFound(Vec<json_find::Selector>), Custom(String), } +#[derive(Debug, Serialize)] +struct JsonOutput { + path: String, + errors: Vec<Error>, +} + +#[derive(Parser)] +struct Cli { + /// The path to the json file to be linted + path: String, + + /// Show verbose output + #[arg(long)] + verbose: bool, + + #[arg(long)] + json_output: Option<String>, +} + fn main() -> Result<()> { - let path = env::args().nth(1).ok_or_else(|| anyhow!("no path given"))?; + let Cli { path, verbose, json_output } = Cli::parse(); + let contents = fs::read_to_string(&path)?; let krate: Crate = serde_json::from_str(&contents)?; assert_eq!(krate.format_version, FORMAT_VERSION); - let mut validator = validator::Validator::new(&krate); + let krate_json: Value = serde_json::from_str(&contents)?; + + let mut validator = validator::Validator::new(&krate, krate_json); validator.check_crate(); + if let Some(json_output) = json_output { + let output = JsonOutput { path: path.clone(), errors: validator.errs.clone() }; + let mut f = BufWriter::new(fs::File::create(json_output)?); + serde_json::to_writer(&mut f, &output)?; + f.flush()?; + } + if !validator.errs.is_empty() { for err in validator.errs { match err.kind { - ErrorKind::NotFound => { - let krate_json: Value = serde_json::from_str(&contents)?; - - let sels = - json_find::find_selector(&krate_json, &Value::String(err.id.0.clone())); - match &sels[..] { - [] => unreachable!( - "id must be in crate, or it wouldn't be reported as not found" - ), - [sel] => eprintln!( - "{} not in index or paths, but refered to at '{}'", - err.id.0, - json_find::to_jsonpath(&sel) - ), - [sel, ..] => eprintln!( - "{} not in index or paths, but refered to at '{}' and more", - err.id.0, - json_find::to_jsonpath(&sel) - ), + ErrorKind::NotFound(sels) => match &sels[..] { + [] => { + unreachable!( + "id {:?} must be in crate, or it wouldn't be reported as not found", + err.id + ) + } + [sel] => eprintln!( + "{} not in index or paths, but refered to at '{}'", + err.id.0, + json_find::to_jsonpath(&sel) + ), + [sel, ..] => { + if verbose { + let sels = sels + .iter() + .map(json_find::to_jsonpath) + .map(|i| format!("'{i}'")) + .collect::<Vec<_>>() + .join(", "); + eprintln!( + "{} not in index or paths, but refered to at {sels}", + err.id.0 + ); + } else { + eprintln!( + "{} not in index or paths, but refered to at '{}' and {} more", + err.id.0, + json_find::to_jsonpath(&sel), + sels.len() - 1, + ) + } } - } + }, ErrorKind::Custom(msg) => eprintln!("{}: {}", err.id.0, msg), } } diff --git a/src/tools/jsondoclint/src/validator.rs b/src/tools/jsondoclint/src/validator.rs index 291d02d67bd..c6f55410e44 100644 --- a/src/tools/jsondoclint/src/validator.rs +++ b/src/tools/jsondoclint/src/validator.rs @@ -3,12 +3,16 @@ use std::hash::Hash; use rustdoc_json_types::{ Constant, Crate, DynTrait, Enum, FnDecl, Function, FunctionPointer, GenericArg, GenericArgs, - GenericBound, GenericParamDef, Generics, Id, Impl, Import, ItemEnum, Module, OpaqueTy, Path, - Primitive, ProcMacro, Static, Struct, StructKind, Term, Trait, TraitAlias, Type, TypeBinding, - TypeBindingKind, Typedef, Union, Variant, VariantKind, WherePredicate, + GenericBound, GenericParamDef, Generics, Id, Impl, Import, ItemEnum, ItemSummary, Module, + OpaqueTy, Path, Primitive, ProcMacro, Static, Struct, StructKind, Term, Trait, TraitAlias, + Type, TypeBinding, TypeBindingKind, Typedef, Union, Variant, VariantKind, WherePredicate, }; +use serde_json::Value; -use crate::{item_kind::Kind, Error, ErrorKind}; +use crate::{item_kind::Kind, json_find, Error, ErrorKind}; + +// This is a rustc implementation detail that we rely on here +const LOCAL_CRATE_ID: u32 = 0; /// The Validator walks over the JSON tree, and ensures it is well formed. /// It is made of several parts. @@ -22,6 +26,7 @@ use crate::{item_kind::Kind, Error, ErrorKind}; pub struct Validator<'a> { pub(crate) errs: Vec<Error>, krate: &'a Crate, + krate_json: Value, /// Worklist of Ids to check. todo: HashSet<&'a Id>, /// Ids that have already been visited, so don't need to be checked again. @@ -39,9 +44,10 @@ enum PathKind { } impl<'a> Validator<'a> { - pub fn new(krate: &'a Crate) -> Self { + pub fn new(krate: &'a Crate, krate_json: Value) -> Self { Self { krate, + krate_json, errs: Vec::new(), seen_ids: HashSet::new(), todo: HashSet::new(), @@ -50,12 +56,19 @@ impl<'a> Validator<'a> { } pub fn check_crate(&mut self) { + // Graph traverse the index let root = &self.krate.root; self.add_mod_id(root); while let Some(id) = set_remove(&mut self.todo) { self.seen_ids.insert(id); self.check_item(id); } + + let root_crate_id = self.krate.index[root].crate_id; + assert_eq!(root_crate_id, LOCAL_CRATE_ID, "LOCAL_CRATE_ID is wrong"); + for (id, item_info) in &self.krate.paths { + self.check_item_info(id, item_info); + } } fn check_item(&mut self, id: &'a Id) { @@ -361,6 +374,19 @@ impl<'a> Validator<'a> { fp.generic_params.iter().for_each(|gpd| self.check_generic_param_def(gpd)); } + fn check_item_info(&mut self, id: &Id, item_info: &ItemSummary) { + // FIXME: Their should be a better way to determine if an item is local, rather than relying on `LOCAL_CRATE_ID`, + // which encodes rustc implementation details. + if item_info.crate_id == LOCAL_CRATE_ID && !self.krate.index.contains_key(id) { + self.errs.push(Error { + id: id.clone(), + kind: ErrorKind::Custom( + "Id for local item in `paths` but not in `index`".to_owned(), + ), + }) + } + } + fn add_id_checked(&mut self, id: &'a Id, valid: fn(Kind) -> bool, expected: &str) { if let Some(kind) = self.kind_of(id) { if valid(kind) { @@ -373,7 +399,11 @@ impl<'a> Validator<'a> { } else { if !self.missing_ids.contains(id) { self.missing_ids.insert(id); - self.fail(id, ErrorKind::NotFound) + + let sels = json_find::find_selector(&self.krate_json, &Value::String(id.0.clone())); + assert_ne!(sels.len(), 0); + + self.fail(id, ErrorKind::NotFound(sels)) } } } diff --git a/src/tools/jsondoclint/src/validator/tests.rs b/src/tools/jsondoclint/src/validator/tests.rs index c4aeee9c53b..1ef41ff123a 100644 --- a/src/tools/jsondoclint/src/validator/tests.rs +++ b/src/tools/jsondoclint/src/validator/tests.rs @@ -1,12 +1,17 @@ use std::collections::HashMap; -use rustdoc_json_types::{Crate, Item, Visibility}; +use rustdoc_json_types::{Crate, Item, ItemKind, ItemSummary, Visibility, FORMAT_VERSION}; + +use crate::json_find::SelectorPart; use super::*; #[track_caller] fn check(krate: &Crate, errs: &[Error]) { - let mut validator = Validator::new(krate); + let krate_string = serde_json::to_string(krate).unwrap(); + let krate_json = serde_json::from_str(&krate_string).unwrap(); + + let mut validator = Validator::new(krate, krate_json); validator.check_crate(); assert_eq!(errs, &validator.errs[..]); @@ -46,5 +51,114 @@ fn errors_on_missing_links() { format_version: rustdoc_json_types::FORMAT_VERSION, }; - check(&k, &[Error { kind: ErrorKind::NotFound, id: id("1") }]); + check( + &k, + &[Error { + kind: ErrorKind::NotFound(vec![vec![ + SelectorPart::Field("index".to_owned()), + SelectorPart::Field("0".to_owned()), + SelectorPart::Field("links".to_owned()), + SelectorPart::Field("Not Found".to_owned()), + ]]), + id: id("1"), + }], + ); +} + +// Test we would catch +// https://github.com/rust-lang/rust/issues/104064#issuecomment-1368589718 +#[test] +fn errors_on_local_in_paths_and_not_index() { + let krate = Crate { + root: id("0:0:1572"), + crate_version: None, + includes_private: false, + index: HashMap::from_iter([ + ( + id("0:0:1572"), + Item { + id: id("0:0:1572"), + crate_id: 0, + name: Some("microcore".to_owned()), + span: None, + visibility: Visibility::Public, + docs: None, + links: HashMap::from_iter([(("prim@i32".to_owned(), id("0:1:1571")))]), + attrs: Vec::new(), + deprecation: None, + inner: ItemEnum::Module(Module { + is_crate: true, + items: vec![id("0:1:717")], + is_stripped: false, + }), + }, + ), + ( + id("0:1:717"), + Item { + id: id("0:1:717"), + crate_id: 0, + name: Some("i32".to_owned()), + span: None, + visibility: Visibility::Public, + docs: None, + links: HashMap::default(), + attrs: Vec::new(), + deprecation: None, + inner: ItemEnum::Primitive(Primitive { name: "i32".to_owned(), impls: vec![] }), + }, + ), + ]), + paths: HashMap::from_iter([( + id("0:1:1571"), + ItemSummary { + crate_id: 0, + path: vec!["microcore".to_owned(), "i32".to_owned()], + kind: ItemKind::Primitive, + }, + )]), + external_crates: HashMap::default(), + format_version: rustdoc_json_types::FORMAT_VERSION, + }; + + check( + &krate, + &[Error { + id: id("0:1:1571"), + kind: ErrorKind::Custom("Id for local item in `paths` but not in `index`".to_owned()), + }], + ); +} + +#[test] +#[should_panic = "LOCAL_CRATE_ID is wrong"] +fn checks_local_crate_id_is_correct() { + let krate = Crate { + root: id("root"), + crate_version: None, + includes_private: false, + index: HashMap::from_iter([( + id("root"), + Item { + id: id("root"), + crate_id: LOCAL_CRATE_ID.wrapping_add(1), + name: Some("irrelavent".to_owned()), + span: None, + visibility: Visibility::Public, + docs: None, + links: HashMap::default(), + attrs: Vec::new(), + deprecation: None, + inner: ItemEnum::Module(Module { + is_crate: true, + items: vec![], + is_stripped: false, + }), + }, + )]), + paths: HashMap::default(), + external_crates: HashMap::default(), + format_version: FORMAT_VERSION, + }; + check(&krate, &[]); } diff --git a/src/tools/rustc-workspace-hack/Cargo.toml b/src/tools/rustc-workspace-hack/Cargo.toml index a5f0c0f320a..84b16a37a33 100644 --- a/src/tools/rustc-workspace-hack/Cargo.toml +++ b/src/tools/rustc-workspace-hack/Cargo.toml @@ -77,6 +77,8 @@ clap = { version = "3.1.1", features = ["derive", "clap_derive"]} curl-sys = { version = "0.4.13", features = ["http2", "libnghttp2-sys"], optional = true } # Ensure `extra_traits` of libc, which is used transitively by Cargo. libc = { version = "0.2", features = ["extra_traits"] } +# Ensure `js` of getrandom, which is (unfortunately) used transitively by Cargo. +getrandom = { version = "0.2", features = ["js"] } # Ensure default features of libz-sys, which are disabled in some scenarios. libz-sys = { version = "1.1.2" } # Ensure default features of regex, which are disabled in some scenarios. diff --git a/src/tools/rustdoc-gui/tester.js b/src/tools/rustdoc-gui/tester.js index d40d9a3cb54..900ca389436 100644 --- a/src/tools/rustdoc-gui/tester.js +++ b/src/tools/rustdoc-gui/tester.js @@ -9,6 +9,9 @@ const path = require("path"); const os = require('os'); const {Options, runTest} = require('browser-ui-test'); +// If a test fails or errors, we will retry it two more times in case it was a flaky failure. +const NB_RETRY = 3; + function showHelp() { console.log("rustdoc-js options:"); console.log(" --doc-folder [PATH] : location of the generated doc folder"); @@ -129,11 +132,59 @@ function char_printer(n_tests) { }; } -/// Sort array by .file_name property +// Sort array by .file_name property function by_filename(a, b) { return a.file_name - b.file_name; } +async function runTests(opts, framework_options, files, results, status_bar, showTestFailures) { + const tests_queue = []; + + for (const testPath of files) { + const callback = runTest(testPath, framework_options) + .then(out => { + const [output, nb_failures] = out; + results[nb_failures === 0 ? "successful" : "failed"].push({ + file_name: testPath, + output: output, + }); + if (nb_failures === 0) { + status_bar.successful(); + } else if (showTestFailures) { + status_bar.erroneous(); + } + }) + .catch(err => { + results.errored.push({ + file_name: testPath, + output: err, + }); + if (showTestFailures) { + status_bar.erroneous(); + } + }) + .finally(() => { + // We now remove the promise from the tests_queue. + tests_queue.splice(tests_queue.indexOf(callback), 1); + }); + tests_queue.push(callback); + if (opts["jobs"] > 0 && tests_queue.length >= opts["jobs"]) { + await Promise.race(tests_queue); + } + } + if (tests_queue.length > 0) { + await Promise.all(tests_queue); + } +} + +function createEmptyResults() { + return { + successful: [], + failed: [], + errored: [], + }; +} + async function main(argv) { let opts = parseOptions(argv.slice(2)); if (opts === null) { @@ -144,7 +195,7 @@ async function main(argv) { let debug = false; // Run tests in sequentially let headless = true; - const options = new Options(); + const framework_options = new Options(); try { // This is more convenient that setting fields one by one. let args = [ @@ -169,13 +220,12 @@ async function main(argv) { args.push("--executable-path"); args.push(opts["executable_path"]); } - options.parseArguments(args); + framework_options.parseArguments(args); } catch (error) { console.error(`invalid argument: ${error}`); process.exit(1); } - let failed = false; let files; if (opts["files"].length === 0) { files = fs.readdirSync(opts["tests_folder"]); @@ -187,6 +237,9 @@ async function main(argv) { console.error("rustdoc-gui: No test selected"); process.exit(2); } + files.forEach((file_name, index) => { + files[index] = path.join(opts["tests_folder"], file_name); + }); files.sort(); if (!headless) { @@ -215,52 +268,29 @@ async function main(argv) { }; process.on('exit', exitHandling); - const tests_queue = []; - let results = { - successful: [], - failed: [], - errored: [], - }; + const originalFilesLen = files.length; + let results = createEmptyResults(); const status_bar = char_printer(files.length); - for (let i = 0; i < files.length; ++i) { - const file_name = files[i]; - const testPath = path.join(opts["tests_folder"], file_name); - const callback = runTest(testPath, options) - .then(out => { - const [output, nb_failures] = out; - results[nb_failures === 0 ? "successful" : "failed"].push({ - file_name: testPath, - output: output, - }); - if (nb_failures > 0) { - status_bar.erroneous(); - failed = true; - } else { - status_bar.successful(); - } - }) - .catch(err => { - results.errored.push({ - file_name: testPath + file_name, - output: err, - }); - status_bar.erroneous(); - failed = true; - }) - .finally(() => { - // We now remove the promise from the tests_queue. - tests_queue.splice(tests_queue.indexOf(callback), 1); - }); - tests_queue.push(callback); - if (opts["jobs"] > 0 && tests_queue.length >= opts["jobs"]) { - await Promise.race(tests_queue); + + let new_results; + for (let it = 0; it < NB_RETRY && files.length > 0; ++it) { + new_results = createEmptyResults(); + await runTests(opts, framework_options, files, new_results, status_bar, it + 1 >= NB_RETRY); + Array.prototype.push.apply(results.successful, new_results.successful); + // We generate the new list of files with the previously failing tests. + files = Array.prototype.concat(new_results.failed, new_results.errored); + if (files.length > originalFilesLen / 2) { + // If we have too many failing tests, it's very likely not flaky failures anymore so + // no need to retry. + break; } } - if (tests_queue.length > 0) { - await Promise.all(tests_queue); - } + status_bar.finish(); + Array.prototype.push.apply(results.failed, new_results.failed); + Array.prototype.push.apply(results.errored, new_results.errored); + // We don't need this listener anymore. process.removeListener("exit", exitHandling); @@ -287,7 +317,7 @@ async function main(argv) { }); } - if (failed) { + if (results.failed.length > 0 || results.errored.length > 0) { process.exit(1); } } diff --git a/src/tools/rustfmt/tests/target/issue_4110.rs b/src/tools/rustfmt/tests/target/issue_4110.rs index 4a58c3946e1..d3734e90b7f 100644 --- a/src/tools/rustfmt/tests/target/issue_4110.rs +++ b/src/tools/rustfmt/tests/target/issue_4110.rs @@ -20,6 +20,7 @@ fn bindings() { category, span, &format!("`{}`", name), + "function", ), ( ref name, diff --git a/src/tools/tidy/Cargo.toml b/src/tools/tidy/Cargo.toml index fff83a1d097..5f5ae3a65ef 100644 --- a/src/tools/tidy/Cargo.toml +++ b/src/tools/tidy/Cargo.toml @@ -11,6 +11,7 @@ miropt-test-tools = { path = "../miropt-test-tools" } lazy_static = "1" walkdir = "2" ignore = "0.4.18" +semver = "1.0.14" termcolor = "1.1.3" [[bin]] diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 75454cbdc5f..29501d2d3b6 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -40,6 +40,8 @@ const EXCEPTIONS: &[(&str, &str)] = &[ ("im-rc", "MPL-2.0+"), // cargo ("sized-chunks", "MPL-2.0+"), // cargo via im-rc ("bitmaps", "MPL-2.0+"), // cargo via im-rc + ("fiat-crypto", "MIT OR Apache-2.0 OR BSD-1-Clause"), // cargo via pasetors + ("subtle", "BSD-3-Clause"), // cargo via pasetors ("instant", "BSD-3-Clause"), // rustc_driver/tracing-subscriber/parking_lot ("snap", "BSD-3-Clause"), // rustc ("fluent-langneg", "Apache-2.0"), // rustc (fluent translations) @@ -96,6 +98,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "autocfg", "bitflags", "block-buffer", + "bumpalo", // Included in Cargo's dep graph but only activated on wasm32-*-unknown. "cc", "cfg-if", "chalk-derive", @@ -153,6 +156,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "itertools", "itoa", "jobserver", + "js-sys", // Included in Cargo's dep graph but only activated on wasm32-*-unknown. "lazy_static", "libc", "libloading", @@ -191,7 +195,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "rand", "rand_chacha", "rand_core", - "rand_hc", "rand_xorshift", "rand_xoshiro", "redox_syscall", @@ -222,6 +225,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "stable_deref_trait", "stacker", "static_assertions", + "subtle", // dependency of cargo (via pasetors) "syn", "synstructure", "tempfile", @@ -264,6 +268,13 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "valuable", "version_check", "wasi", + // vvv Included in Cargo's dep graph but only activated on wasm32-*-unknown. + "wasm-bindgen", + "wasm-bindgen-backend", + "wasm-bindgen-macro", + "wasm-bindgen-macro-support", + "wasm-bindgen-shared", + // ^^^ Included in Cargo's dep graph but only activated on wasm32-*-unknown. "winapi", "winapi-i686-pc-windows-gnu", "winapi-util", diff --git a/src/tools/tidy/src/error_codes.rs b/src/tools/tidy/src/error_codes.rs new file mode 100644 index 00000000000..8d70335a9e7 --- /dev/null +++ b/src/tools/tidy/src/error_codes.rs @@ -0,0 +1,384 @@ +//! Tidy check to ensure error codes are properly documented and tested. +//! +//! Overview of check: +//! +//! 1. We create a list of error codes used by the compiler. Error codes are extracted from `compiler/rustc_error_codes/src/error_codes.rs`. +//! +//! 2. We check that the error code has a long-form explanation in `compiler/rustc_error_codes/src/error_codes/`. +//! - The explanation is expected to contain a `doctest` that fails with the correct error code. (`EXEMPT_FROM_DOCTEST` *currently* bypasses this check) +//! - Note that other stylistic conventions for markdown files are checked in the `style.rs` tidy check. +//! +//! 3. We check that the error code has a UI test in `src/test/ui/error-codes/`. +//! - We ensure that there is both a `Exxxx.rs` file and a corresponding `Exxxx.stderr` file. +//! - We also ensure that the error code is used in the tests. +//! - *Currently*, it is possible to opt-out of this check with the `EXEMPTED_FROM_TEST` constant. +//! +//! 4. We check that the error code is actually emitted by the compiler. +//! - This is done by searching `compiler/` with a regex. + +use std::{ffi::OsStr, fs, path::Path}; + +use regex::Regex; + +use crate::walk::{filter_dirs, walk, walk_many}; + +const ERROR_CODES_PATH: &str = "compiler/rustc_error_codes/src/error_codes.rs"; +const ERROR_DOCS_PATH: &str = "compiler/rustc_error_codes/src/error_codes/"; +const ERROR_TESTS_PATH: &str = "src/test/ui/error-codes/"; + +// Error codes that (for some reason) can't have a doctest in their explanation. Error codes are still expected to provide a code example, even if untested. +const IGNORE_DOCTEST_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602"]; + +// Error codes that don't yet have a UI test. This list will eventually be removed. +const IGNORE_UI_TEST_CHECK: &[&str] = &[ + "E0461", "E0465", "E0476", "E0490", "E0514", "E0523", "E0554", "E0640", "E0717", "E0729", + "E0789", +]; + +macro_rules! verbose_print { + ($verbose:expr, $($fmt:tt)*) => { + if $verbose { + println!("{}", format_args!($($fmt)*)); + } + }; +} + +pub fn check(root_path: &Path, search_paths: &[&Path], verbose: bool, bad: &mut bool) { + let mut errors = Vec::new(); + + // Stage 1: create list + let error_codes = extract_error_codes(root_path, &mut errors, verbose); + println!("Found {} error codes", error_codes.len()); + println!("Highest error code: `{}`", error_codes.iter().max().unwrap()); + + // Stage 2: check list has docs + let no_longer_emitted = check_error_codes_docs(root_path, &error_codes, &mut errors, verbose); + + // Stage 3: check list has UI tests + check_error_codes_tests(root_path, &error_codes, &mut errors, verbose, &no_longer_emitted); + + // Stage 4: check list is emitted by compiler + check_error_codes_used(search_paths, &error_codes, &mut errors, &no_longer_emitted, verbose); + + // Print any errors. + for error in errors { + tidy_error!(bad, "{}", error); + } +} + +/// Stage 1: Parses a list of error codes from `error_codes.rs`. +fn extract_error_codes(root_path: &Path, errors: &mut Vec<String>, verbose: bool) -> Vec<String> { + let path = root_path.join(Path::new(ERROR_CODES_PATH)); + let file = + fs::read_to_string(&path).unwrap_or_else(|e| panic!("failed to read `{path:?}`: {e}")); + + let mut error_codes = Vec::new(); + let mut reached_undocumented_codes = false; + + for line in file.lines() { + let line = line.trim(); + + if !reached_undocumented_codes && line.starts_with('E') { + let split_line = line.split_once(':'); + + // Extract the error code from the line, emitting a fatal error if it is not in a correct format. + let err_code = if let Some(err_code) = split_line { + err_code.0.to_owned() + } else { + errors.push(format!( + "Expected a line with the format `Exxxx: include_str!(\"..\")`, but got \"{}\" \ + without a `:` delimiter", + line, + )); + continue; + }; + + // If this is a duplicate of another error code, emit a fatal error. + if error_codes.contains(&err_code) { + errors.push(format!("Found duplicate error code: `{}`", err_code)); + continue; + } + + // Ensure that the line references the correct markdown file. + let expected_filename = format!(" include_str!(\"./error_codes/{}.md\"),", err_code); + if expected_filename != split_line.unwrap().1 { + errors.push(format!( + "Error code `{}` expected to reference docs with `{}` but instead found `{}` in \ + `compiler/rustc_error_codes/src/error_codes.rs`", + err_code, + expected_filename, + split_line.unwrap().1, + )); + continue; + } + + error_codes.push(err_code); + } else if reached_undocumented_codes && line.starts_with('E') { + let err_code = match line.split_once(',') { + None => line, + Some((err_code, _)) => err_code, + } + .to_string(); + + verbose_print!(verbose, "warning: Error code `{}` is undocumented.", err_code); + + if error_codes.contains(&err_code) { + errors.push(format!("Found duplicate error code: `{}`", err_code)); + } + + error_codes.push(err_code); + } else if line == ";" { + // Once we reach the undocumented error codes, adapt to different syntax. + reached_undocumented_codes = true; + } + } + + error_codes +} + +/// Stage 2: Checks that long-form error code explanations exist and have doctests. +fn check_error_codes_docs( + root_path: &Path, + error_codes: &[String], + errors: &mut Vec<String>, + verbose: bool, +) -> Vec<String> { + let docs_path = root_path.join(Path::new(ERROR_DOCS_PATH)); + + let mut no_longer_emitted_codes = Vec::new(); + + walk(&docs_path, &mut |_| false, &mut |entry, contents| { + let path = entry.path(); + + // Error if the file isn't markdown. + if path.extension() != Some(OsStr::new("md")) { + errors.push(format!( + "Found unexpected non-markdown file in error code docs directory: {}", + path.display() + )); + return; + } + + // Make sure that the file is referenced in `error_codes.rs` + let filename = path.file_name().unwrap().to_str().unwrap().split_once('.'); + let err_code = filename.unwrap().0; // `unwrap` is ok because we know the filename is in the correct format. + + if error_codes.iter().all(|e| e != err_code) { + errors.push(format!( + "Found valid file `{}` in error code docs directory without corresponding \ + entry in `error_code.rs`", + path.display() + )); + return; + } + + let (found_code_example, found_proper_doctest, emit_ignore_warning, no_longer_emitted) = + check_explanation_has_doctest(&contents, &err_code); + + if emit_ignore_warning { + verbose_print!( + verbose, + "warning: Error code `{err_code}` uses the ignore header. This should not be used, add the error code to the \ + `IGNORE_DOCTEST_CHECK` constant instead." + ); + } + + if no_longer_emitted { + no_longer_emitted_codes.push(err_code.to_owned()); + } + + if !found_code_example { + verbose_print!( + verbose, + "warning: Error code `{err_code}` doesn't have a code example, all error codes are expected to have one \ + (even if untested)." + ); + } + + let test_ignored = IGNORE_DOCTEST_CHECK.contains(&&err_code); + + // Check that the explanation has a doctest, and if it shouldn't, that it doesn't + if !found_proper_doctest && !test_ignored { + errors.push(format!( + "`{}` doesn't use its own error code in compile_fail example", + path.display(), + )); + } else if found_proper_doctest && test_ignored { + errors.push(format!( + "`{}` has a compile_fail doctest with its own error code, it shouldn't \ + be listed in `IGNORE_DOCTEST_CHECK`", + path.display(), + )); + } + }); + + no_longer_emitted_codes +} + +/// This function returns a tuple indicating whether the provided explanation: +/// a) has a code example, tested or not. +/// b) has a valid doctest +fn check_explanation_has_doctest(explanation: &str, err_code: &str) -> (bool, bool, bool, bool) { + let mut found_code_example = false; + let mut found_proper_doctest = false; + + let mut emit_ignore_warning = false; + let mut no_longer_emitted = false; + + for line in explanation.lines() { + let line = line.trim(); + + if line.starts_with("```") { + found_code_example = true; + + // Check for the `rustdoc` doctest headers. + if line.contains("compile_fail") && line.contains(err_code) { + found_proper_doctest = true; + } + + if line.contains("ignore") { + emit_ignore_warning = true; + found_proper_doctest = true; + } + } else if line + .starts_with("#### Note: this error code is no longer emitted by the compiler") + { + no_longer_emitted = true; + found_code_example = true; + found_proper_doctest = true; + } + } + + (found_code_example, found_proper_doctest, emit_ignore_warning, no_longer_emitted) +} + +// Stage 3: Checks that each error code has a UI test in the correct directory +fn check_error_codes_tests( + root_path: &Path, + error_codes: &[String], + errors: &mut Vec<String>, + verbose: bool, + no_longer_emitted: &[String], +) { + let tests_path = root_path.join(Path::new(ERROR_TESTS_PATH)); + + for code in error_codes { + let test_path = tests_path.join(format!("{}.stderr", code)); + + if !test_path.exists() && !IGNORE_UI_TEST_CHECK.contains(&code.as_str()) { + verbose_print!( + verbose, + "warning: Error code `{code}` needs to have at least one UI test in the `src/test/ui/error-codes/` directory`!" + ); + continue; + } + if IGNORE_UI_TEST_CHECK.contains(&code.as_str()) { + if test_path.exists() { + errors.push(format!( + "Error code `{code}` has a UI test in `src/test/ui/error-codes/{code}.rs`, it shouldn't be listed in `EXEMPTED_FROM_TEST`!" + )); + } + continue; + } + + let file = match fs::read_to_string(&test_path) { + Ok(file) => file, + Err(err) => { + verbose_print!( + verbose, + "warning: Failed to read UI test file (`{}`) for `{code}` but the file exists. The test is assumed to work:\n{err}", + test_path.display() + ); + continue; + } + }; + + if no_longer_emitted.contains(code) { + // UI tests *can't* contain error codes that are no longer emitted. + continue; + } + + let mut found_code = false; + + for line in file.lines() { + let s = line.trim(); + // Assuming the line starts with `error[E`, we can substring the error code out. + if s.starts_with("error[E") { + if &s[6..11] == code { + found_code = true; + break; + } + }; + } + + if !found_code { + verbose_print!( + verbose, + "warning: Error code {code}`` has a UI test file, but doesn't contain its own error code!" + ); + } + } +} + +/// Stage 4: Search `compiler/` and ensure that every error code is actually used by the compiler and that no undocumented error codes exist. +fn check_error_codes_used( + search_paths: &[&Path], + error_codes: &[String], + errors: &mut Vec<String>, + no_longer_emitted: &[String], + verbose: bool, +) { + // We want error codes which match the following cases: + // + // * foo(a, E0111, a) + // * foo(a, E0111) + // * foo(E0111, a) + // * #[error = "E0111"] + let regex = Regex::new(r#"[(,"\s](E\d{4})[,)"]"#).unwrap(); + + let mut found_codes = Vec::new(); + + walk_many(search_paths, &mut filter_dirs, &mut |entry, contents| { + let path = entry.path(); + + // Return early if we aren't looking at a source file. + if path.extension() != Some(OsStr::new("rs")) { + return; + } + + for line in contents.lines() { + // We want to avoid parsing error codes in comments. + if line.trim_start().starts_with("//") { + continue; + } + + for cap in regex.captures_iter(line) { + if let Some(error_code) = cap.get(1) { + let error_code = error_code.as_str().to_owned(); + + if !error_codes.contains(&error_code) { + // This error code isn't properly defined, we must error. + errors.push(format!("Error code `{}` is used in the compiler but not defined and documented in `compiler/rustc_error_codes/src/error_codes.rs`.", error_code)); + continue; + } + + // This error code can now be marked as used. + found_codes.push(error_code); + } + } + } + }); + + for code in error_codes { + if !found_codes.contains(code) && !no_longer_emitted.contains(code) { + errors.push(format!("Error code `{code}` exists, but is not emitted by the compiler!")) + } + + if found_codes.contains(code) && no_longer_emitted.contains(code) { + verbose_print!( + verbose, + "warning: Error code `{code}` is used when it's marked as \"no longer emitted\"" + ); + } + } +} diff --git a/src/tools/tidy/src/error_codes_check.rs b/src/tools/tidy/src/error_codes_check.rs deleted file mode 100644 index 3f060e437ac..00000000000 --- a/src/tools/tidy/src/error_codes_check.rs +++ /dev/null @@ -1,305 +0,0 @@ -//! Checks that all error codes have at least one test to prevent having error -//! codes that are silently not thrown by the compiler anymore. - -use crate::walk::{filter_dirs, walk}; -use std::collections::{HashMap, HashSet}; -use std::ffi::OsStr; -use std::fs::read_to_string; -use std::path::Path; - -use regex::Regex; - -// A few of those error codes can't be tested but all the others can and *should* be tested! -const EXEMPTED_FROM_TEST: &[&str] = &[ - "E0313", "E0461", "E0476", "E0490", "E0514", "E0523", "E0554", "E0640", "E0717", "E0729", - "E0789", -]; - -// Some error codes don't have any tests apparently... -const IGNORE_EXPLANATION_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602", "E0729"]; - -// If the file path contains any of these, we don't want to try to extract error codes from it. -// -// We need to declare each path in the windows version (with backslash). -const PATHS_TO_IGNORE_FOR_EXTRACTION: &[&str] = - &["src/test/", "src\\test\\", "src/doc/", "src\\doc\\", "src/tools/", "src\\tools\\"]; - -#[derive(Default, Debug)] -struct ErrorCodeStatus { - has_test: bool, - has_explanation: bool, - is_used: bool, -} - -fn check_error_code_explanation( - f: &str, - error_codes: &mut HashMap<String, ErrorCodeStatus>, - err_code: String, -) -> bool { - let mut invalid_compile_fail_format = false; - let mut found_error_code = false; - - for line in f.lines() { - let s = line.trim(); - if s.starts_with("```") { - if s.contains("compile_fail") && s.contains('E') { - if !found_error_code { - error_codes.get_mut(&err_code).map(|x| x.has_test = true); - found_error_code = true; - } - } else if s.contains("compile-fail") { - invalid_compile_fail_format = true; - } - } else if s.starts_with("#### Note: this error code is no longer emitted by the compiler") { - if !found_error_code { - error_codes.get_mut(&err_code).map(|x| x.has_test = true); - found_error_code = true; - } - } - } - invalid_compile_fail_format -} - -fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &str) -> bool { - let mut ignore_found = false; - - for line in f.lines() { - let s = line.trim(); - if s.starts_with("#### Note: this error code is no longer emitted by the compiler") { - return true; - } - if s.starts_with("```") { - if s.contains("compile_fail") && s.contains(err_code) { - return true; - } else if s.contains("ignore") { - // It's very likely that we can't actually make it fail compilation... - ignore_found = true; - } - } - } - ignore_found -} - -fn extract_error_codes( - f: &str, - error_codes: &mut HashMap<String, ErrorCodeStatus>, - path: &Path, - errors: &mut Vec<String>, -) { - let mut reached_no_explanation = false; - - for line in f.lines() { - let s = line.trim(); - if !reached_no_explanation && s.starts_with('E') && s.contains("include_str!(\"") { - let err_code = s - .split_once(':') - .expect( - format!( - "Expected a line with the format `E0xxx: include_str!(\"..\")`, but got {} \ - without a `:` delimiter", - s, - ) - .as_str(), - ) - .0 - .to_owned(); - error_codes.entry(err_code.clone()).or_default().has_explanation = true; - - // Now we extract the tests from the markdown file! - let md_file_name = match s.split_once("include_str!(\"") { - None => continue, - Some((_, md)) => match md.split_once("\")") { - None => continue, - Some((file_name, _)) => file_name, - }, - }; - - let Some(parent) = path.parent() else { - continue; - }; - - let path = parent - .join(md_file_name) - .canonicalize() - .expect("failed to canonicalize error explanation file path"); - - match read_to_string(&path) { - Ok(content) => { - let has_test = check_if_error_code_is_test_in_explanation(&content, &err_code); - if !has_test && !IGNORE_EXPLANATION_CHECK.contains(&err_code.as_str()) { - errors.push(format!( - "`{}` doesn't use its own error code in compile_fail example", - path.display(), - )); - } else if has_test && IGNORE_EXPLANATION_CHECK.contains(&err_code.as_str()) { - errors.push(format!( - "`{}` has a compile_fail example with its own error code, it shouldn't \ - be listed in IGNORE_EXPLANATION_CHECK!", - path.display(), - )); - } - if check_error_code_explanation(&content, error_codes, err_code) { - errors.push(format!( - "`{}` uses invalid tag `compile-fail` instead of `compile_fail`", - path.display(), - )); - } - } - Err(e) => { - eprintln!("Couldn't read `{}`: {}", path.display(), e); - } - } - } else if reached_no_explanation && s.starts_with('E') { - let err_code = match s.split_once(',') { - None => s, - Some((err_code, _)) => err_code, - } - .to_string(); - if !error_codes.contains_key(&err_code) { - // this check should *never* fail! - error_codes.insert(err_code, ErrorCodeStatus::default()); - } - } else if s == ";" { - reached_no_explanation = true; - } - } -} - -fn extract_error_codes_from_tests(f: &str, error_codes: &mut HashMap<String, ErrorCodeStatus>) { - for line in f.lines() { - let s = line.trim(); - if s.starts_with("error[E") || s.starts_with("warning[E") { - let err_code = match s.split_once(']') { - None => continue, - Some((err_code, _)) => match err_code.split_once('[') { - None => continue, - Some((_, err_code)) => err_code, - }, - }; - error_codes.entry(err_code.to_owned()).or_default().has_test = true; - } - } -} - -fn extract_error_codes_from_source( - f: &str, - error_codes: &mut HashMap<String, ErrorCodeStatus>, - regex: &Regex, -) { - for line in f.lines() { - if line.trim_start().starts_with("//") { - continue; - } - for cap in regex.captures_iter(line) { - if let Some(error_code) = cap.get(1) { - error_codes.entry(error_code.as_str().to_owned()).or_default().is_used = true; - } - } - } -} - -pub fn check(paths: &[&Path], bad: &mut bool) { - let mut errors = Vec::new(); - let mut found_explanations = 0; - let mut found_tests = 0; - let mut error_codes: HashMap<String, ErrorCodeStatus> = HashMap::new(); - let mut explanations: HashSet<String> = HashSet::new(); - // We want error codes which match the following cases: - // - // * foo(a, E0111, a) - // * foo(a, E0111) - // * foo(E0111, a) - // * #[error = "E0111"] - let regex = Regex::new(r#"[(,"\s](E\d{4})[,)"]"#).unwrap(); - - for path in paths { - walk(path, &mut filter_dirs, &mut |entry, contents| { - let file_name = entry.file_name(); - let entry_path = entry.path(); - - if file_name == "error_codes.rs" { - extract_error_codes(contents, &mut error_codes, entry.path(), &mut errors); - found_explanations += 1; - } else if entry_path.extension() == Some(OsStr::new("stderr")) { - extract_error_codes_from_tests(contents, &mut error_codes); - found_tests += 1; - } else if entry_path.extension() == Some(OsStr::new("rs")) { - let path = entry.path().to_string_lossy(); - if PATHS_TO_IGNORE_FOR_EXTRACTION.iter().all(|c| !path.contains(c)) { - extract_error_codes_from_source(contents, &mut error_codes, ®ex); - } - } else if entry_path - .parent() - .and_then(|p| p.file_name()) - .map(|p| p == "error_codes") - .unwrap_or(false) - && entry_path.extension() == Some(OsStr::new("md")) - { - explanations.insert(file_name.to_str().unwrap().replace(".md", "")); - } - }); - } - if found_explanations == 0 { - tidy_error!(bad, "No error code explanation was tested!"); - } - if found_tests == 0 { - tidy_error!(bad, "No error code was found in compilation errors!"); - } - if explanations.is_empty() { - tidy_error!(bad, "No error code explanation was found!"); - } - if errors.is_empty() { - for (err_code, error_status) in &error_codes { - if !error_status.has_test && !EXEMPTED_FROM_TEST.contains(&err_code.as_str()) { - errors.push(format!("Error code {err_code} needs to have at least one UI test!")); - } else if error_status.has_test && EXEMPTED_FROM_TEST.contains(&err_code.as_str()) { - errors.push(format!( - "Error code {} has a UI test, it shouldn't be listed into EXEMPTED_FROM_TEST!", - err_code - )); - } - if !error_status.is_used && !error_status.has_explanation { - errors.push(format!( - "Error code {} isn't used and doesn't have an error explanation, it should be \ - commented in error_codes.rs file", - err_code - )); - } - } - } - if errors.is_empty() { - // Checking if local constants need to be cleaned. - for err_code in EXEMPTED_FROM_TEST { - match error_codes.get(err_code.to_owned()) { - Some(status) => { - if status.has_test { - errors.push(format!( - "{} error code has a test and therefore should be \ - removed from the `EXEMPTED_FROM_TEST` constant", - err_code - )); - } - } - None => errors.push(format!( - "{} error code isn't used anymore and therefore should be removed \ - from `EXEMPTED_FROM_TEST` constant", - err_code - )), - } - } - } - if errors.is_empty() { - for explanation in explanations { - if !error_codes.contains_key(&explanation) { - errors.push(format!( - "{} error code explanation should be listed in `error_codes.rs`", - explanation - )); - } - } - } - errors.sort(); - for err in &errors { - tidy_error!(bad, "{err}"); - } -} diff --git a/src/tools/tidy/src/errors.rs b/src/tools/tidy/src/errors.rs deleted file mode 100644 index fe5fd72b91a..00000000000 --- a/src/tools/tidy/src/errors.rs +++ /dev/null @@ -1,77 +0,0 @@ -//! Tidy check to verify the validity of long error diagnostic codes. -//! -//! This ensures that error codes are used at most once and also prints out some -//! statistics about the error codes. - -use crate::walk::{filter_dirs, walk}; -use std::collections::HashMap; -use std::path::Path; - -pub fn check(path: &Path, bad: &mut bool) { - let mut map: HashMap<_, Vec<_>> = HashMap::new(); - walk( - path, - &mut |path| filter_dirs(path) || path.ends_with("src/test"), - &mut |entry, contents| { - let file = entry.path(); - let filename = file.file_name().unwrap().to_string_lossy(); - if filename != "error_codes.rs" { - return; - } - - // In the `register_long_diagnostics!` macro, entries look like this: - // - // ``` - // EXXXX: r##" - // <Long diagnostic message> - // "##, - // ``` - // - // and these long messages often have error codes themselves inside - // them, but we don't want to report duplicates in these cases. This - // variable keeps track of whether we're currently inside one of these - // long diagnostic messages. - let mut inside_long_diag = false; - for (num, line) in contents.lines().enumerate() { - if inside_long_diag { - inside_long_diag = !line.contains("\"##"); - continue; - } - - let mut search = line; - while let Some(i) = search.find('E') { - search = &search[i + 1..]; - let code = if search.len() > 4 { search[..4].parse::<u32>() } else { continue }; - let code = match code { - Ok(n) => n, - Err(..) => continue, - }; - map.entry(code).or_default().push((file.to_owned(), num + 1, line.to_owned())); - break; - } - - inside_long_diag = line.contains("r##\""); - } - }, - ); - - let mut max = 0; - for (&code, entries) in map.iter() { - if code > max { - max = code; - } - if entries.len() == 1 { - continue; - } - - tidy_error!(bad, "duplicate error code: {}", code); - for &(ref file, line_num, ref line) in entries.iter() { - tidy_error!(bad, "{}:{}: {}", file.display(), line_num, line); - } - } - - if !*bad { - println!("* {} error codes", map.len()); - println!("* highest error code: E{:04}", max); - } -} diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index ce7e7ac5cd4..15c641d748c 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -56,8 +56,7 @@ pub mod bins; pub mod debug_artifacts; pub mod deps; pub mod edition; -pub mod error_codes_check; -pub mod errors; +pub mod error_codes; pub mod extdeps; pub mod features; pub mod mir_opt_tests; @@ -69,3 +68,4 @@ pub mod ui_tests; pub mod unit_tests; pub mod unstable_book; pub mod walk; +pub mod x_version; diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 6714c63ee62..a5685ba7c94 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -27,6 +27,7 @@ fn main() { let src_path = root_path.join("src"); let library_path = root_path.join("library"); let compiler_path = root_path.join("compiler"); + let librustdoc_path = src_path.join("librustdoc"); let args: Vec<String> = env::args().skip(1).collect(); @@ -58,7 +59,7 @@ fn main() { let handle = s.spawn(|| { let mut flag = false; - $p::check($($args),* , &mut flag); + $p::check($($args, )* &mut flag); if (flag) { bad.store(true, Ordering::Relaxed); } @@ -79,8 +80,7 @@ fn main() { check!(mir_opt_tests, &src_path, bless); // Checks that only make sense for the compiler. - check!(errors, &compiler_path); - check!(error_codes_check, &[&src_path, &compiler_path]); + check!(error_codes, &root_path, &[&compiler_path, &librustdoc_path], verbose); // Checks that only make sense for the std libs. check!(pal, &library_path); @@ -107,6 +107,8 @@ fn main() { check!(alphabetical, &compiler_path); check!(alphabetical, &library_path); + check!(x_version, &root_path, &cargo); + let collected = { drain_handles(&mut handles); diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index f91e38262f6..723a52c4c68 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -15,6 +15,7 @@ //! //! A number of these checks can be opted-out of with various directives of the form: //! `// ignore-tidy-CHECK-NAME`. +// ignore-tidy-dbg use crate::walk::{filter_dirs, walk}; use regex::{Regex, RegexSet}; @@ -24,6 +25,7 @@ use std::path::Path; /// displayed on the console with --example. const ERROR_CODE_COLS: usize = 80; const COLS: usize = 100; +const GOML_COLS: usize = 120; const LINES: usize = 3000; @@ -229,7 +231,8 @@ pub fn check(path: &Path, bad: &mut bool) { walk(path, &mut skip, &mut |entry, contents| { let file = entry.path(); let filename = file.file_name().unwrap().to_string_lossy(); - let extensions = [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md", ".css", ".ftl"]; + let extensions = + [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md", ".css", ".ftl", ".goml"]; if extensions.iter().all(|e| !filename.ends_with(e)) || filename.starts_with(".#") { return; } @@ -254,8 +257,15 @@ pub fn check(path: &Path, bad: &mut bool) { let extension = file.extension().unwrap().to_string_lossy(); let is_error_code = extension == "md" && is_in(file, "src", "error_codes"); + let is_goml_code = extension == "goml"; - let max_columns = if is_error_code { ERROR_CODE_COLS } else { COLS }; + let max_columns = if is_error_code { + ERROR_CODE_COLS + } else if is_goml_code { + GOML_COLS + } else { + COLS + }; let can_contain = contents.contains("// ignore-tidy-") || contents.contains("# ignore-tidy-") @@ -278,6 +288,7 @@ pub fn check(path: &Path, bad: &mut bool) { let mut skip_leading_newlines = contains_ignore_directive(can_contain, &contents, "leading-newlines"); let mut skip_copyright = contains_ignore_directive(can_contain, &contents, "copyright"); + let mut skip_dbg = contains_ignore_directive(can_contain, &contents, "dbg"); let mut leading_new_lines = false; let mut trailing_new_lines = 0; let mut lines = 0; @@ -306,6 +317,21 @@ pub fn check(path: &Path, bad: &mut bool) { let mut err = |msg: &str| { tidy_error!(bad, "{}:{}: {}", file.display(), i + 1, msg); }; + + if trimmed.contains("dbg!") + && !trimmed.starts_with("//") + && !file + .ancestors() + .any(|a| a.ends_with("src/test") || a.ends_with("library/alloc/tests")) + && filename != "tests.rs" + { + suppressible_tidy_err!( + err, + skip_dbg, + "`dbg!` macro is intended as a debugging tool. It should not be in version control." + ) + } + if !under_rustfmt && line.chars().count() > max_columns && !long_line_is_ok(&extension, is_error_code, max_columns, line) diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 070e72437be..166d09fa8b0 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -10,7 +10,7 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. const ROOT_ENTRY_LIMIT: usize = 939; -const ISSUES_ENTRY_LIMIT: usize = 2050; +const ISSUES_ENTRY_LIMIT: usize = 1998; fn check_entries(path: &Path, bad: &mut bool) { for dir in Walk::new(&path.join("test/ui")) { diff --git a/src/tools/tidy/src/x_version.rs b/src/tools/tidy/src/x_version.rs new file mode 100644 index 00000000000..5dc6a0588c3 --- /dev/null +++ b/src/tools/tidy/src/x_version.rs @@ -0,0 +1,65 @@ +use semver::Version; +use std::io::ErrorKind; +use std::path::Path; +use std::process::{Command, Stdio}; + +pub fn check(root: &Path, cargo: &Path, bad: &mut bool) { + let result = Command::new("x").arg("--wrapper-version").stdout(Stdio::piped()).spawn(); + // This runs the command inside a temporary directory. + // This allows us to compare output of result to see if `--wrapper-version` is not a recognized argument to x. + let temp_result = Command::new("x") + .arg("--wrapper-version") + .current_dir(std::env::temp_dir()) + .stdout(Stdio::piped()) + .spawn(); + + let (child, temp_child) = match (result, temp_result) { + (Ok(child), Ok(temp_child)) => (child, temp_child), + (Err(e), _) | (_, Err(e)) => match e.kind() { + ErrorKind::NotFound => return, + _ => return tidy_error!(bad, "failed to run `x`: {}", e), + }, + }; + + let output = child.wait_with_output().unwrap(); + let temp_output = temp_child.wait_with_output().unwrap(); + + if output != temp_output { + return tidy_error!( + bad, + "Current version of x does not support the `--wrapper-version` argument\nConsider updating to the newer version of x by running `cargo install --path src/tools/x`" + ); + } + + if output.status.success() { + let version = String::from_utf8_lossy(&output.stdout); + let version = Version::parse(version.trim_end()).unwrap(); + + if let Some(expected) = get_x_wrapper_version(root, cargo) { + if version < expected { + return tidy_error!( + bad, + "Current version of x is {version}, but the latest version is {expected}\nConsider updating to the newer version of x by running `cargo install --path src/tools/x`" + ); + } + } else { + return tidy_error!( + bad, + "Unable to parse the latest version of `x` at `src/tools/x/Cargo.toml`" + ); + } + } else { + return tidy_error!(bad, "failed to check version of `x`: {}", output.status); + } +} + +// Parse latest version out of `x` Cargo.toml +fn get_x_wrapper_version(root: &Path, cargo: &Path) -> Option<Version> { + let mut cmd = cargo_metadata::MetadataCommand::new(); + cmd.cargo_path(cargo) + .manifest_path(root.join("src/tools/x/Cargo.toml")) + .no_deps() + .features(cargo_metadata::CargoOpt::AllFeatures); + let mut metadata = t!(cmd.exec()); + metadata.packages.pop().map(|x| x.version) +} diff --git a/src/tools/x/src/main.rs b/src/tools/x/src/main.rs index f07ff43efe9..01f7187851e 100644 --- a/src/tools/x/src/main.rs +++ b/src/tools/x/src/main.rs @@ -52,6 +52,14 @@ fn exec_or_status(command: &mut Command) -> io::Result<ExitStatus> { } fn main() { + match env::args().skip(1).next().as_deref() { + Some("--wrapper-version") => { + let version = env!("CARGO_PKG_VERSION"); + println!("{}", version); + return; + } + _ => {} + } let current = match env::current_dir() { Ok(dir) => dir, Err(err) => { |
