Repository: gluon-lang/gluon
Pull request #628 (2018-09-14 21:39:00)

style: Fix clippy warnings in gluon_base
Further fixes are blocked on
https://github.com/rust-lang-nursery/rust-clippy/issues/2831


Patch:
diff --git a/base/src/ast.rs b/base/src/ast.rs
index 2d52fbcd..9682e7a7 100644
--- a/base/src/ast.rs
+++ b/base/src/ast.rs
@@ -63,22 +63,28 @@ impl<'a, T: ?Sized + IdentEnv> IdentEnv for &'a mut T {
     }
 }
 
+#[derive(Clone, Eq, PartialEq, Debug)]
+struct InnerAstType<Id> {
+    comment: Option<Comment>,
+    typ: Spanned<Type<Id, AstType<Id>>, BytePos>,
+}
+
 #[derive(Clone, Eq, PartialEq, Debug)]
 pub struct AstType<Id> {
-    _typ: Box<(Option<Comment>, Spanned<Type<Id, AstType<Id>>, BytePos>)>,
+    _typ: Box<InnerAstType<Id>>,
 }
 
 impl<Id> Deref for AstType<Id> {
     type Target = Type<Id, AstType<Id>>;
 
     fn deref(&self) -> &Self::Target {
-        &self._typ.1.value
+        &self._typ.typ.value
     }
 }
 
 impl<Id> DerefMut for AstType<Id> {
     fn deref_mut(&mut self) -> &mut Self::Target {
-        &mut self._typ.1.value
+        &mut self._typ.typ.value
     }
 }
 
@@ -91,7 +97,7 @@ impl<Id: AsRef<str>> fmt::Display for AstType<Id> {
 impl<Id> From<Spanned<Type<Id, AstType<Id>>, BytePos>> for AstType<Id> {
     fn from(typ: Spanned<Type<Id, AstType<Id>>, BytePos>) -> Self {
         AstType {
-            _typ: Box::new((None, typ)),
+            _typ: Box::new(InnerAstType { comment: None, typ }),
         }
     }
 }
@@ -104,7 +110,7 @@ impl<Id> From<Type<Id, AstType<Id>>> for AstType<Id> {
 
 impl<Id> HasSpan for AstType<Id> {
     fn span(&self) -> Span<BytePos> {
-        self._typ.1.span
+        self._typ.typ.span
     }
 }
 
@@ -114,7 +120,7 @@ pub trait Commented {
 
 impl<Id> Commented for AstType<Id> {
     fn comment(&self) -> Option<&Comment> {
-        self._typ.0.as_ref()
+        self._typ.comment.as_ref()
     }
 }
 
@@ -124,7 +130,10 @@ impl<Id> AstType<Id> {
         T: Into<Option<Comment>>,
     {
         AstType {
-            _typ: Box::new((comment.into(), typ)),
+            _typ: Box::new(InnerAstType {
+                comment: comment.into(),
+                typ,
+            }),
         }
     }
 
@@ -132,19 +141,15 @@ impl<Id> AstType<Id> {
     where
         T: Into<Option<Comment>>,
     {
-        self._typ.0 = comment.into();
+        self._typ.comment = comment.into();
     }
 
     pub fn into_inner(self) -> Type<Id, Self> {
-        self._typ.1.value
-    }
-
-    pub fn as_mut(&mut self) -> &mut SpannedAstType<Id> {
-        &mut self._typ.1
+        self._typ.typ.value
     }
 
     pub fn params_mut(&mut self) -> &mut [Generic<Id>] {
-        match self._typ.1.value {
+        match self._typ.typ.value {
             Type::Forall(ref mut params, _, _) => params,
             Type::App(ref mut id, _) => id.params_mut(),
             _ => &mut [],
@@ -152,13 +157,19 @@ impl<Id> AstType<Id> {
     }
 
     pub fn remove_single_forall(&mut self) -> &mut AstType<Id> {
-        match self._typ.1.value {
-            Type::Forall(_, ref mut typ, _) => return typ,
+        match self._typ.typ.value {
+            Type::Forall(_, ref mut typ, _) => typ,
             _ => self,
         }
     }
 }
 
+impl<Id> AsMut<SpannedAstType<Id>> for AstType<Id> {
+    fn as_mut(&mut self) -> &mut SpannedAstType<Id> {
+        &mut self._typ.typ
+    }
+}
+
 #[derive(Clone, Eq, PartialEq, Debug)]
 pub struct TypedIdent<Id = Symbol> {
     pub typ: ArcType<Id>,
@@ -169,7 +180,7 @@ impl<Id> TypedIdent<Id> {
     pub fn new(name: Id) -> TypedIdent<Id> {
         TypedIdent {
             typ: Type::hole(),
-            name: name,
+            name,
         }
     }
 }
@@ -356,24 +367,24 @@ impl<Id> Expr<Id> {
     // TODO Use impl Trait
     pub fn field_iter<'a>(
         &'a self,
-    ) -> Box<
-        Iterator<Item = Either<&'a ExprField<Id, ArcType<Id>>, &'a ExprField<Id, SpannedExpr<Id>>>>
-            + 'a,
-    > {
-        match *self {
+    ) -> impl Iterator<
+        Item = Either<&'a ExprField<Id, ArcType<Id>>, &'a ExprField<Id, SpannedExpr<Id>>>,
+    > + 'a {
+        let (types, exprs) = match *self {
             Expr::Record {
                 ref types,
                 ref exprs,
                 ..
-            } => Box::new(types.iter().map(Either::Left).merge_by(
-                exprs.iter().map(Either::Right),
-                |x, y| {
-                    x.either(|l| l.name.span.start(), |r| r.name.span.start())
-                        < y.either(|l| l.name.span.start(), |r| r.name.span.start())
-                },
-            )),
-            _ => Box::new(None.into_iter()),
-        }
+            } => (&types[..], &exprs[..]),
+            _ => (&[][..], &[][..]),
+        };
+        types
+            .iter()
+            .map(Either::Left)
+            .merge_by(exprs.iter().map(Either::Right), |x, y| {
+                x.either(|l| l.name.span.start(), |r| r.name.span.start())
+                    < y.either(|l| l.name.span.start(), |r| r.name.span.start())
+            })
     }
 }
 
@@ -521,7 +532,7 @@ pub fn walk_alias<'a, V: ?Sized + $trait_name<'a>>(
     v: &mut V,
     alias: &'a $($mut)* SpannedAlias<V::Ident>,
 ) {
-    v.visit_ast_type(&$($mut)* alias.value.$unresolved_type()._typ.1);
+    v.visit_ast_type(&$($mut)* alias.value.$unresolved_type()._typ.typ);
 }
 
 pub fn walk_expr<'a, V: ?Sized + $trait_name<'a>>(v: &mut V, e: &'a $($mut)* SpannedExpr<V::Ident>) {
@@ -553,7 +564,7 @@ pub fn walk_expr<'a, V: ?Sized + $trait_name<'a>>(v: &mut V, e: &'a $($mut)* Spa
                 v.visit_typ(&$($mut)* bind.resolved_type);
                 v.visit_expr(&$($mut)* bind.expr);
                 if let Some(ref $($mut)* ast_type) = bind.typ {
-                    v.visit_ast_type(&$($mut)* ast_type._typ.1)
+                    v.visit_ast_type(&$($mut)* ast_type._typ.typ)
                 }
             }
             v.visit_expr(body);
@@ -706,25 +717,25 @@ pub fn walk_ast_type<'a, V: ?Sized + $trait_name<'a>>(
     match s.value {
         Type::Hole | Type::Opaque | Type::Error | Type::Builtin(_) => (),
         Type::Forall(_, ref $($mut)* ast_type, ref $($mut)* ast_types) => {
-            v.visit_ast_type(&$($mut)* ast_type._typ.1);
-            if let &$($mut)* Some(ref $($mut)* ast_types) = ast_types {
+            v.visit_ast_type(&$($mut)* ast_type._typ.typ);
+            if let Some(ref $($mut)* ast_types) = *ast_types {
                 for ast_type in ast_types {
-                    v.visit_ast_type(&$($mut)* ast_type._typ.1);
+                    v.visit_ast_type(&$($mut)* ast_type._typ.typ);
                 }
             }
         }
         Type::Function(_, ref $($mut)* arg, ref $($mut)* ret) => {
-            v.visit_ast_type(&$($mut)* arg._typ.1);
-            v.visit_ast_type(&$($mut)* ret._typ.1);
+            v.visit_ast_type(&$($mut)* arg._typ.typ);
+            v.visit_ast_type(&$($mut)* ret._typ.typ);
         }
         Type::App(ref $($mut)* ast_type, ref $($mut)* ast_types) => {
             for ast_type in ast_types {
-                v.visit_ast_type(&$($mut)* ast_type._typ.1);
+                v.visit_ast_type(&$($mut)* ast_type._typ.typ);
             }
-            v.visit_ast_type(&$($mut)* ast_type._typ.1)
+            v.visit_ast_type(&$($mut)* ast_type._typ.typ)
         }
-        Type::Record(ref $($mut)* ast_type) => v.visit_ast_type(&$($mut)* ast_type._typ.1),
-        Type::Variant(ref $($mut)* ast_type) => v.visit_ast_type(&$($mut)* ast_type._typ.1),
+        Type::Record(ref $($mut)* ast_type) => v.visit_ast_type(&$($mut)* ast_type._typ.typ),
+        Type::Variant(ref $($mut)* ast_type) => v.visit_ast_type(&$($mut)* ast_type._typ.typ),
         Type::EmptyRow => (),
         Type::ExtendRow {
             ref $($mut)* types,
@@ -733,17 +744,17 @@ pub fn walk_ast_type<'a, V: ?Sized + $trait_name<'a>>(
         } => {
             for field in types {
                 if let Some(alias) = field.typ.$try_get_alias() {
-                    v.visit_ast_type(&$($mut)* alias.$unresolved_type()._typ.1);
+                    v.visit_ast_type(&$($mut)* alias.$unresolved_type()._typ.typ);
                 }
             }
             for field in fields {
-                v.visit_ast_type(&$($mut)* field.typ._typ.1);
+                v.visit_ast_type(&$($mut)* field.typ._typ.typ);
             }
-            v.visit_ast_type(&$($mut)* rest._typ.1);
+            v.visit_ast_type(&$($mut)* rest._typ.typ);
         }
         Type::Alias(ref $($mut)* alias) => {
             if let Some(alias) = alias.$try_get_alias() {
-                v.visit_ast_type(&$($mut)* alias.$unresolved_type()._typ.1);
+                v.visit_ast_type(&$($mut)* alias.$unresolved_type()._typ.typ);
             }
         }
         Type::Ident(_) | Type::Variable(_) | Type::Generic(_) | Type::Skolem(_) => (),
@@ -825,7 +836,7 @@ impl Typed for Expr<Symbol> {
             Expr::MacroExpansion {
                 ref replacement, ..
             } => replacement.try_type_of(env),
-            Expr::Error(ref typ) => Ok(typ.clone().unwrap_or_else(|| Type::hole())),
+            Expr::Error(ref typ) => Ok(typ.clone().unwrap_or_else(Type::hole)),
         }
     }
 }
@@ -925,6 +936,6 @@ pub fn expr_to_path(expr: &SpannedExpr<Symbol>, path: &mut String) -> Result<(),
             path.push_str(id.declared_name());
             Ok(())
         }
-        _ => return Err("Expected a string literal or path to import"),
+        _ => Err("Expected a string literal or path to import"),
     }
 }
diff --git a/base/src/error.rs b/base/src/error.rs
index 0ee30878..9633eabc 100644
--- a/base/src/error.rs
+++ b/base/src/error.rs
@@ -83,7 +83,7 @@ impl<T> Extend<T> for Errors<T> {
 
 impl<T> From<Vec<T>> for Errors<T> {
     fn from(errors: Vec<T>) -> Errors<T> {
-        Errors { errors: errors }
+        Errors { errors }
     }
 }
 
@@ -189,8 +189,7 @@ impl<E: fmt::Display> InFile<E> {
                     "Source file does not exist in associated code map. Error: {}",
                     self.error
                 )
-            })
-            .name()
+            }).name()
     }
 
     pub fn errors(self) -> Errors<Spanned<E, BytePos>> {
diff --git a/base/src/lib.rs b/base/src/lib.rs
index 7d9d9124..eb638929 100644
--- a/base/src/lib.rs
+++ b/base/src/lib.rs
@@ -1,6 +1,7 @@
 //! The base crate contains pervasive types used in the compiler such as type representations, the
 //! AST and some basic containers.
 #![doc(html_root_url = "https://docs.rs/gluon_base/0.8.1")] // # GLUON
+#![allow(unknown_lints)]
 
 #[macro_use]
 extern crate collect_mac;
diff --git a/base/src/merge.rs b/base/src/merge.rs
index d8fc398f..010056d9 100644
--- a/base/src/merge.rs
+++ b/base/src/merge.rs
@@ -51,7 +51,7 @@ pub fn merge_fn<'a, 'b, F, G, H, A: ?Sized, B: ?Sized, A1, B1, R>(
     b_original: &'b B,
     h: H,
     b: Option<B1>,
-    f: F,
+    merger: F,
 ) -> Option<R>
 where
     F: FnOnce(A1, B1) -> R,
@@ -59,9 +59,9 @@ where
     H: FnOnce(&'b B) -> B1,
 {
     match (a, b) {
-        (Some(a), Some(b)) => Some(f(a, b)),
-        (Some(a), None) => Some(f(a, h(b_original))),
-        (None, Some(b)) => Some(f(g(a_original), b)),
+        (Some(a), Some(b)) => Some(merger(a, b)),
+        (Some(a), None) => Some(merger(a, h(b_original))),
+        (None, Some(b)) => Some(merger(g(a_original), b)),
         (None, None) => None,
     }
 }
@@ -76,7 +76,7 @@ where
     merge_iter(types, |(l, r)| f(l, r), |(l, _)| l.clone())
 }
 
-pub fn merge_iter<'a, I, F, G, U, R>(types: I, mut action: F, mut converter: G) -> Option<R>
+pub fn merge_iter<I, F, G, U, R>(types: I, mut action: F, mut converter: G) -> Option<R>
 where
     I: IntoIterator,
     F: FnMut(I::Item) -> Option<U>,
@@ -100,7 +100,7 @@ where
     }
 }
 
-fn merge_iter_<'a, I, F, G, U, R>(
+fn merge_iter_<I, F, G, U, R>(
     mut types: I,
     replaced: bool,
     output: &mut R,
diff --git a/base/src/metadata.rs b/base/src/metadata.rs
index 75d992ab..5302a8ab 100644
--- a/base/src/metadata.rs
+++ b/base/src/metadata.rs
@@ -84,7 +84,7 @@ impl Metadata {
             .map(|t| t.arguments.as_ref().map_or("", |s| s))
     }
 
-    pub fn attributes<'a>(&'a self) -> impl Iterator<Item = &'a Attribute> {
+    pub fn attributes(&self) -> impl Iterator<Item = &Attribute> {
         self.attributes.iter()
     }
 }
diff --git a/base/src/pos.rs b/base/src/pos.rs
index 6ff3aca0..31bf463c 100644
--- a/base/src/pos.rs
+++ b/base/src/pos.rs
@@ -76,10 +76,7 @@ pub fn spanned<T, Pos>(span: Span<Pos>, value: T) -> Spanned<T, Pos>
 where
     Pos: Ord,
 {
-    Spanned {
-        span: span,
-        value: value,
-    }
+    Spanned { span, value }
 }
 
 pub fn spanned2<T, Pos>(start: Pos, end: Pos, value: T) -> Spanned<T, Pos>
@@ -88,7 +85,7 @@ where
 {
     Spanned {
         span: span(start, end),
-        value: value,
+        value,
     }
 }
 
diff --git a/base/src/resolve.rs b/base/src/resolve.rs
index b5db3b5d..615878c7 100644
--- a/base/src/resolve.rs
+++ b/base/src/resolve.rs
@@ -32,6 +32,10 @@ impl AliasRemover {
         self.reduced_aliases.len()
     }
 
+    pub fn is_empty(&self) -> bool {
+        self.reduced_aliases.is_empty()
+    }
+
     pub fn reset(&mut self, to: usize) {
         self.reduced_aliases.truncate(to)
     }
@@ -93,7 +97,7 @@ where
                 .typ()
                 .apply_args(&typ.unapplied_args())
                 .map(|typ| Cow::Owned(canonical_alias(env, &typ, canonical).into_owned()))
-                .unwrap_or(Cow::Borrowed(typ))
+                .unwrap_or_else(|| Cow::Borrowed(typ))
         },
         _ => Cow::Borrowed(typ),
     }
diff --git a/base/src/serialization.rs b/base/src/serialization.rs
index 3077d70a..d887537c 100644
--- a/base/src/serialization.rs
+++ b/base/src/serialization.rs
@@ -22,9 +22,7 @@ pub struct SeSeed {
 
 impl SeSeed {
     pub fn new(node_to_id: NodeToId) -> Self {
-        SeSeed {
-            node_to_id: node_to_id,
-        }
+        SeSeed { node_to_id }
     }
 }
 
@@ -60,7 +58,7 @@ impl<Id, T> AsMut<::serialization::NodeMap> for Seed<Id, T> {
 impl<Id, T> Seed<Id, T> {
     pub fn new(nodes: ::serialization::NodeMap) -> Self {
         Seed {
-            nodes: nodes,
+            nodes,
             _marker: PhantomData,
         }
     }
@@ -172,14 +170,14 @@ impl NodeMap {
             .insert(id, value);
     }
 
-    pub fn get<T>(&self, id: &Id) -> Option<T>
+    pub fn get<T>(&self, id: Id) -> Option<T>
     where
         T: Any + Clone,
     {
         self.0
             .borrow()
             .get::<IdToShared<T>>()
-            .and_then(|map| map.get(id).cloned())
+            .and_then(|map| map.get(&id).cloned())
     }
 }
 
@@ -234,7 +232,7 @@ where
                 Ok(node)
             }
             Variant::Plain(value) => Ok(value),
-            Variant::Reference(id) => match self.0.as_mut().get(&id) {
+            Variant::Reference(id) => match self.0.as_mut().get(id) {
                 Some(rc) => Ok(rc),
                 None => Err(D::Error::custom(format_args!("missing id {}", id))),
             },
diff --git a/base/src/source.rs b/base/src/source.rs
index 03616f83..9415e644 100644
--- a/base/src/source.rs
+++ b/base/src/source.rs
@@ -140,7 +140,7 @@ impl<'a> Iterator for CommentIter<'a> {
                     self.src = rest;
                     comment
                 })
-            } else if self.src.starts_with("\n") {
+            } else if self.src.starts_with('\n') {
                 self.src = &self.src[1..];
                 Some("")
             } else {
@@ -158,7 +158,7 @@ impl<'a> DoubleEndedIterator for CommentIter<'a> {
             self.src = self
                 .src
                 .trim_right_matches(|c: char| c.is_whitespace() && c != '\n');
-            if self.src.ends_with("\n") {
+            if self.src.ends_with('\n') {
                 let comment_line = self.src[..self.src.len() - 1].lines().next_back().unwrap();
                 let trimmed = comment_line.trim_left();
 
diff --git a/base/src/symbol.rs b/base/src/symbol.rs
index dc16b459..3e42b90c 100644
--- a/base/src/symbol.rs
+++ b/base/src/symbol.rs
@@ -75,7 +75,7 @@ mod serialization {
 impl Deref for Symbol {
     type Target = SymbolRef;
     fn deref(&self) -> &SymbolRef {
-        unsafe { ::std::mem::transmute::<&str, &SymbolRef>(&(self.0).0) }
+        unsafe { &*(&*(self.0).0 as *const str as *const SymbolRef) }
     }
 }
 
@@ -105,7 +105,7 @@ impl fmt::Display for Symbol {
 
 impl PartialEq for Symbol {
     fn eq(&self, other: &Symbol) -> bool {
-        &**self == &**other
+        **self == **other
     }
 }
 
@@ -189,7 +189,7 @@ impl Symbol {
 impl SymbolRef {
     #[inline]
     pub fn new<N: ?Sized + AsRef<str>>(n: &N) -> &SymbolRef {
-        unsafe { ::std::mem::transmute::<&Name, &SymbolRef>(Name::new(n)) }
+        unsafe { &*(Name::new(n) as *const Name as *const SymbolRef) }
     }
 
     /// Checks whether the names of two symbols are equal
@@ -212,7 +212,7 @@ impl SymbolRef {
     }
 
     pub fn is_global(&self) -> bool {
-        self.0.chars().next() == Some('@')
+        self.0.starts_with('@')
     }
 
     fn ptr(&self) -> *const () {
@@ -226,6 +226,7 @@ impl SymbolRef {
 #[cfg_attr(feature = "serde_derive", serde(de_parameters = "S"))]
 pub struct NameBuf(String);
 
+#[allow(derive_hash_xor_eq)]
 #[derive(Debug, Eq, Hash)]
 pub struct Name(str);
 
@@ -263,7 +264,7 @@ impl<'a> Iterator for Components<'a> {
 impl Name {
     #[inline]
     pub fn new<N: ?Sized + AsRef<str>>(n: &N) -> &Name {
-        unsafe { ::std::mem::transmute::<&str, &Name>(n.as_ref()) }
+        unsafe { &*(n.as_ref() as *const str as *const Name) }
     }
 
     pub fn as_str(&self) -> &str {
@@ -395,7 +396,7 @@ impl Symbols {
 
     fn make_symbol(&mut self, name: NameBuf) -> Symbol {
         // `name` is fixed in memory and the key lives as long as `s` this is safe
-        let key = unsafe { ::std::mem::transmute::<&Name, &Name>(&name) };
+        let key = unsafe { &*(&*name as *const Name) };
         let s = Symbol(Arc::new(name));
         self.indexes.insert(key, s.clone());
         s
@@ -422,6 +423,10 @@ impl Symbols {
     pub fn len(&self) -> usize {
         self.indexes.len()
     }
+
+    pub fn is_empty(&self) -> bool {
+        self.indexes.is_empty()
+    }
 }
 
 /// `SymbolModule` wraps a `Symbols` struct and adds a prefix to all symbols created by the
@@ -437,7 +442,7 @@ pub struct SymbolModule<'a> {
 impl<'a> SymbolModule<'a> {
     pub fn new(module: String, symbols: &'a mut Symbols) -> SymbolModule<'a> {
         SymbolModule {
-            symbols: symbols,
+            symbols,
             module: NameBuf(module),
         }
     }
@@ -483,6 +488,10 @@ impl<'a> SymbolModule<'a> {
         self.symbols.len()
     }
 
+    pub fn is_empty(&self) -> bool {
+        self.symbols.is_empty()
+    }
+
     pub fn symbols(&mut self) -> &mut Symbols {
         self.symbols
     }
diff --git a/base/src/types/mod.rs b/base/src/types/mod.rs
index 98f650d1..6fa3d883 100644
--- a/base/src/types/mod.rs
+++ b/base/src/types/mod.rs
@@ -115,7 +115,7 @@ where
             .enumerate()
             .map(|(i, typ)| Field {
                 name: symbols.from_str(&format!("_{}", i)),
-                typ: typ,
+                typ,
             }).collect();
         if fields.is_empty() {
             self.unit()
@@ -171,7 +171,7 @@ pub enum BuiltinType {
 
 impl BuiltinType {
     pub fn symbol(self) -> &'static SymbolRef {
-        unsafe { ::std::mem::transmute::<&'static str, &'static SymbolRef>(self.to_str()) }
+        unsafe { &*(self.to_str() as *const str as *const SymbolRef) }
     }
 }
 
@@ -288,7 +288,7 @@ pub struct Generic<Id> {
 
 impl<Id> Generic<Id> {
     pub fn new(id: Id, kind: ArcKind) -> Generic<Id> {
-        Generic { id: id, kind: kind }
+        Generic { id, kind }
     }
 }
 
@@ -385,7 +385,7 @@ where
         (0..group.len())
             .map(|index| Alias {
                 _typ: T::from(Type::Alias(AliasRef {
-                    index: index,
+                    index,
                     group: group.clone(),
                 })),
                 _marker: PhantomData,
@@ -496,7 +496,7 @@ where
                             .position(|alias| alias.name == *id)
                             .map(|index| {
                                 T::from(Type::Alias(AliasRef {
-                                    index: index,
+                                    index,
                                     group: self.group.clone(),
                                 }))
                             });
@@ -565,7 +565,7 @@ where
 {
     pub fn new(name: Id, args: Vec<Generic<Id>>, typ: T) -> AliasData<Id, T> {
         AliasData {
-            name: name,
+            name,
             typ: Type::forall(args, typ),
         }
     }
@@ -649,10 +649,7 @@ pub type AppVec<T> = SmallVec<[T; 2]>;
 
 impl<Id, T> Field<Id, T> {
     pub fn new(name: Id, typ: T) -> Field<Id, T> {
-        Field {
-            name: name,
-            typ: typ,
-        }
+        Field { name, typ }
     }
 }
 
@@ -849,7 +846,7 @@ where
                 .enumerate()
                 .map(|(i, typ)| Field {
                     name: symbols.from_str(&format!("_{}", i)),
-                    typ: typ,
+                    typ,
                 }).collect(),
             Type::empty_row(),
         ))
@@ -876,9 +873,9 @@ where
             rest
         } else {
             T::from(Type::ExtendRow {
-                types: types,
-                fields: fields,
-                rest: rest,
+                types,
+                fields,
+                rest,
             })
         }
     }
@@ -921,10 +918,7 @@ where
     pub fn alias(name: Id, typ: T) -> T {
         T::from(Type::Alias(AliasRef {
             index: 0,
-            group: Arc::new(vec![AliasData {
-                name: name,
-                typ: typ,
-            }]),
+            group: Arc::new(vec![AliasData { name, typ }]),
         }))
     }
 
@@ -1052,7 +1046,7 @@ where
             Type::Opaque | Type::Builtin(_) | Type::Record(_) | Type::Variant(_) => {
                 Cow::Owned(Kind::typ())
             }
-            Type::EmptyRow | Type::ExtendRow { .. } => Cow::Owned(Kind::row().into()),
+            Type::EmptyRow | Type::ExtendRow { .. } => Cow::Owned(Kind::row()),
             Type::Forall(_, ref typ, _) => typ.kind_(applied_args),
             Type::Variable(ref var) => Cow::Borrowed(&var.kind),
             Type::Skolem(ref skolem) => Cow::Borrowed(&skolem.kind),
@@ -1132,8 +1126,7 @@ where
     {
         use serialization::SharedSeed;
         let seed = SharedSeed::new(seed);
-        ::serde::de::DeserializeSeed::deserialize(seed, deserializer)
-            .map(|typ| ArcType { typ: typ })
+        ::serde::de::DeserializeSeed::deserialize(seed, deserializer).map(|typ| ArcType { typ })
     }
 }
 
@@ -1342,7 +1335,7 @@ impl<Id> ArcType<Id> {
                     named_variables.remove(&param.id);
                 }
 
-                typ.instantiate_generics_(&mut named_variables)
+                typ.instantiate_generics_(&named_variables)
                     .map(|typ| Type::Forall(params.clone(), typ, vars.clone()).into())
             }
             _ => walk_move_type_opt(
@@ -1457,10 +1450,7 @@ impl ArcType {
                 .take(arg_types.len() + args.len() - params.len())
                 .cloned()
                 .collect();
-            Type::app(
-                d.cloned().unwrap_or_else(|| Type::function_builtin()),
-                arg_types,
-            )
+            Type::app(d.cloned().unwrap_or_else(Type::function_builtin), arg_types)
         } else {
             return None;
         };
@@ -1692,7 +1682,7 @@ pub fn arg_iter<Id, T>(typ: &T) -> ArgIterator<T>
 where
     T: Deref<Target = Type<Id, T>>,
 {
-    ArgIterator { typ: typ }
+    ArgIterator { typ }
 }
 
 impl<'a, Id, T> Iterator for ArgIterator<'a, T>
@@ -1720,7 +1710,7 @@ pub fn implicit_arg_iter<Id, T>(typ: &T) -> ImplicitArgIterator<T>
 where
     T: Deref<Target = Type<Id, T>>,
 {
-    ImplicitArgIterator { typ: typ }
+    ImplicitArgIterator { typ }
 }
 
 impl<'a, Id, T> Iterator for ImplicitArgIterator<'a, T>
@@ -1818,14 +1808,11 @@ impl Prec {
     }
 }
 
-fn dt<'a, T>(prec: Prec, typ: &'a T) -> DisplayType<'a, T> {
-    DisplayType {
-        prec: prec,
-        typ: typ,
-    }
+fn dt<T>(prec: Prec, typ: &T) -> DisplayType<T> {
+    DisplayType { prec, typ }
 }
 
-fn top<'a, T>(typ: &'a T) -> DisplayType<'a, T> {
+fn top<T>(typ: &T) -> DisplayType<T> {
     dt(Prec::Top, typ)
 }
 
diff --git a/base/src/types/pretty_print.rs b/base/src/types/pretty_print.rs
index 7d01b67f..8a066ca1 100644
--- a/base/src/types/pretty_print.rs
+++ b/base/src/types/pretty_print.rs
@@ -93,7 +93,7 @@ impl<'a, I, T, A> TypeFormatter<'a, I, T, A> {
     pub fn new(typ: &'a T) -> Self {
         TypeFormatter {
             width: 80,
-            typ: typ,
+            typ,
             filter: &|_| Filter::Retain,
             annotate_symbol: &|_| None,
             _marker: PhantomData,
diff --git a/vm/src/api/mod.rs b/vm/src/api/mod.rs
index 4e0e9293..980ba169 100644
--- a/vm/src/api/mod.rs
+++ b/vm/src/api/mod.rs
@@ -969,19 +969,6 @@ impl<'vm, 'value, T: vm::Userdata> Getable<'vm, 'value> for *const T {
     }
 }
 
-impl<'s, T: VmType> VmType for Box<T> {
-    type Type = T::Type;
-    fn make_type(vm: &Thread) -> ArcType {
-        T::make_type(vm)
-    }
-}
-
-impl<'vm, 'value, T: Getable<'vm, 'value>> Getable<'vm, 'value> for Box<T> {
-    fn from_value(vm: &'vm Thread, value: Variants<'value>) -> Box<T> {
-        Box::new(T::from_value(vm, value))
-    }
-}
-
 impl<K, V> VmType for BTreeMap<K, V>
 where
     K: VmType,
diff --git a/vm/src/serialization.rs b/vm/src/serialization.rs
index b5c08e9d..00d94e74 100644
--- a/vm/src/serialization.rs
+++ b/vm/src/serialization.rs
@@ -562,7 +562,7 @@ pub mod closure {
                                     Ok(closure)
                                 }
                                 GraphVariant::Reference(id) => {
-                                    match self.state.gc_map.get::<GcPtr<ClosureData>>(&id) {
+                                    match self.state.gc_map.get::<GcPtr<ClosureData>>(id) {
                                         Some(rc) => Ok(rc),
                                         None => {
                                             Err(V::Error::custom(format_args!("missing id {}", id)))


Test patch:
diff --git a/tests/api.rs b/tests/api.rs
index 15187848..30347ae0 100644
--- a/tests/api.rs
+++ b/tests/api.rs
@@ -351,24 +351,3 @@ fn use_rust_created_record_as_polymorphic() {
     let result = f.call(record_no_decl!{ x => 1 }).unwrap();
     assert_eq!(result, 1);
 }
-
-#[test]
-fn get_value_boxed_or_unboxed() {
-    let _ = ::env_logger::try_init();
-    let vm = make_vm();
-
-    let text = r#"
-        27
-    "#;
-
-    // The user should be able to decide whether or not any gluon value should
-    // be boxed on the rust side.
-    let (unboxed, _) = Compiler::new()
-        .run_expr::<i32>(&vm, "test", text)
-        .unwrap_or_else(|err| panic!("{}", err));
-    assert_eq!(unboxed, 27);
-    let (boxed, _) = Compiler::new()
-        .run_expr::<Box<i32>>(&vm, "test", text)
-        .unwrap_or_else(|err| panic!("{}", err));
-    assert_eq!(boxed, Box::new(27));
-}