]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/associated-consts/defaults-not-assumed-pass.rs
6 // This should not be a constant evaluation error (overflow). The value of
7 // `Self::A` must not be assumed to hold inside the trait.
8 const B
: u8 = Self::A
+ 1;
11 // An impl that doesn't override any constant will NOT cause a const eval error
12 // just because it's defined, but only if the bad constant is used anywhere.
13 // This matches the behavior without defaults.
16 // An impl that overrides either constant with a suitable value will be fine.
31 assert_eq
!(<() as Tr
>::A
, 255);
32 //assert_eq!(<() as Tr>::B, 0); // using this is an error
34 assert_eq
!(<u8 as Tr
>::A
, 254);
35 assert_eq
!(<u8 as Tr
>::B
, 255);
37 assert_eq
!(<u16 as Tr
>::A
, 255);
38 assert_eq
!(<u16 as Tr
>::B
, 0);
40 assert_eq
!(<u32 as Tr
>::A
, 254);
41 assert_eq
!(<u32 as Tr
>::B
, 0);