File tree 1 file changed +15
-3
lines changed
compiler/rustc_ast_pretty/src
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -241,11 +241,22 @@ struct BufEntry {
241
241
// opens/closes. (It is still possible to mess up, e.g. by opening a box and
242
242
// then closing it on one path while not closing it on another.)
243
243
#[ must_use]
244
- pub struct BoxMarker ;
244
+ pub struct BoxMarker {
245
+ ended : bool ,
246
+ }
245
247
246
248
impl !Clone for BoxMarker { }
247
249
impl !Copy for BoxMarker { }
248
250
251
+ impl Drop for BoxMarker {
252
+ fn drop ( & mut self ) {
253
+ if !self . ended {
254
+ // njn: make this debug assertion?
255
+ panic ! ( "BoxMarker not ended" ) ;
256
+ }
257
+ }
258
+ }
259
+
249
260
impl Printer {
250
261
pub fn new ( ) -> Self {
251
262
Printer {
@@ -291,17 +302,18 @@ impl Printer {
291
302
}
292
303
let right = self . buf . push ( BufEntry { token : Token :: Begin ( token) , size : -self . right_total } ) ;
293
304
self . scan_stack . push_back ( right) ;
294
- BoxMarker
305
+ BoxMarker { ended : false }
295
306
}
296
307
297
308
// This is is where `BoxMarker`s are consumed.
298
- fn scan_end ( & mut self , _b : BoxMarker ) {
309
+ fn scan_end ( & mut self , mut b : BoxMarker ) {
299
310
if self . scan_stack . is_empty ( ) {
300
311
self . print_end ( ) ;
301
312
} else {
302
313
let right = self . buf . push ( BufEntry { token : Token :: End , size : -1 } ) ;
303
314
self . scan_stack . push_back ( right) ;
304
315
}
316
+ b. ended = true ;
305
317
}
306
318
307
319
fn scan_break ( & mut self , token : BreakToken ) {
You can’t perform that action at this time.
0 commit comments