@@ -194,8 +194,6 @@ impl<'mir, 'tcx, C: TerminatorClassifier<'tcx>> TriColorVisitor<BasicBlocks<'tcx
194
194
| TerminatorKind :: CoroutineDrop
195
195
| TerminatorKind :: UnwindResume
196
196
| TerminatorKind :: Return
197
- // FIXME(explicit_tail_calls) Is this right??
198
- | TerminatorKind :: TailCall { .. }
199
197
| TerminatorKind :: Unreachable
200
198
| TerminatorKind :: Yield { .. } => ControlFlow :: Break ( NonRecursive ) ,
201
199
@@ -216,12 +214,28 @@ impl<'mir, 'tcx, C: TerminatorClassifier<'tcx>> TriColorVisitor<BasicBlocks<'tcx
216
214
| TerminatorKind :: FalseUnwind { .. }
217
215
| TerminatorKind :: Goto { .. }
218
216
| TerminatorKind :: SwitchInt { .. } => ControlFlow :: Continue ( ( ) ) ,
217
+
218
+ // Note that tail call terminator technically returns to the caller,
219
+ // but for purposes of this lint it makes sense to count it as possibly recursive,
220
+ // since it's still a call.
221
+ //
222
+ // If this'll be repurposed for something else, this might need to be changed.
223
+ TerminatorKind :: TailCall { .. } => ControlFlow :: Continue ( ( ) ) ,
219
224
}
220
225
}
221
226
222
227
fn node_settled ( & mut self , bb : BasicBlock ) -> ControlFlow < Self :: BreakVal > {
223
228
// When we examine a node for the last time, remember it if it is a recursive call.
224
229
let terminator = self . body [ bb] . terminator ( ) ;
230
+
231
+ // FIXME(explicit_tail_calls): highlight tail calls as "recursive call site"
232
+ //
233
+ // We don't want to lint functions that recurse only through tail calls
234
+ // (such as `fn g() { become () }`), so just adding `| TailCall { ... }`
235
+ // here won't work.
236
+ //
237
+ // But at the same time we would like to highlight both calls in a function like
238
+ // `fn f() { if false { become f() } else { f() } }`, so we need to figure something out.
225
239
if self . classifier . is_recursive_terminator ( self . tcx , self . body , terminator) {
226
240
self . reachable_recursive_calls . push ( terminator. source_info . span ) ;
227
241
}
0 commit comments