@@ -481,15 +481,16 @@ fn check_path<'tcx>(
481481 let instance = Instance :: try_resolve ( cx. tcx , cx. typing_env ( ) , default_fn_def_id, args) ;
482482
483483 let Ok ( Some ( instance) ) = instance else { return false } ;
484- // Get the MIR Body for the `<Ty as Default>::default()` function.
484+ // Get the MIR Body for the `<FieldTy as Default>::default()` function.
485485 // If it is a value or call (either fn or ctor), we compare its DefId against the one for the
486- // resolution of the expression we had in the path.
486+ // resolution of the expression we had in the path. This lets us identify, for example, that
487+ // the body of `<Vec<T> as Default>::default()` is a `Vec::new()`, and the field was being
488+ // initialized to `Vec::new()` as well.
487489 let body = cx. tcx . instance_mir ( instance. def ) ;
488490 for block_data in body. basic_blocks . iter ( ) {
489- // FIXME: make another pass on this logic. For example we should be confirming that the
490- // place we assign to is `_0`.
491491 if block_data. statements . len ( ) == 1
492492 && let mir:: StatementKind :: Assign ( assign) = & block_data. statements [ 0 ] . kind
493+ && assign. 0 . local == mir:: RETURN_PLACE
493494 && let mir:: Rvalue :: Aggregate ( kind, _places) = & assign. 1
494495 && let mir:: AggregateKind :: Adt ( did, variant_index, _, _, _) = & * * kind
495496 && let def = cx. tcx . adt_def ( did)
0 commit comments