1
Fork 0

Rustup to *rustc 1.13.0-nightly (f1f40f850 2016-09-09)*

This commit is contained in:
mcarton 2016-09-09 20:24:20 +02:00
parent b08c7aa553
commit ab6669a641
No known key found for this signature in database
GPG key ID: 5E427C794CBA45E8
8 changed files with 17 additions and 21 deletions

View file

@ -141,11 +141,10 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref
} }
match ty.sty { 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 // Some types are not Clone by default but could be cloned “by hand” if necessary
TypeVariants::TyEnum(def, substs) | TypeVariants::TyAdt(def, substs) => {
TypeVariants::TyStruct(def, substs) => {
for variant in &def.variants { for variant in &def.variants {
for field in &variant.fields { for field in &variant.fields {
match field.ty(cx.tcx, substs).sty { match field.ty(cx.tcx, substs).sty {

View file

@ -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))) .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::TyProjection(_) => ty.ty_to_def_id().map_or(false, |id| has_is_empty_impl(cx, &id)),
ty::TyEnum(id, _) | ty::TyAdt(id, _) => has_is_empty_impl(cx, &id.did),
ty::TyStruct(id, _) |
ty::TyUnion(id, _) => has_is_empty_impl(cx, &id.did),
ty::TyArray(..) | ty::TyStr => true, ty::TyArray(..) | ty::TyStr => true,
_ => false, _ => false,
} }

View 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 { fn may_slice(cx: &LateContext, ty: ty::Ty) -> bool {
match ty.sty { match ty.sty {
ty::TySlice(_) => true, 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::TyArray(_, size) => size < 32,
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) | ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) |
ty::TyBox(inner) => may_slice(cx, 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`). /// 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>> { fn get_error_type<'a>(cx: &LateContext, ty: ty::Ty<'a>) -> Option<ty::Ty<'a>> {
if !match_type(cx, ty, &paths::RESULT) { if let ty::TyAdt(_, substs) = ty.sty {
return None; if match_type(cx, ty, &paths::RESULT) {
} substs.types().nth(1)
} else {
if let ty::TyEnum(_, substs) = ty.sty { None
substs.types().nth(1) }
} else { } else {
None None
} }

View file

@ -57,7 +57,7 @@ pub struct MutexAtomic;
impl LateLintPass for MutexAtomic { impl LateLintPass for MutexAtomic {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) { fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
let ty = cx.tcx.expr_ty(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) { if match_type(cx, ty, &paths::MUTEX) {
let mutex_param = &subst.type_at(0).sty; let mutex_param = &subst.type_at(0).sty;
if let Some(atomic_name) = get_atomic_name(mutex_param) { if let Some(atomic_name) = get_atomic_name(mutex_param) {

View file

@ -1,5 +1,5 @@
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::ty::TyStruct; use rustc::ty::TyAdt;
use rustc::hir::{Expr, ExprStruct}; use rustc::hir::{Expr, ExprStruct};
use utils::span_lint; use utils::span_lint;
@ -34,7 +34,7 @@ impl LateLintPass for Pass {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) { fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
if let ExprStruct(_, ref fields, Some(ref base)) = expr.node { if let ExprStruct(_, ref fields, Some(ref base)) = expr.node {
let ty = cx.tcx.expr_ty(expr); 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() { if fields.len() == def.struct_variant().fields.len() {
span_lint(cx, span_lint(cx,
NEEDLESS_UPDATE, NEEDLESS_UPDATE,

View file

@ -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 { fn can_derive_default<'t, 'c>(ty: ty::Ty<'t>, cx: &LateContext<'c, 't>, default_trait_id: DefId) -> bool {
match ty.sty { 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() { for field in adt_def.all_fields() {
let f_ty = field.ty(cx.tcx, substs); let f_ty = field.ty(cx.tcx, substs);
if !implements_trait(cx, f_ty, default_trait_id, Vec::new()) { if !implements_trait(cx, f_ty, default_trait_id, Vec::new()) {

View file

@ -152,11 +152,10 @@ pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool {
apb.names == path 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 { pub fn match_type(cx: &LateContext, ty: ty::Ty, path: &[&str]) -> bool {
match ty.sty { match ty.sty {
ty::TyEnum(adt, _) | ty::TyAdt(adt, _) => match_def_path(cx, adt.did, path),
ty::TyStruct(adt, _) => match_def_path(cx, adt.did, path),
_ => false, _ => false,
} }
} }

View 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>`). /// Return the item type of the vector (ie. the `T` in `Vec<T>`).
fn vec_type(ty: ty::Ty) -> ty::Ty { 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) substs.type_at(0)
} else { } else {
panic!("The type of `vec!` is a not a struct?"); panic!("The type of `vec!` is a not a struct?");