Be smarter about error handling in run()
.
`run()` returns `Result<(), String>`. But on failure it always returns an empty string, and then `wrap_return()` treats an empty string specially, by not reporting the error. It turns out we already have the `ErrorReported` type for this sort of behaviour. This commit changes `run()` to use it.
This commit is contained in:
parent
af4e3e08ea
commit
5f8a11279d
2 changed files with 4 additions and 6 deletions
|
@ -443,9 +443,7 @@ fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> MainRes
|
|||
match res {
|
||||
Ok(()) => Ok(()),
|
||||
Err(err) => {
|
||||
if !err.is_empty() {
|
||||
diag.struct_err(&err).emit();
|
||||
}
|
||||
diag.struct_err(&err).emit();
|
||||
Err(ErrorReported)
|
||||
}
|
||||
}
|
||||
|
@ -478,7 +476,7 @@ fn main_options(options: config::Options) -> MainResult {
|
|||
|
||||
match (options.should_test, options.markdown_input()) {
|
||||
(true, true) => return wrap_return(&diag, markdown::test(options)),
|
||||
(true, false) => return wrap_return(&diag, test::run(options)),
|
||||
(true, false) => return test::run(options),
|
||||
(false, true) => {
|
||||
return wrap_return(
|
||||
&diag,
|
||||
|
|
|
@ -42,7 +42,7 @@ pub struct TestOptions {
|
|||
pub attrs: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn run(options: Options) -> Result<(), String> {
|
||||
pub fn run(options: Options) -> Result<(), ErrorReported> {
|
||||
let input = config::Input::File(options.input.clone());
|
||||
|
||||
let invalid_codeblock_attributes_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;
|
||||
|
@ -150,7 +150,7 @@ pub fn run(options: Options) -> Result<(), String> {
|
|||
});
|
||||
let tests = match tests {
|
||||
Ok(tests) => tests,
|
||||
Err(ErrorReported) => return Err(String::new()),
|
||||
Err(ErrorReported) => return Err(ErrorReported),
|
||||
};
|
||||
|
||||
test_args.insert(0, "rustdoctest".to_string());
|
||||
|
|
Loading…
Reference in a new issue