summaryrefslogtreecommitdiffstats
path: root/tests/ui/const_prop/overwrite_with_const_with_params.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/const_prop/overwrite_with_const_with_params.rs')
-rw-r--r--tests/ui/const_prop/overwrite_with_const_with_params.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/const_prop/overwrite_with_const_with_params.rs b/tests/ui/const_prop/overwrite_with_const_with_params.rs
new file mode 100644
index 000000000..6f533919a
--- /dev/null
+++ b/tests/ui/const_prop/overwrite_with_const_with_params.rs
@@ -0,0 +1,21 @@
+// compile-flags: -O
+// run-pass
+
+// Regression test for https://github.com/rust-lang/rust/issues/118328
+
+#![allow(unused_assignments)]
+
+struct SizeOfConst<T>(std::marker::PhantomData<T>);
+impl<T> SizeOfConst<T> {
+ const SIZE: usize = std::mem::size_of::<T>();
+}
+
+fn size_of<T>() -> usize {
+ let mut a = 0;
+ a = SizeOfConst::<T>::SIZE;
+ a
+}
+
+fn main() {
+ assert_eq!(size_of::<u32>(), std::mem::size_of::<u32>());
+}