diff options
| author | bors <bors@rust-lang.org> | 2022-09-05 13:36:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-05 13:36:54 +0000 |
| commit | 2dc703fd6e3aaaf343828cc7dd1aec192d24c628 (patch) | |
| tree | cfdce4f7717d0af4d6feae94ea2abbe95a2dd092 /compiler/rustc_save_analysis/src | |
| parent | 6e4a9ab650b135ae0ff761e4a37d96c8bcaf7b3d (diff) | |
| parent | 08a00eb0da303f82057174ab79d5b079d762bb61 (diff) | |
| download | rust-2dc703fd6e3aaaf343828cc7dd1aec192d24c628.tar.gz rust-2dc703fd6e3aaaf343828cc7dd1aec192d24c628.zip | |
Auto merge of #101228 - nnethercote:simplify-hir-PathSegment, r=petrochenkov
Simplify `hir::PathSegment` r? `@petrochenkov`
Diffstat (limited to 'compiler/rustc_save_analysis/src')
| -rw-r--r-- | compiler/rustc_save_analysis/src/dump_visitor.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_save_analysis/src/lib.rs | 11 |
2 files changed, 10 insertions, 6 deletions
diff --git a/compiler/rustc_save_analysis/src/dump_visitor.rs b/compiler/rustc_save_analysis/src/dump_visitor.rs index c9fc6b9e47a..d4b4d3c229c 100644 --- a/compiler/rustc_save_analysis/src/dump_visitor.rs +++ b/compiler/rustc_save_analysis/src/dump_visitor.rs @@ -912,7 +912,10 @@ impl<'tcx> DumpVisitor<'tcx> { _, ) | Res::SelfTy { .. } => { - self.dump_path_segment_ref(id, &hir::PathSegment::from_ident(ident)); + self.dump_path_segment_ref( + id, + &hir::PathSegment::new(ident, hir::HirId::INVALID, Res::Err), + ); } def => { error!("unexpected definition kind when processing collected idents: {:?}", def) diff --git a/compiler/rustc_save_analysis/src/lib.rs b/compiler/rustc_save_analysis/src/lib.rs index 16af5338510..c58ccde4390 100644 --- a/compiler/rustc_save_analysis/src/lib.rs +++ b/compiler/rustc_save_analysis/src/lib.rs @@ -596,13 +596,14 @@ impl<'tcx> SaveContext<'tcx> { Node::TraitRef(tr) => tr.path.res, Node::Item(&hir::Item { kind: hir::ItemKind::Use(path, _), .. }) => path.res, - Node::PathSegment(seg) => match seg.res { - Some(res) if res != Res::Err => res, - _ => { + Node::PathSegment(seg) => { + if seg.res != Res::Err { + seg.res + } else { let parent_node = self.tcx.hir().get_parent_node(hir_id); self.get_path_res(parent_node) } - }, + } Node::Expr(&hir::Expr { kind: hir::ExprKind::Struct(ref qpath, ..), .. }) => { self.typeck_results().qpath_res(qpath, hir_id) @@ -648,7 +649,7 @@ impl<'tcx> SaveContext<'tcx> { } pub fn get_path_segment_data(&self, path_seg: &hir::PathSegment<'_>) -> Option<Ref> { - self.get_path_segment_data_with_id(path_seg, path_seg.hir_id?) + self.get_path_segment_data_with_id(path_seg, path_seg.hir_id) } pub fn get_path_segment_data_with_id( |
