mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
Rename try_coerce to coerce
This commit is contained in:
parent
822caa8b80
commit
406b0e2935
@ -744,7 +744,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
ty::FnDef(..) => {
|
||||
// Attempt a coercion to a fn pointer type.
|
||||
let f = fcx.normalize(self.expr_span, self.expr_ty.fn_sig(fcx.tcx));
|
||||
let res = fcx.try_coerce(
|
||||
let res = fcx.coerce(
|
||||
self.expr,
|
||||
self.expr_ty,
|
||||
Ty::new_fn_ptr(fcx.tcx, f),
|
||||
@ -844,7 +844,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
|
||||
(_, DynStar) => {
|
||||
if fcx.tcx.features().dyn_star {
|
||||
bug!("should be handled by `try_coerce`")
|
||||
bug!("should be handled by `coerce`")
|
||||
} else {
|
||||
Err(CastError::IllegalCast)
|
||||
}
|
||||
@ -940,7 +940,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
|
||||
// Coerce to a raw pointer so that we generate AddressOf in MIR.
|
||||
let array_ptr_type = Ty::new_ptr(fcx.tcx, m_expr);
|
||||
fcx.try_coerce(self.expr, self.expr_ty, array_ptr_type, AllowTwoPhase::No, None)
|
||||
fcx.coerce(self.expr, self.expr_ty, array_ptr_type, AllowTwoPhase::No, None)
|
||||
.unwrap_or_else(|_| {
|
||||
bug!(
|
||||
"could not cast from reference to array to pointer to array ({:?} to {:?})",
|
||||
@ -976,7 +976,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
}
|
||||
|
||||
fn try_coercion_cast(&self, fcx: &FnCtxt<'a, 'tcx>) -> Result<(), ty::error::TypeError<'tcx>> {
|
||||
match fcx.try_coerce(self.expr, self.expr_ty, self.cast_ty, AllowTwoPhase::No, None) {
|
||||
match fcx.coerce(self.expr, self.expr_ty, self.cast_ty, AllowTwoPhase::No, None) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
|
@ -1005,7 +1005,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
/// adjusted type of the expression, if successful.
|
||||
/// Adjustments are only recorded if the coercion succeeded.
|
||||
/// The expressions *must not* have any preexisting adjustments.
|
||||
pub fn try_coerce(
|
||||
pub fn coerce(
|
||||
&self,
|
||||
expr: &hir::Expr<'_>,
|
||||
expr_ty: Ty<'tcx>,
|
||||
@ -1036,7 +1036,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Same as `try_coerce()`, but without side-effects.
|
||||
/// Same as `coerce()`, but without side-effects.
|
||||
///
|
||||
/// Returns false if the coercion creates any obligations that result in
|
||||
/// errors.
|
||||
@ -1494,7 +1494,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||
// Special-case the first expression we are coercing.
|
||||
// To be honest, I'm not entirely sure why we do this.
|
||||
// We don't allow two-phase borrows, see comment in try_find_coercion_lub for why
|
||||
fcx.try_coerce(
|
||||
fcx.coerce(
|
||||
expression,
|
||||
expression_ty,
|
||||
self.expected_ty,
|
||||
|
@ -254,7 +254,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
) -> (Ty<'tcx>, Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>>) {
|
||||
let expected = self.resolve_vars_with_obligations(expected);
|
||||
|
||||
let e = match self.try_coerce(expr, checked_ty, expected, allow_two_phase, None) {
|
||||
let e = match self.coerce(expr, checked_ty, expected, allow_two_phase, None) {
|
||||
Ok(ty) => return (ty, None),
|
||||
Err(e) => e,
|
||||
};
|
||||
@ -475,7 +475,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
{
|
||||
let Some(arg_ty) = self.node_ty_opt(arg_expr.hir_id) else { continue; };
|
||||
let arg_ty = arg_ty.fold_with(&mut fudger);
|
||||
let _ = self.try_coerce(
|
||||
let _ = self.coerce(
|
||||
arg_expr,
|
||||
arg_ty,
|
||||
*expected_arg_ty,
|
||||
|
@ -260,9 +260,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// fulfillment error to be more accurate.
|
||||
let coerced_ty = self.resolve_vars_with_obligations(coerced_ty);
|
||||
|
||||
let coerce_error = self
|
||||
.try_coerce(provided_arg, checked_ty, coerced_ty, AllowTwoPhase::Yes, None)
|
||||
.err();
|
||||
let coerce_error =
|
||||
self.coerce(provided_arg, checked_ty, coerced_ty, AllowTwoPhase::Yes, None).err();
|
||||
|
||||
if coerce_error.is_some() {
|
||||
return Compatibility::Incompatible(coerce_error);
|
||||
|
Loading…
Reference in New Issue
Block a user