Skip to content

Commit bf3bb5f

Browse files
committed
Flatten the check for ref/non-ref bindings
1 parent 849b092 commit bf3bb5f

File tree

1 file changed

+5
-7
lines changed
  • compiler/rustc_borrowck/src/type_check

1 file changed

+5
-7
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -462,17 +462,15 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
462462
.into_iter()
463463
.flat_map(UserTypeProjections::projections_and_spans)
464464
{
465-
let ty = if !local_decl.is_nonref_binding() {
465+
let ty = if local_decl.is_nonref_binding() {
466+
local_decl.ty
467+
} else if let &ty::Ref(_, rty, _) = local_decl.ty.kind() {
466468
// If we have a binding of the form `let ref x: T = ..`
467469
// then remove the outermost reference so we can check the
468470
// type annotation for the remaining type.
469-
if let ty::Ref(_, rty, _) = local_decl.ty.kind() {
470-
*rty
471-
} else {
472-
bug!("{:?} with ref binding has wrong type {}", local, local_decl.ty);
473-
}
471+
rty
474472
} else {
475-
local_decl.ty
473+
bug!("{:?} with ref binding has wrong type {}", local, local_decl.ty);
476474
};
477475

478476
if let Err(terr) = self.typeck.relate_type_and_user_type(

0 commit comments

Comments
 (0)