Skip to content

Commit

Permalink
[breaking-change] don't glob export ast::KleeneOp variants
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Feb 11, 2016
1 parent 019614f commit 798974c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/libsyntax/ast.rs
Expand Up @@ -10,7 +10,6 @@

// The Rust abstract syntax tree.

pub use self::KleeneOp::*;
pub use self::MacStmtStyle::*;
pub use self::MetaItem_::*;
pub use self::Mutability::*;
Expand Down
16 changes: 9 additions & 7 deletions src/libsyntax/ext/quote.rs
Expand Up @@ -542,11 +542,6 @@ fn mk_tt_path(cx: &ExtCtxt, sp: Span, name: &str) -> P<ast::Expr> {
cx.expr_path(cx.path_global(sp, idents))
}

fn mk_ast_path(cx: &ExtCtxt, sp: Span, name: &str) -> P<ast::Expr> {
let idents = vec!(id_ext("syntax"), id_ext("ast"), id_ext(name));
cx.expr_path(cx.path_global(sp, idents))
}

fn mk_token_path(cx: &ExtCtxt, sp: Span, name: &str) -> P<ast::Expr> {
let idents = vec!(id_ext("syntax"), id_ext("parse"), id_ext("token"), id_ext(name));
cx.expr_path(cx.path_global(sp, idents))
Expand Down Expand Up @@ -779,9 +774,16 @@ fn statements_mk_tt(cx: &ExtCtxt, tt: &TokenTree, matcher: bool) -> Vec<P<ast::S
None => cx.expr_none(sp),
};
let e_op = match seq.op {
ast::ZeroOrMore => mk_ast_path(cx, sp, "ZeroOrMore"),
ast::OneOrMore => mk_ast_path(cx, sp, "OneOrMore"),
ast::KleeneOp::ZeroOrMore => "ZeroOrMore",
ast::KleeneOp::OneOrMore => "OneOrMore",
};
let e_op_idents = vec![
id_ext("syntax"),
id_ext("ast"),
id_ext("KleeneOp"),
id_ext(e_op),
];
let e_op = cx.expr_path(cx.path_global(sp, e_op_idents));
let fields = vec![cx.field_imm(sp, id_ext("tts"), e_tts),
cx.field_imm(sp, id_ext("separator"), e_separator),
cx.field_imm(sp, id_ext("op"), e_op),
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/tt/macro_parser.rs
Expand Up @@ -374,7 +374,7 @@ pub fn parse(sess: &ParseSess,
match ei.top_elts.get_tt(idx) {
/* need to descend into sequence */
TokenTree::Sequence(sp, seq) => {
if seq.op == ast::ZeroOrMore {
if seq.op == ast::KleeneOp::ZeroOrMore {
let mut new_ei = ei.clone();
new_ei.match_cur += seq.num_captures;
new_ei.idx += 1;
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/tt/macro_rules.rs
Expand Up @@ -248,7 +248,7 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
TokenTree::Token(DUMMY_SP, token::FatArrow),
TokenTree::Token(DUMMY_SP, match_rhs_tok)],
separator: Some(token::Semi),
op: ast::OneOrMore,
op: ast::KleeneOp::OneOrMore,
num_captures: 2
})),
//to phase into semicolon-termination instead of
Expand All @@ -257,7 +257,7 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
Rc::new(ast::SequenceRepetition {
tts: vec![TokenTree::Token(DUMMY_SP, token::Semi)],
separator: None,
op: ast::ZeroOrMore,
op: ast::KleeneOp::ZeroOrMore,
num_captures: 0
})));

Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/tt/transcribe.rs
Expand Up @@ -81,7 +81,7 @@ pub fn new_tt_reader_with_doc_flag<'a>(sp_diag: &'a Handler,
forest: TokenTree::Sequence(DUMMY_SP, Rc::new(ast::SequenceRepetition {
tts: src,
// doesn't matter. This merely holds the root unzipping.
separator: None, op: ast::ZeroOrMore, num_captures: 0
separator: None, op: ast::KleeneOp::ZeroOrMore, num_captures: 0
})),
idx: 0,
dotdotdoted: false,
Expand Down Expand Up @@ -257,7 +257,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
}
LisConstraint(len, _) => {
if len == 0 {
if seq.op == ast::OneOrMore {
if seq.op == ast::KleeneOp::OneOrMore {
// FIXME #2887 blame invoker
panic!(r.sp_diag.span_fatal(sp.clone(),
"this must repeat at least once"));
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/parse/parser.rs
Expand Up @@ -2599,11 +2599,11 @@ impl<'a> Parser<'a> {
match parser.token {
token::BinOp(token::Star) => {
parser.bump();
Ok(Some(ast::ZeroOrMore))
Ok(Some(ast::KleeneOp::ZeroOrMore))
},
token::BinOp(token::Plus) => {
parser.bump();
Ok(Some(ast::OneOrMore))
Ok(Some(ast::KleeneOp::OneOrMore))
},
_ => Ok(None)
}
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/print/pprust.rs
Expand Up @@ -1489,8 +1489,8 @@ impl<'a> State<'a> {
None => {},
}
match seq.op {
ast::ZeroOrMore => word(&mut self.s, "*"),
ast::OneOrMore => word(&mut self.s, "+"),
ast::KleeneOp::ZeroOrMore => word(&mut self.s, "*"),
ast::KleeneOp::OneOrMore => word(&mut self.s, "+"),
}
}
}
Expand Down

0 comments on commit 798974c

Please sign in to comment.