X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_middle%2Fsrc%2Fty%2Flayout.rs;h=0a109fd8f44f85125baa0bcc9f65af9e1f981428;hb=c65ebae2216119d23d88bbfea78192a3d950c4f3;hp=5f8729a8ddf3caadd4cbb33b5e3c7a27c150340a;hpb=42df0a580fe9aa66b8d6457a27b2093208331dc3;p=rust.git diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 5f8729a8ddf..0a109fd8f44 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -191,10 +191,29 @@ pub enum LayoutError<'tcx> { impl<'a> IntoDiagnostic<'a, !> for LayoutError<'a> { fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, !> { - handler.struct_fatal(self.to_string()) + let mut diag = handler.struct_fatal(""); + + match self { + LayoutError::Unknown(ty) => { + diag.set_arg("ty", ty); + diag.set_primary_message(rustc_errors::fluent::middle_unknown_layout); + } + LayoutError::SizeOverflow(ty) => { + diag.set_arg("ty", ty); + diag.set_primary_message(rustc_errors::fluent::middle_values_too_big); + } + LayoutError::NormalizationFailure(ty, e) => { + diag.set_arg("ty", ty); + diag.set_arg("failure_ty", e.get_type_for_failure()); + diag.set_primary_message(rustc_errors::fluent::middle_cannot_be_normalized); + } + } + diag } } +// FIXME: Once the other errors that embed this error have been converted to translateable +// diagnostics, this Display impl should be removed. impl<'tcx> fmt::Display for LayoutError<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self {