Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0c56372

Browse files
committedNov 10, 2020
review comments
1 parent b3fc46c commit 0c56372

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed
 

‎compiler/rustc_middle/src/mir/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ pub struct ConstQualifs {
241241
pub has_mut_interior: bool,
242242
pub needs_drop: bool,
243243
pub custom_eq: bool,
244-
pub error_occured: bool,
244+
pub error_occured: Option<ErrorReported>,
245245
}
246246

247247
/// After we borrow check a closure, we are left with various

‎compiler/rustc_mir/src/const_eval/eval_queries.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,8 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
282282
);
283283
return Err(ErrorHandled::Reported(ErrorReported {}));
284284
}
285-
let qualif = tcx.mir_const_qualif_opt_const_arg(def);
286-
if qualif.error_occured {
287-
return Err(ErrorHandled::Reported(ErrorReported {}));
285+
if let Some(error_reported) = tcx.mir_const_qualif_opt_const_arg(def).error_occured {
286+
return Err(ErrorHandled::Reported(error_reported));
288287
}
289288
}
290289

‎compiler/rustc_mir/src/transform/check_consts/qualifs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//!
33
//! See the `Qualif` trait for more info.
44
5+
use rustc_errors::ErrorReported;
56
use rustc_middle::mir::*;
67
use rustc_middle::ty::{self, subst::SubstsRef, AdtDef, Ty};
78
use rustc_span::DUMMY_SP;
@@ -12,7 +13,7 @@ use super::ConstCx;
1213
pub fn in_any_value_of_ty(
1314
cx: &ConstCx<'_, 'tcx>,
1415
ty: Ty<'tcx>,
15-
error_occured: bool,
16+
error_occured: Option<ErrorReported>,
1617
) -> ConstQualifs {
1718
ConstQualifs {
1819
has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty),

‎compiler/rustc_mir/src/transform/check_consts/validation.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations.
22
3-
use rustc_errors::{struct_span_err, Applicability, Diagnostic};
3+
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorReported};
44
use rustc_hir::def_id::DefId;
55
use rustc_hir::{self as hir, HirId, LangItem};
66
use rustc_infer::infer::TyCtxtInferExt;
@@ -126,7 +126,7 @@ impl Qualifs<'mir, 'tcx> {
126126
fn in_return_place(
127127
&mut self,
128128
ccx: &'mir ConstCx<'mir, 'tcx>,
129-
error_occured: bool,
129+
error_occured: Option<ErrorReported>,
130130
) -> ConstQualifs {
131131
// Find the `Return` terminator if one exists.
132132
//
@@ -186,7 +186,7 @@ pub struct Validator<'mir, 'tcx> {
186186
/// The span of the current statement.
187187
span: Span,
188188

189-
error_emitted: bool,
189+
error_emitted: Option<ErrorReported>,
190190
secondary_errors: Vec<Diagnostic>,
191191
}
192192

@@ -204,7 +204,7 @@ impl Validator<'mir, 'tcx> {
204204
span: ccx.body.span,
205205
ccx,
206206
qualifs: Default::default(),
207-
error_emitted: false,
207+
error_emitted: None,
208208
secondary_errors: Vec::new(),
209209
}
210210
}
@@ -271,7 +271,7 @@ impl Validator<'mir, 'tcx> {
271271
// If we got through const-checking without emitting any "primary" errors, emit any
272272
// "secondary" errors if they occurred.
273273
let secondary_errors = mem::take(&mut self.secondary_errors);
274-
if !self.error_emitted {
274+
if self.error_emitted.is_none() {
275275
for error in secondary_errors {
276276
self.tcx.sess.diagnostic().emit_diagnostic(&error);
277277
}
@@ -323,7 +323,7 @@ impl Validator<'mir, 'tcx> {
323323

324324
match op.importance() {
325325
ops::DiagnosticImportance::Primary => {
326-
self.error_emitted = true;
326+
self.error_emitted = Some(ErrorReported);
327327
err.emit();
328328
}
329329

0 commit comments

Comments
 (0)
Please sign in to comment.