]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-56870.rs
Rollup merge of #91804 - woppopo:const_clone, r=oli-obk
[rust.git] / src / test / ui / issues / issue-56870.rs
1 // build-pass
2 // Regression test for #56870: Internal compiler error (traits & associated consts)
3
4 use std::fmt::Debug;
5
6 pub trait Foo<T> {
7   const FOO: *const u8;
8 }
9
10 impl <T: Debug> Foo<T> for dyn Debug {
11   const FOO: *const u8 = <T as Debug>::fmt as *const u8;
12 }
13
14 pub trait Bar {
15   const BAR: *const u8;
16 }
17
18 pub trait Baz {
19   type Data: Debug;
20 }
21
22 pub struct BarStruct<S: Baz>(S);
23
24 impl<S: Baz> Bar for BarStruct<S> {
25   const BAR: *const u8 = <dyn Debug as Foo<<S as Baz>::Data>>::FOO;
26 }
27
28 struct AnotherStruct;
29 #[derive(Debug)]
30 struct SomeStruct;
31
32 impl Baz for AnotherStruct {
33   type Data = SomeStruct;
34 }
35
36 fn main() {
37   let _x = <BarStruct<AnotherStruct> as Bar>::BAR;
38 }