]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/ext/base.rs
[breaking-change] don't pub export ast::Stmt_ variants
[rust.git] / src / libsyntax / ext / base.rs
index f616420218e1aff1427f4d66c2562a251c6338b0..ceb7cf69680bd9967875a1c931be8c030f9481ed 100644 (file)
@@ -14,6 +14,7 @@
 use ast::Name;
 use codemap;
 use codemap::{CodeMap, Span, ExpnId, ExpnInfo, NO_EXPANSION};
+use errors::DiagnosticBuilder;
 use ext;
 use ext::expand;
 use ext::tt::macro_rules;
@@ -204,7 +205,7 @@ macro_rules! make_stmts_default {
     ($me:expr) => {
         $me.make_expr().map(|e| {
             SmallVector::one(P(codemap::respan(
-                e.span, ast::StmtExpr(e, ast::DUMMY_NODE_ID))))
+                e.span, ast::StmtKind::Expr(e, ast::DUMMY_NODE_ID))))
         })
     }
 }
@@ -302,7 +303,7 @@ fn make_pat(self: Box<Self>) -> Option<P<ast::Pat>> {
             return Some(p);
         }
         if let Some(e) = self.expr {
-            if let ast::ExprLit(_) = e.node {
+            if let ast::ExprKind::Lit(_) = e.node {
                 return Some(P(ast::Pat {
                     id: ast::DUMMY_NODE_ID,
                     span: e.span,
@@ -348,7 +349,7 @@ pub fn expr(sp: Span) -> Box<MacResult+'static> {
     pub fn raw_expr(sp: Span) -> P<ast::Expr> {
         P(ast::Expr {
             id: ast::DUMMY_NODE_ID,
-            node: ast::ExprLit(P(codemap::respan(sp, ast::LitBool(false)))),
+            node: ast::ExprKind::Lit(P(codemap::respan(sp, ast::LitKind::Bool(false)))),
             span: sp,
             attrs: None,
         })
@@ -366,7 +367,7 @@ pub fn raw_pat(sp: Span) -> ast::Pat {
     pub fn raw_ty(sp: Span) -> P<ast::Ty> {
         P(ast::Ty {
             id: ast::DUMMY_NODE_ID,
-            node: ast::TyInfer,
+            node: ast::TyKind::Infer,
             span: sp
         })
     }
@@ -401,8 +402,8 @@ fn make_impl_items(self: Box<DummyResult>) -> Option<SmallVector<P<ast::ImplItem
     fn make_stmts(self: Box<DummyResult>) -> Option<SmallVector<P<ast::Stmt>>> {
         Some(SmallVector::one(P(
             codemap::respan(self.span,
-                            ast::StmtExpr(DummyResult::raw_expr(self.span),
-                                          ast::DUMMY_NODE_ID)))))
+                            ast::StmtKind::Expr(DummyResult::raw_expr(self.span),
+                                                ast::DUMMY_NODE_ID)))))
     }
 }
 
@@ -678,6 +679,25 @@ pub fn insert_macro(&mut self, def: ast::MacroDef) {
         }
     }
 
+    pub fn struct_span_warn(&self,
+                            sp: Span,
+                            msg: &str)
+                            -> DiagnosticBuilder<'a> {
+        self.parse_sess.span_diagnostic.struct_span_warn(sp, msg)
+    }
+    pub fn struct_span_err(&self,
+                           sp: Span,
+                           msg: &str)
+                           -> DiagnosticBuilder<'a> {
+        self.parse_sess.span_diagnostic.struct_span_err(sp, msg)
+    }
+    pub fn struct_span_fatal(&self,
+                             sp: Span,
+                             msg: &str)
+                             -> DiagnosticBuilder<'a> {
+        self.parse_sess.span_diagnostic.struct_span_fatal(sp, msg)
+    }
+
     /// Emit `msg` attached to `sp`, and stop compilation immediately.
     ///
     /// `span_err` should be strongly preferred where-ever possible:
@@ -710,15 +730,6 @@ pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! {
     pub fn span_bug(&self, sp: Span, msg: &str) -> ! {
         self.parse_sess.span_diagnostic.span_bug(sp, msg);
     }
-    pub fn span_note(&self, sp: Span, msg: &str) {
-        self.parse_sess.span_diagnostic.span_note(sp, msg);
-    }
-    pub fn span_help(&self, sp: Span, msg: &str) {
-        self.parse_sess.span_diagnostic.span_help(sp, msg);
-    }
-    pub fn fileline_help(&self, sp: Span, msg: &str) {
-        self.parse_sess.span_diagnostic.fileline_help(sp, msg);
-    }
     pub fn bug(&self, msg: &str) -> ! {
         self.parse_sess.span_diagnostic.bug(msg);
     }
@@ -743,10 +754,13 @@ pub fn name_of(&self, st: &str) -> ast::Name {
         token::intern(st)
     }
 
-    pub fn suggest_macro_name(&mut self, name: &str, span: Span) {
+    pub fn suggest_macro_name(&mut self,
+                              name: &str,
+                              span: Span,
+                              err: &mut DiagnosticBuilder<'a>) {
         let names = &self.syntax_env.names;
         if let Some(suggestion) = find_best_match_for_name(names.iter(), name, None) {
-            self.fileline_help(span, &format!("did you mean `{}!`?", suggestion));
+            err.fileline_help(span, &format!("did you mean `{}!`?", suggestion));
         }
     }
 }
@@ -759,8 +773,8 @@ pub fn expr_to_string(cx: &mut ExtCtxt, expr: P<ast::Expr>, err_msg: &str)
     // we want to be able to handle e.g. concat("foo", "bar")
     let expr = cx.expander().fold_expr(expr);
     match expr.node {
-        ast::ExprLit(ref l) => match l.node {
-            ast::LitStr(ref s, style) => return Some(((*s).clone(), style)),
+        ast::ExprKind::Lit(ref l) => match l.node {
+            ast::LitKind::Str(ref s, style) => return Some(((*s).clone(), style)),
             _ => cx.span_err(l.span, err_msg)
         },
         _ => cx.span_err(expr.span, err_msg)
@@ -812,7 +826,7 @@ pub fn get_exprs_from_tts(cx: &mut ExtCtxt,
     let mut es = Vec::new();
     while p.token != token::Eof {
         es.push(cx.expander().fold_expr(panictry!(p.parse_expr())));
-        if panictry!(p.eat(&token::Comma)){
+        if p.eat(&token::Comma) {
             continue;
         }
         if p.token != token::Eof {