diff options
| author | Keith Yeung <kungfukeith11@gmail.com> | 2018-03-23 01:59:56 -0700 |
|---|---|---|
| committer | Keith Yeung <kungfukeith11@gmail.com> | 2018-04-28 01:55:26 -0700 |
| commit | 8c607eaf949a0ba9c365dd00e18d948418cfe957 (patch) | |
| tree | 9b1de116f8a17b6d8110f40c617d70c849acb46f /src | |
| parent | 180e2426c90cae9362bcc68576293da7a5bdd22a (diff) | |
| download | rust-8c607eaf949a0ba9c365dd00e18d948418cfe957.tar.gz rust-8c607eaf949a0ba9c365dd00e18d948418cfe957.zip | |
Skip implicit self argument for closures
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/borrow_check/mod.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 9da5d1dcdcd..a70c601bd1a 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -265,6 +265,11 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( if let ClearCrossCrate::Set(ref vsi) = mbcx.mir.visibility_scope_info { let local_decl = &mbcx.mir.local_decls[local]; + // Skip implicit `self` argument for closures + if local.index() == 1 && tcx.is_closure(mbcx.mir_def_id) { + continue; + } + // Skip over locals that begin with an underscore match local_decl.name { Some(name) if name.as_str().starts_with("_") => continue, @@ -1890,9 +1895,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { match tnm.mutbl { // `*const` raw pointers are not mutable hir::MutImmutable => return Err(place), - // `*mut` raw pointers are always mutable, regardless of context - // The users have to check by themselve. - hir::MutMutable => return Ok((place, is_local_mutation_allowed)), + // `*mut` raw pointers are always mutable, regardless of + // context. The users have to check by themselves. + hir::MutMutable => { + return Ok((place, is_local_mutation_allowed)); + } } } // `Box<T>` owns its content, so mutable if its location is mutable |
