From 87db6bb1e38b0c0c5b710b4457193aad4aa2c4b2 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Fri, 27 Sep 2019 15:36:20 +0200 Subject: [PATCH 1/3] Add regression test for ICE #4579 --- tests/ui/ice-4579.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/ui/ice-4579.rs diff --git a/tests/ui/ice-4579.rs b/tests/ui/ice-4579.rs new file mode 100644 index 000000000000..2e7e279f847d --- /dev/null +++ b/tests/ui/ice-4579.rs @@ -0,0 +1,13 @@ +#![allow(clippy::single_match)] + +use std::ptr; + +fn main() { + match Some(0_usize) { + Some(_) => { + let s = "012345"; + unsafe { ptr::read(s.as_ptr().offset(1) as *const [u8; 5]) }; + }, + _ => (), + }; +} From 93bda4876a96cfce5ee1c1f547e3a86cc1744854 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Fri, 27 Sep 2019 15:36:56 +0200 Subject: [PATCH 2/3] Fix ICE #4579 --- clippy_lints/src/consts.rs | 8 +++++--- clippy_lints/src/neg_multiply.rs | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index eadadaa1932a..aeb82a0c8cd3 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -152,7 +152,7 @@ impl Constant { } /// Parses a `LitKind` to a `Constant`. -pub fn lit_to_constant(lit: &LitKind, ty: Ty<'_>) -> Constant { +pub fn lit_to_constant(lit: &LitKind, ty: Option>) -> Constant { use syntax::ast::*; match *lit { @@ -161,7 +161,9 @@ pub fn lit_to_constant(lit: &LitKind, ty: Ty<'_>) -> Constant { LitKind::ByteStr(ref s) => Constant::Binary(Lrc::clone(s)), LitKind::Char(c) => Constant::Char(c), LitKind::Int(n, _) => Constant::Int(n), - LitKind::Float(ref is, _) | LitKind::FloatUnsuffixed(ref is) => match ty.kind { + LitKind::Float(ref is, FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()), + LitKind::Float(ref is, FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()), + LitKind::FloatUnsuffixed(ref is) => match ty.expect("type of float is known").kind { ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()), ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()), _ => bug!(), @@ -225,7 +227,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { match e.kind { ExprKind::Path(ref qpath) => self.fetch_path(qpath, e.hir_id), ExprKind::Block(ref block, _) => self.block(block), - ExprKind::Lit(ref lit) => Some(lit_to_constant(&lit.node, self.tables.expr_ty(e))), + ExprKind::Lit(ref lit) => Some(lit_to_constant(&lit.node, self.tables.expr_ty_opt(e))), ExprKind::Array(ref vec) => self.multi(vec).map(Constant::Vec), ExprKind::Tup(ref tup) => self.multi(tup).map(Constant::Tuple), ExprKind::Repeat(ref value, _) => { diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index aec0664a29b2..3ef3ee36c3f0 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -44,7 +44,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NegMultiply { fn check_mul(cx: &LateContext<'_, '_>, span: Span, lit: &Expr, exp: &Expr) { if_chain! { if let ExprKind::Lit(ref l) = lit.kind; - if let Constant::Int(1) = consts::lit_to_constant(&l.node, cx.tables.expr_ty(lit)); + if let Constant::Int(1) = consts::lit_to_constant(&l.node, cx.tables.expr_ty_opt(lit)); if cx.tables.expr_ty(exp).is_integral(); then { span_lint(cx, NEG_MULTIPLY, span, "Negation by multiplying with -1"); From eb1fc7b3fdb7955828af3e416625ea95ebc12c7c Mon Sep 17 00:00:00 2001 From: flip1995 Date: Wed, 2 Oct 2019 10:55:52 +0200 Subject: [PATCH 3/3] Disable hyper and futures-rs integration tests --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c1d004d6943..38deb18949e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,8 +62,8 @@ matrix: if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=rust-lang/rustfmt if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=hyperium/hyper - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) + # - env: INTEGRATION=hyperium/hyper + # if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=bluss/rust-itertools if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=serde-rs/serde @@ -72,8 +72,8 @@ matrix: if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=rust-random/rand if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=rust-lang-nursery/futures-rs - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) + # - env: INTEGRATION=rust-lang-nursery/futures-rs + # if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=Marwes/combine if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=rust-lang-nursery/failure