@@ -166,28 +166,28 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
166
166
place : & Place < ' tcx > ,
167
167
context : PlaceContext < ' tcx > ,
168
168
location : Location ) {
169
- if context. is_borrow ( ) {
170
- if util:: is_disaligned ( self . tcx , self . mir , self . param_env , place) {
171
- let source_info = self . source_info ;
172
- let lint_root =
173
- self . source_scope_local_data [ source_info. scope ] . lint_root ;
174
- self . register_violations ( & [ UnsafetyViolation {
175
- source_info,
176
- description : Symbol :: intern ( "borrow of packed field" ) . as_interned_str ( ) ,
177
- details :
178
- Symbol :: intern ( "fields of packed structs might be misaligned: \
179
- dereferencing a misaligned pointer or even just creating a \
180
- misaligned reference is undefined behavior")
181
- . as_interned_str ( ) ,
182
- kind : UnsafetyViolationKind :: BorrowPacked ( lint_root)
183
- } ] , & [ ] ) ;
184
- }
185
- }
186
-
187
169
match place {
188
170
& Place :: Projection ( box Projection {
189
171
ref base, ref elem
190
172
} ) => {
173
+ if context. is_borrow ( ) {
174
+ if util:: is_disaligned ( self . tcx , self . mir , self . param_env , place) {
175
+ let source_info = self . source_info ;
176
+ let lint_root =
177
+ self . source_scope_local_data [ source_info. scope ] . lint_root ;
178
+ self . register_violations ( & [ UnsafetyViolation {
179
+ source_info,
180
+ description : Symbol :: intern ( "borrow of packed field" ) . as_interned_str ( ) ,
181
+ details :
182
+ Symbol :: intern ( "fields of packed structs might be misaligned: \
183
+ dereferencing a misaligned pointer or even just \
184
+ creating a misaligned reference is undefined \
185
+ behavior")
186
+ . as_interned_str ( ) ,
187
+ kind : UnsafetyViolationKind :: BorrowPacked ( lint_root)
188
+ } ] , & [ ] ) ;
189
+ }
190
+ }
191
191
let old_source_info = self . source_info ;
192
192
if let & Place :: Local ( local) = base {
193
193
if self . mir . local_decls [ local] . internal {
0 commit comments