@@ -71,7 +71,8 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>(
71
71
ccx : & CrateCtxt < ' a , ' tcx > ,
72
72
drop_impl_did : DefId ,
73
73
drop_impl_ty : Ty < ' tcx > ,
74
- self_type_did : DefId ) -> Result < ( ) , ( ) >
74
+ self_type_did : DefId )
75
+ -> Result < ( ) , ( ) >
75
76
{
76
77
let tcx = ccx. tcx ;
77
78
let drop_impl_node_id = tcx. map . as_local_node_id ( drop_impl_did) . unwrap ( ) ;
@@ -123,7 +124,9 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'a, 'tcx>(
123
124
drop_impl_did : DefId ,
124
125
dtor_predicates : & ty:: GenericPredicates < ' tcx > ,
125
126
self_type_did : DefId ,
126
- self_to_impl_substs : & Substs < ' tcx > ) -> Result < ( ) , ( ) > {
127
+ self_to_impl_substs : & Substs < ' tcx > )
128
+ -> Result < ( ) , ( ) >
129
+ {
127
130
128
131
// Here is an example, analogous to that from
129
132
// `compare_impl_method`.
@@ -350,7 +353,8 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'b, 'gcx, 'tcx>(
350
353
cx : & mut DropckContext < ' a , ' b , ' gcx , ' tcx > ,
351
354
context : TypeContext ,
352
355
ty : Ty < ' tcx > ,
353
- depth : usize ) -> Result < ( ) , Error < ' tcx > >
356
+ depth : usize )
357
+ -> Result < ( ) , Error < ' tcx > >
354
358
{
355
359
let tcx = cx. rcx . tcx ;
356
360
// Issue #22443: Watch out for overflow. While we are careful to
@@ -531,7 +535,8 @@ enum DropckKind<'tcx> {
531
535
/// parameters are re-mapped to `()` to reflect the destructor's
532
536
/// "purity" with respect to their actual contents.
533
537
fn has_dtor_of_interest < ' a , ' gcx , ' tcx > ( tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
534
- ty : Ty < ' tcx > ) -> DropckKind < ' tcx > {
538
+ ty : Ty < ' tcx > )
539
+ -> DropckKind < ' tcx > {
535
540
match ty. sty {
536
541
ty:: TyAdt ( adt_def, substs) => {
537
542
if !adt_def. is_dtorck ( tcx) {
@@ -574,7 +579,8 @@ fn has_dtor_of_interest<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
574
579
fn revise_self_ty < ' a , ' gcx , ' tcx > ( tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
575
580
adt_def : ty:: AdtDef < ' tcx > ,
576
581
impl_id : DefId ,
577
- substs : & Substs < ' tcx > ) -> Ty < ' tcx > {
582
+ substs : & Substs < ' tcx > )
583
+ -> Ty < ' tcx > {
578
584
// Get generics for `impl Drop` to query for `#[may_dangle]` attr.
579
585
let impl_bindings = tcx. lookup_generics ( impl_id) ;
580
586
@@ -592,6 +598,14 @@ fn revise_self_ty<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
592
598
593
599
// Walk `substs` + `self_substs`, build new substs appropriate for
594
600
// `adt_def`; each non-dangling param reuses entry from `substs`.
601
+ //
602
+ // Note: The manner we map from a right-hand side (i.e. Region or
603
+ // Ty) for a given `def` to generic parameter associated with that
604
+ // right-hand side is tightly coupled to `Drop` impl constraints.
605
+ //
606
+ // E.g. we know such a Ty must be `TyParam`, because a destructor
607
+ // for `struct Foo<X>` is defined via `impl<Y> Drop for Foo<Y>`,
608
+ // and never by (for example) `impl<Z> Drop for Foo<Vec<Z>>`.
595
609
let substs = Substs :: for_item (
596
610
tcx,
597
611
adt_def. did ,
0 commit comments