@@ -976,7 +976,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
976976 /// adjusted type of the expression, if successful.
977977 /// Adjustments are only recorded if the coercion succeeded.
978978 /// The expressions *must not* have any preexisting adjustments.
979- pub fn coerce (
979+ pub ( crate ) fn coerce (
980980 & self ,
981981 expr : & hir:: Expr < ' _ > ,
982982 expr_ty : Ty < ' tcx > ,
@@ -1011,7 +1011,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10111011 ///
10121012 /// Returns false if the coercion creates any obligations that result in
10131013 /// errors.
1014- pub fn can_coerce ( & self , expr_ty : Ty < ' tcx > , target : Ty < ' tcx > ) -> bool {
1014+ pub ( crate ) fn can_coerce ( & self , expr_ty : Ty < ' tcx > , target : Ty < ' tcx > ) -> bool {
10151015 // FIXME(-Znext-solver): We need to structurally resolve both types here.
10161016 let source = self . resolve_vars_with_obligations ( expr_ty) ;
10171017 debug ! ( "coercion::can_with_predicates({:?} -> {:?})" , source, target) ;
@@ -1032,7 +1032,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10321032 /// Given a type and a target type, this function will calculate and return
10331033 /// how many dereference steps needed to achieve `expr_ty <: target`. If
10341034 /// it's not possible, return `None`.
1035- pub fn deref_steps ( & self , expr_ty : Ty < ' tcx > , target : Ty < ' tcx > ) -> Option < usize > {
1035+ pub ( crate ) fn deref_steps ( & self , expr_ty : Ty < ' tcx > , target : Ty < ' tcx > ) -> Option < usize > {
10361036 let cause = self . cause ( DUMMY_SP , ObligationCauseCode :: ExprAssignable ) ;
10371037 // We don't ever need two-phase here since we throw out the result of the coercion
10381038 let coerce = Coerce :: new ( self , cause, AllowTwoPhase :: No ) ;
@@ -1047,7 +1047,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10471047 /// This function is for diagnostics only, since it does not register
10481048 /// trait or region sub-obligations. (presumably we could, but it's not
10491049 /// particularly important for diagnostics...)
1050- pub fn deref_once_mutably_for_diagnostic ( & self , expr_ty : Ty < ' tcx > ) -> Option < Ty < ' tcx > > {
1050+ pub ( crate ) fn deref_once_mutably_for_diagnostic ( & self , expr_ty : Ty < ' tcx > ) -> Option < Ty < ' tcx > > {
10511051 self . autoderef ( DUMMY_SP , expr_ty) . nth ( 1 ) . and_then ( |( deref_ty, _) | {
10521052 self . infcx
10531053 . type_implements_trait (
@@ -1341,7 +1341,7 @@ pub fn can_coerce<'tcx>(
13411341/// }
13421342/// let final_ty = coerce.complete(fcx);
13431343/// ```
1344- pub struct CoerceMany < ' tcx , ' exprs , E : AsCoercionSite > {
1344+ pub ( crate ) struct CoerceMany < ' tcx , ' exprs , E : AsCoercionSite > {
13451345 expected_ty : Ty < ' tcx > ,
13461346 final_ty : Option < Ty < ' tcx > > ,
13471347 expressions : Expressions < ' tcx , ' exprs , E > ,
@@ -1350,7 +1350,7 @@ pub struct CoerceMany<'tcx, 'exprs, E: AsCoercionSite> {
13501350
13511351/// The type of a `CoerceMany` that is storing up the expressions into
13521352/// a buffer. We use this in `check/mod.rs` for things like `break`.
1353- pub type DynamicCoerceMany < ' tcx > = CoerceMany < ' tcx , ' tcx , & ' tcx hir:: Expr < ' tcx > > ;
1353+ pub ( crate ) type DynamicCoerceMany < ' tcx > = CoerceMany < ' tcx , ' tcx , & ' tcx hir:: Expr < ' tcx > > ;
13541354
13551355enum Expressions < ' tcx , ' exprs , E : AsCoercionSite > {
13561356 Dynamic ( Vec < & ' tcx hir:: Expr < ' tcx > > ) ,
@@ -1361,7 +1361,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
13611361 /// The usual case; collect the set of expressions dynamically.
13621362 /// If the full set of coercion sites is known before hand,
13631363 /// consider `with_coercion_sites()` instead to avoid allocation.
1364- pub fn new ( expected_ty : Ty < ' tcx > ) -> Self {
1364+ pub ( crate ) fn new ( expected_ty : Ty < ' tcx > ) -> Self {
13651365 Self :: make ( expected_ty, Expressions :: Dynamic ( vec ! [ ] ) )
13661366 }
13671367
@@ -1370,7 +1370,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
13701370 /// expected to pass each element in the slice to `coerce(...)` in
13711371 /// order. This is used with arrays in particular to avoid
13721372 /// needlessly cloning the slice.
1373- pub fn with_coercion_sites ( expected_ty : Ty < ' tcx > , coercion_sites : & ' exprs [ E ] ) -> Self {
1373+ pub ( crate ) fn with_coercion_sites ( expected_ty : Ty < ' tcx > , coercion_sites : & ' exprs [ E ] ) -> Self {
13741374 Self :: make ( expected_ty, Expressions :: UpFront ( coercion_sites) )
13751375 }
13761376
@@ -1386,15 +1386,15 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
13861386 /// Typically, this is used as the expected type when
13871387 /// type-checking each of the alternative expressions whose types
13881388 /// we are trying to merge.
1389- pub fn expected_ty ( & self ) -> Ty < ' tcx > {
1389+ pub ( crate ) fn expected_ty ( & self ) -> Ty < ' tcx > {
13901390 self . expected_ty
13911391 }
13921392
13931393 /// Returns the current "merged type", representing our best-guess
13941394 /// at the LUB of the expressions we've seen so far (if any). This
13951395 /// isn't *final* until you call `self.complete()`, which will return
13961396 /// the merged type.
1397- pub fn merged_ty ( & self ) -> Ty < ' tcx > {
1397+ pub ( crate ) fn merged_ty ( & self ) -> Ty < ' tcx > {
13981398 self . final_ty . unwrap_or ( self . expected_ty )
13991399 }
14001400
@@ -1403,7 +1403,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14031403 /// could coerce from. This will record `expression`, and later
14041404 /// calls to `coerce` may come back and add adjustments and things
14051405 /// if necessary.
1406- pub fn coerce < ' a > (
1406+ pub ( crate ) fn coerce < ' a > (
14071407 & mut self ,
14081408 fcx : & FnCtxt < ' a , ' tcx > ,
14091409 cause : & ObligationCause < ' tcx > ,
@@ -1425,7 +1425,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14251425 /// The `augment_error` gives you a chance to extend the error
14261426 /// message, in case any results (e.g., we use this to suggest
14271427 /// removing a `;`).
1428- pub fn coerce_forced_unit < ' a > (
1428+ pub ( crate ) fn coerce_forced_unit < ' a > (
14291429 & mut self ,
14301430 fcx : & FnCtxt < ' a , ' tcx > ,
14311431 cause : & ObligationCause < ' tcx > ,
@@ -1920,7 +1920,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
19201920 }
19211921 }
19221922
1923- pub fn complete < ' a > ( self , fcx : & FnCtxt < ' a , ' tcx > ) -> Ty < ' tcx > {
1923+ pub ( crate ) fn complete < ' a > ( self , fcx : & FnCtxt < ' a , ' tcx > ) -> Ty < ' tcx > {
19241924 if let Some ( final_ty) = self . final_ty {
19251925 final_ty
19261926 } else {
@@ -1934,7 +1934,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
19341934
19351935/// Something that can be converted into an expression to which we can
19361936/// apply a coercion.
1937- pub trait AsCoercionSite {
1937+ pub ( crate ) trait AsCoercionSite {
19381938 fn as_coercion_site ( & self ) -> & hir:: Expr < ' _ > ;
19391939}
19401940
0 commit comments