@@ -976,7 +976,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
976
976
/// adjusted type of the expression, if successful.
977
977
/// Adjustments are only recorded if the coercion succeeded.
978
978
/// The expressions *must not* have any preexisting adjustments.
979
- pub fn coerce (
979
+ pub ( crate ) fn coerce (
980
980
& self ,
981
981
expr : & hir:: Expr < ' _ > ,
982
982
expr_ty : Ty < ' tcx > ,
@@ -1011,7 +1011,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1011
1011
///
1012
1012
/// Returns false if the coercion creates any obligations that result in
1013
1013
/// 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 {
1015
1015
// FIXME(-Znext-solver): We need to structurally resolve both types here.
1016
1016
let source = self . resolve_vars_with_obligations ( expr_ty) ;
1017
1017
debug ! ( "coercion::can_with_predicates({:?} -> {:?})" , source, target) ;
@@ -1032,7 +1032,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1032
1032
/// Given a type and a target type, this function will calculate and return
1033
1033
/// how many dereference steps needed to achieve `expr_ty <: target`. If
1034
1034
/// 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 > {
1036
1036
let cause = self . cause ( DUMMY_SP , ObligationCauseCode :: ExprAssignable ) ;
1037
1037
// We don't ever need two-phase here since we throw out the result of the coercion
1038
1038
let coerce = Coerce :: new ( self , cause, AllowTwoPhase :: No ) ;
@@ -1047,7 +1047,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1047
1047
/// This function is for diagnostics only, since it does not register
1048
1048
/// trait or region sub-obligations. (presumably we could, but it's not
1049
1049
/// 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 > > {
1051
1051
self . autoderef ( DUMMY_SP , expr_ty) . nth ( 1 ) . and_then ( |( deref_ty, _) | {
1052
1052
self . infcx
1053
1053
. type_implements_trait (
@@ -1341,7 +1341,7 @@ pub fn can_coerce<'tcx>(
1341
1341
/// }
1342
1342
/// let final_ty = coerce.complete(fcx);
1343
1343
/// ```
1344
- pub struct CoerceMany < ' tcx , ' exprs , E : AsCoercionSite > {
1344
+ pub ( crate ) struct CoerceMany < ' tcx , ' exprs , E : AsCoercionSite > {
1345
1345
expected_ty : Ty < ' tcx > ,
1346
1346
final_ty : Option < Ty < ' tcx > > ,
1347
1347
expressions : Expressions < ' tcx , ' exprs , E > ,
@@ -1350,7 +1350,7 @@ pub struct CoerceMany<'tcx, 'exprs, E: AsCoercionSite> {
1350
1350
1351
1351
/// The type of a `CoerceMany` that is storing up the expressions into
1352
1352
/// 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 > > ;
1354
1354
1355
1355
enum Expressions < ' tcx , ' exprs , E : AsCoercionSite > {
1356
1356
Dynamic ( Vec < & ' tcx hir:: Expr < ' tcx > > ) ,
@@ -1361,7 +1361,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1361
1361
/// The usual case; collect the set of expressions dynamically.
1362
1362
/// If the full set of coercion sites is known before hand,
1363
1363
/// 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 {
1365
1365
Self :: make ( expected_ty, Expressions :: Dynamic ( vec ! [ ] ) )
1366
1366
}
1367
1367
@@ -1370,7 +1370,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1370
1370
/// expected to pass each element in the slice to `coerce(...)` in
1371
1371
/// order. This is used with arrays in particular to avoid
1372
1372
/// 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 {
1374
1374
Self :: make ( expected_ty, Expressions :: UpFront ( coercion_sites) )
1375
1375
}
1376
1376
@@ -1386,15 +1386,15 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1386
1386
/// Typically, this is used as the expected type when
1387
1387
/// type-checking each of the alternative expressions whose types
1388
1388
/// we are trying to merge.
1389
- pub fn expected_ty ( & self ) -> Ty < ' tcx > {
1389
+ pub ( crate ) fn expected_ty ( & self ) -> Ty < ' tcx > {
1390
1390
self . expected_ty
1391
1391
}
1392
1392
1393
1393
/// Returns the current "merged type", representing our best-guess
1394
1394
/// at the LUB of the expressions we've seen so far (if any). This
1395
1395
/// isn't *final* until you call `self.complete()`, which will return
1396
1396
/// the merged type.
1397
- pub fn merged_ty ( & self ) -> Ty < ' tcx > {
1397
+ pub ( crate ) fn merged_ty ( & self ) -> Ty < ' tcx > {
1398
1398
self . final_ty . unwrap_or ( self . expected_ty )
1399
1399
}
1400
1400
@@ -1403,7 +1403,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1403
1403
/// could coerce from. This will record `expression`, and later
1404
1404
/// calls to `coerce` may come back and add adjustments and things
1405
1405
/// if necessary.
1406
- pub fn coerce < ' a > (
1406
+ pub ( crate ) fn coerce < ' a > (
1407
1407
& mut self ,
1408
1408
fcx : & FnCtxt < ' a , ' tcx > ,
1409
1409
cause : & ObligationCause < ' tcx > ,
@@ -1425,7 +1425,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1425
1425
/// The `augment_error` gives you a chance to extend the error
1426
1426
/// message, in case any results (e.g., we use this to suggest
1427
1427
/// removing a `;`).
1428
- pub fn coerce_forced_unit < ' a > (
1428
+ pub ( crate ) fn coerce_forced_unit < ' a > (
1429
1429
& mut self ,
1430
1430
fcx : & FnCtxt < ' a , ' tcx > ,
1431
1431
cause : & ObligationCause < ' tcx > ,
@@ -1920,7 +1920,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1920
1920
}
1921
1921
}
1922
1922
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 > {
1924
1924
if let Some ( final_ty) = self . final_ty {
1925
1925
final_ty
1926
1926
} else {
@@ -1934,7 +1934,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1934
1934
1935
1935
/// Something that can be converted into an expression to which we can
1936
1936
/// apply a coercion.
1937
- pub trait AsCoercionSite {
1937
+ pub ( crate ) trait AsCoercionSite {
1938
1938
fn as_coercion_site ( & self ) -> & hir:: Expr < ' _ > ;
1939
1939
}
1940
1940
0 commit comments