@@ -39,7 +39,7 @@ enum NicheBias {
39
39
End ,
40
40
}
41
41
42
- #[ derive( Copy , Clone , Debug ) ]
42
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
43
43
pub enum LayoutCalculatorError < F > {
44
44
/// An unsized type was found in a location where a sized type was expected.
45
45
///
@@ -59,6 +59,33 @@ pub enum LayoutCalculatorError<F> {
59
59
ReprConflict ,
60
60
}
61
61
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
+
62
89
type LayoutCalculatorResult < FieldIdx , VariantIdx , F > =
63
90
Result < LayoutS < FieldIdx , VariantIdx > , LayoutCalculatorError < F > > ;
64
91
0 commit comments