fn type_needs_drop_given_env<'a,'tcx>(cx: &ty::ctxt<'tcx>,
                                      ty: Ty<'tcx>,
                                      param_env: &ty::ParameterEnvironment<'a,'tcx>) -> bool {
    // Issue #22536: We first query type_moves_by_default.  It sees a
    // normalized version of the type, and therefore will definitely
    // know whether the type implements Copy (and thus needs no
    // cleanup/drop/zeroing) ...
    let implements_copy = !ty.moves_by_default(param_env, DUMMY_SP);

    if implements_copy { return false; }

    // ... (issue #22536 continued) but as an optimization, still use
    // prior logic of asking if the `needs_drop` bit is set; we need
    // not zero non-Copy types if they have no destructor.

    // FIXME(#22815): Note that calling `ty::type_contents` is a
    // conservative heuristic; it may report that `needs_drop` is set
    // when actual type does not actually have a destructor associated
    // with it. But since `ty` absolutely did not have the `Copy`
    // bound attached (see above), it is sound to treat it as having a
    // destructor (e.g. zero its memory on move).

    let contents = ty.type_contents(cx);
    debug!("type_needs_drop ty={:?} contents={:?}", ty, contents);
    contents.needs_drop(cx)
}
/// Core implementation of type_needs_drop, potentially making use of
/// and/or updating caches held in the `param_env`.
Core implementation of type_needs_drop, potentially making use of
and/or updating caches held in the `param_env`.
Core implementation of type_needs_drop potentially making use of and / or updating caches held in the ` param_env ` .
fn type_needs_drop_given_env<'a,'tcx>(cx: &ty::ctxt<'tcx>,
                                      ty: Ty<'tcx>,
                                      param_env: &ty::ParameterEnvironment<'a,'tcx>) -> bool {
    // Issue #22536: We first query type_moves_by_default.  It sees a
    // normalized version of the type, and therefore will definitely
    // know whether the type implements Copy (and thus needs no
    // cleanup/drop/zeroing) ...
    let implements_copy = !ty.moves_by_default(param_env, DUMMY_SP);
    if implements_copy { return false; }
    // ... (issue #22536 continued) but as an optimization, still use
    // prior logic of asking if the `needs_drop` bit is set; we need
    // not zero non-Copy types if they have no destructor.
    // FIXME(#22815): Note that calling `ty::type_contents` is a
    // conservative heuristic; it may report that `needs_drop` is set
    // when actual type does not actually have a destructor associated
    // with it. But since `ty` absolutely did not have the `Copy`
    // bound attached (see above), it is sound to treat it as having a
    // destructor (e.g. zero its memory on move).
    let contents = ty.type_contents(cx);
    debug!("type_needs_drop ty={:?} contents={:?}", ty, contents);
    contents.needs_drop(cx)
}
fn type_needs_drop_given_env < ' a , ' tcx > ( cx : & ty :: ctxt < ' tcx > , ty : Ty < ' tcx > , param_env : & ty :: ParameterEnvironment < ' a , ' tcx > ) -> bool { // Issue #22536: We first query type_moves_by_default.  It sees a // normalized version of the type, and therefore will definitely // know whether the type implements Copy (and thus needs no // cleanup/drop/zeroing) ... let implements_copy = ! ty . moves_by_default ( param_env , DUMMY_SP ) ; if implements_copy { return false ; } // ... (issue #22536 continued) but as an optimization, still use // prior logic of asking if the `needs_drop` bit is set; we need // not zero non-Copy types if they have no destructor. // FIXME(#22815): Note that calling `ty::type_contents` is a // conservative heuristic; it may report that `needs_drop` is set // when actual type does not actually have a destructor associated // with it. But since `ty` absolutely did not have the `Copy` // bound attached (see above), it is sound to treat it as having a // destructor (e.g. zero its memory on move). let contents = ty . type_contents ( cx ) ; debug ! ( " " ty contents ) ; contents . needs_drop ( cx ) }
Core implementation of type_needs_drop, potentially making use of
and/or updating caches held in the `param_env`.
Core implementation of type_needs_drop potentially making use of and / or updating caches held in the ` param_env ` .
cx
&ty::ctxt<'tcx>
ty
Ty<'tcx>
param_env
&ty::ParameterEnvironment<'a,'tcx>
cx
&ty::ctxt<'tcx>
ty
Ty<'tcx>
param_env
&ty::ParameterEnvironment<'a,'tcx>