diff options
Diffstat (limited to 'compiler/rustc_save_analysis/src/lib.rs')
| -rw-r--r-- | compiler/rustc_save_analysis/src/lib.rs | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/compiler/rustc_save_analysis/src/lib.rs b/compiler/rustc_save_analysis/src/lib.rs index 619e083d89a..ad7aca3cb94 100644 --- a/compiler/rustc_save_analysis/src/lib.rs +++ b/compiler/rustc_save_analysis/src/lib.rs @@ -1,12 +1,14 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![feature(if_let_guard)] -#![feature(let_else)] #![recursion_limit = "256"] #![allow(rustc::potential_query_instability)] #![feature(never_type)] #![deny(rustc::untranslatable_diagnostic)] #![deny(rustc::diagnostic_outside_of_impl)] +#[macro_use] +extern crate tracing; + mod dump_visitor; mod dumper; #[macro_use] @@ -49,8 +51,6 @@ use rls_data::{ RefKind, Relation, RelationKind, SpanData, }; -use tracing::{debug, error, info}; - pub struct SaveContext<'tcx> { tcx: TyCtxt<'tcx>, maybe_typeck_results: Option<&'tcx ty::TypeckResults<'tcx>>, @@ -595,13 +595,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) @@ -620,7 +621,7 @@ impl<'tcx> SaveContext<'tcx> { hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => { // #75962: `self.typeck_results` may be different from the `hir_id`'s result. if self.tcx.has_typeck_results(hir_id.owner.to_def_id()) { - self.tcx.typeck(hir_id.owner).qpath_res(qpath, hir_id) + self.tcx.typeck(hir_id.owner.def_id).qpath_res(qpath, hir_id) } else { Res::Err } @@ -647,7 +648,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( @@ -683,6 +684,7 @@ impl<'tcx> SaveContext<'tcx> { | HirDefKind::AssocTy | HirDefKind::Trait | HirDefKind::OpaqueTy + | HirDefKind::ImplTraitPlaceholder | HirDefKind::TyParam, def_id, ) => Some(Ref { kind: RefKind::Type, span, ref_id: id_from_def_id(def_id) }), @@ -864,23 +866,12 @@ impl<'l> Visitor<'l> for PathCollector<'l> { hir::PatKind::TupleStruct(ref path, ..) | hir::PatKind::Path(ref path) => { self.collected_paths.push((p.hir_id, path)); } - hir::PatKind::Binding(bm, _, ident, _) => { + hir::PatKind::Binding(hir::BindingAnnotation(_, mutbl), _, ident, _) => { debug!( "PathCollector, visit ident in pat {}: {:?} {:?}", ident, p.span, ident.span ); - let immut = match bm { - // Even if the ref is mut, you can't change the ref, only - // the data pointed at, so showing the initialising expression - // is still worthwhile. - hir::BindingAnnotation::Unannotated | hir::BindingAnnotation::Ref => { - hir::Mutability::Not - } - hir::BindingAnnotation::Mutable | hir::BindingAnnotation::RefMut => { - hir::Mutability::Mut - } - }; - self.collected_idents.push((p.hir_id, ident, immut)); + self.collected_idents.push((p.hir_id, ident, mutbl)); } _ => {} } @@ -1049,7 +1040,7 @@ fn id_from_hir_id(id: hir::HirId, scx: &SaveContext<'_>) -> rls_data::Id { // crate (very unlikely to actually happen). rls_data::Id { krate: LOCAL_CRATE.as_u32(), - index: id.owner.local_def_index.as_u32() | id.local_id.as_u32().reverse_bits(), + index: id.owner.def_id.local_def_index.as_u32() | id.local_id.as_u32().reverse_bits(), } }) } |
