]> git.lizzy.rs Git - rust.git/commitdiff
Rustup to *rustc 1.13.0-nightly (f1f40f850 2016-09-09)*
authormcarton <cartonmartin+git@gmail.com>
Fri, 9 Sep 2016 18:24:20 +0000 (20:24 +0200)
committermcarton <cartonmartin+git@gmail.com>
Sat, 10 Sep 2016 17:13:49 +0000 (19:13 +0200)
clippy_lints/src/derive.rs
clippy_lints/src/len_zero.rs
clippy_lints/src/methods.rs
clippy_lints/src/mutex_atomic.rs
clippy_lints/src/needless_update.rs
clippy_lints/src/new_without_default.rs
clippy_lints/src/utils/mod.rs
clippy_lints/src/vec.rs

index 17d17a445afd53e09b4751e941a4678f054fe69c..89e90bff625f311ee65f5d50eff095f25a717add 100644 (file)
@@ -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 {
index f574e6b7f388e42b0024bec131372d498a6735a1..1d81b6dba22f42f7ddf6d876417ab8adca719d86 100644 (file)
@@ -214,9 +214,7 @@ fn has_is_empty_impl(cx: &LateContext, id: &DefId) -> 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,
     }
index ecb19495c20d0a75c825e9b5f91a9e7ea32e352f..c1b933d0121e81dcbbc2411eeb4e16ee22acc93d 100644 (file)
@@ -796,7 +796,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: ty::Ty) -> Option<sug
     fn may_slice(cx: &LateContext, ty: ty::Ty) -> 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<T, E>` type, return its error type (`E`).
 fn get_error_type<'a>(cx: &LateContext, ty: ty::Ty<'a>) -> Option<ty::Ty<'a>> {
-    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
     }
index db2c003b61d73a569f3c76f6630b401c6d331be7..a2117656f9d7851b5f0499e2046d4df65afae535 100644 (file)
@@ -57,7 +57,7 @@ fn get_lints(&self) -> LintArray {
 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) {
index 2b5aa12f7a9b3442047b105ff9099566338070b8..9f607f4350d2a2259df65d8461e6d202b716b76a 100644 (file)
@@ -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,
index b1bffb8c2362eb11fae84330b036a7b7cb809da3..538d3abd5ea430fb204d299968862a33683bdff6 100644 (file)
@@ -146,7 +146,7 @@ fn default() -> Self {{
 
 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()) {
index 9e6ee0fbf1b76f8326383e61e00c555eec8c9e97..31f0c9c8e000d2ebd748f7f93488ae9c09e2f959 100644 (file)
@@ -152,11 +152,10 @@ fn push(&mut self, text: &str) {
     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,
     }
 }
index 053cc69d7e75845267ce223fb5a0519e088ae106..06d3d040ccdc57237befdbe13d3f7cce04d9c61f 100644 (file)
@@ -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<T>`).
 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?");