X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Fhir%2Fmap%2Fmod.rs;h=7a20146130d9480e640e0d1ba328bd980eed2b38;hb=63ac2aae51034f93c23cffde7be711a86f9d139f;hp=6e35755d9a4ec228d93024ef5f4c56fe123309d5;hpb=1002e404e1ae6b8b907c8655edd41380d0c561cb;p=rust.git diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 6e35755d9a4..7a20146130d 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -204,7 +204,7 @@ pub fn read(&self, id: NodeId) { if let Some(entry) = self.map[id.as_usize()] { self.dep_graph.read_index(entry.dep_node); } else { - bug!("called `HirMap::read()` with invalid `NodeId`") + bug!("called `HirMap::read()` with invalid `NodeId`: {:?}", id) } } @@ -344,6 +344,7 @@ pub fn describe_def(&self, node_id: NodeId) -> Option { Node::AnonConst(_) | Node::Expr(_) | Node::Stmt(_) | + Node::PathSegment(_) | Node::Ty(_) | Node::TraitRef(_) | Node::Pat(_) | @@ -668,7 +669,7 @@ fn walk_parent_nodes(&self, /// } /// ``` pub fn get_return_block(&self, id: NodeId) -> Option { - let match_fn = |node: &Node| { + let match_fn = |node: &Node<'_>| { match *node { Node::Item(_) | Node::ForeignItem(_) | @@ -677,7 +678,7 @@ pub fn get_return_block(&self, id: NodeId) -> Option { _ => false, } }; - let match_non_returning_block = |node: &Node| { + let match_non_returning_block = |node: &Node<'_>| { match *node { Node::Expr(ref expr) => { match expr.node { @@ -884,6 +885,7 @@ pub fn span(&self, id: NodeId) -> Span { Some(Node::AnonConst(constant)) => self.body(constant.body).value.span, Some(Node::Expr(expr)) => expr.span, Some(Node::Stmt(stmt)) => stmt.span, + Some(Node::PathSegment(seg)) => seg.ident.span, Some(Node::Ty(ty)) => ty.span, Some(Node::TraitRef(tr)) => tr.path.span, Some(Node::Binding(pat)) => pat.span, @@ -954,7 +956,7 @@ fn suffix_matches(&self, parent: NodeId) -> bool { // If `id` itself is a mod named `m` with parent `p`, then // returns `Some(id, m, p)`. If `id` has no mod in its parent // chain, then returns `None`. - fn find_first_mod_parent<'a>(map: &'a Map, mut id: NodeId) -> Option<(NodeId, Name)> { + fn find_first_mod_parent<'a>(map: &'a Map<'_>, mut id: NodeId) -> Option<(NodeId, Name)> { loop { if let Node::Item(item) = map.find(id)? { if item_is_mod(&item) { @@ -1076,7 +1078,7 @@ pub fn map_crate<'hir>(sess: &::session::Session, /// Identical to the `PpAnn` implementation for `hir::Crate`, /// except it avoids creating a dependency on the whole crate. impl<'hir> print::PpAnn for Map<'hir> { - fn nested(&self, state: &mut print::State, nested: print::Nested) -> io::Result<()> { + fn nested(&self, state: &mut print::State<'_>, nested: print::Nested) -> io::Result<()> { match nested { Nested::Item(id) => state.print_item(self.expect_item(id.id)), Nested::TraitItem(id) => state.print_trait_item(self.trait_item(id)), @@ -1088,7 +1090,7 @@ fn nested(&self, state: &mut print::State, nested: print::Nested) -> io::Result< } impl<'a> print::State<'a> { - pub fn print_node(&mut self, node: Node) -> io::Result<()> { + pub fn print_node(&mut self, node: Node<'_>) -> io::Result<()> { match node { Node::Item(a) => self.print_item(&a), Node::ForeignItem(a) => self.print_foreign_item(&a), @@ -1098,6 +1100,7 @@ pub fn print_node(&mut self, node: Node) -> io::Result<()> { Node::AnonConst(a) => self.print_anon_const(&a), Node::Expr(a) => self.print_expr(&a), Node::Stmt(a) => self.print_stmt(&a), + Node::PathSegment(a) => self.print_path_segment(&a), Node::Ty(a) => self.print_type(&a), Node::TraitRef(a) => self.print_trait_ref(&a), Node::Binding(a) | @@ -1126,7 +1129,7 @@ pub fn print_node(&mut self, node: Node) -> io::Result<()> { } } -fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String { +fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String { let id_str = format!(" (id={})", id); let id_str = if include_id { &id_str[..] } else { "" }; @@ -1215,6 +1218,9 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String { Some(Node::Stmt(_)) => { format!("stmt {}{}", map.node_to_pretty_string(id), id_str) } + Some(Node::PathSegment(_)) => { + format!("path segment {}{}", map.node_to_pretty_string(id), id_str) + } Some(Node::Ty(_)) => { format!("type {}{}", map.node_to_pretty_string(id), id_str) } @@ -1253,7 +1259,7 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String { } } -pub fn describe_def(tcx: TyCtxt, def_id: DefId) -> Option { +pub fn describe_def(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option { if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { tcx.hir.describe_def(node_id) } else {