about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2021-10-29 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2021-11-03 16:43:12 +0100
commitb285e0c5d828d958ac22efa1e82648b178d1cbd5 (patch)
treeb559dee6f512df23a0c12e87fab8c54c507cc8ff /compiler/rustc_const_eval/src
parent473eaa42e9365c47d129f72693b5d163a20cf369 (diff)
downloadrust-b285e0c5d828d958ac22efa1e82648b178d1cbd5.tar.gz
rust-b285e0c5d828d958ac22efa1e82648b178d1cbd5.zip
Remove `MaybeMutBorrowedLocals`
Diffstat (limited to 'compiler/rustc_const_eval/src')
-rw-r--r--compiler/rustc_const_eval/src/transform/check_consts/resolver.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/resolver.rs b/compiler/rustc_const_eval/src/transform/check_consts/resolver.rs
index 38576230883..2420f31ac08 100644
--- a/compiler/rustc_const_eval/src/transform/check_consts/resolver.rs
+++ b/compiler/rustc_const_eval/src/transform/check_consts/resolver.rs
@@ -110,6 +110,15 @@ where
         }
     }
 
+    /// `&` 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: mir::Place<'tcx>) -> bool {
         !place
             .ty(self.ccx.body, self.ccx.tcx)