1
Fork 0

fix static_ptr_ty for foreign statics, and more comments in check_unsafety

This commit is contained in:
Ralf Jung 2020-10-19 09:47:18 +02:00
parent cb33f956c3
commit c1766c6372
2 changed files with 6 additions and 0 deletions

View file

@ -204,6 +204,9 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
if let [] = proj_base {
let decl = &self.body.local_decls[place.local];
if decl.internal {
// If the projection root is an artifical local that we introduced when
// desugaring `static`, give a more specific error message
// (avoid the general "raw pointer" clause below, that would only be confusing).
if let Some(box LocalInfo::StaticRef { def_id, .. }) = decl.local_info {
if self.tcx.is_mutable_static(def_id) {
self.require_unsafe(