diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2025-02-16 21:22:36 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2025-02-20 20:31:06 +1100 |
| commit | bf3bb5fd37b5dcf54a723c8559bba6718630095b (patch) | |
| tree | af1dfecac8e8b0f6d12abcc0ef7cd7c950ec1ce7 | |
| parent | 849b0920b1704cae318e8e8709269d2b1c5d0f05 (diff) | |
| download | rust-bf3bb5fd37b5dcf54a723c8559bba6718630095b.tar.gz rust-bf3bb5fd37b5dcf54a723c8559bba6718630095b.zip | |
Flatten the check for ref/non-ref bindings
| -rw-r--r-- | compiler/rustc_borrowck/src/type_check/mod.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 1f3a15df80c..21b0a62fe43 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -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( |
