From b75e6b4e7e7b12b461e70a5ffaf280b46c746575 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Sun, 17 Mar 2024 13:34:42 +0300 Subject: [PATCH 01/27] fetch submodule before checking llvm stamp Previously, we were checking the LLVM stamp before fetching the submodule which leads to not being able to compile llvm on submodule updates. Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/llvm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 701bd585eee..327dc04b4e5 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -94,6 +94,7 @@ pub fn prebuilt_llvm_config( } } + builder.update_submodule(&Path::new("src").join("llvm-project")); let root = "src/llvm-project/llvm"; let out_dir = builder.llvm_out(target); @@ -279,7 +280,6 @@ fn run(self, builder: &Builder<'_>) -> LlvmResult { Err(m) => m, }; - builder.update_submodule(&Path::new("src").join("llvm-project")); if builder.llvm_link_shared() && target.is_windows() { panic!("shared linking to LLVM is not currently supported on {}", target.triple); } From 3683b11d212d938b5c314a0d0971b794d521046f Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Thu, 28 Mar 2024 17:27:17 +0300 Subject: [PATCH 02/27] create `Build::update_existing_submodule` and use for llvm Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/llvm.rs | 5 +++++ src/bootstrap/src/lib.rs | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 327dc04b4e5..59fdd2e3caf 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -76,6 +76,9 @@ pub fn prebuilt_llvm_config( builder: &Builder<'_>, target: TargetSelection, ) -> Result { + // If we have llvm submodule initialized already, sync it. + builder.update_existing_submodule(&Path::new("src").join("llvm-project")); + builder.config.maybe_download_ci_llvm(); // If we're using a custom LLVM bail out here, but we can only use a @@ -94,7 +97,9 @@ pub fn prebuilt_llvm_config( } } + // Initialize the llvm submodule if not initialized already. builder.update_submodule(&Path::new("src").join("llvm-project")); + let root = "src/llvm-project/llvm"; let out_dir = builder.llvm_out(target); diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index f0fe994d155..9568514db51 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -625,6 +625,18 @@ pub fn update_existing_submodules(&self) { } } + /// Updates the given submodule only if it's initialized already; nothing happens otherwise. + pub fn update_existing_submodule(&self, submodule: &Path) { + // Avoid running git when there isn't a git checkout. + if !self.config.submodules(self.rust_info()) { + return; + } + + if GitInfo::new(false, submodule).is_managed_git_subrepository() { + self.update_submodule(submodule); + } + } + /// Executes the entire build, as configured by the flags and configuration. pub fn build(&mut self) { unsafe { From 1ca145778a4971d82c56025ece1824ec672428b9 Mon Sep 17 00:00:00 2001 From: mu001999 Date: Tue, 2 Apr 2024 14:35:25 +0800 Subject: [PATCH 03/27] Support type '/' to search --- src/librustdoc/html/static/js/main.js | 3 ++- src/librustdoc/html/templates/page.html | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index b9a769a7c6d..0bd75d4a4fc 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -438,6 +438,7 @@ function preLoadCss(cssUrl) { case "s": case "S": + case "/": ev.preventDefault(); searchState.focus(); break; @@ -1310,7 +1311,7 @@ function preLoadCss(cssUrl) { const shortcuts = [ ["?", "Show this help dialog"], - ["S", "Focus the search field"], + ["S / /", "Focus the search field"], ["↑", "Move up in search results"], ["↓", "Move down in search results"], ["← / →", "Switch result tab (when results focused)"], diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html index 0f3debae66c..27b0ed69a58 100644 --- a/src/librustdoc/html/templates/page.html +++ b/src/librustdoc/html/templates/page.html @@ -135,7 +135,7 @@ aria-label="Run search in the documentation" {#+ #} autocomplete="off" {#+ #} spellcheck="false" {#+ #} - placeholder="Click or press ‘S’ to search, ‘?’ for more options…" {#+ #} + placeholder="Type ‘S’ or ‘/’ to search, ‘?’ for more options…" {#+ #} type="search"> {# #}
{# #} ? {# #} From 5519445cad116f8e5f258a8143c24d13135954a2 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 25 Mar 2024 11:01:28 +0100 Subject: [PATCH 04/27] set --sysroot outside the driver rather than messing with the arguments passed to the driver --- src/tools/miri/README.md | 5 ++--- src/tools/miri/cargo-miri/src/phases.rs | 23 +++++++++++++++------- src/tools/miri/miri-script/src/commands.rs | 18 ++++++++++------- src/tools/miri/src/bin/miri.rs | 19 ------------------ src/tools/miri/tests/ui.rs | 7 +++++++ 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md index 60a1c1fa1dd..28f5f112e91 100644 --- a/src/tools/miri/README.md +++ b/src/tools/miri/README.md @@ -464,10 +464,9 @@ Moreover, Miri recognizes some environment variables: standard library that it will build and use for interpretation. This directory must point to the `library` subdirectory of a `rust-lang/rust` repository checkout. -* `MIRI_SYSROOT` (recognized by `cargo miri` and the Miri driver) indicates the sysroot to use. When +* `MIRI_SYSROOT` (recognized by `cargo miri` and the test suite) indicates the sysroot to use. When using `cargo miri`, this skips the automatic setup -- only set this if you do not want to use the - automatically created sysroot. For directly invoking the Miri driver, this variable (or a - `--sysroot` flag) is mandatory. When invoking `cargo miri setup`, this indicates where the sysroot + automatically created sysroot. When invoking `cargo miri setup`, this indicates where the sysroot will be put. * `MIRI_TEST_TARGET` (recognized by the test suite and the `./miri` script) indicates which target architecture to test against. `miri` and `cargo miri` accept the `--target` flag for the same diff --git a/src/tools/miri/cargo-miri/src/phases.rs b/src/tools/miri/cargo-miri/src/phases.rs index 3f6c484a057..482b3dcbdfb 100644 --- a/src/tools/miri/cargo-miri/src/phases.rs +++ b/src/tools/miri/cargo-miri/src/phases.rs @@ -172,8 +172,6 @@ pub fn phase_cargo_miri(mut args: impl Iterator) { // Forward all further arguments (not consumed by `ArgSplitFlagValue`) to cargo. cmd.args(args); - // Let it know where the Miri sysroot lives. - cmd.env("MIRI_SYSROOT", miri_sysroot); // Set `RUSTC_WRAPPER` to ourselves. Cargo will prepend that binary to its usual invocation, // i.e., the first argument is `rustc` -- which is what we use in `main` to distinguish // the two codepaths. (That extra argument is why we prefer this over setting `RUSTC`.) @@ -200,10 +198,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator) { // always applied. However, buggy build scripts (https://github.com/eyre-rs/eyre/issues/84) and // also cargo (https://github.com/rust-lang/cargo/issues/10885) will invoke `rustc` even when // `RUSTC_WRAPPER` is set, bypassing the wrapper. To make sure everything is coherent, we want - // that to be the Miri driver, but acting as rustc, on the target level. (Target, rather than - // host, is needed for cross-interpretation situations.) This is not a perfect emulation of real - // rustc (it might be unable to produce binaries since the sysroot is check-only), but it's as - // close as we can get, and it's good enough for autocfg. + // that to be the Miri driver, but acting as rustc, in host mode. // // In `main`, we need the value of `RUSTC` to distinguish RUSTC_WRAPPER invocations from rustdoc // or TARGET_RUNNER invocations, so we canonicalize it here to make it exceedingly unlikely that @@ -212,7 +207,10 @@ pub fn phase_cargo_miri(mut args: impl Iterator) { // bootstrap `rustc` thing in our way! Instead, we have MIRI_HOST_SYSROOT to use for host // builds. cmd.env("RUSTC", fs::canonicalize(find_miri()).unwrap()); - cmd.env("MIRI_BE_RUSTC", "target"); // we better remember to *unset* this in the other phases! + // In case we get invoked as RUSTC without the wrapper, let's be a host rustc. This makes no + // sense for cross-interpretation situations, but without the wrapper, this will use the host + // sysroot, so asking it to behave like a target build makes even less sense. + cmd.env("MIRI_BE_RUSTC", "host"); // we better remember to *unset* this in the other phases! // Set rustdoc to us as well, so we can run doctests. if let Some(orig_rustdoc) = env::var_os("RUSTDOC") { @@ -220,6 +218,8 @@ pub fn phase_cargo_miri(mut args: impl Iterator) { } cmd.env("RUSTDOC", &cargo_miri_path); + // Forward some crucial information to our own re-invocations. + cmd.env("MIRI_SYSROOT", miri_sysroot); cmd.env("MIRI_LOCAL_CRATES", local_crates(&metadata)); if verbose > 0 { cmd.env("MIRI_VERBOSE", verbose.to_string()); // This makes the other phases verbose. @@ -412,6 +412,9 @@ fn out_filenames() -> Vec { // Arguments are treated very differently depending on whether this crate is // for interpretation by Miri, or for use by a build script / proc macro. if target_crate { + // Set the sysroot. + cmd.arg("--sysroot").arg(env::var_os("MIRI_SYSROOT").unwrap()); + // Forward arguments, but patched. let emit_flag = "--emit"; // This hack helps bootstrap run standard library tests in Miri. The issue is as follows: @@ -579,6 +582,12 @@ pub fn phase_runner(mut binary_args: impl Iterator, phase: Runner cmd.env(name, val); } + if phase != RunnerPhase::Rustdoc { + // Set the sysroot. Not necessary in rustdoc, where we already set the sysroot when invoking + // rustdoc itself, which will forward that flag when invoking rustc (i.e., us), so the flag + // is present in `info.args`. + cmd.arg("--sysroot").arg(env::var_os("MIRI_SYSROOT").unwrap()); + } // Forward rustc arguments. // We need to patch "--extern" filenames because we forced a check-only // build without cargo knowing about that: replace `.rlib` suffix by diff --git a/src/tools/miri/miri-script/src/commands.rs b/src/tools/miri/miri-script/src/commands.rs index 55b3b62819f..66707dee5e7 100644 --- a/src/tools/miri/miri-script/src/commands.rs +++ b/src/tools/miri/miri-script/src/commands.rs @@ -2,6 +2,7 @@ use std::ffi::OsString; use std::io::Write; use std::ops::Not; +use std::path::PathBuf; use std::process; use std::thread; use std::time; @@ -20,10 +21,11 @@ const JOSH_PORT: &str = "42042"; impl MiriEnv { - fn build_miri_sysroot(&mut self, quiet: bool) -> Result<()> { - if self.sh.var("MIRI_SYSROOT").is_ok() { + /// Returns the location of the sysroot. + fn build_miri_sysroot(&mut self, quiet: bool) -> Result { + if let Some(miri_sysroot) = self.sh.var_os("MIRI_SYSROOT") { // Sysroot already set, use that. - return Ok(()); + return Ok(miri_sysroot.into()); } let manifest_path = path!(self.miri_dir / "cargo-miri" / "Cargo.toml"); let Self { toolchain, cargo_extra_flags, .. } = &self; @@ -57,8 +59,8 @@ fn build_miri_sysroot(&mut self, quiet: bool) -> Result<()> { .with_context(|| "`cargo miri setup` failed")?; panic!("`cargo miri setup` didn't fail again the 2nd time?"); }; - self.sh.set_var("MIRI_SYSROOT", output); - Ok(()) + self.sh.set_var("MIRI_SYSROOT", &output); + Ok(output.into()) } } @@ -505,8 +507,10 @@ fn run(dep: bool, mut flags: Vec) -> Result<()> { flags.push("--edition=2021".into()); // keep in sync with `tests/ui.rs`.` } - // Prepare a sysroot. - e.build_miri_sysroot(/* quiet */ true)?; + // Prepare a sysroot, and add it to the flags. + let miri_sysroot = e.build_miri_sysroot(/* quiet */ true)?; + flags.push("--sysroot".into()); + flags.push(miri_sysroot.into()); // Then run the actual command. Also add MIRIFLAGS. let miri_manifest = path!(e.miri_dir / "Cargo.toml"); diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index 8fffb91542f..67a5bf3d141 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -271,25 +271,6 @@ fn run_compiler( callbacks: &mut (dyn rustc_driver::Callbacks + Send), using_internal_features: std::sync::Arc, ) -> ! { - if target_crate { - // Miri needs a custom sysroot for target crates. - // If no `--sysroot` is given, the `MIRI_SYSROOT` env var is consulted to find where - // that sysroot lives, and that is passed to rustc. - let sysroot_flag = "--sysroot"; - if !args.iter().any(|e| e.starts_with(sysroot_flag)) { - // Using the built-in default here would be plain wrong, so we *require* - // the env var to make sure things make sense. - let miri_sysroot = env::var("MIRI_SYSROOT").unwrap_or_else(|_| { - show_error!( - "Miri was invoked in 'target' mode without `MIRI_SYSROOT` or `--sysroot` being set" - ) - }); - - args.push(sysroot_flag.to_owned()); - args.push(miri_sysroot); - } - } - // Don't insert `MIRI_DEFAULT_ARGS`, in particular, `--cfg=miri`, if we are building // a "host" crate. That may cause procedural macros (and probably build scripts) to // depend on Miri-only symbols, such as `miri_resolve_frame`: diff --git a/src/tools/miri/tests/ui.rs b/src/tools/miri/tests/ui.rs index 7e8d1401183..8d985a05200 100644 --- a/src/tools/miri/tests/ui.rs +++ b/src/tools/miri/tests/ui.rs @@ -112,6 +112,13 @@ fn run_tests( config.program.envs.push(("RUST_BACKTRACE".into(), Some("1".into()))); // Add some flags we always want. + config.program.args.push( + format!( + "--sysroot={}", + env::var("MIRI_SYSROOT").expect("MIRI_SYSROOT must be set to run the ui test suite") + ) + .into(), + ); config.program.args.push("-Dwarnings".into()); config.program.args.push("-Dunused".into()); config.program.args.push("-Ainternal_features".into()); From 9ec38eafc907969c1140bedab06874c2628b38dd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 26 Mar 2024 17:17:05 +0100 Subject: [PATCH 05/27] readme updates --- src/tools/miri/README.md | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md index 28f5f112e91..948f1ee6c63 100644 --- a/src/tools/miri/README.md +++ b/src/tools/miri/README.md @@ -451,35 +451,32 @@ Some native rustc `-Z` flags are also very relevant for Miri: * `-Zmir-emit-retag` controls whether `Retag` statements are emitted. Miri enables this per default because it is needed for [Stacked Borrows] and [Tree Borrows]. -Moreover, Miri recognizes some environment variables: +Moreover, Miri recognizes some environment variables (unless noted otherwise, these are supported +by all intended entry points, i.e. `cargo miri` and `./miri {test,run}`): * `MIRI_AUTO_OPS` indicates whether the automatic execution of rustfmt, clippy and toolchain setup should be skipped. If it is set to `no`, they are skipped. This is used to allow automated IDE actions to avoid the auto ops. * `MIRI_LOG`, `MIRI_BACKTRACE` control logging and backtrace printing during Miri executions, also [see "Testing the Miri driver" in `CONTRIBUTING.md`][testing-miri]. -* `MIRIFLAGS` (recognized by `cargo miri` and the test suite) defines extra - flags to be passed to Miri. -* `MIRI_LIB_SRC` defines the directory where Miri expects the sources of the - standard library that it will build and use for interpretation. This directory - must point to the `library` subdirectory of a `rust-lang/rust` repository - checkout. -* `MIRI_SYSROOT` (recognized by `cargo miri` and the test suite) indicates the sysroot to use. When - using `cargo miri`, this skips the automatic setup -- only set this if you do not want to use the - automatically created sysroot. When invoking `cargo miri setup`, this indicates where the sysroot - will be put. -* `MIRI_TEST_TARGET` (recognized by the test suite and the `./miri` script) indicates which target +* `MIRIFLAGS` defines extra flags to be passed to Miri. +* `MIRI_LIB_SRC` defines the directory where Miri expects the sources of the standard library that + it will build and use for interpretation. This directory must point to the `library` subdirectory + of a `rust-lang/rust` repository checkout. +* `MIRI_SYSROOT` indicates the sysroot to use. When using `cargo miri`, this skips the automatic + setup -- only set this if you do not want to use the automatically created sysroot. When invoking + `cargo miri setup`, this indicates where the sysroot will be put. +* `MIRI_TEST_TARGET` (recognized by `./miri {test,run}`) indicates which target architecture to test against. `miri` and `cargo miri` accept the `--target` flag for the same purpose. -* `MIRI_TEST_THREADS` (recognized by the test suite): set the number of threads to use for running tests. - By default the number of cores is used. -* `MIRI_NO_STD` (recognized by `cargo miri`) makes sure that the target's sysroot is built without - libstd. This allows testing and running no_std programs. - (Miri has a heuristic to detect no-std targets based on the target name; this environment variable - is only needed when that heuristic fails.) -* `RUSTC_BLESS` (recognized by the test suite and `cargo-miri-test/run-test.py`): overwrite all +* `MIRI_TEST_THREADS` (recognized by `./miri test`): set the number of threads to use for running tests. + By default, the number of cores is used. +* `MIRI_NO_STD` makes sure that the target's sysroot is built without libstd. This allows testing + and running no_std programs. (Miri has a heuristic to detect no-std targets based on the target + name; this environment variable is only needed when that heuristic fails.) +* `RUSTC_BLESS` (recognized by `./miri test` and `cargo-miri-test/run-test.py`): overwrite all `stderr` and `stdout` files instead of checking whether the output matches. -* `MIRI_SKIP_UI_CHECKS` (recognized by the test suite): don't check whether the +* `MIRI_SKIP_UI_CHECKS` (recognized by `./miri test`): don't check whether the `stderr` or `stdout` files match the actual output. The following environment variables are *internal* and must not be used by From a57a99041616612c8cd7e0cdfe4eb117f9960644 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Wed, 10 Apr 2024 08:53:07 +0300 Subject: [PATCH 06/27] drop `changelog-seen` It's been 7 months since we deprecated this. It should be fine to remove it now. Signed-off-by: onur-ozkan --- src/bootstrap/src/bin/main.rs | 4 ---- src/bootstrap/src/core/config/config.rs | 16 +--------------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs index 340a5c87f0b..4cb67b7aa62 100644 --- a/src/bootstrap/src/bin/main.rs +++ b/src/bootstrap/src/bin/main.rs @@ -131,10 +131,6 @@ fn main() { fn check_version(config: &Config) -> Option { let mut msg = String::new(); - if config.changelog_seen.is_some() { - msg.push_str("WARNING: The use of `changelog-seen` is deprecated. Please refer to `change-id` option in `config.example.toml` instead.\n"); - } - let latest_change_id = CONFIG_CHANGE_HISTORY.last().unwrap().change_id; let warned_id_path = config.out.join("bootstrap").join(".last-warned-change-id"); diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 96dec975250..334cff2fdc5 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -145,7 +145,6 @@ pub fn is_used(&self) -> bool { /// `config.example.toml`. #[derive(Default, Clone)] pub struct Config { - pub changelog_seen: Option, // FIXME: Deprecated field. Remove it at 2024. pub change_id: Option, pub bypass_bootstrap_lock: bool, pub ccache: Option, @@ -605,7 +604,6 @@ pub fn from_triple(triple: &str) -> Self { #[derive(Deserialize, Default)] #[serde(deny_unknown_fields, rename_all = "kebab-case")] pub(crate) struct TomlConfig { - changelog_seen: Option, // FIXME: Deprecated field. Remove it at 2024. #[serde(flatten)] change_id: ChangeIdWrapper, build: Option, @@ -645,17 +643,7 @@ trait Merge { impl Merge for TomlConfig { fn merge( &mut self, - TomlConfig { - build, - install, - llvm, - rust, - dist, - target, - profile: _, - changelog_seen, - change_id, - }: Self, + TomlConfig { build, install, llvm, rust, dist, target, profile: _, change_id }: Self, replace: ReplaceOpt, ) { fn do_merge(x: &mut Option, y: Option, replace: ReplaceOpt) { @@ -667,7 +655,6 @@ fn do_merge(x: &mut Option, y: Option, replace: ReplaceOpt) { } } } - self.changelog_seen.merge(changelog_seen, replace); self.change_id.inner.merge(change_id.inner, replace); do_merge(&mut self.build, build, replace); do_merge(&mut self.install, install, replace); @@ -1400,7 +1387,6 @@ fn get_table(option: &str) -> Result { } toml.merge(override_toml, ReplaceOpt::Override); - config.changelog_seen = toml.changelog_seen; config.change_id = toml.change_id.inner; let Build { From cce21be686b5ad46705b0fa6472fcef90d87668f Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Wed, 10 Apr 2024 14:10:35 +0300 Subject: [PATCH 07/27] add change entry for the removal of `changelog-seen` Signed-off-by: onur-ozkan --- src/bootstrap/src/utils/change_tracker.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index 277ec00fa62..db3df598a0c 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -170,4 +170,9 @@ pub fn human_readable_changes(changes: &[ChangeInfo]) -> String { severity: ChangeSeverity::Warning, summary: "`rust.split-debuginfo` has been moved to `target..split-debuginfo` and its default value is determined for each target individually.", }, + ChangeInfo { + change_id: 123711, + severity: ChangeSeverity::Warning, + summary: "The deprecated field `changelog-seen` has been removed. Using that field in `config.toml` from now on will result in breakage.", + }, ]; From fb779ee0ac899a08fc9433510359528a335e4ab9 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 15 Apr 2024 09:35:06 +0200 Subject: [PATCH 08/27] Windows: add basic support for FormatMessageW --- src/tools/miri/src/helpers.rs | 41 +++++++++++-------- src/tools/miri/src/shims/os_str.rs | 1 + .../miri/src/shims/windows/foreign_items.rs | 38 +++++++++++++++++ src/tools/miri/tests/pass/shims/fs.rs | 2 +- src/tools/miri/tests/pass/shims/io.rs | 16 +++++++- 5 files changed, 79 insertions(+), 19 deletions(-) diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index 6e320b60eec..84eb5f832dd 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -78,6 +78,17 @@ pub enum AccessKind { ("EAGAIN", WouldBlock), ] }; +// This mapping should match `decode_error_kind` in +// . +const WINDOWS_IO_ERROR_TABLE: &[(&str, std::io::ErrorKind)] = { + use std::io::ErrorKind::*; + // FIXME: this is still incomplete. + &[ + ("ERROR_ACCESS_DENIED", PermissionDenied), + ("ERROR_FILE_NOT_FOUND", NotFound), + ("ERROR_INVALID_PARAMETER", InvalidInput), + ] +}; /// Gets an instance for a path. /// @@ -712,20 +723,12 @@ fn io_error_to_errnum( } throw_unsup_format!("io error {:?} cannot be translated into a raw os error", err_kind) } else if target.families.iter().any(|f| f == "windows") { - // FIXME: we have to finish implementing the Windows equivalent of this. - use std::io::ErrorKind::*; - Ok(this.eval_windows( - "c", - match err_kind { - NotFound => "ERROR_FILE_NOT_FOUND", - PermissionDenied => "ERROR_ACCESS_DENIED", - _ => - throw_unsup_format!( - "io error {:?} cannot be translated into a raw os error", - err_kind - ), - }, - )) + for &(name, kind) in WINDOWS_IO_ERROR_TABLE { + if err_kind == kind { + return Ok(this.eval_windows("c", name)); + } + } + throw_unsup_format!("io error {:?} cannot be translated into a raw os error", err_kind); } else { throw_unsup_format!( "converting io::Error into errnum is unsupported for OS {}", @@ -749,8 +752,14 @@ fn try_errnum_to_io_error( return Ok(Some(kind)); } } - // Our table is as complete as the mapping in std, so we are okay with saying "that's a - // strange one" here. + return Ok(None); + } else if target.families.iter().any(|f| f == "windows") { + let errnum = errnum.to_u32()?; + for &(name, kind) in WINDOWS_IO_ERROR_TABLE { + if errnum == this.eval_windows("c", name).to_u32()? { + return Ok(Some(kind)); + } + } return Ok(None); } else { throw_unsup_format!( diff --git a/src/tools/miri/src/shims/os_str.rs b/src/tools/miri/src/shims/os_str.rs index 62ce2ee58ae..74e8d1d9ed6 100644 --- a/src/tools/miri/src/shims/os_str.rs +++ b/src/tools/miri/src/shims/os_str.rs @@ -98,6 +98,7 @@ fn write_os_str_to_c_str( /// /// If `truncate == true`, then in case `size` is not large enough it *will* write the first /// `size.saturating_sub(1)` many items, followed by a null terminator (if `size > 0`). + /// The return value is still `(false, length)` in that case. fn write_os_str_to_wide_str( &mut self, os_str: &OsStr, diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index 9c6994cec70..2e514b11cb1 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -1,3 +1,4 @@ +use std::ffi::OsStr; use std::iter; use std::str; @@ -533,6 +534,43 @@ fn emulate_foreign_item_inner( this.set_last_error(insufficient_buffer)?; } } + "FormatMessageW" => { + let [flags, module, message_id, language_id, buffer, size, arguments] = + this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?; + + let flags = this.read_scalar(flags)?.to_u32()?; + let _module = this.read_pointer(module)?; // seems to contain a module name + let message_id = this.read_scalar(message_id)?; + let _language_id = this.read_scalar(language_id)?.to_u32()?; + let buffer = this.read_pointer(buffer)?; + let size = this.read_scalar(size)?.to_u32()?; + let _arguments = this.read_pointer(arguments)?; + + // We only support `FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS` + // This also means `arguments` can be ignored. + if flags != 4096u32 | 512u32 { + throw_unsup_format!("FormatMessageW: unsupported flags {flags:#x}"); + } + + let error = this.try_errnum_to_io_error(message_id)?; + let formatted = match error { + Some(err) => format!("{err}"), + None => format!(""), + }; + let (complete, length) = this.write_os_str_to_wide_str( + OsStr::new(&formatted), + buffer, + size.into(), + /*trunacte*/ false, + )?; + if !complete { + // The API docs don't say what happens when the buffer is not big enough... + // Let's just bail. + throw_unsup_format!("FormatMessageW: buffer not big enough"); + } + // The return value is the number of characters stored *excluding* the null terminator. + this.write_int(length.checked_sub(1).unwrap(), dest)?; + } // Incomplete shims that we "stub out" just to get pre-main initialization code to work. // These shims are enabled only when the caller is in the standard library. diff --git a/src/tools/miri/tests/pass/shims/fs.rs b/src/tools/miri/tests/pass/shims/fs.rs index d10faebac7d..8a500b857bc 100644 --- a/src/tools/miri/tests/pass/shims/fs.rs +++ b/src/tools/miri/tests/pass/shims/fs.rs @@ -260,7 +260,7 @@ fn test_errors() { // Opening a non-existing file should fail with a "not found" error. assert_eq!(ErrorKind::NotFound, File::open(&path).unwrap_err().kind()); // Make sure we can also format this. - format!("{0:?}: {0}", File::open(&path).unwrap_err()); + format!("{0}: {0:?}", File::open(&path).unwrap_err()); // Removing a non-existing file should fail with a "not found" error. assert_eq!(ErrorKind::NotFound, remove_file(&path).unwrap_err().kind()); // Reading the metadata of a non-existing file should fail with a "not found" error. diff --git a/src/tools/miri/tests/pass/shims/io.rs b/src/tools/miri/tests/pass/shims/io.rs index 295723957a4..d20fc75b793 100644 --- a/src/tools/miri/tests/pass/shims/io.rs +++ b/src/tools/miri/tests/pass/shims/io.rs @@ -1,7 +1,19 @@ -use std::io::IsTerminal; +use std::io::{self, IsTerminal}; fn main() { // We can't really assume that this is truly a terminal, and anyway on Windows Miri will always // return `false` here, but we can check that the call succeeds. - std::io::stdout().is_terminal(); + io::stdout().is_terminal(); + + // Ensure we can format `io::Error` created from OS errors + // (calls OS-specific error formatting functions). + let raw_os_error = if cfg!(unix) { + 22 // EINVAL (on most Unixes, anyway) + } else if cfg!(windows) { + 87 // ERROR_INVALID_PARAMETER + } else { + panic!("unsupported OS") + }; + let err = io::Error::from_raw_os_error(raw_os_error); + format!("{err}: {err:?}"); } From 3868c9faaf0a885a15f7d5e34e3b3624d7f4d3f9 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 15 Apr 2024 09:53:32 +0200 Subject: [PATCH 09/27] fix error display for './miri run --dep' --- src/tools/miri/tests/ui.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/miri/tests/ui.rs b/src/tools/miri/tests/ui.rs index 7e8d1401183..68446f40e07 100644 --- a/src/tools/miri/tests/ui.rs +++ b/src/tools/miri/tests/ui.rs @@ -296,12 +296,13 @@ fn main() -> Result<()> { fn run_dep_mode(target: String, mut args: impl Iterator) -> Result<()> { let path = args.next().expect("./miri run-dep must be followed by a file name"); - let config = miri_config( + let mut config = miri_config( &target, "", Mode::Yolo { rustfix: RustfixMode::Disabled }, /* with dependencies */ true, ); + config.program.args.clear(); // remove the `--error-format` that ui_test adds by default let dep_args = config.build_dependencies()?; let mut cmd = config.program.build(&config.out_dir); From e928fc58434e89f39a262378ea291b7a1bed6680 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 15 Apr 2024 14:32:22 +0200 Subject: [PATCH 10/27] add some basic support for GetFullPathNameW --- src/tools/miri/src/helpers.rs | 15 +++ src/tools/miri/src/lib.rs | 1 + src/tools/miri/src/shims/env.rs | 25 ++--- src/tools/miri/src/shims/os_str.rs | 24 ++++- .../miri/src/shims/windows/foreign_items.rs | 93 ++++++++++++++++++- src/tools/miri/tests/pass/shims/path.rs | 38 ++++++++ 6 files changed, 174 insertions(+), 22 deletions(-) create mode 100644 src/tools/miri/tests/pass/shims/path.rs diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index 84eb5f832dd..998de80a7eb 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -1285,3 +1285,18 @@ pub(crate) fn simd_element_to_bool(elem: ImmTy<'_, Provenance>) -> InterpResult< _ => throw_ub_format!("each element of a SIMD mask must be all-0-bits or all-1-bits"), }) } + +/// Check whether an operation that writes to a target buffer was successful. +/// Accordingly select return value. +/// Local helper function to be used in Windows shims. +pub(crate) fn windows_check_buffer_size((success, len): (bool, u64)) -> u32 { + if success { + // If the function succeeds, the return value is the number of characters stored in the target buffer, + // not including the terminating null character. + u32::try_from(len.checked_sub(1).unwrap()).unwrap() + } else { + // If the target buffer was not large enough to hold the data, the return value is the buffer size, in characters, + // required to hold the string and its terminating null character. + u32::try_from(len).unwrap() + } +} diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 7821aa9efd4..484908086ac 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -13,6 +13,7 @@ #![feature(let_chains)] #![feature(lint_reasons)] #![feature(trait_upcasting)] +#![feature(absolute_path)] // Configure clippy and other lints #![allow( clippy::collapsible_else_if, diff --git a/src/tools/miri/src/shims/env.rs b/src/tools/miri/src/shims/env.rs index 9e8239cdbac..1779189c9ce 100644 --- a/src/tools/miri/src/shims/env.rs +++ b/src/tools/miri/src/shims/env.rs @@ -9,21 +9,7 @@ use rustc_target::abi::Size; use crate::*; - -/// Check whether an operation that writes to a target buffer was successful. -/// Accordingly select return value. -/// Local helper function to be used in Windows shims. -fn windows_check_buffer_size((success, len): (bool, u64)) -> u32 { - if success { - // If the function succeeds, the return value is the number of characters stored in the target buffer, - // not including the terminating null character. - u32::try_from(len.checked_sub(1).unwrap()).unwrap() - } else { - // If the target buffer was not large enough to hold the data, the return value is the buffer size, in characters, - // required to hold the string and its terminating null character. - u32::try_from(len).unwrap() - } -} +use helpers::windows_check_buffer_size; #[derive(Default)] pub struct EnvVars<'tcx> { @@ -164,7 +150,8 @@ fn GetEnvironmentVariableW( let name_ptr = this.read_pointer(name_op)?; let name = this.read_os_str_from_wide_str(name_ptr)?; Ok(match this.machine.env_vars.map.get(&name) { - Some(var_ptr) => { + Some(&var_ptr) => { + this.set_last_error(Scalar::from_u32(0))?; // make sure this is unambiguously not an error // The offset is used to strip the "{name}=" part of the string. #[rustfmt::skip] let name_offset_bytes = u64::try_from(name.len()).unwrap() @@ -375,10 +362,12 @@ fn GetCurrentDirectoryW( // If we cannot get the current directory, we return 0 match env::current_dir() { - Ok(cwd) => + Ok(cwd) => { + this.set_last_error(Scalar::from_u32(0))?; // make sure this is unambiguously not an error return Ok(Scalar::from_u32(windows_check_buffer_size( this.write_path_to_wide_str(&cwd, buf, size, /*truncate*/ false)?, - ))), + ))); + } Err(e) => this.set_last_error_from_io_error(e.kind())?, } Ok(Scalar::from_u32(0)) diff --git a/src/tools/miri/src/shims/os_str.rs b/src/tools/miri/src/shims/os_str.rs index 74e8d1d9ed6..0157c4845c5 100644 --- a/src/tools/miri/src/shims/os_str.rs +++ b/src/tools/miri/src/shims/os_str.rs @@ -316,9 +316,21 @@ fn convert_path<'a>( // We also have to ensure that absolute paths remain absolute. match direction { PathConversion::HostToTarget => { - // If this start withs a `\`, we add `\\?` so it starts with `\\?\` which is - // some magic path on Windows that *is* considered absolute. - if converted.get(0).copied() == Some(b'\\') { + // If the path is `/C:/`, the leading backslash was probably added by the below + // driver letter handling and we should get rid of it again. + if converted.get(0).copied() == Some(b'\\') + && converted.get(2).copied() == Some(b':') + && converted.get(3).copied() == Some(b'\\') + { + converted.remove(0); + } + // If this start withs a `\` but not a `\\`, then for Windows this is a relative + // path. But the host path is absolute as it started with `/`. We add `\\?` so + // it starts with `\\?\` which is some magic path on Windows that *is* + // considered absolute. + else if converted.get(0).copied() == Some(b'\\') + && converted.get(1).copied() != Some(b'\\') + { converted.splice(0..0, b"\\\\?".iter().copied()); } } @@ -333,6 +345,12 @@ fn convert_path<'a>( // Remove first 3 characters converted.splice(0..3, std::iter::empty()); } + // If it starts with a drive letter, convert it to an absolute Unix path. + else if converted.get(1).copied() == Some(b':') + && converted.get(2).copied() == Some(b'/') + { + converted.insert(0, b'/'); + } } } Cow::Owned(OsString::from_vec(converted)) diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index 2e514b11cb1..de80df3c80d 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -1,5 +1,7 @@ use std::ffi::OsStr; +use std::io; use std::iter; +use std::path::{self, Path, PathBuf}; use std::str; use rustc_span::Symbol; @@ -21,6 +23,61 @@ fn is_dyn_sym(name: &str) -> bool { ) } +#[cfg(windows)] +fn win_absolute<'tcx>(path: &Path) -> InterpResult<'tcx, io::Result> { + // We are on Windows so we can simply lte the host do this. + return Ok(path::absolute(path)); +} + +#[cfg(unix)] +#[allow(clippy::get_first, clippy::arithmetic_side_effects)] +fn win_absolute<'tcx>(path: &Path) -> InterpResult<'tcx, io::Result> { + // We are on Unix, so we need to implement parts of the logic ourselves. + let bytes = path.as_os_str().as_encoded_bytes(); + // If it starts with `//` (these were backslashes but are already converted) + // then this is a magic special path, we just leave it unchanged. + if bytes.get(0).copied() == Some(b'/') && bytes.get(1).copied() == Some(b'/') { + return Ok(Ok(path.into())); + }; + // Special treatment for Windows' magic filenames: they are treated as being relative to `\\.\`. + let magic_filenames = &[ + "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", + "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", + ]; + if magic_filenames.iter().any(|m| m.as_bytes() == bytes) { + let mut result: Vec = br"//./".into(); + result.extend(bytes); + return Ok(Ok(bytes_to_os_str(&result)?.into())); + } + // Otherwise we try to do something kind of close to what Windows does, but this is probably not + // right in all cases. We iterate over the components between `/`, and remove trailing `.`, + // except that trailing `..` remain unchanged. + let mut result = vec![]; + let mut bytes = bytes; // the remaining bytes to process + loop { + let len = bytes.iter().position(|&b| b == b'/').unwrap_or(bytes.len()); + let mut component = &bytes[..len]; + if len >= 2 && component[len - 1] == b'.' && component[len - 2] != b'.' { + // Strip trailing `.` + component = &component[..len - 1]; + } + // Add this component to output. + result.extend(component); + // Prepare next iteration. + if len < bytes.len() { + // There's a component after this; add `/` and process remaining bytes. + result.push(b'/'); + bytes = &bytes[len + 1..]; + continue; + } else { + // This was the last component and it did not have a trailing `/`. + break; + } + } + // Let the host `absolute` function do working-dir handling + Ok(path::absolute(bytes_to_os_str(&result)?)) +} + impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {} pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { fn emulate_foreign_item_inner( @@ -112,7 +169,7 @@ fn emulate_foreign_item_inner( let written = if handle == -11 || handle == -12 { // stdout/stderr - use std::io::{self, Write}; + use io::Write; let buf_cont = this.read_bytes_ptr_strip_provenance(buf, Size::from_bytes(u64::from(n)))?; @@ -146,6 +203,40 @@ fn emulate_foreign_item_inner( dest, )?; } + "GetFullPathNameW" => { + let [filename, size, buffer, filepart] = + this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?; + this.check_no_isolation("`GetFullPathNameW`")?; + + let filename = this.read_pointer(filename)?; + let size = this.read_scalar(size)?.to_u32()?; + let buffer = this.read_pointer(buffer)?; + let filepart = this.read_pointer(filepart)?; + + if !this.ptr_is_null(filepart)? { + throw_unsup_format!("GetFullPathNameW: non-null `lpFilePart` is not supported"); + } + + let filename = this.read_path_from_wide_str(filename)?; + let result = match win_absolute(&filename)? { + Err(err) => { + this.set_last_error_from_io_error(err.kind())?; + Scalar::from_u32(0) // return zero upon failure + } + Ok(abs_filename) => { + this.set_last_error(Scalar::from_u32(0))?; // make sure this is unambiguously not an error + Scalar::from_u32(helpers::windows_check_buffer_size( + this.write_path_to_wide_str( + &abs_filename, + buffer, + size.into(), + /*truncate*/ false, + )?, + )) + } + }; + this.write_scalar(result, dest)?; + } // Allocation "HeapAlloc" => { diff --git a/src/tools/miri/tests/pass/shims/path.rs b/src/tools/miri/tests/pass/shims/path.rs new file mode 100644 index 00000000000..9fc6e7faefb --- /dev/null +++ b/src/tools/miri/tests/pass/shims/path.rs @@ -0,0 +1,38 @@ +//@compile-flags: -Zmiri-disable-isolation +#![feature(absolute_path)] +use std::path::{absolute, Path}; + +#[track_caller] +fn test_absolute(in_: &str, out: &str) { + assert_eq!(absolute(in_).unwrap().as_os_str(), Path::new(out).as_os_str()); +} + +fn main() { + if cfg!(unix) { + test_absolute("/a/b/c", "/a/b/c"); + test_absolute("/a/b/c", "/a/b/c"); + test_absolute("/a//b/c", "/a/b/c"); + test_absolute("//a/b/c", "//a/b/c"); + test_absolute("///a/b/c", "/a/b/c"); + test_absolute("/a/b/c/", "/a/b/c/"); + test_absolute("/a/./b/../c/.././..", "/a/b/../c/../.."); + } else if cfg!(windows) { + // Test that all these are unchanged + test_absolute(r"C:\path\to\file", r"C:\path\to\file"); + test_absolute(r"C:\path\to\file\", r"C:\path\to\file\"); + test_absolute(r"\\server\share\to\file", r"\\server\share\to\file"); + test_absolute(r"\\server.\share.\to\file", r"\\server.\share.\to\file"); + test_absolute(r"\\.\PIPE\name", r"\\.\PIPE\name"); + test_absolute(r"\\.\C:\path\to\COM1", r"\\.\C:\path\to\COM1"); + test_absolute(r"\\?\C:\path\to\file", r"\\?\C:\path\to\file"); + test_absolute(r"\\?\UNC\server\share\to\file", r"\\?\UNC\server\share\to\file"); + test_absolute(r"\\?\PIPE\name", r"\\?\PIPE\name"); + // Verbatim paths are always unchanged, no matter what. + test_absolute(r"\\?\path.\to/file..", r"\\?\path.\to/file.."); + + test_absolute(r"C:\path..\to.\file.", r"C:\path..\to\file"); + test_absolute(r"COM1", r"\\.\COM1"); + } else { + panic!("unsupported OS"); + } +} From 54f90bc33fc97f81000bcc10e639e185cd789510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Sun, 14 Apr 2024 19:30:20 +0200 Subject: [PATCH 11/27] Make `split_simd_to_128bit_chunks` take only one operand It will allow more flexible uses in the future. This makes `split_simd_to_128bit_chunks` simpler, moving some of the complexity to its callers. --- src/tools/miri/src/shims/x86/mod.rs | 75 ++++++++++++----------------- 1 file changed, 32 insertions(+), 43 deletions(-) diff --git a/src/tools/miri/src/shims/x86/mod.rs b/src/tools/miri/src/shims/x86/mod.rs index 2a663d300a7..615821b2e37 100644 --- a/src/tools/miri/src/shims/x86/mod.rs +++ b/src/tools/miri/src/shims/x86/mod.rs @@ -664,54 +664,35 @@ fn convert_float_to_int<'tcx>( Ok(()) } -/// Splits `left`, `right` and `dest` (which must be SIMD vectors) -/// into 128-bit chuncks. -/// -/// `left`, `right` and `dest` cannot have different types. +/// Splits `op` (which must be a SIMD vector) into 128-bit chuncks. /// /// Returns a tuple where: /// * The first element is the number of 128-bit chunks (let's call it `N`). /// * The second element is the number of elements per chunk (let's call it `M`). -/// * The third element is the `left` vector split into chunks, i.e, it's -/// type is `[[T; M]; N]`. -/// * The fourth element is the `right` vector split into chunks. -/// * The fifth element is the `dest` vector split into chunks. -fn split_simd_to_128bit_chunks<'tcx>( +/// * The third element is the `op` vector split into chunks, i.e, it's +/// type is `[[T; M]; N]` where `T` is the element type of `op`. +fn split_simd_to_128bit_chunks<'tcx, P: Projectable<'tcx, Provenance>>( this: &mut crate::MiriInterpCx<'_, 'tcx>, - left: &OpTy<'tcx, Provenance>, - right: &OpTy<'tcx, Provenance>, - dest: &MPlaceTy<'tcx, Provenance>, -) -> InterpResult< - 'tcx, - (u64, u64, MPlaceTy<'tcx, Provenance>, MPlaceTy<'tcx, Provenance>, MPlaceTy<'tcx, Provenance>), -> { - assert_eq!(dest.layout, left.layout); - assert_eq!(dest.layout, right.layout); + op: &P, +) -> InterpResult<'tcx, (u64, u64, P)> { + let simd_layout = op.layout(); + let (simd_len, element_ty) = simd_layout.ty.simd_size_and_type(this.tcx.tcx); - let (left, left_len) = this.operand_to_simd(left)?; - let (right, right_len) = this.operand_to_simd(right)?; - let (dest, dest_len) = this.mplace_to_simd(dest)?; - - assert_eq!(dest_len, left_len); - assert_eq!(dest_len, right_len); - - assert_eq!(dest.layout.size.bits() % 128, 0); - let num_chunks = dest.layout.size.bits() / 128; - assert_eq!(dest_len.checked_rem(num_chunks), Some(0)); - let items_per_chunk = dest_len.checked_div(num_chunks).unwrap(); + assert_eq!(simd_layout.size.bits() % 128, 0); + let num_chunks = simd_layout.size.bits() / 128; + let items_per_chunk = simd_len.checked_div(num_chunks).unwrap(); // Transmute to `[[T; items_per_chunk]; num_chunks]` - let element_layout = left.layout.field(this, 0); - let chunked_layout = this.layout_of(Ty::new_array( - this.tcx.tcx, - Ty::new_array(this.tcx.tcx, element_layout.ty, items_per_chunk), - num_chunks, - ))?; - let left = left.transmute(chunked_layout, this)?; - let right = right.transmute(chunked_layout, this)?; - let dest = dest.transmute(chunked_layout, this)?; + let chunked_layout = this + .layout_of(Ty::new_array( + this.tcx.tcx, + Ty::new_array(this.tcx.tcx, element_ty, items_per_chunk), + num_chunks, + )) + .unwrap(); + let chunked_op = op.transmute(chunked_layout, this)?; - Ok((num_chunks, items_per_chunk, left, right, dest)) + Ok((num_chunks, items_per_chunk, chunked_op)) } /// Horizontaly performs `which` operation on adjacent values of @@ -731,8 +712,12 @@ fn horizontal_bin_op<'tcx>( right: &OpTy<'tcx, Provenance>, dest: &MPlaceTy<'tcx, Provenance>, ) -> InterpResult<'tcx, ()> { - let (num_chunks, items_per_chunk, left, right, dest) = - split_simd_to_128bit_chunks(this, left, right, dest)?; + assert_eq!(left.layout, dest.layout); + assert_eq!(right.layout, dest.layout); + + let (num_chunks, items_per_chunk, left) = split_simd_to_128bit_chunks(this, left)?; + let (_, _, right) = split_simd_to_128bit_chunks(this, right)?; + let (_, _, dest) = split_simd_to_128bit_chunks(this, dest)?; let middle = items_per_chunk / 2; for i in 0..num_chunks { @@ -779,8 +764,12 @@ fn conditional_dot_product<'tcx>( imm: &OpTy<'tcx, Provenance>, dest: &MPlaceTy<'tcx, Provenance>, ) -> InterpResult<'tcx, ()> { - let (num_chunks, items_per_chunk, left, right, dest) = - split_simd_to_128bit_chunks(this, left, right, dest)?; + assert_eq!(left.layout, dest.layout); + assert_eq!(right.layout, dest.layout); + + let (num_chunks, items_per_chunk, left) = split_simd_to_128bit_chunks(this, left)?; + let (_, _, right) = split_simd_to_128bit_chunks(this, right)?; + let (_, _, dest) = split_simd_to_128bit_chunks(this, dest)?; let element_layout = left.layout.field(this, 0).field(this, 0); assert!(items_per_chunk <= 4); From ca2bd01b20c3016cd680e781800a586066f24528 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:51:56 -0400 Subject: [PATCH 12/27] Bump rustc-build-sysroot to 0.4.6 --- src/tools/miri/cargo-miri/Cargo.lock | 4 ++-- src/tools/miri/cargo-miri/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/miri/cargo-miri/Cargo.lock b/src/tools/miri/cargo-miri/Cargo.lock index 6841a345ce1..a1dbc85605f 100644 --- a/src/tools/miri/cargo-miri/Cargo.lock +++ b/src/tools/miri/cargo-miri/Cargo.lock @@ -194,9 +194,9 @@ dependencies = [ [[package]] name = "rustc-build-sysroot" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26170e1d79ea32f7ccec3188dd13cfc1f18c82764a9cbc1071667c0f865a4ea" +checksum = "a9bf37423495cd3a6a9ef8c75fc4566de0d26de0ab75f36f67a426e58df5768c" dependencies = [ "anyhow", "rustc_version", diff --git a/src/tools/miri/cargo-miri/Cargo.toml b/src/tools/miri/cargo-miri/Cargo.toml index 55f6b5ac7ef..b16068b6d19 100644 --- a/src/tools/miri/cargo-miri/Cargo.toml +++ b/src/tools/miri/cargo-miri/Cargo.toml @@ -18,7 +18,7 @@ directories = "5" rustc_version = "0.4" serde_json = "1.0.40" cargo_metadata = "0.18.0" -rustc-build-sysroot = "0.4.1" +rustc-build-sysroot = "0.4.6" # Enable some feature flags that dev-dependencies need but dependencies # do not. This makes `./miri install` after `./miri build` faster. From 67334df1eaceede825f81d19c557b73969528d65 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 15 Apr 2024 16:18:32 +0000 Subject: [PATCH 13/27] The new solver ignores `DefineOpaqueTypes`, so switch it to `Yes` We assert that we are in the new solver in the line above --- compiler/rustc_infer/src/infer/at.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_infer/src/infer/at.rs b/compiler/rustc_infer/src/infer/at.rs index f2222eec76a..1d0afe1709c 100644 --- a/compiler/rustc_infer/src/infer/at.rs +++ b/compiler/rustc_infer/src/infer/at.rs @@ -282,7 +282,7 @@ pub fn eq_structurally_relating_aliases(self, a: T, b: T) -> InferResult<'tcx { let Trace { at, trace } = self; debug_assert!(at.infcx.next_trait_solver()); - let mut fields = at.infcx.combine_fields(trace, at.param_env, DefineOpaqueTypes::No); + let mut fields = at.infcx.combine_fields(trace, at.param_env, DefineOpaqueTypes::Yes); fields .equate(StructurallyRelateAliases::Yes) .relate(a, b) From 909fcfcb6a01b9a811835ba001954e6c62b2a2bc Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 25 Feb 2024 14:56:14 +0100 Subject: [PATCH 14/27] Stabilize checking of cfgs at compile-time: --check-cfg option --- compiler/rustc_session/src/config.rs | 2 +- src/librustdoc/doctest.rs | 7 ++----- src/librustdoc/lib.rs | 2 +- tests/rustdoc-ui/{check-cfg => }/check-cfg.rs | 2 +- tests/rustdoc-ui/{check-cfg => }/check-cfg.stderr | 0 tests/rustdoc-ui/check-cfg/check-cfg-test.stderr | 11 ----------- tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs | 2 -- tests/rustdoc-ui/check-cfg/check-cfg-unstable.stderr | 2 -- tests/ui/check-cfg/allow-at-crate-level.rs | 2 +- tests/ui/check-cfg/allow-macro-cfg.rs | 2 +- tests/ui/check-cfg/allow-same-level.rs | 2 +- tests/ui/check-cfg/allow-top-level.rs | 2 +- tests/ui/check-cfg/allow-upper-level.rs | 2 +- tests/ui/check-cfg/cargo-feature.none.stderr | 8 ++++---- tests/ui/check-cfg/cargo-feature.rs | 1 - tests/ui/check-cfg/cargo-feature.some.stderr | 8 ++++---- .../ui/check-cfg/cfg-value-for-cfg-name-duplicate.rs | 1 - .../check-cfg/cfg-value-for-cfg-name-duplicate.stderr | 2 +- tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.rs | 1 - .../check-cfg/cfg-value-for-cfg-name-multiple.stderr | 2 +- tests/ui/check-cfg/cfg-value-for-cfg-name.rs | 1 - tests/ui/check-cfg/cfg-value-for-cfg-name.stderr | 4 ++-- tests/ui/check-cfg/compact-names.rs | 2 +- tests/ui/check-cfg/compact-values.rs | 2 +- tests/ui/check-cfg/concat-values.rs | 1 - tests/ui/check-cfg/concat-values.stderr | 4 ++-- tests/ui/check-cfg/diagnotics.rs | 2 +- tests/ui/check-cfg/empty-values.rs | 2 +- .../exhaustive-names-values.empty_cfg.stderr | 8 ++++---- .../check-cfg/exhaustive-names-values.feature.stderr | 6 +++--- .../ui/check-cfg/exhaustive-names-values.full.stderr | 6 +++--- tests/ui/check-cfg/exhaustive-names-values.rs | 1 - tests/ui/check-cfg/exhaustive-names.rs | 2 +- tests/ui/check-cfg/exhaustive-values.rs | 4 ++-- tests/ui/check-cfg/invalid-arguments.rs | 1 - tests/ui/check-cfg/mix.rs | 2 +- tests/ui/check-cfg/no-expected-values.empty.stderr | 4 ++-- tests/ui/check-cfg/no-expected-values.mixed.stderr | 4 ++-- tests/ui/check-cfg/no-expected-values.rs | 1 - tests/ui/check-cfg/no-expected-values.simple.stderr | 4 ++-- tests/ui/check-cfg/order-independant.rs | 2 -- .../check-cfg/order-independant.values_after.stderr | 2 +- .../check-cfg/order-independant.values_before.stderr | 2 +- tests/ui/check-cfg/stmt-no-ice.rs | 2 +- tests/ui/check-cfg/unexpected-cfg-name.rs | 2 +- tests/ui/check-cfg/unexpected-cfg-value.rs | 2 +- tests/ui/check-cfg/unknown-values.rs | 1 - tests/ui/check-cfg/values-none.explicit.stderr | 4 ++-- tests/ui/check-cfg/values-none.implicit.stderr | 4 ++-- tests/ui/check-cfg/values-none.rs | 1 - tests/ui/check-cfg/values-target-json.rs | 2 +- tests/ui/check-cfg/well-known-names.rs | 2 +- tests/ui/check-cfg/well-known-values.rs | 2 +- tests/ui/feature-gates/feature-gate-check-cfg.rs | 3 --- tests/ui/feature-gates/feature-gate-check-cfg.stderr | 2 -- 55 files changed, 60 insertions(+), 95 deletions(-) rename tests/rustdoc-ui/{check-cfg => }/check-cfg.rs (73%) rename tests/rustdoc-ui/{check-cfg => }/check-cfg.stderr (100%) delete mode 100644 tests/rustdoc-ui/check-cfg/check-cfg-test.stderr delete mode 100644 tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs delete mode 100644 tests/rustdoc-ui/check-cfg/check-cfg-unstable.stderr delete mode 100644 tests/ui/feature-gates/feature-gate-check-cfg.rs delete mode 100644 tests/ui/feature-gates/feature-gate-check-cfg.stderr diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 7aca86f7169..d9fc43625ef 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1373,7 +1373,7 @@ pub fn rustc_short_optgroups() -> Vec { opt::flag_s("h", "help", "Display this message"), opt::multi_s("", "cfg", "Configure the compilation environment. SPEC supports the syntax `NAME[=\"VALUE\"]`.", "SPEC"), - opt::multi("", "check-cfg", "Provide list of valid cfg options for checking", "SPEC"), + opt::multi_s("", "check-cfg", "Provide list of expected cfgs for checking", "SPEC"), opt::multi_s( "L", "", diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 22a3cf4d44d..0ad4c9c2346 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -60,11 +60,8 @@ pub(crate) fn generate_args_file(file_path: &Path, options: &RustdocOptions) -> for cfg in &options.cfgs { content.push(format!("--cfg={cfg}")); } - if !options.check_cfgs.is_empty() { - content.push("-Zunstable-options".to_string()); - for check_cfg in &options.check_cfgs { - content.push(format!("--check-cfg={check_cfg}")); - } + for check_cfg in &options.check_cfgs { + content.push(format!("--check-cfg={check_cfg}")); } for lib_str in &options.lib_strs { diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index b78fb4c4eee..f2a7518b4ce 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -242,7 +242,7 @@ fn opts() -> Vec { o.optmulti("L", "library-path", "directory to add to crate search path", "DIR") }), stable("cfg", |o| o.optmulti("", "cfg", "pass a --cfg to rustc", "")), - unstable("check-cfg", |o| o.optmulti("", "check-cfg", "pass a --check-cfg to rustc", "")), + stable("check-cfg", |o| o.optmulti("", "check-cfg", "pass a --check-cfg to rustc", "")), stable("extern", |o| o.optmulti("", "extern", "pass an --extern to rustc", "NAME[=PATH]")), unstable("extern-html-root-url", |o| { o.optmulti( diff --git a/tests/rustdoc-ui/check-cfg/check-cfg.rs b/tests/rustdoc-ui/check-cfg.rs similarity index 73% rename from tests/rustdoc-ui/check-cfg/check-cfg.rs rename to tests/rustdoc-ui/check-cfg.rs index 27b09985728..6ca37db75af 100644 --- a/tests/rustdoc-ui/check-cfg/check-cfg.rs +++ b/tests/rustdoc-ui/check-cfg.rs @@ -1,5 +1,5 @@ //@ check-pass -//@ compile-flags: --check-cfg=cfg() -Z unstable-options +//@ compile-flags: --check-cfg=cfg() /// uniz is nor a builtin nor pass as arguments so is unexpected #[cfg(uniz)] diff --git a/tests/rustdoc-ui/check-cfg/check-cfg.stderr b/tests/rustdoc-ui/check-cfg.stderr similarity index 100% rename from tests/rustdoc-ui/check-cfg/check-cfg.stderr rename to tests/rustdoc-ui/check-cfg.stderr diff --git a/tests/rustdoc-ui/check-cfg/check-cfg-test.stderr b/tests/rustdoc-ui/check-cfg/check-cfg-test.stderr deleted file mode 100644 index 9770be2f191..00000000000 --- a/tests/rustdoc-ui/check-cfg/check-cfg-test.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: unexpected `cfg` condition value - --> $DIR/check-cfg-test.rs:9:7 - | -LL | #[cfg(feature = "invalid")] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: expected values for `feature` are: test - = note: `#[warn(unexpected_cfgs)]` on by default - -warning: 1 warning emitted - diff --git a/tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs b/tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs deleted file mode 100644 index b24b198e807..00000000000 --- a/tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs +++ /dev/null @@ -1,2 +0,0 @@ -//@ check-fail -//@ compile-flags: --check-cfg=cfg() diff --git a/tests/rustdoc-ui/check-cfg/check-cfg-unstable.stderr b/tests/rustdoc-ui/check-cfg/check-cfg-unstable.stderr deleted file mode 100644 index 9b27c2bc058..00000000000 --- a/tests/rustdoc-ui/check-cfg/check-cfg-unstable.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: the `-Z unstable-options` flag must also be passed to enable the flag `check-cfg` - diff --git a/tests/ui/check-cfg/allow-at-crate-level.rs b/tests/ui/check-cfg/allow-at-crate-level.rs index 48258b97ccc..03b4676ad5f 100644 --- a/tests/ui/check-cfg/allow-at-crate-level.rs +++ b/tests/ui/check-cfg/allow-at-crate-level.rs @@ -1,7 +1,7 @@ // This test check that #![allow(unexpected_cfgs)] works with --cfg // //@ check-pass -//@ compile-flags: --cfg=unexpected --check-cfg=cfg() -Z unstable-options +//@ compile-flags: --cfg=unexpected --check-cfg=cfg() #![allow(unexpected_cfgs)] diff --git a/tests/ui/check-cfg/allow-macro-cfg.rs b/tests/ui/check-cfg/allow-macro-cfg.rs index d3999af7766..3db6e18d77a 100644 --- a/tests/ui/check-cfg/allow-macro-cfg.rs +++ b/tests/ui/check-cfg/allow-macro-cfg.rs @@ -1,7 +1,7 @@ // This test check that local #[allow(unexpected_cfgs)] works // //@ check-pass -//@ compile-flags: --check-cfg=cfg() -Z unstable-options +//@ compile-flags: --check-cfg=cfg() #[allow(unexpected_cfgs)] fn foo() { diff --git a/tests/ui/check-cfg/allow-same-level.rs b/tests/ui/check-cfg/allow-same-level.rs index 231ad522c8d..e932ece6ee7 100644 --- a/tests/ui/check-cfg/allow-same-level.rs +++ b/tests/ui/check-cfg/allow-same-level.rs @@ -1,7 +1,7 @@ // This test check that #[allow(unexpected_cfgs)] doesn't work if put on the same level // //@ check-pass -//@ compile-flags: --check-cfg=cfg() -Z unstable-options +//@ compile-flags: --check-cfg=cfg() #[allow(unexpected_cfgs)] #[cfg(FALSE)] diff --git a/tests/ui/check-cfg/allow-top-level.rs b/tests/ui/check-cfg/allow-top-level.rs index c77a0c7c97b..0f88543d847 100644 --- a/tests/ui/check-cfg/allow-top-level.rs +++ b/tests/ui/check-cfg/allow-top-level.rs @@ -1,7 +1,7 @@ // This test check that a top-level #![allow(unexpected_cfgs)] works // //@ check-pass -//@ compile-flags: --check-cfg=cfg() -Z unstable-options +//@ compile-flags: --check-cfg=cfg() #![allow(unexpected_cfgs)] diff --git a/tests/ui/check-cfg/allow-upper-level.rs b/tests/ui/check-cfg/allow-upper-level.rs index 97339a887bf..d03d0cab37b 100644 --- a/tests/ui/check-cfg/allow-upper-level.rs +++ b/tests/ui/check-cfg/allow-upper-level.rs @@ -1,7 +1,7 @@ // This test check that #[allow(unexpected_cfgs)] work if put on an upper level // //@ check-pass -//@ compile-flags: --check-cfg=cfg() -Z unstable-options +//@ compile-flags: --check-cfg=cfg() #[allow(unexpected_cfgs)] mod aa { diff --git a/tests/ui/check-cfg/cargo-feature.none.stderr b/tests/ui/check-cfg/cargo-feature.none.stderr index 09a1c950267..0b914c2bc35 100644 --- a/tests/ui/check-cfg/cargo-feature.none.stderr +++ b/tests/ui/check-cfg/cargo-feature.none.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `serde` - --> $DIR/cargo-feature.rs:14:7 + --> $DIR/cargo-feature.rs:13:7 | LL | #[cfg(feature = "serde")] | ^^^^^^^^^^^^^^^^^ help: remove the condition @@ -10,7 +10,7 @@ LL | #[cfg(feature = "serde")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: (none) - --> $DIR/cargo-feature.rs:18:7 + --> $DIR/cargo-feature.rs:17:7 | LL | #[cfg(feature)] | ^^^^^^^ help: remove the condition @@ -20,7 +20,7 @@ LL | #[cfg(feature)] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `tokio_unstable` - --> $DIR/cargo-feature.rs:22:7 + --> $DIR/cargo-feature.rs:21:7 | LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | #[cfg(tokio_unstable)] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `CONFIG_NVME` - --> $DIR/cargo-feature.rs:26:7 + --> $DIR/cargo-feature.rs:25:7 | LL | #[cfg(CONFIG_NVME = "m")] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/cargo-feature.rs b/tests/ui/check-cfg/cargo-feature.rs index ba451921d79..ced0d381d2d 100644 --- a/tests/ui/check-cfg/cargo-feature.rs +++ b/tests/ui/check-cfg/cargo-feature.rs @@ -5,7 +5,6 @@ //@ check-pass //@ revisions: some none //@ rustc-env:CARGO_CRATE_NAME=foo -//@ compile-flags: -Z unstable-options //@ [none]compile-flags: --check-cfg=cfg(feature,values()) //@ [some]compile-flags: --check-cfg=cfg(feature,values("bitcode")) //@ [some]compile-flags: --check-cfg=cfg(CONFIG_NVME,values("y")) diff --git a/tests/ui/check-cfg/cargo-feature.some.stderr b/tests/ui/check-cfg/cargo-feature.some.stderr index 4db9c66fc86..1a4ef89efc1 100644 --- a/tests/ui/check-cfg/cargo-feature.some.stderr +++ b/tests/ui/check-cfg/cargo-feature.some.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `serde` - --> $DIR/cargo-feature.rs:14:7 + --> $DIR/cargo-feature.rs:13:7 | LL | #[cfg(feature = "serde")] | ^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg(feature = "serde")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: (none) - --> $DIR/cargo-feature.rs:18:7 + --> $DIR/cargo-feature.rs:17:7 | LL | #[cfg(feature)] | ^^^^^^^- help: specify a config value: `= "bitcode"` @@ -20,7 +20,7 @@ LL | #[cfg(feature)] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `tokio_unstable` - --> $DIR/cargo-feature.rs:22:7 + --> $DIR/cargo-feature.rs:21:7 | LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | #[cfg(tokio_unstable)] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `m` - --> $DIR/cargo-feature.rs:26:7 + --> $DIR/cargo-feature.rs:25:7 | LL | #[cfg(CONFIG_NVME = "m")] | ^^^^^^^^^^^^^^--- diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.rs b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.rs index 35c5f2ae31c..79d4e45c13b 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.rs +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.rs @@ -2,7 +2,6 @@ // This test checks we won't suggest more than 3 span suggestions for cfg names // //@ check-pass -//@ compile-flags: -Z unstable-options //@ compile-flags: --check-cfg=cfg(foo,values("value")) --check-cfg=cfg(bar,values("value")) --check-cfg=cfg(bee,values("value")) --check-cfg=cfg(cow,values("value")) #[cfg(value)] diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr index 9c190117e74..46d6d29b15e 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `value` - --> $DIR/cfg-value-for-cfg-name-duplicate.rs:8:7 + --> $DIR/cfg-value-for-cfg-name-duplicate.rs:7:7 | LL | #[cfg(value)] | ^^^^^ diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.rs b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.rs index 6caedbe719e..f2fd050bb75 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.rs +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.rs @@ -2,7 +2,6 @@ // This test checks that when a single cfg has a value for user's specified name // //@ check-pass -//@ compile-flags: -Z unstable-options //@ compile-flags: --check-cfg=cfg(foo,values("my_value")) --check-cfg=cfg(bar,values("my_value")) #[cfg(my_value)] diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr index 7113790b83a..a70a8b2d3e4 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `my_value` - --> $DIR/cfg-value-for-cfg-name-multiple.rs:8:7 + --> $DIR/cfg-value-for-cfg-name-multiple.rs:7:7 | LL | #[cfg(my_value)] | ^^^^^^^^ diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name.rs b/tests/ui/check-cfg/cfg-value-for-cfg-name.rs index eade190a75c..e8f9095655b 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name.rs +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name.rs @@ -3,7 +3,6 @@ // suggest to use `#[cfg(target_os = "linux")]` instead of `#[cfg(linux)]` // //@ check-pass -//@ compile-flags: -Z unstable-options //@ compile-flags: --check-cfg=cfg() #[cfg(linux)] diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr index ba9f5f4acbd..fab7f595c25 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `linux` - --> $DIR/cfg-value-for-cfg-name.rs:9:7 + --> $DIR/cfg-value-for-cfg-name.rs:8:7 | LL | #[cfg(linux)] | ^^^^^ help: found config with similar value: `target_os = "linux"` @@ -10,7 +10,7 @@ LL | #[cfg(linux)] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `linux` - --> $DIR/cfg-value-for-cfg-name.rs:14:7 + --> $DIR/cfg-value-for-cfg-name.rs:13:7 | LL | #[cfg(linux = "os-name")] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/compact-names.rs b/tests/ui/check-cfg/compact-names.rs index 6592d2acb82..ddbd20b99b2 100644 --- a/tests/ui/check-cfg/compact-names.rs +++ b/tests/ui/check-cfg/compact-names.rs @@ -1,7 +1,7 @@ // This test check that we correctly emit an warning for compact cfg // //@ check-pass -//@ compile-flags: --check-cfg=cfg() -Z unstable-options +//@ compile-flags: --check-cfg=cfg() #![feature(cfg_target_compact)] diff --git a/tests/ui/check-cfg/compact-values.rs b/tests/ui/check-cfg/compact-values.rs index 8df2bf55264..bda4686ebd7 100644 --- a/tests/ui/check-cfg/compact-values.rs +++ b/tests/ui/check-cfg/compact-values.rs @@ -1,7 +1,7 @@ // This test check that we correctly emit an warning for compact cfg // //@ check-pass -//@ compile-flags: --check-cfg=cfg() -Z unstable-options +//@ compile-flags: --check-cfg=cfg() #![feature(cfg_target_compact)] diff --git a/tests/ui/check-cfg/concat-values.rs b/tests/ui/check-cfg/concat-values.rs index 0b2c1949ca3..c546590a2c1 100644 --- a/tests/ui/check-cfg/concat-values.rs +++ b/tests/ui/check-cfg/concat-values.rs @@ -1,5 +1,4 @@ //@ check-pass -//@ compile-flags: -Z unstable-options //@ compile-flags: --check-cfg=cfg(my_cfg,values("foo")) --check-cfg=cfg(my_cfg,values("bar")) //@ compile-flags: --check-cfg=cfg(my_cfg,values()) diff --git a/tests/ui/check-cfg/concat-values.stderr b/tests/ui/check-cfg/concat-values.stderr index 6fe9f2baa09..dec43f5bda3 100644 --- a/tests/ui/check-cfg/concat-values.stderr +++ b/tests/ui/check-cfg/concat-values.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: (none) - --> $DIR/concat-values.rs:6:7 + --> $DIR/concat-values.rs:5:7 | LL | #[cfg(my_cfg)] | ^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg(my_cfg)] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `unk` - --> $DIR/concat-values.rs:10:7 + --> $DIR/concat-values.rs:9:7 | LL | #[cfg(my_cfg = "unk")] | ^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/diagnotics.rs b/tests/ui/check-cfg/diagnotics.rs index 134bfcf8ef4..cccd6f9bbc3 100644 --- a/tests/ui/check-cfg/diagnotics.rs +++ b/tests/ui/check-cfg/diagnotics.rs @@ -2,7 +2,7 @@ //@ revisions: cargo rustc //@ [rustc]unset-rustc-env:CARGO_CRATE_NAME //@ [cargo]rustc-env:CARGO_CRATE_NAME=foo -//@ compile-flags: --check-cfg=cfg(feature,values("foo")) --check-cfg=cfg(no_values) -Z unstable-options +//@ compile-flags: --check-cfg=cfg(feature,values("foo")) --check-cfg=cfg(no_values) #[cfg(featur)] //~^ WARNING unexpected `cfg` condition name diff --git a/tests/ui/check-cfg/empty-values.rs b/tests/ui/check-cfg/empty-values.rs index 07462951e1b..cad2d351b96 100644 --- a/tests/ui/check-cfg/empty-values.rs +++ b/tests/ui/check-cfg/empty-values.rs @@ -1,7 +1,7 @@ // Check that we detect unexpected value when none are allowed // //@ check-pass -//@ compile-flags: --check-cfg=cfg(foo,values()) -Zunstable-options +//@ compile-flags: --check-cfg=cfg(foo,values()) #[cfg(foo = "foo")] //~^ WARNING unexpected `cfg` condition value diff --git a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr index d2870263342..5d1fc74137b 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `unknown_key` - --> $DIR/exhaustive-names-values.rs:10:7 + --> $DIR/exhaustive-names-values.rs:9:7 | LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg(unknown_key = "value")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` - --> $DIR/exhaustive-names-values.rs:14:7 + --> $DIR/exhaustive-names-values.rs:13:7 | LL | #[cfg(test = "value")] | ^^^^---------- @@ -21,7 +21,7 @@ LL | #[cfg(test = "value")] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` - --> $DIR/exhaustive-names-values.rs:18:7 + --> $DIR/exhaustive-names-values.rs:17:7 | LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | #[cfg(feature = "unk")] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` - --> $DIR/exhaustive-names-values.rs:25:7 + --> $DIR/exhaustive-names-values.rs:24:7 | LL | #[cfg(feature = "std")] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr index b24b10bb615..9be2ec71b44 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `unknown_key` - --> $DIR/exhaustive-names-values.rs:10:7 + --> $DIR/exhaustive-names-values.rs:9:7 | LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg(unknown_key = "value")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` - --> $DIR/exhaustive-names-values.rs:14:7 + --> $DIR/exhaustive-names-values.rs:13:7 | LL | #[cfg(test = "value")] | ^^^^---------- @@ -21,7 +21,7 @@ LL | #[cfg(test = "value")] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` - --> $DIR/exhaustive-names-values.rs:18:7 + --> $DIR/exhaustive-names-values.rs:17:7 | LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr index b24b10bb615..9be2ec71b44 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.full.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `unknown_key` - --> $DIR/exhaustive-names-values.rs:10:7 + --> $DIR/exhaustive-names-values.rs:9:7 | LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg(unknown_key = "value")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` - --> $DIR/exhaustive-names-values.rs:14:7 + --> $DIR/exhaustive-names-values.rs:13:7 | LL | #[cfg(test = "value")] | ^^^^---------- @@ -21,7 +21,7 @@ LL | #[cfg(test = "value")] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` - --> $DIR/exhaustive-names-values.rs:18:7 + --> $DIR/exhaustive-names-values.rs:17:7 | LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/exhaustive-names-values.rs b/tests/ui/check-cfg/exhaustive-names-values.rs index d554c19ef25..f6c3e1f575a 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.rs +++ b/tests/ui/check-cfg/exhaustive-names-values.rs @@ -2,7 +2,6 @@ // //@ check-pass //@ revisions: empty_cfg feature full -//@ compile-flags: -Z unstable-options //@ [empty_cfg]compile-flags: --check-cfg=cfg() //@ [feature]compile-flags: --check-cfg=cfg(feature,values("std")) //@ [full]compile-flags: --check-cfg=cfg(feature,values("std")) --check-cfg=cfg() diff --git a/tests/ui/check-cfg/exhaustive-names.rs b/tests/ui/check-cfg/exhaustive-names.rs index edfb3705a7d..23bde4dff55 100644 --- a/tests/ui/check-cfg/exhaustive-names.rs +++ b/tests/ui/check-cfg/exhaustive-names.rs @@ -1,7 +1,7 @@ // Check warning for unexpected cfg // //@ check-pass -//@ compile-flags: --check-cfg=cfg() -Z unstable-options +//@ compile-flags: --check-cfg=cfg() #[cfg(unknown_key = "value")] //~^ WARNING unexpected `cfg` condition name diff --git a/tests/ui/check-cfg/exhaustive-values.rs b/tests/ui/check-cfg/exhaustive-values.rs index 5e65caa6aea..029b2ff2c69 100644 --- a/tests/ui/check-cfg/exhaustive-values.rs +++ b/tests/ui/check-cfg/exhaustive-values.rs @@ -2,8 +2,8 @@ // //@ check-pass //@ revisions: empty_cfg without_names -//@ [empty_cfg]compile-flags: --check-cfg=cfg() -Z unstable-options -//@ [without_names]compile-flags: --check-cfg=cfg(any()) -Z unstable-options +//@ [empty_cfg]compile-flags: --check-cfg=cfg() +//@ [without_names]compile-flags: --check-cfg=cfg(any()) #[cfg(test = "value")] //~^ WARNING unexpected `cfg` condition value diff --git a/tests/ui/check-cfg/invalid-arguments.rs b/tests/ui/check-cfg/invalid-arguments.rs index bdcc202443b..84087a16e80 100644 --- a/tests/ui/check-cfg/invalid-arguments.rs +++ b/tests/ui/check-cfg/invalid-arguments.rs @@ -9,7 +9,6 @@ //@ revisions: mixed_values_any mixed_any any_values giberich unterminated //@ revisions: none_not_empty cfg_none // -//@ compile-flags: -Z unstable-options //@ [anything_else]compile-flags: --check-cfg=anything_else(...) //@ [string_for_name_1]compile-flags: --check-cfg=cfg("NOT_IDENT") //@ [string_for_name_2]compile-flags: --check-cfg=cfg(foo,"NOT_IDENT",bar) diff --git a/tests/ui/check-cfg/mix.rs b/tests/ui/check-cfg/mix.rs index 69156ab6763..ab8a180bc6f 100644 --- a/tests/ui/check-cfg/mix.rs +++ b/tests/ui/check-cfg/mix.rs @@ -3,7 +3,7 @@ // we correctly lint on the `cfg!` macro and `cfg_attr` attribute. // //@ check-pass -//@ compile-flags: --cfg feature="bar" --cfg unknown_name -Z unstable-options +//@ compile-flags: --cfg feature="bar" --cfg unknown_name //@ compile-flags: --check-cfg=cfg(feature,values("foo")) #[cfg(windows)] diff --git a/tests/ui/check-cfg/no-expected-values.empty.stderr b/tests/ui/check-cfg/no-expected-values.empty.stderr index 0c0dbe9bac6..65827efdd39 100644 --- a/tests/ui/check-cfg/no-expected-values.empty.stderr +++ b/tests/ui/check-cfg/no-expected-values.empty.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `foo` - --> $DIR/no-expected-values.rs:11:7 + --> $DIR/no-expected-values.rs:10:7 | LL | #[cfg(feature = "foo")] | ^^^^^^^-------- @@ -12,7 +12,7 @@ LL | #[cfg(feature = "foo")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` - --> $DIR/no-expected-values.rs:15:7 + --> $DIR/no-expected-values.rs:14:7 | LL | #[cfg(test = "foo")] | ^^^^-------- diff --git a/tests/ui/check-cfg/no-expected-values.mixed.stderr b/tests/ui/check-cfg/no-expected-values.mixed.stderr index 0c0dbe9bac6..65827efdd39 100644 --- a/tests/ui/check-cfg/no-expected-values.mixed.stderr +++ b/tests/ui/check-cfg/no-expected-values.mixed.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `foo` - --> $DIR/no-expected-values.rs:11:7 + --> $DIR/no-expected-values.rs:10:7 | LL | #[cfg(feature = "foo")] | ^^^^^^^-------- @@ -12,7 +12,7 @@ LL | #[cfg(feature = "foo")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` - --> $DIR/no-expected-values.rs:15:7 + --> $DIR/no-expected-values.rs:14:7 | LL | #[cfg(test = "foo")] | ^^^^-------- diff --git a/tests/ui/check-cfg/no-expected-values.rs b/tests/ui/check-cfg/no-expected-values.rs index a80f9ec9776..42e7f45fa7a 100644 --- a/tests/ui/check-cfg/no-expected-values.rs +++ b/tests/ui/check-cfg/no-expected-values.rs @@ -2,7 +2,6 @@ // //@ check-pass //@ revisions: simple mixed empty -//@ compile-flags: -Z unstable-options //@ compile-flags: --check-cfg=cfg(values,simple,mixed,empty) //@ [simple]compile-flags: --check-cfg=cfg(test) --check-cfg=cfg(feature) //@ [mixed]compile-flags: --check-cfg=cfg(test,feature) diff --git a/tests/ui/check-cfg/no-expected-values.simple.stderr b/tests/ui/check-cfg/no-expected-values.simple.stderr index 0c0dbe9bac6..65827efdd39 100644 --- a/tests/ui/check-cfg/no-expected-values.simple.stderr +++ b/tests/ui/check-cfg/no-expected-values.simple.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `foo` - --> $DIR/no-expected-values.rs:11:7 + --> $DIR/no-expected-values.rs:10:7 | LL | #[cfg(feature = "foo")] | ^^^^^^^-------- @@ -12,7 +12,7 @@ LL | #[cfg(feature = "foo")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` - --> $DIR/no-expected-values.rs:15:7 + --> $DIR/no-expected-values.rs:14:7 | LL | #[cfg(test = "foo")] | ^^^^-------- diff --git a/tests/ui/check-cfg/order-independant.rs b/tests/ui/check-cfg/order-independant.rs index 9ac96d0b15b..671d2e764d3 100644 --- a/tests/ui/check-cfg/order-independant.rs +++ b/tests/ui/check-cfg/order-independant.rs @@ -1,9 +1,7 @@ //@ check-pass // //@ revisions: values_before values_after -//@ compile-flags: -Z unstable-options //@ compile-flags: --check-cfg=cfg(values_before,values_after) -// //@ [values_before]compile-flags: --check-cfg=cfg(a,values("b")) --check-cfg=cfg(a) //@ [values_after]compile-flags: --check-cfg=cfg(a) --check-cfg=cfg(a,values("b")) diff --git a/tests/ui/check-cfg/order-independant.values_after.stderr b/tests/ui/check-cfg/order-independant.values_after.stderr index d1de26ba303..2be28be39a7 100644 --- a/tests/ui/check-cfg/order-independant.values_after.stderr +++ b/tests/ui/check-cfg/order-independant.values_after.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `unk` - --> $DIR/order-independant.rs:13:7 + --> $DIR/order-independant.rs:11:7 | LL | #[cfg(a = "unk")] | ^^^^^^^^^ diff --git a/tests/ui/check-cfg/order-independant.values_before.stderr b/tests/ui/check-cfg/order-independant.values_before.stderr index d1de26ba303..2be28be39a7 100644 --- a/tests/ui/check-cfg/order-independant.values_before.stderr +++ b/tests/ui/check-cfg/order-independant.values_before.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `unk` - --> $DIR/order-independant.rs:13:7 + --> $DIR/order-independant.rs:11:7 | LL | #[cfg(a = "unk")] | ^^^^^^^^^ diff --git a/tests/ui/check-cfg/stmt-no-ice.rs b/tests/ui/check-cfg/stmt-no-ice.rs index 8a447ade068..866a5836db0 100644 --- a/tests/ui/check-cfg/stmt-no-ice.rs +++ b/tests/ui/check-cfg/stmt-no-ice.rs @@ -1,7 +1,7 @@ // This test checks that there is no ICE with this code // //@ check-pass -//@ compile-flags:--check-cfg=cfg() -Z unstable-options +//@ compile-flags:--check-cfg=cfg() fn main() { #[cfg(crossbeam_loom)] diff --git a/tests/ui/check-cfg/unexpected-cfg-name.rs b/tests/ui/check-cfg/unexpected-cfg-name.rs index 5ea9f560ee4..365c29d10fb 100644 --- a/tests/ui/check-cfg/unexpected-cfg-name.rs +++ b/tests/ui/check-cfg/unexpected-cfg-name.rs @@ -1,7 +1,7 @@ // Check warning for unexpected configuration name // //@ check-pass -//@ compile-flags: --check-cfg=cfg() -Z unstable-options +//@ compile-flags: --check-cfg=cfg() #[cfg(widnows)] //~^ WARNING unexpected `cfg` condition name diff --git a/tests/ui/check-cfg/unexpected-cfg-value.rs b/tests/ui/check-cfg/unexpected-cfg-value.rs index a4a10e503be..583cf40c485 100644 --- a/tests/ui/check-cfg/unexpected-cfg-value.rs +++ b/tests/ui/check-cfg/unexpected-cfg-value.rs @@ -1,7 +1,7 @@ // Check for unexpected configuration value in the code. // //@ check-pass -//@ compile-flags: --cfg=feature="rand" -Z unstable-options +//@ compile-flags: --cfg=feature="rand" //@ compile-flags: --check-cfg=cfg(feature,values("serde","full")) #[cfg(feature = "sedre")] diff --git a/tests/ui/check-cfg/unknown-values.rs b/tests/ui/check-cfg/unknown-values.rs index 61ea82871b2..7b2b00fe9d4 100644 --- a/tests/ui/check-cfg/unknown-values.rs +++ b/tests/ui/check-cfg/unknown-values.rs @@ -2,7 +2,6 @@ // //@ check-pass //@ revisions: simple mixed with_values -//@ compile-flags: -Z unstable-options //@ compile-flags: --check-cfg=cfg(simple,mixed,with_values) //@ [simple]compile-flags: --check-cfg=cfg(foo,values(any())) //@ [mixed]compile-flags: --check-cfg=cfg(foo) --check-cfg=cfg(foo,values(any())) diff --git a/tests/ui/check-cfg/values-none.explicit.stderr b/tests/ui/check-cfg/values-none.explicit.stderr index a025ff441b7..c14cde94005 100644 --- a/tests/ui/check-cfg/values-none.explicit.stderr +++ b/tests/ui/check-cfg/values-none.explicit.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `too` - --> $DIR/values-none.rs:11:7 + --> $DIR/values-none.rs:10:7 | LL | #[cfg(foo = "too")] | ^^^-------- @@ -12,7 +12,7 @@ LL | #[cfg(foo = "too")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `bar` - --> $DIR/values-none.rs:16:7 + --> $DIR/values-none.rs:15:7 | LL | #[cfg(foo = "bar")] | ^^^-------- diff --git a/tests/ui/check-cfg/values-none.implicit.stderr b/tests/ui/check-cfg/values-none.implicit.stderr index a025ff441b7..c14cde94005 100644 --- a/tests/ui/check-cfg/values-none.implicit.stderr +++ b/tests/ui/check-cfg/values-none.implicit.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `too` - --> $DIR/values-none.rs:11:7 + --> $DIR/values-none.rs:10:7 | LL | #[cfg(foo = "too")] | ^^^-------- @@ -12,7 +12,7 @@ LL | #[cfg(foo = "too")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `bar` - --> $DIR/values-none.rs:16:7 + --> $DIR/values-none.rs:15:7 | LL | #[cfg(foo = "bar")] | ^^^-------- diff --git a/tests/ui/check-cfg/values-none.rs b/tests/ui/check-cfg/values-none.rs index 6a68020e418..bd9c0255b7d 100644 --- a/tests/ui/check-cfg/values-none.rs +++ b/tests/ui/check-cfg/values-none.rs @@ -1,7 +1,6 @@ //@ check-pass // //@ revisions: explicit implicit -//@ compile-flags: -Zunstable-options //@ [explicit]compile-flags: --check-cfg=cfg(foo,values(none())) //@ [implicit]compile-flags: --check-cfg=cfg(foo) //@ [simple] compile-flags: --check-cfg=cfg(foo,values(none(),"too")) diff --git a/tests/ui/check-cfg/values-target-json.rs b/tests/ui/check-cfg/values-target-json.rs index afe6e0aaffd..f3a27043e67 100644 --- a/tests/ui/check-cfg/values-target-json.rs +++ b/tests/ui/check-cfg/values-target-json.rs @@ -2,7 +2,7 @@ // //@ check-pass //@ needs-llvm-components: x86 -//@ compile-flags: --crate-type=lib --check-cfg=cfg() --target={{src-base}}/check-cfg/my-awesome-platform.json -Z unstable-options +//@ compile-flags: --crate-type=lib --check-cfg=cfg() --target={{src-base}}/check-cfg/my-awesome-platform.json #![feature(lang_items, no_core, auto_traits)] #![no_core] diff --git a/tests/ui/check-cfg/well-known-names.rs b/tests/ui/check-cfg/well-known-names.rs index a0feee4225a..c277b84d9bd 100644 --- a/tests/ui/check-cfg/well-known-names.rs +++ b/tests/ui/check-cfg/well-known-names.rs @@ -1,7 +1,7 @@ // This test checks that we lint on non well known names and that we don't lint on well known names // //@ check-pass -//@ compile-flags: --check-cfg=cfg() -Z unstable-options +//@ compile-flags: --check-cfg=cfg() #[cfg(target_oz = "linux")] //~^ WARNING unexpected `cfg` condition name diff --git a/tests/ui/check-cfg/well-known-values.rs b/tests/ui/check-cfg/well-known-values.rs index 2758a793538..4c010a62d21 100644 --- a/tests/ui/check-cfg/well-known-values.rs +++ b/tests/ui/check-cfg/well-known-values.rs @@ -5,7 +5,7 @@ // values since the suggestion shows them. // //@ check-pass -//@ compile-flags: --check-cfg=cfg() -Z unstable-options +//@ compile-flags: --check-cfg=cfg() //@ compile-flags: -Zcheck-cfg-all-expected #![feature(cfg_overflow_checks)] diff --git a/tests/ui/feature-gates/feature-gate-check-cfg.rs b/tests/ui/feature-gates/feature-gate-check-cfg.rs deleted file mode 100644 index 1e0106aa748..00000000000 --- a/tests/ui/feature-gates/feature-gate-check-cfg.rs +++ /dev/null @@ -1,3 +0,0 @@ -//@ compile-flags: --check-cfg "cfg()" - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-check-cfg.stderr b/tests/ui/feature-gates/feature-gate-check-cfg.stderr deleted file mode 100644 index 9b27c2bc058..00000000000 --- a/tests/ui/feature-gates/feature-gate-check-cfg.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: the `-Z unstable-options` flag must also be passed to enable the flag `check-cfg` - From a20de73ccfdf24a59f43da9cf9e0d95ca40d6aab Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 25 Feb 2024 15:45:43 +0100 Subject: [PATCH 15/27] Move --check-cfg documentation to stable books --- .../src/context/diagnostics/check_cfg.rs | 4 +- compiler/rustc_session/src/config/cfg.rs | 2 +- src/doc/rustc/src/SUMMARY.md | 1 + .../compiler-flags => rustc/src}/check-cfg.md | 8 +-- src/doc/rustc/src/command-line-arguments.md | 10 ++++ src/doc/rustdoc/src/command-line-arguments.md | 14 +++++ src/doc/rustdoc/src/unstable-features.md | 16 ------ tests/rustdoc-ui/check-cfg.stderr | 2 +- .../rustdoc-ui/doctest/check-cfg-test.stderr | 2 +- tests/ui/check-cfg/allow-same-level.stderr | 2 +- .../cfg-value-for-cfg-name-duplicate.stderr | 2 +- .../cfg-value-for-cfg-name-multiple.stderr | 2 +- .../check-cfg/cfg-value-for-cfg-name.stderr | 4 +- tests/ui/check-cfg/compact-names.stderr | 2 +- tests/ui/check-cfg/compact-values.stderr | 2 +- tests/ui/check-cfg/concat-values.stderr | 4 +- tests/ui/check-cfg/diagnotics.rustc.stderr | 12 ++-- tests/ui/check-cfg/empty-values.stderr | 4 +- .../exhaustive-names-values.empty_cfg.stderr | 8 +-- .../exhaustive-names-values.feature.stderr | 6 +- .../exhaustive-names-values.full.stderr | 6 +- tests/ui/check-cfg/exhaustive-names.stderr | 2 +- .../exhaustive-values.empty_cfg.stderr | 2 +- .../exhaustive-values.without_names.stderr | 2 +- tests/ui/check-cfg/mix.stderr | 54 +++++++++--------- .../check-cfg/no-expected-values.empty.stderr | 4 +- .../check-cfg/no-expected-values.mixed.stderr | 4 +- .../no-expected-values.simple.stderr | 4 +- .../order-independant.values_after.stderr | 2 +- .../order-independant.values_before.stderr | 2 +- tests/ui/check-cfg/stmt-no-ice.stderr | 2 +- tests/ui/check-cfg/unexpected-cfg-name.stderr | 2 +- .../ui/check-cfg/unexpected-cfg-value.stderr | 4 +- .../ui/check-cfg/values-none.explicit.stderr | 4 +- .../ui/check-cfg/values-none.implicit.stderr | 4 +- tests/ui/check-cfg/well-known-names.stderr | 8 +-- tests/ui/check-cfg/well-known-values.stderr | 56 +++++++++---------- triagebot.toml | 2 +- 38 files changed, 137 insertions(+), 134 deletions(-) rename src/doc/{unstable-book/src/compiler-flags => rustc/src}/check-cfg.md (97%) diff --git a/compiler/rustc_lint/src/context/diagnostics/check_cfg.rs b/compiler/rustc_lint/src/context/diagnostics/check_cfg.rs index 2c9a3a6d1b2..0472525d49a 100644 --- a/compiler/rustc_lint/src/context/diagnostics/check_cfg.rs +++ b/compiler/rustc_lint/src/context/diagnostics/check_cfg.rs @@ -168,7 +168,7 @@ pub(super) fn unexpected_cfg_name( diag.note("see for more information about checking conditional configuration"); } else { diag.help(format!("to expect this configuration use `--check-cfg={inst}`")); - diag.note("see for more information about checking conditional configuration"); + diag.note("see for more information about checking conditional configuration"); } } @@ -272,6 +272,6 @@ pub(super) fn unexpected_cfg_value( if !is_cfg_a_well_know_name { diag.help(format!("to expect this configuration use `--check-cfg={inst}`")); } - diag.note("see for more information about checking conditional configuration"); + diag.note("see for more information about checking conditional configuration"); } } diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index 34dcd0cf598..31badbd8692 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -257,7 +257,7 @@ macro_rules! ins { // `tests/ui/check-cfg/well-known-values.rs` (in order to test the // expected values of the new config) and bless the all directory. // - // Don't forget to update `src/doc/unstable-book/src/compiler-flags/check-cfg.md` + // Don't forget to update `src/doc/rustc/src/check-cfg.md` // in the unstable book as well! ins!(sym::debug_assertions, no_values); diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index db85753145d..31096b6df92 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -77,6 +77,7 @@ - [Profile-guided Optimization](profile-guided-optimization.md) - [Instrumentation-based Code Coverage](instrument-coverage.md) - [Linker-plugin-based LTO](linker-plugin-lto.md) +- [Checking conditional configurations](check-cfg.md) - [Exploit Mitigations](exploit-mitigations.md) - [Symbol Mangling](symbol-mangling/index.md) - [v0 Symbol Format](symbol-mangling/v0.md) diff --git a/src/doc/unstable-book/src/compiler-flags/check-cfg.md b/src/doc/rustc/src/check-cfg.md similarity index 97% rename from src/doc/unstable-book/src/compiler-flags/check-cfg.md rename to src/doc/rustc/src/check-cfg.md index 836929aba0b..37708bda1f3 100644 --- a/src/doc/unstable-book/src/compiler-flags/check-cfg.md +++ b/src/doc/rustc/src/check-cfg.md @@ -1,10 +1,4 @@ -# `check-cfg` - -The tracking issue for this feature is: [#82450](https://github.com/rust-lang/rust/issues/82450). - ------------------------- - -This feature enables checking of conditional configuration. +# Checking conditional configurations `rustc` accepts the `--check-cfg` option, which specifies whether to check conditions and how to check them. The `--check-cfg` option takes a value, called the _check cfg specification_. diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md index 5e02453e236..7c605333c25 100644 --- a/src/doc/rustc/src/command-line-arguments.md +++ b/src/doc/rustc/src/command-line-arguments.md @@ -18,6 +18,16 @@ The value can either be a single identifier or two identifiers separated by `=`. For examples, `--cfg 'verbose'` or `--cfg 'feature="serde"'`. These correspond to `#[cfg(verbose)]` and `#[cfg(feature = "serde")]` respectively. + +## `--check-cfg`: enables checking conditional configurations + +This flag will enable checking conditional configurations. +Refer to the [Checking conditional configurations](check-cfg.md) of this book +for further details and explanation. + +For examples, `--check-cfg 'cfg(verbose)'` or `--check-cfg 'cfg(feature, values("serde"))'`. +These correspond to `#[cfg(verbose)]` and `#[cfg(feature = "serde")]` respectively. + ## `-L`: add a directory to the library search path diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md index fe5cb529c26..822f341b370 100644 --- a/src/doc/rustdoc/src/command-line-arguments.md +++ b/src/doc/rustdoc/src/command-line-arguments.md @@ -131,6 +131,20 @@ This flag accepts the same values as `rustc --cfg`, and uses it to configure compilation. The example above uses `feature`, but any of the `cfg` values are acceptable. +## `--check-cfg`: check configuration flags + +This flag accepts the same values as `rustc --check-cfg`, and uses it to +check configuration flags. + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs --check-cfg='cfg(my_cfg, values("foo", "bar"))' +``` + +The example above check every well known names and values (`target_os`, `doc`, `test`, ...) +and check the values of `my_cfg`: `foo` and `bar`. + ## `--extern`: specify a dependency's location Using this flag looks like this: diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 41602dec44c..bdb55de8d63 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -618,22 +618,6 @@ crate being documented (`foobar`) and a path to output the calls To scrape examples from test code, e.g. functions marked `#[test]`, then add the `--scrape-tests` flag. -### `--check-cfg`: check configuration flags - - * Tracking issue: [#82450](https://github.com/rust-lang/rust/issues/82450) - -This flag accepts the same values as `rustc --check-cfg`, and uses it to check configuration flags. - -Using this flag looks like this: - -```bash -$ rustdoc src/lib.rs -Z unstable-options \ - --check-cfg='cfg(feature, values("foo", "bar"))' -``` - -The example above check every well known names and values (`target_os`, `doc`, `test`, ...) -and check the values of `feature`: `foo` and `bar`. - ### `--generate-link-to-definition`: Generate links on types in source code * Tracking issue: [#89095](https://github.com/rust-lang/rust/issues/89095) diff --git a/tests/rustdoc-ui/check-cfg.stderr b/tests/rustdoc-ui/check-cfg.stderr index 3bca5dd0834..6f026cee41e 100644 --- a/tests/rustdoc-ui/check-cfg.stderr +++ b/tests/rustdoc-ui/check-cfg.stderr @@ -5,7 +5,7 @@ LL | #[cfg(uniz)] | ^^^^ help: there is a config with a similar name: `unix` | = help: to expect this configuration use `--check-cfg=cfg(uniz)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/rustdoc-ui/doctest/check-cfg-test.stderr b/tests/rustdoc-ui/doctest/check-cfg-test.stderr index 5524f582d56..a2f173a2cb9 100644 --- a/tests/rustdoc-ui/doctest/check-cfg-test.stderr +++ b/tests/rustdoc-ui/doctest/check-cfg-test.stderr @@ -6,7 +6,7 @@ LL | #[cfg(feature = "invalid")] | = note: expected values for `feature` are: `test` = help: to expect this configuration use `--check-cfg=cfg(feature, values("invalid"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/allow-same-level.stderr b/tests/ui/check-cfg/allow-same-level.stderr index 493132d462a..349f41cb142 100644 --- a/tests/ui/check-cfg/allow-same-level.stderr +++ b/tests/ui/check-cfg/allow-same-level.stderr @@ -6,7 +6,7 @@ LL | #[cfg(FALSE)] | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows` = help: to expect this configuration use `--check-cfg=cfg(FALSE)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr index 46d6d29b15e..23ae4c55e42 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr @@ -6,7 +6,7 @@ LL | #[cfg(value)] | = help: expected names are: `bar`, `bee`, `clippy`, `cow`, `debug_assertions`, `doc`, `doctest`, `foo`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows` = help: to expect this configuration use `--check-cfg=cfg(value)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr index a70a8b2d3e4..b5faaf6029c 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr @@ -6,7 +6,7 @@ LL | #[cfg(my_value)] | = help: expected names are: `bar`, `clippy`, `debug_assertions`, `doc`, `doctest`, `foo`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows` = help: to expect this configuration use `--check-cfg=cfg(my_value)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default help: found config with similar value | diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr index fab7f595c25..01586a6c71d 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr @@ -6,7 +6,7 @@ LL | #[cfg(linux)] | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows` = help: to expect this configuration use `--check-cfg=cfg(linux)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `linux` @@ -16,7 +16,7 @@ LL | #[cfg(linux = "os-name")] | ^^^^^^^^^^^^^^^^^ | = help: to expect this configuration use `--check-cfg=cfg(linux, values("os-name"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/compact-names.stderr b/tests/ui/check-cfg/compact-names.stderr index 446b8f408e3..929501b420a 100644 --- a/tests/ui/check-cfg/compact-names.stderr +++ b/tests/ui/check-cfg/compact-names.stderr @@ -6,7 +6,7 @@ LL | #[cfg(target(os = "linux", architecture = "arm"))] | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows` = help: to expect this configuration use `--check-cfg=cfg(target_architecture, values("arm"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/compact-values.stderr b/tests/ui/check-cfg/compact-values.stderr index 661ee7bff52..45d084c46bf 100644 --- a/tests/ui/check-cfg/compact-values.stderr +++ b/tests/ui/check-cfg/compact-values.stderr @@ -5,7 +5,7 @@ LL | #[cfg(target(os = "linux", pointer_width = "X"))] | ^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_pointer_width` are: `16`, `32`, `64` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/concat-values.stderr b/tests/ui/check-cfg/concat-values.stderr index dec43f5bda3..ca8b58f73e5 100644 --- a/tests/ui/check-cfg/concat-values.stderr +++ b/tests/ui/check-cfg/concat-values.stderr @@ -6,7 +6,7 @@ LL | #[cfg(my_cfg)] | = note: expected values for `my_cfg` are: `bar`, `foo` = help: to expect this configuration use `--check-cfg=cfg(my_cfg)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `unk` @@ -17,7 +17,7 @@ LL | #[cfg(my_cfg = "unk")] | = note: expected values for `my_cfg` are: `bar`, `foo` = help: to expect this configuration use `--check-cfg=cfg(my_cfg, values("unk"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/diagnotics.rustc.stderr b/tests/ui/check-cfg/diagnotics.rustc.stderr index 2b1129a3920..0a938d2143e 100644 --- a/tests/ui/check-cfg/diagnotics.rustc.stderr +++ b/tests/ui/check-cfg/diagnotics.rustc.stderr @@ -6,7 +6,7 @@ LL | #[cfg(featur)] | = help: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(featur)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `featur` @@ -16,7 +16,7 @@ LL | #[cfg(featur = "foo")] | ^^^^^^^^^^^^^^ | = help: to expect this configuration use `--check-cfg=cfg(featur, values("foo"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration help: there is a config with a similar name and value | LL | #[cfg(feature = "foo")] @@ -30,7 +30,7 @@ LL | #[cfg(featur = "fo")] | = help: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(featur, values("fo"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration help: there is a config with a similar name and different values | LL | #[cfg(feature = "foo")] @@ -43,7 +43,7 @@ LL | #[cfg(no_value)] | ^^^^^^^^ help: there is a config with a similar name: `no_values` | = help: to expect this configuration use `--check-cfg=cfg(no_value)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `no_value` --> $DIR/diagnotics.rs:26:7 @@ -52,7 +52,7 @@ LL | #[cfg(no_value = "foo")] | ^^^^^^^^^^^^^^^^ | = help: to expect this configuration use `--check-cfg=cfg(no_value, values("foo"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration help: there is a config with a similar name and no value | LL | #[cfg(no_values)] @@ -68,7 +68,7 @@ LL | #[cfg(no_values = "bar")] | = note: no expected value for `no_values` = help: to expect this configuration use `--check-cfg=cfg(no_values, values("bar"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 6 warnings emitted diff --git a/tests/ui/check-cfg/empty-values.stderr b/tests/ui/check-cfg/empty-values.stderr index e7b0b05d561..1f773b10316 100644 --- a/tests/ui/check-cfg/empty-values.stderr +++ b/tests/ui/check-cfg/empty-values.stderr @@ -6,7 +6,7 @@ LL | #[cfg(foo = "foo")] | = note: no expected values for `foo` = help: to expect this configuration use `--check-cfg=cfg(foo, values("foo"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: (none) @@ -17,7 +17,7 @@ LL | #[cfg(foo)] | = note: no expected values for `foo` = help: to expect this configuration use `--check-cfg=cfg(foo)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr index 5d1fc74137b..9537d4f5172 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr @@ -6,7 +6,7 @@ LL | #[cfg(unknown_key = "value")] | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows` = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` @@ -18,7 +18,7 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` --> $DIR/exhaustive-names-values.rs:17:7 @@ -27,7 +27,7 @@ LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ | = help: to expect this configuration use `--check-cfg=cfg(feature, values("unk"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` --> $DIR/exhaustive-names-values.rs:24:7 @@ -36,7 +36,7 @@ LL | #[cfg(feature = "std")] | ^^^^^^^^^^^^^^^ | = help: to expect this configuration use `--check-cfg=cfg(feature, values("std"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 4 warnings emitted diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr index 9be2ec71b44..d63d8627953 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -6,7 +6,7 @@ LL | #[cfg(unknown_key = "value")] | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows` = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` @@ -18,7 +18,7 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` --> $DIR/exhaustive-names-values.rs:17:7 @@ -28,7 +28,7 @@ LL | #[cfg(feature = "unk")] | = note: expected values for `feature` are: `std` = help: to expect this configuration use `--check-cfg=cfg(feature, values("unk"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 3 warnings emitted diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr index 9be2ec71b44..d63d8627953 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.full.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -6,7 +6,7 @@ LL | #[cfg(unknown_key = "value")] | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows` = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` @@ -18,7 +18,7 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` --> $DIR/exhaustive-names-values.rs:17:7 @@ -28,7 +28,7 @@ LL | #[cfg(feature = "unk")] | = note: expected values for `feature` are: `std` = help: to expect this configuration use `--check-cfg=cfg(feature, values("unk"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 3 warnings emitted diff --git a/tests/ui/check-cfg/exhaustive-names.stderr b/tests/ui/check-cfg/exhaustive-names.stderr index 6ca7ed93625..c42adec94b2 100644 --- a/tests/ui/check-cfg/exhaustive-names.stderr +++ b/tests/ui/check-cfg/exhaustive-names.stderr @@ -6,7 +6,7 @@ LL | #[cfg(unknown_key = "value")] | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows` = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr index e8cf29ae982..63ba2c68625 100644 --- a/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr @@ -7,7 +7,7 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/exhaustive-values.without_names.stderr b/tests/ui/check-cfg/exhaustive-values.without_names.stderr index e8cf29ae982..63ba2c68625 100644 --- a/tests/ui/check-cfg/exhaustive-values.without_names.stderr +++ b/tests/ui/check-cfg/exhaustive-values.without_names.stderr @@ -7,7 +7,7 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.stderr index 87fabf8245f..feb4f21b0ca 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.stderr @@ -5,7 +5,7 @@ LL | #[cfg(widnows)] | ^^^^^^^ help: there is a config with a similar name: `windows` | = help: to expect this configuration use `--check-cfg=cfg(widnows)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: (none) @@ -16,7 +16,7 @@ LL | #[cfg(feature)] | = note: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(feature)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `bar` --> $DIR/mix.rs:23:7 @@ -26,7 +26,7 @@ LL | #[cfg(feature = "bar")] | = note: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(feature, values("bar"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:27:7 @@ -36,7 +36,7 @@ LL | #[cfg(feature = "zebra")] | = note: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `uu` --> $DIR/mix.rs:31:12 @@ -46,7 +46,7 @@ LL | #[cfg_attr(uu, test)] | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows` = help: to expect this configuration use `--check-cfg=cfg(uu)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `widnows` --> $DIR/mix.rs:40:10 @@ -55,7 +55,7 @@ LL | cfg!(widnows); | ^^^^^^^ help: there is a config with a similar name: `windows` | = help: to expect this configuration use `--check-cfg=cfg(widnows)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `bar` --> $DIR/mix.rs:43:10 @@ -65,7 +65,7 @@ LL | cfg!(feature = "bar"); | = note: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(feature, values("bar"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:45:10 @@ -75,7 +75,7 @@ LL | cfg!(feature = "zebra"); | = note: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:47:10 @@ -84,7 +84,7 @@ LL | cfg!(xxx = "foo"); | ^^^^^^^^^^^ | = help: to expect this configuration use `--check-cfg=cfg(xxx, values("foo"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:49:10 @@ -93,7 +93,7 @@ LL | cfg!(xxx); | ^^^ | = help: to expect this configuration use `--check-cfg=cfg(xxx)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:51:14 @@ -102,7 +102,7 @@ LL | cfg!(any(xxx, windows)); | ^^^ | = help: to expect this configuration use `--check-cfg=cfg(xxx)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `bad` --> $DIR/mix.rs:53:14 @@ -112,7 +112,7 @@ LL | cfg!(any(feature = "bad", windows)); | = note: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(feature, values("bad"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:55:23 @@ -121,7 +121,7 @@ LL | cfg!(any(windows, xxx)); | ^^^ | = help: to expect this configuration use `--check-cfg=cfg(xxx)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:57:20 @@ -130,7 +130,7 @@ LL | cfg!(all(unix, xxx)); | ^^^ | = help: to expect this configuration use `--check-cfg=cfg(xxx)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `aa` --> $DIR/mix.rs:59:14 @@ -139,7 +139,7 @@ LL | cfg!(all(aa, bb)); | ^^ | = help: to expect this configuration use `--check-cfg=cfg(aa)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `bb` --> $DIR/mix.rs:59:18 @@ -148,7 +148,7 @@ LL | cfg!(all(aa, bb)); | ^^ | = help: to expect this configuration use `--check-cfg=cfg(bb)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `aa` --> $DIR/mix.rs:62:14 @@ -157,7 +157,7 @@ LL | cfg!(any(aa, bb)); | ^^ | = help: to expect this configuration use `--check-cfg=cfg(aa)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `bb` --> $DIR/mix.rs:62:18 @@ -166,7 +166,7 @@ LL | cfg!(any(aa, bb)); | ^^ | = help: to expect this configuration use `--check-cfg=cfg(bb)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:65:20 @@ -176,7 +176,7 @@ LL | cfg!(any(unix, feature = "zebra")); | = note: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:67:14 @@ -185,7 +185,7 @@ LL | cfg!(any(xxx, feature = "zebra")); | ^^^ | = help: to expect this configuration use `--check-cfg=cfg(xxx)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:67:19 @@ -195,7 +195,7 @@ LL | cfg!(any(xxx, feature = "zebra")); | = note: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:70:14 @@ -204,7 +204,7 @@ LL | cfg!(any(xxx, unix, xxx)); | ^^^ | = help: to expect this configuration use `--check-cfg=cfg(xxx)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:70:25 @@ -213,7 +213,7 @@ LL | cfg!(any(xxx, unix, xxx)); | ^^^ | = help: to expect this configuration use `--check-cfg=cfg(xxx)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:73:14 @@ -223,7 +223,7 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | = note: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:73:33 @@ -233,7 +233,7 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | = note: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:73:52 @@ -243,7 +243,7 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | = note: expected values for `feature` are: `foo` = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:77:10 @@ -252,7 +252,7 @@ LL | cfg!(target_feature = "zebra"); | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512er`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512pf`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `bf16`, `bmi1`, `bmi2` and 187 more - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 27 warnings emitted diff --git a/tests/ui/check-cfg/no-expected-values.empty.stderr b/tests/ui/check-cfg/no-expected-values.empty.stderr index 65827efdd39..0f181cc2ab1 100644 --- a/tests/ui/check-cfg/no-expected-values.empty.stderr +++ b/tests/ui/check-cfg/no-expected-values.empty.stderr @@ -8,7 +8,7 @@ LL | #[cfg(feature = "foo")] | = note: no expected value for `feature` = help: to expect this configuration use `--check-cfg=cfg(feature, values("foo"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` @@ -20,7 +20,7 @@ LL | #[cfg(test = "foo")] | help: remove the value | = note: no expected value for `test` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/no-expected-values.mixed.stderr b/tests/ui/check-cfg/no-expected-values.mixed.stderr index 65827efdd39..0f181cc2ab1 100644 --- a/tests/ui/check-cfg/no-expected-values.mixed.stderr +++ b/tests/ui/check-cfg/no-expected-values.mixed.stderr @@ -8,7 +8,7 @@ LL | #[cfg(feature = "foo")] | = note: no expected value for `feature` = help: to expect this configuration use `--check-cfg=cfg(feature, values("foo"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` @@ -20,7 +20,7 @@ LL | #[cfg(test = "foo")] | help: remove the value | = note: no expected value for `test` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/no-expected-values.simple.stderr b/tests/ui/check-cfg/no-expected-values.simple.stderr index 65827efdd39..0f181cc2ab1 100644 --- a/tests/ui/check-cfg/no-expected-values.simple.stderr +++ b/tests/ui/check-cfg/no-expected-values.simple.stderr @@ -8,7 +8,7 @@ LL | #[cfg(feature = "foo")] | = note: no expected value for `feature` = help: to expect this configuration use `--check-cfg=cfg(feature, values("foo"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` @@ -20,7 +20,7 @@ LL | #[cfg(test = "foo")] | help: remove the value | = note: no expected value for `test` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/order-independant.values_after.stderr b/tests/ui/check-cfg/order-independant.values_after.stderr index 2be28be39a7..7e18df8e1c2 100644 --- a/tests/ui/check-cfg/order-independant.values_after.stderr +++ b/tests/ui/check-cfg/order-independant.values_after.stderr @@ -6,7 +6,7 @@ LL | #[cfg(a = "unk")] | = note: expected values for `a` are: (none), `b` = help: to expect this configuration use `--check-cfg=cfg(a, values("unk"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/order-independant.values_before.stderr b/tests/ui/check-cfg/order-independant.values_before.stderr index 2be28be39a7..7e18df8e1c2 100644 --- a/tests/ui/check-cfg/order-independant.values_before.stderr +++ b/tests/ui/check-cfg/order-independant.values_before.stderr @@ -6,7 +6,7 @@ LL | #[cfg(a = "unk")] | = note: expected values for `a` are: (none), `b` = help: to expect this configuration use `--check-cfg=cfg(a, values("unk"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/stmt-no-ice.stderr b/tests/ui/check-cfg/stmt-no-ice.stderr index 1afdbe84d34..e686cdddc1c 100644 --- a/tests/ui/check-cfg/stmt-no-ice.stderr +++ b/tests/ui/check-cfg/stmt-no-ice.stderr @@ -6,7 +6,7 @@ LL | #[cfg(crossbeam_loom)] | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows` = help: to expect this configuration use `--check-cfg=cfg(crossbeam_loom)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/unexpected-cfg-name.stderr b/tests/ui/check-cfg/unexpected-cfg-name.stderr index 8748b324fb6..0b265078aa5 100644 --- a/tests/ui/check-cfg/unexpected-cfg-name.stderr +++ b/tests/ui/check-cfg/unexpected-cfg-name.stderr @@ -5,7 +5,7 @@ LL | #[cfg(widnows)] | ^^^^^^^ help: there is a config with a similar name: `windows` | = help: to expect this configuration use `--check-cfg=cfg(widnows)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/unexpected-cfg-value.stderr b/tests/ui/check-cfg/unexpected-cfg-value.stderr index e5435d37670..c3001208492 100644 --- a/tests/ui/check-cfg/unexpected-cfg-value.stderr +++ b/tests/ui/check-cfg/unexpected-cfg-value.stderr @@ -8,7 +8,7 @@ LL | #[cfg(feature = "sedre")] | = note: expected values for `feature` are: `full`, `serde` = help: to expect this configuration use `--check-cfg=cfg(feature, values("sedre"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `rand` @@ -19,7 +19,7 @@ LL | #[cfg(feature = "rand")] | = note: expected values for `feature` are: `full`, `serde` = help: to expect this configuration use `--check-cfg=cfg(feature, values("rand"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/values-none.explicit.stderr b/tests/ui/check-cfg/values-none.explicit.stderr index c14cde94005..f75cc08f551 100644 --- a/tests/ui/check-cfg/values-none.explicit.stderr +++ b/tests/ui/check-cfg/values-none.explicit.stderr @@ -8,7 +8,7 @@ LL | #[cfg(foo = "too")] | = note: no expected value for `foo` = help: to expect this configuration use `--check-cfg=cfg(foo, values("too"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `bar` @@ -21,7 +21,7 @@ LL | #[cfg(foo = "bar")] | = note: no expected value for `foo` = help: to expect this configuration use `--check-cfg=cfg(foo, values("bar"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/values-none.implicit.stderr b/tests/ui/check-cfg/values-none.implicit.stderr index c14cde94005..f75cc08f551 100644 --- a/tests/ui/check-cfg/values-none.implicit.stderr +++ b/tests/ui/check-cfg/values-none.implicit.stderr @@ -8,7 +8,7 @@ LL | #[cfg(foo = "too")] | = note: no expected value for `foo` = help: to expect this configuration use `--check-cfg=cfg(foo, values("too"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `bar` @@ -21,7 +21,7 @@ LL | #[cfg(foo = "bar")] | = note: no expected value for `foo` = help: to expect this configuration use `--check-cfg=cfg(foo, values("bar"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/well-known-names.stderr b/tests/ui/check-cfg/well-known-names.stderr index 467f9675f7f..b2db777e8a8 100644 --- a/tests/ui/check-cfg/well-known-names.stderr +++ b/tests/ui/check-cfg/well-known-names.stderr @@ -5,7 +5,7 @@ LL | #[cfg(target_oz = "linux")] | ^^^^^^^^^^^^^^^^^^^ | = help: to expect this configuration use `--check-cfg=cfg(target_oz, values("linux"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default help: there is a config with a similar name and value | @@ -20,7 +20,7 @@ LL | #[cfg(features = "foo")] | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows` = help: to expect this configuration use `--check-cfg=cfg(features, values("foo"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` --> $DIR/well-known-names.rs:17:7 @@ -29,7 +29,7 @@ LL | #[cfg(feature = "foo")] | ^^^^^^^^^^^^^^^ | = help: to expect this configuration use `--check-cfg=cfg(feature, values("foo"))` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `uniw` --> $DIR/well-known-names.rs:21:7 @@ -38,7 +38,7 @@ LL | #[cfg(uniw)] | ^^^^ help: there is a config with a similar name: `unix` | = help: to expect this configuration use `--check-cfg=cfg(uniw)` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 4 warnings emitted diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 729794150f6..af3ef92fdd5 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -7,7 +7,7 @@ LL | clippy = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `clippy` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` @@ -19,7 +19,7 @@ LL | debug_assertions = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `debug_assertions` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:31:5 @@ -30,7 +30,7 @@ LL | doc = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `doc` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:33:5 @@ -41,7 +41,7 @@ LL | doctest = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `doctest` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:35:5 @@ -52,7 +52,7 @@ LL | miri = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `miri` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:37:5 @@ -63,7 +63,7 @@ LL | overflow_checks = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `overflow_checks` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:39:5 @@ -72,7 +72,7 @@ LL | panic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `panic` are: `abort`, `unwind` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:41:5 @@ -83,7 +83,7 @@ LL | proc_macro = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `proc_macro` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:43:5 @@ -92,7 +92,7 @@ LL | relocation_model = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `relocation_model` are: `dynamic-no-pic`, `pic`, `pie`, `ropi`, `ropi-rwpi`, `rwpi`, `static` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:45:5 @@ -101,7 +101,7 @@ LL | sanitize = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `sanitize` are: `address`, `cfi`, `dataflow`, `hwaddress`, `kcfi`, `kernel-address`, `leak`, `memory`, `memtag`, `safestack`, `shadow-call-stack`, `thread` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:47:5 @@ -110,7 +110,7 @@ LL | target_abi = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_abi` are: ``, `abi64`, `abiv2`, `abiv2hf`, `eabi`, `eabihf`, `elf`, `fortanix`, `ilp32`, `llvm`, `macabi`, `sim`, `softfloat`, `spe`, `uwp`, `vec-extabi`, `x32` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:49:5 @@ -119,7 +119,7 @@ LL | target_arch = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_arch` are: `aarch64`, `arm`, `arm64ec`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:51:5 @@ -128,7 +128,7 @@ LL | target_endian = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_endian` are: `big`, `little` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:53:5 @@ -137,7 +137,7 @@ LL | target_env = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_env` are: ``, `gnu`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p2`, `psx`, `relibc`, `sgx`, `uclibc` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:55:5 @@ -146,7 +146,7 @@ LL | target_family = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_family` are: `unix`, `wasm`, `windows` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:57:5 @@ -155,7 +155,7 @@ LL | target_feature = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512er`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512pf`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `f`, `f16c`, `f32mm`, `f64mm`, `fast-unaligned-access`, `fcma`, `fdivdu`, `fhm`, `flagm`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lsx`, `lvz`, `lzcnt`, `m`, `mclass`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sign-ext`, `simd128`, `sm4`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `sve`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, `zkt` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:59:5 @@ -164,7 +164,7 @@ LL | target_has_atomic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_has_atomic` are: (none), `128`, `16`, `32`, `64`, `8`, `ptr` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:61:5 @@ -173,7 +173,7 @@ LL | target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_has_atomic_equal_alignment` are: (none), `128`, `16`, `32`, `64`, `8`, `ptr` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:63:5 @@ -182,7 +182,7 @@ LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_has_atomic_load_store` are: (none), `128`, `16`, `32`, `64`, `8`, `ptr` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:65:5 @@ -191,7 +191,7 @@ LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, `zkvm` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:67:5 @@ -200,7 +200,7 @@ LL | target_pointer_width = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_pointer_width` are: `16`, `32`, `64` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:69:5 @@ -211,7 +211,7 @@ LL | target_thread_local = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `target_thread_local` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:71:5 @@ -220,7 +220,7 @@ LL | target_vendor = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, `wrs` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:73:5 @@ -231,7 +231,7 @@ LL | test = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `test` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:75:5 @@ -242,7 +242,7 @@ LL | ub_checks = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `ub_checks` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:77:5 @@ -253,7 +253,7 @@ LL | unix = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `unix` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:79:5 @@ -264,7 +264,7 @@ LL | windows = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `windows` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `linuz` --> $DIR/well-known-values.rs:85:7 @@ -275,7 +275,7 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | help: there is a expected value with a similar name: `"linux"` | = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, `zkvm` - = note: see for more information about checking conditional configuration + = note: see for more information about checking conditional configuration warning: 28 warnings emitted diff --git a/triagebot.toml b/triagebot.toml index b96225c4520..1fdcffebf83 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -728,7 +728,7 @@ cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"] [mentions."src/doc/unstable-book/src/language-features/no-sanitize.md"] cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"] -[mentions."src/doc/unstable-book/src/compiler-flags/check-cfg.md"] +[mentions."src/doc/rustc/src/check-cfg.md"] cc = ["@Urgau"] [mentions."src/doc/rustc/src/platform-support"] From ef1d084c0b5b0ff7143bbca966442cd24151313b Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Fri, 5 Apr 2024 23:27:29 -0400 Subject: [PATCH 16/27] Match ergonomics 2024: `mut` doesn't reset binding mode --- compiler/rustc_feature/src/unstable.rs | 2 ++ compiler/rustc_hir_typeck/src/pat.rs | 16 +++++++--- compiler/rustc_span/src/symbol.rs | 1 + ...e-gate-mut_dont_reset_binding_mode_2024.rs | 14 +++++++++ ...te-mut_dont_reset_binding_mode_2024.stderr | 31 +++++++++++++++++++ .../mut_dont_reset_binding_mode_2021.rs | 15 +++++++++ .../mut_dont_reset_binding_mode_2021.stderr | 31 +++++++++++++++++++ .../mut_dont_reset_binding_mode_2024.rs | 15 +++++++++ 8 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.rs create mode 100644 tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.stderr create mode 100644 tests/ui/pattern/mut_dont_reset_binding_mode_2021.rs create mode 100644 tests/ui/pattern/mut_dont_reset_binding_mode_2021.stderr create mode 100644 tests/ui/pattern/mut_dont_reset_binding_mode_2024.rs diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index e6b19817de3..2a753af9387 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -533,6 +533,8 @@ pub fn internal(&self, feature: Symbol) -> bool { (unstable, more_qualified_paths, "1.54.0", Some(86935)), /// Allows the `#[must_not_suspend]` attribute. (unstable, must_not_suspend, "1.57.0", Some(83310)), + /// Make `mut` not reset the binding mode on edition >= 2024. + (unstable, mut_dont_reset_binding_mode_2024, "CURRENT_RUSTC_VERSION", Some(123076)), /// Allows `mut ref` and `mut ref mut` identifier patterns. (incomplete, mut_ref, "CURRENT_RUSTC_VERSION", Some(123076)), /// Allows using `#[naked]` on functions. diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index db4bd132b7e..06f6a7f6bf2 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -629,12 +629,20 @@ fn check_pat_ident( expected: Ty<'tcx>, pat_info: PatInfo<'tcx, '_>, ) -> Ty<'tcx> { - let PatInfo { binding_mode: def_bm, top_info: ti, .. } = pat_info; + let PatInfo { binding_mode: BindingAnnotation(def_br, _), top_info: ti, .. } = pat_info; // Determine the binding mode... let bm = match ba { - BindingAnnotation(ByRef::No, Mutability::Not) => def_bm, - _ => ba, + BindingAnnotation(ByRef::No, Mutability::Mut) + if !(pat.span.at_least_rust_2024() + && self.tcx.features().mut_dont_reset_binding_mode_2024) + && matches!(def_br, ByRef::Yes(_)) => + { + // `mut x` resets the binding mode in edition <= 2021. + BindingAnnotation(ByRef::No, Mutability::Mut) + } + BindingAnnotation(ByRef::No, mutbl) => BindingAnnotation(def_br, mutbl), + BindingAnnotation(ByRef::Yes(_), _) => ba, }; // ...and store it in a side table: self.typeck_results.borrow_mut().pat_binding_modes_mut().insert(pat.hir_id, bm); @@ -743,7 +751,7 @@ fn suggest_adding_missing_ref_or_removing_ref( } } - // Precondition: pat is a Ref(_) pattern + /// Precondition: pat is a `Ref(_)` pattern fn borrow_pat_suggestion(&self, err: &mut Diag<'_>, pat: &Pat<'_>) { let tcx = self.tcx; if let PatKind::Ref(inner, mutbl) = pat.kind diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index bfd0f77c237..02550fd655c 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1194,6 +1194,7 @@ multiple_supertrait_upcastable, must_not_suspend, must_use, + mut_dont_reset_binding_mode_2024, mut_ref, naked, naked_functions, diff --git a/tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.rs b/tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.rs new file mode 100644 index 00000000000..15c542e6bf1 --- /dev/null +++ b/tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.rs @@ -0,0 +1,14 @@ +//@ edition: 2024 +//@ compile-flags: -Zunstable-options + +struct Foo(u8); + +fn main() { + let Foo(mut a) = &Foo(0); + a = &42; + //~^ ERROR: mismatched types + + let Foo(mut a) = &mut Foo(0); + a = &mut 42; + //~^ ERROR: mismatched types +} diff --git a/tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.stderr b/tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.stderr new file mode 100644 index 00000000000..1624883de60 --- /dev/null +++ b/tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.stderr @@ -0,0 +1,31 @@ +error[E0308]: mismatched types + --> $DIR/feature-gate-mut_dont_reset_binding_mode_2024.rs:8:9 + | +LL | let Foo(mut a) = &Foo(0); + | ----- expected due to the type of this binding +LL | a = &42; + | ^^^ expected `u8`, found `&{integer}` + | +help: consider removing the borrow + | +LL - a = &42; +LL + a = 42; + | + +error[E0308]: mismatched types + --> $DIR/feature-gate-mut_dont_reset_binding_mode_2024.rs:12:9 + | +LL | let Foo(mut a) = &mut Foo(0); + | ----- expected due to the type of this binding +LL | a = &mut 42; + | ^^^^^^^ expected `u8`, found `&mut {integer}` + | +help: consider removing the borrow + | +LL - a = &mut 42; +LL + a = 42; + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2021.rs b/tests/ui/pattern/mut_dont_reset_binding_mode_2021.rs new file mode 100644 index 00000000000..a9e12472734 --- /dev/null +++ b/tests/ui/pattern/mut_dont_reset_binding_mode_2021.rs @@ -0,0 +1,15 @@ +//@ edition: 2021 +//@ compile-flags: -Zunstable-options +#![feature(mut_dont_reset_binding_mode_2024)] + +struct Foo(u8); + +fn main() { + let Foo(mut a) = &Foo(0); + a = &42; + //~^ ERROR: mismatched types + + let Foo(mut a) = &mut Foo(0); + a = &mut 42; + //~^ ERROR: mismatched types +} diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2021.stderr b/tests/ui/pattern/mut_dont_reset_binding_mode_2021.stderr new file mode 100644 index 00000000000..16818c900b3 --- /dev/null +++ b/tests/ui/pattern/mut_dont_reset_binding_mode_2021.stderr @@ -0,0 +1,31 @@ +error[E0308]: mismatched types + --> $DIR/mut_dont_reset_binding_mode_2021.rs:9:9 + | +LL | let Foo(mut a) = &Foo(0); + | ----- expected due to the type of this binding +LL | a = &42; + | ^^^ expected `u8`, found `&{integer}` + | +help: consider removing the borrow + | +LL - a = &42; +LL + a = 42; + | + +error[E0308]: mismatched types + --> $DIR/mut_dont_reset_binding_mode_2021.rs:13:9 + | +LL | let Foo(mut a) = &mut Foo(0); + | ----- expected due to the type of this binding +LL | a = &mut 42; + | ^^^^^^^ expected `u8`, found `&mut {integer}` + | +help: consider removing the borrow + | +LL - a = &mut 42; +LL + a = 42; + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2024.rs b/tests/ui/pattern/mut_dont_reset_binding_mode_2024.rs new file mode 100644 index 00000000000..9ac5ec50c74 --- /dev/null +++ b/tests/ui/pattern/mut_dont_reset_binding_mode_2024.rs @@ -0,0 +1,15 @@ +//@ run-pass +//@ edition: 2024 +//@ compile-flags: -Zunstable-options +#![feature(mut_dont_reset_binding_mode_2024)] +#![allow(unused)] + +struct Foo(u8); + +fn main() { + let Foo(mut a) = &Foo(0); + a = &42; + + let Foo(mut a) = &mut Foo(0); + a = &mut 42; +} From 83f330fbd45be04a693e89e9602f0ab2ffab16e2 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Fri, 5 Apr 2024 23:28:34 -0400 Subject: [PATCH 17/27] Migration lint Rustfix remains TODO --- compiler/rustc_hir_typeck/messages.ftl | 4 +++ compiler/rustc_hir_typeck/src/errors.rs | 8 +++++ compiler/rustc_hir_typeck/src/pat.rs | 7 ++++ compiler/rustc_lint_defs/src/builtin.rs | 36 +++++++++++++++++++ .../mut_dont_reset_binding_mode_2024_lint.rs | 18 ++++++++++ ...t_dont_reset_binding_mode_2024_lint.stderr | 35 ++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs create mode 100644 tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr diff --git a/compiler/rustc_hir_typeck/messages.ftl b/compiler/rustc_hir_typeck/messages.ftl index 18d9d739dd6..07b4948872d 100644 --- a/compiler/rustc_hir_typeck/messages.ftl +++ b/compiler/rustc_hir_typeck/messages.ftl @@ -46,6 +46,10 @@ hir_typeck_ctor_is_private = tuple struct constructor `{$def}` is private hir_typeck_deref_is_empty = this expression `Deref`s to `{$deref_ty}` which implements `is_empty` +hir_typeck_dereferencing_mut_binding = dereferencing `mut` binding + .label = `mut` dereferences the type of this binding + .help = this will change in edition 2024 + hir_typeck_expected_default_return_type = expected `()` because of default return type hir_typeck_expected_return_type = expected `{$expected}` because of return type diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index d399730bf3d..3dc9c7b86f7 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -632,3 +632,11 @@ pub enum SuggestBoxingForReturnImplTrait { ends: Vec, }, } + +#[derive(LintDiagnostic)] +#[diag(hir_typeck_dereferencing_mut_binding)] +pub struct DereferencingMutBinding { + #[label] + #[help] + pub span: Span, +} diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 06f6a7f6bf2..252125aba7c 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -10,6 +10,7 @@ use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Mutability, Pat, PatKind}; use rustc_infer::infer; use rustc_infer::infer::type_variable::TypeVariableOrigin; +use rustc_lint as lint; use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::ty::{self, Adt, Ty, TypeVisitableExt}; use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS; @@ -639,6 +640,12 @@ fn check_pat_ident( && matches!(def_br, ByRef::Yes(_)) => { // `mut x` resets the binding mode in edition <= 2021. + self.tcx.emit_node_span_lint( + lint::builtin::DEREFERENCING_MUT_BINDING, + pat.hir_id, + pat.span, + errors::DereferencingMutBinding { span: pat.span }, + ); BindingAnnotation(ByRef::No, Mutability::Mut) } BindingAnnotation(ByRef::No, mutbl) => BindingAnnotation(def_br, mutbl), diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 2713690f812..bc36a587a9e 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -38,6 +38,7 @@ DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME, DEPRECATED_IN_FUTURE, DEPRECATED_WHERE_CLAUSE_LOCATION, + DEREFERENCING_MUT_BINDING, DUPLICATE_MACRO_ATTRIBUTES, ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT, ELIDED_LIFETIMES_IN_PATHS, @@ -1627,6 +1628,41 @@ "detect mut variables which don't need to be mutable" } +declare_lint! { + /// The `dereferencing_mut_binding` lint detects a `mut x` pattern that resets the binding mode, + /// as this behavior will change in rust 2024. + /// + /// ### Example + /// + /// ```rust + /// # #![warn(dereferencing_mut_binding)] + /// let x = Some(123u32); + /// let _y = match &x { + /// Some(mut x) => { + /// x += 1; + /// x + /// } + /// None => 0, + /// }; + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Without the `mut`, `x` would have type `&u32`. Pre-2024, adding `mut` makes `x` have type + /// `u32`, which was deeped surprising. After edition 2024, adding `mut` will not change the + /// type of `x`. This lint warns users of editions before 2024 to update their code. + pub DEREFERENCING_MUT_BINDING, + Allow, + "detects `mut x` bindings that change the type of `x`", + @feature_gate = sym::mut_dont_reset_binding_mode_2024; + @future_incompatible = FutureIncompatibleInfo { + reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024), + reference: "123076", + }; +} + declare_lint! { /// The `unconditional_recursion` lint detects functions that cannot /// return without calling themselves. diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs b/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs new file mode 100644 index 00000000000..2992e61fbbc --- /dev/null +++ b/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs @@ -0,0 +1,18 @@ +//@ edition: 2021 +#![feature(mut_dont_reset_binding_mode_2024)] +#![allow(unused)] +#![forbid(dereferencing_mut_binding)] + +struct Foo(u8); + +fn main() { + let Foo(mut a) = &Foo(0); + //~^ ERROR: dereferencing `mut` binding + //~| WARN: this changes meaning in Rust 2024 + a = 42; + + let Foo(mut a) = &mut Foo(0); + //~^ ERROR: dereferencing `mut` binding + //~| WARN: this changes meaning in Rust 2024 + a = 42; +} diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr b/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr new file mode 100644 index 00000000000..72b72f0df5d --- /dev/null +++ b/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr @@ -0,0 +1,35 @@ +error: dereferencing `mut` binding + --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:9:13 + | +LL | let Foo(mut a) = &Foo(0); + | ^^^^^ `mut` dereferences the type of this binding + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see 123076 +help: this will change in edition 2024 + --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:9:13 + | +LL | let Foo(mut a) = &Foo(0); + | ^^^^^ +note: the lint level is defined here + --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:4:11 + | +LL | #![forbid(dereferencing_mut_binding)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: dereferencing `mut` binding + --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:14:13 + | +LL | let Foo(mut a) = &mut Foo(0); + | ^^^^^ `mut` dereferences the type of this binding + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see 123076 +help: this will change in edition 2024 + --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:14:13 + | +LL | let Foo(mut a) = &mut Foo(0); + | ^^^^^ + +error: aborting due to 2 previous errors + From d5d700d5c65df24dfeec32f6fbd9d1d7b81c70b2 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Sat, 6 Apr 2024 00:29:35 -0400 Subject: [PATCH 18/27] Temporarily remove future compatibility label from migration lint The lint is unstable, and the lint group `rust_2024_compatibility` must keep working on stable --- compiler/rustc_lint_defs/src/builtin.rs | 5 +++-- tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs | 2 -- .../pattern/mut_dont_reset_binding_mode_2024_lint.stderr | 8 ++------ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index bc36a587a9e..5859f7b4319 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1657,10 +1657,11 @@ Allow, "detects `mut x` bindings that change the type of `x`", @feature_gate = sym::mut_dont_reset_binding_mode_2024; - @future_incompatible = FutureIncompatibleInfo { + // FIXME uncomment below upon stabilization + /*@future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024), reference: "123076", - }; + };*/ } declare_lint! { diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs b/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs index 2992e61fbbc..2e8a82d12cd 100644 --- a/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs +++ b/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs @@ -8,11 +8,9 @@ fn main() { let Foo(mut a) = &Foo(0); //~^ ERROR: dereferencing `mut` binding - //~| WARN: this changes meaning in Rust 2024 a = 42; let Foo(mut a) = &mut Foo(0); //~^ ERROR: dereferencing `mut` binding - //~| WARN: this changes meaning in Rust 2024 a = 42; } diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr b/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr index 72b72f0df5d..4db775f0f51 100644 --- a/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr +++ b/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr @@ -4,8 +4,6 @@ error: dereferencing `mut` binding LL | let Foo(mut a) = &Foo(0); | ^^^^^ `mut` dereferences the type of this binding | - = warning: this changes meaning in Rust 2024 - = note: for more information, see 123076 help: this will change in edition 2024 --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:9:13 | @@ -18,15 +16,13 @@ LL | #![forbid(dereferencing_mut_binding)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: dereferencing `mut` binding - --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:14:13 + --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:13:13 | LL | let Foo(mut a) = &mut Foo(0); | ^^^^^ `mut` dereferences the type of this binding | - = warning: this changes meaning in Rust 2024 - = note: for more information, see 123076 help: this will change in edition 2024 - --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:14:13 + --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:13:13 | LL | let Foo(mut a) = &mut Foo(0); | ^^^^^ From 1b2e471b43610e74c7cc6e7a38d48293420e157f Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Sun, 14 Apr 2024 11:07:23 -0400 Subject: [PATCH 19/27] Fix typo Co-authored-by: Guillaume Boisseau --- compiler/rustc_lint_defs/src/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 5859f7b4319..3d80eb1cec9 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1651,7 +1651,7 @@ /// ### Explanation /// /// Without the `mut`, `x` would have type `&u32`. Pre-2024, adding `mut` makes `x` have type - /// `u32`, which was deeped surprising. After edition 2024, adding `mut` will not change the + /// `u32`, which was deemed surprising. After edition 2024, adding `mut` will not change the /// type of `x`. This lint warns users of editions before 2024 to update their code. pub DEREFERENCING_MUT_BINDING, Allow, From e13911e6e8d0d85802789a2d75aeb0e4b49ebb33 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Sun, 14 Apr 2024 11:12:52 -0400 Subject: [PATCH 20/27] Rename feature gate --- compiler/rustc_feature/src/unstable.rs | 2 +- compiler/rustc_hir_typeck/src/pat.rs | 2 +- compiler/rustc_lint_defs/src/builtin.rs | 2 +- compiler/rustc_span/src/symbol.rs | 2 +- ... => feature-gate-mut_preserve_binding_mode_2024.rs} | 0 ...feature-gate-mut_preserve_binding_mode_2024.stderr} | 4 ++-- ..._mode_2021.rs => mut_preserve_binding_mode_2021.rs} | 2 +- ...21.stderr => mut_preserve_binding_mode_2021.stderr} | 4 ++-- ..._mode_2024.rs => mut_preserve_binding_mode_2024.rs} | 2 +- ..._lint.rs => mut_preserve_binding_mode_2024_lint.rs} | 2 +- ...derr => mut_preserve_binding_mode_2024_lint.stderr} | 10 +++++----- 11 files changed, 16 insertions(+), 16 deletions(-) rename tests/ui/pattern/{feature-gate-mut_dont_reset_binding_mode_2024.rs => feature-gate-mut_preserve_binding_mode_2024.rs} (100%) rename tests/ui/pattern/{feature-gate-mut_dont_reset_binding_mode_2024.stderr => feature-gate-mut_preserve_binding_mode_2024.stderr} (84%) rename tests/ui/pattern/{mut_dont_reset_binding_mode_2021.rs => mut_preserve_binding_mode_2021.rs} (84%) rename tests/ui/pattern/{mut_dont_reset_binding_mode_2021.stderr => mut_preserve_binding_mode_2021.stderr} (87%) rename tests/ui/pattern/{mut_dont_reset_binding_mode_2024.rs => mut_preserve_binding_mode_2024.rs} (82%) rename tests/ui/pattern/{mut_dont_reset_binding_mode_2024_lint.rs => mut_preserve_binding_mode_2024_lint.rs} (86%) rename tests/ui/pattern/{mut_dont_reset_binding_mode_2024_lint.stderr => mut_preserve_binding_mode_2024_lint.stderr} (70%) diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 2a753af9387..3fc05752dd1 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -534,7 +534,7 @@ pub fn internal(&self, feature: Symbol) -> bool { /// Allows the `#[must_not_suspend]` attribute. (unstable, must_not_suspend, "1.57.0", Some(83310)), /// Make `mut` not reset the binding mode on edition >= 2024. - (unstable, mut_dont_reset_binding_mode_2024, "CURRENT_RUSTC_VERSION", Some(123076)), + (unstable, mut_preserve_binding_mode_2024, "CURRENT_RUSTC_VERSION", Some(123076)), /// Allows `mut ref` and `mut ref mut` identifier patterns. (incomplete, mut_ref, "CURRENT_RUSTC_VERSION", Some(123076)), /// Allows using `#[naked]` on functions. diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 252125aba7c..cdc6c4d809d 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -636,7 +636,7 @@ fn check_pat_ident( let bm = match ba { BindingAnnotation(ByRef::No, Mutability::Mut) if !(pat.span.at_least_rust_2024() - && self.tcx.features().mut_dont_reset_binding_mode_2024) + && self.tcx.features().mut_preserve_binding_mode_2024) && matches!(def_br, ByRef::Yes(_)) => { // `mut x` resets the binding mode in edition <= 2021. diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 3d80eb1cec9..e74cc388cab 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1656,7 +1656,7 @@ pub DEREFERENCING_MUT_BINDING, Allow, "detects `mut x` bindings that change the type of `x`", - @feature_gate = sym::mut_dont_reset_binding_mode_2024; + @feature_gate = sym::mut_preserve_binding_mode_2024; // FIXME uncomment below upon stabilization /*@future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024), diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 02550fd655c..0a95d86ccc8 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1194,7 +1194,7 @@ multiple_supertrait_upcastable, must_not_suspend, must_use, - mut_dont_reset_binding_mode_2024, + mut_preserve_binding_mode_2024, mut_ref, naked, naked_functions, diff --git a/tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.rs b/tests/ui/pattern/feature-gate-mut_preserve_binding_mode_2024.rs similarity index 100% rename from tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.rs rename to tests/ui/pattern/feature-gate-mut_preserve_binding_mode_2024.rs diff --git a/tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.stderr b/tests/ui/pattern/feature-gate-mut_preserve_binding_mode_2024.stderr similarity index 84% rename from tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.stderr rename to tests/ui/pattern/feature-gate-mut_preserve_binding_mode_2024.stderr index 1624883de60..6d0a034be21 100644 --- a/tests/ui/pattern/feature-gate-mut_dont_reset_binding_mode_2024.stderr +++ b/tests/ui/pattern/feature-gate-mut_preserve_binding_mode_2024.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/feature-gate-mut_dont_reset_binding_mode_2024.rs:8:9 + --> $DIR/feature-gate-mut_preserve_binding_mode_2024.rs:8:9 | LL | let Foo(mut a) = &Foo(0); | ----- expected due to the type of this binding @@ -13,7 +13,7 @@ LL + a = 42; | error[E0308]: mismatched types - --> $DIR/feature-gate-mut_dont_reset_binding_mode_2024.rs:12:9 + --> $DIR/feature-gate-mut_preserve_binding_mode_2024.rs:12:9 | LL | let Foo(mut a) = &mut Foo(0); | ----- expected due to the type of this binding diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2021.rs b/tests/ui/pattern/mut_preserve_binding_mode_2021.rs similarity index 84% rename from tests/ui/pattern/mut_dont_reset_binding_mode_2021.rs rename to tests/ui/pattern/mut_preserve_binding_mode_2021.rs index a9e12472734..658ba2851cc 100644 --- a/tests/ui/pattern/mut_dont_reset_binding_mode_2021.rs +++ b/tests/ui/pattern/mut_preserve_binding_mode_2021.rs @@ -1,6 +1,6 @@ //@ edition: 2021 //@ compile-flags: -Zunstable-options -#![feature(mut_dont_reset_binding_mode_2024)] +#![feature(mut_preserve_binding_mode_2024)] struct Foo(u8); diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2021.stderr b/tests/ui/pattern/mut_preserve_binding_mode_2021.stderr similarity index 87% rename from tests/ui/pattern/mut_dont_reset_binding_mode_2021.stderr rename to tests/ui/pattern/mut_preserve_binding_mode_2021.stderr index 16818c900b3..9487aa64b4f 100644 --- a/tests/ui/pattern/mut_dont_reset_binding_mode_2021.stderr +++ b/tests/ui/pattern/mut_preserve_binding_mode_2021.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/mut_dont_reset_binding_mode_2021.rs:9:9 + --> $DIR/mut_preserve_binding_mode_2021.rs:9:9 | LL | let Foo(mut a) = &Foo(0); | ----- expected due to the type of this binding @@ -13,7 +13,7 @@ LL + a = 42; | error[E0308]: mismatched types - --> $DIR/mut_dont_reset_binding_mode_2021.rs:13:9 + --> $DIR/mut_preserve_binding_mode_2021.rs:13:9 | LL | let Foo(mut a) = &mut Foo(0); | ----- expected due to the type of this binding diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2024.rs b/tests/ui/pattern/mut_preserve_binding_mode_2024.rs similarity index 82% rename from tests/ui/pattern/mut_dont_reset_binding_mode_2024.rs rename to tests/ui/pattern/mut_preserve_binding_mode_2024.rs index 9ac5ec50c74..a5d7ac9d8e6 100644 --- a/tests/ui/pattern/mut_dont_reset_binding_mode_2024.rs +++ b/tests/ui/pattern/mut_preserve_binding_mode_2024.rs @@ -1,7 +1,7 @@ //@ run-pass //@ edition: 2024 //@ compile-flags: -Zunstable-options -#![feature(mut_dont_reset_binding_mode_2024)] +#![feature(mut_preserve_binding_mode_2024)] #![allow(unused)] struct Foo(u8); diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs b/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.rs similarity index 86% rename from tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs rename to tests/ui/pattern/mut_preserve_binding_mode_2024_lint.rs index 2e8a82d12cd..d3e3ffffcc5 100644 --- a/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.rs +++ b/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.rs @@ -1,5 +1,5 @@ //@ edition: 2021 -#![feature(mut_dont_reset_binding_mode_2024)] +#![feature(mut_preserve_binding_mode_2024)] #![allow(unused)] #![forbid(dereferencing_mut_binding)] diff --git a/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr b/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.stderr similarity index 70% rename from tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr rename to tests/ui/pattern/mut_preserve_binding_mode_2024_lint.stderr index 4db775f0f51..e8d11acd83e 100644 --- a/tests/ui/pattern/mut_dont_reset_binding_mode_2024_lint.stderr +++ b/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.stderr @@ -1,28 +1,28 @@ error: dereferencing `mut` binding - --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:9:13 + --> $DIR/mut_preserve_binding_mode_2024_lint.rs:9:13 | LL | let Foo(mut a) = &Foo(0); | ^^^^^ `mut` dereferences the type of this binding | help: this will change in edition 2024 - --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:9:13 + --> $DIR/mut_preserve_binding_mode_2024_lint.rs:9:13 | LL | let Foo(mut a) = &Foo(0); | ^^^^^ note: the lint level is defined here - --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:4:11 + --> $DIR/mut_preserve_binding_mode_2024_lint.rs:4:11 | LL | #![forbid(dereferencing_mut_binding)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: dereferencing `mut` binding - --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:13:13 + --> $DIR/mut_preserve_binding_mode_2024_lint.rs:13:13 | LL | let Foo(mut a) = &mut Foo(0); | ^^^^^ `mut` dereferences the type of this binding | help: this will change in edition 2024 - --> $DIR/mut_dont_reset_binding_mode_2024_lint.rs:13:13 + --> $DIR/mut_preserve_binding_mode_2024_lint.rs:13:13 | LL | let Foo(mut a) = &mut Foo(0); | ^^^^^ From 1b6d435cf3e94548f3da6a0409c5786c4accfaa4 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Sun, 14 Apr 2024 11:17:58 -0400 Subject: [PATCH 21/27] Mark gate as incomplete --- compiler/rustc_feature/src/unstable.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 3fc05752dd1..eaaf4026cd7 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -534,7 +534,7 @@ pub fn internal(&self, feature: Symbol) -> bool { /// Allows the `#[must_not_suspend]` attribute. (unstable, must_not_suspend, "1.57.0", Some(83310)), /// Make `mut` not reset the binding mode on edition >= 2024. - (unstable, mut_preserve_binding_mode_2024, "CURRENT_RUSTC_VERSION", Some(123076)), + (incomplete, mut_preserve_binding_mode_2024, "CURRENT_RUSTC_VERSION", Some(123076)), /// Allows `mut ref` and `mut ref mut` identifier patterns. (incomplete, mut_ref, "CURRENT_RUSTC_VERSION", Some(123076)), /// Allows using `#[naked]` on functions. From 7a3211726bb101ab0c0138b2dcff44a175ff74c4 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Sun, 14 Apr 2024 13:33:11 -0400 Subject: [PATCH 22/27] Fix tests --- tests/ui/pattern/mut_preserve_binding_mode_2021.rs | 1 + tests/ui/pattern/mut_preserve_binding_mode_2021.stderr | 4 ++-- tests/ui/pattern/mut_preserve_binding_mode_2024.rs | 2 +- tests/ui/pattern/mut_preserve_binding_mode_2024_lint.rs | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/ui/pattern/mut_preserve_binding_mode_2021.rs b/tests/ui/pattern/mut_preserve_binding_mode_2021.rs index 658ba2851cc..befa49fdc24 100644 --- a/tests/ui/pattern/mut_preserve_binding_mode_2021.rs +++ b/tests/ui/pattern/mut_preserve_binding_mode_2021.rs @@ -1,6 +1,7 @@ //@ edition: 2021 //@ compile-flags: -Zunstable-options #![feature(mut_preserve_binding_mode_2024)] +#![allow(incomplete_features)] struct Foo(u8); diff --git a/tests/ui/pattern/mut_preserve_binding_mode_2021.stderr b/tests/ui/pattern/mut_preserve_binding_mode_2021.stderr index 9487aa64b4f..b800cc4a0f4 100644 --- a/tests/ui/pattern/mut_preserve_binding_mode_2021.stderr +++ b/tests/ui/pattern/mut_preserve_binding_mode_2021.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/mut_preserve_binding_mode_2021.rs:9:9 + --> $DIR/mut_preserve_binding_mode_2021.rs:10:9 | LL | let Foo(mut a) = &Foo(0); | ----- expected due to the type of this binding @@ -13,7 +13,7 @@ LL + a = 42; | error[E0308]: mismatched types - --> $DIR/mut_preserve_binding_mode_2021.rs:13:9 + --> $DIR/mut_preserve_binding_mode_2021.rs:14:9 | LL | let Foo(mut a) = &mut Foo(0); | ----- expected due to the type of this binding diff --git a/tests/ui/pattern/mut_preserve_binding_mode_2024.rs b/tests/ui/pattern/mut_preserve_binding_mode_2024.rs index a5d7ac9d8e6..5454962e16c 100644 --- a/tests/ui/pattern/mut_preserve_binding_mode_2024.rs +++ b/tests/ui/pattern/mut_preserve_binding_mode_2024.rs @@ -2,7 +2,7 @@ //@ edition: 2024 //@ compile-flags: -Zunstable-options #![feature(mut_preserve_binding_mode_2024)] -#![allow(unused)] +#![allow(incomplete_features, unused)] struct Foo(u8); diff --git a/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.rs b/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.rs index d3e3ffffcc5..249f251d2cd 100644 --- a/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.rs +++ b/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.rs @@ -1,6 +1,6 @@ //@ edition: 2021 #![feature(mut_preserve_binding_mode_2024)] -#![allow(unused)] +#![allow(incomplete_features, unused)] #![forbid(dereferencing_mut_binding)] struct Foo(u8); From 2f08c2c96501990caab0e47a095d76ffd6a31f16 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 16 Apr 2024 07:52:25 +0200 Subject: [PATCH 23/27] update lockfile --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bf31bf72d4c..c8b3095ae80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3365,9 +3365,9 @@ dependencies = [ [[package]] name = "rustc-build-sysroot" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26170e1d79ea32f7ccec3188dd13cfc1f18c82764a9cbc1071667c0f865a4ea" +checksum = "a9bf37423495cd3a6a9ef8c75fc4566de0d26de0ab75f36f67a426e58df5768c" dependencies = [ "anyhow", "rustc_version", From 876ac7b1c3fcd99b06a3170bd4abdc7e3317a005 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 16 Apr 2024 08:52:06 +0200 Subject: [PATCH 24/27] avoid passing --sysroot twice in bootstrap --- src/tools/miri/cargo-miri/src/phases.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/tools/miri/cargo-miri/src/phases.rs b/src/tools/miri/cargo-miri/src/phases.rs index ca8b35a17be..b774ca8fa72 100644 --- a/src/tools/miri/cargo-miri/src/phases.rs +++ b/src/tools/miri/cargo-miri/src/phases.rs @@ -412,8 +412,11 @@ fn out_filenames() -> Vec { // Arguments are treated very differently depending on whether this crate is // for interpretation by Miri, or for use by a build script / proc macro. if target_crate { - // Set the sysroot. - cmd.arg("--sysroot").arg(env::var_os("MIRI_SYSROOT").unwrap()); + if phase != RustcPhase::Setup { + // Set the sysroot -- except during setup, where we don't have an existing sysroot yet + // and where the bootstrap wrapper adds its own `--sysroot` flag so we can't set ours. + cmd.arg("--sysroot").arg(env::var_os("MIRI_SYSROOT").unwrap()); + } // Forward arguments, but patched. let emit_flag = "--emit"; @@ -578,9 +581,9 @@ pub fn phase_runner(mut binary_args: impl Iterator, phase: Runner } if phase != RunnerPhase::Rustdoc { - // Set the sysroot. Not necessary in rustdoc, where we already set the sysroot when invoking - // rustdoc itself, which will forward that flag when invoking rustc (i.e., us), so the flag - // is present in `info.args`. + // Set the sysroot. Not necessary in rustdoc, where we already set the sysroot in + // `phase_rustdoc`. rustdoc will forward that flag when invoking rustc (i.e., us), so the + // flag is present in `info.args`. cmd.arg("--sysroot").arg(env::var_os("MIRI_SYSROOT").unwrap()); } // Forward rustc arguments. From e03926c1438173843429f570513972cc6f2e2f6c Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 16 Apr 2024 14:00:53 +0000 Subject: [PATCH 25/27] Change a diagnostics-path-only `DefineOpaqueTypes` to `Yes`. --- compiler/rustc_hir_typeck/src/method/probe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 28e17e1de36..f1e3f38febd 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -1696,7 +1696,7 @@ fn consider_probe( if let ProbeResult::Match = result && self .at(&ObligationCause::dummy(), self.param_env) - .sup(DefineOpaqueTypes::No, return_ty, xform_ret_ty) + .sup(DefineOpaqueTypes::Yes, return_ty, xform_ret_ty) .is_err() { result = ProbeResult::BadReturnType; From 18bfca50f1a6d9ccf322fa4dafec3a67a39ef300 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 16 Apr 2024 16:37:34 +0200 Subject: [PATCH 26/27] interpret: pass MemoryKind to before_memory_deallocation --- .../rustc_const_eval/src/interpret/machine.rs | 1 + compiler/rustc_const_eval/src/interpret/memory.rs | 1 + src/tools/miri/src/borrow_tracker/mod.rs | 2 +- .../src/borrow_tracker/stacked_borrows/mod.rs | 2 +- .../miri/src/borrow_tracker/tree_borrows/mod.rs | 2 +- src/tools/miri/src/concurrency/data_race.rs | 2 +- src/tools/miri/src/diagnostics.rs | 4 ++-- src/tools/miri/src/lib.rs | 2 +- src/tools/miri/src/machine.rs | 15 ++++++++------- src/tools/miri/src/shims/os_str.rs | 8 ++++---- 10 files changed, 21 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs index 827d8fd9417..be66ac548d3 100644 --- a/compiler/rustc_const_eval/src/interpret/machine.rs +++ b/compiler/rustc_const_eval/src/interpret/machine.rs @@ -427,6 +427,7 @@ fn before_memory_deallocation( _prov: (AllocId, Self::ProvenanceExtra), _size: Size, _align: Align, + _kind: MemoryKind, ) -> InterpResult<'tcx> { Ok(()) } diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index 9b1d9cf932b..ca2beb40ce8 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -355,6 +355,7 @@ pub fn deallocate_ptr( (alloc_id, prov), size, alloc.align, + kind, )?; // Don't forget to remember size and align of this now-dead allocation diff --git a/src/tools/miri/src/borrow_tracker/mod.rs b/src/tools/miri/src/borrow_tracker/mod.rs index 8d76a488269..f21315790a5 100644 --- a/src/tools/miri/src/borrow_tracker/mod.rs +++ b/src/tools/miri/src/borrow_tracker/mod.rs @@ -260,7 +260,7 @@ pub fn new_allocation( &mut self, id: AllocId, alloc_size: Size, - kind: MemoryKind, + kind: MemoryKind, machine: &MiriMachine<'_, '_>, ) -> AllocState { match self.borrow_tracker_method { diff --git a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs index 96ff298402d..b4005515d9d 100644 --- a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs @@ -509,7 +509,7 @@ pub fn new_allocation( id: AllocId, size: Size, state: &mut GlobalStateInner, - kind: MemoryKind, + kind: MemoryKind, machine: &MiriMachine<'_, '_>, ) -> Self { let (base_tag, perm) = match kind { diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs index a3d49756e4c..492e324de45 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs @@ -34,7 +34,7 @@ pub fn new_allocation( id: AllocId, size: Size, state: &mut GlobalStateInner, - _kind: MemoryKind, + _kind: MemoryKind, machine: &MiriMachine<'_, 'tcx>, ) -> Self { let tag = state.base_ptr_tag(id, machine); // Fresh tag for the root diff --git a/src/tools/miri/src/concurrency/data_race.rs b/src/tools/miri/src/concurrency/data_race.rs index d51160b2831..95049b91cba 100644 --- a/src/tools/miri/src/concurrency/data_race.rs +++ b/src/tools/miri/src/concurrency/data_race.rs @@ -844,7 +844,7 @@ pub fn new_allocation( global: &GlobalState, thread_mgr: &ThreadManager<'_, '_>, len: Size, - kind: MemoryKind, + kind: MemoryKind, current_span: Span, ) -> VClockAlloc { let (alloc_timestamp, alloc_index) = match kind { diff --git a/src/tools/miri/src/diagnostics.rs b/src/tools/miri/src/diagnostics.rs index 30349c003a9..a2b817ea0d5 100644 --- a/src/tools/miri/src/diagnostics.rs +++ b/src/tools/miri/src/diagnostics.rs @@ -115,7 +115,7 @@ pub enum NonHaltingDiagnostic { /// This `Item` was popped from the borrow stack. The string explains the reason. PoppedPointerTag(Item, String), CreatedCallId(CallId), - CreatedAlloc(AllocId, Size, Align, MemoryKind), + CreatedAlloc(AllocId, Size, Align, MemoryKind), FreedAlloc(AllocId), AccessedAlloc(AllocId, AccessKind), RejectedIsolatedOp(String), @@ -414,7 +414,7 @@ pub fn report_error<'tcx, 'mir>( pub fn report_leaks<'mir, 'tcx>( ecx: &InterpCx<'mir, 'tcx, MiriMachine<'mir, 'tcx>>, - leaks: Vec<(AllocId, MemoryKind, Allocation>)>, + leaks: Vec<(AllocId, MemoryKind, Allocation>)>, ) { let mut any_pruned = false; for (id, kind, mut alloc) in leaks { diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 7821aa9efd4..42e66057b9d 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -125,7 +125,7 @@ }; pub use crate::helpers::{AccessKind, EvalContextExt as _}; pub use crate::machine::{ - AllocExtra, FrameExtra, MiriInterpCx, MiriInterpCxExt, MiriMachine, MiriMemoryKind, + AllocExtra, FrameExtra, MemoryKind, MiriInterpCx, MiriInterpCxExt, MiriMachine, MiriMemoryKind, PrimitiveLayouts, Provenance, ProvenanceExtra, }; pub use crate::mono_hash_map::MonoHashMap; diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index ff081328a72..1d06d5c69d3 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -135,9 +135,9 @@ pub enum MiriMemoryKind { Mmap, } -impl From for MemoryKind { +impl From for MemoryKind { #[inline(always)] - fn from(kind: MiriMemoryKind) -> MemoryKind { + fn from(kind: MiriMemoryKind) -> MemoryKind { MemoryKind::Machine(kind) } } @@ -185,6 +185,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } +pub type MemoryKind = interpret::MemoryKind; + /// Pointer provenance. #[derive(Clone, Copy)] pub enum Provenance { @@ -863,10 +865,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> { type ProvenanceExtra = ProvenanceExtra; type Bytes = Box<[u8]>; - type MemoryMap = MonoHashMap< - AllocId, - (MemoryKind, Allocation), - >; + type MemoryMap = + MonoHashMap)>; const GLOBAL_KIND: Option = Some(MiriMemoryKind::Global); @@ -1088,7 +1088,7 @@ fn adjust_allocation<'b>( ecx: &MiriInterpCx<'mir, 'tcx>, id: AllocId, alloc: Cow<'b, Allocation>, - kind: Option>, + kind: Option, ) -> InterpResult<'tcx, Cow<'b, Allocation>> { let kind = kind.expect("we set our STATIC_KIND so this cannot be None"); if ecx.machine.tracked_alloc_ids.contains(&id) { @@ -1280,6 +1280,7 @@ fn before_memory_deallocation( (alloc_id, prove_extra): (AllocId, Self::ProvenanceExtra), size: Size, align: Align, + _kind: MemoryKind, ) -> InterpResult<'tcx> { if machine.tracked_alloc_ids.contains(&alloc_id) { machine.emit_diagnostic(NonHaltingDiagnostic::FreedAlloc(alloc_id)); diff --git a/src/tools/miri/src/shims/os_str.rs b/src/tools/miri/src/shims/os_str.rs index 62ce2ee58ae..a27c9b746da 100644 --- a/src/tools/miri/src/shims/os_str.rs +++ b/src/tools/miri/src/shims/os_str.rs @@ -136,7 +136,7 @@ fn os_str_to_u16vec<'tcx>(os_str: &OsStr) -> InterpResult<'tcx, Vec> { fn alloc_os_str_as_c_str( &mut self, os_str: &OsStr, - memkind: MemoryKind, + memkind: MemoryKind, ) -> InterpResult<'tcx, Pointer>> { let size = u64::try_from(os_str.len()).unwrap().checked_add(1).unwrap(); // Make space for `0` terminator. let this = self.eval_context_mut(); @@ -152,7 +152,7 @@ fn alloc_os_str_as_c_str( fn alloc_os_str_as_wide_str( &mut self, os_str: &OsStr, - memkind: MemoryKind, + memkind: MemoryKind, ) -> InterpResult<'tcx, Pointer>> { let size = u64::try_from(os_str.len()).unwrap().checked_add(1).unwrap(); // Make space for `0x0000` terminator. let this = self.eval_context_mut(); @@ -229,7 +229,7 @@ fn write_path_to_wide_str( fn alloc_path_as_c_str( &mut self, path: &Path, - memkind: MemoryKind, + memkind: MemoryKind, ) -> InterpResult<'tcx, Pointer>> { let this = self.eval_context_mut(); let os_str = @@ -242,7 +242,7 @@ fn alloc_path_as_c_str( fn alloc_path_as_wide_str( &mut self, path: &Path, - memkind: MemoryKind, + memkind: MemoryKind, ) -> InterpResult<'tcx, Pointer>> { let this = self.eval_context_mut(); let os_str = From 5b8b9cfaaac046d105a1d716b182a84dbd582678 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 16 Apr 2024 17:33:12 +0200 Subject: [PATCH 27/27] interpret: remove outdated comment --- compiler/rustc_const_eval/src/interpret/machine.rs | 2 -- compiler/rustc_const_eval/src/interpret/memory.rs | 1 - 2 files changed, 3 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs index 827d8fd9417..9c110202fe0 100644 --- a/compiler/rustc_const_eval/src/interpret/machine.rs +++ b/compiler/rustc_const_eval/src/interpret/machine.rs @@ -347,8 +347,6 @@ fn ptr_get_alloc( /// allocation (because a copy had to be done to adjust things), machine memory will /// cache the result. (This relies on `AllocMap::get_or` being able to add the /// owned allocation to the map even when the map is shared.) - /// - /// This must only fail if `alloc` contains provenance. fn adjust_allocation<'b>( ecx: &InterpCx<'mir, 'tcx, Self>, id: AllocId, diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index 9b1d9cf932b..bd228122dba 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -227,7 +227,6 @@ pub fn allocate_bytes_ptr( self.allocate_raw_ptr(alloc, kind) } - /// This can fail only if `alloc` contains provenance. pub fn allocate_raw_ptr( &mut self, alloc: Allocation,