Skip to content

Commit

Permalink
Changed NonCamelCaseTypes lint to warn by default
Browse files Browse the repository at this point in the history
Added allow(non_camel_case_types) to librustc where necesary

Tried to fix problems with non_camel_case_types outside rustc

fixed failing tests

Docs updated

Moved #[allow(non_camel_case_types)] a level higher.

markdown.rs reverted

Fixed timer that was failing tests

Fixed another timer
  • Loading branch information
mrshu committed Feb 21, 2014
1 parent d70f909 commit 70319f7
Show file tree
Hide file tree
Showing 42 changed files with 122 additions and 68 deletions.
68 changes: 34 additions & 34 deletions src/doc/guide-macros.md
Expand Up @@ -11,17 +11,17 @@ which both pattern-match on their input and both return early in one case,
doing nothing otherwise:

~~~~
# enum t { special_a(uint), special_b(uint) };
# enum T { SpecialA(uint), SpecialB(uint) };
# fn f() -> uint {
# let input_1 = special_a(0);
# let input_2 = special_a(0);
# let input_1 = SpecialA(0);
# let input_2 = SpecialA(0);
match input_1 {
special_a(x) => { return x; }
SpecialA(x) => { return x; }
_ => {}
}
// ...
match input_2 {
special_b(x) => { return x; }
SpecialB(x) => { return x; }
_ => {}
}
# return 0u;
Expand All @@ -37,22 +37,22 @@ lightweight custom syntax extensions, themselves defined using the
the pattern in the above code:

~~~~
# enum t { special_a(uint), special_b(uint) };
# enum T { SpecialA(uint), SpecialB(uint) };
# fn f() -> uint {
# let input_1 = special_a(0);
# let input_2 = special_a(0);
# let input_1 = SpecialA(0);
# let input_2 = SpecialA(0);
macro_rules! early_return(
($inp:expr $sp:ident) => ( // invoke it like `(input_5 special_e)`
($inp:expr $sp:ident) => ( // invoke it like `(input_5 SpecialE)`
match $inp {
$sp(x) => { return x; }
_ => {}
}
);
)
// ...
early_return!(input_1 special_a);
early_return!(input_1 SpecialA);
// ...
early_return!(input_2 special_b);
early_return!(input_2 SpecialB);
# return 0;
# }
~~~~
Expand Down Expand Up @@ -155,10 +155,10 @@ separator token (a comma-separated list could be written `$(...),*`), and `+`
instead of `*` to mean "at least one".

~~~~
# enum t { special_a(uint),special_b(uint),special_c(uint),special_d(uint)};
# enum T { SpecialA(uint),SpecialB(uint),SpecialC(uint),SpecialD(uint)};
# fn f() -> uint {
# let input_1 = special_a(0);
# let input_2 = special_a(0);
# let input_1 = SpecialA(0);
# let input_2 = SpecialA(0);
macro_rules! early_return(
($inp:expr, [ $($sp:ident)|+ ]) => (
match $inp {
Expand All @@ -170,9 +170,9 @@ macro_rules! early_return(
);
)
// ...
early_return!(input_1, [special_a|special_c|special_d]);
early_return!(input_1, [SpecialA|SpecialC|SpecialD]);
// ...
early_return!(input_2, [special_b]);
early_return!(input_2, [SpecialB]);
# return 0;
# }
~~~~
Expand Down Expand Up @@ -215,14 +215,14 @@ solves the problem.
Now consider code like the following:

~~~~
# enum t1 { good_1(t2, uint), bad_1 };
# struct t2 { body: t3 }
# enum t3 { good_2(uint), bad_2};
# fn f(x: t1) -> uint {
# enum T1 { Good1(T2, uint), Bad1};
# struct T2 { body: T3 }
# enum T3 { Good2(uint), Bad2};
# fn f(x: T1) -> uint {
match x {
good_1(g1, val) => {
Good1(g1, val) => {
match g1.body {
good_2(result) => {
Good2(result) => {
// complicated stuff goes here
return result + val;
},
Expand Down Expand Up @@ -261,13 +261,13 @@ macro_rules! biased_match (
)
)
# enum t1 { good_1(t2, uint), bad_1 };
# struct t2 { body: t3 }
# enum t3 { good_2(uint), bad_2};
# fn f(x: t1) -> uint {
biased_match!((x) ~ (good_1(g1, val)) else { return 0 };
# enum T1 { Good1(T2, uint), Bad1};
# struct T2 { body: T3 }
# enum T3 { Good2(uint), Bad2};
# fn f(x: T1) -> uint {
biased_match!((x) ~ (Good1(g1, val)) else { return 0 };
binds g1, val )
biased_match!((g1.body) ~ (good_2(result) )
biased_match!((g1.body) ~ (Good2(result) )
else { fail!("Didn't get good_2") };
binds result )
// complicated stuff goes here
Expand Down Expand Up @@ -365,13 +365,13 @@ macro_rules! biased_match (
)
# enum t1 { good_1(t2, uint), bad_1 };
# struct t2 { body: t3 }
# enum t3 { good_2(uint), bad_2};
# fn f(x: t1) -> uint {
# enum T1 { Good1(T2, uint), Bad1};
# struct T2 { body: T3 }
# enum T3 { Good2(uint), Bad2};
# fn f(x: T1) -> uint {
biased_match!(
(x) ~ (good_1(g1, val)) else { return 0 };
(g1.body) ~ (good_2(result) ) else { fail!("Didn't get good_2") };
(x) ~ (Good1(g1, val)) else { return 0 };
(g1.body) ~ (Good2(result) ) else { fail!("Didn't get Good2") };
binds val, result )
// complicated stuff goes here
return result + val;
Expand Down
10 changes: 5 additions & 5 deletions src/doc/rust.md
Expand Up @@ -470,7 +470,7 @@ Two examples of paths with type arguments:
# use std::hashmap::HashMap;
# fn f() {
# fn id<T>(t: T) -> T { t }
type t = HashMap<int,~str>; // Type arguments used in a type expression
type T = HashMap<int,~str>; // Type arguments used in a type expression
let x = id::<int>(10); // Type arguments used in a call expression
# }
~~~~
Expand Down Expand Up @@ -701,7 +701,7 @@ An example of a module:

~~~~
mod math {
type complex = (f64, f64);
type Complex = (f64, f64);
fn sin(f: f64) -> f64 {
...
# fail!();
Expand Down Expand Up @@ -2824,13 +2824,13 @@ provided by an implementation of `std::iter::Iterator`.
An example of a for loop over the contents of a vector:

~~~~
# type foo = int;
# fn bar(f: foo) { }
# type Foo = int;
# fn bar(f: Foo) { }
# let a = 0;
# let b = 0;
# let c = 0;
let v: &[foo] = &[a, b, c];
let v: &[Foo] = &[a, b, c];
for e in v.iter() {
bar(*e);
Expand Down
4 changes: 3 additions & 1 deletion src/libnative/io/file.rs
@@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -10,6 +10,8 @@

//! Blocking posix-based file I/O

#[allow(non_camel_case_types)];

use std::sync::arc::UnsafeArc;
use std::c_str::CString;
use std::io::IoError;
Expand Down
4 changes: 3 additions & 1 deletion src/libnative/io/net.rs
@@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[allow(non_camel_case_types)];

use std::cast;
use std::io::net::ip;
use std::io;
Expand Down
5 changes: 4 additions & 1 deletion src/libnative/io/timer_helper.rs
@@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -20,6 +20,8 @@
//! can be created in the future and there must be no active timers at that
//! time.

#[allow(non_camel_case_types)];

use std::cast;
use std::rt;
use std::unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
Expand Down Expand Up @@ -98,6 +100,7 @@ mod imp {

use io::file::FileDesc;

#[allow(non_camel_case_types)]
pub type signal = libc::c_int;

pub fn new() -> (signal, signal) {
Expand Down
2 changes: 2 additions & 0 deletions src/libnative/io/timer_other.rs
Expand Up @@ -46,6 +46,8 @@
//!
//! Note that all time units in this file are in *milliseconds*.

#[allow(non_camel_case_types)];

use std::comm::Data;
use std::hashmap::HashMap;
use std::libc;
Expand Down
4 changes: 3 additions & 1 deletion src/libnative/io/timer_timerfd.rs
@@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -28,6 +28,8 @@
//!
//! As with timer_other, all units in this file are in units of millseconds.

#[allow(non_camel_case_types)];

use std::comm::Data;
use std::libc;
use std::ptr;
Expand Down
1 change: 1 addition & 0 deletions src/librustc/back/target_strs.rs
Expand Up @@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[allow(non_camel_case_types)];

pub struct t {
module_asm: ~str,
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib/llvm.rs
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

#[allow(non_uppercase_pattern_statics)];
#[allow(non_camel_case_types)];

use std::c_str::ToCStr;
use std::cell::RefCell;
Expand Down
4 changes: 3 additions & 1 deletion src/librustc/metadata/common.rs
@@ -1,4 +1,4 @@
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// 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.
//
Expand All @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[allow(non_camel_case_types)];

use std::cast;
use syntax::crateid::CrateId;

Expand Down
4 changes: 3 additions & 1 deletion src/librustc/metadata/creader.rs
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// 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.
//
Expand All @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[allow(non_camel_case_types)];

//! Validates all used crates and extern libraries and loads their metadata

use driver::{driver, session};
Expand Down
1 change: 1 addition & 0 deletions src/librustc/metadata/csearch.rs
Expand Up @@ -10,6 +10,7 @@

// Searching for information from the cstore

#[allow(non_camel_case_types)];

use metadata::common::*;
use metadata::cstore;
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/metadata/cstore.rs
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// 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.
//
Expand All @@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[allow(non_camel_case_types)];

// The crate store - a central repo for information collected about external
// crates and libraries
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/metadata/decoder.rs
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// 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.
//
Expand All @@ -10,6 +10,7 @@

// Decoding metadata from a single crate's metadata

#[allow(non_camel_case_types)];

use metadata::cstore::crate_metadata;
use metadata::common::*;
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/metadata/encoder.rs
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// 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.
//
Expand All @@ -11,6 +11,7 @@
// Metadata encoding

#[allow(unused_must_use)]; // everything is just a MemWriter, can't fail
#[allow(non_camel_case_types)];

use metadata::common::*;
use metadata::cstore;
Expand Down
4 changes: 3 additions & 1 deletion src/librustc/metadata/filesearch.rs
@@ -1,4 +1,4 @@
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// 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.
//
Expand All @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[allow(non_camel_case_types)];

use std::cell::RefCell;
use std::option;
use std::os;
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/metadata/tydecode.rs
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// 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.
//
Expand All @@ -14,6 +14,7 @@
// tjc note: Would be great to have a `match check` macro equivalent
// for some of these

#[allow(non_camel_case_types)];

use middle::ty;

Expand Down
3 changes: 2 additions & 1 deletion src/librustc/metadata/tyencode.rs
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// 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.
//
Expand All @@ -11,6 +11,7 @@
// Type encoding

#[allow(unused_must_use)]; // as with encoding, everything is a no-fail MemWriter
#[allow(non_camel_case_types)];

use std::cell::RefCell;
use std::hashmap::HashMap;
Expand Down

5 comments on commit 70319f7

@bors
Copy link
Contributor

@bors bors commented on 70319f7 Feb 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at mrshu@70319f7

@bors
Copy link
Contributor

@bors bors commented on 70319f7 Feb 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging mrshu/rust/lint-warn-by-default = 70319f7 into auto

@bors
Copy link
Contributor

@bors bors commented on 70319f7 Feb 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mrshu/rust/lint-warn-by-default = 70319f7 merged ok, testing candidate = 37903cb

@bors
Copy link
Contributor

@bors bors commented on 70319f7 Feb 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 70319f7 Feb 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 37903cb

Please sign in to comment.