lint: add lint for use of a ~[T]
.
This is useless at the moment (since pretty much every crate uses `~[]`), but should help avoid regressions once completely removed from a crate.
This commit is contained in:
parent
6ff3c9995e
commit
62792f09f2
33 changed files with 75 additions and 1 deletions
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#[allow(non_camel_case_types)];
|
#[allow(non_camel_case_types)];
|
||||||
#[deny(warnings)];
|
#[deny(warnings)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#[license = "MIT/ASL2"];
|
#[license = "MIT/ASL2"];
|
||||||
#[allow(missing_doc)];
|
#[allow(missing_doc)];
|
||||||
#[feature(managed_boxes)];
|
#[feature(managed_boxes)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
extern crate collections;
|
extern crate collections;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
// NOTE remove the following two attributes after the next snapshot.
|
// NOTE remove the following two attributes after the next snapshot.
|
||||||
#[allow(unrecognized_lint)];
|
#[allow(unrecognized_lint)];
|
||||||
#[allow(default_type_param_usage)];
|
#[allow(default_type_param_usage)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ Rust extras are part of the standard Rust distribution.
|
||||||
|
|
||||||
#[feature(macro_rules, globs, managed_boxes, asm, default_type_params)];
|
#[feature(macro_rules, globs, managed_boxes, asm, default_type_params)];
|
||||||
|
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
#[deny(non_camel_case_types)];
|
#[deny(non_camel_case_types)];
|
||||||
#[deny(missing_doc)];
|
#[deny(missing_doc)];
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ pub fn inflate_bytes_zlib(bytes: &[u8]) -> CVec<u8> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
||||||
use super::{inflate_bytes, deflate_bytes};
|
use super::{inflate_bytes, deflate_bytes};
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
#[crate_type = "dylib"];
|
#[crate_type = "dylib"];
|
||||||
#[license = "MIT/ASL2"];
|
#[license = "MIT/ASL2"];
|
||||||
#[allow(missing_doc)];
|
#[allow(missing_doc)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
#[feature(globs)];
|
#[feature(globs)];
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#[crate_type = "rlib"];
|
#[crate_type = "rlib"];
|
||||||
#[crate_type = "dylib"];
|
#[crate_type = "dylib"];
|
||||||
#[license = "MIT/ASL2"];
|
#[license = "MIT/ASL2"];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::{cmp, os, path};
|
use std::{cmp, os, path};
|
||||||
|
|
|
@ -174,6 +174,7 @@
|
||||||
// NB this does *not* include globs, please keep it that way.
|
// NB this does *not* include globs, please keep it that way.
|
||||||
#[feature(macro_rules)];
|
#[feature(macro_rules)];
|
||||||
#[allow(visible_private_types)];
|
#[allow(visible_private_types)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
html_root_url = "http://static.rust-lang.org/doc/master")];
|
html_root_url = "http://static.rust-lang.org/doc/master")];
|
||||||
#[deny(unused_result, unused_must_use)];
|
#[deny(unused_result, unused_must_use)];
|
||||||
#[allow(non_camel_case_types)];
|
#[allow(non_camel_case_types)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
// NB this crate explicitly does *not* allow glob imports, please seriously
|
// NB this crate explicitly does *not* allow glob imports, please seriously
|
||||||
// consider whether they're needed before adding that feature here (the
|
// consider whether they're needed before adding that feature here (the
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#[crate_type = "rlib"];
|
#[crate_type = "rlib"];
|
||||||
#[crate_type = "dylib"];
|
#[crate_type = "dylib"];
|
||||||
#[license = "MIT/ASL2"];
|
#[license = "MIT/ASL2"];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ println!("{:?}", tuple_ptr)
|
||||||
html_root_url = "http://static.rust-lang.org/doc/master")];
|
html_root_url = "http://static.rust-lang.org/doc/master")];
|
||||||
|
|
||||||
#[feature(macro_rules, managed_boxes)];
|
#[feature(macro_rules, managed_boxes)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
use std::cast;
|
use std::cast;
|
||||||
use std::kinds::marker;
|
use std::kinds::marker;
|
||||||
|
|
|
@ -28,6 +28,7 @@ This API is completely unstable and subject to change.
|
||||||
html_root_url = "http://static.rust-lang.org/doc/master")];
|
html_root_url = "http://static.rust-lang.org/doc/master")];
|
||||||
|
|
||||||
#[allow(deprecated)];
|
#[allow(deprecated)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
#[feature(macro_rules, globs, struct_variant, managed_boxes)];
|
#[feature(macro_rules, globs, struct_variant, managed_boxes)];
|
||||||
#[feature(quote, default_type_params)];
|
#[feature(quote, default_type_params)];
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,8 @@ pub enum Lint {
|
||||||
UnusedMustUse,
|
UnusedMustUse,
|
||||||
UnusedResult,
|
UnusedResult,
|
||||||
|
|
||||||
|
DeprecatedOwnedVector,
|
||||||
|
|
||||||
Warnings,
|
Warnings,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +399,14 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
|
||||||
lint: UnusedResult,
|
lint: UnusedResult,
|
||||||
desc: "unused result of an expression in a statement",
|
desc: "unused result of an expression in a statement",
|
||||||
default: allow,
|
default: allow,
|
||||||
})
|
}),
|
||||||
|
|
||||||
|
("deprecated_owned_vector",
|
||||||
|
LintSpec {
|
||||||
|
lint: DeprecatedOwnedVector,
|
||||||
|
desc: "use of a `~[T]` vector",
|
||||||
|
default: warn
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1107,6 +1116,17 @@ fn check_unused_result(cx: &Context, s: &ast::Stmt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn check_deprecated_owned_vector(cx: &Context, e: &ast::Expr) {
|
||||||
|
let t = ty::expr_ty(cx.tcx, e);
|
||||||
|
match ty::get(t).sty {
|
||||||
|
ty::ty_vec(_, ty::vstore_uniq) => {
|
||||||
|
cx.span_lint(DeprecatedOwnedVector, e.span,
|
||||||
|
"use of deprecated `~[]` vector; replaced by `std::vec_ng::Vec`")
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn check_item_non_camel_case_types(cx: &Context, it: &ast::Item) {
|
fn check_item_non_camel_case_types(cx: &Context, it: &ast::Item) {
|
||||||
fn is_camel_case(ident: ast::Ident) -> bool {
|
fn is_camel_case(ident: ast::Ident) -> bool {
|
||||||
let ident = token::get_ident(ident);
|
let ident = token::get_ident(ident);
|
||||||
|
@ -1634,6 +1654,7 @@ impl<'a> Visitor<()> for Context<'a> {
|
||||||
|
|
||||||
check_type_limits(self, e);
|
check_type_limits(self, e);
|
||||||
check_unused_casts(self, e);
|
check_unused_casts(self, e);
|
||||||
|
check_deprecated_owned_vector(self, e);
|
||||||
|
|
||||||
visit::walk_expr(self, e, ());
|
visit::walk_expr(self, e, ());
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#[crate_type = "dylib"];
|
#[crate_type = "dylib"];
|
||||||
#[crate_type = "rlib"];
|
#[crate_type = "rlib"];
|
||||||
|
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
#[feature(globs, struct_variant, managed_boxes, macro_rules)];
|
#[feature(globs, struct_variant, managed_boxes, macro_rules)];
|
||||||
|
|
||||||
extern crate syntax;
|
extern crate syntax;
|
||||||
|
|
|
@ -166,6 +166,9 @@ fn maketest(s: &str, cratename: &str, loose_feature_gating: bool) -> ~str {
|
||||||
let mut prog = ~r"
|
let mut prog = ~r"
|
||||||
#[deny(warnings)];
|
#[deny(warnings)];
|
||||||
#[allow(unused_variable, dead_assignment, unused_mut, attribute_usage, dead_code)];
|
#[allow(unused_variable, dead_assignment, unused_mut, attribute_usage, dead_code)];
|
||||||
|
|
||||||
|
// FIXME: remove when ~[] disappears from tests.
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
";
|
";
|
||||||
|
|
||||||
if loose_feature_gating {
|
if loose_feature_gating {
|
||||||
|
|
|
@ -42,6 +42,7 @@ via `close` and `delete` methods.
|
||||||
#[feature(macro_rules)];
|
#[feature(macro_rules)];
|
||||||
#[deny(unused_result, unused_must_use)];
|
#[deny(unused_result, unused_must_use)];
|
||||||
#[allow(visible_private_types)];
|
#[allow(visible_private_types)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
#[cfg(test)] extern crate green;
|
#[cfg(test)] extern crate green;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#[crate_type = "dylib"];
|
#[crate_type = "dylib"];
|
||||||
#[license = "MIT/ASL2"];
|
#[license = "MIT/ASL2"];
|
||||||
|
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
use std::char;
|
use std::char;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
|
@ -25,6 +25,7 @@ Core encoding and decoding interfaces.
|
||||||
// NOTE remove the following two attributes after the next snapshot.
|
// NOTE remove the following two attributes after the next snapshot.
|
||||||
#[allow(unrecognized_lint)];
|
#[allow(unrecognized_lint)];
|
||||||
#[allow(default_type_param_usage)];
|
#[allow(default_type_param_usage)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
// test harness access
|
// test harness access
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
#[deny(non_camel_case_types)];
|
#[deny(non_camel_case_types)];
|
||||||
#[deny(missing_doc)];
|
#[deny(missing_doc)];
|
||||||
#[allow(unknown_features)];
|
#[allow(unknown_features)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
// When testing libstd, bring in libuv as the I/O backend so tests can print
|
// When testing libstd, bring in libuv as the I/O backend so tests can print
|
||||||
// things and all of the std::io tests have an I/O interface to run on top
|
// things and all of the std::io tests have an I/O interface to run on top
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#[crate_type = "dylib"];
|
#[crate_type = "dylib"];
|
||||||
#[license = "MIT/ASL2"];
|
#[license = "MIT/ASL2"];
|
||||||
|
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
pub use arc::{Arc, MutexArc, RWArc, RWWriteMode, RWReadMode, ArcCondvar, CowArc};
|
pub use arc::{Arc, MutexArc, RWArc, RWWriteMode, RWReadMode, ArcCondvar, CowArc};
|
||||||
pub use sync::{Mutex, RWLock, Condvar, Semaphore, RWLockWriteMode,
|
pub use sync::{Mutex, RWLock, Condvar, Semaphore, RWLockWriteMode,
|
||||||
RWLockReadMode, Barrier, one, mutex};
|
RWLockReadMode, Barrier, one, mutex};
|
||||||
|
|
|
@ -32,6 +32,7 @@ This API is completely unstable and subject to change.
|
||||||
|
|
||||||
#[allow(deprecated)];
|
#[allow(deprecated)];
|
||||||
#[deny(non_camel_case_types)];
|
#[deny(non_camel_case_types)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
extern crate serialize;
|
extern crate serialize;
|
||||||
extern crate term;
|
extern crate term;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#[feature(macro_rules)];
|
#[feature(macro_rules)];
|
||||||
#[deny(non_camel_case_types)];
|
#[deny(non_camel_case_types)];
|
||||||
#[allow(missing_doc)];
|
#[allow(missing_doc)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
extern crate collections;
|
extern crate collections;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#[crate_type = "dylib"];
|
#[crate_type = "dylib"];
|
||||||
|
|
||||||
#[feature(asm)];
|
#[feature(asm)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
extern crate collections;
|
extern crate collections;
|
||||||
extern crate extra;
|
extern crate extra;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#[license = "MIT/ASL2"];
|
#[license = "MIT/ASL2"];
|
||||||
|
|
||||||
#[allow(missing_doc)];
|
#[allow(missing_doc)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
extern crate serialize;
|
extern crate serialize;
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,8 @@ Examples of string representations:
|
||||||
#[crate_type = "dylib"];
|
#[crate_type = "dylib"];
|
||||||
#[license = "MIT/ASL2"];
|
#[license = "MIT/ASL2"];
|
||||||
|
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
#[feature(default_type_params)];
|
#[feature(default_type_params)];
|
||||||
|
|
||||||
// NOTE remove the following two attributes after the next snapshot.
|
// NOTE remove the following two attributes after the next snapshot.
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#[deny(unreachable_code)];
|
#[deny(unreachable_code)];
|
||||||
#[allow(unused_variable)];
|
#[allow(unused_variable)];
|
||||||
#[allow(dead_code)];
|
#[allow(dead_code)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
fn fail_len(v: ~[int]) -> uint {
|
fn fail_len(v: ~[int]) -> uint {
|
||||||
let mut i = 3;
|
let mut i = 3;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
// Verify the compiler fails with an error on infinite function
|
// Verify the compiler fails with an error on infinite function
|
||||||
// recursions.
|
// recursions.
|
||||||
|
|
17
src/test/compile-fail/lint-deprecated-owned-vector.rs
Normal file
17
src/test/compile-fail/lint-deprecated-owned-vector.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
#[deny(deprecated_owned_vector)];
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
~[1]; //~ ERROR use of deprecated `~[]`
|
||||||
|
//~^ ERROR use of deprecated `~[]`
|
||||||
|
std::vec::with_capacity::<int>(10); //~ ERROR use of deprecated `~[]`
|
||||||
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
#[feature(managed_boxes)];
|
#[feature(managed_boxes)];
|
||||||
#[forbid(heap_memory)];
|
#[forbid(heap_memory)];
|
||||||
#[allow(dead_code)];
|
#[allow(dead_code)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
x: @int //~ ERROR type uses managed
|
x: @int //~ ERROR type uses managed
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#[feature(globs)];
|
#[feature(globs)];
|
||||||
#[deny(unused_imports)];
|
#[deny(unused_imports)];
|
||||||
#[allow(dead_code)];
|
#[allow(dead_code)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
use cal = bar::c::cc;
|
use cal = bar::c::cc;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#[allow(dead_assignment)];
|
#[allow(dead_assignment)];
|
||||||
#[allow(unused_variable)];
|
#[allow(unused_variable)];
|
||||||
#[allow(dead_code)];
|
#[allow(dead_code)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
#[deny(unused_mut)];
|
#[deny(unused_mut)];
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#[allow(dead_code)];
|
#[allow(dead_code)];
|
||||||
#[deny(unused_unsafe)];
|
#[deny(unused_unsafe)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
mod foo {
|
mod foo {
|
||||||
extern {
|
extern {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#[feature(macro_rules)];
|
#[feature(macro_rules)];
|
||||||
#[deny(warnings)];
|
#[deny(warnings)];
|
||||||
#[allow(unused_must_use)];
|
#[allow(unused_must_use)];
|
||||||
|
#[allow(deprecated_owned_vector)];
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::io::MemWriter;
|
use std::io::MemWriter;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue