diff options
| author | bors <bors@rust-lang.org> | 2020-04-17 11:52:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-04-17 11:52:01 +0000 |
| commit | 8d67f576b56e8fc98a31123e5963f8d00e40611c (patch) | |
| tree | 41ca42929c30c4fe7da7021b9f4dc7355e7ffe47 /src/librustc_trait_selection | |
| parent | b2c1a606feb1fbdb0ac0acba76f881ef172ed474 (diff) | |
| parent | 77f38dc284c3adab8c529e478fe8b2fa5e4a82d3 (diff) | |
| download | rust-8d67f576b56e8fc98a31123e5963f8d00e40611c.tar.gz rust-8d67f576b56e8fc98a31123e5963f8d00e40611c.zip | |
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
Diffstat (limited to 'src/librustc_trait_selection')
| -rw-r--r-- | src/librustc_trait_selection/opaque_types.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trait_selection/traits/error_reporting/mod.rs | 15 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/librustc_trait_selection/opaque_types.rs b/src/librustc_trait_selection/opaque_types.rs index 0cb26e08228..f67b8b87ced 100644 --- a/src/librustc_trait_selection/opaque_types.rs +++ b/src/librustc_trait_selection/opaque_types.rs @@ -972,7 +972,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> { ) .emit(); - self.tcx().consts.err + self.tcx().mk_const(ty::Const { val: ty::ConstKind::Error, ty: ct.ty }) } } } diff --git a/src/librustc_trait_selection/traits/error_reporting/mod.rs b/src/librustc_trait_selection/traits/error_reporting/mod.rs index 144812e3923..8a9017960fb 100644 --- a/src/librustc_trait_selection/traits/error_reporting/mod.rs +++ b/src/librustc_trait_selection/traits/error_reporting/mod.rs @@ -12,7 +12,7 @@ use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCod use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use crate::infer::{self, InferCtxt, TyCtxtInferExt}; use rustc_data_structures::fx::FxHashMap; -use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; +use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, ErrorReported}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_hir::{Node, QPath, TyKind, WhereBoundPredicate, WherePredicate}; @@ -674,8 +674,17 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } // Already reported in the query. - ConstEvalFailure(ErrorHandled::Reported) => { - self.tcx.sess.delay_span_bug(span, "constant in type had an ignored error"); + ConstEvalFailure(ErrorHandled::Reported(ErrorReported)) => { + // FIXME(eddyb) remove this once `ErrorReported` becomes a proof token. + self.tcx.sess.delay_span_bug(span, "`ErrorReported` without an error"); + return; + } + + // Already reported in the query, but only as a lint. + // This shouldn't actually happen for constants used in types, modulo + // bugs. The `delay_span_bug` here ensures it won't be ignored. + ConstEvalFailure(ErrorHandled::Linted) => { + self.tcx.sess.delay_span_bug(span, "constant in type had error reported as lint"); return; } |
