Skip to content

Commit 6247a52

Browse files
committed
Handle prefix notations for strings in patterns. This is kind of gross.
1 parent eaf8b76 commit 6247a52

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,14 +1696,33 @@ class parser {
16961696
token::AT {
16971697
self.bump();
16981698
let sub = self.parse_pat();
1699-
pat = pat_box(sub);
17001699
hi = sub.span.hi;
1700+
// HACK: parse @"..." as a literal of a vstore @str
1701+
pat = alt sub.node {
1702+
pat_lit(e@@{node: expr_lit(@{node: lit_str(_), span: _}), _}) {
1703+
let vst = @{id: self.get_id(), callee_id: self.get_id(),
1704+
node: expr_vstore(e, vstore_box),
1705+
span: mk_sp(lo, hi)};
1706+
pat_lit(vst)
1707+
}
1708+
_ { pat_box(sub) }
1709+
};
17011710
}
17021711
token::TILDE {
17031712
self.bump();
17041713
let sub = self.parse_pat();
1705-
pat = pat_uniq(sub);
17061714
hi = sub.span.hi;
1715+
// HACK: parse ~"..." as a literal of a vstore ~str
1716+
pat = alt sub.node {
1717+
pat_lit(e@@{node: expr_lit(@{node: lit_str(_), span: _}), _}) {
1718+
let vst = @{id: self.get_id(), callee_id: self.get_id(),
1719+
node: expr_vstore(e, vstore_uniq),
1720+
span: mk_sp(lo, hi)};
1721+
pat_lit(vst)
1722+
}
1723+
_ { pat_uniq(sub) }
1724+
};
1725+
17071726
}
17081727
token::LBRACE {
17091728
self.bump();

0 commit comments

Comments
 (0)