From 29c2bb51c0b82bed1322a18566fb659c1846d136 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 7 Feb 2022 22:37:32 -0800 Subject: rework borrowck errors so that it's harder to not set tainted --- compiler/rustc_const_eval/src/const_eval/eval_queries.rs | 4 ++-- compiler/rustc_const_eval/src/interpret/eval_context.rs | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'compiler/rustc_const_eval/src') diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 7235b8416ad..df08b541801 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -287,8 +287,8 @@ pub fn eval_to_allocation_raw_provider<'tcx>( if let Some(error_reported) = tcx.typeck_opt_const_arg(def).tainted_by_errors { return Err(ErrorHandled::Reported(error_reported)); } - if tcx.mir_borrowck_opt_const_arg(def).tainted_by_errors { - return Err(ErrorHandled::Reported(ErrorReported {})); + if let Some(error_reported) = tcx.mir_borrowck_opt_const_arg(def).tainted_by_errors { + return Err(ErrorHandled::Reported(error_reported)); } } if !tcx.is_mir_available(def.did) { diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 00c066a2851..022127de65a 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -516,8 +516,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { if let Some(error_reported) = self.tcx.typeck_opt_const_arg(def).tainted_by_errors { throw_inval!(AlreadyReported(error_reported)); } - if self.tcx.mir_borrowck_opt_const_arg(def).tainted_by_errors { - throw_inval!(AlreadyReported(rustc_errors::ErrorReported {})); + if let Some(error_reported) = + self.tcx.mir_borrowck_opt_const_arg(def).tainted_by_errors + { + throw_inval!(AlreadyReported(error_reported)); } } } -- cgit 1.4.1-3-g733a5