@@ -114,22 +114,7 @@ pub trait Provenance: Copy + fmt::Debug + 'static {
114
114
const OFFSET_IS_ADDR : bool ;
115
115
116
116
/// Determines how a pointer should be printed.
117
- ///
118
- /// Default impl is only good for when `OFFSET_IS_ADDR == true`.
119
- fn fmt ( ptr : & Pointer < Self > , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result
120
- where
121
- Self : Sized ,
122
- {
123
- assert ! ( Self :: OFFSET_IS_ADDR ) ;
124
- let ( prov, addr) = ptr. into_parts ( ) ; // address is absolute
125
- write ! ( f, "{:#x}" , addr. bytes( ) ) ?;
126
- if f. alternate ( ) {
127
- write ! ( f, "{prov:#?}" ) ?;
128
- } else {
129
- write ! ( f, "{prov:?}" ) ?;
130
- }
131
- Ok ( ( ) )
132
- }
117
+ fn fmt ( ptr : & Pointer < Self > , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result ;
133
118
134
119
/// If `OFFSET_IS_ADDR == false`, provenance must always be able to
135
120
/// identify the allocation this ptr points to (i.e., this must return `Some`).
@@ -156,8 +141,11 @@ impl From<AllocId> for CtfeProvenance {
156
141
157
142
impl fmt:: Debug for CtfeProvenance {
158
143
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
159
- // FIXME print "immutable" bit
160
- self . alloc_id ( ) . fmt ( f)
144
+ fmt:: Debug :: fmt ( & self . alloc_id ( ) , f) ?; // propagates `alternate` flag
145
+ if self . immutable ( ) {
146
+ write ! ( f, "<imm>" ) ?;
147
+ }
148
+ Ok ( ( ) )
161
149
}
162
150
}
163
151
@@ -189,17 +177,16 @@ impl Provenance for CtfeProvenance {
189
177
const OFFSET_IS_ADDR : bool = false ;
190
178
191
179
fn fmt ( ptr : & Pointer < Self > , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
192
- // FIXME print "immutable" bit
193
- // Forward `alternate` flag to `alloc_id` printing.
194
- if f. alternate ( ) {
195
- write ! ( f, "{:#?}" , ptr. provenance. alloc_id( ) ) ?;
196
- } else {
197
- write ! ( f, "{:?}" , ptr. provenance. alloc_id( ) ) ?;
198
- }
180
+ // Print AllocId.
181
+ fmt:: Debug :: fmt ( & ptr. provenance . alloc_id ( ) , f) ?; // propagates `alternate` flag
199
182
// Print offset only if it is non-zero.
200
183
if ptr. offset . bytes ( ) > 0 {
201
184
write ! ( f, "+{:#x}" , ptr. offset. bytes( ) ) ?;
202
185
}
186
+ // Print immutable status.
187
+ if ptr. provenance . immutable ( ) {
188
+ write ! ( f, "<imm>" ) ?;
189
+ }
203
190
Ok ( ( ) )
204
191
}
205
192
0 commit comments