@@ -23,37 +23,78 @@ impl<I: Interner> Debug for AssocTypeId<I> {
23
23
24
24
impl < I : Interner > Debug for Ty < I > {
25
25
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
26
- I :: debug_ty ( self , fmt) . unwrap_or_else ( || unimplemented ! ( ) )
26
+ I :: debug_ty ( self , fmt)
27
+ . unwrap_or_else ( || unimplemented ! ( "cannot format Ty without setting Program in tls" ) )
27
28
}
28
29
}
29
30
30
31
impl < I : Interner > Debug for Lifetime < I > {
31
32
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
32
- I :: debug_lifetime ( self , fmt) . unwrap_or_else ( || unimplemented ! ( ) )
33
+ I :: debug_lifetime ( self , fmt) . unwrap_or_else ( || {
34
+ unimplemented ! ( "cannot format Lifetime without setting Program in tls" )
35
+ } )
33
36
}
34
37
}
35
38
36
39
impl < I : Interner > Debug for Parameter < I > {
37
40
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
38
- I :: debug_parameter ( self , fmt) . unwrap_or_else ( || unimplemented ! ( ) )
41
+ I :: debug_parameter ( self , fmt) . unwrap_or_else ( || {
42
+ unimplemented ! ( "cannot format Parameter without setting Program in tls" )
43
+ } )
39
44
}
40
45
}
41
46
42
47
impl < I : Interner > Debug for Goal < I > {
43
48
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
44
- I :: debug_goal ( self , fmt) . unwrap_or_else ( || unimplemented ! ( ) )
49
+ I :: debug_goal ( self , fmt)
50
+ . unwrap_or_else ( || unimplemented ! ( "cannot format Goal without setting Program in tls" ) )
45
51
}
46
52
}
47
53
48
54
impl < I : Interner > Debug for Goals < I > {
49
55
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
50
- I :: debug_goals ( self , fmt) . unwrap_or_else ( || unimplemented ! ( ) )
56
+ I :: debug_goals ( self , fmt)
57
+ . unwrap_or_else ( || unimplemented ! ( "cannot format Goals without setting Program in tls" ) )
51
58
}
52
59
}
53
60
54
61
impl < I : Interner > Debug for ProgramClauseImplication < I > {
55
62
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
56
- I :: debug_program_clause_implication ( self , fmt) . unwrap_or_else ( || unimplemented ! ( ) )
63
+ I :: debug_program_clause_implication ( self , fmt) . unwrap_or_else ( || {
64
+ unimplemented ! ( "cannot format ProgramClauseImplication without setting Program in tls" )
65
+ } )
66
+ }
67
+ }
68
+
69
+ impl < I : Interner > Debug for ApplicationTy < I > {
70
+ fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
71
+ I :: debug_application_ty ( self , fmt) . unwrap_or_else ( || {
72
+ unimplemented ! ( "cannot format ApplicationTy without setting Program in tls" )
73
+ } )
74
+ }
75
+ }
76
+
77
+ impl < I : Interner > Debug for SeparatorTraitRef < ' _ , I > {
78
+ fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
79
+ I :: debug_separator_trait_ref ( self , fmt) . unwrap_or_else ( || {
80
+ unimplemented ! ( "cannot format Substitution without setting Program in tls" )
81
+ } )
82
+ }
83
+ }
84
+
85
+ impl < I : Interner > Debug for AliasTy < I > {
86
+ fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
87
+ I :: debug_alias ( self , fmt) . unwrap_or_else ( || {
88
+ unimplemented ! ( "cannot format AliasTy without setting Program in tls" )
89
+ } )
90
+ }
91
+ }
92
+
93
+ impl < I : Interner > Display for Substitution < I > {
94
+ fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
95
+ I :: debug_substitution ( self , fmt) . unwrap_or_else ( || {
96
+ unimplemented ! ( "cannot format Substitution without setting Program in tls" )
97
+ } )
57
98
}
58
99
}
59
100
@@ -135,13 +176,6 @@ impl Debug for PlaceholderIndex {
135
176
}
136
177
}
137
178
138
- impl < I : Interner > Debug for ApplicationTy < I > {
139
- fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
140
- let ApplicationTy { name, substitution } = self ;
141
- write ! ( fmt, "{:?}{:?}" , name, substitution. with_angle( ) )
142
- }
143
- }
144
-
145
179
impl < I : Interner > TraitRef < I > {
146
180
/// Returns a "Debuggable" type that prints like `P0 as Trait<P1..>`
147
181
pub fn with_as ( & self ) -> impl std:: fmt:: Debug + ' _ {
@@ -166,36 +200,9 @@ impl<I: Interner> Debug for TraitRef<I> {
166
200
}
167
201
}
168
202
169
- struct SeparatorTraitRef < ' me , I : Interner > {
170
- trait_ref : & ' me TraitRef < I > ,
171
- separator : & ' me str ,
172
- }
173
-
174
- impl < I : Interner > Debug for SeparatorTraitRef < ' _ , I > {
175
- fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
176
- let parameters = self . trait_ref . substitution . parameters ( ) ;
177
- write ! (
178
- fmt,
179
- "{:?}{}{:?}{:?}" ,
180
- parameters[ 0 ] ,
181
- self . separator,
182
- self . trait_ref. trait_id,
183
- Angle ( & parameters[ 1 ..] )
184
- )
185
- }
186
- }
187
-
188
- impl < I : Interner > Debug for AliasTy < I > {
189
- fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
190
- I :: debug_alias ( self , fmt) . unwrap_or_else ( || {
191
- write ! (
192
- fmt,
193
- "({:?}){:?}" ,
194
- self . associated_ty_id,
195
- self . substitution. with_angle( )
196
- )
197
- } )
198
- }
203
+ pub struct SeparatorTraitRef < ' me , I : Interner > {
204
+ pub trait_ref : & ' me TraitRef < I > ,
205
+ pub separator : & ' me str ,
199
206
}
200
207
201
208
pub struct Angle < ' a , T > ( pub & ' a [ T ] ) ;
@@ -374,8 +381,8 @@ impl<I: Interner> Display for ConstrainedSubst<I> {
374
381
impl < I : Interner > Substitution < I > {
375
382
/// Displays the substitution in the form `< P0, .. Pn >`, or (if
376
383
/// the substitution is empty) as an empty string.
377
- pub fn with_angle ( & self ) -> Angle < ' _ , Parameter < I > > {
378
- Angle ( self . parameters ( ) )
384
+ pub fn with_angle ( & self , interner : & I ) -> Angle < ' _ , Parameter < I > > {
385
+ Angle ( self . parameters ( interner ) )
379
386
}
380
387
}
381
388
@@ -384,25 +391,3 @@ impl<I: Interner> Debug for Substitution<I> {
384
391
Display :: fmt ( self , fmt)
385
392
}
386
393
}
387
-
388
- impl < I : Interner > Display for Substitution < I > {
389
- fn fmt ( & self , f : & mut Formatter < ' _ > ) -> Result < ( ) , Error > {
390
- let mut first = true ;
391
-
392
- write ! ( f, "[" ) ?;
393
-
394
- for ( index, value) in self . iter ( ) . enumerate ( ) {
395
- if first {
396
- first = false ;
397
- } else {
398
- write ! ( f, ", " ) ?;
399
- }
400
-
401
- write ! ( f, "?{} := {:?}" , index, value) ?;
402
- }
403
-
404
- write ! ( f, "]" ) ?;
405
-
406
- Ok ( ( ) )
407
- }
408
- }
0 commit comments