Skip to content

Commit ad264f7

Browse files
authored
Auto merge of rust-lang#34924 - cgswords:empty_delim, r=nrc
Added empty CloseDelim to tokens for future use. Description says it all. I added a new DelimToken type, Empty, to indicate a Delimited tokenstream with no actual delimiters (which are variously useful for constructing macro output). r? @nrc
2 parents af87681 + 536c315 commit ad264f7

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

src/librustdoc/html/highlight.rs

+1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ impl<'a> Classifier<'a> {
233233
token::Dot | token::DotDot | token::DotDotDot | token::Comma | token::Semi |
234234
token::Colon | token::ModSep | token::LArrow | token::OpenDelim(_) |
235235
token::CloseDelim(token::Brace) | token::CloseDelim(token::Paren) |
236+
token::CloseDelim(token::NoDelim) |
236237
token::Question => Class::None,
237238
token::Dollar => {
238239
if self.lexer.peek().tok.is_ident() {

src/libsyntax/ext/quote.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,10 @@ fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::BinOpToken) -> P<ast::Expr> {
581581

582582
fn mk_delim(cx: &ExtCtxt, sp: Span, delim: token::DelimToken) -> P<ast::Expr> {
583583
let name = match delim {
584-
token::Paren => "Paren",
585-
token::Bracket => "Bracket",
586-
token::Brace => "Brace",
584+
token::Paren => "Paren",
585+
token::Bracket => "Bracket",
586+
token::Brace => "Brace",
587+
token::NoDelim => "NoDelim",
587588
};
588589
mk_token_path(cx, sp, name)
589590
}

src/libsyntax/parse/token.rs

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ pub enum DelimToken {
4848
Bracket,
4949
/// A curly brace: `{` or `}`
5050
Brace,
51+
/// An empty delimiter
52+
NoDelim,
5153
}
5254

5355
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Debug, Copy)]

src/libsyntax/print/pprust.rs

+4
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ pub fn token_to_string(tok: &Token) -> String {
242242
token::CloseDelim(token::Bracket) => "]".to_string(),
243243
token::OpenDelim(token::Brace) => "{".to_string(),
244244
token::CloseDelim(token::Brace) => "}".to_string(),
245+
token::OpenDelim(token::NoDelim) => " ".to_string(),
246+
token::CloseDelim(token::NoDelim) => " ".to_string(),
245247
token::Pound => "#".to_string(),
246248
token::Dollar => "$".to_string(),
247249
token::Question => "?".to_string(),
@@ -1777,12 +1779,14 @@ impl<'a> State<'a> {
17771779
try!(self.head(""));
17781780
try!(self.bopen());
17791781
}
1782+
token::NoDelim => {}
17801783
}
17811784
try!(self.print_tts(&m.node.tts));
17821785
match delim {
17831786
token::Paren => self.pclose(),
17841787
token::Bracket => word(&mut self.s, "]"),
17851788
token::Brace => self.bclose(m.span),
1789+
token::NoDelim => Ok(()),
17861790
}
17871791
}
17881792

0 commit comments

Comments
 (0)