Replace most of ty:Ty with Ty
This commit is contained in:
parent
4832a853c7
commit
9b7ff501a6
@ -117,7 +117,7 @@ impl Hash for Constant {
|
||||
}
|
||||
|
||||
impl Constant {
|
||||
pub fn partial_cmp(tcx: TyCtxt<'_, '_, '_>, cmp_type: ty::Ty<'_>, left: &Self, right: &Self) -> Option<Ordering> {
|
||||
pub fn partial_cmp(tcx: TyCtxt<'_, '_, '_>, cmp_type: Ty<'_>, left: &Self, right: &Self) -> Option<Ordering> {
|
||||
match (left, right) {
|
||||
(&Constant::Str(ref ls), &Constant::Str(ref rs)) => Some(ls.cmp(rs)),
|
||||
(&Constant::Char(ref l), &Constant::Char(ref r)) => Some(l.cmp(r)),
|
||||
@ -268,7 +268,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_possible_wrap)]
|
||||
fn constant_not(&self, o: &Constant, ty: ty::Ty<'_>) -> Option<Constant> {
|
||||
fn constant_not(&self, o: &Constant, ty: Ty<'_>) -> Option<Constant> {
|
||||
use self::Constant::*;
|
||||
match *o {
|
||||
Bool(b) => Some(Bool(!b)),
|
||||
@ -284,7 +284,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
||||
}
|
||||
}
|
||||
|
||||
fn constant_negate(&self, o: &Constant, ty: ty::Ty<'_>) -> Option<Constant> {
|
||||
fn constant_negate(&self, o: &Constant, ty: Ty<'_>) -> Option<Constant> {
|
||||
use self::Constant::*;
|
||||
match *o {
|
||||
Int(value) => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use if_chain::if_chain;
|
||||
use rustc::hir::*;
|
||||
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
|
||||
use rustc::ty;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc::{declare_tool_lint, lint_array};
|
||||
use rustc_errors::Applicability;
|
||||
|
||||
@ -147,7 +147,7 @@ fn get_ufcs_type_name(
|
||||
})
|
||||
}
|
||||
|
||||
fn match_borrow_depth(lhs: ty::Ty<'_>, rhs: ty::Ty<'_>) -> bool {
|
||||
fn match_borrow_depth(lhs: Ty<'_>, rhs: Ty<'_>) -> bool {
|
||||
match (&lhs.sty, &rhs.sty) {
|
||||
(ty::Ref(_, t1, _), ty::Ref(_, t2, _)) => match_borrow_depth(&t1, &t2),
|
||||
(l, r) => match (l, r) {
|
||||
@ -157,7 +157,7 @@ fn match_borrow_depth(lhs: ty::Ty<'_>, rhs: ty::Ty<'_>) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
fn match_types(lhs: ty::Ty<'_>, rhs: ty::Ty<'_>) -> bool {
|
||||
fn match_types(lhs: Ty<'_>, rhs: Ty<'_>) -> bool {
|
||||
match (&lhs.sty, &rhs.sty) {
|
||||
(ty::Bool, ty::Bool)
|
||||
| (ty::Char, ty::Char)
|
||||
@ -172,7 +172,7 @@ fn match_types(lhs: ty::Ty<'_>, rhs: ty::Ty<'_>) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_type_name(cx: &LateContext<'_, '_>, ty: ty::Ty<'_>) -> String {
|
||||
fn get_type_name(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> String {
|
||||
match ty.sty {
|
||||
ty::Adt(t, _) => cx.tcx.def_path_str(t.did),
|
||||
ty::Ref(_, r, _) => get_type_name(cx, &r),
|
||||
|
@ -3,7 +3,7 @@ use crate::utils::{is_expn_of, match_def_path, method_chain_args, span_lint_and_
|
||||
use if_chain::if_chain;
|
||||
use rustc::hir;
|
||||
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
||||
use rustc::ty;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc::{declare_tool_lint, lint_array};
|
||||
use syntax_pos::Span;
|
||||
|
||||
@ -132,7 +132,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
|
||||
}
|
||||
}
|
||||
|
||||
fn match_type<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>, ty: ty::Ty<'_>, path: &[&str]) -> bool {
|
||||
fn match_type<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'_>, path: &[&str]) -> bool {
|
||||
match ty.sty {
|
||||
ty::Adt(adt, _) => match_def_path(tcx, adt.did, path),
|
||||
_ => false,
|
||||
|
@ -3,7 +3,7 @@ use crate::utils::{in_macro, iter_input_pats, match_type, method_chain_args, sni
|
||||
use if_chain::if_chain;
|
||||
use rustc::hir;
|
||||
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
||||
use rustc::ty;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc::{declare_tool_lint, lint_array};
|
||||
use rustc_errors::Applicability;
|
||||
use syntax::source_map::Span;
|
||||
@ -87,7 +87,7 @@ impl LintPass for Pass {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_unit_type(ty: ty::Ty<'_>) -> bool {
|
||||
fn is_unit_type(ty: Ty<'_>) -> bool {
|
||||
match ty.sty {
|
||||
ty::Tuple(slice) => slice.is_empty(),
|
||||
ty::Never => true,
|
||||
|
@ -2196,7 +2196,7 @@ fn lint_asref(cx: &LateContext<'_, '_>, expr: &hir::Expr, call_name: &str, as_re
|
||||
|
||||
fn ty_has_iter_method(
|
||||
cx: &LateContext<'_, '_>,
|
||||
self_ref_ty: ty::Ty<'_>,
|
||||
self_ref_ty: Ty<'_>,
|
||||
) -> Option<(&'static Lint, &'static str, &'static str)> {
|
||||
if let Some(ty_name) = has_iter_method(cx, self_ref_ty) {
|
||||
let lint = match ty_name {
|
||||
@ -2217,7 +2217,7 @@ fn ty_has_iter_method(
|
||||
}
|
||||
}
|
||||
|
||||
fn lint_into_iter(cx: &LateContext<'_, '_>, expr: &hir::Expr, self_ref_ty: ty::Ty<'_>, method_span: Span) {
|
||||
fn lint_into_iter(cx: &LateContext<'_, '_>, expr: &hir::Expr, self_ref_ty: Ty<'_>, method_span: Span) {
|
||||
if !match_trait_method(cx, expr, &paths::INTO_ITERATOR) {
|
||||
return;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use rustc::hir::def::Def;
|
||||
use rustc::hir::*;
|
||||
use rustc::lint::{LateContext, LateLintPass, Lint, LintArray, LintPass};
|
||||
use rustc::ty::adjustment::Adjust;
|
||||
use rustc::ty::{self, TypeFlags};
|
||||
use rustc::ty::{Ty, TypeFlags};
|
||||
use rustc::{declare_tool_lint, lint_array};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_typeck::hir_ty_to_ty;
|
||||
@ -108,7 +108,7 @@ impl Source {
|
||||
}
|
||||
}
|
||||
|
||||
fn verify_ty_bound<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>, source: Source) {
|
||||
fn verify_ty_bound<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>, source: Source) {
|
||||
if ty.is_freeze(cx.tcx, cx.param_env, DUMMY_SP) || is_copy(cx, ty) {
|
||||
// An `UnsafeCell` is `!Copy`, and an `UnsafeCell` is also the only type which
|
||||
// is `!Freeze`, thus if our type is `Copy` we can be sure it must be `Freeze`
|
||||
|
@ -12,7 +12,7 @@ use rustc::mir::{
|
||||
visit::{MutatingUseContext, PlaceContext, Visitor},
|
||||
TerminatorKind,
|
||||
};
|
||||
use rustc::ty;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc::{declare_tool_lint, lint_array};
|
||||
use rustc_errors::Applicability;
|
||||
use std::convert::TryFrom;
|
||||
@ -225,7 +225,7 @@ fn is_call_with_ref_arg<'tcx>(
|
||||
cx: &LateContext<'_, 'tcx>,
|
||||
mir: &'tcx mir::Mir<'tcx>,
|
||||
kind: &'tcx mir::TerminatorKind<'tcx>,
|
||||
) -> Option<(def_id::DefId, mir::Local, ty::Ty<'tcx>, Option<&'tcx mir::Place<'tcx>>)> {
|
||||
) -> Option<(def_id::DefId, mir::Local, Ty<'tcx>, Option<&'tcx mir::Place<'tcx>>)> {
|
||||
if_chain! {
|
||||
if let TerminatorKind::Call { func, args, destination, .. } = kind;
|
||||
if args.len() == 1;
|
||||
|
@ -1080,7 +1080,7 @@ pub fn any_parent_is_automatically_derived(tcx: TyCtxt<'_, '_, '_>, node: HirId)
|
||||
}
|
||||
|
||||
/// Returns true if ty has `iter` or `iter_mut` methods
|
||||
pub fn has_iter_method(cx: &LateContext<'_, '_>, probably_ref_ty: ty::Ty<'_>) -> Option<&'static str> {
|
||||
pub fn has_iter_method(cx: &LateContext<'_, '_>, probably_ref_ty: Ty<'_>) -> Option<&'static str> {
|
||||
// FIXME: instead of this hard-coded list, we should check if `<adt>::iter`
|
||||
// exists and has the desired signature. Unfortunately FnCtxt is not exported
|
||||
// so we can't use its `lookup_method` method.
|
||||
|
Loading…
x
Reference in New Issue
Block a user