4
4
use core:: ops:: ControlFlow ;
5
5
use hir:: { ExprKind , Param } ;
6
6
use rustc_errors:: { Applicability , Diag } ;
7
- use rustc_hir as hir;
8
7
use rustc_hir:: intravisit:: Visitor ;
9
- use rustc_hir:: Node ;
8
+ use rustc_hir:: { self as hir , BindingAnnotation , ByRef , Node } ;
10
9
use rustc_infer:: traits;
11
10
use rustc_middle:: mir:: { Mutability , Place , PlaceRef , ProjectionElem } ;
12
11
use rustc_middle:: ty:: { self , InstanceDef , ToPredicate , Ty , TyCtxt } ;
@@ -304,7 +303,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
304
303
{
305
304
match * decl. local_info ( ) {
306
305
LocalInfo :: User ( BindingForm :: Var ( mir:: VarBindingForm {
307
- binding_mode : ty :: BindingMode :: BindByValue ( Mutability :: Not ) ,
306
+ binding_mode : BindingAnnotation ( ByRef :: No , Mutability :: Not ) ,
308
307
opt_ty_info : Some ( sp) ,
309
308
opt_match_place : _,
310
309
pat_span : _,
@@ -342,7 +341,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
342
341
} else if decl. mutability . is_not ( ) {
343
342
if matches ! (
344
343
decl. local_info( ) ,
345
- LocalInfo :: User ( BindingForm :: ImplicitSelf ( hir:: ImplicitSelfKind :: MutRef ) )
344
+ LocalInfo :: User ( BindingForm :: ImplicitSelf ( hir:: ImplicitSelfKind :: RefMut ) )
346
345
) {
347
346
err. note (
348
347
"as `Self` may be unsized, this call attempts to take `&mut &mut self`" ,
@@ -407,7 +406,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
407
406
if let Some ( fn_decl) = node. fn_decl ( ) {
408
407
if !matches ! (
409
408
fn_decl. implicit_self,
410
- hir:: ImplicitSelfKind :: ImmRef | hir:: ImplicitSelfKind :: MutRef
409
+ hir:: ImplicitSelfKind :: RefImm | hir:: ImplicitSelfKind :: RefMut
411
410
) {
412
411
err. span_suggestion (
413
412
upvar_ident. span ,
@@ -717,7 +716,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
717
716
debug ! ( "local_decl: {:?}" , local_decl) ;
718
717
let pat_span = match * local_decl. local_info ( ) {
719
718
LocalInfo :: User ( BindingForm :: Var ( mir:: VarBindingForm {
720
- binding_mode : ty :: BindingMode :: BindByValue ( Mutability :: Not ) ,
719
+ binding_mode : BindingAnnotation ( ByRef :: No , Mutability :: Not ) ,
721
720
opt_ty_info : _,
722
721
opt_match_place : _,
723
722
pat_span,
@@ -1070,7 +1069,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
1070
1069
}
1071
1070
1072
1071
LocalInfo :: User ( mir:: BindingForm :: Var ( mir:: VarBindingForm {
1073
- binding_mode : ty :: BindingMode :: BindByValue ( _) ,
1072
+ binding_mode : BindingAnnotation ( ByRef :: No , _) ,
1074
1073
opt_ty_info,
1075
1074
..
1076
1075
} ) ) => {
@@ -1138,7 +1137,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
1138
1137
}
1139
1138
1140
1139
LocalInfo :: User ( mir:: BindingForm :: Var ( mir:: VarBindingForm {
1141
- binding_mode : ty :: BindingMode :: BindByReference ( _) ,
1140
+ binding_mode : BindingAnnotation ( ByRef :: Yes ( _ ) , _) ,
1142
1141
..
1143
1142
} ) ) => {
1144
1143
let pattern_span: Span = local_decl. source_info . span ;
@@ -1329,7 +1328,7 @@ pub fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<
1329
1328
match * local_decl. local_info ( ) {
1330
1329
// Check if mutably borrowing a mutable reference.
1331
1330
LocalInfo :: User ( mir:: BindingForm :: Var ( mir:: VarBindingForm {
1332
- binding_mode : ty :: BindingMode :: BindByValue ( Mutability :: Not ) ,
1331
+ binding_mode : BindingAnnotation ( ByRef :: No , Mutability :: Not ) ,
1333
1332
..
1334
1333
} ) ) => matches ! ( local_decl. ty. kind( ) , ty:: Ref ( _, _, hir:: Mutability :: Mut ) ) ,
1335
1334
LocalInfo :: User ( mir:: BindingForm :: ImplicitSelf ( kind) ) => {
@@ -1338,7 +1337,7 @@ pub fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<
1338
1337
//
1339
1338
// Deliberately fall into this case for all implicit self types,
1340
1339
// so that we don't fall into the next case with them.
1341
- kind == hir:: ImplicitSelfKind :: MutRef
1340
+ kind == hir:: ImplicitSelfKind :: RefMut
1342
1341
}
1343
1342
_ if Some ( kw:: SelfLower ) == local_name => {
1344
1343
// Otherwise, check if the name is the `self` keyword - in which case
0 commit comments