diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2022-05-20 19:51:09 -0400 |
|---|---|---|
| committer | Jacob Pratt <jacob@jhpratt.dev> | 2022-05-20 20:04:54 -0400 |
| commit | 49c82f31a85f04a709810de4ccfb8ba765c1377b (patch) | |
| tree | dbcbf74a4c0cef46af19b4b24f04dd2e79e3ea23 /compiler/rustc_mir_build/src | |
| parent | 536020c5f97883aa9f2a90897a5adb520486d2e1 (diff) | |
| download | rust-49c82f31a85f04a709810de4ccfb8ba765c1377b.tar.gz rust-49c82f31a85f04a709810de4ccfb8ba765c1377b.zip | |
Remove `crate` visibility usage in compiler
Diffstat (limited to 'compiler/rustc_mir_build/src')
28 files changed, 140 insertions, 129 deletions
diff --git a/compiler/rustc_mir_build/src/build/block.rs b/compiler/rustc_mir_build/src/build/block.rs index 679043bdc30..a83328c0cab 100644 --- a/compiler/rustc_mir_build/src/build/block.rs +++ b/compiler/rustc_mir_build/src/build/block.rs @@ -6,7 +6,7 @@ use rustc_middle::{mir::*, ty}; use rustc_span::Span; impl<'a, 'tcx> Builder<'a, 'tcx> { - crate fn ast_block( + pub(crate) fn ast_block( &mut self, destination: Place<'tcx>, block: BasicBlock, diff --git a/compiler/rustc_mir_build/src/build/cfg.rs b/compiler/rustc_mir_build/src/build/cfg.rs index ac92b03e5f3..d7b4b1f731a 100644 --- a/compiler/rustc_mir_build/src/build/cfg.rs +++ b/compiler/rustc_mir_build/src/build/cfg.rs @@ -5,33 +5,33 @@ use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; impl<'tcx> CFG<'tcx> { - crate fn block_data(&self, blk: BasicBlock) -> &BasicBlockData<'tcx> { + pub(crate) fn block_data(&self, blk: BasicBlock) -> &BasicBlockData<'tcx> { &self.basic_blocks[blk] } - crate fn block_data_mut(&mut self, blk: BasicBlock) -> &mut BasicBlockData<'tcx> { + pub(crate) fn block_data_mut(&mut self, blk: BasicBlock) -> &mut BasicBlockData<'tcx> { &mut self.basic_blocks[blk] } // llvm.org/PR32488 makes this function use an excess of stack space. Mark // it as #[inline(never)] to keep rustc's stack use in check. #[inline(never)] - crate fn start_new_block(&mut self) -> BasicBlock { + pub(crate) fn start_new_block(&mut self) -> BasicBlock { self.basic_blocks.push(BasicBlockData::new(None)) } - crate fn start_new_cleanup_block(&mut self) -> BasicBlock { + pub(crate) fn start_new_cleanup_block(&mut self) -> BasicBlock { let bb = self.start_new_block(); self.block_data_mut(bb).is_cleanup = true; bb } - crate fn push(&mut self, block: BasicBlock, statement: Statement<'tcx>) { + pub(crate) fn push(&mut self, block: BasicBlock, statement: Statement<'tcx>) { debug!("push({:?}, {:?})", block, statement); self.block_data_mut(block).statements.push(statement); } - crate fn push_assign( + pub(crate) fn push_assign( &mut self, block: BasicBlock, source_info: SourceInfo, @@ -44,7 +44,7 @@ impl<'tcx> CFG<'tcx> { ); } - crate fn push_assign_constant( + pub(crate) fn push_assign_constant( &mut self, block: BasicBlock, source_info: SourceInfo, @@ -59,7 +59,7 @@ impl<'tcx> CFG<'tcx> { ); } - crate fn push_assign_unit( + pub(crate) fn push_assign_unit( &mut self, block: BasicBlock, source_info: SourceInfo, @@ -78,7 +78,7 @@ impl<'tcx> CFG<'tcx> { ); } - crate fn push_fake_read( + pub(crate) fn push_fake_read( &mut self, block: BasicBlock, source_info: SourceInfo, @@ -90,7 +90,7 @@ impl<'tcx> CFG<'tcx> { self.push(block, stmt); } - crate fn terminate( + pub(crate) fn terminate( &mut self, block: BasicBlock, source_info: SourceInfo, @@ -107,7 +107,7 @@ impl<'tcx> CFG<'tcx> { } /// In the `origin` block, push a `goto -> target` terminator. - crate fn goto(&mut self, origin: BasicBlock, source_info: SourceInfo, target: BasicBlock) { + pub(crate) fn goto(&mut self, origin: BasicBlock, source_info: SourceInfo, target: BasicBlock) { self.terminate(origin, source_info, TerminatorKind::Goto { target }) } } diff --git a/compiler/rustc_mir_build/src/build/expr/as_constant.rs b/compiler/rustc_mir_build/src/build/expr/as_constant.rs index 25ba5d570b8..035e94eecee 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_constant.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_constant.rs @@ -11,7 +11,7 @@ use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, TyCtxt}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Compile `expr`, yielding a compile-time constant. Assumes that /// `expr` is a valid compile-time constant! - crate fn as_constant(&mut self, expr: &Expr<'tcx>) -> Constant<'tcx> { + pub(crate) fn as_constant(&mut self, expr: &Expr<'tcx>) -> Constant<'tcx> { let create_uneval_from_def_id = |tcx: TyCtxt<'tcx>, def_id: DefId, ty: Ty<'tcx>, substs: SubstsRef<'tcx>| { let uneval = ty::Unevaluated::new(ty::WithOptConstParam::unknown(def_id), substs); diff --git a/compiler/rustc_mir_build/src/build/expr/as_operand.rs b/compiler/rustc_mir_build/src/build/expr/as_operand.rs index 7eca49454ba..e707c373f0d 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_operand.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_operand.rs @@ -14,7 +14,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// after the current enclosing `ExprKind::Scope` has ended, so /// please do *not* return it from functions to avoid bad /// miscompiles. - crate fn as_local_operand( + pub(crate) fn as_local_operand( &mut self, block: BasicBlock, expr: &Expr<'tcx>, @@ -73,7 +73,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// value to the stack. /// /// See #68034 for more details. - crate fn as_local_call_operand( + pub(crate) fn as_local_call_operand( &mut self, block: BasicBlock, expr: &Expr<'tcx>, @@ -97,7 +97,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// Like `as_local_call_operand`, except that the argument will /// not be valid once `scope` ends. #[instrument(level = "debug", skip(self, scope))] - crate fn as_operand( + pub(crate) fn as_operand( &mut self, mut block: BasicBlock, scope: Option<region::Scope>, @@ -132,7 +132,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - crate fn as_call_operand( + pub(crate) fn as_call_operand( &mut self, mut block: BasicBlock, scope: Option<region::Scope>, diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index fa1bb0622bd..045d6eb1c30 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -21,7 +21,7 @@ use std::iter; /// The "outermost" place that holds this value. #[derive(Copy, Clone, Debug, PartialEq)] -crate enum PlaceBase { +pub(crate) enum PlaceBase { /// Denotes the start of a `Place`. Local(Local), @@ -71,7 +71,7 @@ crate enum PlaceBase { /// This is used internally when building a place for an expression like `a.b.c`. The fields `b` /// and `c` can be progressively pushed onto the place builder that is created when converting `a`. #[derive(Clone, Debug, PartialEq)] -crate struct PlaceBuilder<'tcx> { +pub(crate) struct PlaceBuilder<'tcx> { base: PlaceBase, projection: Vec<PlaceElem<'tcx>>, } @@ -283,7 +283,7 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>( } impl<'tcx> PlaceBuilder<'tcx> { - crate fn into_place<'a>( + pub(crate) fn into_place<'a>( self, tcx: TyCtxt<'tcx>, typeck_results: &'a ty::TypeckResults<'tcx>, @@ -314,7 +314,7 @@ impl<'tcx> PlaceBuilder<'tcx> { /// not captured. This can happen because the final mir that will be /// generated doesn't require a read for this place. Failures will only /// happen inside closures. - crate fn try_upvars_resolved<'a>( + pub(crate) fn try_upvars_resolved<'a>( self, tcx: TyCtxt<'tcx>, typeck_results: &'a ty::TypeckResults<'tcx>, @@ -322,19 +322,19 @@ impl<'tcx> PlaceBuilder<'tcx> { to_upvars_resolved_place_builder(self, tcx, typeck_results) } - crate fn base(&self) -> PlaceBase { + pub(crate) fn base(&self) -> PlaceBase { self.base } - crate fn field(self, f: Field, ty: Ty<'tcx>) -> Self { + pub(crate) fn field(self, f: Field, ty: Ty<'tcx>) -> Self { self.project(PlaceElem::Field(f, ty)) } - crate fn deref(self) -> Self { + pub(crate) fn deref(self) -> Self { self.project(PlaceElem::Deref) } - crate fn downcast(self, adt_def: AdtDef<'tcx>, variant_index: VariantIdx) -> Self { + pub(crate) fn downcast(self, adt_def: AdtDef<'tcx>, variant_index: VariantIdx) -> Self { self.project(PlaceElem::Downcast(Some(adt_def.variant(variant_index).name), variant_index)) } @@ -342,7 +342,7 @@ impl<'tcx> PlaceBuilder<'tcx> { self.project(PlaceElem::Index(index)) } - crate fn project(mut self, elem: PlaceElem<'tcx>) -> Self { + pub(crate) fn project(mut self, elem: PlaceElem<'tcx>) -> Self { self.projection.push(elem); self } @@ -373,7 +373,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// Extra care is needed if any user code is allowed to run between calling /// this method and using it, as is the case for `match` and index /// expressions. - crate fn as_place( + pub(crate) fn as_place( &mut self, mut block: BasicBlock, expr: &Expr<'tcx>, @@ -384,7 +384,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// This is used when constructing a compound `Place`, so that we can avoid creating /// intermediate `Place` values until we know the full set of projections. - crate fn as_place_builder( + pub(crate) fn as_place_builder( &mut self, block: BasicBlock, expr: &Expr<'tcx>, @@ -397,7 +397,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// place. The place itself may or may not be mutable: /// * If this expr is a place expr like a.b, then we will return that place. /// * Otherwise, a temporary is created: in that event, it will be an immutable temporary. - crate fn as_read_only_place( + pub(crate) fn as_read_only_place( &mut self, mut block: BasicBlock, expr: &Expr<'tcx>, diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index d807500f1fb..0fd67f15b75 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -21,7 +21,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// The operand returned from this function will *not be valid* after /// an ExprKind::Scope is passed, so please do *not* return it from /// functions to avoid bad miscompiles. - crate fn as_local_rvalue( + pub(crate) fn as_local_rvalue( &mut self, block: BasicBlock, expr: &Expr<'tcx>, @@ -31,7 +31,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } /// Compile `expr`, yielding an rvalue. - crate fn as_rvalue( + pub(crate) fn as_rvalue( &mut self, mut block: BasicBlock, scope: Option<region::Scope>, @@ -416,7 +416,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - crate fn build_binary_op( + pub(crate) fn build_binary_op( &mut self, mut block: BasicBlock, op: BinOp, diff --git a/compiler/rustc_mir_build/src/build/expr/as_temp.rs b/compiler/rustc_mir_build/src/build/expr/as_temp.rs index 6067da2f69b..724b72f8769 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_temp.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_temp.rs @@ -10,7 +10,7 @@ use rustc_middle::thir::*; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Compile `expr` into a fresh temporary. This is used when building /// up rvalues so as to freeze the value that will be consumed. - crate fn as_temp( + pub(crate) fn as_temp( &mut self, block: BasicBlock, temp_lifetime: Option<region::Scope>, diff --git a/compiler/rustc_mir_build/src/build/expr/category.rs b/compiler/rustc_mir_build/src/build/expr/category.rs index bcece39c620..b1a70643934 100644 --- a/compiler/rustc_mir_build/src/build/expr/category.rs +++ b/compiler/rustc_mir_build/src/build/expr/category.rs @@ -1,7 +1,7 @@ use rustc_middle::thir::*; #[derive(Debug, PartialEq)] -crate enum Category { +pub(crate) enum Category { // An assignable memory location like `x`, `x.f`, `foo()[3]`, that // sort of thing. Something that could appear on the LHS of an `=` // sign. @@ -19,7 +19,7 @@ crate enum Category { // Rvalues fall into different "styles" that will determine which fn // is best suited to generate them. #[derive(Debug, PartialEq)] -crate enum RvalueFunc { +pub(crate) enum RvalueFunc { // Best generated by `into`. This is generally exprs that // cause branching, like `match`, but also includes calls. Into, @@ -31,7 +31,7 @@ crate enum RvalueFunc { /// Determines the category for a given expression. Note that scope /// and paren expressions have no category. impl Category { - crate fn of(ek: &ExprKind<'_>) -> Option<Category> { + pub(crate) fn of(ek: &ExprKind<'_>) -> Option<Category> { match *ek { ExprKind::Scope { .. } => None, diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs index 4399fdf8520..e912501d55f 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/build/expr/into.rs @@ -15,7 +15,7 @@ use std::iter; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Compile `expr`, storing the result into `destination`, which /// is assumed to be uninitialized. - crate fn expr_into_dest( + pub(crate) fn expr_into_dest( &mut self, destination: Place<'tcx>, mut block: BasicBlock, diff --git a/compiler/rustc_mir_build/src/build/expr/mod.rs b/compiler/rustc_mir_build/src/build/expr/mod.rs index 7be435cda7d..f5ae060d603 100644 --- a/compiler/rustc_mir_build/src/build/expr/mod.rs +++ b/compiler/rustc_mir_build/src/build/expr/mod.rs @@ -60,7 +60,7 @@ //! basically the point where the "by value" operations are bridged //! over to the "by reference" mode (`as_place`). -crate mod as_constant; +pub(crate) mod as_constant; mod as_operand; pub mod as_place; mod as_rvalue; diff --git a/compiler/rustc_mir_build/src/build/expr/stmt.rs b/compiler/rustc_mir_build/src/build/expr/stmt.rs index 46c616ff362..a7e1331aabc 100644 --- a/compiler/rustc_mir_build/src/build/expr/stmt.rs +++ b/compiler/rustc_mir_build/src/build/expr/stmt.rs @@ -10,7 +10,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// (e.g., `some().code(&here());`) then `opt_stmt_span` is the /// span of that statement (including its semicolon, if any). /// The scope is used if a statement temporary must be dropped. - crate fn stmt_expr( + pub(crate) fn stmt_expr( &mut self, mut block: BasicBlock, expr: &Expr<'tcx>, diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 05b1342cf8c..83ecd185b3c 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -151,7 +151,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// /// * From each pre-binding block to the next pre-binding block. /// * From each otherwise block to the next pre-binding block. - crate fn match_expr( + pub(crate) fn match_expr( &mut self, destination: Place<'tcx>, span: Span, @@ -577,7 +577,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - crate fn place_into_pattern( + pub(crate) fn place_into_pattern( &mut self, block: BasicBlock, irrefutable_pat: Pat<'tcx>, @@ -653,7 +653,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// scope for the bindings in these patterns, if such a scope had to be /// created. NOTE: Declaring the bindings should always be done in their /// drop scope. - crate fn declare_bindings( + pub(crate) fn declare_bindings( &mut self, mut visibility_scope: Option<SourceScope>, scope_span: Span, @@ -690,7 +690,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { visibility_scope } - crate fn storage_live_binding( + pub(crate) fn storage_live_binding( &mut self, block: BasicBlock, var: HirId, @@ -709,7 +709,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Place::from(local_id) } - crate fn schedule_drop_for_binding(&mut self, var: HirId, span: Span, for_guard: ForGuard) { + pub(crate) fn schedule_drop_for_binding( + &mut self, + var: HirId, + span: Span, + for_guard: ForGuard, + ) { let local_id = self.var_local_id(var, for_guard); if let Some(region_scope) = self.region_scope_tree.var_scope(var.local_id) { self.schedule_drop(span, region_scope, local_id, DropKind::Value); @@ -934,7 +939,7 @@ struct Ascription<'tcx> { } #[derive(Clone, Debug)] -crate struct MatchPair<'pat, 'tcx> { +pub(crate) struct MatchPair<'pat, 'tcx> { // this place... place: PlaceBuilder<'tcx>, @@ -991,7 +996,7 @@ enum TestKind<'tcx> { /// [`Test`] is just the test to perform; it does not include the value /// to be tested. #[derive(Debug)] -crate struct Test<'tcx> { +pub(crate) struct Test<'tcx> { span: Span, kind: TestKind<'tcx>, } @@ -999,7 +1004,7 @@ crate struct Test<'tcx> { /// `ArmHasGuard` is a wrapper around a boolean flag. It indicates whether /// a match arm has a guard expression attached to it. #[derive(Copy, Clone, Debug)] -crate struct ArmHasGuard(crate bool); +pub(crate) struct ArmHasGuard(pub(crate) bool); /////////////////////////////////////////////////////////////////////////// // Main matching algorithm @@ -1769,7 +1774,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Pat binding - used for `let` and function parameters as well. impl<'a, 'tcx> Builder<'a, 'tcx> { - crate fn lower_let_expr( + pub(crate) fn lower_let_expr( &mut self, mut block: BasicBlock, expr: &Expr<'tcx>, diff --git a/compiler/rustc_mir_build/src/build/matches/util.rs b/compiler/rustc_mir_build/src/build/matches/util.rs index 88dd76e37c1..9a1e98d3bb1 100644 --- a/compiler/rustc_mir_build/src/build/matches/util.rs +++ b/compiler/rustc_mir_build/src/build/matches/util.rs @@ -8,7 +8,7 @@ use smallvec::SmallVec; use std::convert::TryInto; impl<'a, 'tcx> Builder<'a, 'tcx> { - crate fn field_match_pairs<'pat>( + pub(crate) fn field_match_pairs<'pat>( &mut self, place: PlaceBuilder<'tcx>, subpatterns: &'pat [FieldPat<'tcx>], @@ -22,7 +22,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .collect() } - crate fn prefix_slice_suffix<'pat>( + pub(crate) fn prefix_slice_suffix<'pat>( &mut self, match_pairs: &mut SmallVec<[MatchPair<'pat, 'tcx>; 1]>, place: &PlaceBuilder<'tcx>, @@ -79,7 +79,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// Creates a false edge to `imaginary_target` and a real edge to /// real_target. If `imaginary_target` is none, or is the same as the real /// target, a Goto is generated instead to simplify the generated MIR. - crate fn false_edges( + pub(crate) fn false_edges( &mut self, from_block: BasicBlock, real_target: BasicBlock, @@ -100,7 +100,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } impl<'pat, 'tcx> MatchPair<'pat, 'tcx> { - crate fn new(place: PlaceBuilder<'tcx>, pattern: &'pat Pat<'tcx>) -> MatchPair<'pat, 'tcx> { + pub(crate) fn new( + place: PlaceBuilder<'tcx>, + pattern: &'pat Pat<'tcx>, + ) -> MatchPair<'pat, 'tcx> { MatchPair { place, pattern } } } diff --git a/compiler/rustc_mir_build/src/build/misc.rs b/compiler/rustc_mir_build/src/build/misc.rs index 8b1ab482ee8..86f466ff767 100644 --- a/compiler/rustc_mir_build/src/build/misc.rs +++ b/compiler/rustc_mir_build/src/build/misc.rs @@ -14,7 +14,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// /// N.B., **No cleanup is scheduled for this temporary.** You should /// call `schedule_drop` once the temporary is initialized. - crate fn temp(&mut self, ty: Ty<'tcx>, span: Span) -> Place<'tcx> { + pub(crate) fn temp(&mut self, ty: Ty<'tcx>, span: Span) -> Place<'tcx> { // Mark this local as internal to avoid temporaries with types not present in the // user's code resulting in ICEs from the generator transform. let temp = self.local_decls.push(LocalDecl::new(ty, span).internal()); @@ -25,20 +25,24 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// Convenience function for creating a literal operand, one /// without any user type annotation. - crate fn literal_operand(&mut self, span: Span, literal: ConstantKind<'tcx>) -> Operand<'tcx> { + pub(crate) fn literal_operand( + &mut self, + span: Span, + literal: ConstantKind<'tcx>, + ) -> Operand<'tcx> { let constant = Box::new(Constant { span, user_ty: None, literal }); Operand::Constant(constant) } // Returns a zero literal operand for the appropriate type, works for // bool, char and integers. - crate fn zero_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> { + pub(crate) fn zero_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> { let literal = ConstantKind::from_bits(self.tcx, 0, ty::ParamEnv::empty().and(ty)); self.literal_operand(span, literal) } - crate fn push_usize( + pub(crate) fn push_usize( &mut self, block: BasicBlock, source_info: SourceInfo, @@ -59,7 +63,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { temp } - crate fn consume_by_copy_or_move(&self, place: Place<'tcx>) -> Operand<'tcx> { + pub(crate) fn consume_by_copy_or_move(&self, place: Place<'tcx>) -> Operand<'tcx> { let tcx = self.tcx; let ty = place.ty(&self.local_decls, tcx).ty; if !self.infcx.type_is_copy_modulo_regions(self.param_env, ty, DUMMY_SP) { diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 1cbe8c5a68a..4ae74433df6 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -26,7 +26,7 @@ use rustc_target::spec::abi::Abi; use super::lints; -crate fn mir_built<'tcx>( +pub(crate) fn mir_built<'tcx>( tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalDefId>, ) -> &'tcx rustc_data_structures::steal::Steal<Body<'tcx>> { diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index 465bd62406e..2d14a78accf 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -177,7 +177,7 @@ struct IfThenScope { /// The target of an expression that breaks out of a scope #[derive(Clone, Copy, Debug)] -crate enum BreakableTarget { +pub(crate) enum BreakableTarget { Continue(region::Scope), Break(region::Scope), Return, @@ -445,7 +445,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // ========================== // Start a breakable scope, which tracks where `continue`, `break` and // `return` should branch to. - crate fn in_breakable_scope<F>( + pub(crate) fn in_breakable_scope<F>( &mut self, loop_block: Option<BasicBlock>, break_destination: Place<'tcx>, @@ -507,7 +507,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// - We don't need to keep a stack of scopes in the `Builder` because the /// 'else' paths will only leave the innermost scope. /// - This is also used for match guards. - crate fn in_if_then_scope<F>( + pub(crate) fn in_if_then_scope<F>( &mut self, region_scope: region::Scope, f: F, @@ -530,7 +530,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { (then_block, else_block) } - crate fn in_opt_scope<F, R>( + pub(crate) fn in_opt_scope<F, R>( &mut self, opt_scope: Option<(region::Scope, SourceInfo)>, f: F, @@ -553,7 +553,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// Convenience wrapper that pushes a scope and then executes `f` /// to build its contents, popping the scope afterwards. - crate fn in_scope<F, R>( + pub(crate) fn in_scope<F, R>( &mut self, region_scope: (region::Scope, SourceInfo), lint_level: LintLevel, @@ -597,14 +597,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// scope and call `pop_scope` afterwards. Note that these two /// calls must be paired; using `in_scope` as a convenience /// wrapper maybe preferable. - crate fn push_scope(&mut self, region_scope: (region::Scope, SourceInfo)) { + pub(crate) fn push_scope(&mut self, region_scope: (region::Scope, SourceInfo)) { self.scopes.push_scope(region_scope, self.source_scope); } /// Pops a scope, which should have region scope `region_scope`, /// adding any drops onto the end of `block` that are needed. /// This must match 1-to-1 with `push_scope`. - crate fn pop_scope( + pub(crate) fn pop_scope( &mut self, region_scope: (region::Scope, SourceInfo), mut block: BasicBlock, @@ -619,7 +619,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } /// Sets up the drops for breaking from `block` to `target`. - crate fn break_scope( + pub(crate) fn break_scope( &mut self, mut block: BasicBlock, value: Option<&Expr<'tcx>>, @@ -698,7 +698,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.cfg.start_new_block().unit() } - crate fn break_for_else( + pub(crate) fn break_for_else( &mut self, block: BasicBlock, target: region::Scope, @@ -756,7 +756,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } /// Creates a new source scope, nested in the current one. - crate fn new_source_scope( + pub(crate) fn new_source_scope( &mut self, span: Span, lint_level: LintLevel, @@ -791,7 +791,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } /// Given a span and the current source scope, make a SourceInfo. - crate fn source_info(&self, span: Span) -> SourceInfo { + pub(crate) fn source_info(&self, span: Span) -> SourceInfo { SourceInfo { span, scope: self.source_scope } } @@ -816,13 +816,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// We would allocate the box but then free it on the unwinding /// path; we would also emit a free on the 'success' path from /// panic, but that will turn out to be removed as dead-code. - crate fn local_scope(&self) -> region::Scope { + pub(crate) fn local_scope(&self) -> region::Scope { self.scopes.topmost() } // Scheduling drops // ================ - crate fn schedule_drop_storage_and_value( + pub(crate) fn schedule_drop_storage_and_value( &mut self, span: Span, region_scope: region::Scope, @@ -836,7 +836,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// /// When called with `DropKind::Storage`, `place` shouldn't be the return /// place, or a function parameter. - crate fn schedule_drop( + pub(crate) fn schedule_drop( &mut self, span: Span, region_scope: region::Scope, @@ -969,7 +969,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// spurious borrow-check errors -- the problem, ironically, is /// not the `DROP(_X)` itself, but the (spurious) unwind pathways /// that it creates. See #64391 for an example. - crate fn record_operands_moved(&mut self, operands: &[Operand<'tcx>]) { + pub(crate) fn record_operands_moved(&mut self, operands: &[Operand<'tcx>]) { let local_scope = self.local_scope(); let scope = self.scopes.scopes.last_mut().unwrap(); @@ -1026,7 +1026,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// /// This path terminates in Resume. The path isn't created until after all /// of the non-unwind paths in this item have been lowered. - crate fn diverge_from(&mut self, start: BasicBlock) { + pub(crate) fn diverge_from(&mut self, start: BasicBlock) { debug_assert!( matches!( self.cfg.block_data(start).terminator().kind, @@ -1048,7 +1048,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// [TerminatorKind::Yield]. /// /// This path terminates in GeneratorDrop. - crate fn generator_drop_cleanup(&mut self, yield_block: BasicBlock) { + pub(crate) fn generator_drop_cleanup(&mut self, yield_block: BasicBlock) { debug_assert!( matches!( self.cfg.block_data(yield_block).terminator().kind, @@ -1078,7 +1078,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } /// Utility function for *non*-scope code to build their own drops - crate fn build_drop_and_replace( + pub(crate) fn build_drop_and_replace( &mut self, block: BasicBlock, span: Span, @@ -1101,7 +1101,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// Creates an `Assert` terminator and return the success block. /// If the boolean condition operand is not the expected value, /// a runtime panic will be caused with the given message. - crate fn assert( + pub(crate) fn assert( &mut self, block: BasicBlock, cond: Operand<'tcx>, @@ -1126,7 +1126,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// /// This is only needed for `match` arm scopes, because they have one /// entrance per pattern, but only one exit. - crate fn clear_top_scope(&mut self, region_scope: region::Scope) { + pub(crate) fn clear_top_scope(&mut self, region_scope: region::Scope) { let top_scope = self.scopes.scopes.last_mut().unwrap(); assert_eq!(top_scope.region_scope, region_scope); @@ -1262,7 +1262,7 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> { } /// Build the unwind and generator drop trees. - crate fn build_drop_trees(&mut self) { + pub(crate) fn build_drop_trees(&mut self) { if self.generator_kind.is_some() { self.build_generator_drop_trees(); } else { diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 6c14f207a7d..94b2722dca8 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -678,7 +678,7 @@ pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalD visitor.visit_expr(&thir[expr]); } -crate fn thir_check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) { +pub(crate) fn thir_check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) { if let Some(def) = ty::WithOptConstParam::try_lookup(def_id, tcx) { tcx.thir_check_unsafety_for_const_arg(def) } else { @@ -686,7 +686,7 @@ crate fn thir_check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) { } } -crate fn thir_check_unsafety_for_const_arg<'tcx>( +pub(crate) fn thir_check_unsafety_for_const_arg<'tcx>( tcx: TyCtxt<'tcx>, (did, param_did): (LocalDefId, DefId), ) { diff --git a/compiler/rustc_mir_build/src/lib.rs b/compiler/rustc_mir_build/src/lib.rs index 4f0402bfa8b..11cd2a9aa4d 100644 --- a/compiler/rustc_mir_build/src/lib.rs +++ b/compiler/rustc_mir_build/src/lib.rs @@ -4,7 +4,6 @@ #![allow(rustc::potential_query_instability)] #![feature(box_patterns)] #![feature(control_flow_enum)] -#![feature(crate_visibility_modifier)] #![feature(if_let_guard)] #![feature(let_chains)] #![feature(let_else)] diff --git a/compiler/rustc_mir_build/src/lints.rs b/compiler/rustc_mir_build/src/lints.rs index bccff379873..5470cc1262e 100644 --- a/compiler/rustc_mir_build/src/lints.rs +++ b/compiler/rustc_mir_build/src/lints.rs @@ -9,7 +9,7 @@ use rustc_session::lint::builtin::UNCONDITIONAL_RECURSION; use rustc_span::Span; use std::ops::ControlFlow; -crate fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) { +pub(crate) fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) { let def_id = body.source.def_id().expect_local(); if let Some(fn_kind) = tcx.hir().get_by_def_id(def_id).fn_kind() { diff --git a/compiler/rustc_mir_build/src/thir/constant.rs b/compiler/rustc_mir_build/src/thir/constant.rs index 30d7fdb7fec..d82e6688633 100644 --- a/compiler/rustc_mir_build/src/thir/constant.rs +++ b/compiler/rustc_mir_build/src/thir/constant.rs @@ -8,7 +8,7 @@ use rustc_span::symbol::Symbol; use rustc_target::abi::Size; // FIXME Once valtrees are available, get rid of this function and the query -crate fn lit_to_const<'tcx>( +pub(crate) fn lit_to_const<'tcx>( tcx: TyCtxt<'tcx>, lit_input: LitToConstInput<'tcx>, ) -> Result<ty::Const<'tcx>, LitToConstError> { diff --git a/compiler/rustc_mir_build/src/thir/cx/block.rs b/compiler/rustc_mir_build/src/thir/cx/block.rs index 2d9b5c1d98a..72ce8c24cdd 100644 --- a/compiler/rustc_mir_build/src/thir/cx/block.rs +++ b/compiler/rustc_mir_build/src/thir/cx/block.rs @@ -8,7 +8,7 @@ use rustc_middle::ty; use rustc_index::vec::Idx; impl<'tcx> Cx<'tcx> { - crate fn mirror_block(&mut self, block: &'tcx hir::Block<'tcx>) -> Block { + pub(crate) fn mirror_block(&mut self, block: &'tcx hir::Block<'tcx>) -> Block { // We have to eagerly lower the "spine" of the statements // in order to get the lexical scoping correctly. let stmts = self.mirror_stmts(block.hir_id.local_id, block.stmts); diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 8f5ad6b1a07..b9879b9159f 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -22,12 +22,12 @@ use rustc_span::Span; use rustc_target::abi::VariantIdx; impl<'tcx> Cx<'tcx> { - crate fn mirror_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) -> ExprId { + pub(crate) fn mirror_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) -> ExprId { // `mirror_expr` is recursing very deep. Make sure the stack doesn't overflow. ensure_sufficient_stack(|| self.mirror_expr_inner(expr)) } - crate fn mirror_exprs(&mut self, exprs: &'tcx [hir::Expr<'tcx>]) -> Box<[ExprId]> { + pub(crate) fn mirror_exprs(&mut self, exprs: &'tcx [hir::Expr<'tcx>]) -> Box<[ExprId]> { exprs.iter().map(|expr| self.mirror_expr_inner(expr)).collect() } diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index aafc368d3fd..81eb7efad37 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -19,7 +19,7 @@ use rustc_middle::thir::*; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::Span; -crate fn thir_body<'tcx>( +pub(crate) fn thir_body<'tcx>( tcx: TyCtxt<'tcx>, owner_def: ty::WithOptConstParam<LocalDefId>, ) -> Result<(&'tcx Steal<Thir<'tcx>>, ExprId), ErrorGuaranteed> { @@ -33,7 +33,7 @@ crate fn thir_body<'tcx>( Ok((tcx.alloc_steal_thir(cx.thir), expr)) } -crate fn thir_tree<'tcx>( +pub(crate) fn thir_tree<'tcx>( tcx: TyCtxt<'tcx>, owner_def: ty::WithOptConstParam<LocalDefId>, ) -> String { @@ -47,10 +47,10 @@ struct Cx<'tcx> { tcx: TyCtxt<'tcx>, thir: Thir<'tcx>, - crate param_env: ty::ParamEnv<'tcx>, + pub(crate) param_env: ty::ParamEnv<'tcx>, - crate region_scope_tree: &'tcx region::ScopeTree, - crate typeck_results: &'tcx ty::TypeckResults<'tcx>, + pub(crate) region_scope_tree: &'tcx region::ScopeTree, + pub(crate) typeck_results: &'tcx ty::TypeckResults<'tcx>, /// When applying adjustments to the expression /// with the given `HirId`, use the given `Span`, @@ -79,7 +79,7 @@ impl<'tcx> Cx<'tcx> { } #[instrument(skip(self), level = "debug")] - crate fn const_eval_literal( + pub(crate) fn const_eval_literal( &mut self, lit: &'tcx ast::LitKind, ty: Ty<'tcx>, @@ -96,7 +96,7 @@ impl<'tcx> Cx<'tcx> { } } - crate fn pattern_from_hir(&mut self, p: &hir::Pat<'_>) -> Pat<'tcx> { + pub(crate) fn pattern_from_hir(&mut self, p: &hir::Pat<'_>) -> Pat<'tcx> { let p = match self.tcx.hir().get(p.hir_id) { Node::Pat(p) | Node::Binding(p) => p, node => bug!("pattern became {:?}", node), diff --git a/compiler/rustc_mir_build/src/thir/mod.rs b/compiler/rustc_mir_build/src/thir/mod.rs index ddbe1b0b69c..e0e6ac26654 100644 --- a/compiler/rustc_mir_build/src/thir/mod.rs +++ b/compiler/rustc_mir_build/src/thir/mod.rs @@ -4,10 +4,10 @@ //! unit-tested and separated from the Rust source and compiler data //! structures. -crate mod constant; +pub(crate) mod constant; -crate mod cx; +pub(crate) mod cx; -crate mod pattern; +pub(crate) mod pattern; mod util; diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index f86899021e3..dc204eb47ae 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -23,7 +23,7 @@ use rustc_session::Session; use rustc_span::source_map::Spanned; use rustc_span::{BytePos, DesugaringKind, ExpnKind, Span}; -crate fn check_match(tcx: TyCtxt<'_>, def_id: DefId) { +pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: DefId) { let body_id = match def_id.as_local() { None => return, Some(id) => tcx.hir().body_owned_by(tcx.hir().local_def_id_to_hir_id(id)), @@ -880,7 +880,7 @@ fn non_exhaustive_match<'p, 'tcx>( err.emit(); } -crate fn joined_uncovered_patterns<'p, 'tcx>( +pub(crate) fn joined_uncovered_patterns<'p, 'tcx>( cx: &MatchCheckCtxt<'p, 'tcx>, witnesses: &[DeconstructedPat<'p, 'tcx>], ) -> String { @@ -901,7 +901,7 @@ crate fn joined_uncovered_patterns<'p, 'tcx>( } } -crate fn pattern_not_covered_label( +pub(crate) fn pattern_not_covered_label( witnesses: &[DeconstructedPat<'_, '_>], joined_patterns: &str, ) -> String { diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 55d84782c48..1f152549a63 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -27,22 +27,22 @@ use rustc_span::{Span, Symbol}; use std::cmp::Ordering; #[derive(Clone, Debug)] -crate enum PatternError { +pub(crate) enum PatternError { AssocConstInPattern(Span), ConstParamInPattern(Span), StaticInPattern(Span), NonConstPath(Span), } -crate struct PatCtxt<'a, 'tcx> { - crate tcx: TyCtxt<'tcx>, - crate param_env: ty::ParamEnv<'tcx>, - crate typeck_results: &'a ty::TypeckResults<'tcx>, - crate errors: Vec<PatternError>, +pub(crate) struct PatCtxt<'a, 'tcx> { + pub(crate) tcx: TyCtxt<'tcx>, + pub(crate) param_env: ty::ParamEnv<'tcx>, + pub(crate) typeck_results: &'a ty::TypeckResults<'tcx>, + pub(crate) errors: Vec<PatternError>, include_lint_checks: bool, } -crate fn pat_from_hir<'a, 'tcx>( +pub(crate) fn pat_from_hir<'a, 'tcx>( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, typeck_results: &'a ty::TypeckResults<'tcx>, @@ -59,7 +59,7 @@ crate fn pat_from_hir<'a, 'tcx>( } impl<'a, 'tcx> PatCtxt<'a, 'tcx> { - crate fn new( + pub(crate) fn new( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, typeck_results: &'a ty::TypeckResults<'tcx>, @@ -67,12 +67,12 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { PatCtxt { tcx, param_env, typeck_results, errors: vec![], include_lint_checks: false } } - crate fn include_lint_checks(&mut self) -> &mut Self { + pub(crate) fn include_lint_checks(&mut self) -> &mut Self { self.include_lint_checks = true; self } - crate fn lower_pattern(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Pat<'tcx> { + pub(crate) fn lower_pattern(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Pat<'tcx> { // When implicit dereferences have been inserted in this pattern, the unadjusted lowered // pattern has the type that results *after* dereferencing. For example, in this code: // @@ -608,7 +608,7 @@ impl<'tcx> UserAnnotatedTyHelpers<'tcx> for PatCtxt<'_, 'tcx> { } } -crate trait PatternFoldable<'tcx>: Sized { +pub(crate) trait PatternFoldable<'tcx>: Sized { fn fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self { self.super_fold_with(folder) } @@ -616,7 +616,7 @@ crate trait PatternFoldable<'tcx>: Sized { fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self; } -crate trait PatternFolder<'tcx>: Sized { +pub(crate) trait PatternFolder<'tcx>: Sized { fn fold_pattern(&mut self, pattern: &Pat<'tcx>) -> Pat<'tcx> { pattern.super_fold_with(self) } @@ -746,7 +746,7 @@ impl<'tcx> PatternFoldable<'tcx> for PatKind<'tcx> { } #[instrument(skip(tcx), level = "debug")] -crate fn compare_const_vals<'tcx>( +pub(crate) fn compare_const_vals<'tcx>( tcx: TyCtxt<'tcx>, a: mir::ConstantKind<'tcx>, b: mir::ConstantKind<'tcx>, diff --git a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs index 4e96cfd9bbd..9e7a267ecbd 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs @@ -309,16 +309,16 @@ use smallvec::{smallvec, SmallVec}; use std::fmt; use std::iter::once; -crate struct MatchCheckCtxt<'p, 'tcx> { - crate tcx: TyCtxt<'tcx>, +pub(crate) struct MatchCheckCtxt<'p, 'tcx> { + pub(crate) tcx: TyCtxt<'tcx>, /// The module in which the match occurs. This is necessary for /// checking inhabited-ness of types because whether a type is (visibly) /// inhabited can depend on whether it was defined in the current module or /// not. E.g., `struct Foo { _private: ! }` cannot be seen to be empty /// outside its module and should not be matchable with an empty match statement. - crate module: DefId, - crate param_env: ty::ParamEnv<'tcx>, - crate pattern_arena: &'p TypedArena<DeconstructedPat<'p, 'tcx>>, + pub(crate) module: DefId, + pub(crate) param_env: ty::ParamEnv<'tcx>, + pub(crate) pattern_arena: &'p TypedArena<DeconstructedPat<'p, 'tcx>>, } impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> { @@ -691,7 +691,7 @@ enum ArmType { /// /// The final `Pair(Some(_), true)` is then the resulting witness. #[derive(Debug)] -crate struct Witness<'p, 'tcx>(Vec<DeconstructedPat<'p, 'tcx>>); +pub(crate) struct Witness<'p, 'tcx>(Vec<DeconstructedPat<'p, 'tcx>>); impl<'p, 'tcx> Witness<'p, 'tcx> { /// Asserts that the witness contains a single pattern, and returns it. @@ -908,16 +908,16 @@ fn is_useful<'p, 'tcx>( /// The arm of a match expression. #[derive(Clone, Copy, Debug)] -crate struct MatchArm<'p, 'tcx> { +pub(crate) struct MatchArm<'p, 'tcx> { /// The pattern must have been lowered through `check_match::MatchVisitor::lower_pattern`. - crate pat: &'p DeconstructedPat<'p, 'tcx>, - crate hir_id: HirId, - crate has_guard: bool, + pub(crate) pat: &'p DeconstructedPat<'p, 'tcx>, + pub(crate) hir_id: HirId, + pub(crate) has_guard: bool, } /// Indicates whether or not a given arm is reachable. #[derive(Clone, Debug)] -crate enum Reachability { +pub(crate) enum Reachability { /// The arm is reachable. This additionally carries a set of or-pattern branches that have been /// found to be unreachable despite the overall arm being reachable. Used only in the presence /// of or-patterns, otherwise it stays empty. @@ -927,12 +927,12 @@ crate enum Reachability { } /// The output of checking a match for exhaustiveness and arm reachability. -crate struct UsefulnessReport<'p, 'tcx> { +pub(crate) struct UsefulnessReport<'p, 'tcx> { /// For each arm of the input, whether that arm is reachable after the arms above it. - crate arm_usefulness: Vec<(MatchArm<'p, 'tcx>, Reachability)>, + pub(crate) arm_usefulness: Vec<(MatchArm<'p, 'tcx>, Reachability)>, /// If the match is exhaustive, this is empty. If not, this contains witnesses for the lack of /// exhaustiveness. - crate non_exhaustiveness_witnesses: Vec<DeconstructedPat<'p, 'tcx>>, + pub(crate) non_exhaustiveness_witnesses: Vec<DeconstructedPat<'p, 'tcx>>, } /// The entrypoint for the usefulness algorithm. Computes whether a match is exhaustive and which @@ -941,7 +941,7 @@ crate struct UsefulnessReport<'p, 'tcx> { /// Note: the input patterns must have been lowered through /// `check_match::MatchVisitor::lower_pattern`. #[instrument(skip(cx, arms), level = "debug")] -crate fn compute_match_usefulness<'p, 'tcx>( +pub(crate) fn compute_match_usefulness<'p, 'tcx>( cx: &MatchCheckCtxt<'p, 'tcx>, arms: &[MatchArm<'p, 'tcx>], scrut_hir_id: HirId, diff --git a/compiler/rustc_mir_build/src/thir/util.rs b/compiler/rustc_mir_build/src/thir/util.rs index 82f97f22cce..c58ed1ac0b8 100644 --- a/compiler/rustc_mir_build/src/thir/util.rs +++ b/compiler/rustc_mir_build/src/thir/util.rs @@ -1,7 +1,7 @@ use rustc_hir as hir; use rustc_middle::ty::{self, CanonicalUserType, TyCtxt, UserType}; -crate trait UserAnnotatedTyHelpers<'tcx> { +pub(crate) trait UserAnnotatedTyHelpers<'tcx> { fn tcx(&self) -> TyCtxt<'tcx>; fn typeck_results(&self) -> &ty::TypeckResults<'tcx>; |
