Separate out a hir::Impl
struct
This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases.
This commit is contained in:
parent
fd34606ddf
commit
a8ff647deb
61 changed files with 258 additions and 246 deletions
|
@ -631,14 +631,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
self.dumper.dump_def(&access, enum_data);
|
||||
}
|
||||
|
||||
fn process_impl(
|
||||
&mut self,
|
||||
item: &'tcx hir::Item<'tcx>,
|
||||
generics: &'tcx hir::Generics<'tcx>,
|
||||
trait_ref: &'tcx Option<hir::TraitRef<'tcx>>,
|
||||
typ: &'tcx hir::Ty<'tcx>,
|
||||
impl_items: &'tcx [hir::ImplItemRef<'tcx>],
|
||||
) {
|
||||
fn process_impl(&mut self, item: &'tcx hir::Item<'tcx>, impl_: &'tcx hir::Impl<'tcx>) {
|
||||
if let Some(impl_data) = self.save_ctxt.get_item_data(item) {
|
||||
if !self.span.filter_generated(item.span) {
|
||||
if let super::Data::RelationData(rel, imp) = impl_data {
|
||||
|
@ -652,12 +645,12 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
|
||||
let map = &self.tcx.hir();
|
||||
self.nest_typeck_results(map.local_def_id(item.hir_id), |v| {
|
||||
v.visit_ty(&typ);
|
||||
if let Some(trait_ref) = trait_ref {
|
||||
v.visit_ty(&impl_.self_ty);
|
||||
if let Some(trait_ref) = &impl_.of_trait {
|
||||
v.process_path(trait_ref.hir_ref_id, &hir::QPath::Resolved(None, &trait_ref.path));
|
||||
}
|
||||
v.process_generic_params(generics, "", item.hir_id);
|
||||
for impl_item in impl_items {
|
||||
v.process_generic_params(&impl_.generics, "", item.hir_id);
|
||||
for impl_item in impl_.items {
|
||||
v.process_impl_item(
|
||||
map.impl_item(impl_item.id),
|
||||
map.local_def_id(item.hir_id).to_def_id(),
|
||||
|
@ -1287,9 +1280,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
|
|||
self.process_struct(item, def, ty_params)
|
||||
}
|
||||
hir::ItemKind::Enum(ref def, ref ty_params) => self.process_enum(item, def, ty_params),
|
||||
hir::ItemKind::Impl { ref generics, ref of_trait, ref self_ty, ref items, .. } => {
|
||||
self.process_impl(item, generics, of_trait, &self_ty, items)
|
||||
}
|
||||
hir::ItemKind::Impl(ref impl_) => self.process_impl(item, impl_),
|
||||
hir::ItemKind::Trait(_, _, ref generics, ref trait_refs, methods) => {
|
||||
self.process_trait(item, generics, trait_refs, methods)
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
attributes: lower_attributes(item.attrs.to_vec(), self),
|
||||
}))
|
||||
}
|
||||
hir::ItemKind::Impl { ref of_trait, ref self_ty, ref items, .. } => {
|
||||
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) {
|
||||
|
@ -410,7 +410,7 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
match self.tcx.impl_of_method(def_id) {
|
||||
Some(impl_id) => match self.tcx.hir().get_if_local(impl_id) {
|
||||
Some(Node::Item(item)) => match item.kind {
|
||||
hir::ItemKind::Impl { ref self_ty, .. } => {
|
||||
hir::ItemKind::Impl(hir::Impl { ref self_ty, .. }) => {
|
||||
let hir = self.tcx.hir();
|
||||
|
||||
let mut qualname = String::from("<");
|
||||
|
|
|
@ -501,7 +501,7 @@ impl<'hir> Sig for hir::Item<'hir> {
|
|||
|
||||
Ok(sig)
|
||||
}
|
||||
hir::ItemKind::Impl {
|
||||
hir::ItemKind::Impl(hir::Impl {
|
||||
unsafety,
|
||||
polarity,
|
||||
defaultness,
|
||||
|
@ -511,7 +511,7 @@ impl<'hir> Sig for hir::Item<'hir> {
|
|||
ref of_trait,
|
||||
ref self_ty,
|
||||
items: _,
|
||||
} => {
|
||||
}) => {
|
||||
let mut text = String::new();
|
||||
if let hir::Defaultness::Default { .. } = defaultness {
|
||||
text.push_str("default ");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue