Skip to content

Commit e1c95e2

Browse files
committed
Fix tree format parsing for bare }
1 parent 6868215 commit e1c95e2

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/cargo/ops/tree/format/parse.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'a> Parser<'a> {
7979
fn text(&mut self, start: usize) -> RawChunk<'a> {
8080
while let Some(&(pos, ch)) = self.it.peek() {
8181
match ch {
82-
'{' | '}' | ')' => return RawChunk::Text(&self.s[start..pos]),
82+
'{' | '}' => return RawChunk::Text(&self.s[start..pos]),
8383
_ => {
8484
self.it.next();
8585
}
@@ -110,7 +110,11 @@ impl<'a> Iterator for Parser<'a> {
110110
}
111111
Some(&(_, '}')) => {
112112
self.it.next();
113-
Some(RawChunk::Error("unexpected '}'"))
113+
if self.consume('}') {
114+
Some(RawChunk::Text("}"))
115+
} else {
116+
Some(RawChunk::Error("unexpected '}'"))
117+
}
114118
}
115119
Some(&(i, _)) => Some(self.text(i)),
116120
None => None,

tests/testsuite/tree.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,10 @@ Caused by:
903903
.with_status(101)
904904
.run();
905905

906+
p.cargo("tree --format {p}-{{hello}}")
907+
.with_stdout("foo v0.1.0 ([..]/foo)-{hello}")
908+
.run();
909+
906910
p.cargo("tree --format")
907911
.arg("{p} {l} {r}")
908912
.with_stdout("foo v0.1.0 ([..]/foo) MIT https://github.com/rust-lang/cargo")

0 commit comments

Comments
 (0)