]> git.lizzy.rs Git - rust.git/commitdiff
review comments
authorVishnunarayan K I <appukuttancr@gmail.com>
Tue, 10 Nov 2020 09:29:44 +0000 (14:59 +0530)
committerVishnunarayan K I <appukuttancr@gmail.com>
Thu, 12 Nov 2020 15:38:18 +0000 (21:08 +0530)
compiler/rustc_middle/src/mir/query.rs
compiler/rustc_mir/src/const_eval/eval_queries.rs
compiler/rustc_mir/src/transform/check_consts/qualifs.rs
compiler/rustc_mir/src/transform/check_consts/validation.rs

index b0311400e77e25b4f9c14c23a3a9d66db928c78b..db0056e482be06bf89890d3e408ce90bd9514ab0 100644 (file)
@@ -241,7 +241,7 @@ pub struct ConstQualifs {
     pub has_mut_interior: bool,
     pub needs_drop: bool,
     pub custom_eq: bool,
-    pub error_occured: bool,
+    pub error_occured: Option<ErrorReported>,
 }
 
 /// After we borrow check a closure, we are left with various
index 1fc3fd9be2b657c845ac8e1cae6fa753d843c4be..6e09ae43406456ea78a49de1daae97f7e4e91c43 100644 (file)
@@ -282,9 +282,8 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
             );
             return Err(ErrorHandled::Reported(ErrorReported {}));
         }
-        let qualif = tcx.mir_const_qualif_opt_const_arg(def);
-        if qualif.error_occured {
-            return Err(ErrorHandled::Reported(ErrorReported {}));
+        if let Some(error_reported) = tcx.mir_const_qualif_opt_const_arg(def).error_occured {
+            return Err(ErrorHandled::Reported(error_reported));
         }
     }
 
index 129985543a0d826d8c49780c4ab45467e19777b0..c66d3ed76df904190ddfc9d94774e5213132229e 100644 (file)
@@ -2,6 +2,7 @@
 //!
 //! See the `Qualif` trait for more info.
 
+use rustc_errors::ErrorReported;
 use rustc_middle::mir::*;
 use rustc_middle::ty::{self, subst::SubstsRef, AdtDef, Ty};
 use rustc_span::DUMMY_SP;
@@ -12,7 +13,7 @@
 pub fn in_any_value_of_ty(
     cx: &ConstCx<'_, 'tcx>,
     ty: Ty<'tcx>,
-    error_occured: bool,
+    error_occured: Option<ErrorReported>,
 ) -> ConstQualifs {
     ConstQualifs {
         has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty),
index ab65bc5a338beba4143948ffa8d1b73f812aabf8..e4893044a159933cabf2b6c5e323d508ece31145 100644 (file)
@@ -1,6 +1,6 @@
 //! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations.
 
-use rustc_errors::{struct_span_err, Applicability, Diagnostic};
+use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorReported};
 use rustc_hir::def_id::DefId;
 use rustc_hir::{self as hir, HirId, LangItem};
 use rustc_infer::infer::TyCtxtInferExt;
@@ -126,7 +126,7 @@ pub fn has_mut_interior(
     fn in_return_place(
         &mut self,
         ccx: &'mir ConstCx<'mir, 'tcx>,
-        error_occured: bool,
+        error_occured: Option<ErrorReported>,
     ) -> ConstQualifs {
         // Find the `Return` terminator if one exists.
         //
@@ -186,7 +186,7 @@ pub struct Validator<'mir, 'tcx> {
     /// The span of the current statement.
     span: Span,
 
-    error_emitted: bool,
+    error_emitted: Option<ErrorReported>,
     secondary_errors: Vec<Diagnostic>,
 }
 
@@ -204,7 +204,7 @@ pub fn new(ccx: &'mir ConstCx<'mir, 'tcx>) -> Self {
             span: ccx.body.span,
             ccx,
             qualifs: Default::default(),
-            error_emitted: false,
+            error_emitted: None,
             secondary_errors: Vec::new(),
         }
     }
@@ -271,7 +271,7 @@ pub fn check_body(&mut self) {
         // If we got through const-checking without emitting any "primary" errors, emit any
         // "secondary" errors if they occurred.
         let secondary_errors = mem::take(&mut self.secondary_errors);
-        if !self.error_emitted {
+        if self.error_emitted.is_none() {
             for error in secondary_errors {
                 self.tcx.sess.diagnostic().emit_diagnostic(&error);
             }
@@ -323,7 +323,7 @@ pub fn check_op_spanned<O: NonConstOp>(&mut self, op: O, span: Span) {
 
         match op.importance() {
             ops::DiagnosticImportance::Primary => {
-                self.error_emitted = true;
+                self.error_emitted = Some(ErrorReported);
                 err.emit();
             }