@@ -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,10 +85,11 @@ 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.
90
+ let mut fallback_occurred = false ;
92
91
for effect in unsolved_effects {
92
+ fallback_occurred = true ;
93
93
let expected = self . tcx . consts . true_ ;
94
94
let cause = self . misc ( rustc_span:: DUMMY_SP ) ;
95
95
match self . at ( & cause, self . param_env ) . eq ( DefineOpaqueTypes :: Yes , expected, effect) {
@@ -102,7 +102,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
102
102
}
103
103
}
104
104
105
- true
105
+ fallback_occurred
106
106
}
107
107
108
108
// Tries to apply a fallback to `ty` if it is an unsolved variable.
@@ -124,7 +124,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
124
124
& self ,
125
125
ty : Ty < ' tcx > ,
126
126
diverging_fallback : & UnordMap < Ty < ' tcx > , Ty < ' tcx > > ,
127
- ) {
127
+ ) -> bool {
128
128
// Careful: we do NOT shallow-resolve `ty`. We know that `ty`
129
129
// is an unsolved variable, and we determine its fallback
130
130
// based solely on how it was created, not what other type
@@ -149,7 +149,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
149
149
ty:: Infer ( ty:: FloatVar ( _) ) => self . tcx . types . f64 ,
150
150
_ => match diverging_fallback. get ( & ty) {
151
151
Some ( & fallback_ty) => fallback_ty,
152
- None => return ,
152
+ None => return false ,
153
153
} ,
154
154
} ;
155
155
debug ! ( "fallback_if_possible(ty={:?}): defaulting to `{:?}`" , ty, fallback) ;
@@ -161,6 +161,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
161
161
. unwrap_or ( rustc_span:: DUMMY_SP ) ;
162
162
self . demand_eqtype ( span, ty, fallback) ;
163
163
self . fallback_has_occurred . set ( true ) ;
164
+ true
164
165
}
165
166
166
167
/// The "diverging fallback" system is rather complicated. This is
0 commit comments