@@ -329,30 +329,12 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
329
329
// When borrowck=migrate, check if AST-borrowck would
330
330
// error on the given code.
331
331
332
- // rust-lang/rust#55492: loop over parents to ensure that
333
- // errors that AST-borrowck only detects in some parent of
334
- // a closure still allows NLL to signal an error.
335
- let mut curr_def_id = def_id;
336
- let signalled_any_error = loop {
337
- match tcx. borrowck ( curr_def_id) . signalled_any_error {
338
- SignalledError :: NoErrorsSeen => {
339
- // keep traversing (and borrow-checking) parents
340
- }
341
- SignalledError :: SawSomeError => {
342
- // stop search here
343
- break SignalledError :: SawSomeError ;
344
- }
345
- }
346
-
347
- if tcx. is_closure ( curr_def_id) {
348
- curr_def_id = tcx. parent_def_id ( curr_def_id)
349
- . expect ( "a closure must have a parent_def_id" ) ;
350
- } else {
351
- break SignalledError :: NoErrorsSeen ;
352
- }
353
- } ;
332
+ // rust-lang/rust#55492, rust-lang/rust#58776 check the base def id
333
+ // for errors. AST borrowck is responsible for aggregating
334
+ // `signalled_any_error` from all of the nested closures here.
335
+ let base_def_id = tcx. closure_base_def_id ( def_id) ;
354
336
355
- match signalled_any_error {
337
+ match tcx . borrowck ( base_def_id ) . signalled_any_error {
356
338
SignalledError :: NoErrorsSeen => {
357
339
// if AST-borrowck signalled no errors, then
358
340
// downgrade all the buffered MIR-borrowck errors
0 commit comments