diff options
| author | Nicholas-Baron <nicholas.baron.ten@gmail.com> | 2020-09-19 01:09:45 -0700 |
|---|---|---|
| committer | Nicholas-Baron <nicholas.baron.ten@gmail.com> | 2020-09-20 18:48:31 -0700 |
| commit | 6fd80e35e03f0acf48c065d6682600d32b27915f (patch) | |
| tree | d8cf3fdd359c667dbaafb41fe093a2c10ec97cb2 | |
| parent | bfe5bc9cb93445c7e2818db684de2bf1d84a06c7 (diff) | |
| download | rust-6fd80e35e03f0acf48c065d6682600d32b27915f.tar.gz rust-6fd80e35e03f0acf48c065d6682600d32b27915f.zip | |
Moved another struct and used pub(super) to be explicit
| -rw-r--r-- | compiler/rustc_typeck/src/check/mod.rs | 29 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/util.rs | 40 |
2 files changed, 36 insertions, 33 deletions
diff --git a/compiler/rustc_typeck/src/check/mod.rs b/compiler/rustc_typeck/src/check/mod.rs index 1b542818b6f..560248480cf 100644 --- a/compiler/rustc_typeck/src/check/mod.rs +++ b/compiler/rustc_typeck/src/check/mod.rs @@ -87,6 +87,7 @@ pub mod writeback; use crate::astconv::{ AstConv, ExplicitLateBound, GenericArgCountMismatch, GenericArgCountResult, PathSeg, }; +use crate::check::util::MaybeInProgressTables; use rustc_ast as ast; use rustc_ast::util::parser::ExprPrecedence; use rustc_attr as attr; @@ -141,7 +142,7 @@ use rustc_trait_selection::traits::{ self, ObligationCause, ObligationCauseCode, TraitEngine, TraitEngineExt, }; -use std::cell::{Cell, Ref, RefCell, RefMut}; +use std::cell::{Cell, RefCell}; use std::cmp; use std::collections::hash_map::Entry; use std::iter; @@ -177,32 +178,6 @@ pub struct LocalTy<'tcx> { revealed_ty: Ty<'tcx>, } -/// A wrapper for `InferCtxt`'s `in_progress_typeck_results` field. -#[derive(Copy, Clone)] -struct MaybeInProgressTables<'a, 'tcx> { - maybe_typeck_results: Option<&'a RefCell<ty::TypeckResults<'tcx>>>, -} - -impl<'a, 'tcx> MaybeInProgressTables<'a, 'tcx> { - fn borrow(self) -> Ref<'a, ty::TypeckResults<'tcx>> { - match self.maybe_typeck_results { - Some(typeck_results) => typeck_results.borrow(), - None => bug!( - "MaybeInProgressTables: inh/fcx.typeck_results.borrow() with no typeck results" - ), - } - } - - fn borrow_mut(self) -> RefMut<'a, ty::TypeckResults<'tcx>> { - match self.maybe_typeck_results { - Some(typeck_results) => typeck_results.borrow_mut(), - None => bug!( - "MaybeInProgressTables: inh/fcx.typeck_results.borrow_mut() with no typeck results" - ), - } - } -} - /// Closures defined within the function. For example: /// /// fn foo() { diff --git a/compiler/rustc_typeck/src/check/util.rs b/compiler/rustc_typeck/src/check/util.rs index 973c9a2a26a..9a948c949ec 100644 --- a/compiler/rustc_typeck/src/check/util.rs +++ b/compiler/rustc_typeck/src/check/util.rs @@ -1,26 +1,54 @@ use rustc_hir::def_id::{CrateNum, LocalDefId, LOCAL_CRATE}; +use std::cell::{Ref, RefCell, RefMut}; + use super::wfcheck; use crate::check::CheckItemTypesVisitor; -use crate::TyCtxt; +use crate::{ty, TyCtxt}; + +/// A wrapper for `InferCtxt`'s `in_progress_typeck_results` field. +#[derive(Copy, Clone)] +pub(super) struct MaybeInProgressTables<'a, 'tcx> { + pub(super) maybe_typeck_results: Option<&'a RefCell<ty::TypeckResults<'tcx>>>, +} + +impl<'a, 'tcx> MaybeInProgressTables<'a, 'tcx> { + pub(super) fn borrow(self) -> Ref<'a, ty::TypeckResults<'tcx>> { + match self.maybe_typeck_results { + Some(typeck_results) => typeck_results.borrow(), + None => bug!( + "MaybeInProgressTables: inh/fcx.typeck_results.borrow() with no typeck results" + ), + } + } + + pub(super) fn borrow_mut(self) -> RefMut<'a, ty::TypeckResults<'tcx>> { + match self.maybe_typeck_results { + Some(typeck_results) => typeck_results.borrow_mut(), + None => bug!( + "MaybeInProgressTables: inh/fcx.typeck_results.borrow_mut() with no typeck results" + ), + } + } +} -pub fn check_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { +pub(super) fn check_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckItemTypesVisitor { tcx }); } -pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) { +pub(super) fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) { wfcheck::check_item_well_formed(tcx, def_id); } -pub fn check_trait_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) { +pub(super) fn check_trait_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) { wfcheck::check_trait_item(tcx, def_id); } -pub fn check_impl_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) { +pub(super) fn check_impl_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) { wfcheck::check_impl_item(tcx, def_id); } -pub fn typeck_item_bodies(tcx: TyCtxt<'_>, crate_num: CrateNum) { +pub(super) fn typeck_item_bodies(tcx: TyCtxt<'_>, crate_num: CrateNum) { debug_assert!(crate_num == LOCAL_CRATE); tcx.par_body_owners(|body_owner_def_id| { tcx.ensure().typeck(body_owner_def_id); |
