From b08c7aa553a0ccdd4a1fb9eb4c9f982be44332d4 Mon Sep 17 00:00:00 2001 From: mcarton Date: Fri, 9 Sep 2016 20:24:00 +0200 Subject: [PATCH 1/3] Remove EOL space --- tests/compile-fail/escape_analysis.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/compile-fail/escape_analysis.rs b/tests/compile-fail/escape_analysis.rs index cb4f2b0a655..8e185f24b1f 100644 --- a/tests/compile-fail/escape_analysis.rs +++ b/tests/compile-fail/escape_analysis.rs @@ -31,7 +31,7 @@ fn ok_box_trait(boxed_trait: &Box) { fn warn_call() { let x = box A; //~ ERROR local variable - x.foo(); + x.foo(); } fn warn_arg(x: Box) { //~ ERROR local variable From ab6669a64194eb8aa9a033b6cfefb7ce01cadccb Mon Sep 17 00:00:00 2001 From: mcarton Date: Fri, 9 Sep 2016 20:24:20 +0200 Subject: [PATCH 2/3] Rustup to *rustc 1.13.0-nightly (f1f40f850 2016-09-09)* --- clippy_lints/src/derive.rs | 5 ++--- clippy_lints/src/len_zero.rs | 4 +--- clippy_lints/src/methods.rs | 14 +++++++------- clippy_lints/src/mutex_atomic.rs | 2 +- clippy_lints/src/needless_update.rs | 4 ++-- clippy_lints/src/new_without_default.rs | 2 +- clippy_lints/src/utils/mod.rs | 5 ++--- clippy_lints/src/vec.rs | 2 +- 8 files changed, 17 insertions(+), 21 deletions(-) diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 17d17a445af..89e90bff625 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -141,11 +141,10 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref } match ty.sty { - TypeVariants::TyUnion(..) => return, + TypeVariants::TyAdt(def, _) if def.is_union() => return, // Some types are not Clone by default but could be cloned “by hand” if necessary - TypeVariants::TyEnum(def, substs) | - TypeVariants::TyStruct(def, substs) => { + TypeVariants::TyAdt(def, substs) => { for variant in &def.variants { for field in &variant.fields { match field.ty(cx.tcx, substs).sty { diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index f574e6b7f38..1d81b6dba22 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -214,9 +214,7 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool { .map_or(false, |ids| ids.iter().any(|i| is_is_empty(cx, i))) } ty::TyProjection(_) => ty.ty_to_def_id().map_or(false, |id| has_is_empty_impl(cx, &id)), - ty::TyEnum(id, _) | - ty::TyStruct(id, _) | - ty::TyUnion(id, _) => has_is_empty_impl(cx, &id.did), + ty::TyAdt(id, _) => has_is_empty_impl(cx, &id.did), ty::TyArray(..) | ty::TyStr => true, _ => false, } diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index ecb19495c20..c1b933d0121 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -796,7 +796,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: ty::Ty) -> Option bool { match ty.sty { ty::TySlice(_) => true, - ty::TyStruct(..) => match_type(cx, ty, &paths::VEC), + ty::TyAdt(..) => match_type(cx, ty, &paths::VEC), ty::TyArray(_, size) => size < 32, ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) | ty::TyBox(inner) => may_slice(cx, inner), @@ -1081,12 +1081,12 @@ fn lint_single_char_pattern(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr) /// Given a `Result` type, return its error type (`E`). fn get_error_type<'a>(cx: &LateContext, ty: ty::Ty<'a>) -> Option> { - if !match_type(cx, ty, &paths::RESULT) { - return None; - } - - if let ty::TyEnum(_, substs) = ty.sty { - substs.types().nth(1) + if let ty::TyAdt(_, substs) = ty.sty { + if match_type(cx, ty, &paths::RESULT) { + substs.types().nth(1) + } else { + None + } } else { None } diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index db2c003b61d..a2117656f9d 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -57,7 +57,7 @@ pub struct MutexAtomic; impl LateLintPass for MutexAtomic { fn check_expr(&mut self, cx: &LateContext, expr: &Expr) { let ty = cx.tcx.expr_ty(expr); - if let ty::TyStruct(_, subst) = ty.sty { + if let ty::TyAdt(_, subst) = ty.sty { if match_type(cx, ty, &paths::MUTEX) { let mutex_param = &subst.type_at(0).sty; if let Some(atomic_name) = get_atomic_name(mutex_param) { diff --git a/clippy_lints/src/needless_update.rs b/clippy_lints/src/needless_update.rs index 2b5aa12f7a9..9f607f4350d 100644 --- a/clippy_lints/src/needless_update.rs +++ b/clippy_lints/src/needless_update.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::ty::TyStruct; +use rustc::ty::TyAdt; use rustc::hir::{Expr, ExprStruct}; use utils::span_lint; @@ -34,7 +34,7 @@ impl LateLintPass for Pass { fn check_expr(&mut self, cx: &LateContext, expr: &Expr) { if let ExprStruct(_, ref fields, Some(ref base)) = expr.node { let ty = cx.tcx.expr_ty(expr); - if let TyStruct(def, _) = ty.sty { + if let TyAdt(def, _) = ty.sty { if fields.len() == def.struct_variant().fields.len() { span_lint(cx, NEEDLESS_UPDATE, diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index b1bffb8c236..538d3abd5ea 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -146,7 +146,7 @@ impl LateLintPass for NewWithoutDefault { fn can_derive_default<'t, 'c>(ty: ty::Ty<'t>, cx: &LateContext<'c, 't>, default_trait_id: DefId) -> bool { match ty.sty { - ty::TyStruct(adt_def, substs) => { + ty::TyAdt(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, Vec::new()) { diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 9e6ee0fbf1b..31f0c9c8e00 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -152,11 +152,10 @@ pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool { apb.names == path } -/// Check if type is struct or enum type with given def path. +/// Check if type is struct, enum or union type with given def path. pub fn match_type(cx: &LateContext, ty: ty::Ty, path: &[&str]) -> bool { match ty.sty { - ty::TyEnum(adt, _) | - ty::TyStruct(adt, _) => match_def_path(cx, adt.did, path), + ty::TyAdt(adt, _) => match_def_path(cx, adt.did, path), _ => false, } } diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index 053cc69d7e7..06d3d040ccd 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -88,7 +88,7 @@ fn check_vec_macro(cx: &LateContext, vec_args: &higher::VecArgs, span: Span) { /// Return the item type of the vector (ie. the `T` in `Vec`). fn vec_type(ty: ty::Ty) -> ty::Ty { - if let ty::TyStruct(_, substs) = ty.sty { + if let ty::TyAdt(_, substs) = ty.sty { substs.type_at(0) } else { panic!("The type of `vec!` is a not a struct?"); From 7279dc3edfcea642f80eb1536af4fb35d612249f Mon Sep 17 00:00:00 2001 From: mcarton Date: Fri, 9 Sep 2016 20:26:11 +0200 Subject: [PATCH 3/3] Bump to 0.0.90 --- CHANGELOG.md | 3 +++ Cargo.toml | 4 ++-- clippy_lints/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6322479e45..f6163d54ef6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## 0.0.90 — 2016-09-09 +* Rustup to *rustc 1.13.0-dev (f1f40f850 2016-09-09)* + ## 0.0.89 — 2016-09-06 * Rustup to *rustc 1.13.0-nightly (cbe4de78e 2016-09-05)* diff --git a/Cargo.toml b/Cargo.toml index 7e83e45d856..80f821a1b41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.0.89" +version = "0.0.90" authors = [ "Manish Goregaokar ", "Andre Bogus ", @@ -25,7 +25,7 @@ test = false [dependencies] # begin automatic update -clippy_lints = { version = "0.0.89", path = "clippy_lints" } +clippy_lints = { version = "0.0.90", path = "clippy_lints" } # end automatic update [dev-dependencies] diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml index 50eba2aee4f..a7e863c2968 100644 --- a/clippy_lints/Cargo.toml +++ b/clippy_lints/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "clippy_lints" # begin automatic update -version = "0.0.89" +version = "0.0.90" # end automatic update authors = [ "Manish Goregaokar ",