Skip to content

Commit 802b7ab

Browse files
author
Lukas Markeffsky
committed
clean up layout error diagnostics
- group the fluent slugs together - reword (internal-only) "too generic" error to be more in line with the other errors
1 parent d0a5bbb commit 802b7ab

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

Diff for: compiler/rustc_middle/messages.ftl

+14-14
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ middle_autodiff_unsafe_inner_const_ref = reading from a `Duplicated` const {$ty}
3737
middle_bounds_check =
3838
index out of bounds: the length is {$len} but the index is {$index}
3939
40-
middle_cannot_be_normalized =
41-
unable to determine layout for `{$ty}` because `{$failure_ty}` cannot be normalized
42-
4340
middle_conflict_types =
4441
this expression supplies two conflicting concrete types for the same opaque type
4542
@@ -52,9 +49,6 @@ middle_const_eval_non_int =
5249
middle_const_not_used_in_type_alias =
5350
const parameter `{$ct}` is part of concrete type but not used in parameter list for the `impl Trait` type alias
5451
55-
middle_cycle =
56-
a cycle occurred during layout computation
57-
5852
middle_deprecated = use of deprecated {$kind} `{$path}`{$has_note ->
5953
[true] : {$note}
6054
*[other] {""}
@@ -78,9 +72,23 @@ middle_erroneous_constant = erroneous constant encountered
7872
middle_failed_writing_file =
7973
failed to write file {$path}: {$error}"
8074
75+
middle_layout_cycle =
76+
a cycle occurred during layout computation
77+
78+
middle_layout_normalization_failure =
79+
unable to determine layout for `{$ty}` because `{$failure_ty}` cannot be normalized
80+
8181
middle_layout_references_error =
8282
the type has an unknown layout
8383
84+
middle_layout_size_overflow =
85+
values of the type `{$ty}` are too big for the target architecture
86+
87+
middle_layout_too_generic = the type `{$ty}` does not have a fixed layout
88+
89+
middle_layout_unknown =
90+
the type `{$ty}` has an unknown layout
91+
8492
middle_opaque_hidden_type_mismatch =
8593
concrete type differs from previous defining opaque type use
8694
.label = expected `{$self_ty}`, got `{$other_ty}`
@@ -98,16 +106,8 @@ middle_strict_coherence_needs_negative_coherence =
98106
to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled
99107
.label = due to this attribute
100108
101-
middle_too_generic = `{$ty}` does not have a fixed size
102-
103109
middle_type_length_limit = reached the type-length limit while instantiating `{$shrunk}`
104110
105-
middle_unknown_layout =
106-
the type `{$ty}` has an unknown layout
107-
108111
middle_unsupported_union = we don't support unions yet: '{$ty_name}'
109112
110-
middle_values_too_big =
111-
values of the type `{$ty}` are too big for the target architecture
112-
113113
middle_written_to_path = the full type name has been written to '{$path}'

Diff for: compiler/rustc_middle/src/error.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,19 @@ impl fmt::Debug for CustomSubdiagnostic<'_> {
132132

133133
#[derive(Diagnostic)]
134134
pub enum LayoutError<'tcx> {
135-
#[diag(middle_unknown_layout)]
135+
#[diag(middle_layout_unknown)]
136136
Unknown { ty: Ty<'tcx> },
137137

138-
#[diag(middle_too_generic)]
138+
#[diag(middle_layout_too_generic)]
139139
TooGeneric { ty: Ty<'tcx> },
140140

141-
#[diag(middle_values_too_big)]
141+
#[diag(middle_layout_size_overflow)]
142142
Overflow { ty: Ty<'tcx> },
143143

144-
#[diag(middle_cannot_be_normalized)]
144+
#[diag(middle_layout_normalization_failure)]
145145
NormalizationFailure { ty: Ty<'tcx>, failure_ty: String },
146146

147-
#[diag(middle_cycle)]
147+
#[diag(middle_layout_cycle)]
148148
Cycle,
149149

150150
#[diag(middle_layout_references_error)]

Diff for: compiler/rustc_middle/src/ty/layout.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,11 @@ impl<'tcx> LayoutError<'tcx> {
264264

265265
use crate::fluent_generated::*;
266266
match self {
267-
Unknown(_) => middle_unknown_layout,
268-
SizeOverflow(_) => middle_values_too_big,
269-
TooGeneric(_) => middle_too_generic,
270-
NormalizationFailure(_, _) => middle_cannot_be_normalized,
271-
Cycle(_) => middle_cycle,
267+
Unknown(_) => middle_layout_unknown,
268+
SizeOverflow(_) => middle_layout_size_overflow,
269+
TooGeneric(_) => middle_layout_too_generic,
270+
NormalizationFailure(_, _) => middle_layout_normalization_failure,
271+
Cycle(_) => middle_layout_cycle,
272272
ReferencesError(_) => middle_layout_references_error,
273273
}
274274
}
@@ -297,7 +297,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
297297
match *self {
298298
LayoutError::Unknown(ty) => write!(f, "the type `{ty}` has an unknown layout"),
299299
LayoutError::TooGeneric(ty) => {
300-
write!(f, "`{ty}` does not have a fixed size")
300+
write!(f, "the type `{ty}` does not have a fixed layout")
301301
}
302302
LayoutError::SizeOverflow(ty) => {
303303
write!(f, "values of the type `{ty}` are too big for the target architecture")

Diff for: tests/ui/layout/debug.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ union EmptyUnion {} //~ ERROR: has an unknown layout
8686
// Test the error message of `LayoutError::TooGeneric`
8787
// (this error is never emitted to users).
8888
#[rustc_layout(debug)]
89-
type TooGeneric<T> = T; //~ ERROR: does not have a fixed size
89+
type TooGeneric<T> = T; //~ ERROR: does not have a fixed layout

Diff for: tests/ui/layout/debug.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ error: the type has an unknown layout
596596
LL | union EmptyUnion {}
597597
| ^^^^^^^^^^^^^^^^
598598

599-
error: `T` does not have a fixed size
599+
error: the type `T` does not have a fixed layout
600600
--> $DIR/debug.rs:89:1
601601
|
602602
LL | type TooGeneric<T> = T;

0 commit comments

Comments
 (0)