@@ -36,6 +36,7 @@ use rustc_span::symbol::{kw, sym};
36
36
use rustc_span:: { ExpnKind , Span , DUMMY_SP } ;
37
37
use std:: fmt;
38
38
use std:: iter;
39
+ use std:: ops:: ControlFlow ;
39
40
40
41
use crate :: traits:: query:: evaluate_obligation:: InferCtxtExt as _;
41
42
use crate :: traits:: query:: normalize:: AtExt as _;
@@ -2226,9 +2227,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
2226
2227
post. dedup ( ) ;
2227
2228
2228
2229
if self . is_tainted_by_errors ( )
2229
- && crate_names. len ( ) == 1
2230
- && [ "`core`" , "`alloc`" , "`std`" ] . contains ( & crate_names[ 0 ] . as_str ( ) )
2231
- && spans. len ( ) == 0
2230
+ && ( crate_names. len ( ) == 1
2231
+ && spans. len ( ) == 0
2232
+ && [ "`core`" , "`alloc`" , "`std`" ] . contains ( & crate_names[ 0 ] . as_str ( ) )
2233
+ || predicate. visit_with ( & mut HasNumericInferVisitor ) . is_break ( ) )
2232
2234
{
2233
2235
// Avoid complaining about other inference issues for expressions like
2234
2236
// `42 >> 1`, where the types are still `{integer}`, but we want to
@@ -2666,3 +2668,17 @@ impl ArgKind {
2666
2668
}
2667
2669
}
2668
2670
}
2671
+
2672
+ struct HasNumericInferVisitor ;
2673
+
2674
+ impl < ' tcx > ty:: TypeVisitor < ' tcx > for HasNumericInferVisitor {
2675
+ type BreakTy = ( ) ;
2676
+
2677
+ fn visit_ty ( & mut self , ty : Ty < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
2678
+ if matches ! ( ty. kind( ) , ty:: Infer ( ty:: FloatVar ( _) | ty:: IntVar ( _) ) ) {
2679
+ ControlFlow :: Break ( ( ) )
2680
+ } else {
2681
+ ControlFlow :: CONTINUE
2682
+ }
2683
+ }
2684
+ }
0 commit comments