Skip to content

Commit 6a25bfa

Browse files
committed
Don't silently ignore errors that happen during rendering
This caught a real, existing bug.
1 parent 8841bee commit 6a25bfa

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ fn run_renderer<'tcx, T: formats::FormatRenderer<'tcx>>(
689689
tcx: TyCtxt<'tcx>,
690690
) -> MainResult {
691691
match formats::run_format::<T>(krate, renderopts, cache, tcx) {
692-
Ok(_) => Ok(()),
692+
Ok(_) => tcx.sess.has_errors().map_or(Ok(()), Err),
693693
Err(e) => {
694694
let mut msg =
695695
tcx.sess.struct_err(&format!("couldn't generate documentation: {}", e.error));

src/test/rustdoc/const-evalutation-ice.rs renamed to src/test/rustdoc-ui/const-evalutation-ice.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ pub struct S {
88
}
99

1010
pub const N: usize = 0 - (mem::size_of::<S>() != 4) as usize;
11+
//~^ ERROR evaluation of constant value failed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0080]: evaluation of constant value failed
2+
--> $DIR/const-evalutation-ice.rs:10:22
3+
|
4+
LL | pub const N: usize = 0 - (mem::size_of::<S>() != 4) as usize;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)