Skip to content

Commit 10a58ac

Browse files
committed
Incorporate review feedback: code formatting fixes, expand a comment.
1 parent 4124d8e commit 10a58ac

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

Diff for: src/librustc_typeck/check/dropck.rs

+19-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>(
7171
ccx: &CrateCtxt<'a, 'tcx>,
7272
drop_impl_did: DefId,
7373
drop_impl_ty: Ty<'tcx>,
74-
self_type_did: DefId) -> Result<(), ()>
74+
self_type_did: DefId)
75+
-> Result<(), ()>
7576
{
7677
let tcx = ccx.tcx;
7778
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>(
123124
drop_impl_did: DefId,
124125
dtor_predicates: &ty::GenericPredicates<'tcx>,
125126
self_type_did: DefId,
126-
self_to_impl_substs: &Substs<'tcx>) -> Result<(), ()> {
127+
self_to_impl_substs: &Substs<'tcx>)
128+
-> Result<(), ()>
129+
{
127130

128131
// Here is an example, analogous to that from
129132
// `compare_impl_method`.
@@ -350,7 +353,8 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'b, 'gcx, 'tcx>(
350353
cx: &mut DropckContext<'a, 'b, 'gcx, 'tcx>,
351354
context: TypeContext,
352355
ty: Ty<'tcx>,
353-
depth: usize) -> Result<(), Error<'tcx>>
356+
depth: usize)
357+
-> Result<(), Error<'tcx>>
354358
{
355359
let tcx = cx.rcx.tcx;
356360
// Issue #22443: Watch out for overflow. While we are careful to
@@ -531,7 +535,8 @@ enum DropckKind<'tcx> {
531535
/// parameters are re-mapped to `()` to reflect the destructor's
532536
/// "purity" with respect to their actual contents.
533537
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> {
535540
match ty.sty {
536541
ty::TyAdt(adt_def, substs) => {
537542
if !adt_def.is_dtorck(tcx) {
@@ -574,7 +579,8 @@ fn has_dtor_of_interest<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
574579
fn revise_self_ty<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
575580
adt_def: ty::AdtDef<'tcx>,
576581
impl_id: DefId,
577-
substs: &Substs<'tcx>) -> Ty<'tcx> {
582+
substs: &Substs<'tcx>)
583+
-> Ty<'tcx> {
578584
// Get generics for `impl Drop` to query for `#[may_dangle]` attr.
579585
let impl_bindings = tcx.lookup_generics(impl_id);
580586

@@ -592,6 +598,14 @@ fn revise_self_ty<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
592598

593599
// Walk `substs` + `self_substs`, build new substs appropriate for
594600
// `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>>`.
595609
let substs = Substs::for_item(
596610
tcx,
597611
adt_def.did,

0 commit comments

Comments
 (0)