mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 19:23:50 +00:00
Merge branch 'pr-2889'
This commit is contained in:
commit
184b99de39
40
Cargo.toml
40
Cargo.toml
@ -45,6 +45,46 @@ clippy_lints = { version = "0.0.211", path = "clippy_lints" }
|
||||
regex = "1"
|
||||
semver = "0.9"
|
||||
|
||||
# Not actually needed right now but required to make sure that clippy/ and cargo build
|
||||
# with the same set of features in rust-lang/rust
|
||||
num-traits = "0.2" # enable the default feature
|
||||
backtrace = "0.3"
|
||||
|
||||
# keep in sync with `cargo`'s `Cargo.toml'
|
||||
[target.'cfg(windows)'.dependencies.winapi]
|
||||
version = "0.3"
|
||||
features = [
|
||||
# keep in sync with `cargo`'s `Cargo.toml'
|
||||
"handleapi",
|
||||
"jobapi",
|
||||
"jobapi2",
|
||||
"minwindef",
|
||||
"ntdef",
|
||||
"ntstatus",
|
||||
"processenv",
|
||||
"processthreadsapi",
|
||||
"psapi",
|
||||
"synchapi",
|
||||
"winerror",
|
||||
"winbase",
|
||||
"wincon",
|
||||
"winnt",
|
||||
# no idea where these come from
|
||||
"basetsd",
|
||||
"lmcons",
|
||||
"memoryapi",
|
||||
"minschannel",
|
||||
"minwinbase",
|
||||
"ntsecapi",
|
||||
"profileapi",
|
||||
"schannel",
|
||||
"securitybaseapi",
|
||||
"synchapi",
|
||||
"sysinfoapi",
|
||||
"timezoneapi",
|
||||
"wincrypt",
|
||||
]
|
||||
|
||||
[dev-dependencies]
|
||||
cargo_metadata = "0.5"
|
||||
compiletest_rs = "0.3.7"
|
||||
|
@ -13,7 +13,6 @@ use std::mem;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast::{FloatTy, LitKind};
|
||||
use syntax::ptr::P;
|
||||
use rustc::middle::const_val::ConstVal;
|
||||
use crate::utils::{sext, unsext, clip};
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
@ -428,7 +427,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
||||
pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'tcx>) -> Option<Constant> {
|
||||
use rustc::mir::interpret::{Scalar, ConstValue};
|
||||
match result.val {
|
||||
ConstVal::Value(ConstValue::Scalar(Scalar::Bits{ bits: b, ..})) => match result.ty.sty {
|
||||
ConstValue::Scalar(Scalar::Bits{ bits: b, ..}) => match result.ty.sty {
|
||||
ty::TyBool => Some(Constant::Bool(b == 1)),
|
||||
ty::TyUint(_) | ty::TyInt(_) => Some(Constant::Int(b)),
|
||||
ty::TyFloat(FloatTy::F32) => Some(Constant::F32(f32::from_bits(b as u32))),
|
||||
@ -436,7 +435,7 @@ pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'
|
||||
// FIXME: implement other conversion
|
||||
_ => None,
|
||||
},
|
||||
ConstVal::Value(ConstValue::ScalarPair(Scalar::Ptr(ptr), Scalar::Bits { bits: n, .. })) => match result.ty.sty {
|
||||
ConstValue::ScalarPair(Scalar::Ptr(ptr), Scalar::Bits { bits: n, .. }) => match result.ty.sty {
|
||||
ty::TyRef(_, tam, _) => match tam.sty {
|
||||
ty::TyStr => {
|
||||
let alloc = tcx
|
||||
|
@ -44,7 +44,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EnumGlobUse {
|
||||
|
||||
impl EnumGlobUse {
|
||||
fn lint_item(&self, cx: &LateContext, item: &Item) {
|
||||
if item.vis == Visibility::Public {
|
||||
if item.vis.node == VisibilityKind::Public {
|
||||
return; // re-exports are fine
|
||||
}
|
||||
if let ItemUse(ref path, UseKind::Glob) = item.node {
|
||||
|
@ -108,7 +108,8 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
if let Categorization::Rvalue(..) = cmt.cat {
|
||||
if let Some(NodeStmt(st)) = map.find(map.get_parent_node(cmt.id)) {
|
||||
let id = map.hir_to_node_id(cmt.hir_id);
|
||||
if let Some(NodeStmt(st)) = map.find(map.get_parent_node(id)) {
|
||||
if let StmtDecl(ref decl, _) = st.node {
|
||||
if let DeclLocal(ref loc) = decl.node {
|
||||
if let Some(ref ex) = loc.init {
|
||||
|
@ -342,16 +342,23 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
|
||||
self.record(&None);
|
||||
},
|
||||
TyPath(ref path) => {
|
||||
self.collect_anonymous_lifetimes(path, ty);
|
||||
},
|
||||
TyImplTraitExistential(exist_ty_id, _, _) => {
|
||||
if let ItemExistential(ref exist_ty) = self.cx.tcx.hir.expect_item(exist_ty_id.id).node {
|
||||
for bound in &exist_ty.bounds {
|
||||
if let GenericBound::Outlives(_) = *bound {
|
||||
self.record(&None);
|
||||
if let QPath::Resolved(_, ref path) = *path {
|
||||
if let Def::Existential(def_id) = path.def {
|
||||
let node_id = self.cx.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
if let ItemExistential(ref exist_ty) = self.cx.tcx.hir.expect_item(node_id).node {
|
||||
for bound in &exist_ty.bounds {
|
||||
if let GenericBound::Outlives(_) = *bound {
|
||||
self.record(&None);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
walk_ty(self, ty);
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.collect_anonymous_lifetimes(path, ty);
|
||||
}
|
||||
TyTraitObject(ref bounds, ref lt) => {
|
||||
if !lt.is_elided() {
|
||||
|
@ -840,7 +840,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
.iter()
|
||||
.any(|k| k.matches(first_arg_ty, first_arg, self_ty, is_copy, &implitem.generics));
|
||||
then {
|
||||
let lint = if item.vis == hir::Visibility::Public {
|
||||
let lint = if item.vis.node == hir::VisibilityKind::Public {
|
||||
WRONG_PUB_SELF_CONVENTION
|
||||
} else {
|
||||
WRONG_SELF_CONVENTION
|
||||
|
@ -51,14 +51,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
return;
|
||||
}
|
||||
println!("impl item `{}`", item.ident.name);
|
||||
match item.vis {
|
||||
hir::Visibility::Public => println!("public"),
|
||||
hir::Visibility::Crate(_) => println!("visible crate wide"),
|
||||
hir::Visibility::Restricted { ref path, .. } => println!(
|
||||
match item.vis.node {
|
||||
hir::VisibilityKind::Public => println!("public"),
|
||||
hir::VisibilityKind::Crate(_) => println!("visible crate wide"),
|
||||
hir::VisibilityKind::Restricted { ref path, .. } => println!(
|
||||
"visible in module `{}`",
|
||||
print::to_string(print::NO_ANN, |s| s.print_path(path, false))
|
||||
),
|
||||
hir::Visibility::Inherited => println!("visibility inherited from outer item"),
|
||||
hir::VisibilityKind::Inherited => println!("visibility inherited from outer item"),
|
||||
}
|
||||
if item.defaultness.is_default() {
|
||||
println!("default");
|
||||
@ -343,14 +343,14 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
|
||||
fn print_item(cx: &LateContext, item: &hir::Item) {
|
||||
let did = cx.tcx.hir.local_def_id(item.id);
|
||||
println!("item `{}`", item.name);
|
||||
match item.vis {
|
||||
hir::Visibility::Public => println!("public"),
|
||||
hir::Visibility::Crate(_) => println!("visible crate wide"),
|
||||
hir::Visibility::Restricted { ref path, .. } => println!(
|
||||
match item.vis.node {
|
||||
hir::VisibilityKind::Public => println!("public"),
|
||||
hir::VisibilityKind::Crate(_) => println!("visible crate wide"),
|
||||
hir::VisibilityKind::Restricted { ref path, .. } => println!(
|
||||
"visible in module `{}`",
|
||||
print::to_string(print::NO_ANN, |s| s.print_path(path, false))
|
||||
),
|
||||
hir::Visibility::Inherited => println!("visibility inherited from outer item"),
|
||||
hir::VisibilityKind::Inherited => println!("visibility inherited from outer item"),
|
||||
}
|
||||
match item.node {
|
||||
hir::ItemExternCrate(ref _renamed_from) => {
|
||||
|
@ -120,7 +120,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
|
||||
if let ItemStatic(ref ty, MutImmutable, body_id) = item.node {
|
||||
if is_lint_ref_type(ty) {
|
||||
self.declared_lints.insert(item.name, item.span);
|
||||
} else if is_lint_array_type(ty) && item.vis == Visibility::Inherited && item.name == "ARRAY" {
|
||||
} else if is_lint_array_type(ty) && item.vis.node == VisibilityKind::Inherited && item.name == "ARRAY" {
|
||||
let mut collector = LintCollector {
|
||||
output: &mut self.registered_lints,
|
||||
cx,
|
||||
|
@ -2,18 +2,18 @@
|
||||
//! about.
|
||||
|
||||
pub const ANY_TRAIT: [&str; 3] = ["std", "any", "Any"];
|
||||
pub const ARC: [&str; 3] = ["alloc", "arc", "Arc"];
|
||||
pub const ARC: [&str; 3] = ["alloc", "sync", "Arc"];
|
||||
pub const ASMUT_TRAIT: [&str; 3] = ["core", "convert", "AsMut"];
|
||||
pub const ASREF_TRAIT: [&str; 3] = ["core", "convert", "AsRef"];
|
||||
pub const BEGIN_PANIC: [&str; 3] = ["std", "panicking", "begin_panic"];
|
||||
pub const BEGIN_PANIC_FMT: [&str; 3] = ["std", "panicking", "begin_panic_fmt"];
|
||||
pub const BINARY_HEAP: [&str; 3] = ["alloc", "binary_heap", "BinaryHeap"];
|
||||
pub const BINARY_HEAP: [&str; 4] = ["alloc", "collections", "binary_heap", "BinaryHeap"];
|
||||
pub const BORROW_TRAIT: [&str; 3] = ["core", "borrow", "Borrow"];
|
||||
pub const BOX: [&str; 3] = ["std", "boxed", "Box"];
|
||||
pub const BOX_NEW: [&str; 4] = ["std", "boxed", "Box", "new"];
|
||||
pub const BTREEMAP: [&str; 4] = ["alloc", "btree", "map", "BTreeMap"];
|
||||
pub const BTREEMAP_ENTRY: [&str; 4] = ["alloc", "btree", "map", "Entry"];
|
||||
pub const BTREESET: [&str; 4] = ["alloc", "btree", "set", "BTreeSet"];
|
||||
pub const BTREEMAP: [&str; 5] = ["alloc", "collections", "btree", "map", "BTreeMap"];
|
||||
pub const BTREEMAP_ENTRY: [&str; 5] = ["alloc", "collections", "btree", "map", "Entry"];
|
||||
pub const BTREESET: [&str; 5] = ["alloc", "collections", "btree", "set", "BTreeSet"];
|
||||
pub const CLONE: [&str; 4] = ["core", "clone", "Clone", "clone"];
|
||||
pub const CLONE_TRAIT: [&str; 3] = ["core", "clone", "Clone"];
|
||||
pub const CMP_MAX: [&str; 3] = ["core", "cmp", "max"];
|
||||
@ -47,7 +47,7 @@ pub const IO_PRINT: [&str; 4] = ["std", "io", "stdio", "_print"];
|
||||
pub const IO_READ: [&str; 3] = ["std", "io", "Read"];
|
||||
pub const IO_WRITE: [&str; 3] = ["std", "io", "Write"];
|
||||
pub const ITERATOR: [&str; 4] = ["core", "iter", "iterator", "Iterator"];
|
||||
pub const LINKED_LIST: [&str; 3] = ["alloc", "linked_list", "LinkedList"];
|
||||
pub const LINKED_LIST: [&str; 4] = ["alloc", "collections", "linked_list", "LinkedList"];
|
||||
pub const LINT: [&str; 2] = ["lint", "Lint"];
|
||||
pub const LINT_ARRAY: [&str; 2] = ["lint", "LintArray"];
|
||||
pub const MEM_FORGET: [&str; 3] = ["core", "mem", "forget"];
|
||||
@ -101,7 +101,7 @@ pub const TRANSMUTE: [&str; 4] = ["core", "intrinsics", "", "transmute"];
|
||||
pub const TRY_INTO_RESULT: [&str; 4] = ["std", "ops", "Try", "into_result"];
|
||||
pub const UNINIT: [&str; 4] = ["core", "intrinsics", "", "uninit"];
|
||||
pub const VEC: [&str; 3] = ["alloc", "vec", "Vec"];
|
||||
pub const VEC_DEQUE: [&str; 3] = ["alloc", "vec_deque", "VecDeque"];
|
||||
pub const VEC_DEQUE: [&str; 4] = ["alloc", "collections", "vec_deque", "VecDeque"];
|
||||
pub const VEC_FROM_ELEM: [&str; 3] = ["alloc", "vec", "from_elem"];
|
||||
pub const WEAK_ARC: [&str; 3] = ["alloc", "arc", "Weak"];
|
||||
pub const WEAK_ARC: [&str; 3] = ["alloc", "sync", "Weak"];
|
||||
pub const WEAK_RC: [&str; 3] = ["alloc", "rc", "Weak"];
|
||||
|
@ -6,7 +6,7 @@
|
||||
#![allow(dead_code, needless_pass_by_value)]
|
||||
|
||||
extern crate alloc;
|
||||
use alloc::linked_list::LinkedList;
|
||||
use alloc::collections::linked_list::LinkedList;
|
||||
|
||||
trait Foo {
|
||||
type Baz = LinkedList<u8>;
|
||||
|
Loading…
Reference in New Issue
Block a user