X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_typeck%2Fsrc%2Fmem_categorization.rs;h=21916352532b1698231bc935415ad7594aa53d14;hb=8fd9e24b9a7660fae2f10090e3063808d70afc97;hp=3d7b6593a645559c19452d2138e10de5a3c398e2;hpb=2af6677de8062390b530373dc6b82468afaadd35;p=rust.git diff --git a/compiler/rustc_typeck/src/mem_categorization.rs b/compiler/rustc_typeck/src/mem_categorization.rs index 3d7b6593a64..21916352532 100644 --- a/compiler/rustc_typeck/src/mem_categorization.rs +++ b/compiler/rustc_typeck/src/mem_categorization.rs @@ -65,7 +65,7 @@ use rustc_target::abi::VariantIdx; use rustc_trait_selection::infer::InferCtxtExt; -crate trait HirNode { +pub(crate) trait HirNode { fn hir_id(&self) -> hir::HirId; fn span(&self) -> Span; } @@ -89,19 +89,19 @@ fn span(&self) -> Span { } #[derive(Clone)] -crate struct MemCategorizationContext<'a, 'tcx> { - crate typeck_results: &'a ty::TypeckResults<'tcx>, +pub(crate) struct MemCategorizationContext<'a, 'tcx> { + pub(crate) typeck_results: &'a ty::TypeckResults<'tcx>, infcx: &'a InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, body_owner: LocalDefId, upvars: Option<&'tcx FxIndexMap>, } -crate type McResult = Result; +pub(crate) type McResult = Result; impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { /// Creates a `MemCategorizationContext`. - crate fn new( + pub(crate) fn new( infcx: &'a InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, body_owner: LocalDefId, @@ -116,11 +116,11 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { } } - crate fn tcx(&self) -> TyCtxt<'tcx> { + pub(crate) fn tcx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } - crate fn type_is_copy_modulo_regions(&self, ty: Ty<'tcx>, span: Span) -> bool { + pub(crate) fn type_is_copy_modulo_regions(&self, ty: Ty<'tcx>, span: Span) -> bool { self.infcx.type_is_copy_modulo_regions(self.param_env, ty, span) } @@ -162,7 +162,7 @@ fn resolve_type_vars_or_error( } } - crate fn node_ty(&self, hir_id: hir::HirId) -> McResult> { + pub(crate) fn node_ty(&self, hir_id: hir::HirId) -> McResult> { self.resolve_type_vars_or_error(hir_id, self.typeck_results.node_type_opt(hir_id)) } @@ -170,7 +170,7 @@ fn expr_ty(&self, expr: &hir::Expr<'_>) -> McResult> { self.resolve_type_vars_or_error(expr.hir_id, self.typeck_results.expr_ty_opt(expr)) } - crate fn expr_ty_adjusted(&self, expr: &hir::Expr<'_>) -> McResult> { + pub(crate) fn expr_ty_adjusted(&self, expr: &hir::Expr<'_>) -> McResult> { self.resolve_type_vars_or_error(expr.hir_id, self.typeck_results.expr_ty_adjusted_opt(expr)) } @@ -184,7 +184,7 @@ fn expr_ty(&self, expr: &hir::Expr<'_>) -> McResult> { /// implicit deref patterns attached (e.g., it is really /// `&Some(x)`). In that case, we return the "outermost" type /// (e.g., `&Option). - crate fn pat_ty_adjusted(&self, pat: &hir::Pat<'_>) -> McResult> { + pub(crate) fn pat_ty_adjusted(&self, pat: &hir::Pat<'_>) -> McResult> { // Check for implicit `&` types wrapping the pattern; note // that these are never attached to binding patterns, so // actually this is somewhat "disjoint" from the code below @@ -236,7 +236,7 @@ fn pat_ty_unadjusted(&self, pat: &hir::Pat<'_>) -> McResult> { Ok(ret_ty) } - crate fn cat_expr(&self, expr: &hir::Expr<'_>) -> McResult> { + pub(crate) fn cat_expr(&self, expr: &hir::Expr<'_>) -> McResult> { // This recursion helper avoids going through *too many* // adjustments, since *only* non-overloaded deref recurses. fn helper<'a, 'tcx>( @@ -255,7 +255,7 @@ fn helper<'a, 'tcx>( helper(self, expr, self.typeck_results.expr_adjustments(expr)) } - crate fn cat_expr_adjusted( + pub(crate) fn cat_expr_adjusted( &self, expr: &hir::Expr<'_>, previous: PlaceWithHirId<'tcx>, @@ -298,7 +298,10 @@ fn cat_expr_adjusted_with( } } - crate fn cat_expr_unadjusted(&self, expr: &hir::Expr<'_>) -> McResult> { + pub(crate) fn cat_expr_unadjusted( + &self, + expr: &hir::Expr<'_>, + ) -> McResult> { debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr); let expr_ty = self.expr_ty(expr)?; @@ -383,7 +386,7 @@ fn cat_expr_adjusted_with( } } - crate fn cat_res( + pub(crate) fn cat_res( &self, hir_id: hir::HirId, span: Span, @@ -440,7 +443,7 @@ fn cat_upvar(&self, hir_id: hir::HirId, var_id: hir::HirId) -> McResult McResult( + pub(crate) fn cat_projection( &self, node: &N, base_place: PlaceWithHirId<'tcx>, @@ -521,7 +524,7 @@ fn cat_deref( Ok(ret) } - crate fn cat_pattern( + pub(crate) fn cat_pattern( &self, place: PlaceWithHirId<'tcx>, pat: &hir::Pat<'_>,