about summary refs log tree commit diff
path: root/src/librustc
diff options
context:
space:
mode:
authorSeo Sanghyeon <sanxiyn@gmail.com>2016-07-31 00:58:30 +0900
committerSeo Sanghyeon <sanxiyn@gmail.com>2016-07-31 00:58:30 +0900
commit03652157f9da55ea58debabe22bb7105ef8ebdf7 (patch)
treeabc9f9339bf238bb955b70d12669384f5711ded8 /src/librustc
parent7580534c3a142c79340576c109f3cd73950996c0 (diff)
downloadrust-03652157f9da55ea58debabe22bb7105ef8ebdf7.tar.gz
rust-03652157f9da55ea58debabe22bb7105ef8ebdf7.zip
Suppress unused type parameter error when type has error field
Diffstat (limited to 'src/librustc')
-rw-r--r--src/librustc/ty/util.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs
index 21c14e6fe4c..fadf3647155 100644
--- a/src/librustc/ty/util.rs
+++ b/src/librustc/ty/util.rs
@@ -182,6 +182,21 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
         pat_util::arm_contains_ref_binding(arm)
     }
 
+    pub fn has_error_field(self, ty: Ty<'tcx>) -> bool {
+        match ty.sty {
+            ty::TyStruct(def, substs) | ty::TyEnum(def, substs) => {
+                for field in def.all_fields() {
+                    let field_ty = field.ty(self, substs);
+                    if let TyError = field_ty.sty {
+                        return true;
+                    }
+                }
+            }
+            _ => ()
+        }
+        false
+    }
+
     /// Returns the type of element at index `i` in tuple or tuple-like type `t`.
     /// For an enum `t`, `variant` is None only if `t` is a univariant enum.
     pub fn positional_element_ty(self,