about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-03-04 22:06:38 -0800
committerbors <bors@rust-lang.org>2014-03-04 22:06:38 -0800
commit712c630ab6bc67a934311c0e31ead3a46ae1a75f (patch)
treec2adb219abe4b1a5d8e414c099246053d15683ad /src/rustllvm/RustWrapper.cpp
parent3cc761f3f97b0a5ff5e355430bb4e52b15f567b6 (diff)
parent258dbd09ba4aa868b373df7e82721ba0c40167ba (diff)
downloadrust-712c630ab6bc67a934311c0e31ead3a46ae1a75f.tar.gz
rust-712c630ab6bc67a934311c0e31ead3a46ae1a75f.zip
auto merge of #12300 : DaGenix/rust/uppercase-variable-lint, r=alexcrichton
I added a new lint for variables whose names contain uppercase characters, since, by convention, variable names should be all lowercase. What motivated me to work on this was when I ran into something like the following:

```rust
use std::io::File;
use std::io::IoError;

fn main() {
    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_str()),
    }
}
```

I then got compile errors when I tried to add a wildcard match pattern at the end which I found very confusing since I believed that the 2nd match arm was only matching the EndOfFile condition. The problem is that I hadn't imported io::EndOfFile into the local scope. So, I thought that I was using EndOfFile as a sub-pattern, however, what I was actually doing was creating a new local variable named EndOfFile. This lint makes this error easier to spot by providing a warning that the variable name EndOfFile contains a uppercase characters which provides a nice hint as to why the code isn't doing what is intended.

The lint warns on local bindings as well:

```rust
let Hi = 0;
```

And also struct fields:

```rust
struct Something {
    X: uint
}
```
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions