fn classify_constraint(
        &self,
        constraint: OutlivesConstraint,
        mir: &Mir<'tcx>,
        tcx: TyCtxt<'_, '_, 'tcx>,
    ) -> (ConstraintCategory, Span) {
        debug!("classify_constraint: constraint={:?}", constraint);
        let span = constraint.locations.span(mir);
        let location = constraint
            .locations
            .from_location()
            .unwrap_or(Location::START);

        if !self.constraint_is_interesting(constraint) {
            return (ConstraintCategory::Boring, span);
        }

        let data = &mir[location.block];
        debug!(
            "classify_constraint: location={:?} data={:?}",
            location, data
        );
        let category = if location.statement_index == data.statements.len() {
            if let Some(ref terminator) = data.terminator {
                debug!("classify_constraint: terminator.kind={:?}", terminator.kind);
                match terminator.kind {
                    TerminatorKind::DropAndReplace { .. } => ConstraintCategory::Assignment,
                    // Classify calls differently depending on whether or not
                    // the sub region appears in the destination type (so the
                    // sup region is in the return type). If the return type
                    // contains the sub-region, then this is either an
                    // assignment or a return, depending on whether we are
                    // writing to the RETURN_PLACE or not.
                    //
                    // The idea here is that the region is being propagated
                    // from an input into the output place, so it's a kind of
                    // assignment. Otherwise, if the sub-region only appears in
                    // the argument types, then use the CallArgument
                    // classification.
                    TerminatorKind::Call { destination: Some((ref place, _)), .. } => {
                        if tcx.any_free_region_meets(
                            &place.ty(mir, tcx).to_ty(tcx),
                            |region| self.to_region_vid(region) == constraint.sub,
                        ) {
                            match place {
                                Place::Local(mir::RETURN_PLACE) => ConstraintCategory::Return,
                                _ => ConstraintCategory::Assignment,
                            }
                        } else {
                            ConstraintCategory::CallArgument
                        }
                    }
                    TerminatorKind::Call { destination: None, .. } => {
                        ConstraintCategory::CallArgument
                    }
                    _ => ConstraintCategory::Other,
                }
            } else {
                ConstraintCategory::Other
            }
        } else {
            let statement = &data.statements[location.statement_index];
            debug!("classify_constraint: statement.kind={:?}", statement.kind);
            match statement.kind {
                StatementKind::Assign(ref place, ref rvalue) => {
                    debug!("classify_constraint: place={:?} rvalue={:?}", place, rvalue);
                    if *place == Place::Local(mir::RETURN_PLACE) {
                        ConstraintCategory::Return
                    } else {
                        match rvalue {
                            Rvalue::Cast(..) => ConstraintCategory::Cast,
                            Rvalue::Use(..) | Rvalue::Aggregate(..) => {
                                ConstraintCategory::Assignment
                            }
                            _ => ConstraintCategory::Other,
                        }
                    }
                }
                _ => ConstraintCategory::Other,
            }
        };

        (category, span)
    }
/// This function classifies a constraint from a location.
This function classifies a constraint from a location.
This function classifies a constraint from a location .
fn classify_constraint(
        &self,
        constraint: OutlivesConstraint,
        mir: &Mir<'tcx>,
        tcx: TyCtxt<'_, '_, 'tcx>,
    ) -> (ConstraintCategory, Span) {
        debug!("classify_constraint: constraint={:?}", constraint);
        let span = constraint.locations.span(mir);
        let location = constraint
            .locations
            .from_location()
            .unwrap_or(Location::START);
        if !self.constraint_is_interesting(constraint) {
            return (ConstraintCategory::Boring, span);
        }
        let data = &mir[location.block];
        debug!(
            "classify_constraint: location={:?} data={:?}",
            location, data
        );
        let category = if location.statement_index == data.statements.len() {
            if let Some(ref terminator) = data.terminator {
                debug!("classify_constraint: terminator.kind={:?}", terminator.kind);
                match terminator.kind {
                    TerminatorKind::DropAndReplace { .. } => ConstraintCategory::Assignment,
                    // Classify calls differently depending on whether or not
                    // the sub region appears in the destination type (so the
                    // sup region is in the return type). If the return type
                    // contains the sub-region, then this is either an
                    // assignment or a return, depending on whether we are
                    // writing to the RETURN_PLACE or not.
                    //
                    // The idea here is that the region is being propagated
                    // from an input into the output place, so it's a kind of
                    // assignment. Otherwise, if the sub-region only appears in
                    // the argument types, then use the CallArgument
                    // classification.
                    TerminatorKind::Call { destination: Some((ref place, _)), .. } => {
                        if tcx.any_free_region_meets(
                            &place.ty(mir, tcx).to_ty(tcx),
                            |region| self.to_region_vid(region) == constraint.sub,
                        ) {
                            match place {
                                Place::Local(mir::RETURN_PLACE) => ConstraintCategory::Return,
                                _ => ConstraintCategory::Assignment,
                            }
                        } else {
                            ConstraintCategory::CallArgument
                        }
                    }
                    TerminatorKind::Call { destination: None, .. } => {
                        ConstraintCategory::CallArgument
                    }
                    _ => ConstraintCategory::Other,
                }
            } else {
                ConstraintCategory::Other
            }
        } else {
            let statement = &data.statements[location.statement_index];
            debug!("classify_constraint: statement.kind={:?}", statement.kind);
            match statement.kind {
                StatementKind::Assign(ref place, ref rvalue) => {
                    debug!("classify_constraint: place={:?} rvalue={:?}", place, rvalue);
                    if *place == Place::Local(mir::RETURN_PLACE) {
                        ConstraintCategory::Return
                    } else {
                        match rvalue {
                            Rvalue::Cast(..) => ConstraintCategory::Cast,
                            Rvalue::Use(..) | Rvalue::Aggregate(..) => {
                                ConstraintCategory::Assignment
                            }
                            _ => ConstraintCategory::Other,
                        }
                    }
                }
                _ => ConstraintCategory::Other,
            }
        };
        (category, span)
    }
fn classify_constraint ( & self , constraint : OutlivesConstraint , mir : & Mir < ' tcx > , tcx : TyCtxt < ' _ , ' _ , ' tcx > , ) -> ( ConstraintCategory , Span ) { debug ! ( " " constraint ) ; let span = constraint . locations . span ( mir ) ; let location = constraint . locations . from_location ( ) . unwrap_or ( Location :: START ) ; if ! self . constraint_is_interesting ( constraint ) { return ( ConstraintCategory :: Boring , span ) ; } let data = & mir [ location . block ] ; debug ! ( " " location data ) ; let category = if location . statement_index == data . statements . len ( ) { if let Some ( ref terminator ) = data . terminator { debug ! ( " " terminator kind ) ; match terminator . kind { TerminatorKind :: DropAndReplace { .. } => ConstraintCategory :: Assignment , // Classify calls differently depending on whether or not // the sub region appears in the destination type (so the // sup region is in the return type). If the return type // contains the sub-region, then this is either an // assignment or a return, depending on whether we are // writing to the RETURN_PLACE or not. // // The idea here is that the region is being propagated // from an input into the output place, so it's a kind of // assignment. Otherwise, if the sub-region only appears in // the argument types, then use the CallArgument // classification. TerminatorKind :: Call { destination : Some ( ( ref place , _ ) ) , .. } => { if tcx . any_free_region_meets ( & place . ty ( mir , tcx ) . to_ty ( tcx ) , | region | self . to_region_vid ( region ) == constraint . sub , ) { match place { Place :: Local ( mir :: RETURN_PLACE ) => ConstraintCategory :: Return , _ => ConstraintCategory :: Assignment , } } else { ConstraintCategory :: CallArgument } } TerminatorKind :: Call { destination : None , .. } => { ConstraintCategory :: CallArgument } _ => ConstraintCategory :: Other , } } else { ConstraintCategory :: Other } } else { let statement = & data . statements [ location . statement_index ] ; debug ! ( " " statement kind ) ; match statement . kind { StatementKind :: Assign ( ref place , ref rvalue ) => { debug ! ( " " place rvalue ) ; if * place == Place :: Local ( mir :: RETURN_PLACE ) { ConstraintCategory :: Return } else { match rvalue { Rvalue :: Cast ( .. ) => ConstraintCategory :: Cast , Rvalue :: Use ( .. ) | Rvalue :: Aggregate ( .. ) => { ConstraintCategory :: Assignment } _ => ConstraintCategory :: Other , } } } _ => ConstraintCategory :: Other , } } ; ( category , span ) }
This function classifies a constraint from a location.
This function classifies a constraint from a location .
&self
constraint
OutlivesConstraint
mir
&Mir<'tcx>
tcx
TyCtxt<'_, '_, 'tcx>
&self
constraint
OutlivesConstraint
mir
&Mir<'tcx>
tcx
TyCtxt<'_, '_, 'tcx>