mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-15 18:15:01 +00:00
64ea8eb1a9
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 `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 attribute) 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.
578 lines
16 KiB
Plaintext
578 lines
16 KiB
Plaintext
error: layout_of(E) = Layout {
|
|
size: Size(12 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(4 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Aggregate {
|
|
sized: true,
|
|
},
|
|
fields: Arbitrary {
|
|
offsets: [
|
|
Size(0 bytes),
|
|
],
|
|
memory_index: [
|
|
0,
|
|
],
|
|
},
|
|
largest_niche: Some(
|
|
Niche {
|
|
offset: Size(0 bytes),
|
|
value: Int(
|
|
I32,
|
|
false,
|
|
),
|
|
valid_range: 0..=0,
|
|
},
|
|
),
|
|
variants: Multiple {
|
|
tag: Initialized {
|
|
value: Int(
|
|
I32,
|
|
false,
|
|
),
|
|
valid_range: 0..=0,
|
|
},
|
|
tag_encoding: Direct,
|
|
tag_field: 0,
|
|
variants: [
|
|
Layout {
|
|
size: Size(4 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(1 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Aggregate {
|
|
sized: true,
|
|
},
|
|
fields: Arbitrary {
|
|
offsets: [],
|
|
memory_index: [],
|
|
},
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(1 bytes),
|
|
},
|
|
Layout {
|
|
size: Size(12 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(4 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Uninhabited,
|
|
fields: Arbitrary {
|
|
offsets: [
|
|
Size(4 bytes),
|
|
Size(4 bytes),
|
|
Size(8 bytes),
|
|
],
|
|
memory_index: [
|
|
0,
|
|
1,
|
|
2,
|
|
],
|
|
},
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 1,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(4 bytes),
|
|
},
|
|
],
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(4 bytes),
|
|
}
|
|
--> $DIR/debug.rs:7:1
|
|
|
|
|
LL | enum E { Foo, Bar(!, i32, i32) }
|
|
| ^^^^^^
|
|
|
|
error: layout_of(S) = Layout {
|
|
size: Size(8 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(4 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: ScalarPair(
|
|
Initialized {
|
|
value: Int(
|
|
I32,
|
|
true,
|
|
),
|
|
valid_range: 0..=4294967295,
|
|
},
|
|
Initialized {
|
|
value: Int(
|
|
I32,
|
|
true,
|
|
),
|
|
valid_range: 0..=4294967295,
|
|
},
|
|
),
|
|
fields: Arbitrary {
|
|
offsets: [
|
|
Size(0 bytes),
|
|
Size(8 bytes),
|
|
Size(4 bytes),
|
|
],
|
|
memory_index: [
|
|
0,
|
|
2,
|
|
1,
|
|
],
|
|
},
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(4 bytes),
|
|
}
|
|
--> $DIR/debug.rs:10:1
|
|
|
|
|
LL | struct S { f1: i32, f2: (), f3: i32 }
|
|
| ^^^^^^^^
|
|
|
|
error: layout_of(U) = Layout {
|
|
size: Size(8 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(4 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Aggregate {
|
|
sized: true,
|
|
},
|
|
fields: Union(
|
|
2,
|
|
),
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(4 bytes),
|
|
}
|
|
--> $DIR/debug.rs:13:1
|
|
|
|
|
LL | union U { f1: (i32, i32), f3: i32 }
|
|
| ^^^^^^^
|
|
|
|
error: layout_of(Result<i32, i32>) = Layout {
|
|
size: Size(8 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(4 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: ScalarPair(
|
|
Initialized {
|
|
value: Int(
|
|
I32,
|
|
false,
|
|
),
|
|
valid_range: 0..=1,
|
|
},
|
|
Initialized {
|
|
value: Int(
|
|
I32,
|
|
true,
|
|
),
|
|
valid_range: 0..=4294967295,
|
|
},
|
|
),
|
|
fields: Arbitrary {
|
|
offsets: [
|
|
Size(0 bytes),
|
|
],
|
|
memory_index: [
|
|
0,
|
|
],
|
|
},
|
|
largest_niche: Some(
|
|
Niche {
|
|
offset: Size(0 bytes),
|
|
value: Int(
|
|
I32,
|
|
false,
|
|
),
|
|
valid_range: 0..=1,
|
|
},
|
|
),
|
|
variants: Multiple {
|
|
tag: Initialized {
|
|
value: Int(
|
|
I32,
|
|
false,
|
|
),
|
|
valid_range: 0..=1,
|
|
},
|
|
tag_encoding: Direct,
|
|
tag_field: 0,
|
|
variants: [
|
|
Layout {
|
|
size: Size(8 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(4 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: ScalarPair(
|
|
Initialized {
|
|
value: Int(
|
|
I32,
|
|
false,
|
|
),
|
|
valid_range: 0..=1,
|
|
},
|
|
Initialized {
|
|
value: Int(
|
|
I32,
|
|
true,
|
|
),
|
|
valid_range: 0..=4294967295,
|
|
},
|
|
),
|
|
fields: Arbitrary {
|
|
offsets: [
|
|
Size(4 bytes),
|
|
],
|
|
memory_index: [
|
|
0,
|
|
],
|
|
},
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(4 bytes),
|
|
},
|
|
Layout {
|
|
size: Size(8 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(4 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: ScalarPair(
|
|
Initialized {
|
|
value: Int(
|
|
I32,
|
|
false,
|
|
),
|
|
valid_range: 0..=1,
|
|
},
|
|
Initialized {
|
|
value: Int(
|
|
I32,
|
|
true,
|
|
),
|
|
valid_range: 0..=4294967295,
|
|
},
|
|
),
|
|
fields: Arbitrary {
|
|
offsets: [
|
|
Size(4 bytes),
|
|
],
|
|
memory_index: [
|
|
0,
|
|
],
|
|
},
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 1,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(4 bytes),
|
|
},
|
|
],
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(4 bytes),
|
|
}
|
|
--> $DIR/debug.rs:16:1
|
|
|
|
|
LL | type Test = Result<i32, i32>;
|
|
| ^^^^^^^^^
|
|
|
|
error: layout_of(i32) = Layout {
|
|
size: Size(4 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(4 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Scalar(
|
|
Initialized {
|
|
value: Int(
|
|
I32,
|
|
true,
|
|
),
|
|
valid_range: 0..=4294967295,
|
|
},
|
|
),
|
|
fields: Primitive,
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(4 bytes),
|
|
}
|
|
--> $DIR/debug.rs:19:1
|
|
|
|
|
LL | type T = impl std::fmt::Debug;
|
|
| ^^^^^^
|
|
|
|
error: layout_of(V) = Layout {
|
|
size: Size(2 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(2 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Aggregate {
|
|
sized: true,
|
|
},
|
|
fields: Union(
|
|
2,
|
|
),
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(2 bytes),
|
|
}
|
|
--> $DIR/debug.rs:25:1
|
|
|
|
|
LL | pub union V {
|
|
| ^^^^^^^^^^^
|
|
|
|
error: layout_of(W) = Layout {
|
|
size: Size(2 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(2 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Aggregate {
|
|
sized: true,
|
|
},
|
|
fields: Union(
|
|
2,
|
|
),
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(2 bytes),
|
|
}
|
|
--> $DIR/debug.rs:31:1
|
|
|
|
|
LL | pub union W {
|
|
| ^^^^^^^^^^^
|
|
|
|
error: layout_of(Y) = Layout {
|
|
size: Size(0 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(2 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Aggregate {
|
|
sized: true,
|
|
},
|
|
fields: Union(
|
|
2,
|
|
),
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(2 bytes),
|
|
}
|
|
--> $DIR/debug.rs:37:1
|
|
|
|
|
LL | pub union Y {
|
|
| ^^^^^^^^^^^
|
|
|
|
error: layout_of(P1) = Layout {
|
|
size: Size(4 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(1 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Aggregate {
|
|
sized: true,
|
|
},
|
|
fields: Union(
|
|
1,
|
|
),
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(1 bytes),
|
|
}
|
|
--> $DIR/debug.rs:44:1
|
|
|
|
|
LL | union P1 { x: u32 }
|
|
| ^^^^^^^^
|
|
|
|
error: layout_of(P2) = Layout {
|
|
size: Size(8 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(1 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Aggregate {
|
|
sized: true,
|
|
},
|
|
fields: Union(
|
|
1,
|
|
),
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(1 bytes),
|
|
}
|
|
--> $DIR/debug.rs:48:1
|
|
|
|
|
LL | union P2 { x: (u32, u32) }
|
|
| ^^^^^^^^
|
|
|
|
error: layout_of(P3) = Layout {
|
|
size: Size(16 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(1 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Aggregate {
|
|
sized: true,
|
|
},
|
|
fields: Union(
|
|
1,
|
|
),
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(1 bytes),
|
|
}
|
|
--> $DIR/debug.rs:56:1
|
|
|
|
|
LL | union P3 { x: F32x4 }
|
|
| ^^^^^^^^
|
|
|
|
error: layout_of(P4) = Layout {
|
|
size: Size(12 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(1 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Aggregate {
|
|
sized: true,
|
|
},
|
|
fields: Union(
|
|
1,
|
|
),
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(1 bytes),
|
|
}
|
|
--> $DIR/debug.rs:60:1
|
|
|
|
|
LL | union P4 { x: E }
|
|
| ^^^^^^^^
|
|
|
|
error: layout_of(P5) = Layout {
|
|
size: Size(1 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(1 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Scalar(
|
|
Union {
|
|
value: Int(
|
|
I8,
|
|
false,
|
|
),
|
|
},
|
|
),
|
|
fields: Union(
|
|
2,
|
|
),
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(1 bytes),
|
|
}
|
|
--> $DIR/debug.rs:64:1
|
|
|
|
|
LL | union P5 { zst: [u16; 0], byte: u8 }
|
|
| ^^^^^^^^
|
|
|
|
error: layout_of(MaybeUninit<u8>) = Layout {
|
|
size: Size(1 bytes),
|
|
align: AbiAndPrefAlign {
|
|
abi: Align(1 bytes),
|
|
pref: $SOME_ALIGN,
|
|
},
|
|
abi: Scalar(
|
|
Union {
|
|
value: Int(
|
|
I8,
|
|
false,
|
|
),
|
|
},
|
|
),
|
|
fields: Union(
|
|
2,
|
|
),
|
|
largest_niche: None,
|
|
variants: Single {
|
|
index: 0,
|
|
},
|
|
max_repr_align: None,
|
|
unadjusted_abi_align: Align(1 bytes),
|
|
}
|
|
--> $DIR/debug.rs:67:1
|
|
|
|
|
LL | type X = std::mem::MaybeUninit<u8>;
|
|
| ^^^^^^
|
|
|
|
error: `#[rustc_layout]` can only be applied to `struct`/`enum`/`union` declarations and type aliases
|
|
--> $DIR/debug.rs:70:1
|
|
|
|
|
LL | const C: () = ();
|
|
| ^^^^^^^^^^^
|
|
|
|
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
|
--> $DIR/debug.rs:78:19
|
|
|
|
|
LL | type Impossible = (str, str);
|
|
| ^^^^^^^^^^ doesn't have a size known at compile-time
|
|
|
|
|
= help: the trait `Sized` is not implemented for `str`
|
|
= note: only the last element of a tuple may have a dynamically sized type
|
|
|
|
error: `#[rustc_layout]` can only be applied to `struct`/`enum`/`union` declarations and type aliases
|
|
--> $DIR/debug.rs:74:5
|
|
|
|
|
LL | const C: () = ();
|
|
| ^^^^^^^^^^^
|
|
|
|
error: aborting due to 17 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0277`.
|