Skip to content

Commit 37903cb

Browse files
committed
auto merge of #12290 : mrshu/rust/lint-warn-by-default, r=alexcrichton
This first part of my attempts to fix #11432. In this one I only set NonCamelCaseTypes to warn by default and tried to fix errors that were reported by `make check`. Please feel free to let me know if I missed something or didn't do it the right way. Thanks.
2 parents ca41bbb + 70319f7 commit 37903cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+122
-68
lines changed

src/doc/guide-macros.md

+34-34
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ which both pattern-match on their input and both return early in one case,
1111
doing nothing otherwise:
1212

1313
~~~~
14-
# enum t { special_a(uint), special_b(uint) };
14+
# enum T { SpecialA(uint), SpecialB(uint) };
1515
# fn f() -> uint {
16-
# let input_1 = special_a(0);
17-
# let input_2 = special_a(0);
16+
# let input_1 = SpecialA(0);
17+
# let input_2 = SpecialA(0);
1818
match input_1 {
19-
special_a(x) => { return x; }
19+
SpecialA(x) => { return x; }
2020
_ => {}
2121
}
2222
// ...
2323
match input_2 {
24-
special_b(x) => { return x; }
24+
SpecialB(x) => { return x; }
2525
_ => {}
2626
}
2727
# return 0u;
@@ -37,22 +37,22 @@ lightweight custom syntax extensions, themselves defined using the
3737
the pattern in the above code:
3838

3939
~~~~
40-
# enum t { special_a(uint), special_b(uint) };
40+
# enum T { SpecialA(uint), SpecialB(uint) };
4141
# fn f() -> uint {
42-
# let input_1 = special_a(0);
43-
# let input_2 = special_a(0);
42+
# let input_1 = SpecialA(0);
43+
# let input_2 = SpecialA(0);
4444
macro_rules! early_return(
45-
($inp:expr $sp:ident) => ( // invoke it like `(input_5 special_e)`
45+
($inp:expr $sp:ident) => ( // invoke it like `(input_5 SpecialE)`
4646
match $inp {
4747
$sp(x) => { return x; }
4848
_ => {}
4949
}
5050
);
5151
)
5252
// ...
53-
early_return!(input_1 special_a);
53+
early_return!(input_1 SpecialA);
5454
// ...
55-
early_return!(input_2 special_b);
55+
early_return!(input_2 SpecialB);
5656
# return 0;
5757
# }
5858
~~~~
@@ -155,10 +155,10 @@ separator token (a comma-separated list could be written `$(...),*`), and `+`
155155
instead of `*` to mean "at least one".
156156

157157
~~~~
158-
# enum t { special_a(uint),special_b(uint),special_c(uint),special_d(uint)};
158+
# enum T { SpecialA(uint),SpecialB(uint),SpecialC(uint),SpecialD(uint)};
159159
# fn f() -> uint {
160-
# let input_1 = special_a(0);
161-
# let input_2 = special_a(0);
160+
# let input_1 = SpecialA(0);
161+
# let input_2 = SpecialA(0);
162162
macro_rules! early_return(
163163
($inp:expr, [ $($sp:ident)|+ ]) => (
164164
match $inp {
@@ -170,9 +170,9 @@ macro_rules! early_return(
170170
);
171171
)
172172
// ...
173-
early_return!(input_1, [special_a|special_c|special_d]);
173+
early_return!(input_1, [SpecialA|SpecialC|SpecialD]);
174174
// ...
175-
early_return!(input_2, [special_b]);
175+
early_return!(input_2, [SpecialB]);
176176
# return 0;
177177
# }
178178
~~~~
@@ -215,14 +215,14 @@ solves the problem.
215215
Now consider code like the following:
216216

217217
~~~~
218-
# enum t1 { good_1(t2, uint), bad_1 };
219-
# struct t2 { body: t3 }
220-
# enum t3 { good_2(uint), bad_2};
221-
# fn f(x: t1) -> uint {
218+
# enum T1 { Good1(T2, uint), Bad1};
219+
# struct T2 { body: T3 }
220+
# enum T3 { Good2(uint), Bad2};
221+
# fn f(x: T1) -> uint {
222222
match x {
223-
good_1(g1, val) => {
223+
Good1(g1, val) => {
224224
match g1.body {
225-
good_2(result) => {
225+
Good2(result) => {
226226
// complicated stuff goes here
227227
return result + val;
228228
},
@@ -261,13 +261,13 @@ macro_rules! biased_match (
261261
)
262262
)
263263
264-
# enum t1 { good_1(t2, uint), bad_1 };
265-
# struct t2 { body: t3 }
266-
# enum t3 { good_2(uint), bad_2};
267-
# fn f(x: t1) -> uint {
268-
biased_match!((x) ~ (good_1(g1, val)) else { return 0 };
264+
# enum T1 { Good1(T2, uint), Bad1};
265+
# struct T2 { body: T3 }
266+
# enum T3 { Good2(uint), Bad2};
267+
# fn f(x: T1) -> uint {
268+
biased_match!((x) ~ (Good1(g1, val)) else { return 0 };
269269
binds g1, val )
270-
biased_match!((g1.body) ~ (good_2(result) )
270+
biased_match!((g1.body) ~ (Good2(result) )
271271
else { fail!("Didn't get good_2") };
272272
binds result )
273273
// complicated stuff goes here
@@ -365,13 +365,13 @@ macro_rules! biased_match (
365365
)
366366
367367
368-
# enum t1 { good_1(t2, uint), bad_1 };
369-
# struct t2 { body: t3 }
370-
# enum t3 { good_2(uint), bad_2};
371-
# fn f(x: t1) -> uint {
368+
# enum T1 { Good1(T2, uint), Bad1};
369+
# struct T2 { body: T3 }
370+
# enum T3 { Good2(uint), Bad2};
371+
# fn f(x: T1) -> uint {
372372
biased_match!(
373-
(x) ~ (good_1(g1, val)) else { return 0 };
374-
(g1.body) ~ (good_2(result) ) else { fail!("Didn't get good_2") };
373+
(x) ~ (Good1(g1, val)) else { return 0 };
374+
(g1.body) ~ (Good2(result) ) else { fail!("Didn't get Good2") };
375375
binds val, result )
376376
// complicated stuff goes here
377377
return result + val;

src/doc/rust.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ Two examples of paths with type arguments:
470470
# use std::hashmap::HashMap;
471471
# fn f() {
472472
# fn id<T>(t: T) -> T { t }
473-
type t = HashMap<int,~str>; // Type arguments used in a type expression
473+
type T = HashMap<int,~str>; // Type arguments used in a type expression
474474
let x = id::<int>(10); // Type arguments used in a call expression
475475
# }
476476
~~~~
@@ -701,7 +701,7 @@ An example of a module:
701701

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

28262826
~~~~
2827-
# type foo = int;
2828-
# fn bar(f: foo) { }
2827+
# type Foo = int;
2828+
# fn bar(f: Foo) { }
28292829
# let a = 0;
28302830
# let b = 0;
28312831
# let c = 0;
28322832
2833-
let v: &[foo] = &[a, b, c];
2833+
let v: &[Foo] = &[a, b, c];
28342834
28352835
for e in v.iter() {
28362836
bar(*e);

src/libnative/io/file.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -10,6 +10,8 @@
1010

1111
//! Blocking posix-based file I/O
1212
13+
#[allow(non_camel_case_types)];
14+
1315
use std::sync::arc::UnsafeArc;
1416
use std::c_str::CString;
1517
use std::io::IoError;

src/libnative/io/net.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[allow(non_camel_case_types)];
12+
1113
use std::cast;
1214
use std::io::net::ip;
1315
use std::io;

src/libnative/io/timer_helper.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -20,6 +20,8 @@
2020
//! can be created in the future and there must be no active timers at that
2121
//! time.
2222
23+
#[allow(non_camel_case_types)];
24+
2325
use std::cast;
2426
use std::rt;
2527
use std::unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
@@ -98,6 +100,7 @@ mod imp {
98100

99101
use io::file::FileDesc;
100102

103+
#[allow(non_camel_case_types)]
101104
pub type signal = libc::c_int;
102105

103106
pub fn new() -> (signal, signal) {

src/libnative/io/timer_other.rs

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
//!
4747
//! Note that all time units in this file are in *milliseconds*.
4848
49+
#[allow(non_camel_case_types)];
50+
4951
use std::comm::Data;
5052
use std::hashmap::HashMap;
5153
use std::libc;

src/libnative/io/timer_timerfd.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -28,6 +28,8 @@
2828
//!
2929
//! As with timer_other, all units in this file are in units of millseconds.
3030
31+
#[allow(non_camel_case_types)];
32+
3133
use std::comm::Data;
3234
use std::libc;
3335
use std::ptr;

src/librustc/back/target_strs.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[allow(non_camel_case_types)];
1112

1213
pub struct t {
1314
module_asm: ~str,

src/librustc/lib/llvm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#[allow(non_uppercase_pattern_statics)];
12+
#[allow(non_camel_case_types)];
1213

1314
use std::c_str::ToCStr;
1415
use std::cell::RefCell;

src/librustc/metadata/common.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[allow(non_camel_case_types)];
12+
1113
use std::cast;
1214
use syntax::crateid::CrateId;
1315

src/librustc/metadata/creader.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[allow(non_camel_case_types)];
12+
1113
//! Validates all used crates and extern libraries and loads their metadata
1214
1315
use driver::{driver, session};

src/librustc/metadata/csearch.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// Searching for information from the cstore
1212

13+
#[allow(non_camel_case_types)];
1314

1415
use metadata::common::*;
1516
use metadata::cstore;

src/librustc/metadata/cstore.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[allow(non_camel_case_types)];
1112

1213
// The crate store - a central repo for information collected about external
1314
// crates and libraries

src/librustc/metadata/decoder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -10,6 +10,7 @@
1010

1111
// Decoding metadata from a single crate's metadata
1212

13+
#[allow(non_camel_case_types)];
1314

1415
use metadata::cstore::crate_metadata;
1516
use metadata::common::*;

src/librustc/metadata/encoder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -11,6 +11,7 @@
1111
// Metadata encoding
1212

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

1516
use metadata::common::*;
1617
use metadata::cstore;

src/librustc/metadata/filesearch.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[allow(non_camel_case_types)];
12+
1113
use std::cell::RefCell;
1214
use std::option;
1315
use std::os;

src/librustc/metadata/tydecode.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -14,6 +14,7 @@
1414
// tjc note: Would be great to have a `match check` macro equivalent
1515
// for some of these
1616

17+
#[allow(non_camel_case_types)];
1718

1819
use middle::ty;
1920

src/librustc/metadata/tyencode.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -11,6 +11,7 @@
1111
// Type encoding
1212

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

1516
use std::cell::RefCell;
1617
use std::hashmap::HashMap;

0 commit comments

Comments
 (0)