Skip to content

Commit

Permalink
Rollup merge of rust-lang#104995 - jyn514:lint-errors, r=Manishearth
Browse files Browse the repository at this point in the history
Don't silently ignore errors that happen during rendering

This caught a real, existing bug.

Found in rust-lang#104994
  • Loading branch information
matthiaskrgr committed Nov 29, 2022
2 parents de1af83 + 6a25bfa commit 8937a2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ fn run_renderer<'tcx, T: formats::FormatRenderer<'tcx>>(
tcx: TyCtxt<'tcx>,
) -> MainResult {
match formats::run_format::<T>(krate, renderopts, cache, tcx) {
Ok(_) => Ok(()),
Ok(_) => tcx.sess.has_errors().map_or(Ok(()), Err),
Err(e) => {
let mut msg =
tcx.sess.struct_err(&format!("couldn't generate documentation: {}", e.error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pub struct S {
}

pub const N: usize = 0 - (mem::size_of::<S>() != 4) as usize;
//~^ ERROR evaluation of constant value failed
9 changes: 9 additions & 0 deletions src/test/rustdoc-ui/const-evalutation-ice.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0080]: evaluation of constant value failed
--> $DIR/const-evalutation-ice.rs:10:22
|
LL | pub const N: usize = 0 - (mem::size_of::<S>() != 4) as usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.

0 comments on commit 8937a2e

Please sign in to comment.