This commit is contained in:
csmoe 2018-07-12 16:03:06 +08:00 committed by Oliver Schneider
parent 5d4102ee78
commit 12ded030b6
18 changed files with 55 additions and 55 deletions

View file

@ -168,7 +168,7 @@ impl<'a, 'tcx> Functions {
}
fn raw_ptr_arg(arg: &hir::Arg, ty: &hir::Ty) -> Option<ast::NodeId> {
if let (&hir::PatKind::Binding(_, id, _, _), &hir::TyPtr(_)) = (&arg.pat.node, &ty.node) {
if let (&hir::PatKind::Binding(_, id, _, _), &hir::TyKind::Ptr(_)) = (&arg.pat.node, &ty.node) {
Some(id)
} else {
None

View file

@ -338,10 +338,10 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
fn visit_ty(&mut self, ty: &'tcx Ty) {
match ty.node {
TyRptr(ref lt, _) if lt.is_elided() => {
TyKind::Rptr(ref lt, _) if lt.is_elided() => {
self.record(&None);
},
TyPath(ref path) => {
TyKind::Path(ref path) => {
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();

View file

@ -2057,7 +2057,7 @@ impl SelfKind {
return true;
}
match ty.node {
hir::TyRptr(_, ref mt_ty) => {
hir::TyKind::Rptr(_, ref mt_ty) => {
let mutability_match = if self == SelfKind::Ref {
mt_ty.mutbl == hir::MutImmutable
} else {
@ -2128,8 +2128,8 @@ fn is_as_ref_or_mut_trait(ty: &hir::Ty, self_ty: &hir::Ty, generics: &hir::Gener
fn is_ty(ty: &hir::Ty, self_ty: &hir::Ty) -> bool {
match (&ty.node, &self_ty.node) {
(
&hir::TyPath(hir::QPath::Resolved(_, ref ty_path)),
&hir::TyPath(hir::QPath::Resolved(_, ref self_ty_path)),
&hir::TyKind::Path(hir::QPath::Resolved(_, ref ty_path)),
&hir::TyKind::Path(hir::QPath::Resolved(_, ref self_ty_path)),
) => ty_path
.segments
.iter()
@ -2140,7 +2140,7 @@ fn is_ty(ty: &hir::Ty, self_ty: &hir::Ty) -> bool {
}
fn single_segment_ty(ty: &hir::Ty) -> Option<&hir::PathSegment> {
if let hir::TyPath(ref path) = ty.node {
if let hir::TyKind::Path(ref path) = ty.node {
single_segment_path(path)
} else {
None
@ -2181,14 +2181,14 @@ impl OutType {
(OutType::Unit, &hir::Return(ref ty)) if is_unit(ty) => true,
(OutType::Bool, &hir::Return(ref ty)) if is_bool(ty) => true,
(OutType::Any, &hir::Return(ref ty)) if !is_unit(ty) => true,
(OutType::Ref, &hir::Return(ref ty)) => matches!(ty.node, hir::TyRptr(_, _)),
(OutType::Ref, &hir::Return(ref ty)) => matches!(ty.node, hir::TyKind::Rptr(_, _)),
_ => false,
}
}
}
fn is_bool(ty: &hir::Ty) -> bool {
if let hir::TyPath(ref p) = ty.node {
if let hir::TyKind::Path(ref p) = ty.node {
match_qpath(p, &["bool"])
} else {
false

View file

@ -571,7 +571,7 @@ fn non_macro_local(cx: &LateContext, def: &def::Def) -> bool {
fn check_cast(cx: &LateContext, span: Span, e: &Expr, ty: &Ty) {
if_chain! {
if let TyPtr(MutTy { mutbl, .. }) = ty.node;
if let TyKind::Ptr(MutTy { mutbl, .. }) = ty.node;
if let ExprKind::Lit(ref lit) = e.node;
if let LitKind::Int(value, ..) = lit.node;
if value == 0;

View file

@ -87,7 +87,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> {
}
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
if let hir::TyRptr(
if let hir::TyKind::Rptr(
_,
hir::MutTy {
ty: ref pty,
@ -95,7 +95,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> {
},
) = ty.node
{
if let hir::TyRptr(
if let hir::TyKind::Rptr(
_,
hir::MutTy {
mutbl: hir::MutMutable,

View file

@ -215,7 +215,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
if match_type(cx, ty, &paths::VEC);
if let Some(clone_spans) =
get_spans(cx, Some(body.id()), idx, &[("clone", ".to_owned()")]);
if let TyPath(QPath::Resolved(_, ref path)) = input.node;
if let TyKind::Path(QPath::Resolved(_, ref path)) = input.node;
if let Some(elem_ty) = path.segments.iter()
.find(|seg| seg.ident.name == "Vec")
.and_then(|ps| ps.args.as_ref())

View file

@ -159,7 +159,7 @@ fn check_fn(cx: &LateContext, decl: &FnDecl, fn_id: NodeId, opt_body_id: Option<
if match_type(cx, ty, &paths::VEC) {
let mut ty_snippet = None;
if_chain! {
if let TyPath(QPath::Resolved(_, ref path)) = walk_ptrs_hir_ty(arg).node;
if let TyKind::Path(QPath::Resolved(_, ref path)) = walk_ptrs_hir_ty(arg).node;
if let Some(&PathSegment{args: Some(ref parameters), ..}) = path.segments.last();
then {
let types: Vec<_> = parameters.args.iter().filter_map(|arg| match arg {
@ -219,8 +219,8 @@ fn check_fn(cx: &LateContext, decl: &FnDecl, fn_id: NodeId, opt_body_id: Option<
}
} else if match_type(cx, ty, &paths::COW) {
if_chain! {
if let TyRptr(_, MutTy { ref ty, ..} ) = arg.node;
if let TyPath(ref path) = ty.node;
if let TyKind::Rptr(_, MutTy { ref ty, ..} ) = arg.node;
if let TyKind::Path(ref path) = ty.node;
if let QPath::Resolved(None, ref pp) = *path;
if let [ref bx] = *pp.segments;
if let Some(ref params) = bx.args;
@ -273,7 +273,7 @@ fn check_fn(cx: &LateContext, decl: &FnDecl, fn_id: NodeId, opt_body_id: Option<
}
fn get_rptr_lm(ty: &Ty) -> Option<(&Lifetime, Mutability, Span)> {
if let Ty_::TyRptr(ref lt, ref m) = ty.node {
if let TyKind::Rptr(ref lt, ref m) = ty.node {
Some((lt, m.mutbl, ty.span))
} else {
None

View file

@ -347,16 +347,16 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings:
fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut Vec<(Name, Span)>) {
match ty.node {
TySlice(ref sty) => check_ty(cx, sty, bindings),
TyArray(ref fty, ref anon_const) => {
TyKind::Slice(ref sty) => check_ty(cx, sty, bindings),
TyKind::Array(ref fty, ref anon_const) => {
check_ty(cx, fty, bindings);
check_expr(cx, &cx.tcx.hir.body(anon_const.body).value, bindings);
},
TyPtr(MutTy { ty: ref mty, .. }) | TyRptr(_, MutTy { ty: ref mty, .. }) => check_ty(cx, mty, bindings),
TyTup(ref tup) => for t in tup {
TyKind::Ptr(MutTy { ty: ref mty, .. }) | TyKind::Rptr(_, MutTy { ty: ref mty, .. }) => check_ty(cx, mty, bindings),
TyKind::Tup(ref tup) => for t in tup {
check_ty(cx, t, bindings)
},
TyTypeof(ref anon_const) => check_expr(cx, &cx.tcx.hir.body(anon_const.body).value, bindings),
TyKind::Typeof(ref anon_const) => check_expr(cx, &cx.tcx.hir.body(anon_const.body).value, bindings),
_ => (),
}
}

View file

@ -90,7 +90,7 @@ fn check_manual_swap(cx: &LateContext, block: &Block) {
if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs1, lhs2) {
let ty = walk_ptrs_ty(cx.tables.expr_ty(lhs1));
if matches!(ty.sty, ty::TySlice(_)) ||
if matches!(ty.sty, ty::TyKind::Slice(_)) ||
matches!(ty.sty, ty::TyArray(_, _)) ||
match_type(cx, ty, &paths::VEC) ||
match_type(cx, ty, &paths::VEC_DEQUE) {

View file

@ -461,7 +461,7 @@ fn get_type_snippet(cx: &LateContext, path: &QPath, to_ref_ty: Ty) -> String {
GenericArg::Type(ty) => Some(ty),
GenericArg::Lifetime(_) => None,
}).nth(1);
if let TyRptr(_, ref to_ty) = to_ty.node;
if let TyKind::Rptr(_, ref to_ty) = to_ty.node;
then {
return snippet(cx, to_ty.ty.span, &to_ref_ty.to_string()).to_string();
}

View file

@ -123,7 +123,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
if is_copy(cx, ty);
if let Some(size) = cx.layout_of(ty).ok().map(|l| l.size.bytes());
if size <= self.limit;
if let Ty_::TyRptr(_, MutTy { ty: ref decl_ty, .. }) = input.node;
if let TyKind::Rptr(_, MutTy { ty: ref decl_ty, .. }) = input.node;
then {
let value_type = if is_self(arg) {
"self".into()

View file

@ -186,7 +186,7 @@ fn match_type_parameter(cx: &LateContext, qpath: &QPath, path: &[&str]) -> bool
GenericArg::Type(ty) => Some(ty),
GenericArg::Lifetime(_) => None,
});
if let TyPath(ref qpath) = ty.node;
if let TyKind::Path(ref qpath) = ty.node;
if let Some(did) = opt_def_id(cx.tables.qpath_def(qpath, cx.tcx.hir.node_to_hir_id(ty.id)));
if match_def_path(cx.tcx, did, path);
then {
@ -206,7 +206,7 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) {
return;
}
match ast_ty.node {
TyPath(ref qpath) if !is_local => {
TyKind::Path(ref qpath) if !is_local => {
let hir_id = cx.tcx.hir.node_to_hir_id(ast_ty.id);
let def = cx.tables.qpath_def(qpath, hir_id);
if let Some(def_id) = opt_def_id(def) {
@ -282,10 +282,10 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) {
},
}
},
TyRptr(ref lt, ref mut_ty) => check_ty_rptr(cx, ast_ty, is_local, lt, mut_ty),
TyKind::Rptr(ref lt, ref mut_ty) => check_ty_rptr(cx, ast_ty, is_local, lt, mut_ty),
// recurse
TySlice(ref ty) | TyArray(ref ty, _) | TyPtr(MutTy { ref ty, .. }) => check_ty(cx, ty, is_local),
TyTup(ref tys) => for ty in tys {
TyKind::Slice(ref ty) | TyKind::Array(ref ty, _) | TyKind::Ptr(MutTy { ref ty, .. }) => check_ty(cx, ty, is_local),
TyKind::Tup(ref tys) => for ty in tys {
check_ty(cx, ty, is_local);
},
_ => {},
@ -294,7 +294,7 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) {
fn check_ty_rptr(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool, lt: &Lifetime, mut_ty: &MutTy) {
match mut_ty.ty.node {
TyPath(ref qpath) => {
TyKind::Path(ref qpath) => {
let hir_id = cx.tcx.hir.node_to_hir_id(mut_ty.ty.id);
let def = cx.tables.qpath_def(qpath, hir_id);
if_chain! {
@ -1214,13 +1214,13 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
let (add_score, sub_nest) = match ty.node {
// _, &x and *x have only small overhead; don't mess with nesting level
TyInfer | TyPtr(..) | TyRptr(..) => (1, 0),
TyKind::Infer | TyKind::Ptr(..) | TyKind::Rptr(..) => (1, 0),
// the "normal" components of a type: named types, arrays/tuples
TyPath(..) | TySlice(..) | TyTup(..) | TyArray(..) => (10 * self.nest, 1),
TyKind::Path(..) | TyKind::Slice(..) | TyKind::Tup(..) | TyKind::Array(..) => (10 * self.nest, 1),
// function types bring a lot of overhead
TyBareFn(..) => (50 * self.nest, 1),
TyKind::BareFn(..) => (50 * self.nest, 1),
TyTraitObject(ref param_bounds, _) => {
let has_lifetime_parameters = param_bounds
@ -1878,7 +1878,7 @@ enum ImplicitHasherType<'tcx> {
impl<'tcx> ImplicitHasherType<'tcx> {
/// Checks that `ty` is a target type without a BuildHasher.
fn new<'a>(cx: &LateContext<'a, 'tcx>, hir_ty: &hir::Ty) -> Option<Self> {
if let TyPath(QPath::Resolved(None, ref path)) = hir_ty.node {
if let TyKind::Path(QPath::Resolved(None, ref path)) = hir_ty.node {
let params: Vec<_> = path.segments.last().as_ref()?.args.as_ref()?
.args.iter().filter_map(|arg| match arg {
GenericArg::Type(ty) => Some(ty),
@ -1986,7 +1986,7 @@ impl<'a, 'b, 'tcx: 'a + 'b> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'
if_chain! {
if let ExprKind::Call(ref fun, ref args) = e.node;
if let ExprKind::Path(QPath::TypeRelative(ref ty, ref method)) = fun.node;
if let TyPath(QPath::Resolved(None, ref ty_path)) = ty.node;
if let TyKind::Path(QPath::Resolved(None, ref ty_path)) = ty.node;
then {
if !same_tys(self.cx, self.target.ty(), self.body.expr_ty(e)) {
return;

View file

@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
}
if_chain! {
if let ItemImpl(.., ref item_type, ref refs) = item.node;
if let Ty_::TyPath(QPath::Resolved(_, ref item_path)) = item_type.node;
if let TyKind::Path(QPath::Resolved(_, ref item_path)) = item_type.node;
then {
let parameters = &item_path.segments.last().expect(SEGMENTS_MSG).args;
let should_check = if let Some(ref params) = *parameters {

View file

@ -283,8 +283,8 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
let qp_label = self.next("qp");
println!("Cast(ref {}, ref {}) = {};", cast_pat, cast_ty, current);
if let Ty_::TyPath(ref qp) = ty.node {
println!(" if let Ty_::TyPath(ref {}) = {}.node;", qp_label, cast_ty);
if let TyKind::Path(ref qp) = ty.node {
println!(" if let TyKind::Path(ref {}) = {}.node;", qp_label, cast_ty);
self.current = qp_label;
self.print_qpath(qp);
}
@ -674,7 +674,7 @@ fn print_path(path: &QPath, first: &mut bool) {
print!("{:?}", segment.ident.as_str());
},
QPath::TypeRelative(ref ty, ref segment) => match ty.node {
hir::Ty_::TyPath(ref inner_path) => {
hir::TyKind::Path(ref inner_path) => {
print_path(inner_path, first);
if *first {
*first = false;

View file

@ -246,10 +246,10 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
self.eq_ty_kind(&left.node, &right.node)
}
pub fn eq_ty_kind(&mut self, left: &Ty_, right: &Ty_) -> bool {
pub fn eq_ty_kind(&mut self, left: &TyKind, right: &TyKind) -> bool {
match (left, right) {
(&TySlice(ref l_vec), &TySlice(ref r_vec)) => self.eq_ty(l_vec, r_vec),
(&TyArray(ref lt, ref ll_id), &TyArray(ref rt, ref rl_id)) => {
(&TyKind::Slice(ref l_vec), &TyKind::Slice(ref r_vec)) => self.eq_ty(l_vec, r_vec),
(&TyKind::Array(ref lt, ref ll_id), &TyKind::Array(ref rt, ref rl_id)) => {
let full_table = self.tables;
let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body));
@ -264,13 +264,13 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
self.tables = full_table;
eq_ty && ll == rl
},
(&TyPtr(ref l_mut), &TyPtr(ref r_mut)) => l_mut.mutbl == r_mut.mutbl && self.eq_ty(&*l_mut.ty, &*r_mut.ty),
(&TyRptr(_, ref l_rmut), &TyRptr(_, ref r_rmut)) => {
(&TyKind::Ptr(ref l_mut), &TyKind::Ptr(ref r_mut)) => l_mut.mutbl == r_mut.mutbl && self.eq_ty(&*l_mut.ty, &*r_mut.ty),
(&TyKind::Rptr(_, ref l_rmut), &TyKind::Rptr(_, ref r_rmut)) => {
l_rmut.mutbl == r_rmut.mutbl && self.eq_ty(&*l_rmut.ty, &*r_rmut.ty)
},
(&TyPath(ref l), &TyPath(ref r)) => self.eq_qpath(l, r),
(&TyTup(ref l), &TyTup(ref r)) => over(l, r, |l, r| self.eq_ty(l, r)),
(&TyInfer, &TyInfer) => true,
(&TyKind::Path(ref l), &TyKind::Path(ref r)) => self.eq_qpath(l, r),
(&TyKind::Tup(ref l), &TyKind::Tup(ref r)) => over(l, r, |l, r| self.eq_ty(l, r)),
(&TyKind::Infer, &TyKind::Infer) => true,
_ => false,
}
}

View file

@ -162,7 +162,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
fn is_lint_ref_type(ty: &Ty) -> bool {
if let TyRptr(
if let TyKind::Rptr(
_,
MutTy {
ty: ref inner,
@ -170,7 +170,7 @@ fn is_lint_ref_type(ty: &Ty) -> bool {
},
) = ty.node
{
if let TyPath(ref path) = inner.node {
if let TyKind::Path(ref path) = inner.node {
return match_qpath(path, &paths::LINT);
}
}
@ -179,7 +179,7 @@ fn is_lint_ref_type(ty: &Ty) -> bool {
fn is_lint_array_type(ty: &Ty) -> bool {
if let TyPath(ref path) = ty.node {
if let TyKind::Path(ref path) = ty.node {
match_qpath(path, &paths::LINT_ARRAY)
} else {
false

View file

@ -210,7 +210,7 @@ pub fn match_qpath(path: &QPath, segments: &[&str]) -> bool {
match *path {
QPath::Resolved(_, ref path) => match_path(path, segments),
QPath::TypeRelative(ref ty, ref segment) => match ty.node {
TyPath(ref inner_path) => {
TyKind::Path(ref inner_path) => {
!segments.is_empty() && match_qpath(inner_path, &segments[..(segments.len() - 1)])
&& segment.ident.name == segments[segments.len() - 1]
},
@ -667,7 +667,7 @@ where
/// Return the base type for HIR references and pointers.
pub fn walk_ptrs_hir_ty(ty: &hir::Ty) -> &hir::Ty {
match ty.node {
TyPtr(ref mut_ty) | TyRptr(_, ref mut_ty) => walk_ptrs_hir_ty(&mut_ty.ty),
TyKind::Ptr(ref mut_ty) | TyKind::Rptr(_, ref mut_ty) => walk_ptrs_hir_ty(&mut_ty.ty),
_ => ty,
}
}
@ -998,7 +998,7 @@ pub fn is_self(slf: &Arg) -> bool {
pub fn is_self_ty(slf: &hir::Ty) -> bool {
if_chain! {
if let TyPath(ref qp) = slf.node;
if let TyKind::Path(ref qp) = slf.node;
if let QPath::Resolved(None, ref path) = *qp;
if let Def::SelfTy(..) = path.def;
then {

View file

@ -3,7 +3,7 @@ if_chain! {
if let Decl_::DeclLocal(ref local) = decl.node;
if let Some(ref init) = local.init
if let ExprKind::Cast(ref expr, ref cast_ty) = init.node;
if let Ty_::TyPath(ref qp) = cast_ty.node;
if let TyKind::Path(ref qp) = cast_ty.node;
if match_qpath(qp, &["char"]);
if let ExprKind::Lit(ref lit) = expr.node;
if let LitKind::Int(69, _) = lit.node;