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;
($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))))
})
}
}
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,
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,
})
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
})
}
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)))))
}
}
}
}
+ 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:
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);
}
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));
}
}
}
// 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)
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 {