Skip to content

Commit

Permalink
Rollup merge of rust-lang#65511 - Xanewok:sa-nest-in-impls, r=pnkfelix
Browse files Browse the repository at this point in the history
save-analysis: Nest tables when processing impl block definitions

Similar to rust-lang#65353 (which this PR should've been a part of), however in this case we didn't previously nest the tables when processing trait paths in impl block declarations.

Closes rust-lang#65411
  • Loading branch information
tmandry authored Oct 18, 2019
2 parents f58b532 + ad6ce46 commit 00427cb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,15 +669,18 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
}
}
}
self.visit_ty(&typ);
if let &Some(ref trait_ref) = trait_ref {
self.process_path(trait_ref.ref_id, &trait_ref.path);
}
self.process_generic_params(generics, "", item.id);
for impl_item in impl_items {
let map = &self.tcx.hir();
self.process_impl_item(impl_item, map.local_def_id_from_node_id(item.id));
}

let map = &self.tcx.hir();
self.nest_tables(item.id, |v| {
v.visit_ty(&typ);
if let &Some(ref trait_ref) = trait_ref {
v.process_path(trait_ref.ref_id, &trait_ref.path);
}
v.process_generic_params(generics, "", item.id);
for impl_item in impl_items {
v.process_impl_item(impl_item, map.local_def_id_from_node_id(item.id));
}
});
}

fn process_trait(
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/save-analysis/issue-65411.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// check-pass
// compile-flags: -Zsave-analysis

trait Trait { type Assoc; }
trait GenericTrait<T> {}
struct Wrapper<B> { b: B }

fn func() {
// Processing associated path in impl block definition inside a function
// body does not ICE
impl<B: Trait> GenericTrait<B::Assoc> for Wrapper<B> {}
}


fn main() {}

0 comments on commit 00427cb

Please sign in to comment.