Skip to content

Commit 8c852bc

Browse files
committed
Auto merge of rust-lang#89858 - matthiaskrgr:rollup-evsnr2e, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#89347 (suggestion for typoed crate or module) - rust-lang#89670 (Improve `std::thread::available_parallelism` docs) - rust-lang#89757 (Use shallow clones for submodules) - rust-lang#89759 (Assemble the compiler when running `x.py build`) - rust-lang#89846 (Add `riscv32imc-esp-espidf` to 1.56 changelog) - rust-lang#89853 (Update the 1.56.0 release header for consistency) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents dfc5add + a624eef commit 8c852bc

File tree

10 files changed

+180
-26
lines changed

10 files changed

+180
-26
lines changed

RELEASES.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Rust 1.56.0 (2021-10-21)
1+
Version 1.56.0 (2021-10-21)
22
========================
33

44
Language
@@ -22,6 +22,7 @@ Compiler
2222
This feature is primarily intended for usage by `cargo fix`, rather than end users.
2323
- [Promote `aarch64-apple-ios-sim` to Tier 2\*.][rust#87760]
2424
- [Add `powerpc-unknown-freebsd` at Tier 3\*.][rust#87370]
25+
- [Add `riscv32imc-esp-espidf` at Tier 3\*.][rust#87666]
2526

2627
\* Refer to Rust's [platform support page][platform-support-doc] for more
2728
information on Rust's tiered platform support.
@@ -180,6 +181,7 @@ and related tools.
180181
[rust#87619]: https://github.com/rust-lang/rust/pull/87619
181182
[rust#81825]: https://github.com/rust-lang/rust/pull/81825#issuecomment-808406918
182183
[rust#88019]: https://github.com/rust-lang/rust/pull/88019
184+
[rust#87666]: https://github.com/rust-lang/rust/pull/87666
183185

184186
Version 1.55.0 (2021-09-09)
185187
============================

compiler/rustc_resolve/src/diagnostics.rs

+28
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,34 @@ impl<'a> Resolver<'a> {
12771277

12781278
err.emit();
12791279
}
1280+
1281+
crate fn find_similarly_named_module_or_crate(
1282+
&mut self,
1283+
ident: Symbol,
1284+
current_module: &Module<'a>,
1285+
) -> Option<Symbol> {
1286+
let mut candidates = self
1287+
.extern_prelude
1288+
.iter()
1289+
.map(|(ident, _)| ident.name)
1290+
.chain(
1291+
self.module_map
1292+
.iter()
1293+
.filter(|(_, module)| {
1294+
current_module.is_ancestor_of(module) && !ptr::eq(current_module, *module)
1295+
})
1296+
.map(|(_, module)| module.kind.name())
1297+
.flatten(),
1298+
)
1299+
.filter(|c| !c.to_string().is_empty())
1300+
.collect::<Vec<_>>();
1301+
candidates.sort();
1302+
candidates.dedup();
1303+
match find_best_match_for_name(&candidates, ident, None) {
1304+
Some(sugg) if sugg == ident => None,
1305+
sugg => sugg,
1306+
}
1307+
}
12801308
}
12811309

12821310
impl<'a, 'b> ImportResolver<'a, 'b> {

compiler/rustc_resolve/src/lib.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -2555,7 +2555,22 @@ impl<'a> Resolver<'a> {
25552555

25562556
(format!("use of undeclared type `{}`", ident), suggestion)
25572557
} else {
2558-
(format!("use of undeclared crate or module `{}`", ident), None)
2558+
(
2559+
format!("use of undeclared crate or module `{}`", ident),
2560+
self.find_similarly_named_module_or_crate(
2561+
ident.name,
2562+
&parent_scope.module,
2563+
)
2564+
.map(|sugg| {
2565+
(
2566+
vec![(ident.span, sugg.to_string())],
2567+
String::from(
2568+
"there is a crate or module with a similar name",
2569+
),
2570+
Applicability::MaybeIncorrect,
2571+
)
2572+
}),
2573+
)
25592574
}
25602575
} else {
25612576
let parent = path[i - 1].ident.name;

library/std/src/thread/mod.rs

+57-20
Original file line numberDiff line numberDiff line change
@@ -1428,39 +1428,76 @@ fn _assert_sync_and_send() {
14281428
_assert_both::<Thread>();
14291429
}
14301430

1431-
/// Returns the number of hardware threads available to the program.
1432-
///
1433-
/// This value should be considered only a hint.
1434-
///
1435-
/// # Platform-specific behavior
1436-
///
1437-
/// If interpreted as the number of actual hardware threads, it may undercount on
1438-
/// Windows systems with more than 64 hardware threads. If interpreted as the
1439-
/// available concurrency for that process, it may overcount on Windows systems
1440-
/// when limited by a process wide affinity mask or job object limitations, and
1441-
/// it may overcount on Linux systems when limited by a process wide affinity
1442-
/// mask or affected by cgroups limits.
1431+
/// Returns an estimate of the default amount of parallelism a program should use.
1432+
///
1433+
/// Parallelism is a resource. A given machine provides a certain capacity for
1434+
/// parallelism, i.e., a bound on the number of computations it can perform
1435+
/// simultaneously. This number often corresponds to the amount of CPUs or
1436+
/// computer has, but it may diverge in various cases.
1437+
///
1438+
/// Host environments such as VMs or container orchestrators may want to
1439+
/// restrict the amount of parallelism made available to programs in them. This
1440+
/// is often done to limit the potential impact of (unintentionally)
1441+
/// resource-intensive programs on other programs running on the same machine.
1442+
///
1443+
/// # Limitations
1444+
///
1445+
/// The purpose of this API is to provide an easy and portable way to query
1446+
/// the default amount of parallelism the program should use. Among other things it
1447+
/// does not expose information on NUMA regions, does not account for
1448+
/// differences in (co)processor capabilities, and will not modify the program's
1449+
/// global state in order to more accurately query the amount of available
1450+
/// parallelism.
1451+
///
1452+
/// The value returned by this function should be considered a simplified
1453+
/// approximation of the actual amount of parallelism available at any given
1454+
/// time. To get a more detailed or precise overview of the amount of
1455+
/// parallelism available to the program, you may wish to use
1456+
/// platform-specific APIs as well. The following platform limitations currently
1457+
/// apply to `available_parallelism`:
1458+
///
1459+
/// On Windows:
1460+
/// - It may undercount the amount of parallelism available on systems with more
1461+
/// than 64 logical CPUs. However, programs typically need specific support to
1462+
/// take advantage of more than 64 logical CPUs, and in the absence of such
1463+
/// support, the number returned by this function accurately reflects the
1464+
/// number of logical CPUs the program can use by default.
1465+
/// - It may overcount the amount of parallelism available on systems limited by
1466+
/// process-wide affinity masks, or job object limitations.
1467+
///
1468+
/// On Linux:
1469+
/// - It may overcount the amount of parallelism available when limited by a
1470+
/// process-wide affinity mask, or when affected by cgroup limits.
1471+
///
1472+
/// On all targets:
1473+
/// - It may overcount the amount of parallelism available when running in a VM
1474+
/// with CPU usage limits (e.g. an overcommitted host).
14431475
///
14441476
/// # Errors
14451477
///
1446-
/// This function will return an error in the following situations, but is not
1447-
/// limited to just these cases:
1478+
/// This function will, but is not limited to, return errors in the following
1479+
/// cases:
14481480
///
1449-
/// - If the number of hardware threads is not known for the target platform.
1450-
/// - The process lacks permissions to view the number of hardware threads
1451-
/// available.
1481+
/// - If the amount of parallelism is not known for the target platform.
1482+
/// - If the program lacks permission to query the amount of parallelism made
1483+
/// available to it.
14521484
///
14531485
/// # Examples
14541486
///
14551487
/// ```
14561488
/// # #![allow(dead_code)]
14571489
/// #![feature(available_parallelism)]
1458-
/// use std::thread;
1490+
/// use std::{io, thread};
14591491
///
1460-
/// let count = thread::available_parallelism().map(|n| n.get()).unwrap_or(1);
1492+
/// fn main() -> io::Result<()> {
1493+
/// let count = thread::available_parallelism()?.get();
1494+
/// assert!(count >= 1_usize);
1495+
/// Ok(())
1496+
/// }
14611497
/// ```
1498+
#[doc(alias = "available_concurrency")] // Alias for a previous name we gave this API on unstable.
14621499
#[doc(alias = "hardware_concurrency")] // Alias for C++ `std::thread::hardware_concurrency`.
1463-
#[doc(alias = "available_concurrency")] // Alias for a name we gave this API on unstable.
1500+
#[doc(alias = "num_cpus")] // Alias for a popular ecosystem crate which provides similar functionality.
14641501
#[unstable(feature = "available_parallelism", issue = "74479")]
14651502
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
14661503
imp::available_parallelism()

src/bootstrap/bootstrap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ def update_submodule(self, module, checked_out, recorded_submodules):
10011001
run(["git", "submodule", "-q", "sync", module],
10021002
cwd=self.rust_root, verbose=self.verbose)
10031003

1004-
update_args = ["git", "submodule", "update", "--init", "--recursive"]
1004+
update_args = ["git", "submodule", "update", "--init", "--recursive", "--depth=1"]
10051005
if self.git_version >= distutils.version.LooseVersion("2.11.0"):
10061006
update_args.append("--progress")
10071007
update_args.append(module)

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<'a> Builder<'a> {
370370
match kind {
371371
Kind::Build => describe!(
372372
compile::Std,
373-
compile::Rustc,
373+
compile::Assemble,
374374
compile::CodegenBackend,
375375
compile::StartupObjects,
376376
tool::BuildManifest,

src/bootstrap/compile.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ impl Step for Rustc {
528528
const DEFAULT: bool = false;
529529

530530
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
531-
run.path("compiler/rustc")
531+
run.never()
532532
}
533533

534534
fn make_run(run: RunConfig<'_>) {
@@ -1023,9 +1023,16 @@ pub struct Assemble {
10231023

10241024
impl Step for Assemble {
10251025
type Output = Compiler;
1026+
const ONLY_HOSTS: bool = true;
10261027

10271028
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1028-
run.never()
1029+
run.path("compiler/rustc")
1030+
}
1031+
1032+
fn make_run(run: RunConfig<'_>) {
1033+
run.builder.ensure(Assemble {
1034+
target_compiler: run.builder.compiler(run.builder.top_stage + 1, run.target),
1035+
});
10291036
}
10301037

10311038
/// Prepare a new compiler from the artifacts in `stage`

src/test/ui/macros/macro-inner-attributes.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ error[E0433]: failed to resolve: use of undeclared crate or module `a`
33
|
44
LL | a::bar();
55
| ^ use of undeclared crate or module `a`
6+
|
7+
help: there is a crate or module with a similar name
8+
|
9+
LL | b::bar();
10+
| ~
611

712
error: aborting due to previous error
813

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// edition:2018
2+
3+
use st::cell::Cell; //~ ERROR failed to resolve: use of undeclared crate or module `st`
4+
5+
mod bar {
6+
pub fn bar() { bar::baz(); } //~ ERROR failed to resolve: use of undeclared crate or module `bar`
7+
8+
fn baz() {}
9+
}
10+
11+
use bas::bar; //~ ERROR unresolved import `bas`
12+
13+
struct Foo {
14+
bar: st::cell::Cell<bool> //~ ERROR failed to resolve: use of undeclared crate or module `st`
15+
}
16+
17+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0433]: failed to resolve: use of undeclared crate or module `st`
2+
--> $DIR/crate-or-module-typo.rs:3:5
3+
|
4+
LL | use st::cell::Cell;
5+
| ^^ use of undeclared crate or module `st`
6+
|
7+
help: there is a crate or module with a similar name
8+
|
9+
LL | use std::cell::Cell;
10+
| ~~~
11+
12+
error[E0432]: unresolved import `bas`
13+
--> $DIR/crate-or-module-typo.rs:11:5
14+
|
15+
LL | use bas::bar;
16+
| ^^^ use of undeclared crate or module `bas`
17+
|
18+
help: there is a crate or module with a similar name
19+
|
20+
LL | use bar::bar;
21+
| ~~~
22+
23+
error[E0433]: failed to resolve: use of undeclared crate or module `bar`
24+
--> $DIR/crate-or-module-typo.rs:6:20
25+
|
26+
LL | pub fn bar() { bar::baz(); }
27+
| ^^^ use of undeclared crate or module `bar`
28+
29+
error[E0433]: failed to resolve: use of undeclared crate or module `st`
30+
--> $DIR/crate-or-module-typo.rs:14:10
31+
|
32+
LL | bar: st::cell::Cell<bool>
33+
| ^^ use of undeclared crate or module `st`
34+
|
35+
help: there is a crate or module with a similar name
36+
|
37+
LL | bar: std::cell::Cell<bool>
38+
| ~~~
39+
40+
error: aborting due to 4 previous errors
41+
42+
Some errors have detailed explanations: E0432, E0433.
43+
For more information about an error, try `rustc --explain E0432`.

0 commit comments

Comments
 (0)