From 89f56a8568d061ea5e110d804aeb62f390a3be17 Mon Sep 17 00:00:00 2001 From: joboet Date: Fri, 5 Jan 2024 12:20:01 +0100 Subject: [PATCH] add regression test to adress the issue outlined in #119562 --- library/core/tests/pin.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/core/tests/pin.rs b/library/core/tests/pin.rs index 6f617c8d0c297..ce0c6c6f85cf9 100644 --- a/library/core/tests/pin.rs +++ b/library/core/tests/pin.rs @@ -29,3 +29,14 @@ fn pin_const() { pin_mut_const(); } + +#[test] +fn dont_shadow() { + // test that the pointer field does not shadow fields of the pinned data. + + struct Pinned { + pinned: i32, + } + + let _: i32 = Pin::new(&mut Pinned { pinned: 0 }).pinned; +}