Skip to content

Commit

Permalink
Get --fix working for everything except rustdoc
Browse files Browse the repository at this point in the history
Here's the error for rustdoc:

```
Checking rustdoc artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
error: no library targets found in package `rustdoc-tool`
```
  • Loading branch information
jyn514 committed Nov 5, 2020
1 parent 31ecd2a commit 8d2fa72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,8 @@ impl<'a> Builder<'a> {
}
rustflags.env("RUSTFLAGS_BOOTSTRAP");
if cmd == "clippy" {
// clippy overwrites any sysroot we pass on the command line.
// Tell it to use the appropriate sysroot instead.
// clippy overwrites sysroot if we pass it to cargo.
// Pass it directly to clippy instead.
// NOTE: this can't be fixed in clippy because we explicitly don't set `RUSTC`,
// so it has no way of knowing the sysroot.
rustflags.arg("--sysroot");
Expand All @@ -867,8 +867,7 @@ impl<'a> Builder<'a> {
// Explicitly does *not* set `--cfg=bootstrap`, since we're using a nightly clippy.
let host_version = Command::new("rustc").arg("--version").output().map_err(|_| ());
let output = host_version.and_then(|output| {
if output.status.success()
{
if output.status.success() {
Ok(output)
} else {
Err(())
Expand Down
17 changes: 14 additions & 3 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,23 @@ pub struct Std {

/// Returns args for the subcommand itself (not for cargo)
fn args(builder: &Builder<'_>) -> Vec<String> {
fn strings<'a>(arr: &'a [&str]) -> impl Iterator<Item = String> + 'a {
arr.iter().copied().map(String::from)
}

if let Subcommand::Clippy { fix, .. } = builder.config.cmd {
let mut args = vec!["--".to_owned(), "--cap-lints".to_owned(), "warn".to_owned()];
let mut args = vec![];
if fix {
args.insert(0, "--fix".to_owned());
args.insert(0, "-Zunstable-options".to_owned());
#[rustfmt::skip]
args.extend(strings(&[
"--fix", "-Zunstable-options",
// FIXME: currently, `--fix` gives an error while checking tests for libtest,
// possibly because libtest is not yet built in the sysroot.
// As a workaround, avoid checking tests and benches when passed --fix.
"--lib", "--bins", "--examples",
]));
}
args.extend(strings(&["--", "--cap-lints", "warn"]));
args
} else {
vec![]
Expand Down

0 comments on commit 8d2fa72

Please sign in to comment.