Skip to content

Commit

Permalink
Check for ident length. Fixes rust-lang#13105
Browse files Browse the repository at this point in the history
  • Loading branch information
Aatch committed Mar 24, 2014
1 parent bc37b8f commit 636d61f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1204,11 +1204,13 @@ fn check_pat_uppercase_variable(cx: &Context, p: &ast::Pat) {
// last identifier alone is right choice for this lint.
let ident = path.segments.last().unwrap().identifier;
let s = token::get_ident(ident);
if s.get().char_at(0).is_uppercase() {
cx.span_lint(
UppercaseVariables,
path.span,
"variable names should start with a lowercase character");
if s.get().len() > 0 {
if s.get().char_at(0).is_uppercase() {
cx.span_lint(
UppercaseVariables,
path.span,
"variable names should start with a lowercase character");
}
}
}
_ => {}
Expand Down
36 changes: 36 additions & 0 deletions src/test/run-pass/13105-unnamed-argument-lint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2012 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.


// Regression test for issue #13105

#[deny(uppercase_variables)];

trait Foo {
// Good
fn foo(&self);

// Good
fn bar(u8);

// Good
fn baz(&self) {

}

// ICE
fn quux(u8) {

}
}

fn main() {

}

0 comments on commit 636d61f

Please sign in to comment.