@@ -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
///
@@ -56,6 +56,31 @@ pub enum LayoutCalculatorError<F> {
56
56
EmptyUnion ,
57
57
}
58
58
59
+ impl < F > LayoutCalculatorError < F > {
60
+ pub fn without_payload ( & self ) -> LayoutCalculatorError < ( ) > {
61
+ match self {
62
+ LayoutCalculatorError :: UnexpectedUnsized ( _) => {
63
+ LayoutCalculatorError :: UnexpectedUnsized ( ( ) )
64
+ }
65
+ LayoutCalculatorError :: SizeOverflow => LayoutCalculatorError :: SizeOverflow ,
66
+ LayoutCalculatorError :: EmptyUnion => LayoutCalculatorError :: EmptyUnion ,
67
+ }
68
+ }
69
+
70
+ /// Format an untranslated diagnostic for this type
71
+ ///
72
+ /// Intended for use by rust-analyzer, as neither it nor `rustc_abi` depend on fluent infra.
73
+ pub fn fallback_fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
74
+ f. write_str ( match self {
75
+ LayoutCalculatorError :: UnexpectedUnsized ( _) => {
76
+ "an unsized type was found where a sized type was expected"
77
+ }
78
+ LayoutCalculatorError :: SizeOverflow => "size overflow" ,
79
+ LayoutCalculatorError :: EmptyUnion => "type is a union with no fields" ,
80
+ } )
81
+ }
82
+ }
83
+
59
84
type LayoutCalculatorResult < FieldIdx , VariantIdx , F > =
60
85
Result < LayoutS < FieldIdx , VariantIdx > , LayoutCalculatorError < F > > ;
61
86
0 commit comments