Skip to content

Commit 586a25a

Browse files
committed
make Ty: Debug be useful for debugging
1 parent e972bc8 commit 586a25a

File tree

60 files changed

+1069
-311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1069
-311
lines changed

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,9 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
772772
// MyNewtype and then the scalar in there).
773773
match op.layout.abi {
774774
Abi::Uninhabited => {
775-
throw_validation_failure!(self.path,
776-
{ "a value of uninhabited type {:?}", op.layout.ty }
777-
);
775+
ty::print::with_no_trimmed_paths!(throw_validation_failure!(self.path,
776+
{ "a value of uninhabited type {}", op.layout.ty }
777+
));
778778
}
779779
Abi::Scalar(scalar_layout) => {
780780
if !scalar_layout.is_uninit_valid() {

compiler/rustc_middle/src/ty/structural_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'tcx> fmt::Debug for ty::TraitRef<'tcx> {
108108

109109
impl<'tcx> fmt::Debug for Ty<'tcx> {
110110
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
111-
with_no_trimmed_paths!(fmt::Display::fmt(self, f))
111+
with_no_trimmed_paths!(fmt::Debug::fmt(self.kind(), f))
112112
}
113113
}
114114

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
16521652
);
16531653
} else {
16541654
err.note(&format!(
1655-
"`{}` is implemented for `{:?}`, but not for `{:?}`",
1655+
"`{}` is implemented for `{}`, but not for `{}`",
16561656
trait_pred.print_modifiers_and_trait_path(),
16571657
suggested_ty,
16581658
trait_pred.skip_binder().self_ty(),

tests/ui/async-await/async-is-unwindsafe.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LL | | });
1515
| within this `[async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6]`
1616
|
1717
= help: within `[async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6]`, the trait `UnwindSafe` is not implemented for `&mut Context<'_>`
18-
= note: `UnwindSafe` is implemented for `&std::task::Context<'_>`, but not for `&mut std::task::Context<'_>`
18+
= note: `UnwindSafe` is implemented for `&Context<'_>`, but not for `&mut Context<'_>`
1919
note: future does not implement `UnwindSafe` as this value is used across an await
2020
--> $DIR/async-is-unwindsafe.rs:25:17
2121
|

tests/ui/chalkify/bugs/async.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ LL | async fn foo(x: u32) -> u32 {
3737
= help: the trait `Future` is not implemented for `[async fn body@$DIR/async.rs:23:29: 25:2]`
3838
= note: [async fn body@$DIR/async.rs:23:29: 25:2] must be a future or must implement `IntoFuture` to be awaited
3939

40-
error: internal compiler error: projection clauses should be implied from elsewhere. obligation: `Obligation(predicate=Binder(ProjectionPredicate(AliasTy { substs: [[async fn body@$DIR/async.rs:23:29: 25:2]], def_id: ...) }, Term::Ty(u32)), []), depth=0)`
40+
error: internal compiler error: projection clauses should be implied from elsewhere. obligation: `Obligation(predicate=Binder(ProjectionPredicate(AliasTy { substs: [Generator(...), [Adt(std::future::ResumeTy, []), Tuple([]), Uint(U32), Infer(_#7t), Infer(_#8t)], Static)], def_id: ...) }, Term::Ty(Uint(U32))), []), depth=0)`
4141
--> $DIR/async.rs:23:25
4242
|
4343
LL | async fn foo(x: u32) -> u32 {

tests/ui/closures/binder/nested-closures-regions.stderr

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,22 @@ LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; };
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: defining type: main::{closure#0}::{closure#0} with closure substs [
8-
i8,
9-
extern "rust-call" fn((&(),)),
10-
(),
8+
Int(
9+
I8,
10+
),
11+
FnPtr(
12+
Binder(
13+
([Tuple([Ref('_#1r, Tuple([]), Not)])]; c_variadic: false)->Tuple([]),
14+
[
15+
Region(
16+
BrNamed(DefId(0:7 ~ nested_closures_regions[ac46]::main::{closure#0}::{closure#0}::'c), 'c),
17+
),
18+
],
19+
),
20+
),
21+
Tuple(
22+
[],
23+
),
1124
]
1225
= note: late-bound region is '_#4r
1326
= note: late-bound region is '_#2r
@@ -22,9 +35,22 @@ LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; };
2235
| ^^^^^^^^^^^^^^^^
2336
|
2437
= note: defining type: main::{closure#0} with closure substs [
25-
i8,
26-
extern "rust-call" fn(()),
27-
(),
38+
Int(
39+
I8,
40+
),
41+
FnPtr(
42+
Binder(
43+
([Tuple([])]; c_variadic: false)->Tuple([]),
44+
[
45+
Region(
46+
BrNamed(DefId(0:5 ~ nested_closures_regions[ac46]::main::{closure#0}::'a), 'a),
47+
),
48+
],
49+
),
50+
),
51+
Tuple(
52+
[],
53+
),
2854
]
2955
= note: late-bound region is '_#2r
3056

tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | let c1 : () = c;
99
| expected due to this
1010
|
1111
= note: expected unit type `()`
12-
found closure `[mod1::f<T>::{closure#0} closure_substs=(unavailable) substs=[T, _#16t, extern "rust-call" fn(()), _#15t]]`
12+
found closure `[mod1::f<T>::{closure#0} closure_substs=(unavailable) substs=[Param(T/#0), Infer(_#16t), FnPtr(Binder(([Tuple([])]; c_variadic: false)->Tuple([]), [])), Infer(_#15t)]]`
1313
help: use parentheses to call this closure
1414
|
1515
LL | let c1 : () = c();

tests/ui/closures/print/closure-print-generic-verbose-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | let c1 : () = c;
99
| expected due to this
1010
|
1111
= note: expected unit type `()`
12-
found closure `[f<T>::{closure#0} closure_substs=(unavailable) substs=[T, _#16t, extern "rust-call" fn(()), _#15t]]`
12+
found closure `[f<T>::{closure#0} closure_substs=(unavailable) substs=[Param(T/#0), Infer(_#16t), FnPtr(Binder(([Tuple([])]; c_variadic: false)->Tuple([]), [])), Infer(_#15t)]]`
1313
help: use parentheses to call this closure
1414
|
1515
LL | let c1 : () = c();

tests/ui/closures/print/closure-print-verbose.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | let foo: fn(u8) -> u8 = |v: u8| { a += v; a };
77
| expected due to this
88
|
99
= note: expected fn pointer `fn(u8) -> u8`
10-
found closure `[main::{closure#0} closure_substs=(unavailable) substs=[i8, extern "rust-call" fn((u8,)) -> u8, _#6t]]`
10+
found closure `[main::{closure#0} closure_substs=(unavailable) substs=[Int(I8), FnPtr(Binder(([Tuple([Uint(U8)])]; c_variadic: false)->Uint(U8), [])), Infer(_#6t)]]`
1111
note: closures can only be coerced to `fn` types if they do not capture any variables
1212
--> $DIR/closure-print-verbose.rs:10:39
1313
|
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
error: generator cannot be sent between threads safely
2+
--> $DIR/generator-print-verbose-1.rs:37:18
3+
|
4+
LL | require_send(send_gen);
5+
| ^^^^^^^^ generator is not `Send`
6+
|
7+
= help: the trait `Sync` is not implemented for `RefCell<i32>`
8+
note: generator is not `Send` as this value is used across a yield
9+
--> $DIR/generator-print-verbose-1.rs:35:9
10+
|
11+
LL | let _non_send_gen = make_non_send_generator();
12+
| ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[749a]::make_non_send_generator::{opaque#0}), [])` which is not `Send`
13+
LL | yield;
14+
| ^^^^^ yield occurs here, with `_non_send_gen` maybe used later
15+
LL | };
16+
| - `_non_send_gen` is later dropped here
17+
note: required by a bound in `require_send`
18+
--> $DIR/generator-print-verbose-1.rs:26:25
19+
|
20+
LL | fn require_send(_: impl Send) {}
21+
| ^^^^ required by this bound in `require_send`
22+
23+
error[E0277]: `RefCell<i32>` cannot be shared between threads safely
24+
--> $DIR/generator-print-verbose-1.rs:56:18
25+
|
26+
LL | require_send(send_gen);
27+
| ------------ ^^^^^^^^ `RefCell<i32>` cannot be shared between threads safely
28+
| |
29+
| required by a bound introduced by this call
30+
|
31+
= help: the trait `Sync` is not implemented for `RefCell<i32>`
32+
= note: required for `Arc<RefCell<i32>>` to implement `Send`
33+
note: required because it's used within this generator
34+
--> $DIR/generator-print-verbose-1.rs:42:5
35+
|
36+
LL | || {
37+
| ^^
38+
note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [Adt(Arc, [Adt(RefCell, [Int(I32)])])])`
39+
--> $DIR/generator-print-verbose-1.rs:41:30
40+
|
41+
LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> {
42+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
43+
note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`
44+
--> $DIR/generator-print-verbose-1.rs:47:34
45+
|
46+
LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> {
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48+
= note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`, `()`
49+
note: required because it's used within this generator
50+
--> $DIR/generator-print-verbose-1.rs:52:20
51+
|
52+
LL | let send_gen = || {
53+
| ^^
54+
note: required by a bound in `require_send`
55+
--> $DIR/generator-print-verbose-1.rs:26:25
56+
|
57+
LL | fn require_send(_: impl Send) {}
58+
| ^^^^ required by this bound in `require_send`
59+
60+
error: aborting due to 2 previous errors
61+
62+
For more information about this error, try `rustc --explain E0277`.

tests/ui/impl-trait/normalize-tait-in-const.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:198:90: Failed to normalize <for<'a, 'b> fn(&'a Alias<'b>) {foo} as std::ops::FnOnce<(&&S,)>>::Output, maybe try to call `try_normalize_erasing_regions` instead
1+
error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:198:90: Failed to normalize Alias(Projection, AliasTy { substs: [FnDef(DefId(0:18 ~ normalize_tait_in_const[1c07]::foo), []), Tuple([Ref(ReErased, Ref(ReErased, Adt(S, []), Not), Not)])], def_id: DefId(2:2940 ~ core[a28e]::ops::function::FnOnce::Output) }), maybe try to call `try_normalize_erasing_regions` instead
22

33
query stack during panic:
44
#0 [eval_to_allocation_raw] const-evaluating + checking `BAR`

tests/ui/layout/debug.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: layout_of(E) = Layout {
1+
error: layout_of(Adt(E, [])) = Layout {
22
size: Size(12 bytes),
33
align: AbiAndPrefAlign {
44
abi: Align(4 bytes),
@@ -86,7 +86,7 @@ error: layout_of(E) = Layout {
8686
LL | enum E { Foo, Bar(!, i32, i32) }
8787
| ^^^^^^
8888

89-
error: layout_of(S) = Layout {
89+
error: layout_of(Adt(S, [])) = Layout {
9090
size: Size(8 bytes),
9191
align: AbiAndPrefAlign {
9292
abi: Align(4 bytes),
@@ -130,7 +130,7 @@ error: layout_of(S) = Layout {
130130
LL | struct S { f1: i32, f2: (), f3: i32 }
131131
| ^^^^^^^^
132132

133-
error: layout_of(U) = Layout {
133+
error: layout_of(Adt(U, [])) = Layout {
134134
size: Size(8 bytes),
135135
align: AbiAndPrefAlign {
136136
abi: Align(4 bytes),
@@ -152,7 +152,7 @@ error: layout_of(U) = Layout {
152152
LL | union U { f1: (i32, i32), f3: i32 }
153153
| ^^^^^^^
154154

155-
error: layout_of(std::result::Result<i32, i32>) = Layout {
155+
error: layout_of(Adt(std::result::Result, [Int(I32), Int(I32)])) = Layout {
156156
size: Size(8 bytes),
157157
align: AbiAndPrefAlign {
158158
abi: Align(4 bytes),
@@ -281,7 +281,7 @@ error: layout_of(std::result::Result<i32, i32>) = Layout {
281281
LL | type Test = Result<i32, i32>;
282282
| ^^^^^^^^^
283283

284-
error: layout_of(i32) = Layout {
284+
error: layout_of(Int(I32)) = Layout {
285285
size: Size(4 bytes),
286286
align: AbiAndPrefAlign {
287287
abi: Align(4 bytes),

tests/ui/layout/hexagon-enum.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: layout_of(A) = Layout {
1+
error: layout_of(Adt(A, [])) = Layout {
22
size: Size(1 bytes),
33
align: AbiAndPrefAlign {
44
abi: Align(1 bytes),
@@ -68,7 +68,7 @@ error: layout_of(A) = Layout {
6868
LL | enum A { Apple }
6969
| ^^^^^^
7070

71-
error: layout_of(B) = Layout {
71+
error: layout_of(Adt(B, [])) = Layout {
7272
size: Size(1 bytes),
7373
align: AbiAndPrefAlign {
7474
abi: Align(1 bytes),
@@ -138,7 +138,7 @@ error: layout_of(B) = Layout {
138138
LL | enum B { Banana = 255, }
139139
| ^^^^^^
140140

141-
error: layout_of(C) = Layout {
141+
error: layout_of(Adt(C, [])) = Layout {
142142
size: Size(2 bytes),
143143
align: AbiAndPrefAlign {
144144
abi: Align(2 bytes),
@@ -208,7 +208,7 @@ error: layout_of(C) = Layout {
208208
LL | enum C { Chaenomeles = 256, }
209209
| ^^^^^^
210210

211-
error: layout_of(P) = Layout {
211+
error: layout_of(Adt(P, [])) = Layout {
212212
size: Size(4 bytes),
213213
align: AbiAndPrefAlign {
214214
abi: Align(4 bytes),
@@ -278,7 +278,7 @@ error: layout_of(P) = Layout {
278278
LL | enum P { Peach = 0x1000_0000isize, }
279279
| ^^^^^^
280280

281-
error: layout_of(T) = Layout {
281+
error: layout_of(Adt(T, [])) = Layout {
282282
size: Size(4 bytes),
283283
align: AbiAndPrefAlign {
284284
abi: Align(4 bytes),

tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: layout_of(MissingPayloadField) = Layout {
1+
error: layout_of(Adt(MissingPayloadField, [])) = Layout {
22
size: Size(2 bytes),
33
align: AbiAndPrefAlign {
44
abi: Align(1 bytes),
@@ -108,7 +108,7 @@ error: layout_of(MissingPayloadField) = Layout {
108108
LL | pub enum MissingPayloadField {
109109
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
110110

111-
error: layout_of(CommonPayloadField) = Layout {
111+
error: layout_of(Adt(CommonPayloadField, [])) = Layout {
112112
size: Size(2 bytes),
113113
align: AbiAndPrefAlign {
114114
abi: Align(1 bytes),
@@ -237,7 +237,7 @@ error: layout_of(CommonPayloadField) = Layout {
237237
LL | pub enum CommonPayloadField {
238238
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
239239

240-
error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout {
240+
error: layout_of(Adt(CommonPayloadFieldIsMaybeUninit, [])) = Layout {
241241
size: Size(2 bytes),
242242
align: AbiAndPrefAlign {
243243
abi: Align(1 bytes),
@@ -363,7 +363,7 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout {
363363
LL | pub enum CommonPayloadFieldIsMaybeUninit {
364364
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
365365

366-
error: layout_of(NicheFirst) = Layout {
366+
error: layout_of(Adt(NicheFirst, [])) = Layout {
367367
size: Size(2 bytes),
368368
align: AbiAndPrefAlign {
369369
abi: Align(1 bytes),
@@ -507,7 +507,7 @@ error: layout_of(NicheFirst) = Layout {
507507
LL | pub enum NicheFirst {
508508
| ^^^^^^^^^^^^^^^^^^^
509509

510-
error: layout_of(NicheSecond) = Layout {
510+
error: layout_of(Adt(NicheSecond, [])) = Layout {
511511
size: Size(2 bytes),
512512
align: AbiAndPrefAlign {
513513
abi: Align(1 bytes),

tests/ui/layout/issue-96185-overaligned-enum.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: layout_of(Aligned1) = Layout {
1+
error: layout_of(Adt(Aligned1, [])) = Layout {
22
size: Size(8 bytes),
33
align: AbiAndPrefAlign {
44
abi: Align(8 bytes),
@@ -80,7 +80,7 @@ error: layout_of(Aligned1) = Layout {
8080
LL | pub enum Aligned1 {
8181
| ^^^^^^^^^^^^^^^^^
8282

83-
error: layout_of(Aligned2) = Layout {
83+
error: layout_of(Adt(Aligned2, [])) = Layout {
8484
size: Size(1 bytes),
8585
align: AbiAndPrefAlign {
8686
abi: Align(1 bytes),

tests/ui/layout/thumb-enum.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: layout_of(A) = Layout {
1+
error: layout_of(Adt(A, [])) = Layout {
22
size: Size(1 bytes),
33
align: AbiAndPrefAlign {
44
abi: Align(1 bytes),
@@ -68,7 +68,7 @@ error: layout_of(A) = Layout {
6868
LL | enum A { Apple }
6969
| ^^^^^^
7070

71-
error: layout_of(B) = Layout {
71+
error: layout_of(Adt(B, [])) = Layout {
7272
size: Size(1 bytes),
7373
align: AbiAndPrefAlign {
7474
abi: Align(1 bytes),
@@ -138,7 +138,7 @@ error: layout_of(B) = Layout {
138138
LL | enum B { Banana = 255, }
139139
| ^^^^^^
140140

141-
error: layout_of(C) = Layout {
141+
error: layout_of(Adt(C, [])) = Layout {
142142
size: Size(2 bytes),
143143
align: AbiAndPrefAlign {
144144
abi: Align(2 bytes),
@@ -208,7 +208,7 @@ error: layout_of(C) = Layout {
208208
LL | enum C { Chaenomeles = 256, }
209209
| ^^^^^^
210210

211-
error: layout_of(P) = Layout {
211+
error: layout_of(Adt(P, [])) = Layout {
212212
size: Size(4 bytes),
213213
align: AbiAndPrefAlign {
214214
abi: Align(4 bytes),
@@ -278,7 +278,7 @@ error: layout_of(P) = Layout {
278278
LL | enum P { Peach = 0x1000_0000isize, }
279279
| ^^^^^^
280280

281-
error: layout_of(T) = Layout {
281+
error: layout_of(Adt(T, [])) = Layout {
282282
size: Size(4 bytes),
283283
align: AbiAndPrefAlign {
284284
abi: Align(4 bytes),

0 commit comments

Comments
 (0)