From 9d694b583e3c4e899f61cb2086e2ed9627ec3619 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Mon, 26 Aug 2024 08:28:26 +0300 Subject: [PATCH 01/17] support custom clippy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to cargo, rustc, and rustfmt, this adds the support of using custom clippy on bootstrap. It’s designed for those who want to test their own clippy builds or avoid downloading the stage0 clippy. Signed-off-by: onur-ozkan --- src/bootstrap/src/core/builder.rs | 8 ++++++-- src/bootstrap/src/core/config/config.rs | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index ff0d1f3a725d2..d7398b76cc91e 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -1298,8 +1298,12 @@ impl<'a> Builder<'a> { pub fn cargo_clippy_cmd(&self, run_compiler: Compiler) -> BootstrapCommand { if run_compiler.stage == 0 { - // `ensure(Clippy { stage: 0 })` *builds* clippy with stage0, it doesn't use the beta clippy. - let cargo_clippy = self.build.config.download_clippy(); + let cargo_clippy = self + .config + .initial_cargo_clippy + .clone() + .unwrap_or_else(|| self.build.config.download_clippy()); + let mut cmd = command(cargo_clippy); cmd.env("CARGO", &self.initial_cargo); return cmd; diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index ce23b7735f8bd..cf87f1ff9470e 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -344,6 +344,7 @@ pub struct Config { // These are either the stage0 downloaded binaries or the locally installed ones. pub initial_cargo: PathBuf, pub initial_rustc: PathBuf, + pub initial_cargo_clippy: Option, #[cfg(not(test))] initial_rustfmt: RefCell, @@ -834,6 +835,7 @@ define_config! { cargo: Option = "cargo", rustc: Option = "rustc", rustfmt: Option = "rustfmt", + cargo_clippy: Option = "cargo-clippy", docs: Option = "docs", compiler_docs: Option = "compiler-docs", library_docs_private_items: Option = "library-docs-private-items", @@ -1439,6 +1441,7 @@ impl Config { cargo, rustc, rustfmt, + cargo_clippy, docs, compiler_docs, library_docs_private_items, @@ -1491,6 +1494,14 @@ impl Config { config.out = absolute(&config.out).expect("can't make empty path absolute"); } + if cargo_clippy.is_some() && rustc.is_none() { + println!( + "WARNING: Using `build.cargo-clippy` without `build.rustc` usually fails due to toolchain conflict." + ); + } + + config.initial_cargo_clippy = cargo_clippy; + config.initial_rustc = if let Some(rustc) = rustc { if !flags.skip_stage0_validation { config.check_stage0_version(&rustc, "rustc"); From 9dcc65600e63d23a727190ca1fd91ab645adefb8 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Mon, 26 Aug 2024 08:28:54 +0300 Subject: [PATCH 02/17] document `build.cargo-clippy` option Signed-off-by: onur-ozkan --- config.example.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config.example.toml b/config.example.toml index f1dc32234ccf2..b967d5d9fe8c2 100644 --- a/config.example.toml +++ b/config.example.toml @@ -230,6 +230,13 @@ # use this rustfmt binary instead as the stage0 snapshot rustfmt. #rustfmt = "/path/to/rustfmt" +# Instead of downloading the src/stage0 version of cargo-clippy specified, +# use this cargo-clippy binary instead as the stage0 snapshot cargo-clippy. +# +# Note that this option should be used with the same toolchain as the `rustc` option above. +# Otherwise, clippy is likely to fail due to a toolchain conflict. +#cargo-clippy = "/path/to/cargo-clippy" + # Whether to build documentation by default. If false, rustdoc and # friends will still be compiled but they will not be used to generate any # documentation. From 1a991e5b805832aca83862458864a7caf57d6725 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Mon, 26 Aug 2024 08:29:17 +0300 Subject: [PATCH 03/17] add change entry for custom clippy support 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 51a25104e4cfb..3ab14aade9f81 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -235,4 +235,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Info, summary: "The `build.profiler` option now tries to use source code from `download-ci-llvm` if possible, instead of checking out the `src/llvm-project` submodule.", }, + ChangeInfo { + change_id: 129152, + severity: ChangeSeverity::Info, + summary: "New option `build.cargo-clippy` added for supporting the use of custom/external clippy.", + }, ]; From 893413de5b3e574cee9e2e2cc36524a485b9ea83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sat, 24 Aug 2024 10:55:31 +0200 Subject: [PATCH 04/17] Add a run-make test for checking that certain `rustc_` crates build on stable --- .../src/external_deps/cargo.rs | 7 ++++ .../run-make-support/src/external_deps/mod.rs | 1 + .../src/external_deps/rustc.rs | 7 ++-- src/tools/run-make-support/src/lib.rs | 4 ++- .../run-make/rustc-crates-on-stable/rmake.rs | 35 +++++++++++++++++++ 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 src/tools/run-make-support/src/external_deps/cargo.rs create mode 100644 tests/run-make/rustc-crates-on-stable/rmake.rs diff --git a/src/tools/run-make-support/src/external_deps/cargo.rs b/src/tools/run-make-support/src/external_deps/cargo.rs new file mode 100644 index 0000000000000..b0e045dc80bf8 --- /dev/null +++ b/src/tools/run-make-support/src/external_deps/cargo.rs @@ -0,0 +1,7 @@ +use crate::command::Command; +use crate::env_var; + +/// Returns a command that can be used to invoke Cargo. +pub fn cargo() -> Command { + Command::new(env_var("BOOTSTRAP_CARGO")) +} diff --git a/src/tools/run-make-support/src/external_deps/mod.rs b/src/tools/run-make-support/src/external_deps/mod.rs index f7c84724d0e07..80c34a9070fcc 100644 --- a/src/tools/run-make-support/src/external_deps/mod.rs +++ b/src/tools/run-make-support/src/external_deps/mod.rs @@ -2,6 +2,7 @@ //! such as `cc` or `python`. pub mod c_build; +pub mod cargo; pub mod cc; pub mod clang; pub mod htmldocck; diff --git a/src/tools/run-make-support/src/external_deps/rustc.rs b/src/tools/run-make-support/src/external_deps/rustc.rs index cece58d29566c..e20d87165144a 100644 --- a/src/tools/run-make-support/src/external_deps/rustc.rs +++ b/src/tools/run-make-support/src/external_deps/rustc.rs @@ -36,10 +36,13 @@ pub struct Rustc { crate::macros::impl_common_helpers!(Rustc); +pub fn rustc_path() -> String { + env_var("RUSTC") +} + #[track_caller] fn setup_common() -> Command { - let rustc = env_var("RUSTC"); - let mut cmd = Command::new(rustc); + let mut cmd = Command::new(rustc_path()); set_host_rpath(&mut cmd); cmd } diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index 989d00d4c2f97..efe744d6ba4a7 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -48,6 +48,7 @@ pub use external_deps::{c_build, cc, clang, htmldocck, llvm, python, rustc, rust // These rely on external dependencies. pub use cc::{cc, cxx, extra_c_flags, extra_cxx_flags, Cc}; pub use c_build::{build_native_dynamic_lib, build_native_static_lib, build_native_static_lib_optimized, build_native_static_lib_cxx}; +pub use cargo::cargo; pub use clang::{clang, Clang}; pub use htmldocck::htmldocck; pub use llvm::{ @@ -56,7 +57,7 @@ pub use llvm::{ LlvmProfdata, LlvmReadobj, }; pub use python::python_command; -pub use rustc::{aux_build, bare_rustc, rustc, Rustc}; +pub use rustc::{aux_build, bare_rustc, rustc, rustc_path, Rustc}; pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc}; /// [`diff`][mod@diff] is implemented in terms of the [similar] library. @@ -96,3 +97,4 @@ pub use assertion_helpers::{ pub use string::{ count_regex_matches_in_files_with_extension, invalid_utf8_contains, invalid_utf8_not_contains, }; +use crate::external_deps::cargo; diff --git a/tests/run-make/rustc-crates-on-stable/rmake.rs b/tests/run-make/rustc-crates-on-stable/rmake.rs new file mode 100644 index 0000000000000..67461788ee4b6 --- /dev/null +++ b/tests/run-make/rustc-crates-on-stable/rmake.rs @@ -0,0 +1,35 @@ +//! Checks if selected rustc crates can be compiled on the stable channel (or a "simulation" of it). +//! These crates are designed to be used by downstream users. + +use run_make_support::{cargo, rustc_path, source_root}; + +fn main() { + // Use the stage0 beta cargo for the compilation (it shouldn't really matter which cargo we use) + let cargo = cargo() + // This is required to allow using nightly cargo features (public-dependency) with beta + // cargo + .env("RUSTC_BOOTSTRAP", "1") + .env("RUSTC", rustc_path()) + .arg("build") + .arg("--manifest-path") + .arg(source_root().join("Cargo.toml")) + .args(&[ + "--config", + r#"workspace.exclude=["library/core"]"#, + // We want to disallow all nightly features, to simulate a stable build + // public-dependency needs to be enabled for cargo to work + "-Zallow-features=public-dependency", + // Avoid depending on transitive rustc crates + "--no-default-features", + // Check that these crates can be compiled on "stable" + "-p", + "rustc_type_ir", + "-p", + "rustc_next_trait_solver", + "-p", + "rustc_pattern_analysis", + "-p", + "rustc_lexer", + ]) + .run(); +} From 7957140f3ef7fbbaf9696d8fbbced1ebe6128c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Sat, 24 Aug 2024 20:34:46 +0000 Subject: [PATCH 05/17] inhibit proc-macro2 nightly detection --- tests/run-make/rustc-crates-on-stable/rmake.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/run-make/rustc-crates-on-stable/rmake.rs b/tests/run-make/rustc-crates-on-stable/rmake.rs index 67461788ee4b6..503b0c6ead445 100644 --- a/tests/run-make/rustc-crates-on-stable/rmake.rs +++ b/tests/run-make/rustc-crates-on-stable/rmake.rs @@ -9,6 +9,7 @@ fn main() { // This is required to allow using nightly cargo features (public-dependency) with beta // cargo .env("RUSTC_BOOTSTRAP", "1") + .env("RUSTC_STAGE", "0") // Ensure `proc-macro2`'s nightly detection is disabled .env("RUSTC", rustc_path()) .arg("build") .arg("--manifest-path") From d9794a9af63b5cf59bf9a7bfa65191a6d2a1e122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Sat, 24 Aug 2024 21:16:54 +0000 Subject: [PATCH 06/17] run test in tmp dir and emit artifacts there otherwise the test would build in the source root's `target` folder --- .../run-make/rustc-crates-on-stable/rmake.rs | 67 ++++++++++--------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/tests/run-make/rustc-crates-on-stable/rmake.rs b/tests/run-make/rustc-crates-on-stable/rmake.rs index 503b0c6ead445..66f0b2c812625 100644 --- a/tests/run-make/rustc-crates-on-stable/rmake.rs +++ b/tests/run-make/rustc-crates-on-stable/rmake.rs @@ -1,36 +1,43 @@ //! Checks if selected rustc crates can be compiled on the stable channel (or a "simulation" of it). //! These crates are designed to be used by downstream users. -use run_make_support::{cargo, rustc_path, source_root}; +use run_make_support::{cargo, run_in_tmpdir, rustc_path, source_root}; fn main() { - // Use the stage0 beta cargo for the compilation (it shouldn't really matter which cargo we use) - let cargo = cargo() - // This is required to allow using nightly cargo features (public-dependency) with beta - // cargo - .env("RUSTC_BOOTSTRAP", "1") - .env("RUSTC_STAGE", "0") // Ensure `proc-macro2`'s nightly detection is disabled - .env("RUSTC", rustc_path()) - .arg("build") - .arg("--manifest-path") - .arg(source_root().join("Cargo.toml")) - .args(&[ - "--config", - r#"workspace.exclude=["library/core"]"#, - // We want to disallow all nightly features, to simulate a stable build - // public-dependency needs to be enabled for cargo to work - "-Zallow-features=public-dependency", - // Avoid depending on transitive rustc crates - "--no-default-features", - // Check that these crates can be compiled on "stable" - "-p", - "rustc_type_ir", - "-p", - "rustc_next_trait_solver", - "-p", - "rustc_pattern_analysis", - "-p", - "rustc_lexer", - ]) - .run(); + run_in_tmpdir(|| { + // Use the stage0 beta cargo for the compilation (it shouldn't really matter which cargo we + // use) + let cargo = cargo() + // This is required to allow using nightly cargo features (public-dependency) with beta + // cargo + .env("RUSTC_BOOTSTRAP", "1") + .env("RUSTC_STAGE", "0") // Ensure `proc-macro2`'s nightly detection is disabled + .env("RUSTC", rustc_path()) + .arg("build") + .arg("--manifest-path") + .arg(source_root().join("Cargo.toml")) + .args(&[ + "--config", + r#"workspace.exclude=["library/core"]"#, + // We want to disallow all nightly features, to simulate a stable build + // public-dependency needs to be enabled for cargo to work + "-Zallow-features=public-dependency", + // Avoid depending on transitive rustc crates + "--no-default-features", + // Emit artifacts in this temporary directory, not in the source_root's `target` + // folder + "--target-dir", + ".", + // Check that these crates can be compiled on "stable" + "-p", + "rustc_type_ir", + "-p", + "rustc_next_trait_solver", + "-p", + "rustc_pattern_analysis", + "-p", + "rustc_lexer", + ]) + .run(); + }); } From 2190c288e2455bce98dde643267ce53fd3412edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Sun, 25 Aug 2024 10:53:28 +0000 Subject: [PATCH 07/17] remove use of RUSTC_BOOTSTRAP and cargo nightly features --- tests/run-make/rustc-crates-on-stable/rmake.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/run-make/rustc-crates-on-stable/rmake.rs b/tests/run-make/rustc-crates-on-stable/rmake.rs index 66f0b2c812625..513c128828725 100644 --- a/tests/run-make/rustc-crates-on-stable/rmake.rs +++ b/tests/run-make/rustc-crates-on-stable/rmake.rs @@ -8,20 +8,17 @@ fn main() { // Use the stage0 beta cargo for the compilation (it shouldn't really matter which cargo we // use) let cargo = cargo() - // This is required to allow using nightly cargo features (public-dependency) with beta - // cargo - .env("RUSTC_BOOTSTRAP", "1") - .env("RUSTC_STAGE", "0") // Ensure `proc-macro2`'s nightly detection is disabled + // Ensure `proc-macro2`'s nightly detection is disabled + .env("RUSTC_STAGE", "0") .env("RUSTC", rustc_path()) + // We want to disallow all nightly features to simulate a stable build + .env("RUSTFLAGS", "-Zallow-features=") .arg("build") .arg("--manifest-path") .arg(source_root().join("Cargo.toml")) .args(&[ "--config", r#"workspace.exclude=["library/core"]"#, - // We want to disallow all nightly features, to simulate a stable build - // public-dependency needs to be enabled for cargo to work - "-Zallow-features=public-dependency", // Avoid depending on transitive rustc crates "--no-default-features", // Emit artifacts in this temporary directory, not in the source_root's `target` From 057703593c9744619787f1fe93b01059247ebb2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Sun, 25 Aug 2024 10:59:38 +0000 Subject: [PATCH 08/17] separate the crates to test from the test setup it'll be easier to see and update the list: the other cmd args can just be ignored --- tests/run-make/rustc-crates-on-stable/rmake.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/run-make/rustc-crates-on-stable/rmake.rs b/tests/run-make/rustc-crates-on-stable/rmake.rs index 513c128828725..48b8551ecef7c 100644 --- a/tests/run-make/rustc-crates-on-stable/rmake.rs +++ b/tests/run-make/rustc-crates-on-stable/rmake.rs @@ -25,7 +25,9 @@ fn main() { // folder "--target-dir", ".", - // Check that these crates can be compiled on "stable" + ]) + // Check that these crates can be compiled on "stable" + .args(&[ "-p", "rustc_type_ir", "-p", From f1df0c5fdc8fce70a36bbe283c7165223056d16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Sun, 25 Aug 2024 22:33:18 +0000 Subject: [PATCH 09/17] remove unneeded type ascription --- compiler/rustc_type_ir/src/elaborate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_type_ir/src/elaborate.rs b/compiler/rustc_type_ir/src/elaborate.rs index 433c444e701cc..f30419c801f18 100644 --- a/compiler/rustc_type_ir/src/elaborate.rs +++ b/compiler/rustc_type_ir/src/elaborate.rs @@ -237,7 +237,7 @@ pub fn supertrait_def_ids( cx: I, trait_def_id: I::DefId, ) -> impl Iterator { - let mut set: HashSet = HashSet::default(); + let mut set = HashSet::default(); let mut stack = vec![trait_def_id]; set.insert(trait_def_id); From 175238badb14beb04f6973da93fe9f883758ae7f Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 29 Aug 2024 20:49:39 -0400 Subject: [PATCH 10/17] Make decoding non-optional LazyArray panic if not set --- .../src/rmeta/decoder/cstore_impl.rs | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index a82340e3d6130..2ecad5096d5a1 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -71,8 +71,8 @@ impl<'a, 'tcx, T: Copy + Decodable>> ProcessQueryValue<' for Option> { #[inline(always)] - fn process_decoded(self, tcx: TyCtxt<'tcx>, _err: impl Fn() -> !) -> &'tcx [T] { - if let Some(iter) = self { tcx.arena.alloc_from_iter(iter) } else { &[] } + fn process_decoded(self, tcx: TyCtxt<'tcx>, err: impl Fn() -> !) -> &'tcx [T] { + if let Some(iter) = self { tcx.arena.alloc_from_iter(iter) } else { err() } } } @@ -84,12 +84,12 @@ impl<'a, 'tcx, T: Copy + Decodable>> fn process_decoded( self, tcx: TyCtxt<'tcx>, - _err: impl Fn() -> !, + err: impl Fn() -> !, ) -> ty::EarlyBinder<'tcx, &'tcx [T]> { ty::EarlyBinder::bind(if let Some(iter) = self { tcx.arena.alloc_from_iter(iter) } else { - &[] + err() }) } } @@ -301,7 +301,20 @@ provide! { tcx, def_id, other, cdata, .unwrap_or_else(|| panic!("{def_id:?} does not have eval_static_initializer"))) } trait_def => { table } - deduced_param_attrs => { table } + deduced_param_attrs => { + // FIXME: `deduced_param_attrs` has some sketchy encoding settings, + // where we don't encode unless we're optimizing, doing codegen, + // and not incremental (see `encoder.rs`). I don't think this is right! + cdata + .root + .tables + .deduced_param_attrs + .get(cdata, def_id.index) + .map(|lazy| { + &*tcx.arena.alloc_from_iter(lazy.decode((cdata, tcx))) + }) + .unwrap_or_default() + } is_type_alias_impl_trait => { debug_assert_eq!(tcx.def_kind(def_id), DefKind::OpaqueTy); cdata.root.tables.is_type_alias_impl_trait.get(cdata, def_id.index) From d30b5f00035bf55b18d576f9f2014e28e40f04bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Sun, 1 Sep 2024 12:21:04 +0000 Subject: [PATCH 11/17] update `object` dependency to deduplicate `wasmparser` --- Cargo.lock | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7244ae14fb8da..ce78d921244fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -199,7 +199,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01667f6f40216b9a0b2945e05fed5f1ad0ab6470e69cb9378001e37b1c0668e4" dependencies = [ - "object 0.36.3", + "object 0.36.4", ] [[package]] @@ -2453,9 +2453,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.3" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "crc32fast", "flate2", @@ -2463,7 +2463,7 @@ dependencies = [ "indexmap", "memchr", "ruzstd 0.7.0", - "wasmparser 0.215.0", + "wasmparser", ] [[package]] @@ -3129,11 +3129,11 @@ dependencies = [ "build_helper", "gimli 0.31.0", "libc", - "object 0.36.3", + "object 0.36.4", "regex", "serde_json", "similar", - "wasmparser 0.216.0", + "wasmparser", ] [[package]] @@ -3408,7 +3408,7 @@ dependencies = [ "itertools", "libc", "measureme", - "object 0.36.3", + "object 0.36.4", "rustc-demangle", "rustc_ast", "rustc_attr", @@ -3447,7 +3447,7 @@ dependencies = [ "itertools", "jobserver", "libc", - "object 0.36.3", + "object 0.36.4", "pathdiff", "regex", "rustc_arena", @@ -4431,7 +4431,7 @@ name = "rustc_target" version = "0.0.0" dependencies = [ "bitflags 2.6.0", - "object 0.36.3", + "object 0.36.4", "rustc_abi", "rustc_data_structures", "rustc_feature", @@ -5849,7 +5849,7 @@ dependencies = [ "lexopt", "tempfile", "wasi-preview1-component-adapter-provider", - "wasmparser 0.216.0", + "wasmparser", "wat", "wit-component", "wit-parser", @@ -5869,7 +5869,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04c23aebea22c8a75833ae08ed31ccc020835b12a41999e58c31464271b94a88" dependencies = [ "leb128", - "wasmparser 0.216.0", + "wasmparser", ] [[package]] @@ -5885,16 +5885,7 @@ dependencies = [ "serde_json", "spdx", "wasm-encoder", - "wasmparser 0.216.0", -] - -[[package]] -name = "wasmparser" -version = "0.215.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fbde0881f24199b81cf49b6ff8f9c145ac8eb1b7fc439adb5c099734f7d90e" -dependencies = [ - "bitflags 2.6.0", + "wasmparser", ] [[package]] @@ -6228,7 +6219,7 @@ dependencies = [ "serde_json", "wasm-encoder", "wasm-metadata", - "wasmparser 0.216.0", + "wasmparser", "wit-parser", ] @@ -6247,7 +6238,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.216.0", + "wasmparser", ] [[package]] From 5780c1ca5ec96036ab579da6c245d62b34491237 Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Mon, 2 Sep 2024 07:33:41 +0200 Subject: [PATCH 12/17] chore: Fix typos in 'compiler' (batch 3) --- compiler/rustc_symbol_mangling/src/hashed.rs | 2 +- compiler/rustc_target/src/abi/call/xtensa.rs | 2 +- compiler/rustc_target/src/spec/base/windows_msvc.rs | 2 +- compiler/rustc_target/src/spec/mod.rs | 2 +- compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs | 2 +- .../src/error_reporting/traits/fulfillment_errors.rs | 4 ++-- .../src/error_reporting/traits/on_unimplemented.rs | 6 +++--- .../src/error_reporting/traits/suggestions.rs | 2 +- compiler/rustc_trait_selection/src/traits/coherence.rs | 2 +- compiler/rustc_trait_selection/src/traits/fulfill.rs | 2 +- compiler/rustc_trait_selection/src/traits/select/mod.rs | 2 +- compiler/rustc_transmute/src/maybe_transmutable/mod.rs | 2 +- compiler/rustc_type_ir/src/binder.rs | 2 +- compiler/rustc_type_ir/src/inherent.rs | 2 +- compiler/rustc_type_ir/src/relate.rs | 2 +- compiler/rustc_type_ir/src/solve/mod.rs | 2 +- compiler/stable_mir/src/abi.rs | 2 +- compiler/stable_mir/src/ty.rs | 2 +- 18 files changed, 21 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_symbol_mangling/src/hashed.rs b/compiler/rustc_symbol_mangling/src/hashed.rs index 8e2f94991cf90..07c5f54479232 100644 --- a/compiler/rustc_symbol_mangling/src/hashed.rs +++ b/compiler/rustc_symbol_mangling/src/hashed.rs @@ -14,7 +14,7 @@ pub(super) fn mangle<'tcx>( ) -> String { // The symbol of a generic function may be scattered in multiple downstream dylibs. // If the symbol of a generic function still contains `crate name`, hash conflicts between the - // generic funcion and other symbols of the same `crate` cannot be detected in time during + // generic function and other symbols of the same `crate` cannot be detected in time during // construction. This symbol conflict is left over until it occurs during run time. // In this case, `instantiating-crate name` is used to replace `crate name` can completely // eliminate the risk of the preceding potential hash conflict. diff --git a/compiler/rustc_target/src/abi/call/xtensa.rs b/compiler/rustc_target/src/abi/call/xtensa.rs index addbe6989254c..0994ff4798805 100644 --- a/compiler/rustc_target/src/abi/call/xtensa.rs +++ b/compiler/rustc_target/src/abi/call/xtensa.rs @@ -26,7 +26,7 @@ where // so defer to `classify_arg_ty`. let mut arg_gprs_left = NUM_RET_GPRS; classify_arg_ty(arg, &mut arg_gprs_left, MAX_RET_IN_REGS_SIZE); - // Ret args cannot be passed via stack, we lower to indirect and let the backend handle the invisble reference + // Ret args cannot be passed via stack, we lower to indirect and let the backend handle the invisible reference match arg.mode { super::PassMode::Indirect { attrs: _, meta_attrs: _, ref mut on_stack } => { *on_stack = false; diff --git a/compiler/rustc_target/src/spec/base/windows_msvc.rs b/compiler/rustc_target/src/spec/base/windows_msvc.rs index bd0318f31832a..6f886ec8a250f 100644 --- a/compiler/rustc_target/src/spec/base/windows_msvc.rs +++ b/compiler/rustc_target/src/spec/base/windows_msvc.rs @@ -29,7 +29,7 @@ pub fn opts() -> TargetOptions { // they bring in. // // See also https://learn.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=msvc-170#lib - // for documention on including library dependencies in C/C++ code. + // for documentation on including library dependencies in C/C++ code. no_default_libraries: false, has_thread_local: true, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index d5f227a84a4ca..a7305ca05626a 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2148,7 +2148,7 @@ pub struct TargetOptions { pub is_like_aix: bool, /// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS, /// in particular running dsymutil and some other stuff like `-dead_strip`. Defaults to false. - /// Also indiates whether to use Apple-specific ABI changes, such as extending function + /// Also indicates whether to use Apple-specific ABI changes, such as extending function /// parameters to 32-bits. pub is_like_osx: bool, /// Whether the target toolchain is like Solaris's. diff --git a/compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs b/compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs index 489bae4fedf17..1a2533ecd7475 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs @@ -53,7 +53,7 @@ pub fn target() -> Target { options.entry_name = "__main_void".into(); // Default to PIC unlike base wasm. This makes precompiled objects such as - // the standard library more suitable to be used with shared libaries a la + // the standard library more suitable to be used with shared libraries a la // emscripten's dynamic linking convention. options.relocation_model = RelocModel::Pic; diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 3fdfca50dceba..de93434bd6011 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -170,7 +170,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { { return guar; } - // Silence redundant errors on binding acccess that are already + // Silence redundant errors on binding access that are already // reported on the binding definition (#56607). if let Err(guar) = self.fn_arg_obligation(&obligation) { return guar; @@ -900,7 +900,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let mut suggested = false; let mut chain = vec![]; - // The following logic is simlar to `point_at_chain`, but that's focused on associated types + // The following logic is similar to `point_at_chain`, but that's focused on associated types let mut expr = expr; while let hir::ExprKind::MethodCall(path_segment, rcvr_expr, args, span) = expr.kind { // Point at every method call in the chain with the `Result` type. diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs index efbc2695fd95e..41b0ee56a4cb5 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs @@ -878,7 +878,7 @@ impl<'tcx> OnUnimplementedFormatString { } } // we cannot return errors from processing the format string as hard error here - // as the diagnostic namespace gurantees that malformed input cannot cause an error + // as the diagnostic namespace guarantees that malformed input cannot cause an error // // if we encounter any error while processing we nevertheless want to show it as warning // so that users are aware that something is not correct @@ -986,10 +986,10 @@ impl<'tcx> OnUnimplementedFormatString { }) .collect(); // we cannot return errors from processing the format string as hard error here - // as the diagnostic namespace gurantees that malformed input cannot cause an error + // as the diagnostic namespace guarantees that malformed input cannot cause an error // // if we encounter any error while processing the format string - // we don't want to show the potentially half assembled formated string, + // we don't want to show the potentially half assembled formatted string, // therefore we fall back to just showing the input string in this case // // The actual parser errors are emitted earlier diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index f2c457aa377fb..5c663e0bf4b5b 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -4663,7 +4663,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // because this suggest adding both return type in // the `FnSig` and a default return value in the body, so it // is not suitable for foreign function without a local body, - // and neighter for trait method which may be also implemented + // and neither for trait method which may be also implemented // in other place, so shouldn't change it's FnSig. fn choose_suggest_items<'tcx, 'hir>( tcx: TyCtxt<'tcx>, diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index bf4b0482081d9..4acbca994aaa3 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -723,7 +723,7 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for AmbiguityCausesVisitor<'a, 'tcx> { // FIXME: While this matches the behavior of the // old solver, it is not the only way in which the unknowable // candidates *weaken* coherence, they can also force otherwise - // sucessful normalization to be ambiguous. + // successful normalization to be ambiguous. Ok(Certainty::Maybe(_) | Certainty::Yes) => { ambiguity_cause = None; break; diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index f72ae94fffc7a..16ba06f8667ff 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -472,7 +472,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> { }; match infcx.at(&obligation.cause, obligation.param_env).eq( - // Only really excercised by generic_const_exprs + // Only really exercised by generic_const_exprs DefineOpaqueTypes::Yes, ct_ty, ty, diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 91fe19c20f77b..12497e32b2db4 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -991,7 +991,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { }; match self.infcx.at(&obligation.cause, obligation.param_env).eq( - // Only really excercised by generic_const_exprs + // Only really exercised by generic_const_exprs DefineOpaqueTypes::Yes, ct_ty, ty, diff --git a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs index 2762b4e638405..a76ef7f0d189b 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs @@ -242,7 +242,7 @@ where // } // ...if `refs_answer` was computed lazily. The below early // returns can be deleted without impacting the correctness of - // the algoritm; only its performance. + // the algorithm; only its performance. debug!(?bytes_answer); match bytes_answer { Answer::No(_) if !self.assume.validity => return bytes_answer, diff --git a/compiler/rustc_type_ir/src/binder.rs b/compiler/rustc_type_ir/src/binder.rs index d42efbc91e196..f20beb797500e 100644 --- a/compiler/rustc_type_ir/src/binder.rs +++ b/compiler/rustc_type_ir/src/binder.rs @@ -776,7 +776,7 @@ impl<'a, I: Interner> ArgFolder<'a, I> { } /// It is sometimes necessary to adjust the De Bruijn indices during instantiation. This occurs - /// when we are instantating a type with escaping bound vars into a context where we have + /// when we are instantiating a type with escaping bound vars into a context where we have /// passed through binders. That's quite a mouthful. Let's see an example: /// /// ``` diff --git a/compiler/rustc_type_ir/src/inherent.rs b/compiler/rustc_type_ir/src/inherent.rs index 958360faede57..59a83ea5412d5 100644 --- a/compiler/rustc_type_ir/src/inherent.rs +++ b/compiler/rustc_type_ir/src/inherent.rs @@ -162,7 +162,7 @@ pub trait Ty>: /// Returns `true` when the outermost type cannot be further normalized, /// resolved, or instantiated. This includes all primitive types, but also - /// things like ADTs and trait objects, sice even if their arguments or + /// things like ADTs and trait objects, since even if their arguments or /// nested types may be further simplified, the outermost [`ty::TyKind`] or /// type constructor remains the same. fn is_known_rigid(self) -> bool { diff --git a/compiler/rustc_type_ir/src/relate.rs b/compiler/rustc_type_ir/src/relate.rs index 578436b622a87..9c725f34d8e5b 100644 --- a/compiler/rustc_type_ir/src/relate.rs +++ b/compiler/rustc_type_ir/src/relate.rs @@ -550,7 +550,7 @@ pub fn structurally_relate_tys>( /// Any semantic equality, e.g. of unevaluated consts, and inference variables have /// to be handled by the caller. /// -/// FIXME: This is not totally structual, which probably should be fixed. +/// FIXME: This is not totally structural, which probably should be fixed. /// See the HACKs below. pub fn structurally_relate_consts>( relation: &mut R, diff --git a/compiler/rustc_type_ir/src/solve/mod.rs b/compiler/rustc_type_ir/src/solve/mod.rs index 00fc6ba1c5c8f..96c939a898bd9 100644 --- a/compiler/rustc_type_ir/src/solve/mod.rs +++ b/compiler/rustc_type_ir/src/solve/mod.rs @@ -132,7 +132,7 @@ pub enum GoalSource { /// results in better error messages by avoiding spurious errors. /// We do not erase overflow constraints in `normalizes-to` goals unless /// they are from an impl where-clause. This is necessary due to - /// backwards compatability, cc trait-system-refactor-initiatitive#70. + /// backwards compatibility, cc trait-system-refactor-initiatitive#70. ImplWhereBound, /// Instantiating a higher-ranked goal and re-proving it. InstantiateHigherRanked, diff --git a/compiler/stable_mir/src/abi.rs b/compiler/stable_mir/src/abi.rs index 9d3b40e5eea7b..317bec3050c74 100644 --- a/compiler/stable_mir/src/abi.rs +++ b/compiler/stable_mir/src/abi.rs @@ -70,7 +70,7 @@ pub struct TyAndLayout { /// The layout of a type in memory. #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)] pub struct LayoutShape { - /// The fields location withing the layout + /// The fields location within the layout pub fields: FieldsShape, /// Encodes information about multi-variant layouts. diff --git a/compiler/stable_mir/src/ty.rs b/compiler/stable_mir/src/ty.rs index 2f36aa5182965..5bad3d5ae7a3c 100644 --- a/compiler/stable_mir/src/ty.rs +++ b/compiler/stable_mir/src/ty.rs @@ -267,7 +267,7 @@ impl Span { with(|c| c.get_filename(self)) } - /// Return lines that corespond to this `Span` + /// Return lines that correspond to this `Span` pub fn get_lines(&self) -> LineInfo { with(|c| c.get_lines(self)) } From ac69544a175d692dd623fb854261ca64b1b9b802 Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Mon, 2 Sep 2024 07:42:38 +0200 Subject: [PATCH 13/17] chore: Fix typos in 'compiler' (batch 1) --- compiler/rustc_ast_lowering/src/delegation.rs | 4 ++-- .../rustc_borrowck/src/diagnostics/conflict_errors.rs | 2 +- compiler/rustc_borrowck/src/type_check/liveness/trace.rs | 2 +- compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs | 2 +- compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs | 2 +- compiler/rustc_const_eval/src/interpret/call.rs | 4 ++-- compiler/rustc_const_eval/src/interpret/eval_context.rs | 2 +- compiler/rustc_const_eval/src/interpret/memory.rs | 2 +- compiler/rustc_const_eval/src/interpret/place.rs | 2 +- compiler/rustc_const_eval/src/interpret/stack.rs | 2 +- compiler/rustc_data_structures/src/base_n.rs | 2 +- compiler/rustc_data_structures/src/graph/scc/mod.rs | 2 +- compiler/rustc_data_structures/src/hashes.rs | 4 ++-- compiler/rustc_data_structures/src/sync/worker_local.rs | 8 ++++---- compiler/rustc_error_codes/src/error_codes/E0582.md | 2 +- compiler/rustc_errors/src/diagnostic.rs | 2 +- compiler/rustc_errors/src/emitter.rs | 2 +- compiler/rustc_errors/src/lib.rs | 2 +- compiler/rustc_errors/src/markdown/parse.rs | 2 +- compiler/rustc_feature/src/unstable.rs | 2 +- compiler/rustc_hir_analysis/src/check/wfcheck.rs | 2 +- compiler/rustc_hir_analysis/src/coherence/builtin.rs | 2 +- compiler/rustc_hir_analysis/src/collect.rs | 4 ++-- compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs | 2 +- compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs | 2 +- compiler/rustc_hir_typeck/src/cast.rs | 2 +- compiler/rustc_hir_typeck/src/method/confirm.rs | 6 +++--- compiler/rustc_hir_typeck/src/upvar.rs | 2 +- compiler/rustc_infer/src/infer/canonical/canonicalizer.rs | 2 +- compiler/rustc_infer/src/infer/opaque_types/mod.rs | 2 +- compiler/rustc_infer/src/infer/relate/combine.rs | 2 +- compiler/rustc_infer/src/infer/relate/generalize.rs | 2 +- compiler/rustc_interface/src/passes.rs | 2 +- compiler/rustc_lint/src/non_local_def.rs | 2 +- compiler/rustc_lint/src/unused.rs | 2 +- 35 files changed, 44 insertions(+), 44 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index 800773482041a..ac527df474aff 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -72,7 +72,7 @@ impl<'hir> LoweringContext<'_, 'hir> { fn has_self(&self, def_id: DefId, span: Span) -> bool { if let Some(local_sig_id) = def_id.as_local() { // The value may be missing due to recursive delegation. - // Error will be emmited later during HIR ty lowering. + // Error will be emitted later during HIR ty lowering. self.resolver.delegation_fn_sigs.get(&local_sig_id).map_or(false, |sig| sig.has_self) } else { match self.tcx.def_kind(def_id) { @@ -139,7 +139,7 @@ impl<'hir> LoweringContext<'_, 'hir> { fn param_count(&self, sig_id: DefId) -> (usize, bool /*c_variadic*/) { if let Some(local_sig_id) = sig_id.as_local() { // Map may be filled incorrectly due to recursive delegation. - // Error will be emmited later during HIR ty lowering. + // Error will be emitted later during HIR ty lowering. match self.resolver.delegation_fn_sigs.get(&local_sig_id) { Some(sig) => (sig.param_count, sig.c_variadic), None => (0, false), diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 9951f9fcda69c..c817b6fac7134 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -1179,7 +1179,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { for field in &variant.fields { // In practice unless there are more than one field with the same type, we'll be // suggesting a single field at a type, because we don't aggregate multiple borrow - // checker errors involving the functional record update sytnax into a single one. + // checker errors involving the functional record update syntax into a single one. let field_ty = field.ty(self.infcx.tcx, args); let ident = field.ident(self.infcx.tcx); if field_ty == ty && fields.iter().all(|field| field.ident.name != ident.name) { diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs index de3ff8378bcc7..6186904e5fbb6 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs @@ -218,7 +218,7 @@ impl<'a, 'me, 'typeck, 'flow, 'tcx> LivenessResults<'a, 'me, 'typeck, 'flow, 'tc // This collect is more necessary than immediately apparent // because these facts go into `add_drop_live_facts_for()`, // which also writes to `all_facts`, and so this is genuinely - // a simulatneous overlapping mutable borrow. + // a simultaneous overlapping mutable borrow. // FIXME for future hackers: investigate whether this is // actually necessary; these facts come from Polonius // and probably maybe plausibly does not need to go back in. diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs index 069b62af5e748..b5acfabfde25e 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs @@ -422,7 +422,7 @@ fn prepare_usage_sets<'tcx>(tcx: TyCtxt<'tcx>) -> UsageSets<'tcx> { (instance.def_id(), body) }); - // Functions whose coverage statments were found inlined into other functions. + // Functions whose coverage statements were found inlined into other functions. let mut used_via_inlining = FxHashSet::default(); // Functions that were instrumented, but had all of their coverage statements // removed by later MIR transforms (e.g. UnreachablePropagation). diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index f0bc4354f9a75..5103b2f31582b 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -701,7 +701,7 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S match ty.kind() { ty::Int(ity) => { // FIXME: directly extract the bits from a valtree instead of evaluating an - // alreay evaluated `Const` in order to get the bits. + // already evaluated `Const` in order to get the bits. let bits = ct.eval_bits(tcx, ty::ParamEnv::reveal_all()); let val = Integer::from_int_ty(&tcx, *ity).size().sign_extend(bits) as i128; write!(output, "{val}") diff --git a/compiler/rustc_const_eval/src/interpret/call.rs b/compiler/rustc_const_eval/src/interpret/call.rs index 61e8007e10ecf..82438eb5e7828 100644 --- a/compiler/rustc_const_eval/src/interpret/call.rs +++ b/compiler/rustc_const_eval/src/interpret/call.rs @@ -20,7 +20,7 @@ use super::{ }; use crate::fluent_generated as fluent; -/// An argment passed to a function. +/// An argument passed to a function. #[derive(Clone, Debug)] pub enum FnArg<'tcx, Prov: Provenance = CtfeProvenance> { /// Pass a copy of the given operand. @@ -123,7 +123,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { self.tcx.has_attr(def.did(), sym::rustc_nonnull_optimization_guaranteed) }; let inner = self.unfold_transparent(inner, /* may_unfold */ |def| { - // Stop at NPO tpyes so that we don't miss that attribute in the check below! + // Stop at NPO types so that we don't miss that attribute in the check below! def.is_struct() && !is_npo(def) }); Ok(match inner.ty.kind() { diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 7a6bbdfdcb5e5..dd744c51f23be 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -574,7 +574,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // be computed as the type references non-existing names. // See . } else { - // Looks like the const is not captued by `required_consts`, that's bad. + // Looks like the const is not captured by `required_consts`, that's bad. span_bug!(span, "interpret const eval failure of {val:?} which is not in required_consts"); } } diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index 97326fe99a21a..45a5eb9bd52fc 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -827,7 +827,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let (size, align) = if nested { // Nested anonymous statics are untyped, so let's get their - // size and alignment from the allocaiton itself. This always + // size and alignment from the allocation itself. This always // succeeds, as the query is fed at DefId creation time, so no // evaluation actually occurs. let alloc = self.tcx.eval_static_initializer(def_id).unwrap(); diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index ede6a51c712b9..d7d033e516295 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -186,7 +186,7 @@ pub(super) enum Place { /// `Local` places always refer to the current stack frame, so they are unstable under /// function calls/returns and switching betweens stacks of different threads! /// We carry around the address of the `locals` buffer of the correct stack frame as a sanity - /// chec to be able to catch some cases of using a dangling `Place`. + /// check to be able to catch some cases of using a dangling `Place`. /// /// This variant shall not be used for unsized types -- those must always live in memory. Local { local: mir::Local, offset: Option, locals_addr: usize }, diff --git a/compiler/rustc_const_eval/src/interpret/stack.rs b/compiler/rustc_const_eval/src/interpret/stack.rs index 0f6bf5c03364c..b6e83715e3989 100644 --- a/compiler/rustc_const_eval/src/interpret/stack.rs +++ b/compiler/rustc_const_eval/src/interpret/stack.rs @@ -1,5 +1,5 @@ //! Manages the low-level pushing and popping of stack frames and the (de)allocation of local variables. -//! For hadling of argument passing and return values, see the `call` module. +//! For handling of argument passing and return values, see the `call` module. use std::cell::Cell; use std::{fmt, mem}; diff --git a/compiler/rustc_data_structures/src/base_n.rs b/compiler/rustc_data_structures/src/base_n.rs index 1c2321623e491..0c3d7613d4f1f 100644 --- a/compiler/rustc_data_structures/src/base_n.rs +++ b/compiler/rustc_data_structures/src/base_n.rs @@ -42,7 +42,7 @@ impl fmt::Display for BaseNString { } // This trait just lets us reserve the exact right amount of space when doing fixed-length -// case-insensitve encoding. Add any impls you need. +// case-insensitive encoding. Add any impls you need. pub trait ToBaseN: Into { fn encoded_len(base: usize) -> usize; diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs index 2a457ffb70b08..06fedef00fc3f 100644 --- a/compiler/rustc_data_structures/src/graph/scc/mod.rs +++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs @@ -477,7 +477,7 @@ where // will know when we hit the state where previous_node == node. loop { // Back at the beginning, we can return. Note that we return the root state. - // This is becuse for components being explored, we would otherwise get a + // This is because for components being explored, we would otherwise get a // `node_state[n] = InCycleWith{ parent: n }` and that's wrong. if previous_node == node { return root_state; diff --git a/compiler/rustc_data_structures/src/hashes.rs b/compiler/rustc_data_structures/src/hashes.rs index f98c8de1eb097..8f4639fc2e666 100644 --- a/compiler/rustc_data_structures/src/hashes.rs +++ b/compiler/rustc_data_structures/src/hashes.rs @@ -3,11 +3,11 @@ //! or 16 bytes of the hash. //! //! The types in this module represent 64-bit or 128-bit hashes produced by a `StableHasher`. -//! `Hash64` and `Hash128` expose some utilty functions to encourage users to not extract the inner +//! `Hash64` and `Hash128` expose some utility functions to encourage users to not extract the inner //! hash value as an integer type and accidentally apply varint encoding to it. //! //! In contrast with `Fingerprint`, users of these types cannot and should not attempt to construct -//! and decompose these types into constitutent pieces. The point of these types is only to +//! and decompose these types into constituent pieces. The point of these types is only to //! connect the fact that they can only be produced by a `StableHasher` to their //! `Encode`/`Decode` impls. diff --git a/compiler/rustc_data_structures/src/sync/worker_local.rs b/compiler/rustc_data_structures/src/sync/worker_local.rs index 4950481d311f0..b6efcada10b77 100644 --- a/compiler/rustc_data_structures/src/sync/worker_local.rs +++ b/compiler/rustc_data_structures/src/sync/worker_local.rs @@ -19,7 +19,7 @@ impl RegistryId { /// index within the registry. This panics if the current thread is not associated with this /// registry. /// - /// Note that there's a race possible where the identifer in `THREAD_DATA` could be reused + /// Note that there's a race possible where the identifier in `THREAD_DATA` could be reused /// so this can succeed from a different registry. #[cfg(parallel_compiler)] fn verify(self) -> usize { @@ -50,7 +50,7 @@ struct ThreadData { } thread_local! { - /// A thread local which contains the identifer of `REGISTRY` but allows for faster access. + /// A thread local which contains the identifier of `REGISTRY` but allows for faster access. /// It also holds the index of the current thread. static THREAD_DATA: ThreadData = const { ThreadData { registry_id: Cell::new(RegistryId(ptr::null())), @@ -66,7 +66,7 @@ impl Registry { /// Gets the registry associated with the current thread. Panics if there's no such registry. pub fn current() -> Self { - REGISTRY.with(|registry| registry.get().cloned().expect("No assocated registry")) + REGISTRY.with(|registry| registry.get().cloned().expect("No associated registry")) } /// Registers the current thread with the registry so worker locals can be used on it. @@ -92,7 +92,7 @@ impl Registry { } } - /// Gets the identifer of this registry. + /// Gets the identifier of this registry. fn id(&self) -> RegistryId { RegistryId(&*self.0) } diff --git a/compiler/rustc_error_codes/src/error_codes/E0582.md b/compiler/rustc_error_codes/src/error_codes/E0582.md index b2cdb509c95c0..c4aaa17706add 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0582.md +++ b/compiler/rustc_error_codes/src/error_codes/E0582.md @@ -44,7 +44,7 @@ where ``` The latter scenario encounters this error because `Foo::Assoc<'a>` could be implemented by a type that does not use the `'a` parameter, so there is no -guarentee that `X::Assoc<'a>` actually uses `'a`. +guarantee that `X::Assoc<'a>` actually uses `'a`. To fix this we can pass a dummy parameter: ``` diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 3303e4ee752c2..41a94cc2b6fde 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -484,7 +484,7 @@ pub struct Subdiag { /// - The `EmissionGuarantee`, which determines the type returned from `emit`. /// /// Each constructed `Diag` must be consumed by a function such as `emit`, -/// `cancel`, `delay_as_bug`, or `into_diag`. A panic occurrs if a `Diag` +/// `cancel`, `delay_as_bug`, or `into_diag`. A panic occurs if a `Diag` /// is dropped without being consumed by one of these functions. /// /// If there is some state in a downstream crate you would like to access in diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 2bc29dabd18a1..2b135df91a4bb 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -2300,7 +2300,7 @@ impl HumanEmitter { // For example, for the following: // | // 2 - .await - // 2 + (note the left over whitepsace) + // 2 + (note the left over whitespace) // | // We really want // | diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 99ee8fb17d7dc..27f9e2249b337 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -817,7 +817,7 @@ impl<'a> DiagCtxtHandle<'a> { ); } // We delay a bug here so that `-Ztreat-err-as-bug -Zeagerly-emit-delayed-bugs` - // can be used to create a backtrace at the stashing site insted of whenever the + // can be used to create a backtrace at the stashing site instead of whenever the // diagnostic context is dropped and thus delayed bugs are emitted. Error => Some(self.span_delayed_bug(span, format!("stashing {key:?}"))), DelayedBug => { diff --git a/compiler/rustc_errors/src/markdown/parse.rs b/compiler/rustc_errors/src/markdown/parse.rs index b1db44dd215b8..8dd146c1c337f 100644 --- a/compiler/rustc_errors/src/markdown/parse.rs +++ b/compiler/rustc_errors/src/markdown/parse.rs @@ -487,7 +487,7 @@ fn is_break_ty(val: &MdTree<'_>) -> bool { || matches!(val, MdTree::PlainText(txt) if txt.trim().is_empty()) } -/// Perform tranformations to text. This splits paragraphs, replaces patterns, +/// Perform transformations to text. This splits paragraphs, replaces patterns, /// and corrects newlines. /// /// To avoid allocating strings (and using a different heavier tt type), our diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 7ea037ca8b2b6..64dd2cbb9894f 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -585,7 +585,7 @@ declare_features! ( (unstable, rust_cold_cc, "1.63.0", Some(97544)), /// Allows use of x86 SHA512, SM3 and SM4 target-features and intrinsics (unstable, sha512_sm_x86, "CURRENT_RUSTC_VERSION", Some(126624)), - /// Shortern the tail expression lifetime + /// Shorten the tail expression lifetime (unstable, shorter_tail_lifetimes, "1.79.0", Some(123739)), /// Allows the use of SIMD types in functions declared in `extern` blocks. (unstable, simd_ffi, "1.0.0", Some(27731)), diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 359b4729e50a6..f83eac7cd6c4d 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1016,7 +1016,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(), sym::adt_const_params, )]) } - // Implments `ConstParamTy`, suggest adding the feature to enable. + // Implements `ConstParamTy`, suggest adding the feature to enable. Ok(..) => Some(vec![(adt_const_params_feature_string, sym::adt_const_params)]), }; if let Some(features) = may_suggest_feature { diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs index 9f01f7be80af4..30fc06829ed8e 100644 --- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs +++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs @@ -219,7 +219,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<() // Later parts of the compiler rely on all DispatchFromDyn types to be ABI-compatible with raw // pointers. This is enforced here: we only allow impls for references, raw pointers, and things // that are effectively repr(transparent) newtypes around types that already hav a - // DispatchedFromDyn impl. We cannot literally use repr(transparent) on those tpyes since some + // DispatchedFromDyn impl. We cannot literally use repr(transparent) on those types since some // of them support an allocator, but we ensure that for the cases where the type implements this // trait, they *do* satisfy the repr(transparent) rules, and then we assume that everything else // in the compiler (in particular, all the call ABI logic) will treat them as repr(transparent) diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 53105f337c4a8..92111805ab422 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -1037,7 +1037,7 @@ impl<'tcx> FieldUniquenessCheckContext<'tcx> { /// Check the uniqueness of fields in a struct variant, and recursively /// check the nested fields if it is an unnamed field with type of an - /// annoymous adt. + /// anonymous adt. fn check_field(&mut self, field: &hir::FieldDef<'_>) { if field.ident.name != kw::Underscore { self.check_field_decl(field.ident, field.span.into()); @@ -1491,7 +1491,7 @@ fn infer_return_ty_for_fn_sig<'tcx>( Some(ty) => { let fn_sig = tcx.typeck(def_id).liberated_fn_sigs()[hir_id]; // Typeck doesn't expect erased regions to be returned from `type_of`. - // This is a heuristic approach. If the scope has region paramters, + // This is a heuristic approach. If the scope has region parameters, // we should change fn_sig's lifetime from `ReErased` to `ReError`, // otherwise to `ReStatic`. let has_region_params = generics.params.iter().any(|param| match param.kind { diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs index 70a3c744c78a2..bffe68f9b745f 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs @@ -529,7 +529,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { /// Detect and reject early-bound & escaping late-bound generic params in the type of assoc const bindings. /// -/// FIXME(const_generics): This is a temporary and semi-artifical restriction until the +/// FIXME(const_generics): This is a temporary and semi-artificial restriction until the /// arrival of *generic const generics*[^1]. /// /// It might actually be possible that we can already support early-bound generic params diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 36c26f91089c3..ac5bd825b18dd 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -986,7 +986,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { /// We **don't** support paths whose self type is an arbitrary type like `Struct::Ty` where /// struct `Struct` impls an in-scope trait that defines an associated type called `Ty`. /// For the latter case, we report ambiguity. - /// While desirable to support, the implemention would be non-trivial. Tracked in [#22519]. + /// While desirable to support, the implementation would be non-trivial. Tracked in [#22519]. /// /// At the time of writing, *inherent associated types* are also resolved here. This however /// is [problematic][iat]. A proper implementation would be as non-trivial as the one diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index 1db2c865b4077..1e1e007862e1c 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -650,7 +650,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { // cannot distinguish. This would cause us to erroneously discard a cast which will // lead to a borrowck error like #113257. // We still did a coercion above to unify inference variables for `ptr as _` casts. - // This does cause us to miss some trivial casts in the trival cast lint. + // This does cause us to miss some trivial casts in the trivial cast lint. debug!(" -> PointerCast"); } else { self.trivial_cast_lint(fcx); diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index faeabdc082109..10a22eee7b74a 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -249,7 +249,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { } /// Returns a set of generic parameters for the method *receiver* where all type and region - /// parameters are instantiated with fresh variables. This generic paramters does not include any + /// parameters are instantiated with fresh variables. This generic parameters does not include any /// parameters declared on the method itself. /// /// Note that this generic parameters may include late-bound regions from the impl level. If so, @@ -375,7 +375,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { IsMethodCall::Yes, ); - // Create generic paramters for early-bound lifetime parameters, + // Create generic parameters for early-bound lifetime parameters, // combining parameters from the type and those from the method. assert_eq!(generics.parent_count, parent_args.len()); @@ -546,7 +546,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { debug!("instantiate_method_sig(pick={:?}, all_args={:?})", pick, all_args); // Instantiate the bounds on the method with the - // type/early-bound-regions instatiations performed. There can + // type/early-bound-regions instantiations performed. There can // be no late-bound regions appearing here. let def_id = pick.item.def_id; let method_predicates = self.tcx.predicates_of(def_id).instantiate(self.tcx, all_args); diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 986453397ffcc..5789e60ebbebe 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -228,7 +228,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // coroutine bodies can't borrow from their parent closure. To fix this, // we force the inner coroutine to also be `move`. This only matters for // coroutine-closures that are `move` since otherwise they themselves will - // be borrowing from the outer environment, so there's no self-borrows occuring. + // be borrowing from the outer environment, so there's no self-borrows occurring. if let UpvarArgs::Coroutine(..) = args && let hir::CoroutineKind::Desugared(_, hir::CoroutineSource::Closure) = self.tcx.coroutine_kind(closure_def_id).expect("coroutine should have kind") diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index 9d77afa5d2f03..1930e357fc9cc 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -51,7 +51,7 @@ impl<'tcx> InferCtxt<'tcx> { query_state, |tcx, param_env, query_state| { // FIXME(#118965): We don't canonicalize the static lifetimes that appear in the - // `param_env` beacause they are treated differently by trait selection. + // `param_env` because they are treated differently by trait selection. Canonicalizer::canonicalize( param_env, None, diff --git a/compiler/rustc_infer/src/infer/opaque_types/mod.rs b/compiler/rustc_infer/src/infer/opaque_types/mod.rs index 88db7237647cd..5ceaaf1a3c4fe 100644 --- a/compiler/rustc_infer/src/infer/opaque_types/mod.rs +++ b/compiler/rustc_infer/src/infer/opaque_types/mod.rs @@ -213,7 +213,7 @@ impl<'tcx> InferCtxt<'tcx> { /// ``` /// /// As indicating in the comments above, each of those references - /// is (in the compiler) basically generic paramters (`args`) + /// is (in the compiler) basically generic parameters (`args`) /// applied to the type of a suitable `def_id` (which identifies /// `Foo1` or `Foo2`). /// diff --git a/compiler/rustc_infer/src/infer/relate/combine.rs b/compiler/rustc_infer/src/infer/relate/combine.rs index 70b59322f5bee..f2ec1dd3df74a 100644 --- a/compiler/rustc_infer/src/infer/relate/combine.rs +++ b/compiler/rustc_infer/src/infer/relate/combine.rs @@ -153,7 +153,7 @@ impl<'tcx> InferCtxt<'tcx> { // During coherence, opaque types should be treated as *possibly* // equal to any other type (except for possibly itself). This is an - // extremely heavy hammer, but can be relaxed in a fowards-compatible + // extremely heavy hammer, but can be relaxed in a forwards-compatible // way later. (&ty::Alias(ty::Opaque, _), _) | (_, &ty::Alias(ty::Opaque, _)) if self.intercrate => { relation.register_predicates([ty::Binder::dummy(ty::PredicateKind::Ambiguous)]); diff --git a/compiler/rustc_infer/src/infer/relate/generalize.rs b/compiler/rustc_infer/src/infer/relate/generalize.rs index f257141ea6581..f2a511d7a886b 100644 --- a/compiler/rustc_infer/src/infer/relate/generalize.rs +++ b/compiler/rustc_infer/src/infer/relate/generalize.rs @@ -120,7 +120,7 @@ impl<'tcx> InferCtxt<'tcx> { } else { // NOTE: The `instantiation_variance` is not the same variance as // used by the relation. When instantiating `b`, `target_is_expected` - // is flipped and the `instantion_variance` is also flipped. To + // is flipped and the `instantiation_variance` is also flipped. To // constrain the `generalized_ty` while using the original relation, // we therefore only have to flip the arguments. // diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 779b98d073dab..c4a38047b5e3b 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -435,7 +435,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P escape_dep_filename(&file.prefer_local().to_string()) }; - // The entries will be used to declare dependencies beween files in a + // The entries will be used to declare dependencies between files in a // Makefile-like output, so the iteration order does not matter. #[allow(rustc::potential_query_instability)] let extra_tracked_files = diff --git a/compiler/rustc_lint/src/non_local_def.rs b/compiler/rustc_lint/src/non_local_def.rs index 13a3c741fe39b..1546d79e4fd91 100644 --- a/compiler/rustc_lint/src/non_local_def.rs +++ b/compiler/rustc_lint/src/non_local_def.rs @@ -126,7 +126,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions { // > same expression-containing item. // // To achieve this we get try to get the paths of the _Trait_ and - // _Type_, and we look inside thoses paths to try a find in one + // _Type_, and we look inside those paths to try a find in one // of them a type whose parent is the same as the impl definition. // // If that's the case this means that this impl block declaration diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index c3b80e01c3624..761d30bac715a 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -734,7 +734,7 @@ trait UnusedDelimLint { return false; } - // Check if we need parens for `match &( Struct { feild: }) {}`. + // Check if we need parens for `match &( Struct { field: }) {}`. { let mut innermost = inner; loop { From 00de006f22f2304bddabb2d00a13af242ea21c17 Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Mon, 2 Sep 2024 07:50:22 +0200 Subject: [PATCH 14/17] chore: Fix typos in 'compiler' (batch 2) --- .../src/context/diagnostics/check_cfg.rs | 2 +- compiler/rustc_middle/src/mir/consts.rs | 2 +- .../rustc_middle/src/mir/interpret/error.rs | 6 +++--- compiler/rustc_middle/src/query/mod.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 2 +- compiler/rustc_middle/src/ty/instance.rs | 2 +- compiler/rustc_middle/src/ty/mod.rs | 2 +- compiler/rustc_middle/src/ty/sty.rs | 2 +- .../src/dead_store_elimination.rs | 2 +- compiler/rustc_mir_transform/src/dest_prop.rs | 2 +- .../src/known_panics_lint.rs | 2 +- .../rustc_mir_transform/src/match_branches.rs | 20 +++++++++---------- .../rustc_mir_transform/src/promote_consts.rs | 2 +- compiler/rustc_mir_transform/src/ref_prop.rs | 2 +- compiler/rustc_monomorphize/src/collector.rs | 2 +- .../src/solve/eval_ctxt/canonical.rs | 2 +- .../rustc_next_trait_solver/src/solve/mod.rs | 2 +- .../src/solve/trait_goals.rs | 2 +- compiler/rustc_parse/src/parser/pat.rs | 2 +- compiler/rustc_passes/src/dead.rs | 4 ++-- .../rustc_pattern_analysis/src/constructor.rs | 2 +- .../tests/exhaustiveness.rs | 2 +- .../rustc_query_system/src/dep_graph/graph.rs | 2 +- compiler/rustc_resolve/messages.ftl | 2 +- compiler/rustc_resolve/src/errors.rs | 2 +- compiler/rustc_resolve/src/ident.rs | 2 +- compiler/rustc_resolve/src/late.rs | 4 ++-- compiler/rustc_resolve/src/rustdoc.rs | 2 +- .../cfi/typeid/itanium_cxx_abi/transform.rs | 6 +++--- compiler/rustc_serialize/src/opaque.rs | 2 +- compiler/rustc_session/src/config.rs | 10 +++++----- compiler/rustc_smir/src/rustc_internal/mod.rs | 2 +- compiler/rustc_span/src/hygiene.rs | 2 +- compiler/rustc_span/src/lib.rs | 4 ++-- 34 files changed, 54 insertions(+), 54 deletions(-) diff --git a/compiler/rustc_lint/src/context/diagnostics/check_cfg.rs b/compiler/rustc_lint/src/context/diagnostics/check_cfg.rs index fb3f40aa27108..ddaa819df1413 100644 --- a/compiler/rustc_lint/src/context/diagnostics/check_cfg.rs +++ b/compiler/rustc_lint/src/context/diagnostics/check_cfg.rs @@ -267,7 +267,7 @@ pub(super) fn unexpected_cfg_value( // encouraged to do so. let can_suggest_adding_value = !sess.psess.check_config.well_known_names.contains(&name) // Except when working on rustc or the standard library itself, in which case we want to - // suggest adding these cfgs to the "normal" place because of bootstraping reasons. As a + // suggest adding these cfgs to the "normal" place because of bootstrapping reasons. As a // basic heuristic, we use the "cheat" unstable feature enable method and the // non-ui-testing enabled option. || (matches!(sess.psess.unstable_features, rustc_feature::UnstableFeatures::Cheat) diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs index 563647ad4e678..c6105d1f383b1 100644 --- a/compiler/rustc_middle/src/mir/consts.rs +++ b/compiler/rustc_middle/src/mir/consts.rs @@ -240,7 +240,7 @@ impl<'tcx> Const<'tcx> { match self { Const::Ty(ty, ct) => { match ct.kind() { - // Dont use the outter ty as on invalid code we can wind up with them not being the same. + // Dont use the outer ty as on invalid code we can wind up with them not being the same. // this then results in allowing const eval to add `1_i64 + 1_usize` in cases where the mir // was originally `({N: usize} + 1_usize)` under `generic_const_exprs`. ty::ConstKind::Value(ty, _) => ty, diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index 69ce3e087350b..8c89c15f9611d 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -91,9 +91,9 @@ pub type EvalToAllocationRawResult<'tcx> = Result, ErrorHandled pub type EvalStaticInitializerRawResult<'tcx> = Result, ErrorHandled>; pub type EvalToConstValueResult<'tcx> = Result, ErrorHandled>; /// `Ok(Err(ty))` indicates the constant was fine, but the valtree couldn't be constructed -/// because the value containts something of type `ty` that is not valtree-compatible. +/// because the value contains something of type `ty` that is not valtree-compatible. /// The caller can then show an appropriate error; the query does not have the -/// necssary context to give good user-facing errors for this case. +/// necessary context to give good user-facing errors for this case. pub type EvalToValTreeResult<'tcx> = Result, Ty<'tcx>>, ErrorHandled>; #[cfg(target_pointer_width = "64")] @@ -231,7 +231,7 @@ pub enum CheckInAllocMsg { pub enum CheckAlignMsg { /// The accessed pointer did not have proper alignment. AccessedPtr, - /// The access ocurred with a place that was based on a misaligned pointer. + /// The access occurred with a place that was based on a misaligned pointer. BasedOn, } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index b6443778c936b..71b8cfcc46e3d 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -327,7 +327,7 @@ rustc_queries! { } } - /// Returns the list of bounds that are required to be satsified + /// Returns the list of bounds that are required to be satisfied /// by a implementation or definition. For associated types, these /// must be satisfied for an implementation to be well-formed, /// and for opaque types, these are required to be satisfied by diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 43dda252f835e..20828067c469c 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1475,7 +1475,7 @@ impl<'tcx> TyCtxt<'tcx> { /// provides a `TyCtxt`. /// /// By only providing the `TyCtxt` inside of the closure we enforce that the type - /// context and any interned alue (types, args, etc.) can only be used while `ty::tls` + /// context and any interned value (types, args, etc.) can only be used while `ty::tls` /// has a valid reference to the context, to allow formatting values that need it. pub fn create_global_ctxt( s: &'tcx Session, diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index 7d5f0f1e9c415..072951d131917 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -38,7 +38,7 @@ pub struct Instance<'tcx> { pub args: GenericArgsRef<'tcx>, } -/// Describes why a `ReifyShim` was created. This is needed to distingish a ReifyShim created to +/// Describes why a `ReifyShim` was created. This is needed to distinguish a ReifyShim created to /// adjust for things like `#[track_caller]` in a vtable from a `ReifyShim` created to produce a /// function pointer from a vtable entry. /// Currently, this is only used when KCFI is enabled, as only KCFI needs to treat those two diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index e41ea7507efff..cd94c0afad0a9 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1819,7 +1819,7 @@ impl<'tcx> TyCtxt<'tcx> { self.get_attrs(did, attr).next().is_some() } - /// Determines whether an item is annotated with a multi-segement attribute + /// Determines whether an item is annotated with a multi-segment attribute pub fn has_attrs_with_path(self, did: impl Into, attrs: &[Symbol]) -> bool { self.get_attrs_by_path(did.into(), attrs).next().is_some() } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index b144fd0feb00e..89ef30fa768e0 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1930,7 +1930,7 @@ impl<'tcx> Ty<'tcx> { /// Returns `true` when the outermost type cannot be further normalized, /// resolved, or instantiated. This includes all primitive types, but also - /// things like ADTs and trait objects, sice even if their arguments or + /// things like ADTs and trait objects, since even if their arguments or /// nested types may be further simplified, the outermost [`TyKind`] or /// type constructor remains the same. pub fn is_known_rigid(self) -> bool { diff --git a/compiler/rustc_mir_transform/src/dead_store_elimination.rs b/compiler/rustc_mir_transform/src/dead_store_elimination.rs index f473073083af4..39c8db184a5a2 100644 --- a/compiler/rustc_mir_transform/src/dead_store_elimination.rs +++ b/compiler/rustc_mir_transform/src/dead_store_elimination.rs @@ -32,7 +32,7 @@ pub fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let borrowed_locals = borrowed_locals(body); // If the user requests complete debuginfo, mark the locals that appear in it as live, so - // we don't remove assignements to them. + // we don't remove assignments to them. let mut always_live = debuginfo_locals(body); always_live.union(&borrowed_locals); diff --git a/compiler/rustc_mir_transform/src/dest_prop.rs b/compiler/rustc_mir_transform/src/dest_prop.rs index a530dccf96b27..a6d626d3f8ff5 100644 --- a/compiler/rustc_mir_transform/src/dest_prop.rs +++ b/compiler/rustc_mir_transform/src/dest_prop.rs @@ -38,7 +38,7 @@ //! not contain any indirection through a pointer or any indexing projections. //! //! * `p` and `q` must have the **same type**. If we replace a local with a subtype or supertype, -//! we may end up with a differnet vtable for that local. See the `subtyping-impacts-selection` +//! we may end up with a different vtable for that local. See the `subtyping-impacts-selection` //! tests for an example where that causes issues. //! //! * We need to make sure that the goal of "merging the memory" is actually structurally possible diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs index 443d97d004e16..15d71ee2ac81f 100644 --- a/compiler/rustc_mir_transform/src/known_panics_lint.rs +++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs @@ -914,7 +914,7 @@ impl<'tcx> Visitor<'tcx> for CanConstProp { fn visit_place(&mut self, place: &Place<'tcx>, mut context: PlaceContext, loc: Location) { use rustc_middle::mir::visit::PlaceContext::*; - // Dereferencing just read the addess of `place.local`. + // Dereferencing just read the address of `place.local`. if place.projection.first() == Some(&PlaceElem::Deref) { context = NonMutatingUse(NonMutatingUseContext::Copy); } diff --git a/compiler/rustc_mir_transform/src/match_branches.rs b/compiler/rustc_mir_transform/src/match_branches.rs index 47758b56f8c90..5240f1c887c5c 100644 --- a/compiler/rustc_mir_transform/src/match_branches.rs +++ b/compiler/rustc_mir_transform/src/match_branches.rs @@ -289,7 +289,7 @@ fn can_cast( #[derive(Default)] struct SimplifyToExp { - transfrom_kinds: Vec, + transform_kinds: Vec, } #[derive(Clone, Copy)] @@ -302,17 +302,17 @@ enum ExpectedTransformKind<'tcx, 'a> { Cast { place: &'a Place<'tcx>, ty: Ty<'tcx> }, } -enum TransfromKind { +enum TransformKind { Same, Cast, } -impl From> for TransfromKind { +impl From> for TransformKind { fn from(compare_type: ExpectedTransformKind<'_, '_>) -> Self { match compare_type { - ExpectedTransformKind::Same(_) => TransfromKind::Same, - ExpectedTransformKind::SameByEq { .. } => TransfromKind::Same, - ExpectedTransformKind::Cast { .. } => TransfromKind::Cast, + ExpectedTransformKind::Same(_) => TransformKind::Same, + ExpectedTransformKind::SameByEq { .. } => TransformKind::Same, + ExpectedTransformKind::Cast { .. } => TransformKind::Cast, } } } @@ -475,7 +475,7 @@ impl<'tcx> SimplifyMatch<'tcx> for SimplifyToExp { } } } - self.transfrom_kinds = expected_transform_kinds.into_iter().map(|c| c.into()).collect(); + self.transform_kinds = expected_transform_kinds.into_iter().map(|c| c.into()).collect(); Some(()) } @@ -493,13 +493,13 @@ impl<'tcx> SimplifyMatch<'tcx> for SimplifyToExp { let (_, first) = targets.iter().next().unwrap(); let first = &bbs[first]; - for (t, s) in iter::zip(&self.transfrom_kinds, &first.statements) { + for (t, s) in iter::zip(&self.transform_kinds, &first.statements) { match (t, &s.kind) { - (TransfromKind::Same, _) => { + (TransformKind::Same, _) => { patch.add_statement(parent_end, s.kind.clone()); } ( - TransfromKind::Cast, + TransformKind::Cast, StatementKind::Assign(box (lhs, Rvalue::Use(Operand::Constant(f_c)))), ) => { let operand = Operand::Copy(Place::from(discr_local)); diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs index f2610fd52bc12..0c940bac13c0b 100644 --- a/compiler/rustc_mir_transform/src/promote_consts.rs +++ b/compiler/rustc_mir_transform/src/promote_consts.rs @@ -498,7 +498,7 @@ impl<'tcx> Validator<'_, 'tcx> { Some(x) if x != 0 => {} // okay _ => return Err(Unpromotable), // value not known or 0 -- not okay } - // Furthermore, for signed divison, we also have to exclude `int::MIN / -1`. + // Furthermore, for signed division, we also have to exclude `int::MIN / -1`. if lhs_ty.is_signed() { match rhs_val.map(|x| x.to_int(sz)) { Some(-1) | None => { diff --git a/compiler/rustc_mir_transform/src/ref_prop.rs b/compiler/rustc_mir_transform/src/ref_prop.rs index 2b07c04a12130..8d0b47cb34a8f 100644 --- a/compiler/rustc_mir_transform/src/ref_prop.rs +++ b/compiler/rustc_mir_transform/src/ref_prop.rs @@ -345,7 +345,7 @@ fn fully_replacable_locals(ssa: &SsaLocals) -> BitSet { replacable } -/// Utility to help performing subtitution of `*pattern` by `target`. +/// Utility to help performing substitution of `*pattern` by `target`. struct Replacer<'tcx> { tcx: TyCtxt<'tcx>, targets: IndexVec>, diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 9c820b888d910..8515ab45de217 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -397,7 +397,7 @@ fn collect_items_rec<'tcx>( MonoItem::Static(def_id) => { recursion_depth_reset = None; - // Statics always get evaluted (which is possible because they can't be generic), so for + // Statics always get evaluated (which is possible because they can't be generic), so for // `MentionedItems` collection there's nothing to do here. if mode == CollectionMode::UsedItems { let instance = Instance::mono(tcx, def_id); diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs index 2e521ddcec322..1c00f5f8b4173 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs @@ -238,7 +238,7 @@ where (normalization_nested_goals.clone(), certainty) } - /// This returns the canoncial variable values to instantiate the bound variables of + /// This returns the canonical variable values to instantiate the bound variables of /// the canonical response. This depends on the `original_values` for the /// bound variables. fn compute_query_response_instantiation_values>( diff --git a/compiler/rustc_next_trait_solver/src/solve/mod.rs b/compiler/rustc_next_trait_solver/src/solve/mod.rs index c65c5851e9b4f..536b502136ad3 100644 --- a/compiler/rustc_next_trait_solver/src/solve/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/mod.rs @@ -164,7 +164,7 @@ where // - `Bound` cannot exist as we don't have a binder around the self Type // - `Expr` is part of `feature(generic_const_exprs)` and is not implemented yet ty::ConstKind::Param(_) | ty::ConstKind::Bound(_, _) | ty::ConstKind::Expr(_) => { - panic!("unexpect const kind: {:?}", ct) + panic!("unexpected const kind: {:?}", ct) } } } diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index 1314b7eb6ffc6..67b001d0cceda 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -628,7 +628,7 @@ where } // FIXME: This actually should destructure the `Result` we get from transmutability and - // register candiates. We probably need to register >1 since we may have an OR of ANDs. + // register candidates. We probably need to register >1 since we may have an OR of ANDs. ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc).enter(|ecx| { let certainty = ecx.is_transmutable( goal.param_env, diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 8233f9a79435f..f87b564965469 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -402,7 +402,7 @@ impl<'a> Parser<'a> { let non_assoc_span = expr.span; // Parse an associative expression such as `+ expr`, `% expr`, ... - // Assignements, ranges and `|` are disabled by [`Restrictions::IS_PAT`]. + // Assignments, ranges and `|` are disabled by [`Restrictions::IS_PAT`]. if let Ok((expr, _)) = snapshot.parse_expr_assoc_rest_with(0, false, expr).map_err(|err| err.cancel()) { diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 7ae5c9040042c..7f1e906ffd737 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -439,7 +439,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { _ => intravisit::walk_item(self, item), }, Node::TraitItem(trait_item) => { - // mark corresponing ImplTerm live + // mark corresponding ImplTerm live let trait_item_id = trait_item.owner_id.to_def_id(); if let Some(trait_id) = self.tcx.trait_of_item(trait_item_id) { // mark the trait live @@ -1035,7 +1035,7 @@ impl<'tcx> DeadVisitor<'tcx> { }; let encl_def_id = parent_item.unwrap_or(first_item.def_id); - // If parent of encl_def_id is an enum, use the parent ID intead. + // If parent of encl_def_id is an enum, use the parent ID instead. let encl_def_id = get_parent_if_enum_variant(tcx, encl_def_id); let ignored_derived_impls = diff --git a/compiler/rustc_pattern_analysis/src/constructor.rs b/compiler/rustc_pattern_analysis/src/constructor.rs index 3a2a75a638f79..e4edd7befb76f 100644 --- a/compiler/rustc_pattern_analysis/src/constructor.rs +++ b/compiler/rustc_pattern_analysis/src/constructor.rs @@ -288,7 +288,7 @@ impl IntRange { /// Best effort; will not know that e.g. `255u8..` is a singleton. pub fn is_singleton(&self) -> bool { // Since `lo` and `hi` can't be the same `Infinity` and `plus_one` never changes from finite - // to infinite, this correctly only detects ranges that contain exacly one `Finite(x)`. + // to infinite, this correctly only detects ranges that contain exactly one `Finite(x)`. self.lo.plus_one() == Some(self.hi) } diff --git a/compiler/rustc_pattern_analysis/tests/exhaustiveness.rs b/compiler/rustc_pattern_analysis/tests/exhaustiveness.rs index 2192940d4d716..af093db782cde 100644 --- a/compiler/rustc_pattern_analysis/tests/exhaustiveness.rs +++ b/compiler/rustc_pattern_analysis/tests/exhaustiveness.rs @@ -22,7 +22,7 @@ fn check(patterns: Vec>) -> Vec> { fn assert_exhaustive(patterns: Vec>) { let witnesses = check(patterns); if !witnesses.is_empty() { - panic!("non-exaustive match: missing {witnesses:?}"); + panic!("non-exhaustive match: missing {witnesses:?}"); } } diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index b6aa1d5a43bb8..eb3eddf34aa3e 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -1405,7 +1405,7 @@ fn panic_on_forbidden_read(data: &DepGraphData, dep_node_index: DepN "Error: trying to record dependency on DepNode {dep_node} in a \ context that does not allow it (e.g. during query deserialization). \ The most common case of recording a dependency on a DepNode `foo` is \ - when the correspondng query `foo` is invoked. Invoking queries is not \ + when the corresponding query `foo` is invoked. Invoking queries is not \ allowed as part of loading something from the incremental on-disk cache. \ See ." ) diff --git a/compiler/rustc_resolve/messages.ftl b/compiler/rustc_resolve/messages.ftl index 73d1a2ea49a13..6602c7889691f 100644 --- a/compiler/rustc_resolve/messages.ftl +++ b/compiler/rustc_resolve/messages.ftl @@ -11,7 +11,7 @@ resolve_added_macro_use = resolve_ancestor_only = visibilities can only be restricted to ancestor modules -resolve_anonymous_livetime_non_gat_report_error = +resolve_anonymous_lifetime_non_gat_report_error = in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type .label = this lifetime must come from the implemented type diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index 662b772413b86..58834d0a2b3a6 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -894,7 +894,7 @@ pub(crate) struct LendingIteratorReportError { } #[derive(Diagnostic)] -#[diag(resolve_anonymous_livetime_non_gat_report_error)] +#[diag(resolve_anonymous_lifetime_non_gat_report_error)] pub(crate) struct AnonymousLivetimeNonGatReportError { #[primary_span] #[label] diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index 149c639efab86..87f8e51f28231 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -445,7 +445,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } } Scope::DeriveHelpersCompat => { - // FIXME: Try running this logic eariler, to allocate name bindings for + // FIXME: Try running this logic earlier, to allocate name bindings for // legacy derive helpers when creating an attribute invocation with // following derives. Legacy derive helpers are not common, so it shouldn't // affect performance. It should also allow to remove the `derives` diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index a0386ddcbb37e..79c42456cf8c9 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -133,7 +133,7 @@ pub(crate) enum NoConstantGenericsReason { /// Const arguments are only allowed to use generic parameters when: /// - `feature(generic_const_exprs)` is enabled /// or - /// - the const argument is a sole const generic paramater, i.e. `foo::<{ N }>()` + /// - the const argument is a sole const generic parameter, i.e. `foo::<{ N }>()` /// /// If neither of the above are true then this is used as the cause. NonTrivialConstArg, @@ -4486,7 +4486,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { /// There are a few places that we need to resolve an anon const but we did not parse an /// anon const so cannot provide an `&'ast AnonConst`. Right now this is just unbraced - /// const arguments that were parsed as type arguments, and `legact_const_generics` which + /// const arguments that were parsed as type arguments, and `legacy_const_generics` which /// parse as normal function argument expressions. To avoid duplicating the code for resolving /// an anon const we have this function which lets the caller manually call `resolve_expr` or /// `smart_resolve_path`. diff --git a/compiler/rustc_resolve/src/rustdoc.rs b/compiler/rustc_resolve/src/rustdoc.rs index de4fc5c27d40a..976c4acb212f5 100644 --- a/compiler/rustc_resolve/src/rustdoc.rs +++ b/compiler/rustc_resolve/src/rustdoc.rs @@ -417,7 +417,7 @@ pub(crate) fn attrs_to_preprocessed_links(attrs: &[ast::Attribute]) -> Vec(doc: &'md str) -> Vec> { let mut broken_link_callback = |link: BrokenLink<'md>| Some((link.reference, "".into())); diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs index 2f43199796cc6..5b2062e0b0ab3 100644 --- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs +++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs @@ -262,7 +262,7 @@ fn trait_object_ty<'tcx>(tcx: TyCtxt<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tc /// mangling. /// /// typeid_for_instance is called at two locations, initially when declaring/defining functions and -/// methods, and later during code generation at call sites, after type erasure might have ocurred. +/// methods, and later during code generation at call sites, after type erasure might have occurred. /// /// In the first call (i.e., when declaring/defining functions and methods), it encodes type ids for /// an FnAbi or Instance, and these type ids are attached to functions and methods. (These type ids @@ -270,7 +270,7 @@ fn trait_object_ty<'tcx>(tcx: TyCtxt<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tc /// these type ids.) /// /// In the second call (i.e., during code generation at call sites), it encodes a type id for an -/// FnAbi or Instance, after type erasure might have occured, and this type id is used for testing +/// FnAbi or Instance, after type erasure might have occurred, and this type id is used for testing /// if a function is member of the group derived from this type id. Therefore, in the first call to /// typeid_for_fnabi (when type ids are attached to functions and methods), it can only include at /// most as much information that would be available in the second call (i.e., during code @@ -365,7 +365,7 @@ pub fn transform_instance<'tcx>( // of the trait that defines the method. if let Some((trait_ref, method_id, ancestor)) = implemented_method(tcx, instance) { // Trait methods will have a Self polymorphic parameter, where the concreteized - // implementatation will not. We need to walk back to the more general trait method + // implementation will not. We need to walk back to the more general trait method let trait_ref = tcx.instantiate_and_normalize_erasing_regions( instance.args, ty::ParamEnv::reveal_all(), diff --git a/compiler/rustc_serialize/src/opaque.rs b/compiler/rustc_serialize/src/opaque.rs index d8609ccfe429f..c7c561156e35b 100644 --- a/compiler/rustc_serialize/src/opaque.rs +++ b/compiler/rustc_serialize/src/opaque.rs @@ -159,7 +159,7 @@ impl FileEncoder { // We produce a post-mono error if N > BUF_SIZE. let buf = unsafe { self.buffer_empty().first_chunk_mut::().unwrap_unchecked() }; let written = visitor(buf); - // We have to ensure that an errant visitor cannot cause self.buffered to exeed BUF_SIZE. + // We have to ensure that an errant visitor cannot cause self.buffered to exceed BUF_SIZE. if written > N { Self::panic_invalid_write::(written); } diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 945bab6887e69..908d50a041ef1 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -251,7 +251,7 @@ pub struct LinkSelfContained { pub explicitly_set: Option, /// The components that are enabled on the CLI, using the `+component` syntax or one of the - /// `true` shorcuts. + /// `true` shortcuts. enabled_components: LinkSelfContainedComponents, /// The components that are disabled on the CLI, using the `-component` syntax or one of the @@ -313,13 +313,13 @@ impl LinkSelfContained { } /// Returns whether the self-contained linker component was enabled on the CLI, using the - /// `-C link-self-contained=+linker` syntax, or one of the `true` shorcuts. + /// `-C link-self-contained=+linker` syntax, or one of the `true` shortcuts. pub fn is_linker_enabled(&self) -> bool { self.enabled_components.contains(LinkSelfContainedComponents::LINKER) } /// Returns whether the self-contained linker component was disabled on the CLI, using the - /// `-C link-self-contained=-linker` syntax, or one of the `false` shorcuts. + /// `-C link-self-contained=-linker` syntax, or one of the `false` shortcuts. pub fn is_linker_disabled(&self) -> bool { self.disabled_components.contains(LinkSelfContainedComponents::LINKER) } @@ -360,7 +360,7 @@ impl LinkerFeaturesCli { // Duplicate flags are reduced as we go, the last occurrence wins: // `+feature,-feature,+feature` only enables the feature, and does not record it as both // enabled and disabled on the CLI. - // We also only expose `+/-lld` at the moment, as it's currenty the only implemented linker + // We also only expose `+/-lld` at the moment, as it's currently the only implemented linker // feature and toggling `LinkerFeatures::CC` would be a noop. match feature { "+lld" => { @@ -1102,7 +1102,7 @@ bitflags::bitflags! { const MACRO = 1 << 0; /// Apply remappings to printed compiler diagnostics const DIAGNOSTICS = 1 << 1; - /// Apply remappings to debug informations + /// Apply remappings to debug information const DEBUGINFO = 1 << 3; /// An alias for `macro` and `debuginfo`. This ensures all paths in compiled diff --git a/compiler/rustc_smir/src/rustc_internal/mod.rs b/compiler/rustc_smir/src/rustc_internal/mod.rs index e997ea25ec863..a3aa589cb643e 100644 --- a/compiler/rustc_smir/src/rustc_internal/mod.rs +++ b/compiler/rustc_smir/src/rustc_internal/mod.rs @@ -397,7 +397,7 @@ macro_rules! run_driver { }}; } -/// Simmilar to rustc's `FxIndexMap`, `IndexMap` with extra +/// Similar to rustc's `FxIndexMap`, `IndexMap` with extra /// safety features added. pub struct IndexMap { index_map: fx::FxIndexMap, diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 5e1b1b44bc2a2..463e0dbc30ce5 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -1358,7 +1358,7 @@ pub fn decode_syntax_context SyntaxContext let mut inner = context.inner.lock(); if let Some(ctxt) = inner.remapped_ctxts.get(raw_id as usize).copied().flatten() { - // This has already beeen decoded. + // This has already been decoded. return ctxt; } diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 7b020f11cdda0..a6ec15d5d3641 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -271,7 +271,7 @@ impl RealFileName { } } - /// Return the path remmapped or not depending on the [`FileNameDisplayPreference`]. + /// Return the path remapped or not depending on the [`FileNameDisplayPreference`]. /// /// For the purpose of this function, local and short preference are equal. pub fn to_path(&self, display_pref: FileNameDisplayPreference) -> &Path { @@ -1683,7 +1683,7 @@ impl fmt::Debug for SourceFile { /// is because SourceFiles for the local crate are allocated very early in the /// compilation process when the `StableCrateId` is not yet known. If, due to /// some refactoring of the compiler, the `StableCrateId` of the local crate -/// were to become available, it would be better to uniformely make this a +/// were to become available, it would be better to uniformly make this a /// hash of `(filename, stable_crate_id)`. /// /// When `SourceFile`s are exported in crate metadata, the `StableSourceFileId` From a178559a03a11b5f6e716045e1b486ca29b2d543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Mon, 2 Sep 2024 08:37:55 +0000 Subject: [PATCH 15/17] address review comments --- .../run-make/rustc-crates-on-stable/rmake.rs | 66 +++++++++---------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/tests/run-make/rustc-crates-on-stable/rmake.rs b/tests/run-make/rustc-crates-on-stable/rmake.rs index 48b8551ecef7c..81cc775c91997 100644 --- a/tests/run-make/rustc-crates-on-stable/rmake.rs +++ b/tests/run-make/rustc-crates-on-stable/rmake.rs @@ -1,42 +1,36 @@ //! Checks if selected rustc crates can be compiled on the stable channel (or a "simulation" of it). //! These crates are designed to be used by downstream users. -use run_make_support::{cargo, run_in_tmpdir, rustc_path, source_root}; +use run_make_support::{cargo, rustc_path, source_root}; fn main() { - run_in_tmpdir(|| { - // Use the stage0 beta cargo for the compilation (it shouldn't really matter which cargo we - // use) - let cargo = cargo() - // Ensure `proc-macro2`'s nightly detection is disabled - .env("RUSTC_STAGE", "0") - .env("RUSTC", rustc_path()) - // We want to disallow all nightly features to simulate a stable build - .env("RUSTFLAGS", "-Zallow-features=") - .arg("build") - .arg("--manifest-path") - .arg(source_root().join("Cargo.toml")) - .args(&[ - "--config", - r#"workspace.exclude=["library/core"]"#, - // Avoid depending on transitive rustc crates - "--no-default-features", - // Emit artifacts in this temporary directory, not in the source_root's `target` - // folder - "--target-dir", - ".", - ]) - // Check that these crates can be compiled on "stable" - .args(&[ - "-p", - "rustc_type_ir", - "-p", - "rustc_next_trait_solver", - "-p", - "rustc_pattern_analysis", - "-p", - "rustc_lexer", - ]) - .run(); - }); + // Use the stage0 beta cargo for the compilation (it shouldn't really matter which cargo we use) + cargo() + // Ensure `proc-macro2`'s nightly detection is disabled + .env("RUSTC_STAGE", "0") + .env("RUSTC", rustc_path()) + // We want to disallow all nightly features to simulate a stable build + .env("RUSTFLAGS", "-Zallow-features=") + .arg("build") + .arg("--manifest-path") + .arg(source_root().join("Cargo.toml")) + .args(&[ + // Avoid depending on transitive rustc crates + "--no-default-features", + // Emit artifacts in this temporary directory, not in the source_root's `target` folder + "--target-dir", + "target", + ]) + // Check that these crates can be compiled on "stable" + .args(&[ + "-p", + "rustc_type_ir", + "-p", + "rustc_next_trait_solver", + "-p", + "rustc_pattern_analysis", + "-p", + "rustc_lexer", + ]) + .run(); } From cf0844735f18591761ead9b6ed5d8aa929daeecc Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 2 Sep 2024 15:45:06 +0200 Subject: [PATCH 16/17] Do not request sanitizers for naked functions Naked functions can only contain inline asm, so any instrumentation inserted by sanitizers is illegal. Don't request it. Fixes https://github.com/rust-lang/rust/issues/129224. --- compiler/rustc_codegen_llvm/src/attributes.rs | 46 ++++++++++--------- tests/codegen/naked-asan.rs | 22 +++++++++ 2 files changed, 47 insertions(+), 21 deletions(-) create mode 100644 tests/codegen/naked-asan.rs diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 92a857c2adcf4..9d4497d73a8ae 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -411,26 +411,31 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>( // the string "false". Now it is disabled by absence of the attribute. to_add.push(llvm::CreateAttrStringValue(cx.llcx, "branch-target-enforcement", "false")); } - } else if llvm_util::get_version() >= (19, 0, 0) { - // For non-naked functions, set branch protection attributes on aarch64. - if let Some(BranchProtection { bti, pac_ret }) = - cx.sess().opts.unstable_opts.branch_protection - { - assert!(cx.sess().target.arch == "aarch64"); - if bti { - to_add.push(llvm::CreateAttrString(cx.llcx, "branch-target-enforcement")); - } - if let Some(PacRet { leaf, key }) = pac_ret { - to_add.push(llvm::CreateAttrStringValue( - cx.llcx, - "sign-return-address", - if leaf { "all" } else { "non-leaf" }, - )); - to_add.push(llvm::CreateAttrStringValue( - cx.llcx, - "sign-return-address-key", - if key == PAuthKey::A { "a_key" } else { "b_key" }, - )); + } else { + // Do not set sanitizer attributes for naked functions. + to_add.extend(sanitize_attrs(cx, codegen_fn_attrs.no_sanitize)); + + if llvm_util::get_version() >= (19, 0, 0) { + // For non-naked functions, set branch protection attributes on aarch64. + if let Some(BranchProtection { bti, pac_ret }) = + cx.sess().opts.unstable_opts.branch_protection + { + assert!(cx.sess().target.arch == "aarch64"); + if bti { + to_add.push(llvm::CreateAttrString(cx.llcx, "branch-target-enforcement")); + } + if let Some(PacRet { leaf, key }) = pac_ret { + to_add.push(llvm::CreateAttrStringValue( + cx.llcx, + "sign-return-address", + if leaf { "all" } else { "non-leaf" }, + )); + to_add.push(llvm::CreateAttrStringValue( + cx.llcx, + "sign-return-address-key", + if key == PAuthKey::A { "a_key" } else { "b_key" }, + )); + } } } } @@ -485,7 +490,6 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>( if let Some(backchain) = backchain_attr(cx) { to_add.push(backchain); } - to_add.extend(sanitize_attrs(cx, codegen_fn_attrs.no_sanitize)); to_add.extend(patchable_function_entry_attrs(cx, codegen_fn_attrs.patchable_function_entry)); // Always annotate functions with the target-cpu they are compiled for. diff --git a/tests/codegen/naked-asan.rs b/tests/codegen/naked-asan.rs new file mode 100644 index 0000000000000..943a7800a10bd --- /dev/null +++ b/tests/codegen/naked-asan.rs @@ -0,0 +1,22 @@ +// Make sure we do not request sanitizers for naked functions. + +//@ only-x86_64 +//@ needs-sanitizer-address +//@ compile-flags: -Zsanitizer=address + +#![crate_type = "lib"] +#![no_std] +#![feature(abi_x86_interrupt, naked_functions)] + +// CHECK: define x86_intrcc void @page_fault_handler(ptr {{.*}} %0, i64 {{.*}} %1){{.*}}#[[ATTRS:[0-9]+]] { +// CHECK-NOT: memcpy +#[naked] +#[no_mangle] +pub extern "x86-interrupt" fn page_fault_handler(_: u64, _: u64) { + unsafe { + core::arch::asm!("ud2", options(noreturn)); + } +} + +// CHECK: #[[ATTRS]] = +// CHECK-NOT: sanitize_address From 7494224e74682a7dff39747ef5007ad7df889e2b Mon Sep 17 00:00:00 2001 From: oskgo Date: Mon, 2 Sep 2024 15:49:18 +0200 Subject: [PATCH 17/17] clarify language around non-null ptrs in slice::raw --- library/core/src/slice/raw.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/core/src/slice/raw.rs b/library/core/src/slice/raw.rs index 85507eb8a7381..2cf3fecb47542 100644 --- a/library/core/src/slice/raw.rs +++ b/library/core/src/slice/raw.rs @@ -11,13 +11,13 @@ use crate::{array, ptr, ub_checks}; /// /// Behavior is undefined if any of the following conditions are violated: /// -/// * `data` must be [valid] for reads for `len * mem::size_of::()` many bytes, +/// * `data` must be non-null, [valid] for reads for `len * mem::size_of::()` many bytes, /// and it must be properly aligned. This means in particular: /// /// * The entire memory range of this slice must be contained within a single allocated object! /// Slices can never span across multiple allocated objects. See [below](#incorrect-usage) /// for an example incorrectly not taking this into account. -/// * `data` must be non-null and aligned even for zero-length slices. One +/// * `data` must be non-null and aligned even for zero-length slices or slices of ZSTs. One /// reason for this is that enum layout optimizations may rely on references /// (including slices of any length) being aligned and non-null to distinguish /// them from other data. You can obtain a pointer that is usable as `data` @@ -146,12 +146,12 @@ pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] /// /// Behavior is undefined if any of the following conditions are violated: /// -/// * `data` must be [valid] for both reads and writes for `len * mem::size_of::()` many bytes, +/// * `data` must be non-null, [valid] for both reads and writes for `len * mem::size_of::()` many bytes, /// and it must be properly aligned. This means in particular: /// /// * The entire memory range of this slice must be contained within a single allocated object! /// Slices can never span across multiple allocated objects. -/// * `data` must be non-null and aligned even for zero-length slices. One +/// * `data` must be non-null and aligned even for zero-length slices or slices of ZSTs. One /// reason for this is that enum layout optimizations may rely on references /// (including slices of any length) being aligned and non-null to distinguish /// them from other data. You can obtain a pointer that is usable as `data` @@ -219,7 +219,7 @@ pub const fn from_mut(s: &mut T) -> &mut [T] { /// /// Behavior is undefined if any of the following conditions are violated: /// -/// * The `start` pointer of the range must be a [valid] and properly aligned pointer +/// * The `start` pointer of the range must be a non-null, [valid] and properly aligned pointer /// to the first element of a slice. /// /// * The `end` pointer must be a [valid] and properly aligned pointer to *one past* @@ -235,7 +235,7 @@ pub const fn from_mut(s: &mut T) -> &mut [T] { /// of lifetime `'a`, except inside an `UnsafeCell`. /// /// * The total length of the range must be no larger than `isize::MAX`, -/// and adding that size to `data` must not "wrap around" the address space. +/// and adding that size to `start` must not "wrap around" the address space. /// See the safety documentation of [`pointer::offset`]. /// /// Note that a range created from [`slice::as_ptr_range`] fulfills these requirements. @@ -288,7 +288,7 @@ pub const unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] { /// /// Behavior is undefined if any of the following conditions are violated: /// -/// * The `start` pointer of the range must be a [valid] and properly aligned pointer +/// * The `start` pointer of the range must be a non-null, [valid] and properly aligned pointer /// to the first element of a slice. /// /// * The `end` pointer must be a [valid] and properly aligned pointer to *one past* @@ -305,7 +305,7 @@ pub const unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] { /// Both read and write accesses are forbidden. /// /// * The total length of the range must be no larger than `isize::MAX`, -/// and adding that size to `data` must not "wrap around" the address space. +/// and adding that size to `start` must not "wrap around" the address space. /// See the safety documentation of [`pointer::offset`]. /// /// Note that a range created from [`slice::as_mut_ptr_range`] fulfills these requirements.