1
Fork 0

Flatten the check for ref/non-ref bindings

This commit is contained in:
Zalathar 2025-02-16 21:22:36 +11:00
parent 849b0920b1
commit bf3bb5fd37

View file

@ -462,17 +462,15 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
.into_iter()
.flat_map(UserTypeProjections::projections_and_spans)
{
let ty = if !local_decl.is_nonref_binding() {
let ty = if local_decl.is_nonref_binding() {
local_decl.ty
} else if let &ty::Ref(_, rty, _) = local_decl.ty.kind() {
// If we have a binding of the form `let ref x: T = ..`
// then remove the outermost reference so we can check the
// type annotation for the remaining type.
if let ty::Ref(_, rty, _) = local_decl.ty.kind() {
*rty
} else {
bug!("{:?} with ref binding has wrong type {}", local, local_decl.ty);
}
rty
} else {
local_decl.ty
bug!("{:?} with ref binding has wrong type {}", local, local_decl.ty);
};
if let Err(terr) = self.typeck.relate_type_and_user_type(