- let combined_mutbl = match outer_mutbl { MutMutable => mutbl, MutImmutable => MutImmutable };
- let extent = match *region {
- ReScope(extent) => Some(extent),
- _ => None,
- };
- self.validate_ptr(val, extent, pointee_ty, combined_mutbl)
+ // Sharing restricts our context
+ if mutbl == MutImmutable {
+ // Actually, in case of releasing-validation, this means we are done.
+ if vctx.op != ValidationOp::Acquire {
+ return Ok(());
+ }
+ vctx.mutbl = MutImmutable;
+ }
+ // Inner lifetimes *outlive* outer ones, so only if we have no lifetime restriction yet,
+ // we record the region of this borrow to the context.
+ if vctx.region == None {
+ match *region {
+ ReScope(ce) => vctx.region = Some(ce),
+ // It is possible for us to encode erased lifetimes here because the lifetimes in
+ // this functions' Subst will be erased.
+ _ => {},
+ }
+ }
+ self.validate_ptr(val, pointee_ty, vctx)