Add some code comments
This commit is contained in:
parent
a68db7e3a8
commit
42b8b13b22
2 changed files with 11 additions and 1 deletions
|
@ -1760,9 +1760,13 @@ pub enum CaptureBy {
|
|||
/// The span of the `move` keyword.
|
||||
move_kw: Span,
|
||||
},
|
||||
/// `move` keyword was not specified.
|
||||
/// `move` or `use` keywords were not specified.
|
||||
Ref,
|
||||
/// `use |x| y + x`.
|
||||
///
|
||||
/// Note that if you have a regular closure like `|| x.use`, this will *not* result
|
||||
/// in a `Use` capture. Instead, the `ExprUseVisitor` will look at the type
|
||||
/// of `x` and treat `x.use` as either a copy/clone/move as appropriate.
|
||||
Use {
|
||||
/// The span of the `use` keyword.
|
||||
use_kw: Span,
|
||||
|
|
|
@ -327,6 +327,12 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
|||
pub fn consume_clone_or_copy(&self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
|
||||
debug!("delegate_consume_or_clone(place_with_id={:?})", place_with_id);
|
||||
|
||||
// `x.use` will do one of the following
|
||||
// * if it implements `Copy`, it will be a copy
|
||||
// * if it implements `UseCloned`, it will be a call to `clone`
|
||||
// * otherwise, it is a move
|
||||
//
|
||||
// we do a conservative approximation of this, treating it as a move unless we know that it implements copy or `UseCloned`
|
||||
if self.cx.type_is_copy_modulo_regions(place_with_id.place.ty()) {
|
||||
self.delegate.borrow_mut().copy(place_with_id, diag_expr_id);
|
||||
} else if self.cx.type_is_use_cloned_modulo_regions(place_with_id.place.ty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue