Re-implement lint with less emphasis on item ids
This way it's much easier to add lints throughout compilation correctly, and functions on impls can alter the way lints are emitted.
This commit is contained in:
parent
77c98f0815
commit
030c666cc1
16 changed files with 507 additions and 605 deletions
37
src/test/compile-fail/lint-impl-fn.rs
Normal file
37
src/test/compile-fail/lint-impl-fn.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2013 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.
|
||||
|
||||
#[allow(while_true)];
|
||||
|
||||
struct A(int);
|
||||
|
||||
impl A {
|
||||
fn foo(&self) { while true {} }
|
||||
|
||||
#[deny(while_true)]
|
||||
fn bar(&self) { while true {} } //~ ERROR: infinite loops
|
||||
}
|
||||
|
||||
#[deny(while_true)]
|
||||
mod foo {
|
||||
struct B(int);
|
||||
|
||||
impl B {
|
||||
fn foo(&self) { while true {} } //~ ERROR: infinite loops
|
||||
|
||||
#[allow(while_true)]
|
||||
fn bar(&self) { while true {} }
|
||||
}
|
||||
}
|
||||
|
||||
#[deny(while_true)]
|
||||
fn main() {
|
||||
while true {} //~ ERROR: infinite loops
|
||||
}
|
||||
|
|
@ -8,12 +8,14 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[deny(dead_assignment)];
|
||||
|
||||
fn f1(x: &mut int) {
|
||||
*x = 1; // no error
|
||||
}
|
||||
|
||||
fn f2() {
|
||||
let mut x = 3; //~ WARNING value assigned to `x` is never read
|
||||
let mut x = 3; //~ ERROR: value assigned to `x` is never read
|
||||
x = 4;
|
||||
copy x;
|
||||
}
|
||||
|
|
@ -21,10 +23,7 @@ fn f2() {
|
|||
fn f3() {
|
||||
let mut x = 3;
|
||||
copy x;
|
||||
x = 4; //~ WARNING value assigned to `x` is never read
|
||||
x = 4; //~ ERROR: value assigned to `x` is never read
|
||||
}
|
||||
|
||||
fn main() { // leave this in here just to trigger compile-fail:
|
||||
let x: int;
|
||||
copy x; //~ ERROR use of possibly uninitialized variable: `x`
|
||||
}
|
||||
fn main() {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue