diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-02-17 13:39:50 -0800 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-02-17 13:39:50 -0800 |
| commit | 9d423950cc141e110242ff1973f2d7b84c719a86 (patch) | |
| tree | 036cc36e6f1b0608a5cfcc834131dcdd4e4d643f | |
| parent | 668d2fe807068073647f9c92d81ff0e7b9ab8486 (diff) | |
| download | rust-9d423950cc141e110242ff1973f2d7b84c719a86.tar.gz rust-9d423950cc141e110242ff1973f2d7b84c719a86.zip | |
Use doc comment for explanation of `shared_borrow_allows_mutation`
| -rw-r--r-- | src/librustc_mir/dataflow/impls/borrowed_locals.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/librustc_mir/dataflow/impls/borrowed_locals.rs b/src/librustc_mir/dataflow/impls/borrowed_locals.rs index 0ce37aea69d..44693c50eac 100644 --- a/src/librustc_mir/dataflow/impls/borrowed_locals.rs +++ b/src/librustc_mir/dataflow/impls/borrowed_locals.rs @@ -221,15 +221,15 @@ pub struct MutBorrow<'mir, 'tcx> { } impl MutBorrow<'mir, 'tcx> { - // `&` and `&raw` only allow mutation if the borrowed place is `!Freeze`. - // - // This assumes that it is UB to take the address of a struct field whose type is - // `Freeze`, then use pointer arithmetic to derive a pointer to a *different* field of - // that same struct whose type is `!Freeze`. If we decide that this is not UB, we will - // have to check the type of the borrowed **local** instead of the borrowed **place** - // below. See [rust-lang/unsafe-code-guidelines#134]. - // - // [rust-lang/unsafe-code-guidelines#134]: https://github.com/rust-lang/unsafe-code-guidelines/issues/134 + /// `&` and `&raw` only allow mutation if the borrowed place is `!Freeze`. + /// + /// This assumes that it is UB to take the address of a struct field whose type is + /// `Freeze`, then use pointer arithmetic to derive a pointer to a *different* field of + /// that same struct whose type is `!Freeze`. If we decide that this is not UB, we will + /// have to check the type of the borrowed **local** instead of the borrowed **place** + /// below. See [rust-lang/unsafe-code-guidelines#134]. + /// + /// [rust-lang/unsafe-code-guidelines#134]: https://github.com/rust-lang/unsafe-code-guidelines/issues/134 fn shared_borrow_allows_mutation(&self, place: &Place<'tcx>) -> bool { !place.ty(self.body, self.tcx).ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) } |
