From 9177fa3dd23945a8add858cfce893bb25194e0fe Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 10 Oct 2021 22:34:10 -0500 Subject: [PATCH 1/6] Use shallow clones for submodules This reduces the amount of git history downloaded from ~67M to ~11M. --- src/bootstrap/bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 05d7b0f611f72..9d64a254f619b 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -990,7 +990,7 @@ def update_submodule(self, module, checked_out, recorded_submodules): run(["git", "submodule", "-q", "sync", module], cwd=self.rust_root, verbose=self.verbose) - update_args = ["git", "submodule", "update", "--init", "--recursive"] + update_args = ["git", "submodule", "update", "--init", "--recursive", "--depth=1"] if self.git_version >= distutils.version.LooseVersion("2.11.0"): update_args.append("--progress") update_args.append(module) From f819e6d59c41b6bb3db2810c5c8e340b2fb2a88d Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Wed, 29 Sep 2021 13:55:24 +0900 Subject: [PATCH 2/6] suggestion for typoed crate or module avoid suggesting the same name sort candidates fix a message use `opt_def_id` instead of `def_id` move `find_similarly_named_module_or_crate` to rustc_resolve/src/diagnostics.rs --- compiler/rustc_resolve/src/diagnostics.rs | 28 ++++++++++++ compiler/rustc_resolve/src/lib.rs | 17 +++++++- .../ui/macros/macro-inner-attributes.stderr | 5 +++ .../ui/suggestions/crate-or-module-typo.rs | 17 ++++++++ .../suggestions/crate-or-module-typo.stderr | 43 +++++++++++++++++++ 5 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/suggestions/crate-or-module-typo.rs create mode 100644 src/test/ui/suggestions/crate-or-module-typo.stderr diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index dea47c25a8e0a..e3970038a33b0 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1277,6 +1277,34 @@ impl<'a> Resolver<'a> { err.emit(); } + + crate fn find_similarly_named_module_or_crate( + &mut self, + ident: Symbol, + current_module: &Module<'a>, + ) -> Option { + let mut candidates = self + .extern_prelude + .iter() + .map(|(ident, _)| ident.name) + .chain( + self.module_map + .iter() + .filter(|(_, module)| { + current_module.is_ancestor_of(module) && !ptr::eq(current_module, *module) + }) + .map(|(_, module)| module.kind.name()) + .flatten(), + ) + .filter(|c| !c.to_string().is_empty()) + .collect::>(); + candidates.sort(); + candidates.dedup(); + match find_best_match_for_name(&candidates, ident, None) { + Some(sugg) if sugg == ident => None, + sugg => sugg, + } + } } impl<'a, 'b> ImportResolver<'a, 'b> { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 3e7783033efa5..9652c483686f0 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -2555,7 +2555,22 @@ impl<'a> Resolver<'a> { (format!("use of undeclared type `{}`", ident), suggestion) } else { - (format!("use of undeclared crate or module `{}`", ident), None) + ( + format!("use of undeclared crate or module `{}`", ident), + self.find_similarly_named_module_or_crate( + ident.name, + &parent_scope.module, + ) + .map(|sugg| { + ( + vec![(ident.span, sugg.to_string())], + String::from( + "there is a crate or module with a similar name", + ), + Applicability::MaybeIncorrect, + ) + }), + ) } } else { let parent = path[i - 1].ident.name; diff --git a/src/test/ui/macros/macro-inner-attributes.stderr b/src/test/ui/macros/macro-inner-attributes.stderr index 8223220d9a4e2..77b6486155cd2 100644 --- a/src/test/ui/macros/macro-inner-attributes.stderr +++ b/src/test/ui/macros/macro-inner-attributes.stderr @@ -3,6 +3,11 @@ error[E0433]: failed to resolve: use of undeclared crate or module `a` | LL | a::bar(); | ^ use of undeclared crate or module `a` + | +help: there is a crate or module with a similar name + | +LL | b::bar(); + | ~ error: aborting due to previous error diff --git a/src/test/ui/suggestions/crate-or-module-typo.rs b/src/test/ui/suggestions/crate-or-module-typo.rs new file mode 100644 index 0000000000000..2471b11c61efd --- /dev/null +++ b/src/test/ui/suggestions/crate-or-module-typo.rs @@ -0,0 +1,17 @@ +// edition:2018 + +use st::cell::Cell; //~ ERROR failed to resolve: use of undeclared crate or module `st` + +mod bar { + pub fn bar() { bar::baz(); } //~ ERROR failed to resolve: use of undeclared crate or module `bar` + + fn baz() {} +} + +use bas::bar; //~ ERROR unresolved import `bas` + +struct Foo { + bar: st::cell::Cell //~ ERROR failed to resolve: use of undeclared crate or module `st` +} + +fn main() {} diff --git a/src/test/ui/suggestions/crate-or-module-typo.stderr b/src/test/ui/suggestions/crate-or-module-typo.stderr new file mode 100644 index 0000000000000..e8250c9fa5ff4 --- /dev/null +++ b/src/test/ui/suggestions/crate-or-module-typo.stderr @@ -0,0 +1,43 @@ +error[E0433]: failed to resolve: use of undeclared crate or module `st` + --> $DIR/crate-or-module-typo.rs:3:5 + | +LL | use st::cell::Cell; + | ^^ use of undeclared crate or module `st` + | +help: there is a crate or module with a similar name + | +LL | use std::cell::Cell; + | ~~~ + +error[E0432]: unresolved import `bas` + --> $DIR/crate-or-module-typo.rs:11:5 + | +LL | use bas::bar; + | ^^^ use of undeclared crate or module `bas` + | +help: there is a crate or module with a similar name + | +LL | use bar::bar; + | ~~~ + +error[E0433]: failed to resolve: use of undeclared crate or module `bar` + --> $DIR/crate-or-module-typo.rs:6:20 + | +LL | pub fn bar() { bar::baz(); } + | ^^^ use of undeclared crate or module `bar` + +error[E0433]: failed to resolve: use of undeclared crate or module `st` + --> $DIR/crate-or-module-typo.rs:14:10 + | +LL | bar: st::cell::Cell + | ^^ use of undeclared crate or module `st` + | +help: there is a crate or module with a similar name + | +LL | bar: std::cell::Cell + | ~~~ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0432, E0433. +For more information about an error, try `rustc --explain E0432`. From 31265c6ca3a2d404b7dbda0e3529f0be7c38cde7 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 11 Oct 2021 04:09:15 +0000 Subject: [PATCH 3/6] Assemble the compiler when running `x.py build` Previously, there was no way to actually get binaries in `build/$TARGET/stage1/bin` without building the standard library. This makes it possible to build just the compiler. This can be useful when the standard library isn't actually necessary for trying out your tests (e.g. a bug that can be reproduced with only a `no_core` crate). --- src/bootstrap/builder.rs | 2 +- src/bootstrap/compile.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 0a6ed2f49b787..b55e7d8d50e36 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -370,7 +370,7 @@ impl<'a> Builder<'a> { match kind { Kind::Build => describe!( compile::Std, - compile::Rustc, + compile::Assemble, compile::CodegenBackend, compile::StartupObjects, tool::BuildManifest, diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index ae234fb1dc729..6a4d57a36b71c 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -528,7 +528,7 @@ impl Step for Rustc { const DEFAULT: bool = false; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("compiler/rustc") + run.never() } fn make_run(run: RunConfig<'_>) { @@ -1023,9 +1023,16 @@ pub struct Assemble { impl Step for Assemble { type Output = Compiler; + const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() + run.path("compiler/rustc") + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(Assemble { + target_compiler: run.builder.compiler(run.builder.top_stage + 1, run.target), + }); } /// Prepare a new compiler from the artifacts in `stage` From cf905ed72f75918597fec46080e31dfca7eaddd4 Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Wed, 13 Oct 2021 13:13:08 +0100 Subject: [PATCH 4/6] Add `riscv32imc-esp-espidf` to changelog --- RELEASES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 269740c171cfb..ae09de5e3fca1 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -22,6 +22,7 @@ Compiler This feature is primarily intended for usage by `cargo fix`, rather than end users. - [Promote `aarch64-apple-ios-sim` to Tier 2\*.][rust#87760] - [Add `powerpc-unknown-freebsd` at Tier 3\*.][rust#87370] +- [Add `riscv32imc-esp-espidf` at Tier 3\*.][rust#87666] \* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support. @@ -180,6 +181,7 @@ and related tools. [rust#87619]: https://github.com/rust-lang/rust/pull/87619 [rust#81825]: https://github.com/rust-lang/rust/pull/81825#issuecomment-808406918 [rust#88019]: https://github.com/rust-lang/rust/pull/88019 +[rust#87666]: https://github.com/rust-lang/rust/pull/87666 Version 1.55.0 (2021-09-09) ============================ From 21429eda2de59327881359b083e97f5fef58f17a Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Fri, 8 Oct 2021 17:17:50 +0200 Subject: [PATCH 5/6] Improve `std::thread::available_parallelism` docs --- library/std/src/thread/mod.rs | 77 ++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 20 deletions(-) diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 707a55b625814..944defa0f817a 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -1427,39 +1427,76 @@ fn _assert_sync_and_send() { _assert_both::(); } -/// Returns the number of hardware threads available to the program. -/// -/// This value should be considered only a hint. -/// -/// # Platform-specific behavior -/// -/// If interpreted as the number of actual hardware threads, it may undercount on -/// Windows systems with more than 64 hardware threads. If interpreted as the -/// available concurrency for that process, it may overcount on Windows systems -/// when limited by a process wide affinity mask or job object limitations, and -/// it may overcount on Linux systems when limited by a process wide affinity -/// mask or affected by cgroups limits. +/// Returns an estimate of the default amount of parallelism a program should use. +/// +/// Parallelism is a resource. A given machine provides a certain capacity for +/// parallelism, i.e., a bound on the number of computations it can perform +/// simultaneously. This number often corresponds to the amount of CPUs or +/// computer has, but it may diverge in various cases. +/// +/// Host environments such as VMs or container orchestrators may want to +/// restrict the amount of parallelism made available to programs in them. This +/// is often done to limit the potential impact of (unintentionally) +/// resource-intensive programs on other programs running on the same machine. +/// +/// # Limitations +/// +/// The purpose of this API is to provide an easy and portable way to query +/// the default amount of parallelism the program should use. Among other things it +/// does not expose information on NUMA regions, does not account for +/// differences in (co)processor capabilities, and will not modify the program's +/// global state in order to more accurately query the amount of available +/// parallelism. +/// +/// The value returned by this function should be considered a simplified +/// approximation of the actual amount of parallelism available at any given +/// time. To get a more detailed or precise overview of the amount of +/// parallelism available to the program, you may wish to use +/// platform-specific APIs as well. The following platform limitations currently +/// apply to `available_parallelism`: +/// +/// On Windows: +/// - It may undercount the amount of parallelism available on systems with more +/// than 64 logical CPUs. However, programs typically need specific support to +/// take advantage of more than 64 logical CPUs, and in the absence of such +/// support, the number returned by this function accurately reflects the +/// number of logical CPUs the program can use by default. +/// - It may overcount the amount of parallelism available on systems limited by +/// process-wide affinity masks, or job object limitations. +/// +/// On Linux: +/// - It may overcount the amount of parallelism available when limited by a +/// process-wide affinity mask, or when affected by cgroup limits. +/// +/// On all targets: +/// - It may overcount the amount of parallelism available when running in a VM +/// with CPU usage limits (e.g. an overcommitted host). /// /// # Errors /// -/// This function will return an error in the following situations, but is not -/// limited to just these cases: +/// This function will, but is not limited to, return errors in the following +/// cases: /// -/// - If the number of hardware threads is not known for the target platform. -/// - The process lacks permissions to view the number of hardware threads -/// available. +/// - If the amount of parallelism is not known for the target platform. +/// - If the program lacks permission to query the amount of parallelism made +/// available to it. /// /// # Examples /// /// ``` /// # #![allow(dead_code)] /// #![feature(available_parallelism)] -/// use std::thread; +/// use std::{io, thread}; /// -/// let count = thread::available_parallelism().map(|n| n.get()).unwrap_or(1); +/// fn main() -> io::Result<()> { +/// let count = thread::available_parallelism()?.get(); +/// assert!(count >= 1_usize); +/// Ok(()) +/// } /// ``` +#[doc(alias = "available_concurrency")] // Alias for a previous name we gave this API on unstable. #[doc(alias = "hardware_concurrency")] // Alias for C++ `std::thread::hardware_concurrency`. -#[doc(alias = "available_concurrency")] // Alias for a name we gave this API on unstable. +#[doc(alias = "num_cpus")] // Alias for a popular ecosystem crate which provides similar functionality. #[unstable(feature = "available_parallelism", issue = "74479")] pub fn available_parallelism() -> io::Result { imp::available_parallelism() From a0cc8725e95793891e21f4211492abb0da800d3e Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 13 Oct 2021 11:10:00 -0700 Subject: [PATCH 6/6] Update the 1.56.0 release header for consistency --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 269740c171cfb..94cfb4563af37 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,4 +1,4 @@ -Rust 1.56.0 (2021-10-21) +Version 1.56.0 (2021-10-21) ======================== Language