2 // compile-flags: -C symbol-mangling-version=v0 --crate-name=c
4 // NOTE(eddyb) we need `core` for `core::option::Option`, normalize away its
5 // disambiguator hash, which can/should change (including between stage{1,2}).
6 // normalize-stderr-test: "core\[[0-9a-f]+\]" -> "core[HASH]"
7 // normalize-stderr-test: "c\[[0-9a-f]+\]" -> "c[HASH]"
9 #![feature(adt_const_params, decl_macro, rustc_attrs)]
10 #![allow(incomplete_features)]
12 pub struct RefByte<const RB: &'static u8>;
15 //~^ ERROR symbol-name
17 //~| ERROR demangling-alt(<c::RefByte<{&123}>>)
18 impl RefByte<{&123}> {}
20 // FIXME(eddyb) this was supposed to be `RefMutZst` with `&mut []`,
21 // but that is currently not allowed in const generics.
22 pub struct RefZst<const RMZ: &'static [u8; 0]>;
25 //~^ ERROR symbol-name
27 //~| ERROR demangling-alt(<c::RefZst<{&[]}>>)
30 pub struct Array3Bytes<const A3B: [u8; 3]>;
33 //~^ ERROR symbol-name
35 //~| ERROR demangling-alt(<c::Array3Bytes<{[1, 2, 3]}>>)
36 impl Array3Bytes<{[1, 2, 3]}> {}
38 pub struct TupleByteBool<const TBB: (u8, bool)>;
41 //~^ ERROR symbol-name
43 //~| ERROR demangling-alt(<c::TupleByteBool<{(1, false)}>>)
44 impl TupleByteBool<{(1, false)}> {}
46 pub struct OptionUsize<const OU: Option<usize>>;
48 // HACK(eddyb) the full mangling is only in `.stderr` because we can normalize
49 // the `core` disambiguator hash away there, but not here.
51 //~^ ERROR symbol-name
53 //~| ERROR demangling-alt(<c::OptionUsize<{core::option::Option::<usize>::None}>>)
54 impl OptionUsize<{None}> {}
56 // HACK(eddyb) the full mangling is only in `.stderr` because we can normalize
57 // the `core` disambiguator hash away there, but not here.
59 //~^ ERROR symbol-name
61 //~| ERROR demangling-alt(<c::OptionUsize<{core::option::Option::<usize>::Some(0)}>>)
62 impl OptionUsize<{Some(0)}> {}
64 #[derive(PartialEq, Eq)]
70 pub struct Foo_<const F: Foo>;
73 //~^ ERROR symbol-name
75 //~| ERROR demangling-alt(<c::Foo_<{c::Foo { s: "abc", ch: 'x', slice: &[1, 2, 3] }}>>)
76 impl Foo_<{Foo { s: "abc", ch: 'x', slice: &[1, 2, 3] }}> {}
78 // NOTE(eddyb) this tests specifically the use of disambiguators in field names,
79 // using macros 2.0 hygiene to create a `struct` with conflicting field names.
80 macro duplicate_field_name_test($x:ident) {
81 #[derive(PartialEq, Eq)]
86 pub struct Bar_<const B: Bar>;
89 //~^ ERROR symbol-name
91 //~| ERROR demangling-alt(<c::Bar_<{c::Bar { x: 123, x: 4096 }}>>)
92 impl Bar_<{Bar { $x: 123, x: 4096 }}> {}
94 duplicate_field_name_test!(x);