Skip to content

Commit 2bcb018

Browse files
committed
fmt
1 parent 631ea7c commit 2bcb018

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

compiler/rustc_passes/src/dead.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,13 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
255255
self.insert_def_id(field.did);
256256
let field_ty = field.ty(self.tcx, subst);
257257

258-
current_ty =
259-
self.tcx.normalize_erasing_regions(param_env, field_ty);
258+
current_ty = self.tcx.normalize_erasing_regions(param_env, field_ty);
260259
}
261260
// we don't need to mark tuple fields as live,
262261
// but we may need to mark subfields
263262
ty::Tuple(tys) => {
264-
current_ty = self.tcx.normalize_erasing_regions(
265-
param_env,
266-
tys[index.as_usize()],
267-
);
263+
current_ty =
264+
self.tcx.normalize_erasing_regions(param_env, tys[index.as_usize()]);
268265
}
269266
_ => span_bug!(expr.span, "named field access on non-ADT"),
270267
}

library/core/tests/mem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,4 @@ fn offset_of_addr() {
458458
assert_eq!(ptr::addr_of!(base).addr() + offset_of!(Foo, y), ptr::addr_of!(base.y).addr());
459459
assert_eq!(ptr::addr_of!(base).addr() + offset_of!(Foo, z.0), ptr::addr_of!(base.z.0).addr());
460460
assert_eq!(ptr::addr_of!(base).addr() + offset_of!(Foo, z.1), ptr::addr_of!(base.z.1).addr());
461-
}
461+
}

tests/ui/lint/dead-code/offset-of-correct-param-env.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ fn test<T>() -> usize
2727
where
2828
GenericIsEqual<T>: Project<EquateParamTo = MyFieldIsNotDead>,
2929
{
30-
// The first field of the A that we construct here is `<GenericIsEqual<T>> as Project>::EquateParamTo`.
31-
// Typeck normalizes this and figures that the not_dead field is totally fine and accessible.
32-
// But importantly, the normalization ends up with T, which, as we've declared in our param env is MyFieldDead.
33-
// When we're in the param env of the `a` field, the where bound above is not in scope, so we don't know what T is - it's generic.
34-
// We cannot access a field on T. Boom!
30+
// The first field of the A that we construct here is
31+
// `<GenericIsEqual<T>> as Project>::EquateParamTo`.
32+
// Typeck normalizes this and figures that the not_dead field is totally fine and accessible.
33+
// But importantly, the normalization ends up with T, which, as we've declared in our param
34+
// env is MyFieldDead. When we're in the param env of the `a` field, the where bound above
35+
// is not in scope, so we don't know what T is - it's generic.
36+
// We cannot access a field on T. Boom!
3537
std::mem::offset_of!(A<GenericIsEqual<T>>, a.not_dead)
3638
}
3739

3840
fn main() {
3941
test::<MyFieldIsNotDead>();
40-
}
42+
}

0 commit comments

Comments
 (0)