rename structurally_resolved_type
This commit is contained in:
parent
d5a74249c8
commit
8ebb3d49e4
9 changed files with 22 additions and 22 deletions
|
@ -89,7 +89,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
_ => self.check_expr(callee_expr),
|
||||
};
|
||||
|
||||
let expr_ty = self.structurally_resolved_type(call_expr.span, original_callee_ty);
|
||||
let expr_ty = self.structurally_resolve_type(call_expr.span, original_callee_ty);
|
||||
|
||||
let mut autoderef = self.autoderef(callee_expr.span, expr_ty);
|
||||
let mut result = None;
|
||||
|
@ -138,7 +138,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
autoderef: &Autoderef<'a, 'tcx>,
|
||||
) -> Option<CallStep<'tcx>> {
|
||||
let adjusted_ty =
|
||||
self.structurally_resolved_type(autoderef.span(), autoderef.final_ty(false));
|
||||
self.structurally_resolve_type(autoderef.span(), autoderef.final_ty(false));
|
||||
|
||||
// If the callee is a bare function or a closure, then we're all set.
|
||||
match *adjusted_ty.kind() {
|
||||
|
|
|
@ -717,8 +717,8 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
|
||||
#[instrument(skip(fcx), level = "debug")]
|
||||
pub fn check(mut self, fcx: &FnCtxt<'a, 'tcx>) {
|
||||
self.expr_ty = fcx.structurally_resolved_type(self.expr_span, self.expr_ty);
|
||||
self.cast_ty = fcx.structurally_resolved_type(self.cast_span, self.cast_ty);
|
||||
self.expr_ty = fcx.structurally_resolve_type(self.expr_span, self.expr_ty);
|
||||
self.cast_ty = fcx.structurally_resolve_type(self.cast_span, self.cast_ty);
|
||||
|
||||
debug!("check_cast({}, {:?} as {:?})", self.expr.hir_id, self.expr_ty, self.cast_ty);
|
||||
|
||||
|
|
|
@ -380,7 +380,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let mut oprnd_t = self.check_expr_with_expectation(&oprnd, expected_inner);
|
||||
|
||||
if !oprnd_t.references_error() {
|
||||
oprnd_t = self.structurally_resolved_type(expr.span, oprnd_t);
|
||||
oprnd_t = self.structurally_resolve_type(expr.span, oprnd_t);
|
||||
match unop {
|
||||
hir::UnOp::Deref => {
|
||||
if let Some(ty) = self.lookup_derefing(expr, oprnd, oprnd_t) {
|
||||
|
@ -1266,13 +1266,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
) -> Ty<'tcx> {
|
||||
let rcvr_t = self.check_expr(&rcvr);
|
||||
// no need to check for bot/err -- callee does that
|
||||
let rcvr_t = self.structurally_resolved_type(rcvr.span, rcvr_t);
|
||||
let rcvr_t = self.structurally_resolve_type(rcvr.span, rcvr_t);
|
||||
let span = segment.ident.span;
|
||||
|
||||
let method = match self.lookup_method(rcvr_t, segment, span, expr, rcvr, args) {
|
||||
Ok(method) => {
|
||||
// We could add a "consider `foo::<params>`" suggestion here, but I wasn't able to
|
||||
// trigger this codepath causing `structurally_resolved_type` to emit an error.
|
||||
// trigger this codepath causing `structurally_resolve_type` to emit an error.
|
||||
|
||||
self.write_method_call(expr.hir_id, method);
|
||||
Ok(method)
|
||||
|
@ -2252,7 +2252,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
) -> Ty<'tcx> {
|
||||
debug!("check_field(expr: {:?}, base: {:?}, field: {:?})", expr, base, field);
|
||||
let base_ty = self.check_expr(base);
|
||||
let base_ty = self.structurally_resolved_type(base.span, base_ty);
|
||||
let base_ty = self.structurally_resolve_type(base.span, base_ty);
|
||||
let mut private_candidate = None;
|
||||
let mut autoderef = self.autoderef(expr.span, base_ty);
|
||||
while let Some((deref_base_ty, _)) = autoderef.next() {
|
||||
|
@ -2300,7 +2300,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
self.structurally_resolved_type(autoderef.span(), autoderef.final_ty(false));
|
||||
self.structurally_resolve_type(autoderef.span(), autoderef.final_ty(false));
|
||||
|
||||
if let Some((adjustments, did)) = private_candidate {
|
||||
// (#90483) apply adjustments to avoid ExprUseVisitor from
|
||||
|
@ -2857,7 +2857,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
} else if idx_t.references_error() {
|
||||
idx_t
|
||||
} else {
|
||||
let base_t = self.structurally_resolved_type(base.span, base_t);
|
||||
let base_t = self.structurally_resolve_type(base.span, base_t);
|
||||
match self.lookup_indexing(expr, base, base_t, idx, idx_t) {
|
||||
Some((index_ty, element_ty)) => {
|
||||
// two-phase not needed because index_ty is never mutable
|
||||
|
@ -3084,7 +3084,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// allows them to be inferred based on how they are used later in the
|
||||
// function.
|
||||
if is_input {
|
||||
let ty = self.structurally_resolved_type(expr.span, ty);
|
||||
let ty = self.structurally_resolve_type(expr.span, ty);
|
||||
match *ty.kind() {
|
||||
ty::FnDef(..) => {
|
||||
let fnptr_ty = self.tcx.mk_fn_ptr(ty.fn_sig(self.tcx));
|
||||
|
@ -3142,7 +3142,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let mut current_container = container;
|
||||
|
||||
for &field in fields {
|
||||
let container = self.structurally_resolved_type(expr.span, current_container);
|
||||
let container = self.structurally_resolve_type(expr.span, current_container);
|
||||
|
||||
match container.kind() {
|
||||
ty::Adt(container_def, substs) if !container_def.is_enum() => {
|
||||
|
|
|
@ -1473,7 +1473,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
///
|
||||
/// If no resolution is possible, then an error is reported.
|
||||
/// Numeric inference variables may be left unresolved.
|
||||
pub fn structurally_resolved_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
pub fn structurally_resolve_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
let mut ty = self.resolve_vars_with_obligations(ty);
|
||||
|
||||
if self.next_trait_solver()
|
||||
|
|
|
@ -184,7 +184,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
// If the arguments should be wrapped in a tuple (ex: closures), unwrap them here
|
||||
let (formal_input_tys, expected_input_tys) = if tuple_arguments == TupleArguments {
|
||||
let tuple_type = self.structurally_resolved_type(call_span, formal_input_tys[0]);
|
||||
let tuple_type = self.structurally_resolve_type(call_span, formal_input_tys[0]);
|
||||
match tuple_type.kind() {
|
||||
// We expected a tuple and got a tuple
|
||||
ty::Tuple(arg_types) => {
|
||||
|
@ -412,7 +412,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
// There are a few types which get autopromoted when passed via varargs
|
||||
// in C but we just error out instead and require explicit casts.
|
||||
let arg_ty = self.structurally_resolved_type(arg.span, arg_ty);
|
||||
let arg_ty = self.structurally_resolve_type(arg.span, arg_ty);
|
||||
match arg_ty.kind() {
|
||||
ty::Float(ty::FloatTy::F32) => {
|
||||
variadic_error(tcx.sess, arg.span, arg_ty, "c_double");
|
||||
|
|
|
@ -179,7 +179,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
|||
assert_eq!(n, pick.autoderefs);
|
||||
|
||||
let mut adjustments = self.adjust_steps(&autoderef);
|
||||
let mut target = self.structurally_resolved_type(autoderef.span(), ty);
|
||||
let mut target = self.structurally_resolve_type(autoderef.span(), ty);
|
||||
|
||||
match pick.autoref_or_ptr_adjustment {
|
||||
Some(probe::AutorefOrPtrAdjustment::Autoref { mutbl, unsize }) => {
|
||||
|
|
|
@ -451,7 +451,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
} else {
|
||||
// Ended up encountering a type variable when doing autoderef,
|
||||
// but it may not be a type variable after processing obligations
|
||||
// in our local `FnCtxt`, so don't call `structurally_resolved_type`.
|
||||
// in our local `FnCtxt`, so don't call `structurally_resolve_type`.
|
||||
let ty = &bad_ty.ty;
|
||||
let ty = self
|
||||
.probe_instantiate_query_response(span, &orig_values, ty)
|
||||
|
|
|
@ -393,7 +393,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// They can denote both statically and dynamically-sized byte arrays.
|
||||
let mut pat_ty = ty;
|
||||
if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind {
|
||||
let expected = self.structurally_resolved_type(span, expected);
|
||||
let expected = self.structurally_resolve_type(span, expected);
|
||||
if let ty::Ref(_, inner_ty, _) = expected.kind()
|
||||
&& matches!(inner_ty.kind(), ty::Slice(_))
|
||||
{
|
||||
|
@ -501,7 +501,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// This check is needed if both sides are inference variables.
|
||||
// We require types to be resolved here so that we emit inference failure
|
||||
// rather than "_ is not a char or numeric".
|
||||
let ty = self.structurally_resolved_type(span, expected);
|
||||
let ty = self.structurally_resolve_type(span, expected);
|
||||
if !(ty.is_numeric() || ty.is_char() || ty.references_error()) {
|
||||
if let Some((ref mut fail, _, _)) = lhs {
|
||||
*fail = true;
|
||||
|
@ -1289,7 +1289,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let mut expected_len = elements.len();
|
||||
if ddpos.as_opt_usize().is_some() {
|
||||
// Require known type only when `..` is present.
|
||||
if let ty::Tuple(tys) = self.structurally_resolved_type(span, expected).kind() {
|
||||
if let ty::Tuple(tys) = self.structurally_resolve_type(span, expected).kind() {
|
||||
expected_len = tys.len();
|
||||
}
|
||||
}
|
||||
|
@ -2042,7 +2042,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
def_bm: BindingMode,
|
||||
ti: TopInfo<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
let expected = self.structurally_resolved_type(span, expected);
|
||||
let expected = self.structurally_resolve_type(span, expected);
|
||||
let (element_ty, opt_slice_ty, inferred) = match *expected.kind() {
|
||||
// An array, so we might have something like `let [a, b, c] = [0, 1, 2];`.
|
||||
ty::Array(element_ty, len) => {
|
||||
|
|
|
@ -107,7 +107,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
index_expr: &hir::Expr<'_>,
|
||||
) -> Option<(/*index type*/ Ty<'tcx>, /*element type*/ Ty<'tcx>)> {
|
||||
let adjusted_ty =
|
||||
self.structurally_resolved_type(autoderef.span(), autoderef.final_ty(false));
|
||||
self.structurally_resolve_type(autoderef.span(), autoderef.final_ty(false));
|
||||
debug!(
|
||||
"try_index_step(expr={:?}, base_expr={:?}, adjusted_ty={:?}, \
|
||||
index_ty={:?})",
|
||||
|
|
Loading…
Add table
Reference in a new issue