Skip to content

Commit 9d42395

Browse files
Use doc comment for explanation of shared_borrow_allows_mutation
1 parent 668d2fe commit 9d42395

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/librustc_mir/dataflow/impls/borrowed_locals.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,15 @@ pub struct MutBorrow<'mir, 'tcx> {
221221
}
222222

223223
impl MutBorrow<'mir, 'tcx> {
224-
// `&` and `&raw` only allow mutation if the borrowed place is `!Freeze`.
225-
//
226-
// This assumes that it is UB to take the address of a struct field whose type is
227-
// `Freeze`, then use pointer arithmetic to derive a pointer to a *different* field of
228-
// that same struct whose type is `!Freeze`. If we decide that this is not UB, we will
229-
// have to check the type of the borrowed **local** instead of the borrowed **place**
230-
// below. See [rust-lang/unsafe-code-guidelines#134].
231-
//
232-
// [rust-lang/unsafe-code-guidelines#134]: https://github.com/rust-lang/unsafe-code-guidelines/issues/134
224+
/// `&` and `&raw` only allow mutation if the borrowed place is `!Freeze`.
225+
///
226+
/// This assumes that it is UB to take the address of a struct field whose type is
227+
/// `Freeze`, then use pointer arithmetic to derive a pointer to a *different* field of
228+
/// that same struct whose type is `!Freeze`. If we decide that this is not UB, we will
229+
/// have to check the type of the borrowed **local** instead of the borrowed **place**
230+
/// below. See [rust-lang/unsafe-code-guidelines#134].
231+
///
232+
/// [rust-lang/unsafe-code-guidelines#134]: https://github.com/rust-lang/unsafe-code-guidelines/issues/134
233233
fn shared_borrow_allows_mutation(&self, place: &Place<'tcx>) -> bool {
234234
!place.ty(self.body, self.tcx).ty.is_freeze(self.tcx, self.param_env, DUMMY_SP)
235235
}

0 commit comments

Comments
 (0)