Skip to content

Commit

Permalink
Auto merge of rust-lang#113676 - matthiaskrgr:rollup-n01iiy8, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

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
  • Loading branch information
bors committed Jul 14, 2023
2 parents 7bd81ee + aa2002e commit 7a5814f
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 58 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1529,9 +1529,9 @@ dependencies = [

[[package]]
name = "hermit-abi"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-alloc",
Expand Down Expand Up @@ -1864,7 +1864,7 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
dependencies = [
"hermit-abi 0.3.1",
"hermit-abi 0.3.2",
"libc",
"windows-sys 0.48.0",
]
Expand All @@ -1881,7 +1881,7 @@ version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24fddda5af7e54bf7da53067d6e802dbcc381d0a8eef629df528e3ebf68755cb"
dependencies = [
"hermit-abi 0.3.1",
"hermit-abi 0.3.2",
"rustix 0.38.2",
"windows-sys 0.48.0",
]
Expand Down Expand Up @@ -2396,7 +2396,7 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
dependencies = [
"hermit-abi 0.3.1",
"hermit-abi 0.3.2",
"libc",
]

Expand Down Expand Up @@ -4819,7 +4819,7 @@ dependencies = [
"dlmalloc",
"fortanix-sgx-abi",
"hashbrown 0.14.0",
"hermit-abi 0.3.1",
"hermit-abi 0.3.2",
"libc",
"miniz_oxide",
"object",
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,14 @@ pub trait LintContext: Sized {
db.span_note(glob_reexport_span, format!("the name `{}` in the {} namespace is supposed to be publicly re-exported here", name, namespace));
db.span_note(private_item_span, "but the private item here shadows it".to_owned());
}
BuiltinLintDiagnostics::UnusedQualifications { path_span, unqualified_path } => {
db.span_suggestion_verbose(
path_span,
"replace it with the unqualified path",
unqualified_path,
Applicability::MachineApplicable
);
}
}
// Rewrap `db`, and pass control to the user.
decorate(db)
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,12 @@ pub enum BuiltinLintDiagnostics {
/// The local binding that shadows the glob reexport.
private_item_span: Span,
},
UnusedQualifications {
/// The span of the unnecessarily-qualified path.
path_span: Span,
/// The replacement unqualified path.
unqualified_path: Ident,
},
}

/// Lints that are buffered up early on in the `Session` before the
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3922,11 +3922,15 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
};
if res == unqualified_result {
let lint = lint::builtin::UNUSED_QUALIFICATIONS;
self.r.lint_buffer.buffer_lint(
self.r.lint_buffer.buffer_lint_with_diagnostic(
lint,
finalize.node_id,
finalize.path_span,
"unnecessary qualification",
lint::BuiltinLintDiagnostics::UnusedQualifications {
path_span: finalize.path_span,
unqualified_path: path.last().unwrap().ident
}
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dlmalloc = { version = "0.2.3", features = ['rustc-dep-of-std'] }
fortanix-sgx-abi = { version = "0.5.0", features = ['rustc-dep-of-std'], public = true }

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

[target.wasm32-wasi.dependencies]
wasi = { version = "0.11.0", features = ['rustc-dep-of-std'], default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ use super::map::{map_try_reserve_error, RandomState};
/// ```
///
/// The easiest way to use `HashSet` with a custom type is to derive
/// [`Eq`] and [`Hash`]. We must also derive [`PartialEq`], this will in the
/// future be implied by [`Eq`].
/// [`Eq`] and [`Hash`]. We must also derive [`PartialEq`],
/// which is required if [`Eq`] is derived.
///
/// ```
/// use std::collections::HashSet;
Expand Down
3 changes: 1 addition & 2 deletions library/std/src/sys/hermit/thread.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(dead_code)]

use super::unsupported;
use crate::ffi::CStr;
use crate::io;
use crate::mem;
Expand Down Expand Up @@ -99,7 +98,7 @@ impl Thread {
}

pub fn available_parallelism() -> io::Result<NonZeroUsize> {
unsupported()
unsafe { Ok(NonZeroUsize::new_unchecked(abi::get_processor_count())) }
}

pub mod guard {
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sys/hermit/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Timespec {
}

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

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

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

// Similar to above, nanos can't overflow.
let mut nsec = self.t.tv_nsec as i32 - other.subsec_nanos() as i32;
Expand Down
82 changes: 39 additions & 43 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,46 +867,43 @@ impl Step for RustdocJSStd {
const ONLY_HOSTS: bool = true;

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

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

fn run(self, builder: &Builder<'_>) {
if let Some(ref nodejs) = builder.config.nodejs {
let mut command = Command::new(nodejs);
command
.arg(builder.src.join("src/tools/rustdoc-js/tester.js"))
.arg("--crate-name")
.arg("std")
.arg("--resource-suffix")
.arg(&builder.version)
.arg("--doc-folder")
.arg(builder.doc_out(self.target))
.arg("--test-folder")
.arg(builder.src.join("tests/rustdoc-js-std"));
for path in &builder.paths {
if let Some(p) =
util::is_valid_test_suite_arg(path, "tests/rustdoc-js-std", builder)
{
if !p.ends_with(".js") {
eprintln!("A non-js file was given: `{}`", path.display());
panic!("Cannot run rustdoc-js-std tests");
}
command.arg("--test-file").arg(path);
let nodejs =
builder.config.nodejs.as_ref().expect("need nodejs to run rustdoc-js-std tests");
let mut command = Command::new(nodejs);
command
.arg(builder.src.join("src/tools/rustdoc-js/tester.js"))
.arg("--crate-name")
.arg("std")
.arg("--resource-suffix")
.arg(&builder.version)
.arg("--doc-folder")
.arg(builder.doc_out(self.target))
.arg("--test-folder")
.arg(builder.src.join("tests/rustdoc-js-std"));
for path in &builder.paths {
if let Some(p) = util::is_valid_test_suite_arg(path, "tests/rustdoc-js-std", builder) {
if !p.ends_with(".js") {
eprintln!("A non-js file was given: `{}`", path.display());
panic!("Cannot run rustdoc-js-std tests");
}
command.arg("--test-file").arg(path);
}
builder.ensure(crate::doc::Std::new(
builder.top_stage,
self.target,
DocumentationFormat::HTML,
));
builder.run(&mut command);
} else {
builder.info("No nodejs found, skipping \"tests/rustdoc-js-std\" tests");
}
builder.ensure(crate::doc::Std::new(
builder.top_stage,
self.target,
DocumentationFormat::HTML,
));
builder.run(&mut command);
}
}

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

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

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

fn run(self, builder: &Builder<'_>) {
if builder.config.nodejs.is_some() {
builder.ensure(Compiletest {
compiler: self.compiler,
target: self.target,
mode: "js-doc-test",
suite: "rustdoc-js",
path: "tests/rustdoc-js",
compare_mode: None,
});
} else {
builder.info("No nodejs found, skipping \"tests/rustdoc-js\" tests");
}
builder.ensure(Compiletest {
compiler: self.compiler,
target: self.target,
mode: "js-doc-test",
suite: "rustdoc-js",
path: "tests/rustdoc-js",
compare_mode: None,
});
}
}

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

if let Some(ref nodejs) = builder.config.nodejs {
cmd.arg("--nodejs").arg(nodejs);
} else if mode == "js-doc-test" {
panic!("need nodejs to run js-doc-test suite");
}
if let Some(ref npm) = builder.config.npm {
cmd.arg("--npm").arg(npm);
Expand Down
2 changes: 1 addition & 1 deletion src/doc/style-guide/src/items.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl<T: Display, U: Debug> SomeType<T, U> { ...

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

```rust
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/lint/lint-qualification.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ note: the lint level is defined here
|
LL | #![deny(unused_qualifications)]
| ^^^^^^^^^^^^^^^^^^^^^
help: replace it with the unqualified path
|
LL | bar();
| ~~~

error: aborting due to previous error

23 changes: 23 additions & 0 deletions tests/ui/resolve/unused-qualifications-suggestion.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// run-rustfix

#![deny(unused_qualifications)]

mod foo {
pub fn bar() {}
}

mod baz {
pub mod qux {
pub fn quux() {}
}
}

fn main() {
use foo::bar;
bar();
//~^ ERROR unnecessary qualification

use baz::qux::quux;
quux();
//~^ ERROR unnecessary qualification
}
23 changes: 23 additions & 0 deletions tests/ui/resolve/unused-qualifications-suggestion.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// run-rustfix

#![deny(unused_qualifications)]

mod foo {
pub fn bar() {}
}

mod baz {
pub mod qux {
pub fn quux() {}
}
}

fn main() {
use foo::bar;
foo::bar();
//~^ ERROR unnecessary qualification

use baz::qux::quux;
baz::qux::quux();
//~^ ERROR unnecessary qualification
}
29 changes: 29 additions & 0 deletions tests/ui/resolve/unused-qualifications-suggestion.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
error: unnecessary qualification
--> $DIR/unused-qualifications-suggestion.rs:17:5
|
LL | foo::bar();
| ^^^^^^^^
|
note: the lint level is defined here
--> $DIR/unused-qualifications-suggestion.rs:3:9
|
LL | #![deny(unused_qualifications)]
| ^^^^^^^^^^^^^^^^^^^^^
help: replace it with the unqualified path
|
LL | bar();
| ~~~

error: unnecessary qualification
--> $DIR/unused-qualifications-suggestion.rs:21:5
|
LL | baz::qux::quux();
| ^^^^^^^^^^^^^^
|
help: replace it with the unqualified path
|
LL | quux();
| ~~~~

error: aborting due to 2 previous errors

0 comments on commit 7a5814f

Please sign in to comment.