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)
}
}
Node::AnonConst(_) |
Node::Expr(_) |
Node::Stmt(_) |
+ Node::PathSegment(_) |
Node::Ty(_) |
Node::TraitRef(_) |
Node::Pat(_) |
/// }
/// ```
pub fn get_return_block(&self, id: NodeId) -> Option<NodeId> {
- let match_fn = |node: &Node| {
+ let match_fn = |node: &Node<'_>| {
match *node {
Node::Item(_) |
Node::ForeignItem(_) |
_ => false,
}
};
- let match_non_returning_block = |node: &Node| {
+ let match_non_returning_block = |node: &Node<'_>| {
match *node {
Node::Expr(ref expr) => {
match expr.node {
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,
// 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) {
/// 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)),
}
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),
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) |
}
}
-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 { "" };
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)
}
}
}
-pub fn describe_def(tcx: TyCtxt, def_id: DefId) -> Option<Def> {
+pub fn describe_def(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option<Def> {
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) {
tcx.hir.describe_def(node_id)
} else {