Skip to content

Commit 8d67f57

Browse files
committedApr 17, 2020
Auto merge of #71049 - eddyb:const-err, r=oli-obk
Add `ConstKind::Error` and convert `ErrorHandled::Reported` to it. By replicating the `ty::Error` approach to encoding "an error has occurred", all of the mechanisms that skip redundant/downstream errors are engaged and help out (see the reduction in test output). This PR also adds `ErrorHandled::Linted` for the lint case because using `ErrorHandled::Reported` *without* having emitted an error that is *guaranteed* to stop compilation, is incorrect now. r? @oli-obk cc @rust-lang/wg-const-eval @varkor @yodaldevoid
2 parents b2c1a60 + 77f38dc commit 8d67f57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+193
-408
lines changed
 

‎src/librustc_codegen_ssa/mir/operand.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::glue;
66
use crate::traits::*;
77
use crate::MemFlags;
88

9+
use rustc_errors::ErrorReported;
910
use rustc_middle::mir;
1011
use rustc_middle::mir::interpret::{ConstValue, ErrorHandled, Pointer, Scalar};
1112
use rustc_middle::ty::layout::TyAndLayout;
@@ -447,8 +448,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
447448
self.eval_mir_constant_to_operand(bx, constant).unwrap_or_else(|err| {
448449
match err {
449450
// errored or at least linted
450-
ErrorHandled::Reported => {}
451-
ErrorHandled::TooGeneric => bug!("codgen encountered polymorphic constant"),
451+
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => {}
452+
ErrorHandled::TooGeneric => {
453+
bug!("codegen encountered polymorphic constant")
454+
}
452455
}
453456
// Allow RalfJ to sleep soundly knowing that even refactorings that remove
454457
// the above error (or silence it under some conditions) will not cause UB.

‎src/librustc_infer/infer/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ pub fn unexpected_hidden_region_diagnostic(
304304
// down this path which gives a decent human readable
305305
// explanation.
306306
//
307-
// (*) if not, the `tainted_by_errors` flag would be set to
308-
// true in any case, so we wouldn't be here at all.
307+
// (*) if not, the `tainted_by_errors` field would be set to
308+
// `Some(ErrorReported)` in any case, so we wouldn't be here at all.
309309
note_and_explain_free_region(
310310
tcx,
311311
&mut err,

0 commit comments

Comments
 (0)
Please sign in to comment.