review comments
This commit is contained in:
parent
5029a19313
commit
8119c4beee
4 changed files with 11 additions and 11 deletions
|
@ -241,7 +241,7 @@ pub struct ConstQualifs {
|
||||||
pub has_mut_interior: bool,
|
pub has_mut_interior: bool,
|
||||||
pub needs_drop: bool,
|
pub needs_drop: bool,
|
||||||
pub custom_eq: 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
|
/// After we borrow check a closure, we are left with various
|
||||||
|
|
|
@ -282,9 +282,8 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
|
||||||
);
|
);
|
||||||
return Err(ErrorHandled::Reported(ErrorReported {}));
|
return Err(ErrorHandled::Reported(ErrorReported {}));
|
||||||
}
|
}
|
||||||
let qualif = tcx.mir_const_qualif_opt_const_arg(def);
|
if let Some(error_reported) = tcx.mir_const_qualif_opt_const_arg(def).error_occured {
|
||||||
if qualif.error_occured {
|
return Err(ErrorHandled::Reported(error_reported));
|
||||||
return Err(ErrorHandled::Reported(ErrorReported {}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See the `Qualif` trait for more info.
|
//! See the `Qualif` trait for more info.
|
||||||
|
|
||||||
|
use rustc_errors::ErrorReported;
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
use rustc_middle::ty::{self, subst::SubstsRef, AdtDef, Ty};
|
use rustc_middle::ty::{self, subst::SubstsRef, AdtDef, Ty};
|
||||||
use rustc_span::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
|
@ -12,7 +13,7 @@ use super::ConstCx;
|
||||||
pub fn in_any_value_of_ty(
|
pub fn in_any_value_of_ty(
|
||||||
cx: &ConstCx<'_, 'tcx>,
|
cx: &ConstCx<'_, 'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
error_occured: bool,
|
error_occured: Option<ErrorReported>,
|
||||||
) -> ConstQualifs {
|
) -> ConstQualifs {
|
||||||
ConstQualifs {
|
ConstQualifs {
|
||||||
has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty),
|
has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations.
|
//! 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::def_id::DefId;
|
||||||
use rustc_hir::{self as hir, HirId, LangItem};
|
use rustc_hir::{self as hir, HirId, LangItem};
|
||||||
use rustc_infer::infer::TyCtxtInferExt;
|
use rustc_infer::infer::TyCtxtInferExt;
|
||||||
|
@ -126,7 +126,7 @@ impl Qualifs<'mir, 'tcx> {
|
||||||
fn in_return_place(
|
fn in_return_place(
|
||||||
&mut self,
|
&mut self,
|
||||||
ccx: &'mir ConstCx<'mir, 'tcx>,
|
ccx: &'mir ConstCx<'mir, 'tcx>,
|
||||||
error_occured: bool,
|
error_occured: Option<ErrorReported>,
|
||||||
) -> ConstQualifs {
|
) -> ConstQualifs {
|
||||||
// Find the `Return` terminator if one exists.
|
// Find the `Return` terminator if one exists.
|
||||||
//
|
//
|
||||||
|
@ -186,7 +186,7 @@ pub struct Validator<'mir, 'tcx> {
|
||||||
/// The span of the current statement.
|
/// The span of the current statement.
|
||||||
span: Span,
|
span: Span,
|
||||||
|
|
||||||
error_emitted: bool,
|
error_emitted: Option<ErrorReported>,
|
||||||
secondary_errors: Vec<Diagnostic>,
|
secondary_errors: Vec<Diagnostic>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ impl Validator<'mir, 'tcx> {
|
||||||
span: ccx.body.span,
|
span: ccx.body.span,
|
||||||
ccx,
|
ccx,
|
||||||
qualifs: Default::default(),
|
qualifs: Default::default(),
|
||||||
error_emitted: false,
|
error_emitted: None,
|
||||||
secondary_errors: Vec::new(),
|
secondary_errors: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ impl Validator<'mir, 'tcx> {
|
||||||
// If we got through const-checking without emitting any "primary" errors, emit any
|
// If we got through const-checking without emitting any "primary" errors, emit any
|
||||||
// "secondary" errors if they occurred.
|
// "secondary" errors if they occurred.
|
||||||
let secondary_errors = mem::take(&mut self.secondary_errors);
|
let secondary_errors = mem::take(&mut self.secondary_errors);
|
||||||
if !self.error_emitted {
|
if self.error_emitted.is_none() {
|
||||||
for error in secondary_errors {
|
for error in secondary_errors {
|
||||||
self.tcx.sess.diagnostic().emit_diagnostic(&error);
|
self.tcx.sess.diagnostic().emit_diagnostic(&error);
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ impl Validator<'mir, 'tcx> {
|
||||||
|
|
||||||
match op.importance() {
|
match op.importance() {
|
||||||
ops::DiagnosticImportance::Primary => {
|
ops::DiagnosticImportance::Primary => {
|
||||||
self.error_emitted = true;
|
self.error_emitted = Some(ErrorReported);
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue