From 636d61f07261be5102f6b9ec7a16e4793c66ce65 Mon Sep 17 00:00:00 2001 From: James Miller Date: Mon, 24 Mar 2014 18:06:27 +1300 Subject: [PATCH] Check for ident length. Fixes #13105 --- src/librustc/middle/lint.rs | 12 ++++--- .../run-pass/13105-unnamed-argument-lint.rs | 36 +++++++++++++++++++ 2 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 src/test/run-pass/13105-unnamed-argument-lint.rs diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 2ba8121b479ea..fdecc2aea91f2 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -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"); + } } } _ => {} diff --git a/src/test/run-pass/13105-unnamed-argument-lint.rs b/src/test/run-pass/13105-unnamed-argument-lint.rs new file mode 100644 index 0000000000000..25eb07e6eecc3 --- /dev/null +++ b/src/test/run-pass/13105-unnamed-argument-lint.rs @@ -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 or the MIT license +// , 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() { + +}