de7abd8824
This unifies the `non_snake_case_functions` and `uppercase_variables` lints into one lint, `non_snake_case`. It also now checks for non-snake-case modules. This also extends the non-camel-case types lint to check type parameters, and merges the `non_uppercase_pattern_statics` lint into the `non_uppercase_statics` lint. Because the `uppercase_variables` lint is now part of the `non_snake_case` lint, all non-snake-case variables that start with lowercase characters (such as `fooBar`) will now trigger the `non_snake_case` lint. New code should be updated to use the new `non_snake_case` lint instead of the previous `non_snake_case_functions` and `uppercase_variables` lints. All use of the `non_uppercase_pattern_statics` should be replaced with the `non_uppercase_statics` lint. Any code that previously contained non-snake-case module or variable names should be updated to use snake case names or disable the `non_snake_case` lint. Any code with non-camel-case type parameters should be changed to use camel case or disable the `non_camel_case_types` lint. [breaking-change]
44 lines
1.3 KiB
Rust
44 lines
1.3 KiB
Rust
// Copyright 2012-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 <LICENSE-APACHE or
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
// option. This file may not be copied, modified, or distributed
|
|
// except according to those terms.
|
|
|
|
// ignore-tidy-linelength
|
|
|
|
#![allow(dead_code)]
|
|
#![deny(non_snake_case)]
|
|
|
|
use std::io::File;
|
|
use std::io::IoError;
|
|
|
|
struct Something {
|
|
X: uint //~ ERROR structure field `X` should have a snake case name such as `x`
|
|
}
|
|
|
|
fn test(Xx: uint) { //~ ERROR variable `Xx` should have a snake case name such as `xx`
|
|
println!("{}", Xx);
|
|
}
|
|
|
|
fn main() {
|
|
let Test: uint = 0; //~ ERROR variable `Test` should have a snake case name such as `test`
|
|
println!("{}", Test);
|
|
|
|
let mut f = File::open(&Path::new("something.txt"));
|
|
let mut buff = [0u8, ..16];
|
|
match f.read(buff) {
|
|
Ok(cnt) => println!("read this many bytes: {}", cnt),
|
|
Err(IoError{ kind: EndOfFile, .. }) => println!("Got end of file: {}", EndOfFile.to_string()),
|
|
//~^ ERROR variable `EndOfFile` should have a snake case name such as `end_of_file`
|
|
}
|
|
|
|
test(1);
|
|
|
|
let _ = Something { X: 0 };
|
|
}
|
|
|