From 6d4a693b0b452977ec880097c7e71d12092c1147 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 7 Sep 2023 15:14:40 +1000 Subject: [PATCH] Disentangle `Debug` and `Display` for `Ty`. The `Debug` impl for `Ty` just calls the `Display` impl for `Ty`. This is surprising and annoying. In particular, it means `Debug` doesn't show as much information as `Debug` for `TyKind` does. And `Debug` is used in some user-facing error messages, which seems bad. This commit changes the `Debug` impl for `Ty` to call the `Debug` impl for `TyKind`. It also does a number of follow-up changes to preserve existing output, many of which involve inserting `with_no_trimmed_paths!` calls. It also adds `Display` impls for `UserType` and `Canonical`. Some tests have changes to expected output: - Those that use the `rustc_abi(debug)` attribute. - Those that use the `rustc_layout(debug)` attribute. - Those that use the `EMIT_MIR` annotation. In each case the output is slightly uglier than before. This isn't ideal, but it's pretty weird (particularly for the attributes) that the output is using `Debug` in the first place. They're fairly obscure attributes (I hadn't heard of them) so I'm not worried by this. For `async-is-unwindsafe.stderr`, there is one line that now lacks a full path. This is a consistency improvement, because all the other mentions of `Context` in this test lack a path. --- compiler/rustc_borrowck/src/nll.rs | 6 +- .../rustc_borrowck/src/universal_regions.rs | 21 +++- compiler/rustc_middle/src/infer/canonical.rs | 11 +++ compiler/rustc_middle/src/mir/mod.rs | 20 ++-- compiler/rustc_middle/src/mir/pretty.rs | 10 +- compiler/rustc_middle/src/ty/print/pretty.rs | 9 +- .../rustc_middle/src/ty/structural_impls.rs | 2 +- .../rustc_middle/src/ty/typeck_results.rs | 11 +++ compiler/rustc_passes/src/abi_test.rs | 1 + compiler/rustc_passes/src/layout_test.rs | 1 + .../src/traits/error_reporting/suggestions.rs | 2 +- compiler/rustc_ty_utils/src/layout.rs | 3 +- ...await.b-{closure#0}.generator_resume.0.mir | 18 +++- ...losure#0}.generator_drop.0.panic-abort.mir | 6 +- ...osure#0}.generator_drop.0.panic-unwind.mir | 6 +- ...ny.main-{closure#0}.generator_resume.0.mir | 6 +- .../mir-opt/issue_99325.main.built.after.mir | 4 +- tests/ui/abi/debug.stderr | 4 +- .../ui/async-await/async-is-unwindsafe.stderr | 2 +- tests/ui/layout/debug.stderr | 26 ++--- tests/ui/layout/hexagon-enum.stderr | 10 +- ...-scalarpair-payload-might-be-uninit.stderr | 10 +- .../issue-96185-overaligned-enum.stderr | 4 +- tests/ui/layout/thumb-enum.stderr | 10 +- .../layout/zero-sized-array-enum-niche.stderr | 8 +- .../thir-print/thir-flat-const-variant.stdout | 96 +++++++++++++++---- tests/ui/thir-print/thir-tree-match.stdout | 20 ++-- 27 files changed, 235 insertions(+), 92 deletions(-) diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs index 679a19710a7f4..3f60f5aca71d4 100644 --- a/compiler/rustc_borrowck/src/nll.rs +++ b/compiler/rustc_borrowck/src/nll.rs @@ -10,6 +10,7 @@ use rustc_middle::mir::{ Body, ClosureOutlivesSubject, ClosureRegionRequirements, LocalKind, Location, Promoted, START_BLOCK, }; +use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{self, OpaqueHiddenType, TyCtxt}; use rustc_span::symbol::sym; use std::env; @@ -441,7 +442,10 @@ fn for_each_region_constraint<'tcx>( let subject = match req.subject { ClosureOutlivesSubject::Region(subject) => format!("{subject:?}"), ClosureOutlivesSubject::Ty(ty) => { - format!("{:?}", ty.instantiate(tcx, |vid| ty::Region::new_var(tcx, vid))) + with_no_trimmed_paths!(format!( + "{}", + ty.instantiate(tcx, |vid| ty::Region::new_var(tcx, vid)) + )) } }; with_msg(format!("where {}: {:?}", subject, req.outlived_free_region,))?; diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index 56945f43fcda6..3b5f1178db520 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -21,6 +21,7 @@ use rustc_hir::BodyOwnerKind; use rustc_index::IndexVec; use rustc_infer::infer::NllRegionVariableOrigin; use rustc_middle::ty::fold::TypeFoldable; +use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{self, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty, TyCtxt}; use rustc_middle::ty::{GenericArgs, GenericArgsRef}; use rustc_span::symbol::{kw, sym}; @@ -332,10 +333,16 @@ impl<'tcx> UniversalRegions<'tcx> { pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diagnostic) { match self.defining_ty { DefiningTy::Closure(def_id, args) => { + let v = with_no_trimmed_paths!( + args[tcx.generics_of(def_id).parent_count..] + .iter() + .map(|arg| arg.to_string()) + .collect::>() + ); err.note(format!( - "defining type: {} with closure args {:#?}", + "defining type: {} with closure args [\n {},\n]", tcx.def_path_str_with_args(def_id, args), - &args[tcx.generics_of(def_id).parent_count..], + v.join(",\n "), )); // FIXME: It'd be nice to print the late-bound regions @@ -348,10 +355,16 @@ impl<'tcx> UniversalRegions<'tcx> { }); } DefiningTy::Generator(def_id, args, _) => { + let v = with_no_trimmed_paths!( + args[tcx.generics_of(def_id).parent_count..] + .iter() + .map(|arg| arg.to_string()) + .collect::>() + ); err.note(format!( - "defining type: {} with generator args {:#?}", + "defining type: {} with generator args [\n {},\n]", tcx.def_path_str_with_args(def_id, args), - &args[tcx.generics_of(def_id).parent_count..], + v.join(",\n "), )); // FIXME: As above, we'd like to print out the region diff --git a/compiler/rustc_middle/src/infer/canonical.rs b/compiler/rustc_middle/src/infer/canonical.rs index 81823118ab810..5011ea829dcdb 100644 --- a/compiler/rustc_middle/src/infer/canonical.rs +++ b/compiler/rustc_middle/src/infer/canonical.rs @@ -27,6 +27,7 @@ use crate::ty::GenericArg; use crate::ty::{self, BoundVar, List, Region, Ty, TyCtxt}; use rustc_macros::HashStable; use smallvec::SmallVec; +use std::fmt::Display; use std::ops::Index; /// A "canonicalized" type `V` is one where all free inference @@ -40,6 +41,16 @@ pub struct Canonical<'tcx, V> { pub variables: CanonicalVarInfos<'tcx>, } +impl<'tcx, V: Display> std::fmt::Display for Canonical<'tcx, V> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "Canonical {{ value: {}, max_universe: {:?}, variables: {:?} }}", + self.value, self.max_universe, self.variables + ) + } +} + pub type CanonicalVarInfos<'tcx> = &'tcx List>; impl<'tcx> ty::TypeFoldable> for CanonicalVarInfos<'tcx> { diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 239d20ae1b09c..a2de5449552f5 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -8,6 +8,7 @@ use crate::mir::interpret::{ use crate::mir::visit::MirVisitable; use crate::ty::codec::{TyDecoder, TyEncoder}; use crate::ty::fold::{FallibleTypeFolder, TypeFoldable}; +use crate::ty::print::with_no_trimmed_paths; use crate::ty::print::{FmtPrinter, Printer}; use crate::ty::visit::TypeVisitableExt; use crate::ty::{self, List, Ty, TyCtxt}; @@ -1787,7 +1788,7 @@ fn post_fmt_projection(projection: &[PlaceElem<'_>], fmt: &mut Formatter<'_>) -> write!(fmt, ")")?; } ProjectionElem::Field(field, ty) => { - write!(fmt, ".{:?}: {:?})", field.index(), ty)?; + with_no_trimmed_paths!(write!(fmt, ".{:?}: {})", field.index(), ty)?); } ProjectionElem::Index(ref index) => { write!(fmt, "[{index:?}]")?; @@ -2070,7 +2071,7 @@ impl<'tcx> Debug for Rvalue<'tcx> { } Len(ref a) => write!(fmt, "Len({a:?})"), Cast(ref kind, ref place, ref ty) => { - write!(fmt, "{place:?} as {ty:?} ({kind:?})") + with_no_trimmed_paths!(write!(fmt, "{place:?} as {ty} ({kind:?})")) } BinaryOp(ref op, box (ref a, ref b)) => write!(fmt, "{op:?}({a:?}, {b:?})"), CheckedBinaryOp(ref op, box (ref a, ref b)) => { @@ -2078,11 +2079,14 @@ impl<'tcx> Debug for Rvalue<'tcx> { } UnaryOp(ref op, ref a) => write!(fmt, "{op:?}({a:?})"), Discriminant(ref place) => write!(fmt, "discriminant({place:?})"), - NullaryOp(ref op, ref t) => match op { - NullOp::SizeOf => write!(fmt, "SizeOf({t:?})"), - NullOp::AlignOf => write!(fmt, "AlignOf({t:?})"), - NullOp::OffsetOf(fields) => write!(fmt, "OffsetOf({t:?}, {fields:?})"), - }, + NullaryOp(ref op, ref t) => { + let t = with_no_trimmed_paths!(format!("{}", t)); + match op { + NullOp::SizeOf => write!(fmt, "SizeOf({t})"), + NullOp::AlignOf => write!(fmt, "AlignOf({t})"), + NullOp::OffsetOf(fields) => write!(fmt, "OffsetOf({t}, {fields:?})"), + } + } ThreadLocalRef(did) => ty::tls::with(|tcx| { let muta = tcx.static_mutability(did).unwrap().prefix_str(); write!(fmt, "&/*tls*/ {}{}", muta, tcx.def_path_str(did)) @@ -2218,7 +2222,7 @@ impl<'tcx> Debug for Rvalue<'tcx> { } ShallowInitBox(ref place, ref ty) => { - write!(fmt, "ShallowInitBox({place:?}, {ty:?})") + with_no_trimmed_paths!(write!(fmt, "ShallowInitBox({place:?}, {ty})")) } } } diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 488526edb430d..6b23a7f5bff5b 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -583,8 +583,10 @@ fn write_scope_tree( let mut_str = local_decl.mutability.prefix_str(); - let mut indented_decl = - format!("{0:1$}let {2}{3:?}: {4:?}", INDENT, indent, mut_str, local, local_decl.ty); + let mut indented_decl = ty::print::with_no_trimmed_paths!(format!( + "{0:1$}let {2}{3:?}: {4}", + INDENT, indent, mut_str, local, local_decl.ty + )); if let Some(user_ty) = &local_decl.user_ty { for user_ty in user_ty.projections() { write!(indented_decl, " as {user_ty:?}").unwrap(); @@ -1058,11 +1060,11 @@ fn write_user_type_annotations( for (index, annotation) in body.user_type_annotations.iter_enumerated() { writeln!( w, - "| {:?}: user_ty: {:?}, span: {}, inferred_ty: {:?}", + "| {:?}: user_ty: {}, span: {}, inferred_ty: {}", index.index(), annotation.user_ty, tcx.sess.source_map().span_to_embeddable_string(annotation.span), - annotation.inferred_ty, + with_no_trimmed_paths!(format!("{}", annotation.inferred_ty)), )?; } if !body.user_type_annotations.is_empty() { diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index ac0c88468faa5..c6f442722eaa6 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -760,9 +760,13 @@ pub trait PrettyPrinter<'tcx>: // only affect certain debug messages (e.g. messages printed // from `rustc_middle::ty` during the computation of `tcx.predicates_of`), // and should have no effect on any compiler output. + // [Untrue! It shows up in the output of + // tests/ui/nll/ty-outlives/impl-trait-captures.rs, for + // example.] if self.should_print_verbose() { // FIXME(eddyb) print this with `print_def_path`. - p!(write("Opaque({:?}, {:?})", def_id, args)); + let v = args.iter().map(|arg| arg.to_string()).collect::>(); + p!(write("Opaque({:?}, [{}])", def_id, v.join(", "))); return Ok(self); } @@ -894,7 +898,8 @@ pub trait PrettyPrinter<'tcx>: p!(print_def_path(did, args)); if !args.as_closure().is_valid() { p!(" closure_args=(unavailable)"); - p!(write(" args={:?}", args)); + let v = args.iter().map(|arg| arg.to_string()).collect::>(); + p!(write(" args=[{}]", v.join(", "))); } else { p!(" closure_kind_ty=", print(args.as_closure().kind_ty())); p!( diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index f979ddd00fa01..a35ca8685c47a 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -154,7 +154,7 @@ impl<'tcx> ty::DebugWithInfcx> for Ty<'tcx> { } impl<'tcx> fmt::Debug for Ty<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - with_no_trimmed_paths!(fmt::Display::fmt(self, f)) + with_no_trimmed_paths!(fmt::Debug::fmt(self.kind(), f)) } } diff --git a/compiler/rustc_middle/src/ty/typeck_results.rs b/compiler/rustc_middle/src/ty/typeck_results.rs index 327cd0a5d7b31..7ecc7e6014dfe 100644 --- a/compiler/rustc_middle/src/ty/typeck_results.rs +++ b/compiler/rustc_middle/src/ty/typeck_results.rs @@ -722,3 +722,14 @@ pub enum UserType<'tcx> { /// given substitutions applied. TypeOf(DefId, UserArgs<'tcx>), } + +impl<'tcx> std::fmt::Display for UserType<'tcx> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Ty(arg0) => { + ty::print::with_no_trimmed_paths!(write!(f, "Ty({})", arg0)) + } + Self::TypeOf(arg0, arg1) => write!(f, "TypeOf({:?}, {:?})", arg0, arg1), + } + } +} diff --git a/compiler/rustc_passes/src/abi_test.rs b/compiler/rustc_passes/src/abi_test.rs index 5c0438e78aebc..29d66117aa196 100644 --- a/compiler/rustc_passes/src/abi_test.rs +++ b/compiler/rustc_passes/src/abi_test.rs @@ -63,6 +63,7 @@ fn dump_abi_of(tcx: TyCtxt<'_>, item_def_id: DefId, attr: &Attribute) { tcx.sess.emit_err(AbiOf { span: tcx.def_span(item_def_id), fn_name, + // FIXME: using the `Debug` impl here isn't ideal. fn_abi: format!("{:#?}", abi), }); } diff --git a/compiler/rustc_passes/src/layout_test.rs b/compiler/rustc_passes/src/layout_test.rs index d839fee07a60d..353a0be94a57e 100644 --- a/compiler/rustc_passes/src/layout_test.rs +++ b/compiler/rustc_passes/src/layout_test.rs @@ -76,6 +76,7 @@ fn dump_layout_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId, attr: &Attribute) { ty, ) ); + // FIXME: using the `Debug` impl here isn't ideal. let ty_layout = format!("{:#?}", *ty_layout); tcx.sess.emit_err(LayoutOf { span: tcx.def_span(item_def_id.to_def_id()), diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 611ec6b00ef60..796834978fe9d 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1792,7 +1792,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ); } else { err.note(format!( - "`{}` is implemented for `{:?}`, but not for `{:?}`", + "`{}` is implemented for `{}`, but not for `{}`", trait_pred.print_modifiers_and_trait_path(), suggested_ty, trait_pred.skip_binder().self_ty(), diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index ed7b3496894dd..904f1b3874088 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -7,6 +7,7 @@ use rustc_middle::query::Providers; use rustc_middle::ty::layout::{ IntegerExt, LayoutCx, LayoutError, LayoutOf, TyAndLayout, MAX_SIMD_LANES, }; +use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{ self, AdtDef, EarlyBinder, GenericArgsRef, ReprOptions, Ty, TyCtxt, TypeVisitableExt, }; @@ -937,7 +938,7 @@ fn record_layout_for_printing_outlined<'tcx>( // (delay format until we actually need it) let record = |kind, packed, opt_discr_size, variants| { - let type_desc = format!("{:?}", layout.ty); + let type_desc = with_no_trimmed_paths!(format!("{}", layout.ty)); cx.tcx.sess.code_stats.record_type_size( kind, type_desc, diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir index 80ac92d59f3c2..b06666c9dd771 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir @@ -2,7 +2,14 @@ /* generator_layout = GeneratorLayout { field_tys: { _0: GeneratorSavedTy { - ty: impl std::future::Future, + ty: Alias( + Opaque, + AliasTy { + args: [ + ], + def_id: DefId(0:7 ~ async_await[ccf8]::a::{opaque#0}), + }, + ), source_info: SourceInfo { span: $DIR/async_await.rs:15:9: 15:14 (#8), scope: scope[0], @@ -10,7 +17,14 @@ ignore_for_traits: false, }, _1: GeneratorSavedTy { - ty: impl std::future::Future, + ty: Alias( + Opaque, + AliasTy { + args: [ + ], + def_id: DefId(0:7 ~ async_await[ccf8]::a::{opaque#0}), + }, + ), source_info: SourceInfo { span: $DIR/async_await.rs:16:9: 16:14 (#10), scope: scope[0], diff --git a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-abort.mir b/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-abort.mir index 958078b97064e..acbb79049853e 100644 --- a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-abort.mir +++ b/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-abort.mir @@ -2,7 +2,11 @@ /* generator_layout = GeneratorLayout { field_tys: { _0: GeneratorSavedTy { - ty: std::string::String, + ty: Adt( + std::string::String, + [ + ], + ), source_info: SourceInfo { span: $DIR/generator_drop_cleanup.rs:11:13: 11:15 (#0), scope: scope[0], diff --git a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-unwind.mir b/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-unwind.mir index 7e050e585b1db..c17d4421542b1 100644 --- a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-unwind.mir +++ b/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-unwind.mir @@ -2,7 +2,11 @@ /* generator_layout = GeneratorLayout { field_tys: { _0: GeneratorSavedTy { - ty: std::string::String, + ty: Adt( + std::string::String, + [ + ], + ), source_info: SourceInfo { span: $DIR/generator_drop_cleanup.rs:11:13: 11:15 (#0), scope: scope[0], diff --git a/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir b/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir index 13d703b908cc8..e33f5f59de1ca 100644 --- a/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir @@ -2,7 +2,11 @@ /* generator_layout = GeneratorLayout { field_tys: { _0: GeneratorSavedTy { - ty: HasDrop, + ty: Adt( + HasDrop, + [ + ], + ), source_info: SourceInfo { span: $DIR/generator_tiny.rs:20:13: 20:15 (#0), scope: scope[0], diff --git a/tests/mir-opt/issue_99325.main.built.after.mir b/tests/mir-opt/issue_99325.main.built.after.mir index f12179a890535..55f6176b331c4 100644 --- a/tests/mir-opt/issue_99325.main.built.after.mir +++ b/tests/mir-opt/issue_99325.main.built.after.mir @@ -1,8 +1,8 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [Const { ty: &'static [u8; 4], kind: Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)]) }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} -| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [Const { ty: &'static [u8; 4], kind: UnevaluatedConst { def: DefId(0:8 ~ issue_99325[22bb]::main::{constant#1}), args: [] } }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:11:16: 11:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [Const { ty: &ReStatic [u8; Const { ty: usize, kind: Leaf(0x0000000000000004) }], kind: Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)]) }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserArgs { args: [Const { ty: &ReStatic [u8; Const { ty: usize, kind: Leaf(0x0000000000000004) }], kind: UnevaluatedConst { def: DefId(0:8 ~ issue_99325[22bb]::main::{constant#1}), args: [] } }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:11:16: 11:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | fn main() -> () { let mut _0: (); diff --git a/tests/ui/abi/debug.stderr b/tests/ui/abi/debug.stderr index 4f4ee3de4b8a0..7fc3370f26f39 100644 --- a/tests/ui/abi/debug.stderr +++ b/tests/ui/abi/debug.stderr @@ -96,7 +96,7 @@ error: fn_abi_of_instance(test_generic) = FnAbi { args: [ ArgAbi { layout: TyAndLayout { - ty: *const T, + ty: *const T/#0, layout: Layout { size: $SOME_SIZE, align: AbiAndPrefAlign { @@ -172,7 +172,7 @@ error: fn_abi_of_instance(assoc_test) = FnAbi { args: [ ArgAbi { layout: TyAndLayout { - ty: &S, + ty: &ReErased Adt(S, []), layout: Layout { size: $SOME_SIZE, align: AbiAndPrefAlign { diff --git a/tests/ui/async-await/async-is-unwindsafe.stderr b/tests/ui/async-await/async-is-unwindsafe.stderr index 5d29325c82730..c855e902ba93d 100644 --- a/tests/ui/async-await/async-is-unwindsafe.stderr +++ b/tests/ui/async-await/async-is-unwindsafe.stderr @@ -15,7 +15,7 @@ LL | | }); | within this `[async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6]` | = help: within `[async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6]`, the trait `UnwindSafe` is not implemented for `&mut Context<'_>` - = note: `UnwindSafe` is implemented for `&std::task::Context<'_>`, but not for `&mut std::task::Context<'_>` + = note: `UnwindSafe` is implemented for `&Context<'_>`, but not for `&mut Context<'_>` note: future does not implement `UnwindSafe` as this value is used across an await --> $DIR/async-is-unwindsafe.rs:25:18 | diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index c20a0198ccb8b..3302b158b84f7 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -1,4 +1,4 @@ -error: layout_of(E) = Layout { +error: layout_of(Adt(E, [])) = Layout { size: Size(12 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), @@ -92,7 +92,7 @@ error: layout_of(E) = Layout { LL | enum E { Foo, Bar(!, i32, i32) } | ^^^^^^ -error: layout_of(S) = Layout { +error: layout_of(Adt(S, [])) = Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), @@ -138,7 +138,7 @@ error: layout_of(S) = Layout { LL | struct S { f1: i32, f2: (), f3: i32 } | ^^^^^^^^ -error: layout_of(U) = Layout { +error: layout_of(Adt(U, [])) = Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), @@ -162,7 +162,7 @@ error: layout_of(U) = Layout { LL | union U { f1: (i32, i32), f3: i32 } | ^^^^^^^ -error: layout_of(std::result::Result) = Layout { +error: layout_of(Adt(std::result::Result, [i32, i32])) = Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), @@ -325,7 +325,7 @@ error: layout_of(i32) = Layout { LL | type T = impl std::fmt::Debug; | ^^^^^^ -error: layout_of(V) = Layout { +error: layout_of(Adt(V, [])) = Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(2 bytes), @@ -349,7 +349,7 @@ error: layout_of(V) = Layout { LL | pub union V { | ^^^^^^^^^^^ -error: layout_of(W) = Layout { +error: layout_of(Adt(W, [])) = Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(2 bytes), @@ -373,7 +373,7 @@ error: layout_of(W) = Layout { LL | pub union W { | ^^^^^^^^^^^ -error: layout_of(Y) = Layout { +error: layout_of(Adt(Y, [])) = Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(2 bytes), @@ -397,7 +397,7 @@ error: layout_of(Y) = Layout { LL | pub union Y { | ^^^^^^^^^^^ -error: layout_of(P1) = Layout { +error: layout_of(Adt(P1, [])) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -421,7 +421,7 @@ error: layout_of(P1) = Layout { LL | union P1 { x: u32 } | ^^^^^^^^ -error: layout_of(P2) = Layout { +error: layout_of(Adt(P2, [])) = Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -445,7 +445,7 @@ error: layout_of(P2) = Layout { LL | union P2 { x: (u32, u32) } | ^^^^^^^^ -error: layout_of(P3) = Layout { +error: layout_of(Adt(P3, [])) = Layout { size: Size(16 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -469,7 +469,7 @@ error: layout_of(P3) = Layout { LL | union P3 { x: F32x4 } | ^^^^^^^^ -error: layout_of(P4) = Layout { +error: layout_of(Adt(P4, [])) = Layout { size: Size(12 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -493,7 +493,7 @@ error: layout_of(P4) = Layout { LL | union P4 { x: E } | ^^^^^^^^ -error: layout_of(P5) = Layout { +error: layout_of(Adt(P5, [])) = Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -522,7 +522,7 @@ error: layout_of(P5) = Layout { LL | union P5 { zst: [u16; 0], byte: u8 } | ^^^^^^^^ -error: layout_of(std::mem::MaybeUninit) = Layout { +error: layout_of(Adt(std::mem::MaybeUninit, [u8])) = Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index a2ad4a1ab58ad..d7df5bca90c8a 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -1,4 +1,4 @@ -error: layout_of(A) = Layout { +error: layout_of(Adt(A, [])) = Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -72,7 +72,7 @@ error: layout_of(A) = Layout { LL | enum A { Apple } | ^^^^^^ -error: layout_of(B) = Layout { +error: layout_of(Adt(B, [])) = Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -146,7 +146,7 @@ error: layout_of(B) = Layout { LL | enum B { Banana = 255, } | ^^^^^^ -error: layout_of(C) = Layout { +error: layout_of(Adt(C, [])) = Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(2 bytes), @@ -220,7 +220,7 @@ error: layout_of(C) = Layout { LL | enum C { Chaenomeles = 256, } | ^^^^^^ -error: layout_of(P) = Layout { +error: layout_of(Adt(P, [])) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), @@ -294,7 +294,7 @@ error: layout_of(P) = Layout { LL | enum P { Peach = 0x1000_0000isize, } | ^^^^^^ -error: layout_of(T) = Layout { +error: layout_of(Adt(T, [])) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index d3ba1a295b1bc..4acb53e92c89b 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -1,4 +1,4 @@ -error: layout_of(MissingPayloadField) = Layout { +error: layout_of(Adt(MissingPayloadField, [])) = Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -114,7 +114,7 @@ error: layout_of(MissingPayloadField) = Layout { LL | pub enum MissingPayloadField { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: layout_of(CommonPayloadField) = Layout { +error: layout_of(Adt(CommonPayloadField, [])) = Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -249,7 +249,7 @@ error: layout_of(CommonPayloadField) = Layout { LL | pub enum CommonPayloadField { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { +error: layout_of(Adt(CommonPayloadFieldIsMaybeUninit, [])) = Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -381,7 +381,7 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { LL | pub enum CommonPayloadFieldIsMaybeUninit { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: layout_of(NicheFirst) = Layout { +error: layout_of(Adt(NicheFirst, [])) = Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -533,7 +533,7 @@ error: layout_of(NicheFirst) = Layout { LL | pub enum NicheFirst { | ^^^^^^^^^^^^^^^^^^^ -error: layout_of(NicheSecond) = Layout { +error: layout_of(Adt(NicheSecond, [])) = Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr index c539eb453d915..9df2b2fbe7c2c 100644 --- a/tests/ui/layout/issue-96185-overaligned-enum.stderr +++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr @@ -1,4 +1,4 @@ -error: layout_of(Aligned1) = Layout { +error: layout_of(Adt(Aligned1, [])) = Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), @@ -92,7 +92,7 @@ error: layout_of(Aligned1) = Layout { LL | pub enum Aligned1 { | ^^^^^^^^^^^^^^^^^ -error: layout_of(Aligned2) = Layout { +error: layout_of(Adt(Aligned2, [])) = Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index 6f6ab49820676..c64180a63dab0 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -1,4 +1,4 @@ -error: layout_of(A) = Layout { +error: layout_of(Adt(A, [])) = Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -72,7 +72,7 @@ error: layout_of(A) = Layout { LL | enum A { Apple } | ^^^^^^ -error: layout_of(B) = Layout { +error: layout_of(Adt(B, [])) = Layout { size: Size(1 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), @@ -146,7 +146,7 @@ error: layout_of(B) = Layout { LL | enum B { Banana = 255, } | ^^^^^^ -error: layout_of(C) = Layout { +error: layout_of(Adt(C, [])) = Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(2 bytes), @@ -220,7 +220,7 @@ error: layout_of(C) = Layout { LL | enum C { Chaenomeles = 256, } | ^^^^^^ -error: layout_of(P) = Layout { +error: layout_of(Adt(P, [])) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), @@ -294,7 +294,7 @@ error: layout_of(P) = Layout { LL | enum P { Peach = 0x1000_0000isize, } | ^^^^^^ -error: layout_of(T) = Layout { +error: layout_of(Adt(T, [])) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index df9f1cc8d1057..60d80590c18eb 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -1,4 +1,4 @@ -error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { +error: layout_of(Adt(std::result::Result, [[u32; Const { ty: usize, kind: Leaf(0x0000000000000000) }], bool])) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), @@ -103,7 +103,7 @@ error: layout_of(std::result::Result<[u32; 0], bool>) = Layout { LL | type AlignedResult = Result<[u32; 0], bool>; | ^^^^^^^^^^^^^^^^^^ -error: layout_of(MultipleAlignments) = Layout { +error: layout_of(Adt(MultipleAlignments, [])) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), @@ -232,7 +232,7 @@ error: layout_of(MultipleAlignments) = Layout { LL | enum MultipleAlignments { | ^^^^^^^^^^^^^^^^^^^^^^^ -error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { +error: layout_of(Adt(std::result::Result, [[u32; Const { ty: usize, kind: Leaf(0x0000000000000000) }], Adt(Packed, [Adt(std::num::NonZeroU16, [])])])) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), @@ -337,7 +337,7 @@ error: layout_of(std::result::Result<[u32; 0], Packed>) = LL | type NicheLosesToTagged = Result<[u32; 0], Packed>; | ^^^^^^^^^^^^^^^^^^^^^^^ -error: layout_of(std::result::Result<[u32; 0], Packed>) = Layout { +error: layout_of(Adt(std::result::Result, [[u32; Const { ty: usize, kind: Leaf(0x0000000000000000) }], Adt(Packed, [Adt(U16IsZero, [])])])) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), diff --git a/tests/ui/thir-print/thir-flat-const-variant.stdout b/tests/ui/thir-print/thir-flat-const-variant.stdout index 7bddc92599613..af7f2b6715266 100644 --- a/tests/ui/thir-print/thir-flat-const-variant.stdout +++ b/tests/ui/thir-print/thir-flat-const-variant.stdout @@ -1,7 +1,11 @@ DefId(0:8 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR1): Thir { body_type: Const( - Foo, + Adt( + Foo, + [ + ], + ), ), arms: [], blocks: [], @@ -46,7 +50,11 @@ Thir { base: None, }, ), - ty: Foo, + ty: Adt( + Foo, + [ + ], + ), temp_lifetime: Some( Node(3), ), @@ -60,7 +68,11 @@ Thir { ), value: e2, }, - ty: Foo, + ty: Adt( + Foo, + [ + ], + ), temp_lifetime: Some( Node(3), ), @@ -72,7 +84,11 @@ Thir { lint_level: Inherited, value: e3, }, - ty: Foo, + ty: Adt( + Foo, + [ + ], + ), temp_lifetime: Some( Node(3), ), @@ -86,7 +102,11 @@ Thir { DefId(0:9 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR2): Thir { body_type: Const( - Foo, + Adt( + Foo, + [ + ], + ), ), arms: [], blocks: [], @@ -131,7 +151,11 @@ Thir { base: None, }, ), - ty: Foo, + ty: Adt( + Foo, + [ + ], + ), temp_lifetime: Some( Node(3), ), @@ -145,7 +169,11 @@ Thir { ), value: e2, }, - ty: Foo, + ty: Adt( + Foo, + [ + ], + ), temp_lifetime: Some( Node(3), ), @@ -157,7 +185,11 @@ Thir { lint_level: Inherited, value: e3, }, - ty: Foo, + ty: Adt( + Foo, + [ + ], + ), temp_lifetime: Some( Node(3), ), @@ -171,7 +203,11 @@ Thir { DefId(0:10 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR3): Thir { body_type: Const( - Foo, + Adt( + Foo, + [ + ], + ), ), arms: [], blocks: [], @@ -216,7 +252,11 @@ Thir { base: None, }, ), - ty: Foo, + ty: Adt( + Foo, + [ + ], + ), temp_lifetime: Some( Node(3), ), @@ -230,7 +270,11 @@ Thir { ), value: e2, }, - ty: Foo, + ty: Adt( + Foo, + [ + ], + ), temp_lifetime: Some( Node(3), ), @@ -242,7 +286,11 @@ Thir { lint_level: Inherited, value: e3, }, - ty: Foo, + ty: Adt( + Foo, + [ + ], + ), temp_lifetime: Some( Node(3), ), @@ -256,7 +304,11 @@ Thir { DefId(0:11 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR4): Thir { body_type: Const( - Foo, + Adt( + Foo, + [ + ], + ), ), arms: [], blocks: [], @@ -301,7 +353,11 @@ Thir { base: None, }, ), - ty: Foo, + ty: Adt( + Foo, + [ + ], + ), temp_lifetime: Some( Node(3), ), @@ -315,7 +371,11 @@ Thir { ), value: e2, }, - ty: Foo, + ty: Adt( + Foo, + [ + ], + ), temp_lifetime: Some( Node(3), ), @@ -327,7 +387,11 @@ Thir { lint_level: Inherited, value: e3, }, - ty: Foo, + ty: Adt( + Foo, + [ + ], + ), temp_lifetime: Some( Node(3), ), diff --git a/tests/ui/thir-print/thir-tree-match.stdout b/tests/ui/thir-print/thir-tree-match.stdout index 3fc130f01765a..0e21b98307b20 100644 --- a/tests/ui/thir-print/thir-tree-match.stdout +++ b/tests/ui/thir-print/thir-tree-match.stdout @@ -1,13 +1,13 @@ DefId(0:16 ~ thir_tree_match[fcf8]::has_match): params: [ Param { - ty: Foo + ty: Adt(Foo, []) ty_span: Some($DIR/thir-tree-match.rs:15:19: 15:22 (#0)) self_kind: None hir_id: Some(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).1)) param: Some( Pat: { - ty: Foo + ty: Adt(Foo, []) span: $DIR/thir-tree-match.rs:15:14: 15:17 (#0) kind: PatKind { Binding { @@ -15,7 +15,7 @@ params: [ name: "foo" mode: ByValue var: LocalVarId(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).2)) - ty: Foo + ty: Adt(Foo, []) is_primary: true subpattern: None } @@ -73,7 +73,7 @@ body: Match { scrutinee: Expr { - ty: Foo + ty: Adt(Foo, []) temp_lifetime: Some(Node(26)) span: $DIR/thir-tree-match.rs:16:11: 16:14 (#0) kind: @@ -82,7 +82,7 @@ body: lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).4)) value: Expr { - ty: Foo + ty: Adt(Foo, []) temp_lifetime: Some(Node(26)) span: $DIR/thir-tree-match.rs:16:11: 16:14 (#0) kind: @@ -96,7 +96,7 @@ body: Arm { pattern: Pat: { - ty: Foo + ty: Adt(Foo, []) span: $DIR/thir-tree-match.rs:17:9: 17:32 (#0) kind: PatKind { Variant { @@ -110,7 +110,7 @@ body: variant_index: 0 subpatterns: [ Pat: { - ty: Bar + ty: Adt(Bar, []) span: $DIR/thir-tree-match.rs:17:21: 17:31 (#0) kind: PatKind { Variant { @@ -169,7 +169,7 @@ body: Arm { pattern: Pat: { - ty: Foo + ty: Adt(Foo, []) span: $DIR/thir-tree-match.rs:18:9: 18:23 (#0) kind: PatKind { Variant { @@ -183,7 +183,7 @@ body: variant_index: 0 subpatterns: [ Pat: { - ty: Bar + ty: Adt(Bar, []) span: $DIR/thir-tree-match.rs:18:21: 18:22 (#0) kind: PatKind { Wild @@ -232,7 +232,7 @@ body: Arm { pattern: Pat: { - ty: Foo + ty: Adt(Foo, []) span: $DIR/thir-tree-match.rs:19:9: 19:20 (#0) kind: PatKind { Variant {