Skip to content

Commit 3b30b74

Browse files
committed
Rollup merge of rust-lang#22943 - ipetkov:lint-recursion, r=alexcrichton
* The lint visitor's visit_ty method did not recurse, and had a reference to the now closed rust-lang#10894 * The newly enabled recursion has only affected the `deprectated` lint which now detects uses of deprecated items in trait impls and function return types * Renamed some references to `CowString` and `CowVec` to `Cow<str>` and `Cow<[T]>`, respectively, which appear outside of the crate which defines them * Replaced a few instances of `InvariantType<T>` with `PhantomData<Cell<T>>` * Disabled the `deprecated` lint in several places that reference/implement traits on deprecated items which will get cleaned up in the future * Unfortunately, this means that if a library declares `#![deny(deprecated)]` and marks anything as deprecated, it will have to disable the lint for any uses of said item, e.g. any impl the now deprecated item For any library that denies deprecated items but has deprecated items of its own, this is a [breaking-change] I had originally intended for the lint to ignore uses of deprecated items that are declared in the same crate, but this goes against some previous test cases that expect the lint to capture *all* uses of deprecated items, so I maintained the previous approach to avoid changing the expected behavior of the lint. Tested locally on OS X, so hopefully there aren't any deprecated item uses behind a `cfg` that I may have missed.
2 parents 63a91c2 + 2b03718 commit 3b30b74

File tree

14 files changed

+34
-25
lines changed

14 files changed

+34
-25
lines changed

src/libcollections/str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
756756
/// ```
757757
#[unstable(feature = "collections")]
758758
#[deprecated(since = "1.0.0", reason = "use `split()` with a `&str`")]
759+
#[allow(deprecated) /* for SplitStr */]
759760
fn split_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitStr<'a, P> {
760761
core_str::StrExt::split_str(&self[..], pat)
761762
}

src/libcollections/vec.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1499,9 +1499,9 @@ impl<T> Extend<T> for Vec<T> {
14991499
__impl_slice_eq1! { Vec<A>, Vec<B> }
15001500
__impl_slice_eq2! { Vec<A>, &'b [B] }
15011501
__impl_slice_eq2! { Vec<A>, &'b mut [B] }
1502-
__impl_slice_eq2! { CowVec<'a, A>, &'b [B], Clone }
1503-
__impl_slice_eq2! { CowVec<'a, A>, &'b mut [B], Clone }
1504-
__impl_slice_eq2! { CowVec<'a, A>, Vec<B>, Clone }
1502+
__impl_slice_eq2! { Cow<'a, [A]>, &'b [B], Clone }
1503+
__impl_slice_eq2! { Cow<'a, [A]>, &'b mut [B], Clone }
1504+
__impl_slice_eq2! { Cow<'a, [A]>, Vec<B>, Clone }
15051505

15061506
macro_rules! array_impls {
15071507
($($N: expr)+) => {
@@ -1510,9 +1510,9 @@ macro_rules! array_impls {
15101510
__impl_slice_eq2! { Vec<A>, [B; $N] }
15111511
__impl_slice_eq2! { Vec<A>, &'b [B; $N] }
15121512
// __impl_slice_eq2! { Vec<A>, &'b mut [B; $N] }
1513-
// __impl_slice_eq2! { CowVec<'a, A>, [B; $N], Clone }
1514-
// __impl_slice_eq2! { CowVec<'a, A>, &'b [B; $N], Clone }
1515-
// __impl_slice_eq2! { CowVec<'a, A>, &'b mut [B; $N], Clone }
1513+
// __impl_slice_eq2! { Cow<'a, [A]>, [B; $N], Clone }
1514+
// __impl_slice_eq2! { Cow<'a, [A]>, &'b [B; $N], Clone }
1515+
// __impl_slice_eq2! { Cow<'a, [A]>, &'b mut [B; $N], Clone }
15161516
)+
15171517
}
15181518
}

src/libcore/atomic.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,7 @@ pub struct AtomicInt {
10671067
v: UnsafeCell<int>,
10681068
}
10691069

1070+
#[allow(deprecated)]
10701071
unsafe impl Sync for AtomicInt {}
10711072

10721073
#[unstable(feature = "core")]
@@ -1077,6 +1078,7 @@ pub struct AtomicUint {
10771078
v: UnsafeCell<uint>,
10781079
}
10791080

1081+
#[allow(deprecated)]
10801082
unsafe impl Sync for AtomicUint {}
10811083

10821084
#[unstable(feature = "core")]

src/libcore/raw.rs

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ impl<T> Copy for Slice<T> {}
7070
#[deprecated(reason = "unboxed new closures do not have a universal representation; \
7171
`&Fn` (etc) trait objects should use `TraitObject` instead",
7272
since= "1.0.0")]
73+
#[allow(deprecated) /* for deriving Copy impl */]
7374
pub struct Closure {
7475
pub code: *mut (),
7576
pub env: *mut (),

src/libcore/str/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ impl<'a, P: Pattern<'a>> Iterator for MatchIndices<'a, P> {
935935
#[unstable(feature = "core")]
936936
#[deprecated(since = "1.0.0", reason = "use `Split` with a `&str`")]
937937
pub struct SplitStr<'a, P: Pattern<'a>>(Split<'a, P>);
938+
#[allow(deprecated)]
938939
impl<'a, P: Pattern<'a>> Iterator for SplitStr<'a, P> {
939940
type Item = &'a str;
940941

@@ -1325,6 +1326,7 @@ pub trait StrExt {
13251326
fn split_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitTerminator<'a, P>;
13261327
fn rsplitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> RSplitN<'a, P>;
13271328
fn match_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> MatchIndices<'a, P>;
1329+
#[allow(deprecated) /* for SplitStr */]
13281330
fn split_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitStr<'a, P>;
13291331
fn lines<'a>(&'a self) -> Lines<'a>;
13301332
fn lines_any<'a>(&'a self) -> LinesAny<'a>;

src/libgraphviz/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
//! Each node label is derived directly from the int representing the node,
3838
//! while the edge labels are all empty strings.
3939
//!
40-
//! This example also illustrates how to use `CowVec` to return
40+
//! This example also illustrates how to use `Cow<[T]>` to return
4141
//! an owned vector or a borrowed slice as appropriate: we construct the
4242
//! node vector from scratch, but borrow the edge list (rather than
4343
//! constructing a copy of all the edges from scratch).
@@ -502,7 +502,7 @@ pub type Edges<'a,E> = Cow<'a,[E]>;
502502
/// that is bound by the self lifetime `'a`.
503503
///
504504
/// The `nodes` and `edges` method each return instantiations of
505-
/// `CowVec` to leave implementers the freedom to create
505+
/// `Cow<[T]>` to leave implementers the freedom to create
506506
/// entirely new vectors or to pass back slices into internally owned
507507
/// vectors.
508508
pub trait GraphWalk<'a, N, E> {

src/librustc/lint/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
568568
})
569569
}
570570

571-
// FIXME(#10894) should continue recursing
572571
fn visit_ty(&mut self, t: &ast::Ty) {
573572
run_lints!(self, check_ty, t);
573+
visit::walk_ty(self, t);
574574
}
575575

576576
fn visit_ident(&mut self, sp: Span, id: ast::Ident) {

src/librustc/middle/ty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ use std::hash::{Hash, SipHasher, Hasher};
7676
use std::mem;
7777
use std::ops;
7878
use std::rc::Rc;
79-
use std::vec::{CowVec, IntoIter};
79+
use std::vec::IntoIter;
8080
use collections::enum_set::{EnumSet, CLike};
8181
use std::collections::{HashMap, HashSet};
8282
use syntax::abi;
@@ -5580,7 +5580,7 @@ pub fn predicates<'tcx>(
55805580

55815581
/// Get the attributes of a definition.
55825582
pub fn get_attrs<'tcx>(tcx: &'tcx ctxt, did: DefId)
5583-
-> CowVec<'tcx, ast::Attribute> {
5583+
-> Cow<'tcx, [ast::Attribute]> {
55845584
if is_local(did) {
55855585
let item = tcx.map.expect_item(did.node);
55865586
Cow::Borrowed(&item.attrs)

src/libstd/ffi/os_str.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434

3535
use core::prelude::*;
3636

37-
use borrow::{Borrow, ToOwned};
37+
use borrow::{Borrow, Cow, ToOwned};
3838
use fmt::{self, Debug};
3939
use mem;
40-
use string::{String, CowString};
40+
use string::String;
4141
use ops;
4242
use cmp;
4343
use hash::{Hash, Hasher};
@@ -183,10 +183,10 @@ impl OsStr {
183183
self.inner.to_str()
184184
}
185185

186-
/// Convert an `OsStr` to a `CowString`.
186+
/// Convert an `OsStr` to a `Cow<str>`.
187187
///
188188
/// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
189-
pub fn to_string_lossy(&self) -> CowString {
189+
pub fn to_string_lossy(&self) -> Cow<str> {
190190
self.inner.to_string_lossy()
191191
}
192192

src/libstd/sys/common/wtf8.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use num::Int;
3838
use ops;
3939
use slice;
4040
use str;
41-
use string::{String, CowString};
41+
use string::String;
4242
use sys_common::AsInner;
4343
use unicode::str::{Utf16Item, utf16_items};
4444
use vec::Vec;
@@ -530,7 +530,7 @@ impl Wtf8 {
530530
/// Surrogates are replaced with `"\u{FFFD}"` (the replacement character “�”).
531531
///
532532
/// This only copies the data if necessary (if it contains any surrogate).
533-
pub fn to_string_lossy(&self) -> CowString {
533+
pub fn to_string_lossy(&self) -> Cow<str> {
534534
let surrogate_pos = match self.next_surrogate(0) {
535535
None => return Cow::Borrowed(unsafe { str::from_utf8_unchecked(&self.bytes) }),
536536
Some((pos, _)) => pos,
@@ -844,7 +844,6 @@ mod tests {
844844
use borrow::Cow;
845845
use super::*;
846846
use mem::transmute;
847-
use string::CowString;
848847

849848
#[test]
850849
fn code_point_from_u32() {
@@ -1224,7 +1223,7 @@ mod tests {
12241223
assert_eq!(Wtf8::from_str("aé 💩").to_string_lossy(), Cow::Borrowed("aé 💩"));
12251224
let mut string = Wtf8Buf::from_str("aé 💩");
12261225
string.push(CodePoint::from_u32(0xD800).unwrap());
1227-
let expected: CowString = Cow::Owned(String::from_str("aé 💩�"));
1226+
let expected: Cow<str> = Cow::Owned(String::from_str("aé 💩�"));
12281227
assert_eq!(string.to_string_lossy(), expected);
12291228
}
12301229

src/libstd/sys/unix/os_str.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
1414
use core::prelude::*;
1515

16+
use borrow::Cow;
1617
use fmt::{self, Debug};
1718
use vec::Vec;
1819
use slice::SliceExt as StdSliceExt;
1920
use str;
20-
use string::{String, CowString};
21+
use string::String;
2122
use mem;
2223

2324
#[derive(Clone, Hash)]
@@ -76,7 +77,7 @@ impl Slice {
7677
str::from_utf8(&self.inner).ok()
7778
}
7879

79-
pub fn to_string_lossy(&self) -> CowString {
80+
pub fn to_string_lossy(&self) -> Cow<str> {
8081
String::from_utf8_lossy(&self.inner)
8182
}
8283

src/libstd/sys/windows/os_str.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
/// The underlying OsString/OsStr implementation on Windows is a
1212
/// wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
1313
14+
use borrow::Cow;
1415
use fmt::{self, Debug};
1516
use sys_common::wtf8::{Wtf8, Wtf8Buf};
16-
use string::{String, CowString};
17+
use string::String;
1718
use result::Result;
1819
use option::Option;
1920
use mem;
@@ -70,7 +71,7 @@ impl Slice {
7071
self.inner.as_str()
7172
}
7273

73-
pub fn to_string_lossy(&self) -> CowString {
74+
pub fn to_string_lossy(&self) -> Cow<str> {
7475
self.inner.to_string_lossy()
7576
}
7677

src/libstd/thread_local/scoped.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ macro_rules! __scoped_thread_local_inner {
119119
const _INIT: __Key<$t> = __Key {
120120
inner: ::std::thread_local::scoped::__impl::KeyInner {
121121
inner: ::std::thread_local::scoped::__impl::OS_INIT,
122-
marker: ::std::marker::InvariantType,
122+
marker: ::std::marker::PhantomData::<::std::cell::Cell<$t>>,
123123
}
124124
};
125125

@@ -244,12 +244,13 @@ mod imp {
244244
target_arch = "aarch64"))]
245245
mod imp {
246246
use marker;
247+
use std::cell::Cell;
247248
use sys_common::thread_local::StaticKey as OsStaticKey;
248249

249250
#[doc(hidden)]
250251
pub struct KeyInner<T> {
251252
pub inner: OsStaticKey,
252-
pub marker: marker::InvariantType<T>,
253+
pub marker: marker::PhantomData<Cell<T>>,
253254
}
254255

255256
unsafe impl<T> ::marker::Sync for KeyInner<T> { }

src/test/compile-fail/huge-array-simple.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// error-pattern: too big for the current
12+
#![allow(exceeding_bitshifts)]
1213

1314
fn main() {
1415
let fat : [u8; (1<<61)+(1<<31)] = [0; (1u64<<61) as usize +(1u64<<31) as usize];

0 commit comments

Comments
 (0)