2
2
//! normal visitor, which just walks the entire body in one shot, the
3
3
//! `ExprUseVisitor` determines how expressions are being used.
4
4
5
- pub use self :: ConsumeMode :: * ;
6
-
7
5
// Export these here so that Clippy can use them.
8
6
pub use rustc_middle:: hir:: place:: { Place , PlaceBase , PlaceWithHirId , Projection } ;
9
7
@@ -28,19 +26,14 @@ use crate::mem_categorization as mc;
28
26
/// This trait defines the callbacks you can expect to receive when
29
27
/// employing the ExprUseVisitor.
30
28
pub trait Delegate < ' tcx > {
31
- // The value found at `place` is either copied or moved, depending
29
+ // The value found at `place` is moved, depending
32
30
// on `mode`. Where `diag_expr_id` is the id used for diagnostics for `place`.
33
31
//
34
32
// The parameter `diag_expr_id` indicates the HIR id that ought to be used for
35
33
// diagnostics. Around pattern matching such as `let pat = expr`, the diagnostic
36
34
// id will be the id of the expression `expr` but the place itself will have
37
35
// the id of the binding in the pattern `pat`.
38
- fn consume (
39
- & mut self ,
40
- place_with_id : & PlaceWithHirId < ' tcx > ,
41
- diag_expr_id : hir:: HirId ,
42
- mode : ConsumeMode ,
43
- ) ;
36
+ fn consume ( & mut self , place_with_id : & PlaceWithHirId < ' tcx > , diag_expr_id : hir:: HirId ) ;
44
37
45
38
// The value found at `place` is being borrowed with kind `bk`.
46
39
// `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
@@ -60,7 +53,7 @@ pub trait Delegate<'tcx> {
60
53
}
61
54
62
55
#[ derive( Copy , Clone , PartialEq , Debug ) ]
63
- pub enum ConsumeMode {
56
+ enum ConsumeMode {
64
57
Copy , // reference to x where x has a type that copies
65
58
Move , // reference to x where x has a type that moves
66
59
}
@@ -146,7 +139,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
146
139
let mode = copy_or_move ( & self . mc , place_with_id) ;
147
140
148
141
match mode {
149
- ConsumeMode :: Move => self . delegate . consume ( place_with_id, diag_expr_id, mode ) ,
142
+ ConsumeMode :: Move => self . delegate . consume ( place_with_id, diag_expr_id) ,
150
143
ConsumeMode :: Copy => {
151
144
self . delegate . borrow ( place_with_id, diag_expr_id, ty:: BorrowKind :: ImmBorrow )
152
145
}
@@ -662,9 +655,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
662
655
debug!( "walk_pat binding consuming pat" ) ;
663
656
let mode = copy_or_move( mc, & place) ;
664
657
match mode {
665
- ConsumeMode :: Move => {
666
- delegate. consume( place, discr_place. hir_id, mode)
667
- }
658
+ ConsumeMode :: Move => delegate. consume( place, discr_place. hir_id) ,
668
659
ConsumeMode :: Copy => delegate. borrow(
669
660
place,
670
661
discr_place. hir_id,
@@ -812,8 +803,8 @@ fn copy_or_move<'a, 'tcx>(
812
803
place_with_id. place . ty ( ) ,
813
804
mc. tcx ( ) . hir ( ) . span ( place_with_id. hir_id ) ,
814
805
) {
815
- Move
806
+ ConsumeMode :: Move
816
807
} else {
817
- Copy
808
+ ConsumeMode :: Copy
818
809
}
819
810
}
0 commit comments