Skip to content

Commit b765c47

Browse files
committed
Flatten the check for ref/non-ref bindings
1 parent 715780d commit b765c47

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
@@ -463,17 +463,15 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
463463
.into_iter()
464464
.flat_map(UserTypeProjections::projections_and_spans)
465465
{
466-
let ty = if !local_decl.is_nonref_binding() {
466+
let ty = if local_decl.is_nonref_binding() {
467+
local_decl.ty
468+
} else if let &ty::Ref(_, rty, _) = local_decl.ty.kind() {
467469
// If we have a binding of the form `let ref x: T = ..`
468470
// then remove the outermost reference so we can check the
469471
// type annotation for the remaining type.
470-
if let ty::Ref(_, rty, _) = local_decl.ty.kind() {
471-
*rty
472-
} else {
473-
bug!("{:?} with ref binding has wrong type {}", local, local_decl.ty);
474-
}
472+
rty
475473
} else {
476-
local_decl.ty
474+
bug!("{:?} with ref binding has wrong type {}", local, local_decl.ty);
477475
};
478476

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

0 commit comments

Comments
 (0)