1
Fork 0

Rollup merge of #22943 - ipetkov:lint-recursion, r=alexcrichton

* The lint visitor's visit_ty method did not recurse, and had a
  reference to the now closed #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.
This commit is contained in:
Manish Goregaokar 2015-03-03 14:12:12 +05:30
commit 3b30b74692
14 changed files with 34 additions and 25 deletions

View file

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

View file

@ -1499,9 +1499,9 @@ impl<T> Extend<T> for Vec<T> {
__impl_slice_eq1! { Vec<A>, Vec<B> } __impl_slice_eq1! { Vec<A>, Vec<B> }
__impl_slice_eq2! { Vec<A>, &'b [B] } __impl_slice_eq2! { Vec<A>, &'b [B] }
__impl_slice_eq2! { Vec<A>, &'b mut [B] } __impl_slice_eq2! { Vec<A>, &'b mut [B] }
__impl_slice_eq2! { CowVec<'a, A>, &'b [B], Clone } __impl_slice_eq2! { Cow<'a, [A]>, &'b [B], Clone }
__impl_slice_eq2! { CowVec<'a, A>, &'b mut [B], Clone } __impl_slice_eq2! { Cow<'a, [A]>, &'b mut [B], Clone }
__impl_slice_eq2! { CowVec<'a, A>, Vec<B>, Clone } __impl_slice_eq2! { Cow<'a, [A]>, Vec<B>, Clone }
macro_rules! array_impls { macro_rules! array_impls {
($($N: expr)+) => { ($($N: expr)+) => {
@ -1510,9 +1510,9 @@ macro_rules! array_impls {
__impl_slice_eq2! { Vec<A>, [B; $N] } __impl_slice_eq2! { Vec<A>, [B; $N] }
__impl_slice_eq2! { Vec<A>, &'b [B; $N] } __impl_slice_eq2! { Vec<A>, &'b [B; $N] }
// __impl_slice_eq2! { Vec<A>, &'b mut [B; $N] } // __impl_slice_eq2! { Vec<A>, &'b mut [B; $N] }
// __impl_slice_eq2! { CowVec<'a, A>, [B; $N], Clone } // __impl_slice_eq2! { Cow<'a, [A]>, [B; $N], Clone }
// __impl_slice_eq2! { CowVec<'a, A>, &'b [B; $N], Clone } // __impl_slice_eq2! { Cow<'a, [A]>, &'b [B; $N], Clone }
// __impl_slice_eq2! { CowVec<'a, A>, &'b mut [B; $N], Clone } // __impl_slice_eq2! { Cow<'a, [A]>, &'b mut [B; $N], Clone }
)+ )+
} }
} }

View file

@ -1067,6 +1067,7 @@ pub struct AtomicInt {
v: UnsafeCell<int>, v: UnsafeCell<int>,
} }
#[allow(deprecated)]
unsafe impl Sync for AtomicInt {} unsafe impl Sync for AtomicInt {}
#[unstable(feature = "core")] #[unstable(feature = "core")]
@ -1077,6 +1078,7 @@ pub struct AtomicUint {
v: UnsafeCell<uint>, v: UnsafeCell<uint>,
} }
#[allow(deprecated)]
unsafe impl Sync for AtomicUint {} unsafe impl Sync for AtomicUint {}
#[unstable(feature = "core")] #[unstable(feature = "core")]

View file

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

View file

@ -935,6 +935,7 @@ impl<'a, P: Pattern<'a>> Iterator for MatchIndices<'a, P> {
#[unstable(feature = "core")] #[unstable(feature = "core")]
#[deprecated(since = "1.0.0", reason = "use `Split` with a `&str`")] #[deprecated(since = "1.0.0", reason = "use `Split` with a `&str`")]
pub struct SplitStr<'a, P: Pattern<'a>>(Split<'a, P>); pub struct SplitStr<'a, P: Pattern<'a>>(Split<'a, P>);
#[allow(deprecated)]
impl<'a, P: Pattern<'a>> Iterator for SplitStr<'a, P> { impl<'a, P: Pattern<'a>> Iterator for SplitStr<'a, P> {
type Item = &'a str; type Item = &'a str;
@ -1325,6 +1326,7 @@ pub trait StrExt {
fn split_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitTerminator<'a, P>; fn split_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitTerminator<'a, P>;
fn rsplitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> RSplitN<'a, P>; fn rsplitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> RSplitN<'a, P>;
fn match_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> MatchIndices<'a, P>; fn match_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> MatchIndices<'a, P>;
#[allow(deprecated) /* for SplitStr */]
fn split_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitStr<'a, P>; fn split_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitStr<'a, P>;
fn lines<'a>(&'a self) -> Lines<'a>; fn lines<'a>(&'a self) -> Lines<'a>;
fn lines_any<'a>(&'a self) -> LinesAny<'a>; fn lines_any<'a>(&'a self) -> LinesAny<'a>;

View file

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

View file

@ -568,9 +568,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
}) })
} }
// FIXME(#10894) should continue recursing
fn visit_ty(&mut self, t: &ast::Ty) { fn visit_ty(&mut self, t: &ast::Ty) {
run_lints!(self, check_ty, t); run_lints!(self, check_ty, t);
visit::walk_ty(self, t);
} }
fn visit_ident(&mut self, sp: Span, id: ast::Ident) { fn visit_ident(&mut self, sp: Span, id: ast::Ident) {

View file

@ -76,7 +76,7 @@ use std::hash::{Hash, SipHasher, Hasher};
use std::mem; use std::mem;
use std::ops; use std::ops;
use std::rc::Rc; use std::rc::Rc;
use std::vec::{CowVec, IntoIter}; use std::vec::IntoIter;
use collections::enum_set::{EnumSet, CLike}; use collections::enum_set::{EnumSet, CLike};
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use syntax::abi; use syntax::abi;
@ -5580,7 +5580,7 @@ pub fn predicates<'tcx>(
/// Get the attributes of a definition. /// Get the attributes of a definition.
pub fn get_attrs<'tcx>(tcx: &'tcx ctxt, did: DefId) pub fn get_attrs<'tcx>(tcx: &'tcx ctxt, did: DefId)
-> CowVec<'tcx, ast::Attribute> { -> Cow<'tcx, [ast::Attribute]> {
if is_local(did) { if is_local(did) {
let item = tcx.map.expect_item(did.node); let item = tcx.map.expect_item(did.node);
Cow::Borrowed(&item.attrs) Cow::Borrowed(&item.attrs)

View file

@ -34,10 +34,10 @@
use core::prelude::*; use core::prelude::*;
use borrow::{Borrow, ToOwned}; use borrow::{Borrow, Cow, ToOwned};
use fmt::{self, Debug}; use fmt::{self, Debug};
use mem; use mem;
use string::{String, CowString}; use string::String;
use ops; use ops;
use cmp; use cmp;
use hash::{Hash, Hasher}; use hash::{Hash, Hasher};
@ -183,10 +183,10 @@ impl OsStr {
self.inner.to_str() self.inner.to_str()
} }
/// Convert an `OsStr` to a `CowString`. /// Convert an `OsStr` to a `Cow<str>`.
/// ///
/// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER. /// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
pub fn to_string_lossy(&self) -> CowString { pub fn to_string_lossy(&self) -> Cow<str> {
self.inner.to_string_lossy() self.inner.to_string_lossy()
} }

View file

@ -38,7 +38,7 @@ use num::Int;
use ops; use ops;
use slice; use slice;
use str; use str;
use string::{String, CowString}; use string::String;
use sys_common::AsInner; use sys_common::AsInner;
use unicode::str::{Utf16Item, utf16_items}; use unicode::str::{Utf16Item, utf16_items};
use vec::Vec; use vec::Vec;
@ -530,7 +530,7 @@ impl Wtf8 {
/// Surrogates are replaced with `"\u{FFFD}"` (the replacement character “<>”). /// Surrogates are replaced with `"\u{FFFD}"` (the replacement character “<>”).
/// ///
/// This only copies the data if necessary (if it contains any surrogate). /// This only copies the data if necessary (if it contains any surrogate).
pub fn to_string_lossy(&self) -> CowString { pub fn to_string_lossy(&self) -> Cow<str> {
let surrogate_pos = match self.next_surrogate(0) { let surrogate_pos = match self.next_surrogate(0) {
None => return Cow::Borrowed(unsafe { str::from_utf8_unchecked(&self.bytes) }), None => return Cow::Borrowed(unsafe { str::from_utf8_unchecked(&self.bytes) }),
Some((pos, _)) => pos, Some((pos, _)) => pos,
@ -844,7 +844,6 @@ mod tests {
use borrow::Cow; use borrow::Cow;
use super::*; use super::*;
use mem::transmute; use mem::transmute;
use string::CowString;
#[test] #[test]
fn code_point_from_u32() { fn code_point_from_u32() {
@ -1224,7 +1223,7 @@ mod tests {
assert_eq!(Wtf8::from_str("aé 💩").to_string_lossy(), Cow::Borrowed("aé 💩")); assert_eq!(Wtf8::from_str("aé 💩").to_string_lossy(), Cow::Borrowed("aé 💩"));
let mut string = Wtf8Buf::from_str("aé 💩"); let mut string = Wtf8Buf::from_str("aé 💩");
string.push(CodePoint::from_u32(0xD800).unwrap()); string.push(CodePoint::from_u32(0xD800).unwrap());
let expected: CowString = Cow::Owned(String::from_str("aé 💩<>")); let expected: Cow<str> = Cow::Owned(String::from_str("aé 💩<>"));
assert_eq!(string.to_string_lossy(), expected); assert_eq!(string.to_string_lossy(), expected);
} }

View file

@ -13,11 +13,12 @@
use core::prelude::*; use core::prelude::*;
use borrow::Cow;
use fmt::{self, Debug}; use fmt::{self, Debug};
use vec::Vec; use vec::Vec;
use slice::SliceExt as StdSliceExt; use slice::SliceExt as StdSliceExt;
use str; use str;
use string::{String, CowString}; use string::String;
use mem; use mem;
#[derive(Clone, Hash)] #[derive(Clone, Hash)]
@ -76,7 +77,7 @@ impl Slice {
str::from_utf8(&self.inner).ok() str::from_utf8(&self.inner).ok()
} }
pub fn to_string_lossy(&self) -> CowString { pub fn to_string_lossy(&self) -> Cow<str> {
String::from_utf8_lossy(&self.inner) String::from_utf8_lossy(&self.inner)
} }

View file

@ -11,9 +11,10 @@
/// The underlying OsString/OsStr implementation on Windows is a /// The underlying OsString/OsStr implementation on Windows is a
/// wrapper around the "WTF-8" encoding; see the `wtf8` module for more. /// wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
use borrow::Cow;
use fmt::{self, Debug}; use fmt::{self, Debug};
use sys_common::wtf8::{Wtf8, Wtf8Buf}; use sys_common::wtf8::{Wtf8, Wtf8Buf};
use string::{String, CowString}; use string::String;
use result::Result; use result::Result;
use option::Option; use option::Option;
use mem; use mem;
@ -70,7 +71,7 @@ impl Slice {
self.inner.as_str() self.inner.as_str()
} }
pub fn to_string_lossy(&self) -> CowString { pub fn to_string_lossy(&self) -> Cow<str> {
self.inner.to_string_lossy() self.inner.to_string_lossy()
} }

View file

@ -119,7 +119,7 @@ macro_rules! __scoped_thread_local_inner {
const _INIT: __Key<$t> = __Key { const _INIT: __Key<$t> = __Key {
inner: ::std::thread_local::scoped::__impl::KeyInner { inner: ::std::thread_local::scoped::__impl::KeyInner {
inner: ::std::thread_local::scoped::__impl::OS_INIT, inner: ::std::thread_local::scoped::__impl::OS_INIT,
marker: ::std::marker::InvariantType, marker: ::std::marker::PhantomData::<::std::cell::Cell<$t>>,
} }
}; };
@ -244,12 +244,13 @@ mod imp {
target_arch = "aarch64"))] target_arch = "aarch64"))]
mod imp { mod imp {
use marker; use marker;
use std::cell::Cell;
use sys_common::thread_local::StaticKey as OsStaticKey; use sys_common::thread_local::StaticKey as OsStaticKey;
#[doc(hidden)] #[doc(hidden)]
pub struct KeyInner<T> { pub struct KeyInner<T> {
pub inner: OsStaticKey, pub inner: OsStaticKey,
pub marker: marker::InvariantType<T>, pub marker: marker::PhantomData<Cell<T>>,
} }
unsafe impl<T> ::marker::Sync for KeyInner<T> { } unsafe impl<T> ::marker::Sync for KeyInner<T> { }

View file

@ -9,6 +9,7 @@
// except according to those terms. // except according to those terms.
// error-pattern: too big for the current // error-pattern: too big for the current
#![allow(exceeding_bitshifts)]
fn main() { fn main() {
let fat : [u8; (1<<61)+(1<<31)] = [0; (1u64<<61) as usize +(1u64<<31) as usize]; let fat : [u8; (1<<61)+(1<<31)] = [0; (1u64<<61) as usize +(1u64<<31) as usize];