Skip to content

Commit 184b99d

Browse files
committed
Merge branch 'pr-2889'
2 parents 5e92e7a + aad450e commit 184b99d

File tree

10 files changed

+80
-33
lines changed

10 files changed

+80
-33
lines changed

Cargo.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,46 @@ clippy_lints = { version = "0.0.211", path = "clippy_lints" }
4545
regex = "1"
4646
semver = "0.9"
4747

48+
# Not actually needed right now but required to make sure that clippy/ and cargo build
49+
# with the same set of features in rust-lang/rust
50+
num-traits = "0.2" # enable the default feature
51+
backtrace = "0.3"
52+
53+
# keep in sync with `cargo`'s `Cargo.toml'
54+
[target.'cfg(windows)'.dependencies.winapi]
55+
version = "0.3"
56+
features = [
57+
# keep in sync with `cargo`'s `Cargo.toml'
58+
"handleapi",
59+
"jobapi",
60+
"jobapi2",
61+
"minwindef",
62+
"ntdef",
63+
"ntstatus",
64+
"processenv",
65+
"processthreadsapi",
66+
"psapi",
67+
"synchapi",
68+
"winerror",
69+
"winbase",
70+
"wincon",
71+
"winnt",
72+
# no idea where these come from
73+
"basetsd",
74+
"lmcons",
75+
"memoryapi",
76+
"minschannel",
77+
"minwinbase",
78+
"ntsecapi",
79+
"profileapi",
80+
"schannel",
81+
"securitybaseapi",
82+
"synchapi",
83+
"sysinfoapi",
84+
"timezoneapi",
85+
"wincrypt",
86+
]
87+
4888
[dev-dependencies]
4989
cargo_metadata = "0.5"
5090
compiletest_rs = "0.3.7"

clippy_lints/src/consts.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use std::mem;
1313
use std::rc::Rc;
1414
use syntax::ast::{FloatTy, LitKind};
1515
use syntax::ptr::P;
16-
use rustc::middle::const_val::ConstVal;
1716
use crate::utils::{sext, unsext, clip};
1817

1918
#[derive(Debug, Copy, Clone)]
@@ -428,15 +427,15 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
428427
pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'tcx>) -> Option<Constant> {
429428
use rustc::mir::interpret::{Scalar, ConstValue};
430429
match result.val {
431-
ConstVal::Value(ConstValue::Scalar(Scalar::Bits{ bits: b, ..})) => match result.ty.sty {
430+
ConstValue::Scalar(Scalar::Bits{ bits: b, ..}) => match result.ty.sty {
432431
ty::TyBool => Some(Constant::Bool(b == 1)),
433432
ty::TyUint(_) | ty::TyInt(_) => Some(Constant::Int(b)),
434433
ty::TyFloat(FloatTy::F32) => Some(Constant::F32(f32::from_bits(b as u32))),
435434
ty::TyFloat(FloatTy::F64) => Some(Constant::F64(f64::from_bits(b as u64))),
436435
// FIXME: implement other conversion
437436
_ => None,
438437
},
439-
ConstVal::Value(ConstValue::ScalarPair(Scalar::Ptr(ptr), Scalar::Bits { bits: n, .. })) => match result.ty.sty {
438+
ConstValue::ScalarPair(Scalar::Ptr(ptr), Scalar::Bits { bits: n, .. }) => match result.ty.sty {
440439
ty::TyRef(_, tam, _) => match tam.sty {
441440
ty::TyStr => {
442441
let alloc = tcx

clippy_lints/src/enum_glob_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EnumGlobUse {
4444

4545
impl EnumGlobUse {
4646
fn lint_item(&self, cx: &LateContext, item: &Item) {
47-
if item.vis == Visibility::Public {
47+
if item.vis.node == VisibilityKind::Public {
4848
return; // re-exports are fine
4949
}
5050
if let ItemUse(ref path, UseKind::Glob) = item.node {

clippy_lints/src/escape.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
108108
return;
109109
}
110110
if let Categorization::Rvalue(..) = cmt.cat {
111-
if let Some(NodeStmt(st)) = map.find(map.get_parent_node(cmt.id)) {
111+
let id = map.hir_to_node_id(cmt.hir_id);
112+
if let Some(NodeStmt(st)) = map.find(map.get_parent_node(id)) {
112113
if let StmtDecl(ref decl, _) = st.node {
113114
if let DeclLocal(ref loc) = decl.node {
114115
if let Some(ref ex) = loc.init {

clippy_lints/src/lifetimes.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,23 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
342342
self.record(&None);
343343
},
344344
TyPath(ref path) => {
345-
self.collect_anonymous_lifetimes(path, ty);
346-
},
347-
TyImplTraitExistential(exist_ty_id, _, _) => {
348-
if let ItemExistential(ref exist_ty) = self.cx.tcx.hir.expect_item(exist_ty_id.id).node {
349-
for bound in &exist_ty.bounds {
350-
if let GenericBound::Outlives(_) = *bound {
351-
self.record(&None);
345+
if let QPath::Resolved(_, ref path) = *path {
346+
if let Def::Existential(def_id) = path.def {
347+
let node_id = self.cx.tcx.hir.as_local_node_id(def_id).unwrap();
348+
if let ItemExistential(ref exist_ty) = self.cx.tcx.hir.expect_item(node_id).node {
349+
for bound in &exist_ty.bounds {
350+
if let GenericBound::Outlives(_) = *bound {
351+
self.record(&None);
352+
}
353+
}
354+
} else {
355+
unreachable!()
352356
}
357+
walk_ty(self, ty);
358+
return;
353359
}
354360
}
361+
self.collect_anonymous_lifetimes(path, ty);
355362
}
356363
TyTraitObject(ref bounds, ref lt) => {
357364
if !lt.is_elided() {

clippy_lints/src/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
840840
.iter()
841841
.any(|k| k.matches(first_arg_ty, first_arg, self_ty, is_copy, &implitem.generics));
842842
then {
843-
let lint = if item.vis == hir::Visibility::Public {
843+
let lint = if item.vis.node == hir::VisibilityKind::Public {
844844
WRONG_PUB_SELF_CONVENTION
845845
} else {
846846
WRONG_SELF_CONVENTION

clippy_lints/src/utils/inspector.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
5151
return;
5252
}
5353
println!("impl item `{}`", item.ident.name);
54-
match item.vis {
55-
hir::Visibility::Public => println!("public"),
56-
hir::Visibility::Crate(_) => println!("visible crate wide"),
57-
hir::Visibility::Restricted { ref path, .. } => println!(
54+
match item.vis.node {
55+
hir::VisibilityKind::Public => println!("public"),
56+
hir::VisibilityKind::Crate(_) => println!("visible crate wide"),
57+
hir::VisibilityKind::Restricted { ref path, .. } => println!(
5858
"visible in module `{}`",
5959
print::to_string(print::NO_ANN, |s| s.print_path(path, false))
6060
),
61-
hir::Visibility::Inherited => println!("visibility inherited from outer item"),
61+
hir::VisibilityKind::Inherited => println!("visibility inherited from outer item"),
6262
}
6363
if item.defaultness.is_default() {
6464
println!("default");
@@ -343,14 +343,14 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
343343
fn print_item(cx: &LateContext, item: &hir::Item) {
344344
let did = cx.tcx.hir.local_def_id(item.id);
345345
println!("item `{}`", item.name);
346-
match item.vis {
347-
hir::Visibility::Public => println!("public"),
348-
hir::Visibility::Crate(_) => println!("visible crate wide"),
349-
hir::Visibility::Restricted { ref path, .. } => println!(
346+
match item.vis.node {
347+
hir::VisibilityKind::Public => println!("public"),
348+
hir::VisibilityKind::Crate(_) => println!("visible crate wide"),
349+
hir::VisibilityKind::Restricted { ref path, .. } => println!(
350350
"visible in module `{}`",
351351
print::to_string(print::NO_ANN, |s| s.print_path(path, false))
352352
),
353-
hir::Visibility::Inherited => println!("visibility inherited from outer item"),
353+
hir::VisibilityKind::Inherited => println!("visibility inherited from outer item"),
354354
}
355355
match item.node {
356356
hir::ItemExternCrate(ref _renamed_from) => {

clippy_lints/src/utils/internal_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
120120
if let ItemStatic(ref ty, MutImmutable, body_id) = item.node {
121121
if is_lint_ref_type(ty) {
122122
self.declared_lints.insert(item.name, item.span);
123-
} else if is_lint_array_type(ty) && item.vis == Visibility::Inherited && item.name == "ARRAY" {
123+
} else if is_lint_array_type(ty) && item.vis.node == VisibilityKind::Inherited && item.name == "ARRAY" {
124124
let mut collector = LintCollector {
125125
output: &mut self.registered_lints,
126126
cx,

clippy_lints/src/utils/paths.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
//! about.
33
44
pub const ANY_TRAIT: [&str; 3] = ["std", "any", "Any"];
5-
pub const ARC: [&str; 3] = ["alloc", "arc", "Arc"];
5+
pub const ARC: [&str; 3] = ["alloc", "sync", "Arc"];
66
pub const ASMUT_TRAIT: [&str; 3] = ["core", "convert", "AsMut"];
77
pub const ASREF_TRAIT: [&str; 3] = ["core", "convert", "AsRef"];
88
pub const BEGIN_PANIC: [&str; 3] = ["std", "panicking", "begin_panic"];
99
pub const BEGIN_PANIC_FMT: [&str; 3] = ["std", "panicking", "begin_panic_fmt"];
10-
pub const BINARY_HEAP: [&str; 3] = ["alloc", "binary_heap", "BinaryHeap"];
10+
pub const BINARY_HEAP: [&str; 4] = ["alloc", "collections", "binary_heap", "BinaryHeap"];
1111
pub const BORROW_TRAIT: [&str; 3] = ["core", "borrow", "Borrow"];
1212
pub const BOX: [&str; 3] = ["std", "boxed", "Box"];
1313
pub const BOX_NEW: [&str; 4] = ["std", "boxed", "Box", "new"];
14-
pub const BTREEMAP: [&str; 4] = ["alloc", "btree", "map", "BTreeMap"];
15-
pub const BTREEMAP_ENTRY: [&str; 4] = ["alloc", "btree", "map", "Entry"];
16-
pub const BTREESET: [&str; 4] = ["alloc", "btree", "set", "BTreeSet"];
14+
pub const BTREEMAP: [&str; 5] = ["alloc", "collections", "btree", "map", "BTreeMap"];
15+
pub const BTREEMAP_ENTRY: [&str; 5] = ["alloc", "collections", "btree", "map", "Entry"];
16+
pub const BTREESET: [&str; 5] = ["alloc", "collections", "btree", "set", "BTreeSet"];
1717
pub const CLONE: [&str; 4] = ["core", "clone", "Clone", "clone"];
1818
pub const CLONE_TRAIT: [&str; 3] = ["core", "clone", "Clone"];
1919
pub const CMP_MAX: [&str; 3] = ["core", "cmp", "max"];
@@ -47,7 +47,7 @@ pub const IO_PRINT: [&str; 4] = ["std", "io", "stdio", "_print"];
4747
pub const IO_READ: [&str; 3] = ["std", "io", "Read"];
4848
pub const IO_WRITE: [&str; 3] = ["std", "io", "Write"];
4949
pub const ITERATOR: [&str; 4] = ["core", "iter", "iterator", "Iterator"];
50-
pub const LINKED_LIST: [&str; 3] = ["alloc", "linked_list", "LinkedList"];
50+
pub const LINKED_LIST: [&str; 4] = ["alloc", "collections", "linked_list", "LinkedList"];
5151
pub const LINT: [&str; 2] = ["lint", "Lint"];
5252
pub const LINT_ARRAY: [&str; 2] = ["lint", "LintArray"];
5353
pub const MEM_FORGET: [&str; 3] = ["core", "mem", "forget"];
@@ -101,7 +101,7 @@ pub const TRANSMUTE: [&str; 4] = ["core", "intrinsics", "", "transmute"];
101101
pub const TRY_INTO_RESULT: [&str; 4] = ["std", "ops", "Try", "into_result"];
102102
pub const UNINIT: [&str; 4] = ["core", "intrinsics", "", "uninit"];
103103
pub const VEC: [&str; 3] = ["alloc", "vec", "Vec"];
104-
pub const VEC_DEQUE: [&str; 3] = ["alloc", "vec_deque", "VecDeque"];
104+
pub const VEC_DEQUE: [&str; 4] = ["alloc", "collections", "vec_deque", "VecDeque"];
105105
pub const VEC_FROM_ELEM: [&str; 3] = ["alloc", "vec", "from_elem"];
106-
pub const WEAK_ARC: [&str; 3] = ["alloc", "arc", "Weak"];
106+
pub const WEAK_ARC: [&str; 3] = ["alloc", "sync", "Weak"];
107107
pub const WEAK_RC: [&str; 3] = ["alloc", "rc", "Weak"];

tests/ui/dlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![allow(dead_code, needless_pass_by_value)]
77

88
extern crate alloc;
9-
use alloc::linked_list::LinkedList;
9+
use alloc::collections::linked_list::LinkedList;
1010

1111
trait Foo {
1212
type Baz = LinkedList<u8>;

0 commit comments

Comments
 (0)