Skip to content

Commit b35e8fb

Browse files
committed
auto merge of #12861 : huonw/rust/lint-owned-vecs, r=thestinger
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.
2 parents 4443fb3 + adc357a commit b35e8fb

File tree

34 files changed

+79
-3
lines changed

34 files changed

+79
-3
lines changed

src/compiletest/compiletest.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#[allow(non_camel_case_types)];
1414
#[deny(warnings)];
15+
#[allow(deprecated_owned_vector)];
1516

1617
extern crate test;
1718
extern crate getopts;

src/libarena/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#[license = "MIT/ASL2"];
2222
#[allow(missing_doc)];
2323
#[feature(managed_boxes)];
24+
#[allow(deprecated_owned_vector)];
2425

2526
extern crate collections;
2627

src/libcollections/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// NOTE remove the following two attributes after the next snapshot.
2323
#[allow(unrecognized_lint)];
2424
#[allow(default_type_param_usage)];
25+
#[allow(deprecated_owned_vector)];
2526

2627
extern crate rand;
2728

src/libextra/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Rust extras are part of the standard Rust distribution.
3131

3232
#[feature(macro_rules, globs, managed_boxes, asm, default_type_params)];
3333

34+
#[allow(deprecated_owned_vector)];
3435
#[deny(non_camel_case_types)];
3536
#[deny(missing_doc)];
3637

src/libflate/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ pub fn inflate_bytes_zlib(bytes: &[u8]) -> CVec<u8> {
9090

9191
#[cfg(test)]
9292
mod tests {
93+
#[allow(deprecated_owned_vector)];
9394
extern crate rand;
9495

9596
use super::{inflate_bytes, deflate_bytes};

src/libgetopts/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#[crate_type = "dylib"];
8282
#[license = "MIT/ASL2"];
8383
#[allow(missing_doc)];
84+
#[allow(deprecated_owned_vector)];
8485

8586
#[feature(globs)];
8687

src/libglob/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#[crate_type = "rlib"];
2828
#[crate_type = "dylib"];
2929
#[license = "MIT/ASL2"];
30+
#[allow(deprecated_owned_vector)];
3031

3132
use std::cell::Cell;
3233
use std::{cmp, os, path};

src/libgreen/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
// NB this does *not* include globs, please keep it that way.
175175
#[feature(macro_rules)];
176176
#[allow(visible_private_types)];
177+
#[allow(deprecated_owned_vector)];
177178

178179
extern crate rand;
179180

src/libnative/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
html_root_url = "http://static.rust-lang.org/doc/master")];
5151
#[deny(unused_result, unused_must_use)];
5252
#[allow(non_camel_case_types)];
53+
#[allow(deprecated_owned_vector)];
5354

5455
// NB this crate explicitly does *not* allow glob imports, please seriously
5556
// consider whether they're needed before adding that feature here (the

src/libnum/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#[crate_type = "rlib"];
1515
#[crate_type = "dylib"];
1616
#[license = "MIT/ASL2"];
17+
#[allow(deprecated_owned_vector)];
1718

1819
extern crate rand;
1920

src/librand/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ println!("{:?}", tuple_ptr)
7171
html_root_url = "http://static.rust-lang.org/doc/master")];
7272

7373
#[feature(macro_rules, managed_boxes)];
74+
#[allow(deprecated_owned_vector)];
7475

7576
use std::cast;
7677
use std::kinds::marker;

src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This API is completely unstable and subject to change.
2828
html_root_url = "http://static.rust-lang.org/doc/master")];
2929

3030
#[allow(deprecated)];
31+
#[allow(deprecated_owned_vector)];
3132
#[feature(macro_rules, globs, struct_variant, managed_boxes)];
3233
#[feature(quote, default_type_params)];
3334

src/librustc/middle/lint.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ pub enum Lint {
113113
UnusedMustUse,
114114
UnusedResult,
115115

116+
DeprecatedOwnedVector,
117+
116118
Warnings,
117119
}
118120

@@ -397,7 +399,14 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
397399
lint: UnusedResult,
398400
desc: "unused result of an expression in a statement",
399401
default: allow,
400-
})
402+
}),
403+
404+
("deprecated_owned_vector",
405+
LintSpec {
406+
lint: DeprecatedOwnedVector,
407+
desc: "use of a `~[T]` vector",
408+
default: warn
409+
}),
401410
];
402411

403412
/*
@@ -1107,6 +1116,17 @@ fn check_unused_result(cx: &Context, s: &ast::Stmt) {
11071116
}
11081117
}
11091118

1119+
fn check_deprecated_owned_vector(cx: &Context, e: &ast::Expr) {
1120+
let t = ty::expr_ty(cx.tcx, e);
1121+
match ty::get(t).sty {
1122+
ty::ty_vec(_, ty::vstore_uniq) => {
1123+
cx.span_lint(DeprecatedOwnedVector, e.span,
1124+
"use of deprecated `~[]` vector; replaced by `std::vec_ng::Vec`")
1125+
}
1126+
_ => {}
1127+
}
1128+
}
1129+
11101130
fn check_item_non_camel_case_types(cx: &Context, it: &ast::Item) {
11111131
fn is_camel_case(ident: ast::Ident) -> bool {
11121132
let ident = token::get_ident(ident);
@@ -1634,6 +1654,7 @@ impl<'a> Visitor<()> for Context<'a> {
16341654

16351655
check_type_limits(self, e);
16361656
check_unused_casts(self, e);
1657+
check_deprecated_owned_vector(self, e);
16371658

16381659
visit::walk_expr(self, e, ());
16391660
}

src/librustdoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#[crate_type = "dylib"];
1515
#[crate_type = "rlib"];
1616

17+
#[allow(deprecated_owned_vector)];
1718
#[feature(globs, struct_variant, managed_boxes, macro_rules)];
1819

1920
extern crate syntax;

src/librustdoc/test.rs

+3
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ fn maketest(s: &str, cratename: &str, loose_feature_gating: bool) -> ~str {
166166
let mut prog = ~r"
167167
#[deny(warnings)];
168168
#[allow(unused_variable, dead_assignment, unused_mut, attribute_usage, dead_code)];
169+
170+
// FIXME: remove when ~[] disappears from tests.
171+
#[allow(deprecated_owned_vector)];
169172
";
170173

171174
if loose_feature_gating {

src/librustuv/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ via `close` and `delete` methods.
4242
#[feature(macro_rules)];
4343
#[deny(unused_result, unused_must_use)];
4444
#[allow(visible_private_types)];
45+
#[allow(deprecated_owned_vector)];
4546

4647
#[cfg(test)] extern crate green;
4748

src/libsemver/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#[crate_type = "dylib"];
3434
#[license = "MIT/ASL2"];
3535

36+
#[allow(deprecated_owned_vector)];
37+
3638
use std::char;
3739
use std::cmp;
3840
use std::fmt;

src/libserialize/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Core encoding and decoding interfaces.
2525
// NOTE remove the following two attributes after the next snapshot.
2626
#[allow(unrecognized_lint)];
2727
#[allow(default_type_param_usage)];
28+
#[allow(deprecated_owned_vector)];
2829

2930
// test harness access
3031
#[cfg(test)]

src/libstd/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#[deny(non_camel_case_types)];
6666
#[deny(missing_doc)];
6767
#[allow(unknown_features)];
68+
#[allow(deprecated_owned_vector)];
6869

6970
// When testing libstd, bring in libuv as the I/O backend so tests can print
7071
// things and all of the std::io tests have an I/O interface to run on top

src/libstd/vec_ng.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Migrate documentation over from `std::vec` when it is removed.
12-
#[doc(hidden)];
11+
// Migrate documentation over from `std::vec` progressively. (This is
12+
// shown in docs so that people have something to refer too, even if
13+
// the page is rather empty.)
14+
#[allow(missing_doc)];
1315

1416
use cast::{forget, transmute};
1517
use clone::Clone;

src/libsync/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#[crate_type = "dylib"];
1818
#[license = "MIT/ASL2"];
1919

20+
#[allow(deprecated_owned_vector)];
21+
2022
pub use arc::{Arc, MutexArc, RWArc, RWWriteMode, RWReadMode, ArcCondvar, CowArc};
2123
pub use sync::{Mutex, RWLock, Condvar, Semaphore, RWLockWriteMode,
2224
RWLockReadMode, Barrier, one, mutex};

src/libsyntax/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ This API is completely unstable and subject to change.
3232

3333
#[allow(deprecated)];
3434
#[deny(non_camel_case_types)];
35+
#[allow(deprecated_owned_vector)];
3536

3637
extern crate serialize;
3738
extern crate term;

src/libterm/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#[feature(macro_rules)];
2323
#[deny(non_camel_case_types)];
2424
#[allow(missing_doc)];
25+
#[allow(deprecated_owned_vector)];
2526

2627
extern crate collections;
2728

src/libtest/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#[crate_type = "dylib"];
3131

3232
#[feature(asm)];
33+
#[allow(deprecated_owned_vector)];
3334

3435
extern crate collections;
3536
extern crate extra;

src/libtime/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#[license = "MIT/ASL2"];
1515

1616
#[allow(missing_doc)];
17+
#[allow(deprecated_owned_vector)];
1718

1819
extern crate serialize;
1920

src/libuuid/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Examples of string representations:
5959
#[crate_type = "dylib"];
6060
#[license = "MIT/ASL2"];
6161

62+
#[allow(deprecated_owned_vector)];
63+
6264
#[feature(default_type_params)];
6365

6466
// NOTE remove the following two attributes after the next snapshot.

src/test/compile-fail/issue-2150.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#[deny(unreachable_code)];
1212
#[allow(unused_variable)];
1313
#[allow(dead_code)];
14+
#[allow(deprecated_owned_vector)];
1415

1516
fn fail_len(v: ~[int]) -> uint {
1617
let mut i = 3;

src/test/compile-fail/issue-8727.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[allow(deprecated_owned_vector)];
1112

1213
// Verify the compiler fails with an error on infinite function
1314
// recursions.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[deny(deprecated_owned_vector)];
12+
13+
fn main() {
14+
~[1]; //~ ERROR use of deprecated `~[]`
15+
//~^ ERROR use of deprecated `~[]`
16+
std::vec::with_capacity::<int>(10); //~ ERROR use of deprecated `~[]`
17+
}

src/test/compile-fail/lint-heap-memory.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#[feature(managed_boxes)];
1212
#[forbid(heap_memory)];
1313
#[allow(dead_code)];
14+
#[allow(deprecated_owned_vector)];
1415

1516
struct Foo {
1617
x: @int //~ ERROR type uses managed

src/test/compile-fail/lint-unused-imports.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#[feature(globs)];
1212
#[deny(unused_imports)];
1313
#[allow(dead_code)];
14+
#[allow(deprecated_owned_vector)];
1415

1516
use cal = bar::c::cc;
1617

src/test/compile-fail/lint-unused-mut-variables.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#[allow(dead_assignment)];
1414
#[allow(unused_variable)];
1515
#[allow(dead_code)];
16+
#[allow(deprecated_owned_vector)];
1617
#[deny(unused_mut)];
1718

1819
fn main() {

src/test/compile-fail/lint-unused-unsafe.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#[allow(dead_code)];
1414
#[deny(unused_unsafe)];
15+
#[allow(deprecated_owned_vector)];
1516

1617
mod foo {
1718
extern {

src/test/run-pass/ifmt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#[feature(macro_rules)];
1414
#[deny(warnings)];
1515
#[allow(unused_must_use)];
16+
#[allow(deprecated_owned_vector)];
1617

1718
use std::fmt;
1819
use std::io::MemWriter;

0 commit comments

Comments
 (0)