Skip to content

Commit 5b8ca52

Browse files
committed
XXX: drop checking
1 parent 443c96f commit 5b8ca52

File tree

1 file changed

+15
-3
lines changed
  • compiler/rustc_ast_pretty/src

1 file changed

+15
-3
lines changed

compiler/rustc_ast_pretty/src/pp.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,22 @@ struct BufEntry {
241241
// opens/closes. (It is still possible to mess up, e.g. by opening a box and
242242
// then closing it on one path while not closing it on another.)
243243
#[must_use]
244-
pub struct BoxMarker;
244+
pub struct BoxMarker {
245+
ended: bool,
246+
}
245247

246248
impl !Clone for BoxMarker {}
247249
impl !Copy for BoxMarker {}
248250

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+
249260
impl Printer {
250261
pub fn new() -> Self {
251262
Printer {
@@ -291,17 +302,18 @@ impl Printer {
291302
}
292303
let right = self.buf.push(BufEntry { token: Token::Begin(token), size: -self.right_total });
293304
self.scan_stack.push_back(right);
294-
BoxMarker
305+
BoxMarker { ended: false }
295306
}
296307

297308
// 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) {
299310
if self.scan_stack.is_empty() {
300311
self.print_end();
301312
} else {
302313
let right = self.buf.push(BufEntry { token: Token::End, size: -1 });
303314
self.scan_stack.push_back(right);
304315
}
316+
b.ended = true;
305317
}
306318

307319
fn scan_break(&mut self, token: BreakToken) {

0 commit comments

Comments
 (0)