@@ -21,74 +21,74 @@ use std::iter;
2121
2222use crate :: mem_categorization as mc;
2323
24- ///////////////////////////////////////////////////////////////////////////
25- // The Delegate trait
26-
2724/// This trait defines the callbacks you can expect to receive when
2825/// employing the ExprUseVisitor.
2926pub trait Delegate < ' tcx > {
30- // The value found at `place` is moved, depending
31- // on `mode`. Where `diag_expr_id` is the id used for diagnostics for `place`.
32- //
33- // Use of a `Copy` type in a ByValue context is considered a use
34- // by `ImmBorrow` and `borrow` is called instead. This is because
35- // a shared borrow is the "minimum access" that would be needed
36- // to perform a copy.
37- //
38- //
39- // The parameter `diag_expr_id` indicates the HIR id that ought to be used for
40- // diagnostics. Around pattern matching such as `let pat = expr`, the diagnostic
41- // id will be the id of the expression `expr` but the place itself will have
42- // the id of the binding in the pattern `pat`.
27+ /// The value found at `place` is moved, depending
28+ /// on `mode`. Where `diag_expr_id` is the id used for diagnostics for `place`.
29+ ///
30+ /// Use of a `Copy` type in a ByValue context is considered a use
31+ /// by `ImmBorrow` and `borrow` is called instead. This is because
32+ /// a shared borrow is the "minimum access" that would be needed
33+ /// to perform a copy.
34+ ///
35+ ///
36+ /// The parameter `diag_expr_id` indicates the HIR id that ought to be used for
37+ /// diagnostics. Around pattern matching such as `let pat = expr`, the diagnostic
38+ /// id will be the id of the expression `expr` but the place itself will have
39+ /// the id of the binding in the pattern `pat`.
4340 fn consume ( & mut self , place_with_id : & PlaceWithHirId < ' tcx > , diag_expr_id : hir:: HirId ) ;
4441
45- // The value found at `place` is being borrowed with kind `bk`.
46- // `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
42+ /// The value found at `place` is being borrowed with kind `bk`.
43+ /// `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
4744 fn borrow (
4845 & mut self ,
4946 place_with_id : & PlaceWithHirId < ' tcx > ,
5047 diag_expr_id : hir:: HirId ,
5148 bk : ty:: BorrowKind ,
5249 ) ;
5350
54- // The path at `assignee_place` is being assigned to.
55- // `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
51+ /// The path at `assignee_place` is being assigned to.
52+ /// `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
5653 fn mutate ( & mut self , assignee_place : & PlaceWithHirId < ' tcx > , diag_expr_id : hir:: HirId ) ;
5754
58- // The `place` should be a fake read because of specified `cause`.
55+ /// The `place` should be a fake read because of specified `cause`.
5956 fn fake_read ( & mut self , place : Place < ' tcx > , cause : FakeReadCause , diag_expr_id : hir:: HirId ) ;
6057}
6158
6259#[ derive( Copy , Clone , PartialEq , Debug ) ]
6360enum ConsumeMode {
64- Copy , // reference to x where x has a type that copies
65- Move , // reference to x where x has a type that moves
61+ /// reference to x where x has a type that copies
62+ Copy ,
63+ /// reference to x where x has a type that moves
64+ Move ,
6665}
6766
6867#[ derive( Copy , Clone , PartialEq , Debug ) ]
6968pub enum MutateMode {
7069 Init ,
71- JustWrite , // x = y
72- WriteAndRead , // x += y
70+ /// Example: `x = y`
71+ JustWrite ,
72+ /// Example: `x += y`
73+ WriteAndRead ,
7374}
7475
75- ///////////////////////////////////////////////////////////////////////////
76- // The ExprUseVisitor type
77- //
78- // This is the code that actually walks the tree.
76+ /// The ExprUseVisitor type
77+ ///
78+ /// This is the code that actually walks the tree.
7979pub struct ExprUseVisitor < ' a , ' tcx > {
8080 mc : mc:: MemCategorizationContext < ' a , ' tcx > ,
8181 body_owner : LocalDefId ,
8282 delegate : & ' a mut dyn Delegate < ' tcx > ,
8383}
8484
85- // If the MC results in an error, it's because the type check
86- // failed (or will fail, when the error is uncovered and reported
87- // during writeback). In this case, we just ignore this part of the
88- // code.
89- //
90- // Note that this macro appears similar to try!(), but, unlike try!(),
91- // it does not propagate the error.
85+ /// If the MC results in an error, it's because the type check
86+ /// failed (or will fail, when the error is uncovered and reported
87+ /// during writeback). In this case, we just ignore this part of the
88+ /// code.
89+ ///
90+ /// Note that this macro appears similar to try!(), but, unlike try!(),
91+ /// it does not propagate the error.
9292macro_rules! return_if_err {
9393 ( $inp: expr) => {
9494 match $inp {
@@ -537,9 +537,9 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
537537 self . walk_expr ( with_expr) ;
538538 }
539539
540- // Invoke the appropriate delegate calls for anything that gets
541- // consumed or borrowed as part of the automatic adjustment
542- // process.
540+ /// Invoke the appropriate delegate calls for anything that gets
541+ /// consumed or borrowed as part of the automatic adjustment
542+ /// process.
543543 fn walk_adjustment ( & mut self , expr : & hir:: Expr < ' _ > ) {
544544 let adjustments = self . mc . typeck_results . expr_adjustments ( expr) ;
545545 let mut place_with_id = return_if_err ! ( self . mc. cat_expr_unadjusted( expr) ) ;
0 commit comments