Skip to content

Commit 7a5814f

Browse files
committed
Auto merge of rust-lang#113676 - matthiaskrgr:rollup-n01iiy8, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#112525 (Adjustments for RustyHermit) - rust-lang#112729 (Add machine-applicable suggestion for `unused_qualifications` lint) - rust-lang#113618 (update ancient note) - rust-lang#113640 (Make `nodejs` control the default for RustdocJs tests instead of a hard-off switch) - rust-lang#113668 (Correct `the` -> `there` typo in items.md) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7bd81ee + aa2002e commit 7a5814f

File tree

14 files changed

+150
-58
lines changed

14 files changed

+150
-58
lines changed

Cargo.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -1529,9 +1529,9 @@ dependencies = [
15291529

15301530
[[package]]
15311531
name = "hermit-abi"
1532-
version = "0.3.1"
1532+
version = "0.3.2"
15331533
source = "registry+https://github.com/rust-lang/crates.io-index"
1534-
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
1534+
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
15351535
dependencies = [
15361536
"compiler_builtins",
15371537
"rustc-std-workspace-alloc",
@@ -1864,7 +1864,7 @@ version = "1.0.11"
18641864
source = "registry+https://github.com/rust-lang/crates.io-index"
18651865
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
18661866
dependencies = [
1867-
"hermit-abi 0.3.1",
1867+
"hermit-abi 0.3.2",
18681868
"libc",
18691869
"windows-sys 0.48.0",
18701870
]
@@ -1881,7 +1881,7 @@ version = "0.4.8"
18811881
source = "registry+https://github.com/rust-lang/crates.io-index"
18821882
checksum = "24fddda5af7e54bf7da53067d6e802dbcc381d0a8eef629df528e3ebf68755cb"
18831883
dependencies = [
1884-
"hermit-abi 0.3.1",
1884+
"hermit-abi 0.3.2",
18851885
"rustix 0.38.2",
18861886
"windows-sys 0.48.0",
18871887
]
@@ -2396,7 +2396,7 @@ version = "1.16.0"
23962396
source = "registry+https://github.com/rust-lang/crates.io-index"
23972397
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
23982398
dependencies = [
2399-
"hermit-abi 0.3.1",
2399+
"hermit-abi 0.3.2",
24002400
"libc",
24012401
]
24022402

@@ -4819,7 +4819,7 @@ dependencies = [
48194819
"dlmalloc",
48204820
"fortanix-sgx-abi",
48214821
"hashbrown 0.14.0",
4822-
"hermit-abi 0.3.1",
4822+
"hermit-abi 0.3.2",
48234823
"libc",
48244824
"miniz_oxide",
48254825
"object",

compiler/rustc_lint/src/context.rs

+8
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,14 @@ pub trait LintContext: Sized {
956956
db.span_note(glob_reexport_span, format!("the name `{}` in the {} namespace is supposed to be publicly re-exported here", name, namespace));
957957
db.span_note(private_item_span, "but the private item here shadows it".to_owned());
958958
}
959+
BuiltinLintDiagnostics::UnusedQualifications { path_span, unqualified_path } => {
960+
db.span_suggestion_verbose(
961+
path_span,
962+
"replace it with the unqualified path",
963+
unqualified_path,
964+
Applicability::MachineApplicable
965+
);
966+
}
959967
}
960968
// Rewrap `db`, and pass control to the user.
961969
decorate(db)

compiler/rustc_lint_defs/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,12 @@ pub enum BuiltinLintDiagnostics {
550550
/// The local binding that shadows the glob reexport.
551551
private_item_span: Span,
552552
},
553+
UnusedQualifications {
554+
/// The span of the unnecessarily-qualified path.
555+
path_span: Span,
556+
/// The replacement unqualified path.
557+
unqualified_path: Ident,
558+
},
553559
}
554560

555561
/// Lints that are buffered up early on in the `Session` before the

compiler/rustc_resolve/src/late.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -3922,11 +3922,15 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
39223922
};
39233923
if res == unqualified_result {
39243924
let lint = lint::builtin::UNUSED_QUALIFICATIONS;
3925-
self.r.lint_buffer.buffer_lint(
3925+
self.r.lint_buffer.buffer_lint_with_diagnostic(
39263926
lint,
39273927
finalize.node_id,
39283928
finalize.path_span,
39293929
"unnecessary qualification",
3930+
lint::BuiltinLintDiagnostics::UnusedQualifications {
3931+
path_span: finalize.path_span,
3932+
unqualified_path: path.last().unwrap().ident
3933+
}
39303934
)
39313935
}
39323936
}

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dlmalloc = { version = "0.2.3", features = ['rustc-dep-of-std'] }
4545
fortanix-sgx-abi = { version = "0.5.0", features = ['rustc-dep-of-std'], public = true }
4646

4747
[target.'cfg(target_os = "hermit")'.dependencies]
48-
hermit-abi = { version = "0.3.0", features = ['rustc-dep-of-std'] }
48+
hermit-abi = { version = "0.3.2", features = ['rustc-dep-of-std'], public = true }
4949

5050
[target.wasm32-wasi.dependencies]
5151
wasi = { version = "0.11.0", features = ['rustc-dep-of-std'], default-features = false }

library/std/src/collections/hash/set.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ use super::map::{map_try_reserve_error, RandomState};
6565
/// ```
6666
///
6767
/// The easiest way to use `HashSet` with a custom type is to derive
68-
/// [`Eq`] and [`Hash`]. We must also derive [`PartialEq`], this will in the
69-
/// future be implied by [`Eq`].
68+
/// [`Eq`] and [`Hash`]. We must also derive [`PartialEq`],
69+
/// which is required if [`Eq`] is derived.
7070
///
7171
/// ```
7272
/// use std::collections::HashSet;

library/std/src/sys/hermit/thread.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![allow(dead_code)]
22

3-
use super::unsupported;
43
use crate::ffi::CStr;
54
use crate::io;
65
use crate::mem;
@@ -99,7 +98,7 @@ impl Thread {
9998
}
10099

101100
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
102-
unsupported()
101+
unsafe { Ok(NonZeroUsize::new_unchecked(abi::get_processor_count())) }
103102
}
104103

105104
pub mod guard {

library/std/src/sys/hermit/time.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl Timespec {
4040
}
4141

4242
fn checked_add_duration(&self, other: &Duration) -> Option<Timespec> {
43-
let mut secs = self.tv_sec.checked_add_unsigned(other.as_secs())?;
43+
let mut secs = self.t.tv_sec.checked_add_unsigned(other.as_secs())?;
4444

4545
// Nano calculations can't overflow because nanos are <1B which fit
4646
// in a u32.
@@ -53,7 +53,7 @@ impl Timespec {
5353
}
5454

5555
fn checked_sub_duration(&self, other: &Duration) -> Option<Timespec> {
56-
let mut secs = self.tv_sec.checked_sub_unsigned(other.as_secs())?;
56+
let mut secs = self.t.tv_sec.checked_sub_unsigned(other.as_secs())?;
5757

5858
// Similar to above, nanos can't overflow.
5959
let mut nsec = self.t.tv_nsec as i32 - other.subsec_nanos() as i32;

src/bootstrap/test.rs

+39-43
Original file line numberDiff line numberDiff line change
@@ -867,46 +867,43 @@ impl Step for RustdocJSStd {
867867
const ONLY_HOSTS: bool = true;
868868

869869
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
870-
run.suite_path("tests/rustdoc-js-std")
870+
let default = run.builder.config.nodejs.is_some();
871+
run.suite_path("tests/rustdoc-js-std").default_condition(default)
871872
}
872873

873874
fn make_run(run: RunConfig<'_>) {
874875
run.builder.ensure(RustdocJSStd { target: run.target });
875876
}
876877

877878
fn run(self, builder: &Builder<'_>) {
878-
if let Some(ref nodejs) = builder.config.nodejs {
879-
let mut command = Command::new(nodejs);
880-
command
881-
.arg(builder.src.join("src/tools/rustdoc-js/tester.js"))
882-
.arg("--crate-name")
883-
.arg("std")
884-
.arg("--resource-suffix")
885-
.arg(&builder.version)
886-
.arg("--doc-folder")
887-
.arg(builder.doc_out(self.target))
888-
.arg("--test-folder")
889-
.arg(builder.src.join("tests/rustdoc-js-std"));
890-
for path in &builder.paths {
891-
if let Some(p) =
892-
util::is_valid_test_suite_arg(path, "tests/rustdoc-js-std", builder)
893-
{
894-
if !p.ends_with(".js") {
895-
eprintln!("A non-js file was given: `{}`", path.display());
896-
panic!("Cannot run rustdoc-js-std tests");
897-
}
898-
command.arg("--test-file").arg(path);
879+
let nodejs =
880+
builder.config.nodejs.as_ref().expect("need nodejs to run rustdoc-js-std tests");
881+
let mut command = Command::new(nodejs);
882+
command
883+
.arg(builder.src.join("src/tools/rustdoc-js/tester.js"))
884+
.arg("--crate-name")
885+
.arg("std")
886+
.arg("--resource-suffix")
887+
.arg(&builder.version)
888+
.arg("--doc-folder")
889+
.arg(builder.doc_out(self.target))
890+
.arg("--test-folder")
891+
.arg(builder.src.join("tests/rustdoc-js-std"));
892+
for path in &builder.paths {
893+
if let Some(p) = util::is_valid_test_suite_arg(path, "tests/rustdoc-js-std", builder) {
894+
if !p.ends_with(".js") {
895+
eprintln!("A non-js file was given: `{}`", path.display());
896+
panic!("Cannot run rustdoc-js-std tests");
899897
}
898+
command.arg("--test-file").arg(path);
900899
}
901-
builder.ensure(crate::doc::Std::new(
902-
builder.top_stage,
903-
self.target,
904-
DocumentationFormat::HTML,
905-
));
906-
builder.run(&mut command);
907-
} else {
908-
builder.info("No nodejs found, skipping \"tests/rustdoc-js-std\" tests");
909900
}
901+
builder.ensure(crate::doc::Std::new(
902+
builder.top_stage,
903+
self.target,
904+
DocumentationFormat::HTML,
905+
));
906+
builder.run(&mut command);
910907
}
911908
}
912909

@@ -922,7 +919,8 @@ impl Step for RustdocJSNotStd {
922919
const ONLY_HOSTS: bool = true;
923920

924921
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
925-
run.suite_path("tests/rustdoc-js")
922+
let default = run.builder.config.nodejs.is_some();
923+
run.suite_path("tests/rustdoc-js").default_condition(default)
926924
}
927925

928926
fn make_run(run: RunConfig<'_>) {
@@ -931,18 +929,14 @@ impl Step for RustdocJSNotStd {
931929
}
932930

933931
fn run(self, builder: &Builder<'_>) {
934-
if builder.config.nodejs.is_some() {
935-
builder.ensure(Compiletest {
936-
compiler: self.compiler,
937-
target: self.target,
938-
mode: "js-doc-test",
939-
suite: "rustdoc-js",
940-
path: "tests/rustdoc-js",
941-
compare_mode: None,
942-
});
943-
} else {
944-
builder.info("No nodejs found, skipping \"tests/rustdoc-js\" tests");
945-
}
932+
builder.ensure(Compiletest {
933+
compiler: self.compiler,
934+
target: self.target,
935+
mode: "js-doc-test",
936+
suite: "rustdoc-js",
937+
path: "tests/rustdoc-js",
938+
compare_mode: None,
939+
});
946940
}
947941
}
948942

@@ -1568,6 +1562,8 @@ note: if you're sure you want to do this, please open an issue as to why. In the
15681562

15691563
if let Some(ref nodejs) = builder.config.nodejs {
15701564
cmd.arg("--nodejs").arg(nodejs);
1565+
} else if mode == "js-doc-test" {
1566+
panic!("need nodejs to run js-doc-test suite");
15711567
}
15721568
if let Some(ref npm) = builder.config.npm {
15731569
cmd.arg("--npm").arg(npm);

src/doc/style-guide/src/items.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl<T: Display, U: Debug> SomeType<T, U> { ...
282282

283283
If the generics clause must be formatted across multiple lines, each parameter
284284
should have its own block-indented line, there should be newlines after the
285-
opening bracket and before the closing bracket, and the should be a trailing
285+
opening bracket and before the closing bracket, and there should be a trailing
286286
comma.
287287

288288
```rust

tests/ui/lint/lint-qualification.stderr

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ note: the lint level is defined here
99
|
1010
LL | #![deny(unused_qualifications)]
1111
| ^^^^^^^^^^^^^^^^^^^^^
12+
help: replace it with the unqualified path
13+
|
14+
LL | bar();
15+
| ~~~
1216

1317
error: aborting due to previous error
1418

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// run-rustfix
2+
3+
#![deny(unused_qualifications)]
4+
5+
mod foo {
6+
pub fn bar() {}
7+
}
8+
9+
mod baz {
10+
pub mod qux {
11+
pub fn quux() {}
12+
}
13+
}
14+
15+
fn main() {
16+
use foo::bar;
17+
bar();
18+
//~^ ERROR unnecessary qualification
19+
20+
use baz::qux::quux;
21+
quux();
22+
//~^ ERROR unnecessary qualification
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// run-rustfix
2+
3+
#![deny(unused_qualifications)]
4+
5+
mod foo {
6+
pub fn bar() {}
7+
}
8+
9+
mod baz {
10+
pub mod qux {
11+
pub fn quux() {}
12+
}
13+
}
14+
15+
fn main() {
16+
use foo::bar;
17+
foo::bar();
18+
//~^ ERROR unnecessary qualification
19+
20+
use baz::qux::quux;
21+
baz::qux::quux();
22+
//~^ ERROR unnecessary qualification
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error: unnecessary qualification
2+
--> $DIR/unused-qualifications-suggestion.rs:17:5
3+
|
4+
LL | foo::bar();
5+
| ^^^^^^^^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/unused-qualifications-suggestion.rs:3:9
9+
|
10+
LL | #![deny(unused_qualifications)]
11+
| ^^^^^^^^^^^^^^^^^^^^^
12+
help: replace it with the unqualified path
13+
|
14+
LL | bar();
15+
| ~~~
16+
17+
error: unnecessary qualification
18+
--> $DIR/unused-qualifications-suggestion.rs:21:5
19+
|
20+
LL | baz::qux::quux();
21+
| ^^^^^^^^^^^^^^
22+
|
23+
help: replace it with the unqualified path
24+
|
25+
LL | quux();
26+
| ~~~~
27+
28+
error: aborting due to 2 previous errors
29+

0 commit comments

Comments
 (0)