@@ -24,9 +24,9 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
24
24
self . fulfillment_cx. borrow_mut( ) . pending_obligations( )
25
25
) ;
26
26
27
- let fallback_occured = self . fallback_types ( ) | self . fallback_effects ( ) ;
27
+ let fallback_occurred = self . fallback_types ( ) | self . fallback_effects ( ) ;
28
28
29
- if !fallback_occured {
29
+ if !fallback_occurred {
30
30
return ;
31
31
}
32
32
@@ -69,14 +69,13 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
69
69
// We do fallback in two passes, to try to generate
70
70
// better error messages.
71
71
// The first time, we do *not* replace opaque types.
72
- //
73
- // TODO: We return `true` even if no fallback occurs.
72
+ let mut fallback_occurred = false ;
74
73
for ty in unresolved_variables {
75
74
debug ! ( "unsolved_variable = {:?}" , ty) ;
76
- self . fallback_if_possible ( ty, & diverging_fallback) ;
75
+ fallback_occurred |= self . fallback_if_possible ( ty, & diverging_fallback) ;
77
76
}
78
77
79
- true
78
+ fallback_occurred
80
79
}
81
80
82
81
fn fallback_effects ( & self ) -> bool {
@@ -86,9 +85,8 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
86
85
return false ;
87
86
}
88
87
89
- // not setting `fallback_has_occured` here because that field is only used for type fallback
90
- // diagnostics.
91
-
88
+ // not setting the `fallback_has_occured` field here because
89
+ // that field is only used for type fallback diagnostics.
92
90
for effect in unsolved_effects {
93
91
let expected = self . tcx . consts . true_ ;
94
92
let cause = self . misc ( rustc_span:: DUMMY_SP ) ;
@@ -124,7 +122,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
124
122
& self ,
125
123
ty : Ty < ' tcx > ,
126
124
diverging_fallback : & UnordMap < Ty < ' tcx > , Ty < ' tcx > > ,
127
- ) {
125
+ ) -> bool {
128
126
// Careful: we do NOT shallow-resolve `ty`. We know that `ty`
129
127
// is an unsolved variable, and we determine its fallback
130
128
// based solely on how it was created, not what other type
@@ -149,7 +147,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
149
147
ty:: Infer ( ty:: FloatVar ( _) ) => self . tcx . types . f64 ,
150
148
_ => match diverging_fallback. get ( & ty) {
151
149
Some ( & fallback_ty) => fallback_ty,
152
- None => return ,
150
+ None => return false ,
153
151
} ,
154
152
} ;
155
153
debug ! ( "fallback_if_possible(ty={:?}): defaulting to `{:?}`" , ty, fallback) ;
@@ -161,6 +159,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
161
159
. unwrap_or ( rustc_span:: DUMMY_SP ) ;
162
160
self . demand_eqtype ( span, ty, fallback) ;
163
161
self . fallback_has_occurred . set ( true ) ;
162
+ true
164
163
}
165
164
166
165
/// The "diverging fallback" system is rather complicated. This is
0 commit comments