]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_save_analysis/src/lib.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / compiler / rustc_save_analysis / src / lib.rs
index 0a8a88132e33de65849e710a2d069da135a1c5d6..41d174cde0a8ca0d3999641bda02efc5fdbf3b88 100644 (file)
@@ -1,5 +1,7 @@
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
+#![feature(if_let_guard)]
 #![feature(nll)]
+#![cfg_attr(bootstrap, allow(incomplete_features))] // if_let_guard
 #![recursion_limit = "256"]
 
 mod dump_visitor;
@@ -326,54 +328,53 @@ impl<'tcx> SaveContext<'tcx> {
                     attributes: lower_attributes(attrs.to_vec(), self),
                 }))
             }
-            hir::ItemKind::Impl(hir::Impl { ref of_trait, ref self_ty, ref items, .. }) => {
-                if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = self_ty.kind {
-                    // Common case impl for a struct or something basic.
-                    if generated_code(path.span) {
-                        return None;
-                    }
-                    let sub_span = path.segments.last().unwrap().ident.span;
-                    filter!(self.span_utils, sub_span);
+            hir::ItemKind::Impl(hir::Impl { ref of_trait, ref self_ty, ref items, .. })
+                if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = self_ty.kind =>
+            {
+                // Common case impl for a struct or something basic.
+                if generated_code(path.span) {
+                    return None;
+                }
+                let sub_span = path.segments.last().unwrap().ident.span;
+                filter!(self.span_utils, sub_span);
 
-                    let impl_id = self.next_impl_id();
-                    let span = self.span_from_span(sub_span);
+                let impl_id = self.next_impl_id();
+                let span = self.span_from_span(sub_span);
 
-                    let type_data = self.lookup_def_id(self_ty.hir_id);
-                    type_data.map(|type_data| {
-                        Data::RelationData(
-                            Relation {
-                                kind: RelationKind::Impl { id: impl_id },
-                                span: span.clone(),
-                                from: id_from_def_id(type_data),
-                                to: of_trait
-                                    .as_ref()
-                                    .and_then(|t| self.lookup_def_id(t.hir_ref_id))
-                                    .map(id_from_def_id)
-                                    .unwrap_or_else(null_id),
-                            },
-                            Impl {
-                                id: impl_id,
-                                kind: match *of_trait {
-                                    Some(_) => ImplKind::Direct,
-                                    None => ImplKind::Inherent,
-                                },
-                                span,
-                                value: String::new(),
-                                parent: None,
-                                children: items
-                                    .iter()
-                                    .map(|i| id_from_def_id(i.id.def_id.to_def_id()))
-                                    .collect(),
-                                docs: String::new(),
-                                sig: None,
-                                attributes: vec![],
+                let type_data = self.lookup_def_id(self_ty.hir_id);
+                type_data.map(|type_data| {
+                    Data::RelationData(
+                        Relation {
+                            kind: RelationKind::Impl { id: impl_id },
+                            span: span.clone(),
+                            from: id_from_def_id(type_data),
+                            to: of_trait
+                                .as_ref()
+                                .and_then(|t| self.lookup_def_id(t.hir_ref_id))
+                                .map(id_from_def_id)
+                                .unwrap_or_else(null_id),
+                        },
+                        Impl {
+                            id: impl_id,
+                            kind: match *of_trait {
+                                Some(_) => ImplKind::Direct,
+                                None => ImplKind::Inherent,
                             },
-                        )
-                    })
-                } else {
-                    None
-                }
+                            span,
+                            value: String::new(),
+                            parent: None,
+                            children: items
+                                .iter()
+                                .map(|i| id_from_def_id(i.id.def_id.to_def_id()))
+                                .collect(),
+                            docs: String::new(),
+                            sig: None,
+                            attributes: vec![],
+                        },
+                    )
+                })
             }
+            hir::ItemKind::Impl(_) => None,
             _ => {
                 // FIXME
                 bug!();