diff options
Diffstat (limited to 'src/test/ui/associated-consts/defaults-cyclic-fail.rs')
-rw-r--r-- | src/test/ui/associated-consts/defaults-cyclic-fail.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/ui/associated-consts/defaults-cyclic-fail.rs b/src/test/ui/associated-consts/defaults-cyclic-fail.rs new file mode 100644 index 000000000..a1c6840a0 --- /dev/null +++ b/src/test/ui/associated-consts/defaults-cyclic-fail.rs @@ -0,0 +1,17 @@ +// build-fail + +// Cyclic assoc. const defaults don't error unless *used* +trait Tr { + const A: u8 = Self::B; + //~^ cycle detected when const-evaluating + checking `Tr::A` + + const B: u8 = Self::A; +} + +// This impl is *allowed* unless its assoc. consts are used +impl Tr for () {} + +fn main() { + // This triggers the cycle error + assert_eq!(<() as Tr>::A, 0); +} |