@@ -481,15 +481,16 @@ fn check_path<'tcx>(
481
481
let instance = Instance :: try_resolve ( cx. tcx , cx. typing_env ( ) , default_fn_def_id, args) ;
482
482
483
483
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.
485
485
// 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.
487
489
let body = cx. tcx . instance_mir ( instance. def ) ;
488
490
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`.
491
491
if block_data. statements . len ( ) == 1
492
492
&& let mir:: StatementKind :: Assign ( assign) = & block_data. statements [ 0 ] . kind
493
+ && assign. 0 . local == mir:: RETURN_PLACE
493
494
&& let mir:: Rvalue :: Aggregate ( kind, _places) = & assign. 1
494
495
&& let mir:: AggregateKind :: Adt ( did, variant_index, _, _, _) = & * * kind
495
496
&& let def = cx. tcx . adt_def ( did)
0 commit comments