From 94bcd3539c761b4ecf423800bce21057c4e961fa Mon Sep 17 00:00:00 2001 From: P1start Date: Sat, 13 Sep 2014 13:55:37 +1200 Subject: Set the `non_uppercase_statics` lint to warn by default --- src/libsyntax/abi.rs | 3 +++ src/libsyntax/ast_util.rs | 1 + src/libsyntax/parse/token.rs | 7 +++++-- src/libsyntax/print/pprust.rs | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 6d9b8821bd8..3a02d74edff 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -47,7 +47,9 @@ pub enum Architecture { Mipsel } +#[allow(non_uppercase_statics)] static IntelBits: u32 = (1 << (X86 as uint)) | (1 << (X86_64 as uint)); +#[allow(non_uppercase_statics)] static ArmBits: u32 = (1 << (Arm as uint)); pub struct AbiData { @@ -70,6 +72,7 @@ pub enum AbiArchitecture { Archs(u32) } +#[allow(non_uppercase_statics)] static AbiDatas: &'static [AbiData] = &[ // Platform-specific ABIs AbiData {abi: Cdecl, name: "cdecl", abi_arch: Archs(IntelBits)}, diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 31860062580..f746e1f1482 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -293,6 +293,7 @@ pub fn operator_prec(op: ast::BinOp) -> uint { /// Precedence of the `as` operator, which is a binary operator /// not appearing in the prior table. +#[allow(non_uppercase_statics)] pub static as_prec: uint = 12u; pub fn empty_generics() -> Generics { diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index a486ac40a97..a8c827439cc 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -383,12 +383,15 @@ macro_rules! declare_special_idents_and_keywords {( pub mod special_idents { use ast::{Ident, Name}; - $( pub static $si_static: Ident = Ident { name: Name($si_name), ctxt: 0 }; )* + $( + #[allow(non_uppercase_statics)] + pub static $si_static: Ident = Ident { name: Name($si_name), ctxt: 0 }; + )* } pub mod special_names { use ast::Name; - $( pub static $si_static: Name = Name($si_name); )* + $( #[allow(non_uppercase_statics)] pub static $si_static: Name = Name($si_name); )* } /** diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 8400d9aea3b..c3a3848019a 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -89,8 +89,10 @@ pub fn rust_printer_annotated<'a>(writer: Box, } } +#[allow(non_uppercase_statics)] pub static indent_unit: uint = 4u; +#[allow(non_uppercase_statics)] pub static default_columns: uint = 78u; /// Requires you to pass an input filename and reader so that -- cgit 1.4.1-3-g733a5 From 042cdeefc7708291057770ddd5becf14288dad71 Mon Sep 17 00:00:00 2001 From: P1start Date: Sat, 13 Sep 2014 14:09:22 +1200 Subject: Correct error message for invalid `ref`/`mut` bindings Closes #15914. --- src/libsyntax/parse/parser.rs | 7 ++++--- src/test/compile-fail/issue-15914.rs | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 src/test/compile-fail/issue-15914.rs (limited to 'src/libsyntax') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7cce9c2dc3a..d2735a425f5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3402,9 +3402,10 @@ impl<'a> Parser<'a> { binding_mode: ast::BindingMode) -> ast::Pat_ { if !is_plain_ident(&self.token) { - let last_span = self.last_span; - self.span_fatal(last_span, - "expected identifier, found path"); + let span = self.span; + let tok_str = self.this_token_to_string(); + self.span_fatal(span, + format!("expected identifier, found `{}`", tok_str).as_slice()); } let ident = self.parse_ident(); let last_span = self.last_span; diff --git a/src/test/compile-fail/issue-15914.rs b/src/test/compile-fail/issue-15914.rs new file mode 100644 index 00000000000..45b3abfddfb --- /dev/null +++ b/src/test/compile-fail/issue-15914.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let ref + (); //~ ERROR expected identifier, found `(` +} -- cgit 1.4.1-3-g733a5