mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 17:07:17 +00:00
Merge pull request #3072 from matthiaskrgr/rustup
rustup, fix breakage introduced by rust-lang/rust#53581 and rust-lang/rust#53459
This commit is contained in:
commit
e9c3d3d502
48 changed files with 166 additions and 169 deletions
|
@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
|
|||
_ => { return; }
|
||||
}
|
||||
};
|
||||
if ty::TyUint(UintTy::U8) != walk_ptrs_ty(cx.tables.expr_ty(needle)).sty {
|
||||
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.tables.expr_ty(needle)).sty {
|
||||
return;
|
||||
}
|
||||
let haystack = if let ExprKind::MethodCall(ref path, _, ref args) =
|
||||
|
|
|
@ -123,12 +123,12 @@ impl Hash for Constant {
|
|||
}
|
||||
|
||||
impl Constant {
|
||||
pub fn partial_cmp(tcx: TyCtxt<'_, '_, '_>, cmp_type: &ty::TypeVariants<'_>, left: &Self, right: &Self) -> Option<Ordering> {
|
||||
pub fn partial_cmp(tcx: TyCtxt<'_, '_, '_>, cmp_type: &ty::TyKind<'_>, 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)),
|
||||
(&Constant::Int(l), &Constant::Int(r)) => {
|
||||
if let ty::TyInt(int_ty) = *cmp_type {
|
||||
if let ty::Int(int_ty) = *cmp_type {
|
||||
Some(sext(tcx, l, int_ty).cmp(&sext(tcx, r, int_ty)))
|
||||
} else {
|
||||
Some(l.cmp(&r))
|
||||
|
@ -166,8 +166,8 @@ pub fn lit_to_constant<'tcx>(lit: &LitKind, ty: Ty<'tcx>) -> Constant {
|
|||
LitKind::Int(n, _) => Constant::Int(n),
|
||||
LitKind::Float(ref is, _) |
|
||||
LitKind::FloatUnsuffixed(ref is) => match ty.sty {
|
||||
ty::TyFloat(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
|
||||
ty::TyFloat(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
|
||||
ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
|
||||
ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
|
||||
_ => bug!(),
|
||||
},
|
||||
LitKind::Bool(b) => Constant::Bool(b),
|
||||
|
@ -220,7 +220,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
|||
ExprKind::Tup(ref tup) => self.multi(tup).map(Constant::Tuple),
|
||||
ExprKind::Repeat(ref value, _) => {
|
||||
let n = match self.tables.expr_ty(e).sty {
|
||||
ty::TyArray(_, n) => n.assert_usize(self.tcx).expect("array length"),
|
||||
ty::Array(_, n) => n.assert_usize(self.tcx).expect("array length"),
|
||||
_ => span_bug!(e.span, "typeck error"),
|
||||
};
|
||||
self.expr(value).map(|v| Constant::Repeat(Box::new(v), n as u64))
|
||||
|
@ -243,8 +243,8 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
|||
Int(value) => {
|
||||
let value = !value;
|
||||
match ty.sty {
|
||||
ty::TyInt(ity) => Some(Int(unsext(self.tcx, value as i128, ity))),
|
||||
ty::TyUint(ity) => Some(Int(clip(self.tcx, value, ity))),
|
||||
ty::Int(ity) => Some(Int(unsext(self.tcx, value as i128, ity))),
|
||||
ty::Uint(ity) => Some(Int(clip(self.tcx, value, ity))),
|
||||
_ => None,
|
||||
}
|
||||
},
|
||||
|
@ -257,7 +257,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
|||
match *o {
|
||||
Int(value) => {
|
||||
let ity = match ty.sty {
|
||||
ty::TyInt(ity) => ity,
|
||||
ty::Int(ity) => ity,
|
||||
_ => return None,
|
||||
};
|
||||
// sign extend
|
||||
|
@ -336,7 +336,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
|||
match (l, r) {
|
||||
(Constant::Int(l), Some(Constant::Int(r))) => {
|
||||
match self.tables.expr_ty(left).sty {
|
||||
ty::TyInt(ity) => {
|
||||
ty::Int(ity) => {
|
||||
let l = sext(self.tcx, l, ity);
|
||||
let r = sext(self.tcx, r, ity);
|
||||
let zext = |n: i128| Constant::Int(unsext(self.tcx, n, ity));
|
||||
|
@ -360,7 +360,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
ty::TyUint(_) => {
|
||||
ty::Uint(_) => {
|
||||
match op.node {
|
||||
BinOpKind::Add => l.checked_add(r).map(Constant::Int),
|
||||
BinOpKind::Sub => l.checked_sub(r).map(Constant::Int),
|
||||
|
@ -429,18 +429,18 @@ pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'
|
|||
use rustc::mir::interpret::{Scalar, ScalarMaybeUndef, ConstValue};
|
||||
match result.val {
|
||||
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))),
|
||||
ty::TyFloat(FloatTy::F64) => Some(Constant::F64(f64::from_bits(b as u64))),
|
||||
ty::Bool => Some(Constant::Bool(b == 1)),
|
||||
ty::Uint(_) | ty::Int(_) => Some(Constant::Int(b)),
|
||||
ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(b as u32))),
|
||||
ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits(b as u64))),
|
||||
// FIXME: implement other conversion
|
||||
_ => None,
|
||||
},
|
||||
ConstValue::ScalarPair(Scalar::Ptr(ptr),
|
||||
ScalarMaybeUndef::Scalar(
|
||||
Scalar::Bits { bits: n, .. })) => match result.ty.sty {
|
||||
ty::TyRef(_, tam, _) => match tam.sty {
|
||||
ty::TyStr => {
|
||||
ty::Ref(_, tam, _) => match tam.sty {
|
||||
ty::Str => {
|
||||
let alloc = tcx
|
||||
.alloc_map
|
||||
.lock()
|
||||
|
|
|
@ -159,9 +159,9 @@ impl<'a, 'tcx> Visitor<'tcx> for CCHelper<'a, 'tcx> {
|
|||
walk_expr(self, e);
|
||||
let ty = self.cx.tables.node_id_to_type(callee.hir_id);
|
||||
match ty.sty {
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
|
||||
ty::FnDef(..) | ty::FnPtr(_) => {
|
||||
let sig = ty.fn_sig(self.cx.tcx);
|
||||
if sig.skip_binder().output().sty == ty::TyNever {
|
||||
if sig.skip_binder().output().sty == ty::Never {
|
||||
self.divergence += 1;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ use rustc::hir::*;
|
|||
use rustc::lint::*;
|
||||
use rustc::{declare_lint, lint_array};
|
||||
use if_chain::if_chain;
|
||||
use rustc::ty::TypeVariants;
|
||||
use rustc::ty::TyKind;
|
||||
|
||||
use crate::utils::{any_parent_is_automatically_derived, match_def_path, opt_def_id, paths, span_lint_and_sugg};
|
||||
|
||||
|
@ -51,7 +51,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess {
|
|||
// TODO: Work out a way to put "whatever the imported way of referencing
|
||||
// this type in this file" rather than a fully-qualified type.
|
||||
let expr_ty = cx.tables.expr_ty(expr);
|
||||
if let TypeVariants::TyAdt(..) = expr_ty.sty {
|
||||
if let TyKind::Adt(..) = expr_ty.sty {
|
||||
let replacement = format!("{}::default()", expr_ty);
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
|
|
|
@ -141,18 +141,18 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref
|
|||
}
|
||||
|
||||
match ty.sty {
|
||||
ty::TyAdt(def, _) if def.is_union() => return,
|
||||
ty::Adt(def, _) if def.is_union() => return,
|
||||
|
||||
// Some types are not Clone by default but could be cloned “by hand” if necessary
|
||||
ty::TyAdt(def, substs) => for variant in &def.variants {
|
||||
ty::Adt(def, substs) => for variant in &def.variants {
|
||||
for field in &variant.fields {
|
||||
if let ty::TyFnDef(..) = field.ty(cx.tcx, substs).sty {
|
||||
if let ty::FnDef(..) = field.ty(cx.tcx, substs).sty {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for subst in substs {
|
||||
if let ty::subst::UnpackedKind::Type(subst) = subst.unpack() {
|
||||
if let ty::TyParam(_) = subst.sty {
|
||||
if let ty::Param(_) = subst.sty {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
let arg = &args[0];
|
||||
let arg_ty = cx.tables.expr_ty(arg);
|
||||
|
||||
if let ty::TyRef(..) = arg_ty.sty {
|
||||
if let ty::Ref(..) = arg_ty.sty {
|
||||
if match_def_path(cx.tcx, def_id, &paths::DROP) {
|
||||
lint = DROP_REF;
|
||||
msg = DROP_REF_SUMMARY.to_string();
|
||||
|
|
|
@ -63,19 +63,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
|
|||
let constant = cx.tcx.const_eval(param_env.and(cid)).ok();
|
||||
if let Some(Constant::Int(val)) = constant.and_then(|c| miri_to_const(cx.tcx, c)) {
|
||||
let mut ty = cx.tcx.type_of(did);
|
||||
if let ty::TyAdt(adt, _) = ty.sty {
|
||||
if let ty::Adt(adt, _) = ty.sty {
|
||||
if adt.is_enum() {
|
||||
ty = adt.repr.discr_type().to_ty(cx.tcx);
|
||||
}
|
||||
}
|
||||
match ty.sty {
|
||||
ty::TyInt(IntTy::Isize) => {
|
||||
ty::Int(IntTy::Isize) => {
|
||||
let val = ((val as i128) << 64) >> 64;
|
||||
if val <= i128::from(i32::max_value()) && val >= i128::from(i32::min_value()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ty::TyUint(UintTy::Usize) if val > u128::from(u32::max_value()) => {},
|
||||
ty::Uint(UintTy::Usize) if val > u128::from(u32::max_value()) => {},
|
||||
_ => continue,
|
||||
}
|
||||
span_lint(
|
||||
|
|
|
@ -67,9 +67,9 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
|
|||
let fn_ty = cx.tables.expr_ty(caller);
|
||||
match fn_ty.sty {
|
||||
// Is it an unsafe function? They don't implement the closure traits
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
|
||||
ty::FnDef(..) | ty::FnPtr(_) => {
|
||||
let sig = fn_ty.fn_sig(cx.tcx);
|
||||
if sig.skip_binder().unsafety == Unsafety::Unsafe || sig.skip_binder().output().sty == ty::TyNever {
|
||||
if sig.skip_binder().unsafety == Unsafety::Unsafe || sig.skip_binder().output().sty == ty::Never {
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -130,9 +130,9 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
|
|||
ExprKind::Call(ref func, _) => {
|
||||
let typ = self.cx.tables.expr_ty(func);
|
||||
match typ.sty {
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
|
||||
ty::FnDef(..) | ty::FnPtr(_) => {
|
||||
let sig = typ.fn_sig(self.cx.tcx);
|
||||
if let ty::TyNever = self.cx.tcx.erase_late_bound_regions(&sig).output().sty {
|
||||
if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().sty {
|
||||
self.report_diverging_sub_expr(e);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ use rustc::hir;
|
|||
use rustc::lint::*;
|
||||
use rustc::{declare_lint, lint_array};
|
||||
use if_chain::if_chain;
|
||||
use rustc::ty::TypeVariants;
|
||||
use rustc::ty::TyKind;
|
||||
use std::f32;
|
||||
use std::f64;
|
||||
use std::fmt;
|
||||
|
@ -46,7 +46,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision {
|
|||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
|
||||
if_chain! {
|
||||
let ty = cx.tables.expr_ty(expr);
|
||||
if let TypeVariants::TyFloat(fty) = ty.sty;
|
||||
if let TyKind::Float(fty) = ty.sty;
|
||||
if let hir::ExprKind::Lit(ref lit) = expr.node;
|
||||
if let LitKind::Float(sym, _) | LitKind::FloatUnsuffixed(sym) = lit.node;
|
||||
if let Some(sugg) = self.check(sym, fty);
|
||||
|
|
|
@ -130,7 +130,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
|
|||
|
||||
fn match_type(tcx: ty::TyCtxt<'_, '_, '_>, ty: ty::Ty<'_>, path: &[&str]) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyAdt(adt, _) => match_def_path(tcx, adt.did, path),
|
||||
ty::Adt(adt, _) => match_def_path(tcx, adt.did, path),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ fn get_single_string_arg(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<Span>
|
|||
if match_def_path(cx.tcx, fun_def_id, &paths::DISPLAY_FMT_METHOD);
|
||||
then {
|
||||
let ty = walk_ptrs_ty(cx.tables.pat_ty(&pat[0]));
|
||||
if ty.sty == ty::TyStr || match_type(cx, ty, &paths::STRING) {
|
||||
if ty.sty == ty::Str || match_type(cx, ty, &paths::STRING) {
|
||||
if let ExprKind::Tup(ref values) = match_expr.node {
|
||||
return Some(values[0].span);
|
||||
}
|
||||
|
|
|
@ -63,8 +63,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp {
|
|||
fn check(cx: &LateContext<'_, '_>, e: &Expr, m: i8, span: Span, arg: Span) {
|
||||
if let Some(Constant::Int(v)) = constant_simple(cx, cx.tables, e) {
|
||||
let check = match cx.tables.expr_ty(e).sty {
|
||||
ty::TyInt(ity) => unsext(cx.tcx, -1_i128, ity),
|
||||
ty::TyUint(uty) => clip(cx.tcx, !0, uty),
|
||||
ty::Int(ity) => unsext(cx.tcx, -1_i128, ity),
|
||||
ty::Uint(uty) => clip(cx.tcx, !0, uty),
|
||||
_ => return,
|
||||
};
|
||||
if match m {
|
||||
|
|
|
@ -99,7 +99,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
|
|||
let ty = cx.tables.expr_ty(array);
|
||||
if let Some(range) = higher::range(cx, index) {
|
||||
// Ranged indexes, i.e. &x[n..m], &x[n..], &x[..n] and &x[..]
|
||||
if let ty::TyArray(_, s) = ty.sty {
|
||||
if let ty::Array(_, s) = ty.sty {
|
||||
let size: u128 = s.assert_usize(cx.tcx).unwrap().into();
|
||||
// Index is a constant range.
|
||||
if let Some((start, end)) = to_const_range(cx, range, size) {
|
||||
|
@ -131,7 +131,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
|
|||
);
|
||||
} else {
|
||||
// Catchall non-range index, i.e. [n] or [n << m]
|
||||
if let ty::TyArray(..) = ty.sty {
|
||||
if let ty::Array(..) = ty.sty {
|
||||
// Index is a constant uint.
|
||||
if let Some(..) = constant(cx, cx.tables, index) {
|
||||
// Let rustc's `const_err` lint handle constant `usize` indexing on arrays.
|
||||
|
|
|
@ -40,7 +40,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidRef {
|
|||
if let ExprKind::Call(ref path, ref args) = expr.node;
|
||||
if let ExprKind::Path(ref qpath) = path.node;
|
||||
if args.len() == 0;
|
||||
if let ty::TyRef(..) = cx.tables.expr_ty(expr).sty;
|
||||
if let ty::Ref(..) = cx.tables.expr_ty(expr).sty;
|
||||
if let Some(def_id) = opt_def_id(cx.tables.qpath_def(qpath, path.hir_id));
|
||||
then {
|
||||
let msg = if match_def_path(cx.tcx, def_id, &paths::MEM_ZEROED) |
|
||||
|
|
|
@ -265,12 +265,12 @@ fn has_is_empty(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
|
|||
|
||||
let ty = &walk_ptrs_ty(cx.tables.expr_ty(expr));
|
||||
match ty.sty {
|
||||
ty::TyDynamic(ref tt, ..) => cx.tcx
|
||||
ty::Dynamic(ref tt, ..) => cx.tcx
|
||||
.associated_items(tt.principal().expect("trait impl not found").def_id())
|
||||
.any(|item| is_is_empty(cx, &item)),
|
||||
ty::TyProjection(ref proj) => has_is_empty_impl(cx, proj.item_def_id),
|
||||
ty::TyAdt(id, _) => has_is_empty_impl(cx, id.did),
|
||||
ty::TyArray(..) | ty::TySlice(..) | ty::TyStr => true,
|
||||
ty::Projection(ref proj) => has_is_empty_impl(cx, proj.item_def_id),
|
||||
ty::Adt(id, _) => has_is_empty_impl(cx, id.did),
|
||||
ty::Array(..) | ty::Slice(..) | ty::Str => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,13 +5,10 @@
|
|||
#![feature(slice_patterns)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(range_contains)]
|
||||
#![feature(macro_vis_matcher)]
|
||||
#![allow(unknown_lints, shadow_reuse, missing_docs_in_private_items)]
|
||||
#![recursion_limit = "256"]
|
||||
#![allow(stable_features)]
|
||||
#![feature(iterator_find_map)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
#![feature(tool_attributes)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use toml;
|
||||
|
|
|
@ -759,8 +759,8 @@ struct FixedOffsetVar {
|
|||
|
||||
fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'_>) -> bool {
|
||||
let is_slice = match ty.sty {
|
||||
ty::TyRef(_, subty, _) => is_slice_like(cx, subty),
|
||||
ty::TySlice(..) | ty::TyArray(..) => true,
|
||||
ty::Ref(_, subty, _) => is_slice_like(cx, subty),
|
||||
ty::Slice(..) | ty::Array(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
|
@ -1149,8 +1149,8 @@ fn check_for_loop_reverse_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &'tcx
|
|||
Constant::Int(start_idx),
|
||||
Constant::Int(end_idx),
|
||||
) => (match ty.sty {
|
||||
ty::TyInt(ity) => sext(cx.tcx, start_idx, ity) > sext(cx.tcx, end_idx, ity),
|
||||
ty::TyUint(_) => start_idx > end_idx,
|
||||
ty::Int(ity) => sext(cx.tcx, start_idx, ity) > sext(cx.tcx, end_idx, ity),
|
||||
ty::Uint(_) => start_idx > end_idx,
|
||||
_ => false,
|
||||
}, start_idx == end_idx),
|
||||
_ => (false, false),
|
||||
|
@ -1239,7 +1239,7 @@ fn check_for_loop_arg(cx: &LateContext<'_, '_>, pat: &Pat, arg: &Expr, expr: &Ex
|
|||
match cx.tables.expr_ty(&args[0]).sty {
|
||||
// If the length is greater than 32 no traits are implemented for array and
|
||||
// therefore we cannot use `&`.
|
||||
ty::TypeVariants::TyArray(_, size) if size.assert_usize(cx.tcx).expect("array size") > 32 => (),
|
||||
ty::TyKind::Array(_, size) if size.assert_usize(cx.tcx).expect("array size") > 32 => (),
|
||||
_ => lint_iter_method(cx, args, arg, method_name),
|
||||
};
|
||||
} else {
|
||||
|
@ -1381,7 +1381,7 @@ fn check_for_loop_over_map_kv<'a, 'tcx>(
|
|||
if pat.len() == 2 {
|
||||
let arg_span = arg.span;
|
||||
let (new_pat_span, kind, ty, mutbl) = match cx.tables.expr_ty(arg).sty {
|
||||
ty::TyRef(_, ty, mutbl) => match (&pat[0].node, &pat[1].node) {
|
||||
ty::Ref(_, ty, mutbl) => match (&pat[0].node, &pat[1].node) {
|
||||
(key, _) if pat_is_wild(key, body) => (pat[1].span, "value", ty, mutbl),
|
||||
(_, value) if pat_is_wild(value, body) => (pat[0].span, "key", ty, MutImmutable),
|
||||
_ => return,
|
||||
|
@ -1721,7 +1721,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
|
|||
for expr in args {
|
||||
let ty = self.cx.tables.expr_ty_adjusted(expr);
|
||||
self.prefer_mutable = false;
|
||||
if let ty::TyRef(_, _, mutbl) = ty.sty {
|
||||
if let ty::Ref(_, _, mutbl) = ty.sty {
|
||||
if mutbl == MutMutable {
|
||||
self.prefer_mutable = true;
|
||||
}
|
||||
|
@ -1733,7 +1733,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
|
|||
let def_id = self.cx.tables.type_dependent_defs()[expr.hir_id].def_id();
|
||||
for (ty, expr) in self.cx.tcx.fn_sig(def_id).inputs().skip_binder().iter().zip(args) {
|
||||
self.prefer_mutable = false;
|
||||
if let ty::TyRef(_, _, mutbl) = ty.sty {
|
||||
if let ty::Ref(_, _, mutbl) = ty.sty {
|
||||
if mutbl == MutMutable {
|
||||
self.prefer_mutable = true;
|
||||
}
|
||||
|
@ -1814,7 +1814,7 @@ fn is_ref_iterable_type(cx: &LateContext<'_, '_>, e: &Expr) -> bool {
|
|||
fn is_iterable_array(ty: Ty<'_>, cx: &LateContext<'_, '_>) -> bool {
|
||||
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
|
||||
match ty.sty {
|
||||
ty::TyArray(_, n) => (0..=32).contains(&n.assert_usize(cx.tcx).expect("array length")),
|
||||
ty::Array(_, n) => (0..=32).contains(&n.assert_usize(cx.tcx).expect("array length")),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
walk_ptrs_ty_depth(cx.tables.pat_ty(&first_arg.pat)).1 == 1
|
||||
{
|
||||
// the argument is not an &mut T
|
||||
if let ty::TyRef(_, _, mutbl) = ty.sty {
|
||||
if let ty::Ref(_, _, mutbl) = ty.sty {
|
||||
if mutbl == MutImmutable {
|
||||
span_help_and_lint(cx, MAP_CLONE, expr.span, &format!(
|
||||
"you seem to be using .map() to clone the contents of an {}, consider \
|
||||
|
|
|
@ -86,8 +86,8 @@ impl LintPass for Pass {
|
|||
|
||||
fn is_unit_type(ty: ty::Ty<'_>) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyTuple(slice) => slice.is_empty(),
|
||||
ty::TyNever => true,
|
||||
ty::Tuple(slice) => slice.is_empty(),
|
||||
ty::Never => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ fn is_unit_type(ty: ty::Ty<'_>) -> bool {
|
|||
fn is_unit_function(cx: &LateContext<'_, '_>, expr: &hir::Expr) -> bool {
|
||||
let ty = cx.tables.expr_ty(expr);
|
||||
|
||||
if let ty::TyFnDef(id, _) = ty.sty {
|
||||
if let ty::FnDef(id, _) = ty.sty {
|
||||
if let Some(fn_type) = cx.tcx.fn_sig(id).no_late_bound_regions() {
|
||||
return is_unit_type(fn_type.output());
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ fn check_single_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &
|
|||
return;
|
||||
};
|
||||
let ty = cx.tables.expr_ty(ex);
|
||||
if ty.sty != ty::TyBool || is_allowed(cx, MATCH_BOOL, ex.id) {
|
||||
if ty.sty != ty::Bool || is_allowed(cx, MATCH_BOOL, ex.id) {
|
||||
check_single_match_single_pattern(cx, ex, arms, expr, els);
|
||||
check_single_match_opt_like(cx, ex, arms, expr, ty, els);
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ fn check_single_match_opt_like(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm]
|
|||
|
||||
fn check_match_bool(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Expr) {
|
||||
// type of expression == bool
|
||||
if cx.tables.expr_ty(ex).sty == ty::TyBool {
|
||||
if cx.tables.expr_ty(ex).sty == ty::Bool {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
MATCH_BOOL,
|
||||
|
|
|
@ -784,7 +784,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
}
|
||||
|
||||
match self_ty.sty {
|
||||
ty::TyRef(_, ty, _) if ty.sty == ty::TyStr => for &(method, pos) in &PATTERN_METHODS {
|
||||
ty::Ref(_, ty, _) if ty.sty == ty::Str => for &(method, pos) in &PATTERN_METHODS {
|
||||
if method_call.ident.name == method && args.len() > pos {
|
||||
lint_single_char_pattern(cx, expr, &args[pos]);
|
||||
}
|
||||
|
@ -1113,8 +1113,8 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span:
|
|||
/// Checks for the `CLONE_ON_COPY` lint.
|
||||
fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Expr, arg_ty: Ty<'_>) {
|
||||
let ty = cx.tables.expr_ty(expr);
|
||||
if let ty::TyRef(_, inner, _) = arg_ty.sty {
|
||||
if let ty::TyRef(_, innermost, _) = inner.sty {
|
||||
if let ty::Ref(_, inner, _) = arg_ty.sty {
|
||||
if let ty::Ref(_, innermost, _) = inner.sty {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
CLONE_DOUBLE_REF,
|
||||
|
@ -1124,7 +1124,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
|
|||
|db| if let Some(snip) = sugg::Sugg::hir_opt(cx, arg) {
|
||||
let mut ty = innermost;
|
||||
let mut n = 0;
|
||||
while let ty::TyRef(_, inner, _) = ty.sty {
|
||||
while let ty::Ref(_, inner, _) = ty.sty {
|
||||
ty = inner;
|
||||
n += 1;
|
||||
}
|
||||
|
@ -1142,7 +1142,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
|
|||
if is_copy(cx, ty) {
|
||||
let snip;
|
||||
if let Some(snippet) = sugg::Sugg::hir_opt(cx, arg) {
|
||||
if let ty::TyRef(..) = cx.tables.expr_ty(arg).sty {
|
||||
if let ty::Ref(..) = cx.tables.expr_ty(arg).sty {
|
||||
let parent = cx.tcx.hir.get_parent_node(expr.id);
|
||||
match cx.tcx.hir.get(parent) {
|
||||
hir::map::NodeExpr(parent) => match parent.node {
|
||||
|
@ -1182,7 +1182,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
|
|||
fn lint_clone_on_ref_ptr(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Expr) {
|
||||
let obj_ty = walk_ptrs_ty(cx.tables.expr_ty(arg));
|
||||
|
||||
if let ty::TyAdt(_, subst) = obj_ty.sty {
|
||||
if let ty::Adt(_, subst) = obj_ty.sty {
|
||||
let caller_type = if match_type(cx, obj_ty, &paths::RC) {
|
||||
"Rc"
|
||||
} else if match_type(cx, obj_ty, &paths::ARC) {
|
||||
|
@ -1210,7 +1210,7 @@ fn lint_string_extend(cx: &LateContext<'_, '_>, expr: &hir::Expr, args: &[hir::E
|
|||
if let Some(arglists) = method_chain_args(arg, &["chars"]) {
|
||||
let target = &arglists[0][0];
|
||||
let self_ty = walk_ptrs_ty(cx.tables.expr_ty(target));
|
||||
let ref_str = if self_ty.sty == ty::TyStr {
|
||||
let ref_str = if self_ty.sty == ty::Str {
|
||||
""
|
||||
} else if match_type(cx, self_ty, &paths::STRING) {
|
||||
"&"
|
||||
|
@ -1442,11 +1442,11 @@ fn lint_iter_skip_next(cx: &LateContext<'_, '_>, expr: &hir::Expr) {
|
|||
fn derefs_to_slice(cx: &LateContext<'_, '_>, expr: &hir::Expr, ty: Ty<'_>) -> Option<sugg::Sugg<'static>> {
|
||||
fn may_slice(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> bool {
|
||||
match ty.sty {
|
||||
ty::TySlice(_) => true,
|
||||
ty::TyAdt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
|
||||
ty::TyAdt(..) => match_type(cx, ty, &paths::VEC),
|
||||
ty::TyArray(_, size) => size.assert_usize(cx.tcx).expect("array length") < 32,
|
||||
ty::TyRef(_, inner, _) => may_slice(cx, inner),
|
||||
ty::Slice(_) => true,
|
||||
ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
|
||||
ty::Adt(..) => match_type(cx, ty, &paths::VEC),
|
||||
ty::Array(_, size) => size.assert_usize(cx.tcx).expect("array length") < 32,
|
||||
ty::Ref(_, inner, _) => may_slice(cx, inner),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -1459,9 +1459,9 @@ fn derefs_to_slice(cx: &LateContext<'_, '_>, expr: &hir::Expr, ty: Ty<'_>) -> Op
|
|||
}
|
||||
} else {
|
||||
match ty.sty {
|
||||
ty::TySlice(_) => sugg::Sugg::hir_opt(cx, expr),
|
||||
ty::TyAdt(def, _) if def.is_box() && may_slice(cx, ty.boxed_ty()) => sugg::Sugg::hir_opt(cx, expr),
|
||||
ty::TyRef(_, inner, _) => if may_slice(cx, inner) {
|
||||
ty::Slice(_) => sugg::Sugg::hir_opt(cx, expr),
|
||||
ty::Adt(def, _) if def.is_box() && may_slice(cx, ty.boxed_ty()) => sugg::Sugg::hir_opt(cx, expr),
|
||||
ty::Ref(_, inner, _) => if may_slice(cx, inner) {
|
||||
sugg::Sugg::hir_opt(cx, expr)
|
||||
} else {
|
||||
None
|
||||
|
@ -1812,7 +1812,7 @@ fn lint_chars_cmp(
|
|||
then {
|
||||
let self_ty = walk_ptrs_ty(cx.tables.expr_ty_adjusted(&args[0][0]));
|
||||
|
||||
if self_ty.sty != ty::TyStr {
|
||||
if self_ty.sty != ty::Str {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1939,7 +1939,7 @@ fn lint_asref(cx: &LateContext<'_, '_>, expr: &hir::Expr, call_name: &str, as_re
|
|||
|
||||
/// Given a `Result<T, E>` type, return its error type (`E`).
|
||||
fn get_error_type<'a>(cx: &LateContext<'_, '_>, ty: Ty<'a>) -> Option<Ty<'a>> {
|
||||
if let ty::TyAdt(_, substs) = ty.sty {
|
||||
if let ty::Adt(_, substs) = ty.sty {
|
||||
if match_type(cx, ty, &paths::RESULT) {
|
||||
substs.types().nth(1)
|
||||
} else {
|
||||
|
|
|
@ -465,7 +465,7 @@ fn is_allowed<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) -> bool {
|
|||
}
|
||||
|
||||
fn is_float(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
|
||||
matches!(walk_ptrs_ty(cx.tables.expr_ty(expr)).sty, ty::TyFloat(_))
|
||||
matches!(walk_ptrs_ty(cx.tables.expr_ty(expr)).sty, ty::Float(_))
|
||||
}
|
||||
|
||||
fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
|
||||
|
|
|
@ -71,7 +71,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> {
|
|||
expr.span,
|
||||
"generally you want to avoid `&mut &mut _` if possible",
|
||||
);
|
||||
} else if let ty::TyRef(
|
||||
} else if let ty::Ref(
|
||||
_,
|
||||
_,
|
||||
hir::MutMutable,
|
||||
|
|
|
@ -58,16 +58,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
|
|||
|
||||
fn check_arguments<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arguments: &[Expr], type_definition: Ty<'tcx>, name: &str) {
|
||||
match type_definition.sty {
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
|
||||
ty::FnDef(..) | ty::FnPtr(_) => {
|
||||
let parameters = type_definition.fn_sig(cx.tcx).skip_binder().inputs();
|
||||
for (argument, parameter) in arguments.iter().zip(parameters.iter()) {
|
||||
match parameter.sty {
|
||||
ty::TyRef(
|
||||
ty::Ref(
|
||||
_,
|
||||
_,
|
||||
MutImmutable,
|
||||
) |
|
||||
ty::TyRawPtr(ty::TypeAndMut {
|
||||
ty::RawPtr(ty::TypeAndMut {
|
||||
mutbl: MutImmutable,
|
||||
..
|
||||
}) => if let ExprKind::AddrOf(MutMutable, _) = argument.node {
|
||||
|
|
|
@ -60,7 +60,7 @@ pub struct MutexAtomic;
|
|||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutexAtomic {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
let ty = cx.tables.expr_ty(expr);
|
||||
if let ty::TyAdt(_, subst) = ty.sty {
|
||||
if let ty::Adt(_, subst) = ty.sty {
|
||||
if match_type(cx, ty, &paths::MUTEX) {
|
||||
let mutex_param = subst.type_at(0);
|
||||
if let Some(atomic_name) = get_atomic_name(mutex_param) {
|
||||
|
@ -70,8 +70,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutexAtomic {
|
|||
atomic_name
|
||||
);
|
||||
match mutex_param.sty {
|
||||
ty::TyUint(t) if t != ast::UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg),
|
||||
ty::TyInt(t) if t != ast::IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg),
|
||||
ty::Uint(t) if t != ast::UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg),
|
||||
ty::Int(t) if t != ast::IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg),
|
||||
_ => span_lint(cx, MUTEX_ATOMIC, expr.span, &msg),
|
||||
};
|
||||
}
|
||||
|
@ -82,10 +82,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutexAtomic {
|
|||
|
||||
fn get_atomic_name(ty: Ty<'_>) -> Option<(&'static str)> {
|
||||
match ty.sty {
|
||||
ty::TyBool => Some("AtomicBool"),
|
||||
ty::TyUint(_) => Some("AtomicUsize"),
|
||||
ty::TyInt(_) => Some("AtomicIsize"),
|
||||
ty::TyRawPtr(_) => Some("AtomicPtr"),
|
||||
ty::Bool => Some("AtomicBool"),
|
||||
ty::Uint(_) => Some("AtomicUsize"),
|
||||
ty::Int(_) => Some("AtomicIsize"),
|
||||
ty::RawPtr(_) => Some("AtomicPtr"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
|
|||
return;
|
||||
}
|
||||
if let ExprKind::AddrOf(MutImmutable, ref inner) = e.node {
|
||||
if let ty::TyRef(..) = cx.tables.expr_ty(inner).sty {
|
||||
if let ty::Ref(..) = cx.tables.expr_ty(inner).sty {
|
||||
for adj3 in cx.tables.expr_adjustments(e).windows(3) {
|
||||
if let [Adjustment {
|
||||
kind: Adjust::Deref(_),
|
||||
|
@ -90,9 +90,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
|
|||
}
|
||||
if_chain! {
|
||||
if let PatKind::Binding(BindingAnnotation::Ref, _, name, _) = pat.node;
|
||||
if let ty::TyRef(_, tam, mutbl) = cx.tables.pat_ty(pat).sty;
|
||||
if let ty::Ref(_, tam, mutbl) = cx.tables.pat_ty(pat).sty;
|
||||
if mutbl == MutImmutable;
|
||||
if let ty::TyRef(_, _, mutbl) = tam.sty;
|
||||
if let ty::Ref(_, _, mutbl) = tam.sty;
|
||||
// only lint immutable refs, because borrowed `&mut T` cannot be moved out
|
||||
if mutbl == MutImmutable;
|
||||
then {
|
||||
|
|
|
@ -205,7 +205,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
|
|||
|
||||
// Dereference suggestion
|
||||
let sugg = |db: &mut DiagnosticBuilder<'_>| {
|
||||
if let ty::TypeVariants::TyAdt(def, ..) = ty.sty {
|
||||
if let ty::TyKind::Adt(def, ..) = ty.sty {
|
||||
if let Some(span) = cx.tcx.hir.span_if_local(def.did) {
|
||||
if cx.param_env.can_type_implement_copy(cx.tcx, ty).is_ok() {
|
||||
db.span_help(span, "consider marking this type as Copy");
|
||||
|
|
|
@ -35,7 +35,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let ExprKind::Struct(_, ref fields, Some(ref base)) = expr.node {
|
||||
let ty = cx.tables.expr_ty(expr);
|
||||
if let ty::TyAdt(def, _) = ty.sty {
|
||||
if let ty::Adt(def, _) = ty.sty {
|
||||
if fields.len() == def.non_enum_variant().fields.len() {
|
||||
span_lint(
|
||||
cx,
|
||||
|
|
|
@ -169,7 +169,7 @@ fn create_new_without_default_suggest_msg(ty: Ty<'_>) -> String {
|
|||
|
||||
fn can_derive_default<'t, 'c>(ty: Ty<'t>, cx: &LateContext<'c, 't>, default_trait_id: DefId) -> Option<Span> {
|
||||
match ty.sty {
|
||||
ty::TyAdt(adt_def, substs) if adt_def.is_struct() => {
|
||||
ty::Adt(adt_def, substs) if adt_def.is_struct() => {
|
||||
for field in adt_def.all_fields() {
|
||||
let f_ty = field.ty(cx.tcx, substs);
|
||||
if !implements_trait(cx, f_ty, default_trait_id, &[]) {
|
||||
|
|
|
@ -152,7 +152,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id:
|
|||
let fn_ty = sig.skip_binder();
|
||||
|
||||
for (idx, (arg, ty)) in decl.inputs.iter().zip(fn_ty.inputs()).enumerate() {
|
||||
if let ty::TyRef(
|
||||
if let ty::Ref(
|
||||
_,
|
||||
ty,
|
||||
MutImmutable
|
||||
|
|
|
@ -155,7 +155,7 @@ fn check_decl<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx Decl, bindings:
|
|||
fn is_binding(cx: &LateContext<'_, '_>, pat_id: HirId) -> bool {
|
||||
let var_ty = cx.tables.node_id_to_type(pat_id);
|
||||
match var_ty.sty {
|
||||
ty::TyAdt(..) => false,
|
||||
ty::Adt(..) => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,8 +93,8 @@ 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(_)) ||
|
||||
matches!(ty.sty, ty::TyArray(_, _)) ||
|
||||
if matches!(ty.sty, ty::Slice(_)) ||
|
||||
matches!(ty.sty, ty::Array(_, _)) ||
|
||||
match_type(cx, ty, &paths::VEC) ||
|
||||
match_type(cx, ty, &paths::VEC_DEQUE) {
|
||||
return Some((lhs1, idx1, idx2));
|
||||
|
|
|
@ -231,7 +231,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
|||
e.span,
|
||||
&format!("transmute from a type (`{}`) to itself", from_ty),
|
||||
),
|
||||
(&ty::TyRef(_, rty, rty_mutbl), &ty::TyRawPtr(ptr_ty)) => span_lint_and_then(
|
||||
(&ty::Ref(_, rty, rty_mutbl), &ty::RawPtr(ptr_ty)) => span_lint_and_then(
|
||||
cx,
|
||||
USELESS_TRANSMUTE,
|
||||
e.span,
|
||||
|
@ -248,7 +248,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
|||
db.span_suggestion(e.span, "try", sugg.to_string());
|
||||
},
|
||||
),
|
||||
(&ty::TyInt(_), &ty::TyRawPtr(_)) | (&ty::TyUint(_), &ty::TyRawPtr(_)) => {
|
||||
(&ty::Int(_), &ty::RawPtr(_)) | (&ty::Uint(_), &ty::RawPtr(_)) => {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
USELESS_TRANSMUTE,
|
||||
|
@ -259,16 +259,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
|||
},
|
||||
)
|
||||
},
|
||||
(&ty::TyFloat(_), &ty::TyRef(..)) |
|
||||
(&ty::TyFloat(_), &ty::TyRawPtr(_)) |
|
||||
(&ty::TyChar, &ty::TyRef(..)) |
|
||||
(&ty::TyChar, &ty::TyRawPtr(_)) => span_lint(
|
||||
(&ty::Float(_), &ty::Ref(..)) |
|
||||
(&ty::Float(_), &ty::RawPtr(_)) |
|
||||
(&ty::Char, &ty::Ref(..)) |
|
||||
(&ty::Char, &ty::RawPtr(_)) => span_lint(
|
||||
cx,
|
||||
WRONG_TRANSMUTE,
|
||||
e.span,
|
||||
&format!("transmute from a `{}` to a pointer", from_ty),
|
||||
),
|
||||
(&ty::TyRawPtr(from_ptr), _) if from_ptr.ty == to_ty => span_lint(
|
||||
(&ty::RawPtr(from_ptr), _) if from_ptr.ty == to_ty => span_lint(
|
||||
cx,
|
||||
CROSSPOINTER_TRANSMUTE,
|
||||
e.span,
|
||||
|
@ -278,7 +278,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
|||
to_ty
|
||||
),
|
||||
),
|
||||
(_, &ty::TyRawPtr(to_ptr)) if to_ptr.ty == from_ty => span_lint(
|
||||
(_, &ty::RawPtr(to_ptr)) if to_ptr.ty == from_ty => span_lint(
|
||||
cx,
|
||||
CROSSPOINTER_TRANSMUTE,
|
||||
e.span,
|
||||
|
@ -288,7 +288,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
|||
to_ty
|
||||
),
|
||||
),
|
||||
(&ty::TyRawPtr(from_pty), &ty::TyRef(_, to_ref_ty, mutbl)) => span_lint_and_then(
|
||||
(&ty::RawPtr(from_pty), &ty::Ref(_, to_ref_ty, mutbl)) => span_lint_and_then(
|
||||
cx,
|
||||
TRANSMUTE_PTR_TO_REF,
|
||||
e.span,
|
||||
|
@ -315,16 +315,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
|||
db.span_suggestion(e.span, "try", sugg::make_unop(deref, arg).to_string());
|
||||
},
|
||||
),
|
||||
(&ty::TyInt(ast::IntTy::I32), &ty::TyChar) |
|
||||
(&ty::TyUint(ast::UintTy::U32), &ty::TyChar) => span_lint_and_then(
|
||||
(&ty::Int(ast::IntTy::I32), &ty::Char) |
|
||||
(&ty::Uint(ast::UintTy::U32), &ty::Char) => span_lint_and_then(
|
||||
cx,
|
||||
TRANSMUTE_INT_TO_CHAR,
|
||||
e.span,
|
||||
&format!("transmute from a `{}` to a `char`", from_ty),
|
||||
|db| {
|
||||
let arg = sugg::Sugg::hir(cx, &args[0], "..");
|
||||
let arg = if let ty::TyInt(_) = from_ty.sty {
|
||||
arg.as_ty(ty::TyUint(ast::UintTy::U32))
|
||||
let arg = if let ty::Int(_) = from_ty.sty {
|
||||
arg.as_ty(ty::Uint(ast::UintTy::U32))
|
||||
} else {
|
||||
arg
|
||||
};
|
||||
|
@ -335,10 +335,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
|||
);
|
||||
},
|
||||
),
|
||||
(&ty::TyRef(_, ty_from, from_mutbl), &ty::TyRef(_, ty_to, to_mutbl)) => {
|
||||
(&ty::Ref(_, ty_from, from_mutbl), &ty::Ref(_, ty_to, to_mutbl)) => {
|
||||
if_chain! {
|
||||
if let (&ty::TySlice(slice_ty), &ty::TyStr) = (&ty_from.sty, &ty_to.sty);
|
||||
if let ty::TyUint(ast::UintTy::U8) = slice_ty.sty;
|
||||
if let (&ty::Slice(slice_ty), &ty::Str) = (&ty_from.sty, &ty_to.sty);
|
||||
if let ty::Uint(ast::UintTy::U8) = slice_ty.sty;
|
||||
if from_mutbl == to_mutbl;
|
||||
then {
|
||||
let postfix = if from_mutbl == Mutability::MutMutable {
|
||||
|
@ -387,7 +387,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
|||
}
|
||||
}
|
||||
},
|
||||
(&ty::TyRawPtr(_), &ty::TyRawPtr(to_ty)) => span_lint_and_then(
|
||||
(&ty::RawPtr(_), &ty::RawPtr(to_ty)) => span_lint_and_then(
|
||||
cx,
|
||||
TRANSMUTE_PTR_TO_PTR,
|
||||
e.span,
|
||||
|
@ -397,7 +397,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
|||
db.span_suggestion(e.span, "try", sugg.to_string());
|
||||
},
|
||||
),
|
||||
(&ty::TyInt(ast::IntTy::I8), &ty::TyBool) | (&ty::TyUint(ast::UintTy::U8), &ty::TyBool) => {
|
||||
(&ty::Int(ast::IntTy::I8), &ty::Bool) | (&ty::Uint(ast::UintTy::U8), &ty::Bool) => {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
TRANSMUTE_INT_TO_BOOL,
|
||||
|
@ -414,7 +414,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
|||
},
|
||||
)
|
||||
},
|
||||
(&ty::TyInt(_), &ty::TyFloat(_)) | (&ty::TyUint(_), &ty::TyFloat(_)) => {
|
||||
(&ty::Int(_), &ty::Float(_)) | (&ty::Uint(_), &ty::Float(_)) => {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
TRANSMUTE_INT_TO_FLOAT,
|
||||
|
@ -422,7 +422,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
|||
&format!("transmute from a `{}` to a `{}`", from_ty, to_ty),
|
||||
|db| {
|
||||
let arg = sugg::Sugg::hir(cx, &args[0], "..");
|
||||
let arg = if let ty::TyInt(int_ty) = from_ty.sty {
|
||||
let arg = if let ty::Int(int_ty) = from_ty.sty {
|
||||
arg.as_ty(format!(
|
||||
"u{}",
|
||||
int_ty
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
use std::cmp;
|
||||
|
||||
use matches::matches;
|
||||
use rustc::hir;
|
||||
use rustc::hir::*;
|
||||
use rustc::hir::map::*;
|
||||
use rustc::hir::intravisit::FnKind;
|
||||
use rustc::lint::*;
|
||||
use rustc::{declare_lint, lint_array};
|
||||
use if_chain::if_chain;
|
||||
use rustc::ty::TypeVariants;
|
||||
use rustc::ty::TyKind;
|
||||
use rustc::session::config::Config as SessionConfig;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
@ -125,8 +126,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
|
|||
// argument. In that case we can't switch to pass-by-value as the
|
||||
// argument will not live long enough.
|
||||
let output_lts = match fn_sig.output().sty {
|
||||
TypeVariants::TyRef(output_lt, _, _) => vec![output_lt],
|
||||
TypeVariants::TyAdt(_, substs) => substs.regions().collect(),
|
||||
TyKind::Ref(output_lt, _, _) => vec![output_lt],
|
||||
TyKind::Adt(_, substs) => substs.regions().collect(),
|
||||
_ => vec![],
|
||||
};
|
||||
|
||||
|
@ -137,12 +138,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
|
|||
}
|
||||
|
||||
if_chain! {
|
||||
if let TypeVariants::TyRef(input_lt, ty, Mutability::MutImmutable) = ty.sty;
|
||||
if let TyKind::Ref(input_lt, ty, Mutability::MutImmutable) = ty.sty;
|
||||
if !output_lts.contains(&input_lt);
|
||||
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 TyKind::Rptr(_, MutTy { ty: ref decl_ty, .. }) = input.node;
|
||||
if let hir::TyKind::Rptr(_, MutTy { ty: ref decl_ty, .. }) = input.node;
|
||||
then {
|
||||
let value_type = if is_self(arg) {
|
||||
"self".into()
|
||||
|
|
|
@ -550,7 +550,7 @@ fn is_questionmark_desugar_marked_call(expr: &Expr) -> bool {
|
|||
|
||||
fn is_unit(ty: Ty<'_>) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyTuple(slice) if slice.is_empty() => true,
|
||||
ty::Tuple(slice) if slice.is_empty() => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -755,7 +755,7 @@ declare_clippy_lint! {
|
|||
/// Will return 0 if the type is not an int or uint variant
|
||||
fn int_ty_to_nbits(typ: Ty<'_>, tcx: TyCtxt<'_, '_, '_>) -> u64 {
|
||||
match typ.sty {
|
||||
ty::TyInt(i) => match i {
|
||||
ty::Int(i) => match i {
|
||||
IntTy::Isize => tcx.data_layout.pointer_size.bits(),
|
||||
IntTy::I8 => 8,
|
||||
IntTy::I16 => 16,
|
||||
|
@ -763,7 +763,7 @@ fn int_ty_to_nbits(typ: Ty<'_>, tcx: TyCtxt<'_, '_, '_>) -> u64 {
|
|||
IntTy::I64 => 64,
|
||||
IntTy::I128 => 128,
|
||||
},
|
||||
ty::TyUint(i) => match i {
|
||||
ty::Uint(i) => match i {
|
||||
UintTy::Usize => tcx.data_layout.pointer_size.bits(),
|
||||
UintTy::U8 => 8,
|
||||
UintTy::U16 => 16,
|
||||
|
@ -777,7 +777,7 @@ fn int_ty_to_nbits(typ: Ty<'_>, tcx: TyCtxt<'_, '_, '_>) -> u64 {
|
|||
|
||||
fn is_isize_or_usize(typ: Ty<'_>) -> bool {
|
||||
match typ.sty {
|
||||
ty::TyInt(IntTy::Isize) | ty::TyUint(UintTy::Usize) => true,
|
||||
ty::Int(IntTy::Isize) | ty::Uint(UintTy::Usize) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -973,7 +973,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
|
|||
match (cast_from.is_integral(), cast_to.is_integral()) {
|
||||
(true, false) => {
|
||||
let from_nbits = int_ty_to_nbits(cast_from, cx.tcx);
|
||||
let to_nbits = if let ty::TyFloat(FloatTy::F32) = cast_to.sty {
|
||||
let to_nbits = if let ty::Float(FloatTy::F32) = cast_to.sty {
|
||||
32
|
||||
} else {
|
||||
64
|
||||
|
@ -1014,7 +1014,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
|
|||
check_lossless(cx, expr, ex, cast_from, cast_to);
|
||||
},
|
||||
(false, false) => {
|
||||
if let (&ty::TyFloat(FloatTy::F64), &ty::TyFloat(FloatTy::F32)) = (&cast_from.sty, &cast_to.sty)
|
||||
if let (&ty::Float(FloatTy::F64), &ty::Float(FloatTy::F32)) = (&cast_from.sty, &cast_to.sty)
|
||||
{
|
||||
span_lint(
|
||||
cx,
|
||||
|
@ -1023,7 +1023,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
|
|||
"casting f64 to f32 may truncate the value",
|
||||
);
|
||||
}
|
||||
if let (&ty::TyFloat(FloatTy::F32), &ty::TyFloat(FloatTy::F64)) = (&cast_from.sty, &cast_to.sty)
|
||||
if let (&ty::Float(FloatTy::F32), &ty::Float(FloatTy::F64)) = (&cast_from.sty, &cast_to.sty)
|
||||
{
|
||||
span_lossless_lint(cx, expr, ex, cast_from, cast_to);
|
||||
}
|
||||
|
@ -1032,9 +1032,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
|
|||
}
|
||||
|
||||
match &cast_from.sty {
|
||||
ty::TyFnDef(..) |
|
||||
ty::TyFnPtr(..) => {
|
||||
if cast_to.is_numeric() && cast_to.sty != ty::TyUint(UintTy::Usize){
|
||||
ty::FnDef(..) |
|
||||
ty::FnPtr(..) => {
|
||||
if cast_to.is_numeric() && cast_to.sty != ty::Uint(UintTy::Usize){
|
||||
let to_nbits = int_ty_to_nbits(cast_to, cx.tcx);
|
||||
let pointer_nbits = cx.tcx.data_layout.pointer_size.bits();
|
||||
if to_nbits < pointer_nbits || (to_nbits == pointer_nbits && cast_to.is_signed()) {
|
||||
|
@ -1063,8 +1063,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
|
|||
}
|
||||
|
||||
if_chain!{
|
||||
if let ty::TyRawPtr(from_ptr_ty) = &cast_from.sty;
|
||||
if let ty::TyRawPtr(to_ptr_ty) = &cast_to.sty;
|
||||
if let ty::RawPtr(from_ptr_ty) = &cast_from.sty;
|
||||
if let ty::RawPtr(to_ptr_ty) = &cast_to.sty;
|
||||
if let Some(from_align) = cx.layout_of(from_ptr_ty.ty).ok().map(|a| a.align.abi());
|
||||
if let Some(to_align) = cx.layout_of(to_ptr_ty.ty).ok().map(|a| a.align.abi());
|
||||
if from_align < to_align;
|
||||
|
@ -1294,7 +1294,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CharLitAsU8 {
|
|||
if let ExprKind::Cast(ref e, _) = expr.node {
|
||||
if let ExprKind::Lit(ref l) = e.node {
|
||||
if let LitKind::Char(_) = l.node {
|
||||
if ty::TyUint(UintTy::U8) == cx.tables.expr_ty(expr).sty && !in_macro(expr.span) {
|
||||
if ty::Uint(UintTy::U8) == cx.tables.expr_ty(expr).sty && !in_macro(expr.span) {
|
||||
let msg = "casting character literal to u8. `char`s \
|
||||
are 4 bytes wide in rust, so casting to u8 \
|
||||
truncates them";
|
||||
|
@ -1434,13 +1434,13 @@ fn detect_extreme_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) -
|
|||
let cv = constant(cx, cx.tables, expr)?.0;
|
||||
|
||||
let which = match (&ty.sty, cv) {
|
||||
(&ty::TyBool, Constant::Bool(false)) |
|
||||
(&ty::TyUint(_), Constant::Int(0)) => Minimum,
|
||||
(&ty::TyInt(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::min_value() >> (128 - int_bits(cx.tcx, ity)), ity) => Minimum,
|
||||
(&ty::Bool, Constant::Bool(false)) |
|
||||
(&ty::Uint(_), Constant::Int(0)) => Minimum,
|
||||
(&ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::min_value() >> (128 - int_bits(cx.tcx, ity)), ity) => Minimum,
|
||||
|
||||
(&ty::TyBool, Constant::Bool(true)) => Maximum,
|
||||
(&ty::TyInt(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::max_value() >> (128 - int_bits(cx.tcx, ity)), ity) => Maximum,
|
||||
(&ty::TyUint(uty), Constant::Int(i)) if clip(cx.tcx, u128::max_value(), uty) == i => Maximum,
|
||||
(&ty::Bool, Constant::Bool(true)) => Maximum,
|
||||
(&ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::max_value() >> (128 - int_bits(cx.tcx, ity)), ity) => Maximum,
|
||||
(&ty::Uint(uty), Constant::Int(i)) if clip(cx.tcx, u128::max_value(), uty) == i => Maximum,
|
||||
|
||||
_ => return None,
|
||||
};
|
||||
|
@ -1574,7 +1574,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) ->
|
|||
return None;
|
||||
}
|
||||
match pre_cast_ty.sty {
|
||||
ty::TyInt(int_ty) => Some(match int_ty {
|
||||
ty::Int(int_ty) => Some(match int_ty {
|
||||
IntTy::I8 => (FullInt::S(i128::from(i8::min_value())), FullInt::S(i128::from(i8::max_value()))),
|
||||
IntTy::I16 => (
|
||||
FullInt::S(i128::from(i16::min_value())),
|
||||
|
@ -1591,7 +1591,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) ->
|
|||
IntTy::I128 => (FullInt::S(i128::min_value() as i128), FullInt::S(i128::max_value() as i128)),
|
||||
IntTy::Isize => (FullInt::S(isize::min_value() as i128), FullInt::S(isize::max_value() as i128)),
|
||||
}),
|
||||
ty::TyUint(uint_ty) => Some(match uint_ty {
|
||||
ty::Uint(uint_ty) => Some(match uint_ty {
|
||||
UintTy::U8 => (FullInt::U(u128::from(u8::min_value())), FullInt::U(u128::from(u8::max_value()))),
|
||||
UintTy::U16 => (
|
||||
FullInt::U(u128::from(u16::min_value())),
|
||||
|
@ -1619,8 +1619,8 @@ fn node_as_const_fullint<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr)
|
|||
let val = constant(cx, cx.tables, expr)?.0;
|
||||
if let Constant::Int(const_int) = val {
|
||||
match cx.tables.expr_ty(expr).sty {
|
||||
ty::TyInt(ity) => Some(FullInt::S(sext(cx.tcx, const_int, ity))),
|
||||
ty::TyUint(_) => Some(FullInt::U(const_int)),
|
||||
ty::Int(ity) => Some(FullInt::S(sext(cx.tcx, const_int, ity))),
|
||||
ty::Uint(_) => Some(FullInt::U(const_int)),
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
@ -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) |
|
||||
|
|
|
@ -37,8 +37,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
// search for `&vec![_]` expressions where the adjusted type is `&[_]`
|
||||
if_chain! {
|
||||
if let ty::TyRef(_, ty, _) = cx.tables.expr_ty_adjusted(expr).sty;
|
||||
if let ty::TySlice(..) = ty.sty;
|
||||
if let ty::Ref(_, ty, _) = cx.tables.expr_ty_adjusted(expr).sty;
|
||||
if let ty::Slice(..) = ty.sty;
|
||||
if let ExprKind::AddrOf(_, ref addressee) = expr.node;
|
||||
if let Some(vec_args) = higher::vec_macro(cx, addressee);
|
||||
then {
|
||||
|
@ -95,7 +95,7 @@ fn check_vec_macro<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, vec_args: &higher::VecA
|
|||
|
||||
/// Return the item type of the vector (ie. the `T` in `Vec<T>`).
|
||||
fn vec_type(ty: Ty<'_>) -> Ty<'_> {
|
||||
if let ty::TyAdt(_, substs) = ty.sty {
|
||||
if let ty::Adt(_, substs) = ty.sty {
|
||||
substs.type_at(0)
|
||||
} else {
|
||||
panic!("The type of `vec!` is a not a struct?");
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// error-pattern:cargo-clippy
|
||||
#![feature(plugin_registrar)]
|
||||
#![feature(rustc_private)]
|
||||
#![feature(macro_vis_matcher)]
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(missing_docs_in_private_items)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(tool_attributes)]
|
||||
|
||||
|
||||
// Tests for the various helper functions used by the needless_continue
|
||||
// lint that don't belong in utils.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(tool_attributes)]
|
||||
|
||||
|
||||
/// test the multiline-trim function
|
||||
extern crate clippy_lints;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(tool_attributes)]
|
||||
|
||||
|
||||
fn main() {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(tool_attributes)]
|
||||
|
||||
|
||||
fn main() {
|
||||
#[clippy::author]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(tool_attributes, stmt_expr_attributes)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
fn main() {
|
||||
#[clippy::author]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(tool_attributes)]
|
||||
|
||||
|
||||
#![allow(clippy)]
|
||||
#![warn(cyclomatic_complexity)]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(tool_attributes)]
|
||||
|
||||
|
||||
#![warn(cyclomatic_complexity)]
|
||||
#![warn(unused)]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(stmt_expr_attributes, tool_attributes)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
#![allow(unused_parens)]
|
||||
|
||||
|
|
Loading…
Reference in a new issue