This commit is contained in:
Matthias Krüger 2018-08-22 23:34:52 +02:00
parent f05a1038b5
commit 712d2d4fa1
38 changed files with 158 additions and 157 deletions

View file

@ -48,7 +48,7 @@ pub struct Range<'a> {
pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> Option<Range<'b>> {
let def_path = match cx.tables.expr_ty(expr).sty {
ty::TyAdt(def, _) => cx.tcx.def_path(def.did),
ty::Adt(def, _) => cx.tcx.def_path(def.did),
_ => return None,
};

View file

@ -101,7 +101,7 @@ pub fn match_def_path(tcx: TyCtxt<'_, '_, '_>, def_id: DefId, path: &[&str]) ->
/// Check if type is struct, enum or union type with given def path.
pub fn match_type(cx: &LateContext<'_, '_>, ty: Ty<'_>, path: &[&str]) -> bool {
match ty.sty {
ty::TyAdt(adt, _) => match_def_path(cx.tcx, adt.did, path),
ty::Adt(adt, _) => match_def_path(cx.tcx, adt.did, path),
_ => false,
}
}
@ -631,7 +631,7 @@ pub fn walk_ptrs_hir_ty(ty: &hir::Ty) -> &hir::Ty {
/// Return the base type for references and raw pointers.
pub fn walk_ptrs_ty(ty: Ty<'_>) -> Ty<'_> {
match ty.sty {
ty::TyRef(_, ty, _) => walk_ptrs_ty(ty),
ty::Ref(_, ty, _) => walk_ptrs_ty(ty),
_ => ty,
}
}
@ -641,7 +641,7 @@ pub fn walk_ptrs_ty(ty: Ty<'_>) -> Ty<'_> {
pub fn walk_ptrs_ty_depth(ty: Ty<'_>) -> (Ty<'_>, usize) {
fn inner(ty: Ty<'_>, depth: usize) -> (Ty<'_>, usize) {
match ty.sty {
ty::TyRef(_, ty, _) => inner(ty, depth + 1),
ty::Ref(_, ty, _) => inner(ty, depth + 1),
_ => (ty, depth),
}
}
@ -842,7 +842,7 @@ pub fn same_tys<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, a: Ty<'tcx>, b: Ty<'tcx>)
/// Return whether the given type is an `unsafe` function.
pub fn type_is_unsafe_function<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool {
match ty.sty {
ty::TyFnDef(..) | ty::TyFnPtr(_) => ty.fn_sig(cx.tcx).unsafety() == Unsafety::Unsafe,
ty::FnDef(..) | ty::FnPtr(_) => ty.fn_sig(cx.tcx).unsafety() == Unsafety::Unsafe,
_ => false,
}
}
@ -927,7 +927,7 @@ pub fn opt_def_id(def: Def) -> Option<DefId> {
Def::TyAlias(id) |
Def::AssociatedTy(id) |
Def::TyParam(id) |
Def::TyForeign(id) |
Def::ForeignTy(id) |
Def::Struct(id) |
Def::StructCtor(id, ..) |
Def::Union(id) |