-/// How we should handle region solving.
-///
-/// This is used so that the region values inferred by HIR region solving are
-/// not exposed, and so that we can avoid doing work in HIR typeck that MIR
-/// typeck will also do.
-#[derive(Copy, Clone, Debug, Default)]
-pub enum RegionckMode {
- /// The default mode: report region errors, don't erase regions.
- #[default]
- Solve,
- /// Erase the results of region after solving.
- Erase {
- /// A flag that is used to suppress region errors, when we are doing
- /// region checks that the NLL borrow checker will also do -- it might
- /// be set to true.
- suppress_errors: bool,
- },
-}
-
-impl RegionckMode {
- /// Indicates that the MIR borrowck will repeat these region
- /// checks, so we should ignore errors if NLL is (unconditionally)
- /// enabled.
- pub fn for_item_body(tcx: TyCtxt<'_>) -> Self {
- // FIXME(Centril): Once we actually remove `::Migrate` also make
- // this always `true` and then proceed to eliminate the dead code.
- match tcx.borrowck_mode() {
- // If we're on Migrate mode, report AST region errors
- BorrowckMode::Migrate => RegionckMode::Erase { suppress_errors: false },
-
- // If we're on MIR, don't report AST region errors as they should be reported by NLL
- BorrowckMode::Mir => RegionckMode::Erase { suppress_errors: true },
- }
- }
-}
-