diff options
| author | bors <bors@rust-lang.org> | 2015-03-05 21:03:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-05 21:03:10 +0000 |
| commit | b0746ff19b3bc204215f04bbb5756159f9bc5c92 (patch) | |
| tree | 2116c5865229d3d238832e50c99ad9baebe63087 /src/libsyntax | |
| parent | f0c74f85f363a8081b31f9ab696463717ce312d5 (diff) | |
| parent | 340d1cc7d701bf1c5bae6c2ad5b097462c5d1a7c (diff) | |
| download | rust-b0746ff19b3bc204215f04bbb5756159f9bc5c92.tar.gz rust-b0746ff19b3bc204215f04bbb5756159f9bc5c92.zip | |
Auto merge of #23031 - Manishearth:rollup, r=Manishearth
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_util.rs | 16 | ||||
| -rw-r--r-- | src/libsyntax/diagnostics/macros.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/attr.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 15 |
10 files changed, 36 insertions, 21 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 264e05f5c8d..26d7562cdb2 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -159,10 +159,10 @@ pub fn int_ty_to_string(t: IntTy, val: Option<i64>) -> String { pub fn int_ty_max(t: IntTy) -> u64 { match t { - TyI8 => 0x80u64, - TyI16 => 0x8000u64, - TyIs(_) | TyI32 => 0x80000000u64, // actually ni about TyIs - TyI64 => 0x8000000000000000u64 + TyI8 => 0x80, + TyI16 => 0x8000, + TyIs(_) | TyI32 => 0x80000000, // actually ni about TyIs + TyI64 => 0x8000000000000000 } } @@ -185,10 +185,10 @@ pub fn uint_ty_to_string(t: UintTy, val: Option<u64>) -> String { pub fn uint_ty_max(t: UintTy) -> u64 { match t { - TyU8 => 0xffu64, - TyU16 => 0xffffu64, - TyUs(_) | TyU32 => 0xffffffffu64, // actually ni about TyUs - TyU64 => 0xffffffffffffffffu64 + TyU8 => 0xff, + TyU16 => 0xffff, + TyUs(_) | TyU32 => 0xffffffff, // actually ni about TyUs + TyU64 => 0xffffffffffffffff } } diff --git a/src/libsyntax/diagnostics/macros.rs b/src/libsyntax/diagnostics/macros.rs index 54689a1f77a..055ade46a3f 100644 --- a/src/libsyntax/diagnostics/macros.rs +++ b/src/libsyntax/diagnostics/macros.rs @@ -53,6 +53,13 @@ macro_rules! span_help { } #[macro_export] +macro_rules! fileline_help { + ($session:expr, $span:expr, $($message:tt)*) => ({ + ($session).fileline_help($span, &format!($($message)*)) + }) +} + +#[macro_export] macro_rules! register_diagnostics { ($($code:tt),*) => ( $(register_diagnostic! { $code })* diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index f6bdd693cfa..a8c35c1fdb1 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -753,6 +753,10 @@ impl<'a> ExtCtxt<'a> { self.print_backtrace(); self.parse_sess.span_diagnostic.span_help(sp, msg); } + pub fn fileline_help(&self, sp: Span, msg: &str) { + self.print_backtrace(); + self.parse_sess.span_diagnostic.fileline_help(sp, msg); + } pub fn bug(&self, msg: &str) -> ! { self.print_backtrace(); self.parse_sess.span_diagnostic.handler().bug(msg); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index bea57ae14e4..8896a8e0c4f 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -571,7 +571,7 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool fld.cx.span_warn(attr.span, "macro_escape is a deprecated synonym for macro_use"); is_use = true; if let ast::AttrInner = attr.node.style { - fld.cx.span_help(attr.span, "consider an outer attribute, \ + fld.cx.fileline_help(attr.span, "consider an outer attribute, \ #[macro_use] mod ..."); } }; diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 2599a53e313..737648cd90c 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -676,9 +676,10 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> { token::FatArrow => "FatArrow", token::Pound => "Pound", token::Dollar => "Dollar", + token::Question => "Question", token::Underscore => "Underscore", token::Eof => "Eof", - _ => panic!(), + _ => panic!("unhandled token in quote!"), }; mk_token_path(cx, sp, name) } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 18d3f85f4b5..c2ad8554674 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -362,7 +362,7 @@ impl<'a> Context<'a> { pub fn emit_feature_err(diag: &SpanHandler, feature: &str, span: Span, explain: &str) { diag.span_err(span, explain); - diag.span_help(span, &format!("add #![feature({})] to the \ + diag.fileline_help(span, &format!("add #![feature({})] to the \ crate attributes to enable", feature)); } @@ -370,7 +370,7 @@ pub fn emit_feature_err(diag: &SpanHandler, feature: &str, span: Span, explain: pub fn emit_feature_warn(diag: &SpanHandler, feature: &str, span: Span, explain: &str) { diag.span_warn(span, explain); if diag.handler.can_emit_warnings { - diag.span_help(span, &format!("add #![feature({})] to the \ + diag.fileline_help(span, &format!("add #![feature({})] to the \ crate attributes to silence this warning", feature)); } diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index a0e2b4dbf5a..db5583cf13a 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -77,7 +77,7 @@ impl<'a> ParserAttr for Parser<'a> { self.span_err(span, "an inner attribute is not permitted in \ this context"); - self.span_help(span, + self.fileline_help(span, "place inner attribute at the top of the module or block"); } ast::AttrInner diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 8d3e93d35dd..72ff501c648 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -781,7 +781,7 @@ impl<'a> StringReader<'a> { self.span_diagnostic .span_warn(sp, "\\U00ABCD12 and \\uABCD escapes are deprecated"); self.span_diagnostic - .span_help(sp, "use \\u{ABCD12} escapes instead"); + .fileline_help(sp, "use \\u{ABCD12} escapes instead"); } /// Scan for a single (possibly escaped) byte or char diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index def5963e6f4..58d58551df3 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -724,7 +724,7 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) -> &suf[1..])); } else { sd.span_err(sp, &*format!("illegal suffix `{}` for numeric literal", suf)); - sd.span_help(sp, "the suffix must be one of the integral types \ + sd.fileline_help(sp, "the suffix must be one of the integral types \ (`u32`, `isize`, etc)"); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 88df6d6d4cd..28d757e9be9 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -974,7 +974,7 @@ impl<'a> Parser<'a> { } pub fn span_fatal_help(&self, sp: Span, m: &str, help: &str) -> ! { self.span_err(sp, m); - self.span_help(sp, help); + self.fileline_help(sp, help); panic!(diagnostic::FatalError); } pub fn span_note(&self, sp: Span, m: &str) { @@ -983,6 +983,9 @@ impl<'a> Parser<'a> { pub fn span_help(&self, sp: Span, m: &str) { self.sess.span_diagnostic.span_help(sp, m) } + pub fn fileline_help(&self, sp: Span, m: &str) { + self.sess.span_diagnostic.fileline_help(sp, m) + } pub fn bug(&self, m: &str) -> ! { self.sess.span_diagnostic.span_bug(self.span, m) } @@ -2532,7 +2535,7 @@ impl<'a> Parser<'a> { Some(f) => f, None => continue, }; - self.span_help(last_span, + self.fileline_help(last_span, &format!("try parenthesizing the first index; e.g., `(foo.{}){}`", float.trunc() as usize, &float.fract().to_string()[1..])); @@ -2943,7 +2946,7 @@ impl<'a> Parser<'a> { self.span_err(op_span, "chained comparison operators require parentheses"); if op.node == BiLt && outer_op == BiGt { - self.span_help(op_span, + self.fileline_help(op_span, "use `::<...>` instead of `<...>` if you meant to specify type arguments"); } } @@ -4699,7 +4702,7 @@ impl<'a> Parser<'a> { match visa { Public => { self.span_err(span, "can't qualify macro invocation with `pub`"); - self.span_help(span, "try adjusting the macro to put `pub` inside \ + self.fileline_help(span, "try adjusting the macro to put `pub` inside \ the invocation"); } Inherited => (), @@ -5445,7 +5448,7 @@ impl<'a> Parser<'a> { if self.token.is_ident() { self.bump(); } self.span_err(span, "expected `;`, found `as`"); - self.span_help(span, + self.fileline_help(span, &format!("perhaps you meant to enclose the crate name `{}` in \ a string?", the_ident.as_str())); @@ -5756,7 +5759,7 @@ impl<'a> Parser<'a> { if self.eat_keyword(keywords::Mut) { let last_span = self.last_span; self.span_err(last_span, "const globals cannot be mutable"); - self.span_help(last_span, "did you mean to declare a static?"); + self.fileline_help(last_span, "did you mean to declare a static?"); } let (ident, item_, extra_attrs) = self.parse_item_const(None); let last_span = self.last_span; |
