]> git.lizzy.rs Git - rust.git/commitdiff
Moved another struct and used pub(super) to be explicit
authorNicholas-Baron <nicholas.baron.ten@gmail.com>
Sat, 19 Sep 2020 08:09:45 +0000 (01:09 -0700)
committerNicholas-Baron <nicholas.baron.ten@gmail.com>
Mon, 21 Sep 2020 01:48:31 +0000 (18:48 -0700)
compiler/rustc_typeck/src/check/mod.rs
compiler/rustc_typeck/src/check/util.rs

index 1b542818b6fb94d2b6bc3d8876224bd586b8c47b..560248480cfe6f07b17bdf9d4bcba66100225fd4 100644 (file)
@@ -87,6 +87,7 @@
 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;
     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() {
index 973c9a2a26a18bfb67e0255d9fb8f58143563293..9a948c949ece32c9c0562bbc18027ea53ea9ef61 100644 (file)
@@ -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);