pub(super) fn solve(
        &mut self,
        infcx: &InferCtxt<'_, 'tcx>,
        body: &Body<'tcx>,
        local_names: &IndexVec<Local, Option<Symbol>>,
        upvars: &[Upvar],
        mir_def_id: DefId,
        errors_buffer: &mut Vec<Diagnostic>,
        polonius_output: Option<Rc<PoloniusOutput>>,
    ) -> Option<ClosureRegionRequirements<'tcx>> {
        self.propagate_constraints(body);

        // If this is a closure, we can propagate unsatisfied
        // `outlives_requirements` to our creator, so create a vector
        // to store those. Otherwise, we'll pass in `None` to the
        // functions below, which will trigger them to report errors
        // eagerly.
        let mut outlives_requirements =
            infcx.tcx.is_closure(mir_def_id).then(|| vec![]);

        self.check_type_tests(
            infcx,
            body,
            mir_def_id,
            outlives_requirements.as_mut(),
            errors_buffer,
        );

        // If we produce any errors, we keep track of the names of all regions, so that we can use
        // the same error names in any suggestions we produce. Note that we need names to be unique
        // across different errors for the same MIR def so that we can make suggestions that fix
        // multiple problems.
        let mut region_naming = RegionErrorNamingCtx::new();

        // In Polonius mode, the errors about missing universal region relations are in the output
        // and need to be emitted or propagated. Otherwise, we need to check whether the
        // constraints were too strong, and if so, emit or propagate those errors.
        if infcx.tcx.sess.opts.debugging_opts.polonius {
            self.check_polonius_subset_errors(
                infcx,
                body,
                local_names,
                upvars,
                mir_def_id,
                outlives_requirements.as_mut(),
                errors_buffer,
                &mut region_naming,
                polonius_output.expect("Polonius output is unavailable despite `-Z polonius`"),
            );
        } else {
            self.check_universal_regions(
                infcx,
                body,
                local_names,
                upvars,
                mir_def_id,
                outlives_requirements.as_mut(),
                errors_buffer,
                &mut region_naming,
            );
        }

        self.check_member_constraints(infcx, mir_def_id, errors_buffer);

        let outlives_requirements = outlives_requirements.unwrap_or(vec![]);

        if outlives_requirements.is_empty() {
            None
        } else {
            let num_external_vids = self.universal_regions.num_global_and_external_regions();
            Some(ClosureRegionRequirements { num_external_vids, outlives_requirements })
        }
    }
/// Performs region inference and report errors if we see any
/// unsatisfiable constraints. If this is a closure, returns the
/// region requirements to propagate to our creator, if any.
Performs region inference and report errors if we see any
unsatisfiable constraints. If this is a closure, returns the
region requirements to propagate to our creator, if any.
Performs region inference and report errors if we see any unsatisfiable constraints . If this is a closure returns the region requirements to propagate to our creator if any .
pub(super) fn solve(
        &mut self,
        infcx: &InferCtxt<'_, 'tcx>,
        body: &Body<'tcx>,
        local_names: &IndexVec<Local, Option<Symbol>>,
        upvars: &[Upvar],
        mir_def_id: DefId,
        errors_buffer: &mut Vec<Diagnostic>,
        polonius_output: Option<Rc<PoloniusOutput>>,
    ) -> Option<ClosureRegionRequirements<'tcx>> {
        self.propagate_constraints(body);
        // If this is a closure, we can propagate unsatisfied
        // `outlives_requirements` to our creator, so create a vector
        // to store those. Otherwise, we'll pass in `None` to the
        // functions below, which will trigger them to report errors
        // eagerly.
        let mut outlives_requirements =
            infcx.tcx.is_closure(mir_def_id).then(|| vec![]);
        self.check_type_tests(
            infcx,
            body,
            mir_def_id,
            outlives_requirements.as_mut(),
            errors_buffer,
        );
        // If we produce any errors, we keep track of the names of all regions, so that we can use
        // the same error names in any suggestions we produce. Note that we need names to be unique
        // across different errors for the same MIR def so that we can make suggestions that fix
        // multiple problems.
        let mut region_naming = RegionErrorNamingCtx::new();
        // In Polonius mode, the errors about missing universal region relations are in the output
        // and need to be emitted or propagated. Otherwise, we need to check whether the
        // constraints were too strong, and if so, emit or propagate those errors.
        if infcx.tcx.sess.opts.debugging_opts.polonius {
            self.check_polonius_subset_errors(
                infcx,
                body,
                local_names,
                upvars,
                mir_def_id,
                outlives_requirements.as_mut(),
                errors_buffer,
                &mut region_naming,
                polonius_output.expect("Polonius output is unavailable despite `-Z polonius`"),
            );
        } else {
            self.check_universal_regions(
                infcx,
                body,
                local_names,
                upvars,
                mir_def_id,
                outlives_requirements.as_mut(),
                errors_buffer,
                &mut region_naming,
            );
        }
        self.check_member_constraints(infcx, mir_def_id, errors_buffer);
        let outlives_requirements = outlives_requirements.unwrap_or(vec![]);
        if outlives_requirements.is_empty() {
            None
        } else {
            let num_external_vids = self.universal_regions.num_global_and_external_regions();
            Some(ClosureRegionRequirements { num_external_vids, outlives_requirements })
        }
    }
pub ( super ) fn solve ( & mut self , infcx : & InferCtxt < ' _ , ' tcx > , body : & Body < ' tcx > , local_names : & IndexVec < Local , Option < Symbol > > , upvars : & [ Upvar ] , mir_def_id : DefId , errors_buffer : & mut Vec < Diagnostic > , polonius_output : Option < Rc < PoloniusOutput > > , ) -> Option < ClosureRegionRequirements < ' tcx > > { self . propagate_constraints ( body ) ; // If this is a closure, we can propagate unsatisfied // `outlives_requirements` to our creator, so create a vector // to store those. Otherwise, we'll pass in `None` to the // functions below, which will trigger them to report errors // eagerly. let mut outlives_requirements = infcx . tcx . is_closure ( mir_def_id ) . then ( | | vec ! [ ] ) ; self . check_type_tests ( infcx , body , mir_def_id , outlives_requirements . as_mut ( ) , errors_buffer , ) ; // If we produce any errors, we keep track of the names of all regions, so that we can use // the same error names in any suggestions we produce. Note that we need names to be unique // across different errors for the same MIR def so that we can make suggestions that fix // multiple problems. let mut region_naming = RegionErrorNamingCtx :: new ( ) ; // In Polonius mode, the errors about missing universal region relations are in the output // and need to be emitted or propagated. Otherwise, we need to check whether the // constraints were too strong, and if so, emit or propagate those errors. if infcx . tcx . sess . opts . debugging_opts . polonius { self . check_polonius_subset_errors ( infcx , body , local_names , upvars , mir_def_id , outlives_requirements . as_mut ( ) , errors_buffer , & mut region_naming , polonius_output . expect ( " " ) , ) ; } else { self . check_universal_regions ( infcx , body , local_names , upvars , mir_def_id , outlives_requirements . as_mut ( ) , errors_buffer , & mut region_naming , ) ; } self . check_member_constraints ( infcx , mir_def_id , errors_buffer ) ; let outlives_requirements = outlives_requirements . unwrap_or ( vec ! [ ] ) ; if outlives_requirements . is_empty ( ) { None } else { let num_external_vids = self . universal_regions . num_global_and_external_regions ( ) ; Some ( ClosureRegionRequirements { num_external_vids , outlives_requirements } ) } }
Performs region inference and report errors if we see any
unsatisfiable constraints.
Performs region inference and report errors if we see any unsatisfiable constraints .
&mut self
infcx
&InferCtxt<'_, 'tcx>
body
&Body<'tcx>
local_names
&IndexVec<Local, Option<Symbol>>
upvars
&[Upvar]
mir_def_id
DefId
errors_buffer
&mut Vec<Diagnostic>
polonius_output
Option<Rc<PoloniusOutput>>