diff options
| author | Seo Sanghyeon <sanxiyn@gmail.com> | 2016-07-31 00:58:30 +0900 |
|---|---|---|
| committer | Seo Sanghyeon <sanxiyn@gmail.com> | 2016-07-31 00:58:30 +0900 |
| commit | 03652157f9da55ea58debabe22bb7105ef8ebdf7 (patch) | |
| tree | abc9f9339bf238bb955b70d12669384f5711ded8 /src/librustc | |
| parent | 7580534c3a142c79340576c109f3cd73950996c0 (diff) | |
| download | rust-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.rs | 15 |
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, |
