diff options
author | gnzlbg <gonzalobg88@gmail.com> | 2018-08-14 23:11:56 +0200 |
---|---|---|
committer | gnzlbg <gonzalobg88@gmail.com> | 2018-08-14 23:11:56 +0200 |
commit | 6e7d9bebd8c95a8ca7088cf02c17aea811d20783 (patch) | |
tree | 763e2fbd3d476e8c2625446cd0021e7dc74c8974 | |
parent | 122198bfbe30afd00cab87362c0026ded4c9743b (diff) |
address review comments
-rw-r--r-- | src/codegen/impl_debug.rs | 2 | ||||
-rw-r--r-- | src/codegen/impl_partialeq.rs | 2 | ||||
-rw-r--r-- | src/codegen/mod.rs | 8 | ||||
-rw-r--r-- | src/ir/analysis/derive_hash.rs | 4 | ||||
-rw-r--r-- | src/ir/analysis/derive_partialeq_or_partialord.rs | 9 | ||||
-rw-r--r-- | src/ir/analysis/has_float.rs | 2 | ||||
-rw-r--r-- | src/ir/ty.rs | 8 |
7 files changed, 14 insertions, 21 deletions
diff --git a/src/codegen/impl_debug.rs b/src/codegen/impl_debug.rs index 9e3e3425..0842d849 100644 --- a/src/codegen/impl_debug.rs +++ b/src/codegen/impl_debug.rs @@ -197,7 +197,7 @@ impl<'a> ImplDebug<'a> for Item { )) } } - TypeKind::Vector(_, len, _) => { + TypeKind::Vector(_, len) => { let self_ids = 0..len; Some(( format!("{}({{}})", name), diff --git a/src/codegen/impl_partialeq.rs b/src/codegen/impl_partialeq.rs index 936cc05d..66565db6 100644 --- a/src/codegen/impl_partialeq.rs +++ b/src/codegen/impl_partialeq.rs @@ -115,7 +115,7 @@ fn gen_field(ctx: &BindgenContext, ty_item: &Item, name: &str) -> quote::Tokens &self. #name_ident [..] == &other. #name_ident [..] } }, - TypeKind::Vector(_, len, _) => { + TypeKind::Vector(_, len) => { let self_ids = 0..len; let other_ids = 0..len; quote! { diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index acf45841..778deef9 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -3050,13 +3050,7 @@ impl TryToRustTy for Type { ::#prefix::option::Option<#ty> }) } - TypeKind::Array(item, len) => { - let ty = item.try_to_rust_ty(ctx, &())?; - Ok(quote! { - [ #ty ; #len ] - }) - } - TypeKind::Vector(item, len, _) => { + TypeKind::Array(item, len) | TypeKind::Vector(item, len) => { let ty = item.try_to_rust_ty(ctx, &())?; Ok(quote! { [ #ty ; #len ] diff --git a/src/ir/analysis/derive_hash.rs b/src/ir/analysis/derive_hash.rs index df160c44..fe56ed7c 100644 --- a/src/ir/analysis/derive_hash.rs +++ b/src/ir/analysis/derive_hash.rs @@ -202,7 +202,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveHash<'ctx> { self.insert(id) } } - TypeKind::Vector(t, len, _) => { + TypeKind::Vector(t, len) => { if self.cannot_derive_hash.contains(&t.into()) { trace!( " vectors of T for which we cannot derive Hash \ @@ -210,7 +210,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveHash<'ctx> { ); return self.insert(id); } - assert!(len != 0); + assert_ne!(len, 0, "vectors cannot have zero length"); trace!(" vector can derive Hash"); ConstrainResult::Same } diff --git a/src/ir/analysis/derive_partialeq_or_partialord.rs b/src/ir/analysis/derive_partialeq_or_partialord.rs index d78da1e2..23d55c13 100644 --- a/src/ir/analysis/derive_partialeq_or_partialord.rs +++ b/src/ir/analysis/derive_partialeq_or_partialord.rs @@ -200,11 +200,10 @@ impl<'ctx> CannotDerivePartialEqOrPartialOrd<'ctx> { } } TypeKind::Vector(..) => { - // FIXME: vectors always can derive PartialEq, but they can - // never derive PartialOrd. - trace!( - " vectors cannot derive `PartialEq`/`PartialOrd`" - ); + // FIXME: vectors always can derive PartialEq, but they should + // not derive PartialOrd: + // https://github.com/rust-lang-nursery/packed_simd/issues/48 + trace!(" vectors cannot derive `PartialEq`/`PartialOrd`"); return CanDerive::No; } diff --git a/src/ir/analysis/has_float.rs b/src/ir/analysis/has_float.rs index f55fce37..53e6a491 100644 --- a/src/ir/analysis/has_float.rs +++ b/src/ir/analysis/has_float.rs @@ -148,7 +148,7 @@ impl<'ctx> MonotoneFramework for HasFloat<'ctx> { trace!(" Array with type T that do not have float also do not have float"); ConstrainResult::Same } - TypeKind::Vector(t, _, _) => { + TypeKind::Vector(t, _) => { if self.has_float.contains(&t.into()) { trace!(" Vector with type T that has float also has float"); return self.insert(id) diff --git a/src/ir/ty.rs b/src/ir/ty.rs index 22cdc248..9cc097d4 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -630,8 +630,8 @@ pub enum TypeKind { /// template parameters. TemplateAlias(TypeId, Vec<TypeId>), - /// A packed vector type: element type, number of elements, vector alignment. - Vector(TypeId, usize, usize), + /// A packed vector type: element type, number of elements + Vector(TypeId, usize), /// An array of a type and a length. Array(TypeId, usize), @@ -1161,7 +1161,7 @@ impl Type { None, ctx, ).expect("Not able to resolve vector element?"); - TypeKind::Vector(inner, ty.num_elements().unwrap(), ty.align()) + TypeKind::Vector(inner, ty.num_elements().unwrap()) } CXType_ConstantArray => { let inner = Item::from_ty( @@ -1223,7 +1223,7 @@ impl Trace for Type { TypeKind::Pointer(inner) | TypeKind::Reference(inner) | TypeKind::Array(inner, _) | - TypeKind::Vector(inner, _, _) | + TypeKind::Vector(inner, _) | TypeKind::Alias(inner) | TypeKind::ResolvedTypeRef(inner) => { tracer.visit_kind(inner.into(), EdgeKind::TypeReference); |