diff options
| author | bors <bors@rust-lang.org> | 2022-08-15 18:27:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-15 18:27:37 +0000 |
| commit | 40336865fe7d4a01139a3336639c6971647e885c (patch) | |
| tree | c4a707523bfd7a0b4c4cc5f9da41862e2a885975 /src | |
| parent | 9b4ea391a132ec5f5de40079597ab7ff2fd691ad (diff) | |
| parent | e65de39763cc516a92c768c5644d7f86e973fb24 (diff) | |
Auto merge of #100595 - matthiaskrgr:rollup-f1zur58, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #100031 (improve "try ignoring the field" diagnostic) - #100325 (Rustdoc-Json: Don't remove impls for items imported from private modules) - #100377 (Replace - with _ in fluent slugs to improve developer workflows) - #100458 (Adjust span of fn argument declaration) - #100514 (Delay span bug when failing to normalize negative coherence impl subject due to other malformed impls) - #100528 (Support 1st group of RISC-V Bitmanip backend target features) - #100559 (Parser simplifications) - #100568 (Fix STD build for ESP-IDF) - #100582 ([rustdoc] Fix handling of stripped enum variant in JSON output format) - #100586 (Reland changes replacing num_cpus with available_parallelism ) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
31 files changed, 232 insertions, 42 deletions
diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index 664ffa1ddd2..84c06fdce70 100644 --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock @@ -53,7 +53,6 @@ dependencies = [ "hex", "ignore", "libc", - "num_cpus", "once_cell", "opener", "pretty_assertions", diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 84f6aaf99c1..2dad41bb18f 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -38,7 +38,6 @@ test = false cmake = "0.1.38" fd-lock = "3.0.6" filetime = "0.2" -num_cpus = "1.0" getopts = "0.2.19" cc = "1.0.69" libc = "0.2" diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index c4983accc68..203db2d3876 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -1465,7 +1465,7 @@ fn set<T>(field: &mut T, val: Option<T>) { fn threads_from_config(v: u32) -> u32 { match v { - 0 => num_cpus::get() as u32, + 0 => std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32, n => n, } } diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 1edb513f0b6..789da748100 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -220,7 +220,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`", let j_msg = format!( "number of jobs to run in parallel; \ defaults to {} (this host's logical CPU count)", - num_cpus::get() + std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) ); opts.optopt("j", "jobs", &j_msg, "JOBS"); opts.optflag("h", "help", "print this help message"); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index a242243aaaf..dcfa92d1004 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1008,7 +1008,9 @@ impl Build { /// Returns the number of parallel jobs that have been configured for this /// build. fn jobs(&self) -> u32 { - self.config.jobs.unwrap_or_else(|| num_cpus::get() as u32) + self.config.jobs.unwrap_or_else(|| { + std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32 + }) } fn debuginfo_map_to(&self, which: GitRepo) -> Option<String> { diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 5f3793ead42..1fedb0144d1 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -662,12 +662,10 @@ impl FromWithTcx<clean::Variant> for Variant { Tuple(fields) => Variant::Tuple( fields .into_iter() - .map(|f| { - if let clean::StructFieldItem(ty) = *f.kind { - ty.into_tcx(tcx) - } else { - unreachable!() - } + .filter_map(|f| match *f.kind { + clean::StructFieldItem(ty) => Some(ty.into_tcx(tcx)), + clean::StrippedItem(_) => None, + _ => unreachable!(), }) .collect(), ), diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index 3f069e8393f..83ed3752a82 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -88,7 +88,17 @@ impl<'a> DocFolder for Stripper<'a> { } // handled in the `strip-priv-imports` pass - clean::ExternCrateItem { .. } | clean::ImportItem(..) => {} + clean::ExternCrateItem { .. } => {} + clean::ImportItem(ref imp) => { + // Because json doesn't inline imports from private modules, we need to mark + // the imported item as retained so it's impls won't be stripped.i + // + // FIXME: Is it necessary to check for json output here: See + // https://github.com/rust-lang/rust/pull/100325#discussion_r941495215 + if let Some(did) = imp.source.did && self.is_json_output { + self.retained.insert(did.into()); + } + } clean::ImplItem(..) => {} diff --git a/src/test/run-make/translation/broken.ftl b/src/test/run-make/translation/broken.ftl index 1482dd2824a..4e358583528 100644 --- a/src/test/run-make/translation/broken.ftl +++ b/src/test/run-make/translation/broken.ftl @@ -1,3 +1,3 @@ # `foo` isn't provided by this diagnostic so it is expected that the fallback message is used. -parser-struct-literal-body-without-path = this is a {$foo} message +parser_struct_literal_body_without_path = this is a {$foo} message .suggestion = this is a test suggestion diff --git a/src/test/run-make/translation/missing.ftl b/src/test/run-make/translation/missing.ftl index 43076b1d6ae..77bbda3575b 100644 --- a/src/test/run-make/translation/missing.ftl +++ b/src/test/run-make/translation/missing.ftl @@ -1,3 +1,3 @@ -# `parser-struct-literal-body-without-path` isn't provided by this resource at all, so the +# `parser_struct_literal_body_without_path` isn't provided by this resource at all, so the # fallback should be used. foo = bar diff --git a/src/test/run-make/translation/working.ftl b/src/test/run-make/translation/working.ftl index 4681b879cda..d5ea8673875 100644 --- a/src/test/run-make/translation/working.ftl +++ b/src/test/run-make/translation/working.ftl @@ -1,2 +1,2 @@ -parser-struct-literal-body-without-path = this is a test message +parser_struct_literal_body_without_path = this is a test message .suggestion = this is a test suggestion diff --git a/src/test/rustdoc-json/enum_variant_hidden.rs b/src/test/rustdoc-json/enum_variant_hidden.rs new file mode 100644 index 00000000000..96c96a975d3 --- /dev/null +++ b/src/test/rustdoc-json/enum_variant_hidden.rs @@ -0,0 +1,13 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/100529>. + +#![no_core] +#![feature(no_core)] + +// @has enum_variant_hidden.json "$.index[*][?(@.name=='ParseError')]" +// @has - "$.index[*][?(@.name=='UnexpectedEndTag')]" +// @is - "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_kind" '"tuple"' +// @is - "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_inner" [] + +pub enum ParseError { + UnexpectedEndTag(#[doc(hidden)] u32), +} diff --git a/src/test/rustdoc-json/impls/import_from_private.rs b/src/test/rustdoc-json/impls/import_from_private.rs new file mode 100644 index 00000000000..ef4d8aa39f8 --- /dev/null +++ b/src/test/rustdoc-json/impls/import_from_private.rs @@ -0,0 +1,24 @@ +// https://github.com/rust-lang/rust/issues/100252 + +#![feature(no_core)] +#![no_core] + +mod bar { + // @set baz = import_from_private.json "$.index[*][?(@.kind=='struct')].id" + pub struct Baz; + // @set impl = - "$.index[*][?(@.kind=='impl')].id" + impl Baz { + // @set doit = - "$.index[*][?(@.kind=='method')].id" + pub fn doit() {} + } +} + +// @set import = - "$.index[*][?(@.kind=='import')].id" +pub use bar::Baz; + +// FIXME(adotinthevoid): Use hasexact once #99474 lands + +// @has - "$.index[*][?(@.kind=='module')].inner.items[*]" $import +// @is - "$.index[*][?(@.kind=='import')].inner.id" $baz +// @has - "$.index[*][?(@.kind=='struct')].inner.impls[*]" $impl +// @has - "$.index[*][?(@.kind=='impl')].inner.items[*]" $doit diff --git a/src/test/ui-fulldeps/fluent-messages/label-with-hyphens.ftl b/src/test/ui-fulldeps/fluent-messages/label-with-hyphens.ftl new file mode 100644 index 00000000000..84b6c3e6c00 --- /dev/null +++ b/src/test/ui-fulldeps/fluent-messages/label-with-hyphens.ftl @@ -0,0 +1,2 @@ +some_slug = hi + .label-has-hyphens = test diff --git a/src/test/ui-fulldeps/fluent-messages/missing-message.ftl b/src/test/ui-fulldeps/fluent-messages/missing-message.ftl index 372b1a2e453..74b2aa1d44d 100644 --- a/src/test/ui-fulldeps/fluent-messages/missing-message.ftl +++ b/src/test/ui-fulldeps/fluent-messages/missing-message.ftl @@ -1 +1 @@ -missing-message = +missing_message = diff --git a/src/test/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl b/src/test/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl new file mode 100644 index 00000000000..07517c9a243 --- /dev/null +++ b/src/test/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl @@ -0,0 +1 @@ +this-slug-has-hyphens = hi diff --git a/src/test/ui-fulldeps/fluent-messages/test.rs b/src/test/ui-fulldeps/fluent-messages/test.rs index 0390a07850b..f0f35780666 100644 --- a/src/test/ui-fulldeps/fluent-messages/test.rs +++ b/src/test/ui-fulldeps/fluent-messages/test.rs @@ -55,6 +55,24 @@ mod duplicate { } } +mod slug_with_hyphens { + use super::fluent_messages; + + fluent_messages! { + slug_with_hyphens => "./slug-with-hyphens.ftl", +//~^ ERROR name `this-slug-has-hyphens` contains a '-' character + } +} + +mod label_with_hyphens { + use super::fluent_messages; + + fluent_messages! { + label_with_hyphens => "./label-with-hyphens.ftl", +//~^ ERROR attribute `label-has-hyphens` contains a '-' character + } +} + mod valid { use super::fluent_messages; diff --git a/src/test/ui-fulldeps/fluent-messages/test.stderr b/src/test/ui-fulldeps/fluent-messages/test.stderr index 526bca43f69..856642c4818 100644 --- a/src/test/ui-fulldeps/fluent-messages/test.stderr +++ b/src/test/ui-fulldeps/fluent-messages/test.stderr @@ -22,11 +22,11 @@ LL | missing_message => "./missing-message.ftl", | = help: see additional errors emitted -error: expected a message field for "missing-message" +error: expected a message field for "missing_message" --> ./missing-message.ftl:1:1 | -1 | missing-message = - | ^^^^^^^^^^^^^^^^^^ +1 | missing_message = + | ^^^^^^^^^^^^^^^^^ | error: overrides existing message: `key` @@ -41,5 +41,21 @@ help: previously defined in this resource LL | a => "./duplicate-a.ftl", | ^ -error: aborting due to 4 previous errors +error: name `this-slug-has-hyphens` contains a '-' character + --> $DIR/test.rs:62:9 + | +LL | slug_with_hyphens => "./slug-with-hyphens.ftl", + | ^^^^^^^^^^^^^^^^^ + | + = help: replace any '-'s with '_'s + +error: attribute `label-has-hyphens` contains a '-' character + --> $DIR/test.rs:71:9 + | +LL | label_with_hyphens => "./label-with-hyphens.ftl", + | ^^^^^^^^^^^^^^^^^^ + | + = help: replace any '-'s with '_'s + +error: aborting due to 6 previous errors diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index fa030a8f49d..bf49e744458 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -8,7 +8,7 @@ note: function defined here --> $DIR/complex.rs:11:4 | LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} - | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ------ + | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ----- help: did you mean | LL | complex(/* u32 */, &"", /* E */, F::X2, G{}, X {}, Y {}, Z {}); diff --git a/src/test/ui/c-variadic/issue-86053-1.stderr b/src/test/ui/c-variadic/issue-86053-1.stderr index 5d119bb8557..60b379faf4e 100644 --- a/src/test/ui/c-variadic/issue-86053-1.stderr +++ b/src/test/ui/c-variadic/issue-86053-1.stderr @@ -44,19 +44,19 @@ error: `...` must be the last argument of a C-variadic function --> $DIR/issue-86053-1.rs:11:12 | LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { - | ^^^^ + | ^^^ error: only foreign or `unsafe extern "C"` functions may be C-variadic --> $DIR/issue-86053-1.rs:11:12 | LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { - | ^^^^ + | ^^^ error: only foreign or `unsafe extern "C"` functions may be C-variadic --> $DIR/issue-86053-1.rs:11:36 | LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { - | ^^^^ + | ^^^ error[E0412]: cannot find type `F` in this scope --> $DIR/issue-86053-1.rs:11:48 diff --git a/src/test/ui/coherence/issue-100191-2.rs b/src/test/ui/coherence/issue-100191-2.rs new file mode 100644 index 00000000000..1c8316f87fa --- /dev/null +++ b/src/test/ui/coherence/issue-100191-2.rs @@ -0,0 +1,12 @@ +//~ ERROR overflow evaluating the requirement `T: Trait<_>` + +#![feature(specialization, with_negative_coherence)] +#![allow(incomplete_features)] + +pub trait Trait<T> {} + +default impl<T, U> Trait<T> for U {} + +impl<T> Trait<<T as Iterator>::Item> for T {} + +fn main() {} diff --git a/src/test/ui/coherence/issue-100191-2.stderr b/src/test/ui/coherence/issue-100191-2.stderr new file mode 100644 index 00000000000..ea09fb15bdf --- /dev/null +++ b/src/test/ui/coherence/issue-100191-2.stderr @@ -0,0 +1,14 @@ +error[E0275]: overflow evaluating the requirement `T: Trait<_>` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_100191_2`) +note: required because of the requirements on the impl of `Trait<_>` for `T` + --> $DIR/issue-100191-2.rs:8:20 + | +LL | default impl<T, U> Trait<T> for U {} + | ^^^^^^^^ ^ + = note: 128 redundant requirements hidden + = note: required because of the requirements on the impl of `Trait<_>` for `T` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/coherence/issue-100191.rs b/src/test/ui/coherence/issue-100191.rs new file mode 100644 index 00000000000..e8597fde54d --- /dev/null +++ b/src/test/ui/coherence/issue-100191.rs @@ -0,0 +1,21 @@ +#![crate_type = "lib"] +#![feature(specialization, with_negative_coherence)] +#![allow(incomplete_features)] + +trait X {} +trait Y: X {} +trait Z { + type Assoc: Y; +} +struct A<T>(T); + +impl<T> Y for T where T: X {} +impl<T: X> Z for A<T> { + type Assoc = T; +} + +// this impl is invalid, but causes an ICE anyway +impl<T> From<<A<T> as Z>::Assoc> for T {} +//~^ ERROR type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`) + +fn main() {} diff --git a/src/test/ui/coherence/issue-100191.stderr b/src/test/ui/coherence/issue-100191.stderr new file mode 100644 index 00000000000..1adb0f1e4fa --- /dev/null +++ b/src/test/ui/coherence/issue-100191.stderr @@ -0,0 +1,12 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`) + --> $DIR/issue-100191.rs:18:6 + | +LL | impl<T> From<<A<T> as Z>::Assoc> for T {} + | ^ type parameter `T` must be used as the type parameter for some local type + | + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/suggestions/dont-try-removing-the-field.rs b/src/test/ui/suggestions/dont-try-removing-the-field.rs new file mode 100644 index 00000000000..948aa2b94d9 --- /dev/null +++ b/src/test/ui/suggestions/dont-try-removing-the-field.rs @@ -0,0 +1,17 @@ +// run-pass + +#![allow(dead_code)] + +struct Foo { + foo: i32, + bar: i32, + baz: (), +} + +fn use_foo(x: Foo) -> (i32, i32) { + let Foo { foo, bar, baz } = x; //~ WARNING unused variable: `baz` + //~| help: try ignoring the field + return (foo, bar); +} + +fn main() {} diff --git a/src/test/ui/suggestions/dont-try-removing-the-field.stderr b/src/test/ui/suggestions/dont-try-removing-the-field.stderr new file mode 100644 index 00000000000..263171a4ac4 --- /dev/null +++ b/src/test/ui/suggestions/dont-try-removing-the-field.stderr @@ -0,0 +1,10 @@ +warning: unused variable: `baz` + --> $DIR/dont-try-removing-the-field.rs:12:25 + | +LL | let Foo { foo, bar, baz } = x; + | ^^^ help: try ignoring the field: `baz: _` + | + = note: `#[warn(unused_variables)]` on by default + +warning: 1 warning emitted + diff --git a/src/test/ui/suggestions/suggest-ref-macro.stderr b/src/test/ui/suggestions/suggest-ref-macro.stderr index 84cbc93571a..17de49fbd84 100644 --- a/src/test/ui/suggestions/suggest-ref-macro.stderr +++ b/src/test/ui/suggestions/suggest-ref-macro.stderr @@ -10,14 +10,8 @@ LL | #[hello] note: function defined here --> $DIR/suggest-ref-macro.rs:8:1 | -LL | #[hello] - | _-^^^^^^^ -LL | | fn abc() {} -LL | | -LL | | fn x(_: &mut i32) {} -LL | | -LL | | macro_rules! bla { - | |_____________- +LL | #[hello] + | ^^^^^^^^ = note: this error originates in the attribute macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types diff --git a/src/test/ui/suggestions/try-removing-the-field.rs b/src/test/ui/suggestions/try-removing-the-field.rs new file mode 100644 index 00000000000..9d0573ca255 --- /dev/null +++ b/src/test/ui/suggestions/try-removing-the-field.rs @@ -0,0 +1,17 @@ +// run-pass + +#![allow(dead_code)] + +struct Foo { + foo: i32, + bar: (), + baz: (), +} + +fn use_foo(x: Foo) -> i32 { + let Foo { foo, bar, .. } = x; //~ WARNING unused variable: `bar` + //~| help: try removing the field + return foo; +} + +fn main() {} diff --git a/src/test/ui/suggestions/try-removing-the-field.stderr b/src/test/ui/suggestions/try-removing-the-field.stderr new file mode 100644 index 00000000000..448a2c3d2ec --- /dev/null +++ b/src/test/ui/suggestions/try-removing-the-field.stderr @@ -0,0 +1,12 @@ +warning: unused variable: `bar` + --> $DIR/try-removing-the-field.rs:12:20 + | +LL | let Foo { foo, bar, .. } = x; + | ^^^- + | | + | help: try removing the field + | + = note: `#[warn(unused_variables)]` on by default + +warning: 1 warning emitted + diff --git a/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr b/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr index 615fd2ccb04..847bc517ea3 100644 --- a/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr +++ b/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr @@ -1,13 +1,13 @@ error: function can not have more than 65535 arguments - --> $DIR/issue-88577-check-fn-with-more-than-65535-arguments.rs:6:24 + --> $DIR/issue-88577-check-fn-with-more-than-65535-arguments.rs:6:22 | -LL | fn _f($($t: ()),*) {} - | ________________________^ -LL | | } -LL | | } -LL | | -LL | | many_args!{[_]########## ######} - | |____________^ +LL | fn _f($($t: ()),*) {} + | ^ +... +LL | many_args!{[_]########## ######} + | -------------------------------- in this macro invocation + | + = note: this error originates in the macro `many_args` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/tools/build-manifest/Cargo.toml b/src/tools/build-manifest/Cargo.toml index c022d3aa0ac..c437bde5ae6 100644 --- a/src/tools/build-manifest/Cargo.toml +++ b/src/tools/build-manifest/Cargo.toml @@ -13,4 +13,3 @@ tar = "0.4.29" sha2 = "0.10.1" rayon = "1.5.1" hex = "0.4.2" -num_cpus = "1.13.0" diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index efe3f2b618b..1a6760d8c68 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -210,7 +210,7 @@ fn main() { let num_threads = if let Some(num) = env::var_os("BUILD_MANIFEST_NUM_THREADS") { num.to_str().unwrap().parse().expect("invalid number for BUILD_MANIFEST_NUM_THREADS") } else { - num_cpus::get() + std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) }; rayon::ThreadPoolBuilder::new() .num_threads(num_threads) |
