@@ -39,7 +39,7 @@ enum NicheBias {
3939 End ,
4040}
4141
42- #[ derive( Copy , Clone , Debug ) ]
42+ #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
4343pub enum LayoutCalculatorError < F > {
4444 /// An unsized type was found in a location where a sized type was expected.
4545 ///
@@ -59,6 +59,33 @@ pub enum LayoutCalculatorError<F> {
5959 ReprConflict ,
6060}
6161
62+ impl < F > LayoutCalculatorError < F > {
63+ pub fn without_payload ( & self ) -> LayoutCalculatorError < ( ) > {
64+ match self {
65+ LayoutCalculatorError :: UnexpectedUnsized ( _) => {
66+ LayoutCalculatorError :: UnexpectedUnsized ( ( ) )
67+ }
68+ LayoutCalculatorError :: SizeOverflow => LayoutCalculatorError :: SizeOverflow ,
69+ LayoutCalculatorError :: EmptyUnion => LayoutCalculatorError :: EmptyUnion ,
70+ LayoutCalculatorError :: ReprConflict => LayoutCalculatorError :: ReprConflict ,
71+ }
72+ }
73+
74+ /// Format an untranslated diagnostic for this type
75+ ///
76+ /// Intended for use by rust-analyzer, as neither it nor `rustc_abi` depend on fluent infra.
77+ pub fn fallback_fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
78+ f. write_str ( match self {
79+ LayoutCalculatorError :: UnexpectedUnsized ( _) => {
80+ "an unsized type was found where a sized type was expected"
81+ }
82+ LayoutCalculatorError :: SizeOverflow => "size overflow" ,
83+ LayoutCalculatorError :: EmptyUnion => "type is a union with no fields" ,
84+ LayoutCalculatorError :: ReprConflict => "type has an invalid repr" ,
85+ } )
86+ }
87+ }
88+
6289type LayoutCalculatorResult < FieldIdx , VariantIdx , F > =
6390 Result < LayoutS < FieldIdx , VariantIdx > , LayoutCalculatorError < F > > ;
6491
0 commit comments