From f66e0aad840e587f9c9a817f65603897f28bcbe8 Mon Sep 17 00:00:00 2001 From: Enrico Schmitz Date: Wed, 1 Mar 2017 13:24:19 +0100 Subject: [PATCH] Fix for rustc 1.17.0-nightly (be760566c 2017-02-28) --- clippy_lints/src/array_indexing.rs | 13 ++++++------- clippy_lints/src/bit_mask.rs | 3 ++- clippy_lints/src/consts.rs | 8 ++++---- clippy_lints/src/cyclomatic_complexity.rs | 2 +- clippy_lints/src/enum_clike.rs | 2 +- clippy_lints/src/eta_reduction.rs | 2 +- clippy_lints/src/eval_order_dependence.rs | 2 +- clippy_lints/src/identity_op.rs | 6 +++--- clippy_lints/src/len_zero.rs | 5 +++-- clippy_lints/src/lifetimes.rs | 2 +- clippy_lints/src/loops.rs | 5 ++--- clippy_lints/src/matches.rs | 9 ++++----- clippy_lints/src/mem_forget.rs | 2 +- clippy_lints/src/methods.rs | 3 +-- clippy_lints/src/misc.rs | 19 +++++-------------- clippy_lints/src/mut_reference.rs | 2 +- clippy_lints/src/needless_pass_by_value.rs | 2 +- clippy_lints/src/ptr.rs | 3 ++- clippy_lints/src/regex.rs | 3 +-- clippy_lints/src/types.rs | 12 +++--------- clippy_lints/src/utils/mod.rs | 4 ++-- clippy_lints/src/vec.rs | 3 +-- 22 files changed, 47 insertions(+), 65 deletions(-) diff --git a/clippy_lints/src/array_indexing.rs b/clippy_lints/src/array_indexing.rs index 2ab70da8c73..f5902747d4f 100644 --- a/clippy_lints/src/array_indexing.rs +++ b/clippy_lints/src/array_indexing.rs @@ -1,7 +1,6 @@ use rustc::lint::*; use rustc::middle::const_val::ConstVal; use rustc::ty; -use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::ConstContext; use rustc_const_math::ConstInt; use rustc::hir; @@ -61,11 +60,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIndexing { // Array with known size can be checked statically let ty = cx.tables.expr_ty(array); if let ty::TyArray(_, size) = ty.sty { - let size = ConstInt::Infer(size as u128); + let size = ConstInt::U128(size as u128); let constcx = ConstContext::with_tables(cx.tcx, cx.tables); // Index is a constant uint - let const_index = constcx.eval(index, ExprTypeChecked); + let const_index = constcx.eval(index); if let Ok(ConstVal::Integral(const_index)) = const_index { if size <= const_index { utils::span_lint(cx, OUT_OF_BOUNDS_INDEXING, e.span, "const index is out of bounds"); @@ -77,10 +76,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIndexing { // Index is a constant range if let Some(range) = higher::range(index) { let start = range.start - .map(|start| constcx.eval(start, ExprTypeChecked)) + .map(|start| constcx.eval(start)) .map(|v| v.ok()); let end = range.end - .map(|end| constcx.eval(end, ExprTypeChecked)) + .map(|end| constcx.eval(end)) .map(|v| v.ok()); if let Some((start, end)) = to_const_range(&start, &end, range.limits, size) { @@ -117,13 +116,13 @@ fn to_const_range( let start = match *start { Some(Some(ConstVal::Integral(x))) => x, Some(_) => return None, - None => ConstInt::Infer(0), + None => ConstInt::U8(0), }; let end = match *end { Some(Some(ConstVal::Integral(x))) => { if limits == RangeLimits::Closed { - (x + ConstInt::Infer(1)).expect("such a big array is not realistic") + (x + ConstInt::U8(1)).expect("such a big array is not realistic") } else { x } diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index 06e8e918264..789de240d73 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -237,6 +237,7 @@ fn check_ineffective_gt(cx: &LateContext, span: Span, m: u128, c: u128, op: &str } fn fetch_int_literal(cx: &LateContext, lit: &Expr) -> Option { + use rustc::ty::subst::Substs; match lit.node { ExprLit(ref lit_ptr) => { if let LitKind::Int(value, _) = lit_ptr.node { @@ -248,7 +249,7 @@ fn fetch_int_literal(cx: &LateContext, lit: &Expr) -> Option { ExprPath(ref qpath) => { let def = cx.tables.qpath_def(qpath, lit.id); if let Def::Const(def_id) = def { - lookup_const_by_id(cx.tcx, def_id, None).and_then(|(l, _tab, _ty)| fetch_int_literal(cx, l)) + lookup_const_by_id(cx.tcx, def_id, Substs::empty()).and_then(|(l, _ty)| fetch_int_literal(cx, l)) } else { None } diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 46371b938bc..f8e9cff80df 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -180,7 +180,7 @@ pub fn lit_to_constant(lit: &LitKind) -> Constant { LitKind::Byte(b) => Constant::Int(ConstInt::U8(b)), LitKind::ByteStr(ref s) => Constant::Binary(s.clone()), LitKind::Char(c) => Constant::Char(c), - LitKind::Int(value, LitIntType::Unsuffixed) => Constant::Int(ConstInt::Infer(value)), + LitKind::Int(value, LitIntType::Unsuffixed) => Constant::Int(ConstInt::U128(value as u128)), LitKind::Int(value, LitIntType::Unsigned(UintTy::U8)) => Constant::Int(ConstInt::U8(value as u8)), LitKind::Int(value, LitIntType::Unsigned(UintTy::U16)) => Constant::Int(ConstInt::U16(value as u16)), LitKind::Int(value, LitIntType::Unsigned(UintTy::U32)) => Constant::Int(ConstInt::U32(value as u32)), @@ -297,10 +297,10 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { match def { Def::Const(def_id) | Def::AssociatedConst(def_id) => { - let substs = Some(lcx.tables + let substs = lcx.tables .node_id_item_substs(id) - .unwrap_or_else(|| lcx.tcx.intern_substs(&[]))); - if let Some((const_expr, _tab, _ty)) = lookup_const_by_id(lcx.tcx, def_id, substs) { + .unwrap_or_else(|| lcx.tcx.intern_substs(&[])); + if let Some((const_expr, _ty)) = lookup_const_by_id(lcx.tcx, def_id, substs) { let ret = self.expr(const_expr); if ret.is_some() { self.needed_resolution = true; diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs index 9d6056de343..33c27b53b83 100644 --- a/clippy_lints/src/cyclomatic_complexity.rs +++ b/clippy_lints/src/cyclomatic_complexity.rs @@ -136,7 +136,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CCHelper<'a, 'tcx> { let ty = self.cx.tables.node_id_to_type(callee.id); match ty.sty { ty::TyFnDef(_, _, ty) | - ty::TyFnPtr(ty) if ty.sig.skip_binder().output().sty == ty::TyNever => { + ty::TyFnPtr(ty) if ty.skip_binder().output().sty == ty::TyNever => { self.divergence += 1; }, _ => (), diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index e924ae79df9..4032234ac5c 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -45,7 +45,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant { if let Some(body_id) = variant.disr_expr { use rustc_const_eval::*; let constcx = ConstContext::new(cx.tcx, body_id); - let bad = match constcx.eval(&cx.tcx.hir.body(body_id).value, EvalHint::ExprTypeChecked) { + let bad = match constcx.eval(&cx.tcx.hir.body(body_id).value) { Ok(ConstVal::Integral(Usize(Us64(i)))) => i as u32 as u64 != i, Ok(ConstVal::Integral(Isize(Is64(i)))) => i as i32 as i64 != i, _ => false, diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 40678e324b0..8230fe73130 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -66,7 +66,7 @@ fn check_closure(cx: &LateContext, expr: &Expr) { // Is it an unsafe function? They don't implement the closure traits ty::TyFnDef(_, _, fn_ty) | ty::TyFnPtr(fn_ty) => { - if fn_ty.unsafety == Unsafety::Unsafe || fn_ty.sig.skip_binder().output().sty == ty::TyNever { + if fn_ty.skip_binder().unsafety == Unsafety::Unsafe || fn_ty.skip_binder().output().sty == ty::TyNever { return; } }, diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 798bd6cf1f7..f07ec7de52b 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -129,7 +129,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> { match self.cx.tables.expr_ty(func).sty { ty::TyFnDef(_, _, fn_ty) | ty::TyFnPtr(fn_ty) => { - if let ty::TyNever = self.cx.tcx.erase_late_bound_regions(&fn_ty.sig).output().sty { + if let ty::TyNever = self.cx.tcx.erase_late_bound_regions(&fn_ty).output().sty { self.report_diverging_sub_expr(e); } }, diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index a10a9523ac1..58a0ba4c9e9 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -62,9 +62,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp { fn check(cx: &LateContext, e: &Expr, m: i8, span: Span, arg: Span) { if let Some(v @ Constant::Int(_)) = constant_simple(e) { if match m { - 0 => v == Constant::Int(ConstInt::Infer(0)), - -1 => v == Constant::Int(ConstInt::InferSigned(-1)), - 1 => v == Constant::Int(ConstInt::Infer(1)), + 0 => v == Constant::Int(ConstInt::U8(0)), + -1 => v == Constant::Int(ConstInt::I8(-1)), + 1 => v == Constant::Int(ConstInt::U8(1)), _ => unreachable!(), } { span_lint(cx, diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index cc4df4581fb..03522cc02cd 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -186,7 +186,8 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool { fn is_is_empty(cx: &LateContext, item: &ty::AssociatedItem) -> bool { if let ty::AssociatedKind::Method = item.kind { if &*item.name.as_str() == "is_empty" { - let ty = cx.tcx.item_type(item.def_id).fn_sig().skip_binder(); + let sig = cx.tcx.item_type(item.def_id).fn_sig(); + let ty = sig.skip_binder(); ty.inputs().len() == 1 } else { false @@ -198,7 +199,7 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool { /// Check the inherent impl's items for an `is_empty(self)` method. fn has_is_empty_impl(cx: &LateContext, id: DefId) -> bool { - cx.tcx.inherent_impls.borrow().get(&id).map_or(false, |impls| { + cx.tcx.maps.inherent_impls.borrow().get(&id).map_or(false, |impls| { impls.iter().any(|imp| cx.tcx.associated_items(*imp).any(|item| is_is_empty(cx, &item))) }) } diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 2051c883670..1571372cefb 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -257,7 +257,7 @@ impl<'v, 't> RefVisitor<'v, 't> { } }, Def::Trait(def_id) => { - let trait_def = self.cx.tcx.trait_defs.borrow()[&def_id]; + let trait_def = self.cx.tcx.maps.trait_def.borrow()[&def_id]; for _ in &self.cx.tcx.item_generics(trait_def.def_id).regions { self.record(&None); } diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index dd9ec1f6e23..8c1f47a2187 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -8,7 +8,6 @@ use rustc::lint::*; use rustc::middle::const_val::ConstVal; use rustc::middle::region::CodeExtent; use rustc::ty; -use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::ConstContext; use std::collections::HashMap; use syntax::ast; @@ -596,8 +595,8 @@ fn check_for_loop_reverse_range(cx: &LateContext, arg: &Expr, expr: &Expr) { if let Some(higher::Range { start: Some(start), end: Some(end), limits }) = higher::range(arg) { // ...and both sides are compile-time constant integers... let constcx = ConstContext::with_tables(cx.tcx, cx.tables); - if let Ok(start_idx) = constcx.eval(start, ExprTypeChecked) { - if let Ok(end_idx) = constcx.eval(end, ExprTypeChecked) { + if let Ok(start_idx) = constcx.eval(start) { + if let Ok(end_idx) = constcx.eval(end) { // ...and the start index is greater than the end index, // this loop will never run. This is often confusing for developers // who think that this will iterate from the larger value to the diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 5a8ff442262..c4132c4881a 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -2,7 +2,6 @@ use rustc::hir::*; use rustc::lint::*; use rustc::middle::const_val::ConstVal; use rustc::ty; -use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::ConstContext; use rustc_const_math::ConstInt; use std::cmp::Ordering; @@ -415,7 +414,7 @@ fn check_match_ref_pats(cx: &LateContext, ex: &Expr, arms: &[Arm], source: Match } /// Get all arms that are unbounded `PatRange`s. -fn all_ranges(cx: &LateContext, arms: &[Arm]) -> Vec> { +fn all_ranges<'a>(cx: &'a LateContext, arms: &'a [Arm]) -> Vec>> { let constcx = ConstContext::with_tables(cx.tcx, cx.tables); arms.iter() .flat_map(|arm| { @@ -427,8 +426,8 @@ fn all_ranges(cx: &LateContext, arms: &[Arm]) -> Vec> { .filter_map(|pat| { if_let_chain! {[ let PatKind::Range(ref lhs, ref rhs, ref range_end) = pat.node, - let Ok(lhs) = constcx.eval(lhs, ExprTypeChecked), - let Ok(rhs) = constcx.eval(rhs, ExprTypeChecked) + let Ok(lhs) = constcx.eval(lhs), + let Ok(rhs) = constcx.eval(rhs) ], { let rhs = match *range_end { RangeEnd::Included => Bound::Included(rhs), @@ -439,7 +438,7 @@ fn all_ranges(cx: &LateContext, arms: &[Arm]) -> Vec> { if_let_chain! {[ let PatKind::Lit(ref value) = pat.node, - let Ok(value) = constcx.eval(value, ExprTypeChecked) + let Ok(value) = constcx.eval(value) ], { return Some(SpannedRange { span: pat.span, node: (value.clone(), Bound::Included(value)) }); }} diff --git a/clippy_lints/src/mem_forget.rs b/clippy_lints/src/mem_forget.rs index fbb5f32b3b9..b43a2473f0d 100644 --- a/clippy_lints/src/mem_forget.rs +++ b/clippy_lints/src/mem_forget.rs @@ -36,7 +36,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemForget { let forgot_ty = cx.tables.expr_ty(&args[0]); if match forgot_ty.ty_adt_def() { - Some(def) => def.has_dtor(), + Some(def) => def.has_dtor(cx.tcx), _ => false, } { span_lint(cx, MEM_FORGET, e.span, "usage of mem::forget on Drop type"); diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 9acf4c7e973..b7416630963 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -3,7 +3,6 @@ use rustc::lint::*; use rustc::middle::const_val::ConstVal; use rustc::ty; use rustc::hir::def::Def; -use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::ConstContext; use std::borrow::Cow; use std::fmt; @@ -1240,7 +1239,7 @@ fn lint_chars_next(cx: &LateContext, expr: &hir::Expr, chain: &hir::Expr, other: /// lint for length-1 `str`s for methods in `PATTERN_METHODS` fn lint_single_char_pattern(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr) { - if let Ok(ConstVal::Str(r)) = ConstContext::with_tables(cx.tcx, cx.tables).eval(arg, ExprTypeChecked) { + if let Ok(ConstVal::Str(r)) = ConstContext::with_tables(cx.tcx, cx.tables).eval(arg) { if r.len() == 1 { let hint = snippet(cx, expr.span, "..").replace(&format!("\"{}\"", r), &format!("'{}'", r)); span_lint_and_then(cx, diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index d2f794def0c..2e38bcd39eb 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -4,7 +4,6 @@ use rustc::hir::intravisit::FnKind; use rustc::lint::*; use rustc::middle::const_val::ConstVal; use rustc::ty; -use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::ConstContext; use rustc_const_math::ConstFloat; use syntax::codemap::{Span, Spanned, ExpnFormat}; @@ -360,24 +359,16 @@ fn check_nan(cx: &LateContext, path: &Path, span: Span) { } fn is_allowed(cx: &LateContext, expr: &Expr) -> bool { - let res = ConstContext::with_tables(cx.tcx, cx.tables).eval(expr, ExprTypeChecked); + let res = ConstContext::with_tables(cx.tcx, cx.tables).eval(expr); if let Ok(ConstVal::Float(val)) = res { use std::cmp::Ordering; - let zero = ConstFloat::FInfer { - f32: 0.0, - f64: 0.0, - }; + let zero = ConstFloat::F64(0.0); - let infinity = ConstFloat::FInfer { - f32: ::std::f32::INFINITY, - f64: ::std::f64::INFINITY, - }; + let infinity = ConstFloat::F64(::std::f64::INFINITY); - let neg_infinity = ConstFloat::FInfer { - f32: ::std::f32::NEG_INFINITY, - f64: ::std::f64::NEG_INFINITY, - }; + + let neg_infinity = ConstFloat::F64(::std::f64::NEG_INFINITY); val.try_cmp(zero) == Ok(Ordering::Equal) || val.try_cmp(infinity) == Ok(Ordering::Equal) || val.try_cmp(neg_infinity) == Ok(Ordering::Equal) diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index cb1f33133f5..07c941ecee6 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -62,7 +62,7 @@ fn check_arguments(cx: &LateContext, arguments: &[Expr], type_definition: &TyS, match type_definition.sty { TypeVariants::TyFnDef(_, _, fn_type) | TypeVariants::TyFnPtr(fn_type) => { - let parameters = fn_type.sig.skip_binder().inputs(); + let parameters = fn_type.skip_binder().inputs(); for (argument, parameter) in arguments.iter().zip(parameters.iter()) { match parameter.sty { TypeVariants::TyRef(_, TypeAndMut { mutbl: MutImmutable, .. }) | diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 72399a9e634..d7e7a0bdb47 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -85,7 +85,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { let fn_def_id = cx.tcx.hir.local_def_id(node_id); let param_env = ty::ParameterEnvironment::for_item(cx.tcx, node_id); let fn_sig = cx.tcx.item_type(fn_def_id).fn_sig(); - let fn_sig = cx.tcx.liberate_late_bound_regions(param_env.free_id_outlive, fn_sig); + let fn_sig = cx.tcx.liberate_late_bound_regions(param_env.free_id_outlive, &fn_sig); for ((input, ty), arg) in decl.inputs.iter().zip(fn_sig.inputs()).zip(&body.arguments) { diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index e9176372ebc..279996bfabe 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -113,7 +113,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass { fn check_fn(cx: &LateContext, decl: &FnDecl, fn_id: NodeId) { let fn_def_id = cx.tcx.hir.local_def_id(fn_id); - let fn_ty = cx.tcx.item_type(fn_def_id).fn_sig().skip_binder(); + let sig = cx.tcx.item_type(fn_def_id).fn_sig(); + let fn_ty = sig.skip_binder(); for (arg, ty) in decl.inputs.iter().zip(fn_ty.inputs()) { if let ty::TyRef(_, ty::TypeAndMut { ty, mutbl: MutImmutable }) = ty.sty { diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index 991d601cf9a..6f22c3cfc7f 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -2,7 +2,6 @@ use regex_syntax; use rustc::hir::*; use rustc::lint::*; use rustc::middle::const_val::ConstVal; -use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::ConstContext; use std::collections::HashSet; use std::error::Error; @@ -151,7 +150,7 @@ fn str_span(base: Span, s: &str, c: usize) -> Span { } fn const_str(cx: &LateContext, e: &Expr) -> Option { - match ConstContext::with_tables(cx.tcx, cx.tables).eval(e, ExprTypeChecked) { + match ConstContext::with_tables(cx.tcx, cx.tables).eval(e) { Ok(ConstVal::Str(r)) => Some(r), _ => None, } diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 17d4ebd8708..0ec2e80338c 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -907,7 +907,6 @@ fn detect_absurd_comparison<'a>( fn detect_extreme_expr<'a>(cx: &LateContext, expr: &'a Expr) -> Option> { use rustc::middle::const_val::ConstVal::*; use rustc_const_math::*; - use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::*; use types::ExtremeType::*; @@ -918,7 +917,7 @@ fn detect_extreme_expr<'a>(cx: &LateContext, expr: &'a Expr) -> Option return None, }; - let cv = match ConstContext::with_tables(cx.tcx, cx.tables).eval(expr, ExprTypeChecked) { + let cv = match ConstContext::with_tables(cx.tcx, cx.tables).eval(expr) { Ok(val) => val, Err(_) => return None, }; @@ -1107,18 +1106,13 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext, expr: &'a Expr) -> Option<( fn node_as_const_fullint(cx: &LateContext, expr: &Expr) -> Option { use rustc::middle::const_val::ConstVal::*; - use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::ConstContext; use rustc_const_math::ConstInt; - match ConstContext::with_tables(cx.tcx, cx.tables).eval(expr, ExprTypeChecked) { + match ConstContext::with_tables(cx.tcx, cx.tables).eval(expr) { Ok(val) => { if let Integral(const_int) = val { - Some(match const_int.erase_type() { - ConstInt::InferSigned(x) => FullInt::S(x as i128), - ConstInt::Infer(x) => FullInt::U(x as u128), - _ => unreachable!(), - }) + Some(FullInt::U(const_int.to_u128_unchecked())) } else { None } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 2dae1cf1723..e1c09992ce2 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -781,7 +781,7 @@ pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> ty::T let parameter_env = ty::ParameterEnvironment::for_item(cx.tcx, fn_item); let fn_def_id = cx.tcx.hir.local_def_id(fn_item); let fn_sig = cx.tcx.item_type(fn_def_id).fn_sig(); - let fn_sig = cx.tcx.liberate_late_bound_regions(parameter_env.free_id_outlive, fn_sig); + let fn_sig = cx.tcx.liberate_late_bound_regions(parameter_env.free_id_outlive, &fn_sig); fn_sig.output() } @@ -806,7 +806,7 @@ pub fn same_tys<'a, 'tcx>( pub fn type_is_unsafe_function(ty: ty::Ty) -> bool { match ty.sty { ty::TyFnDef(_, _, f) | - ty::TyFnPtr(f) => f.unsafety == Unsafety::Unsafe, + ty::TyFnPtr(f) => f.skip_binder().unsafety == Unsafety::Unsafe, _ => false, } } diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index a8d2701ccfa..3b9e38cb66b 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -1,7 +1,6 @@ use rustc::hir::*; use rustc::lint::*; use rustc::ty; -use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::ConstContext; use syntax::codemap::Span; use utils::{higher, is_copy, snippet, span_lint_and_then}; @@ -60,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_vec_macro(cx: &LateContext, vec_args: &higher::VecArgs, span: Span) { let snippet = match *vec_args { higher::VecArgs::Repeat(elem, len) => { - if ConstContext::with_tables(cx.tcx, cx.tables).eval(len, ExprTypeChecked).is_ok() { + if ConstContext::with_tables(cx.tcx, cx.tables).eval(len).is_ok() { format!("&[{}; {}]", snippet(cx, elem.span, "elem"), snippet(cx, len.span, "len")).into() } else { return;