@@ -176,6 +176,8 @@ pub struct Validator<'mir, 'tcx> {
176176
177177 /// The span of the current statement.
178178 span : Span ,
179+
180+ const_checking_stopped : bool ,
179181}
180182
181183impl Deref for Validator < ' mir , ' tcx > {
@@ -188,7 +190,12 @@ impl Deref for Validator<'mir, 'tcx> {
188190
189191impl Validator < ' mir , ' tcx > {
190192 pub fn new ( ccx : & ' mir ConstCx < ' mir , ' tcx > ) -> Self {
191- Validator { span : ccx. body . span , ccx, qualifs : Default :: default ( ) }
193+ Validator {
194+ span : ccx. body . span ,
195+ ccx,
196+ qualifs : Default :: default ( ) ,
197+ const_checking_stopped : false ,
198+ }
192199 }
193200
194201 pub fn check_body ( & mut self ) {
@@ -226,13 +233,22 @@ impl Validator<'mir, 'tcx> {
226233
227234 /// Emits an error if an expression cannot be evaluated in the current context.
228235 pub fn check_op ( & mut self , op : impl NonConstOp ) {
229- ops :: non_const ( self . ccx , op, self . span ) ;
236+ self . check_op_spanned ( op, self . span ) ;
230237 }
231238
232239 /// Emits an error at the given `span` if an expression cannot be evaluated in the current
233240 /// context.
234- pub fn check_op_spanned ( & mut self , op : impl NonConstOp , span : Span ) {
235- ops:: non_const ( self . ccx , op, span) ;
241+ pub fn check_op_spanned < O : NonConstOp > ( & mut self , op : O , span : Span ) {
242+ // HACK: This is for strict equivalence with the old `qualify_min_const_fn` pass, which
243+ // only emitted one error per function. It should be removed and the test output updated.
244+ if self . const_checking_stopped {
245+ return ;
246+ }
247+
248+ let err_emitted = ops:: non_const ( self . ccx , op, span) ;
249+ if err_emitted && O :: STOPS_CONST_CHECKING {
250+ self . const_checking_stopped = true ;
251+ }
236252 }
237253
238254 fn check_static ( & mut self , def_id : DefId , span : Span ) {
0 commit comments