@@ -105,24 +105,28 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
105
105
. insert ( hir_ty. hir_id , c_ty) ;
106
106
107
107
let ty = o_ty. normalized ;
108
- if let hir:: PatKind :: Wild = decl. pat . kind {
109
- // We explicitly allow `let _: dyn Trait;` (!)
110
- } else {
111
- if self . outermost_fn_param_pat . is_some ( ) {
112
- if !self . fcx . tcx . features ( ) . unsized_fn_params {
113
- self . fcx . require_type_is_sized (
114
- ty,
115
- hir_ty. span ,
116
- traits:: SizedArgumentType ( Some ( decl. pat . hir_id ) ) ,
117
- ) ;
118
- }
119
- } else {
120
- if !self . fcx . tcx . features ( ) . unsized_locals {
121
- self . fcx . require_type_is_sized (
122
- ty,
123
- hir_ty. span ,
124
- traits:: VariableType ( decl. pat . hir_id ) ,
125
- ) ;
108
+ match decl. pat . kind {
109
+ // We explicitly allow `let _: dyn Trait;`
110
+ hir:: PatKind :: Wild => { }
111
+ // We explicitly allow `let ref x: str = *"";`
112
+ hir:: PatKind :: Binding ( hir:: BindingAnnotation ( hir:: ByRef :: Yes ( _) , _) , ..) => { }
113
+ _ => {
114
+ if self . outermost_fn_param_pat . is_some ( ) {
115
+ if !self . fcx . tcx . features ( ) . unsized_fn_params {
116
+ self . fcx . require_type_is_sized (
117
+ ty,
118
+ hir_ty. span ,
119
+ traits:: SizedArgumentType ( Some ( decl. pat . hir_id ) ) ,
120
+ ) ;
121
+ }
122
+ } else {
123
+ if !self . fcx . tcx . features ( ) . unsized_locals {
124
+ self . fcx . require_type_is_sized (
125
+ ty,
126
+ hir_ty. span ,
127
+ traits:: VariableType ( decl. pat . hir_id ) ,
128
+ ) ;
129
+ }
126
130
}
127
131
}
128
132
}
0 commit comments