Skip to content

Commit

Permalink
Rollup merge of rust-lang#83705 - jyn514:theme-error, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Give a better error when --theme is not a CSS file

Before:

```
error: invalid argument: "bacon.toml"
```

After:
```
error: invalid argument: "bacon.toml"
  |
  = help: arguments to --theme must be CSS files
```

cc rust-lang#83478
  • Loading branch information
Dylan-DPC committed Apr 5, 2021
2 parents 335a3c4 + 29eb686 commit a766d63
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ impl Options {
return Err(1);
}
if theme_file.extension() != Some(OsStr::new("css")) {
diag.struct_err(&format!("invalid argument: \"{}\"", theme_s)).emit();
diag.struct_err(&format!("invalid argument: \"{}\"", theme_s))
.help("arguments to --theme must have a .css extension")
.emit();
return Err(1);
}
let (success, ret) = theme::test_theme_against(&theme_file, &paths, &diag);
Expand Down
3 changes: 3 additions & 0 deletions src/test/rustdoc-ui/invalid-theme-name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// compile-flags:--theme {{src-base}}/invalid-theme-name.rs
// error-pattern: invalid argument
// error-pattern: must have a .css extension
4 changes: 4 additions & 0 deletions src/test/rustdoc-ui/invalid-theme-name.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
error: invalid argument: "$DIR/invalid-theme-name.rs"
|
= help: arguments to --theme must have a .css extension

3 changes: 1 addition & 2 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1909,8 +1909,7 @@ impl<'test> TestCx<'test> {
} else {
Command::new(&self.config.rustdoc_path.clone().expect("no rustdoc built yet"))
};
// FIXME Why is -L here?
rustc.arg(input_file); //.arg("-L").arg(&self.config.build_base);
rustc.arg(input_file);

// Use a single thread for efficiency and a deterministic error message order
rustc.arg("-Zthreads=1");
Expand Down

0 comments on commit a766d63

Please sign in to comment.