Auto merge of #61771 - ehuss:update-cargo, r=alexcrichton
Update cargo
Update cargo
19 commits in 545f354259be4e9745ea00a524c0e4c51df01aa6..807429e1b6da4e2ec52488ef2f59e77068c31e1f
2019-05-23 17:45:30 +0000 to 2019-06-11 14:06:10 +0000
- Stabilize publish-lockfile. (rust-lang/cargo#7026)
- change package cache lock message (rust-lang/cargo#7029)
- Fix documenting an example. (rust-lang/cargo#7023)
- Fix nonconcurrent tests (rust-lang/cargo#6900)
- Update git2 crates for libgit2 0.28 (rust-lang/cargo#7018)
- fix bunch of clippy warnings (rust-lang/cargo#7019)
- Ignore remap-path-prefix in metadata hash. (rust-lang/cargo#6966)
- Don't synthesize feature diretives for non-optional deps (rust-lang/cargo#7010)
- Handle pipelined tests of libraries (rust-lang/cargo#7008)
- Import the cargo-vendor subcommand into Cargo (rust-lang/cargo#6869)
- Remove unnecessary outlives bounds (rust-lang/cargo#7000)
- Catch filename output collisions in rustdoc. (rust-lang/cargo#6998)
- the testing SAT solver was messed up by a refactor (rust-lang/cargo#6995)
- Add some hints to the docs for `cfg()` targets (rust-lang/cargo#6990)
- Test the Resolver against the varisat Library (rust-lang/cargo#6980)
- Update changelog. (rust-lang/cargo#6984)
- Update cache-messages tracking issue. (rust-lang/cargo#6987)
- zsh: Add --all-targets option to cargo-check and cargo-build (rust-lang/cargo#6985)
- Fix typo (rust-lang/cargo#6982)
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index 7cbb496..ee78839 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -1515,18 +1515,18 @@
///
/// ```
/// #![feature(weak_ptr_eq)]
- /// use std::rc::{Rc, Weak};
+ /// use std::rc::Rc;
///
/// let first_rc = Rc::new(5);
/// let first = Rc::downgrade(&first_rc);
/// let second = Rc::downgrade(&first_rc);
///
- /// assert!(Weak::ptr_eq(&first, &second));
+ /// assert!(first.ptr_eq(&second));
///
/// let third_rc = Rc::new(5);
/// let third = Rc::downgrade(&third_rc);
///
- /// assert!(!Weak::ptr_eq(&first, &third));
+ /// assert!(!first.ptr_eq(&third));
/// ```
///
/// Comparing `Weak::new`.
@@ -1537,16 +1537,16 @@
///
/// let first = Weak::new();
/// let second = Weak::new();
- /// assert!(Weak::ptr_eq(&first, &second));
+ /// assert!(first.ptr_eq(&second));
///
/// let third_rc = Rc::new(());
/// let third = Rc::downgrade(&third_rc);
- /// assert!(!Weak::ptr_eq(&first, &third));
+ /// assert!(!first.ptr_eq(&third));
/// ```
#[inline]
#[unstable(feature = "weak_ptr_eq", issue = "55981")]
- pub fn ptr_eq(this: &Self, other: &Self) -> bool {
- this.ptr.as_ptr() == other.ptr.as_ptr()
+ pub fn ptr_eq(&self, other: &Self) -> bool {
+ self.ptr.as_ptr() == other.ptr.as_ptr()
}
}
diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs
index 2503f69..6c23b31 100644
--- a/src/liballoc/sync.rs
+++ b/src/liballoc/sync.rs
@@ -1349,18 +1349,18 @@
///
/// ```
/// #![feature(weak_ptr_eq)]
- /// use std::sync::{Arc, Weak};
+ /// use std::sync::Arc;
///
/// let first_rc = Arc::new(5);
/// let first = Arc::downgrade(&first_rc);
/// let second = Arc::downgrade(&first_rc);
///
- /// assert!(Weak::ptr_eq(&first, &second));
+ /// assert!(first.ptr_eq(&second));
///
/// let third_rc = Arc::new(5);
/// let third = Arc::downgrade(&third_rc);
///
- /// assert!(!Weak::ptr_eq(&first, &third));
+ /// assert!(!first.ptr_eq(&third));
/// ```
///
/// Comparing `Weak::new`.
@@ -1371,16 +1371,16 @@
///
/// let first = Weak::new();
/// let second = Weak::new();
- /// assert!(Weak::ptr_eq(&first, &second));
+ /// assert!(first.ptr_eq(&second));
///
/// let third_rc = Arc::new(());
/// let third = Arc::downgrade(&third_rc);
- /// assert!(!Weak::ptr_eq(&first, &third));
+ /// assert!(!first.ptr_eq(&third));
/// ```
#[inline]
#[unstable(feature = "weak_ptr_eq", issue = "55981")]
- pub fn ptr_eq(this: &Self, other: &Self) -> bool {
- this.ptr.as_ptr() == other.ptr.as_ptr()
+ pub fn ptr_eq(&self, other: &Self) -> bool {
+ self.ptr.as_ptr() == other.ptr.as_ptr()
}
}
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs
index 8d9a517..b30eff8 100644
--- a/src/libcore/intrinsics.rs
+++ b/src/libcore/intrinsics.rs
@@ -1607,3 +1607,9 @@
// Identical to the `f32` case.
(if x < y || x != x { y } else { x }) * 1.0
}
+
+/// For bootstrapping, implement unchecked_sub as just wrapping_sub.
+#[cfg(bootstrap)]
+pub unsafe fn unchecked_sub<T>(x: T, y: T) -> T {
+ sub_with_overflow(x, y).0
+}
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs
index d93e5a9..b2376cd 100644
--- a/src/libcore/slice/mod.rs
+++ b/src/libcore/slice/mod.rs
@@ -25,7 +25,7 @@
use crate::cmp::Ordering::{self, Less, Equal, Greater};
use crate::cmp;
use crate::fmt;
-use crate::intrinsics::assume;
+use crate::intrinsics::{assume, exact_div, unchecked_sub};
use crate::isize;
use crate::iter::*;
use crate::ops::{FnMut, Try, self};
@@ -2998,14 +2998,27 @@
// unexpected way. (Tested by `codegen/slice-position-bounds-check`.)
macro_rules! len {
($self: ident) => {{
+ #![allow(unused_unsafe)] // we're sometimes used within an unsafe block
+
let start = $self.ptr;
- let diff = ($self.end as usize).wrapping_sub(start as usize);
let size = size_from_ptr(start);
if size == 0 {
+ // This _cannot_ use `unchecked_sub` because we depend on wrapping
+ // to represent the length of long ZST slice iterators.
+ let diff = ($self.end as usize).wrapping_sub(start as usize);
diff
} else {
- // Using division instead of `offset_from` helps LLVM remove bounds checks
- diff / size
+ // We know that `start <= end`, so can do better than `offset_from`,
+ // which needs to deal in signed. By setting appropriate flags here
+ // we can tell LLVM this, which helps it remove bounds checks.
+ // SAFETY: By the type invariant, `start <= end`
+ let diff = unsafe { unchecked_sub($self.end as usize, start as usize) };
+ // By also telling LLVM that the pointers are apart by an exact
+ // multiple of the type size, it can optimize `len() == 0` down to
+ // `start == end` instead of `(end - start) < size`.
+ // SAFETY: By the type invariant, the pointers are aligned so the
+ // distance between them must be a multiple of pointee size
+ unsafe { exact_div(diff, size) }
}
}}
}
diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs
index 139c144..8560232 100644
--- a/src/librustc/cfg/construct.rs
+++ b/src/librustc/cfg/construct.rs
@@ -42,7 +42,7 @@
let body_exit;
// Find the tables for this body.
- let owner_def_id = tcx.hir().local_def_id(tcx.hir().body_owner(body.id()));
+ let owner_def_id = tcx.hir().body_owner_def_id(body.id());
let tables = tcx.typeck_tables_of(owner_def_id);
let mut cfg_builder = CFGBuilder {
@@ -357,7 +357,7 @@
args: I) -> CFGIndex {
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
let ret = self.straightline(call_expr, func_or_rcvr_exit, args);
- let m = self.tcx.hir().get_module_parent_by_hir_id(call_expr.hir_id);
+ let m = self.tcx.hir().get_module_parent(call_expr.hir_id);
if self.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(call_expr)) {
self.add_unreachable_node()
} else {
diff --git a/src/librustc/cfg/graphviz.rs b/src/librustc/cfg/graphviz.rs
index dbc462e..66963e5 100644
--- a/src/librustc/cfg/graphviz.rs
+++ b/src/librustc/cfg/graphviz.rs
@@ -22,11 +22,11 @@
impl<'a, 'tcx> LabelledCFG<'a, 'tcx> {
fn local_id_to_string(&self, local_id: hir::ItemLocalId) -> String {
assert!(self.cfg.owner_def_id.is_local());
- let node_id = self.tcx.hir().hir_to_node_id(hir::HirId {
+ let hir_id = hir::HirId {
owner: self.tcx.hir().def_index_to_hir_id(self.cfg.owner_def_id.index).owner,
local_id
- });
- let s = self.tcx.hir().node_to_string(node_id);
+ };
+ let s = self.tcx.hir().node_to_string(hir_id);
// Replacing newlines with \\l causes each line to be left-aligned,
// improving presentation of (long) pretty-printed expressions.
diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs
index f4f9d62..666cfc3 100644
--- a/src/librustc/hir/intravisit.rs
+++ b/src/librustc/hir/intravisit.rs
@@ -171,7 +171,7 @@
/// but cannot supply a `Map`; see `nested_visit_map` for advice.
#[allow(unused_variables)]
fn visit_nested_item(&mut self, id: ItemId) {
- let opt_item = self.nested_visit_map().inter().map(|map| map.expect_item_by_hir_id(id.id));
+ let opt_item = self.nested_visit_map().inter().map(|map| map.expect_item(id.id));
if let Some(item) = opt_item {
self.visit_item(item);
}
diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs
index fafe671..32d0e06 100644
--- a/src/librustc/hir/map/hir_id_validator.rs
+++ b/src/librustc/hir/map/hir_id_validator.rs
@@ -1,6 +1,5 @@
use crate::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
use crate::hir::{self, intravisit, HirId, ItemLocalId};
-use syntax::ast::NodeId;
use crate::hir::itemlikevisit::ItemLikeVisitor;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::{Lock, ParallelIterator, par_iter};
@@ -112,19 +111,9 @@
trace!("missing hir id {:#?}", hir_id);
- // We are already in ICE mode here, so doing a linear search
- // should be fine.
- let (node_id, _) = self.hir_map
- .definitions()
- .node_to_hir_id
- .iter()
- .enumerate()
- .find(|&(_, &entry)| hir_id == entry)
- .expect("no node_to_hir_id entry");
- let node_id = NodeId::from_usize(node_id);
missing_items.push(format!("[local_id: {}, node:{}]",
local_id,
- self.hir_map.node_to_string(node_id)));
+ self.hir_map.node_to_string(hir_id)));
}
self.error(|| format!(
"ItemLocalIds not assigned densely in {}. \
@@ -138,7 +127,7 @@
owner: owner_def_index,
local_id,
})
- .map(|h| format!("({:?} {})", h, self.hir_map.hir_to_string(h)))
+ .map(|h| format!("({:?} {})", h, self.hir_map.node_to_string(h)))
.collect::<Vec<_>>()));
}
}
@@ -156,14 +145,14 @@
if hir_id == hir::DUMMY_HIR_ID {
self.error(|| format!("HirIdValidator: HirId {:?} is invalid",
- self.hir_map.hir_to_string(hir_id)));
+ self.hir_map.node_to_string(hir_id)));
return;
}
if owner != hir_id.owner {
self.error(|| format!(
"HirIdValidator: The recorded owner of {} is {} instead of {}",
- self.hir_map.hir_to_string(hir_id),
+ self.hir_map.node_to_string(hir_id),
self.hir_map.def_path(DefId::local(hir_id.owner)).to_string_no_crate(),
self.hir_map.def_path(DefId::local(owner)).to_string_no_crate()));
}
diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs
index 978a555..85c8699 100644
--- a/src/librustc/hir/map/mod.rs
+++ b/src/librustc/hir/map/mod.rs
@@ -35,7 +35,7 @@
pub mod definitions;
mod hir_id_validator;
-/// Represents an entry and its parent `NodeId`.
+/// Represents an entry and its parent `HirId`.
#[derive(Copy, Clone, Debug)]
pub struct Entry<'hir> {
parent: HirId,
@@ -200,7 +200,7 @@
/// "reveals" the content of a node to the caller (who might not
/// otherwise have had access to those contents, and hence needs a
/// read recorded). If the function just returns a DefId or
- /// NodeId, no actual content was returned, so no read is needed.
+ /// HirId, no actual content was returned, so no read is needed.
pub fn read(&self, hir_id: HirId) {
if let Some(entry) = self.lookup(hir_id) {
self.dep_graph.read_index(entry.dep_node);
@@ -287,20 +287,10 @@
}
#[inline]
- pub fn def_index_to_node_id(&self, def_index: DefIndex) -> NodeId {
- self.definitions.def_index_to_node_id(def_index)
- }
-
- #[inline]
pub fn local_def_id_to_hir_id(&self, def_id: LocalDefId) -> HirId {
self.definitions.def_index_to_hir_id(def_id.to_def_id().index)
}
- #[inline]
- pub fn local_def_id_to_node_id(&self, def_id: LocalDefId) -> NodeId {
- self.definitions.as_local_node_id(def_id.to_def_id()).unwrap()
- }
-
fn def_kind(&self, node_id: NodeId) -> Option<DefKind> {
let node = if let Some(node) = self.find(node_id) {
node
@@ -422,12 +412,6 @@
self.forest.krate.body(id)
}
- pub fn fn_decl(&self, node_id: ast::NodeId) -> Option<FnDecl> {
- let hir_id = self.node_to_hir_id(node_id);
- self.fn_decl_by_hir_id(hir_id)
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
pub fn fn_decl_by_hir_id(&self, hir_id: HirId) -> Option<FnDecl> {
if let Some(entry) = self.find_entry(hir_id) {
entry.fn_decl().cloned()
@@ -436,28 +420,22 @@
}
}
- /// Returns the `NodeId` that corresponds to the definition of
+ /// Returns the `HirId` that corresponds to the definition of
/// which this is the body of, i.e., a `fn`, `const` or `static`
/// item (possibly associated), a closure, or a `hir::AnonConst`.
- pub fn body_owner(&self, BodyId { hir_id }: BodyId) -> NodeId {
+ pub fn body_owner(&self, BodyId { hir_id }: BodyId) -> HirId {
let parent = self.get_parent_node_by_hir_id(hir_id);
assert!(self.lookup(parent).map_or(false, |e| e.is_body_owner(hir_id)));
- self.hir_to_node_id(parent)
+ parent
}
pub fn body_owner_def_id(&self, id: BodyId) -> DefId {
- self.local_def_id(self.body_owner(id))
+ self.local_def_id_from_hir_id(self.body_owner(id))
}
- /// Given a `NodeId`, returns the `BodyId` associated with it,
+ /// Given a `HirId`, returns the `BodyId` associated with it,
/// if the node is a body owner, otherwise returns `None`.
- pub fn maybe_body_owned_by(&self, id: NodeId) -> Option<BodyId> {
- let hir_id = self.node_to_hir_id(id);
- self.maybe_body_owned_by_by_hir_id(hir_id)
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
- pub fn maybe_body_owned_by_by_hir_id(&self, hir_id: HirId) -> Option<BodyId> {
+ pub fn maybe_body_owned_by(&self, hir_id: HirId) -> Option<BodyId> {
if let Some(entry) = self.find_entry(hir_id) {
if self.dep_graph.is_fully_enabled() {
let hir_id_owner = hir_id.owner;
@@ -473,19 +451,13 @@
/// Given a body owner's id, returns the `BodyId` associated with it.
pub fn body_owned_by(&self, id: HirId) -> BodyId {
- self.maybe_body_owned_by_by_hir_id(id).unwrap_or_else(|| {
- span_bug!(self.span_by_hir_id(id), "body_owned_by: {} has no associated body",
- self.hir_to_string(id));
+ self.maybe_body_owned_by(id).unwrap_or_else(|| {
+ span_bug!(self.span(id), "body_owned_by: {} has no associated body",
+ self.node_to_string(id));
})
}
- pub fn body_owner_kind(&self, id: NodeId) -> BodyOwnerKind {
- let hir_id = self.node_to_hir_id(id);
- self.body_owner_kind_by_hir_id(hir_id)
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
- pub fn body_owner_kind_by_hir_id(&self, id: HirId) -> BodyOwnerKind {
+ pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind {
match self.get_by_hir_id(id) {
Node::Item(&Item { node: ItemKind::Const(..), .. }) |
Node::TraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) |
@@ -514,7 +486,7 @@
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => id,
Node::GenericParam(_) => self.get_parent_node_by_hir_id(id),
- _ => bug!("ty_param_owner: {} not a type parameter", self.hir_to_string(id))
+ _ => bug!("ty_param_owner: {} not a type parameter", self.node_to_string(id))
}
}
@@ -523,7 +495,7 @@
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper,
Node::GenericParam(param) => param.name.ident().name,
- _ => bug!("ty_param_name: {} not a type parameter", self.hir_to_string(id)),
+ _ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)),
}
}
@@ -576,7 +548,7 @@
let module = &self.forest.krate.modules[&node_id];
for id in &module.items {
- visitor.visit_item(self.expect_item_by_hir_id(*id));
+ visitor.visit_item(self.expect_item(*id));
}
for id in &module.trait_items {
@@ -709,7 +681,7 @@
/// If there is some error when walking the parents (e.g., a node does not
/// have a parent in the map or a node can't be found), then we return the
- /// last good `NodeId` we found. Note that reaching the crate root (`id == 0`),
+ /// last good `HirId` we found. Note that reaching the crate root (`id == 0`),
/// is not an error, since items in the crate module have the crate root as
/// parent.
fn walk_parent_nodes<F, F2>(&self,
@@ -745,7 +717,7 @@
}
}
- /// Retrieves the `NodeId` for `id`'s enclosing method, unless there's a
+ /// Retrieves the `HirId` for `id`'s enclosing method, unless there's a
/// `while` or `loop` before reaching it, as block tail returns are not
/// available in them.
///
@@ -753,7 +725,7 @@
/// fn foo(x: usize) -> bool {
/// if x == 1 {
/// true // `get_return_block` gets passed the `id` corresponding
- /// } else { // to this, it will return `foo`'s `NodeId`.
+ /// } else { // to this, it will return `foo`'s `HirId`.
/// false
/// }
/// }
@@ -793,17 +765,10 @@
self.walk_parent_nodes(id, match_fn, match_non_returning_block).ok()
}
- /// Retrieves the `NodeId` for `id`'s parent item, or `id` itself if no
+ /// Retrieves the `HirId` for `id`'s parent item, or `id` itself if no
/// parent item is in this map. The "parent item" is the closest parent node
/// in the HIR which is recorded by the map and is an item, either an item
/// in a module, trait, or impl.
- pub fn get_parent(&self, id: NodeId) -> NodeId {
- let hir_id = self.node_to_hir_id(id);
- let parent_hir_id = self.get_parent_item(hir_id);
- self.hir_to_node_id(parent_hir_id)
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
pub fn get_parent_item(&self, hir_id: HirId) -> HirId {
match self.walk_parent_nodes(hir_id, |node| match *node {
Node::Item(_) |
@@ -819,13 +784,7 @@
/// Returns the `DefId` of `id`'s nearest module parent, or `id` itself if no
/// module parent is in this map.
- pub fn get_module_parent(&self, id: NodeId) -> DefId {
- let hir_id = self.node_to_hir_id(id);
- self.get_module_parent_by_hir_id(hir_id)
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
- pub fn get_module_parent_by_hir_id(&self, id: HirId) -> DefId {
+ pub fn get_module_parent(&self, id: HirId) -> DefId {
self.local_def_id_from_hir_id(self.get_module_parent_node(id))
}
@@ -901,23 +860,11 @@
Some(scope)
}
- pub fn get_parent_did(&self, id: NodeId) -> DefId {
- let hir_id = self.node_to_hir_id(id);
- self.get_parent_did_by_hir_id(hir_id)
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
- pub fn get_parent_did_by_hir_id(&self, id: HirId) -> DefId {
+ pub fn get_parent_did(&self, id: HirId) -> DefId {
self.local_def_id_from_hir_id(self.get_parent_item(id))
}
- pub fn get_foreign_abi(&self, id: NodeId) -> Abi {
- let hir_id = self.node_to_hir_id(id);
- self.get_foreign_abi_by_hir_id(hir_id)
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
- pub fn get_foreign_abi_by_hir_id(&self, hir_id: HirId) -> Abi {
+ pub fn get_foreign_abi(&self, hir_id: HirId) -> Abi {
let parent = self.get_parent_item(hir_id);
if let Some(entry) = self.find_entry(parent) {
if let Entry {
@@ -927,33 +874,27 @@
return nm.abi;
}
}
- bug!("expected foreign mod or inlined parent, found {}", self.hir_to_string(parent))
+ bug!("expected foreign mod or inlined parent, found {}", self.node_to_string(parent))
}
- pub fn expect_item(&self, id: NodeId) -> &'hir Item {
- let hir_id = self.node_to_hir_id(id);
- self.expect_item_by_hir_id(hir_id)
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
- pub fn expect_item_by_hir_id(&self, id: HirId) -> &'hir Item {
+ pub fn expect_item(&self, id: HirId) -> &'hir Item {
match self.find_by_hir_id(id) { // read recorded by `find`
Some(Node::Item(item)) => item,
- _ => bug!("expected item, found {}", self.hir_to_string(id))
+ _ => bug!("expected item, found {}", self.node_to_string(id))
}
}
pub fn expect_impl_item(&self, id: HirId) -> &'hir ImplItem {
match self.find_by_hir_id(id) {
Some(Node::ImplItem(item)) => item,
- _ => bug!("expected impl item, found {}", self.hir_to_string(id))
+ _ => bug!("expected impl item, found {}", self.node_to_string(id))
}
}
pub fn expect_trait_item(&self, id: HirId) -> &'hir TraitItem {
match self.find_by_hir_id(id) {
Some(Node::TraitItem(item)) => item,
- _ => bug!("expected trait item, found {}", self.hir_to_string(id))
+ _ => bug!("expected trait item, found {}", self.node_to_string(id))
}
}
@@ -963,26 +904,26 @@
match i.node {
ItemKind::Struct(ref struct_def, _) |
ItemKind::Union(ref struct_def, _) => struct_def,
- _ => bug!("struct ID bound to non-struct {}", self.hir_to_string(id))
+ _ => bug!("struct ID bound to non-struct {}", self.node_to_string(id))
}
}
Some(Node::Variant(variant)) => &variant.node.data,
Some(Node::Ctor(data)) => data,
- _ => bug!("expected struct or variant, found {}", self.hir_to_string(id))
+ _ => bug!("expected struct or variant, found {}", self.node_to_string(id))
}
}
pub fn expect_variant(&self, id: HirId) -> &'hir Variant {
match self.find_by_hir_id(id) {
Some(Node::Variant(variant)) => variant,
- _ => bug!("expected variant, found {}", self.hir_to_string(id)),
+ _ => bug!("expected variant, found {}", self.node_to_string(id)),
}
}
pub fn expect_foreign_item(&self, id: HirId) -> &'hir ForeignItem {
match self.find_by_hir_id(id) {
Some(Node::ForeignItem(item)) => item,
- _ => bug!("expected foreign item, found {}", self.hir_to_string(id))
+ _ => bug!("expected foreign item, found {}", self.node_to_string(id))
}
}
@@ -995,7 +936,7 @@
pub fn expect_expr_by_hir_id(&self, id: HirId) -> &'hir Expr {
match self.find_by_hir_id(id) { // read recorded by find
Some(Node::Expr(expr)) => expr,
- _ => bug!("expected expr, found {}", self.hir_to_string(id))
+ _ => bug!("expected expr, found {}", self.node_to_string(id))
}
}
@@ -1018,19 +959,13 @@
Node::GenericParam(param) => param.name.ident().name,
Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
Node::Ctor(..) => self.name_by_hir_id(self.get_parent_item(id)),
- _ => bug!("no name for {}", self.hir_to_string(id))
+ _ => bug!("no name for {}", self.node_to_string(id))
}
}
/// Given a node ID, gets a list of attributes associated with the AST
/// corresponding to the node-ID.
- pub fn attrs(&self, id: NodeId) -> &'hir [ast::Attribute] {
- let hir_id = self.node_to_hir_id(id);
- self.attrs_by_hir_id(hir_id)
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
- pub fn attrs_by_hir_id(&self, id: HirId) -> &'hir [ast::Attribute] {
+ pub fn attrs(&self, id: HirId) -> &'hir [ast::Attribute] {
self.read(id); // reveals attributes on the node
let attrs = match self.find_entry(id).map(|entry| entry.node) {
Some(Node::Local(l)) => Some(&l.attrs[..]),
@@ -1046,7 +981,7 @@
Some(Node::GenericParam(param)) => Some(¶m.attrs[..]),
// Unit/tuple structs/variants take the attributes straight from
// the struct/variant definition.
- Some(Node::Ctor(..)) => return self.attrs_by_hir_id(self.get_parent_item(id)),
+ Some(Node::Ctor(..)) => return self.attrs(self.get_parent_item(id)),
Some(Node::Crate) => Some(&self.forest.krate.attrs[..]),
_ => None
};
@@ -1093,13 +1028,7 @@
})
}
- pub fn span(&self, id: NodeId) -> Span {
- let hir_id = self.node_to_hir_id(id);
- self.span_by_hir_id(hir_id)
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
- pub fn span_by_hir_id(&self, hir_id: HirId) -> Span {
+ pub fn span(&self, hir_id: HirId) -> Span {
self.read(hir_id); // reveals span from node
match self.find_entry(hir_id).map(|entry| entry.node) {
Some(Node::Item(item)) => item.span,
@@ -1139,32 +1068,17 @@
}
pub fn span_if_local(&self, id: DefId) -> Option<Span> {
- self.as_local_node_id(id).map(|id| self.span(id))
+ self.as_local_hir_id(id).map(|id| self.span(id))
}
- pub fn node_to_string(&self, id: NodeId) -> String {
- hir_id_to_string(self, self.node_to_hir_id(id), true)
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
- pub fn hir_to_string(&self, id: HirId) -> String {
+ pub fn node_to_string(&self, id: HirId) -> String {
hir_id_to_string(self, id, true)
}
- pub fn node_to_user_string(&self, id: NodeId) -> String {
- hir_id_to_string(self, self.node_to_hir_id(id), false)
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
pub fn hir_to_user_string(&self, id: HirId) -> String {
hir_id_to_string(self, id, false)
}
- pub fn node_to_pretty_string(&self, id: NodeId) -> String {
- print::to_string(self, |s| s.print_node(self.get(id)))
- }
-
- // FIXME(@ljedrz): replace the `NodeId` variant.
pub fn hir_to_pretty_string(&self, id: HirId) -> String {
print::to_string(self, |s| s.print_node(self.get_by_hir_id(id)))
}
@@ -1307,7 +1221,7 @@
impl<'hir> print::PpAnn for Map<'hir> {
fn nested(&self, state: &mut print::State<'_>, nested: print::Nested) -> io::Result<()> {
match nested {
- Nested::Item(id) => state.print_item(self.expect_item_by_hir_id(id.id)),
+ Nested::Item(id) => state.print_item(self.expect_item(id.id)),
Nested::TraitItem(id) => state.print_trait_item(self.trait_item(id)),
Nested::ImplItem(id) => state.print_impl_item(self.impl_item(id)),
Nested::Body(id) => state.print_expr(&self.body(id).value),
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index 6ace4c4..0884a72 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -2177,8 +2177,8 @@
/// References to traits in impls.
///
/// `resolve` maps each `TraitRef`'s `ref_id` to its defining trait; that's all
-/// that the `ref_id` is for. Note that `ref_id`'s value is not the `NodeId` of the
-/// trait being referred to but just a unique `NodeId` that serves as a key
+/// that the `ref_id` is for. Note that `ref_id`'s value is not the `HirId` of the
+/// trait being referred to but just a unique `HirId` that serves as a key
/// within the resolution map.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
pub struct TraitRef {
diff --git a/src/librustc/hir/upvars.rs b/src/librustc/hir/upvars.rs
index 1a4fe35..54b4435 100644
--- a/src/librustc/hir/upvars.rs
+++ b/src/librustc/hir/upvars.rs
@@ -14,8 +14,8 @@
return None;
}
- let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
- let body = tcx.hir().body(tcx.hir().maybe_body_owned_by(node_id)?);
+ let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
+ let body = tcx.hir().body(tcx.hir().maybe_body_owned_by(hir_id)?);
let mut local_collector = LocalCollector::default();
local_collector.visit_body(body);
diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs
index 04d29a8..321c068 100644
--- a/src/librustc/infer/error_reporting/mod.rs
+++ b/src/librustc/infer/error_reporting/mod.rs
@@ -86,7 +86,7 @@
)
};
let span = scope.span(self, region_scope_tree);
- let tag = match self.hir().find(scope.node_id(self, region_scope_tree)) {
+ let tag = match self.hir().find_by_hir_id(scope.hir_id(region_scope_tree)) {
Some(Node::Block(_)) => "block",
Some(Node::Expr(expr)) => match expr.node {
hir::ExprKind::Call(..) => "call",
@@ -191,7 +191,7 @@
};
let (prefix, span) = match *region {
ty::ReEarlyBound(ref br) => {
- let mut sp = cm.def_span(self.hir().span_by_hir_id(node));
+ let mut sp = cm.def_span(self.hir().span(node));
if let Some(param) = self.hir()
.get_generics(scope)
.and_then(|generics| generics.get_named(br.name))
@@ -204,7 +204,7 @@
bound_region: ty::BoundRegion::BrNamed(_, name),
..
}) => {
- let mut sp = cm.def_span(self.hir().span_by_hir_id(node));
+ let mut sp = cm.def_span(self.hir().span(node));
if let Some(param) = self.hir()
.get_generics(scope)
.and_then(|generics| generics.get_named(name))
@@ -216,11 +216,11 @@
ty::ReFree(ref fr) => match fr.bound_region {
ty::BrAnon(idx) => (
format!("the anonymous lifetime #{} defined on", idx + 1),
- self.hir().span_by_hir_id(node),
+ self.hir().span(node),
),
_ => (
format!("the lifetime {} as defined on", region),
- cm.def_span(self.hir().span_by_hir_id(node)),
+ cm.def_span(self.hir().span(node)),
),
},
_ => bug!(),
@@ -1330,12 +1330,12 @@
if !param.is_self() {
let type_param = generics.type_param(param, self.tcx);
let hir = &self.tcx.hir();
- hir.as_local_node_id(type_param.def_id).map(|id| {
+ hir.as_local_hir_id(type_param.def_id).map(|id| {
// Get the `hir::Param` to verify whether it already has any bounds.
// We do this to avoid suggesting code that ends up as `T: 'a'b`,
// instead we suggest `T: 'a + 'b` in that case.
let mut has_bounds = false;
- if let Node::GenericParam(ref param) = hir.get(id) {
+ if let Node::GenericParam(ref param) = hir.get_by_hir_id(id) {
has_bounds = !param.bounds.is_empty();
}
let sp = hir.span(id);
diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs
index fa95ea1..78d1d569 100644
--- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs
+++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs
@@ -28,8 +28,8 @@
) -> Option<(&hir::Ty, &hir::FnDecl)> {
if let Some(anon_reg) = self.tcx().is_suitable_region(region) {
let def_id = anon_reg.def_id;
- if let Some(node_id) = self.tcx().hir().as_local_node_id(def_id) {
- let fndecl = match self.tcx().hir().get(node_id) {
+ if let Some(hir_id) = self.tcx().hir().as_local_hir_id(def_id) {
+ let fndecl = match self.tcx().hir().get_by_hir_id(hir_id) {
Node::Item(&hir::Item {
node: hir::ItemKind::Fn(ref fndecl, ..),
..
diff --git a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs
index 0d98a02..6ed2b67 100644
--- a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs
+++ b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs
@@ -48,11 +48,11 @@
if let (&SubregionOrigin::BindingTypeIsNotValidAtDecl(ref external_span),
&RegionKind::ReFree(ref free_region)) = (&sub_origin, sup_region) {
let hir = &self.tcx().hir();
- if let Some(node_id) = hir.as_local_node_id(free_region.scope) {
+ if let Some(hir_id) = hir.as_local_hir_id(free_region.scope) {
if let Node::Expr(Expr {
node: Closure(_, _, _, closure_span, None),
..
- }) = hir.get(node_id) {
+ }) = hir.get_by_hir_id(hir_id) {
let sup_sp = sup_origin.span();
let origin_sp = origin.span();
let mut err = self.tcx().sess.struct_span_err(
diff --git a/src/librustc/infer/error_reporting/nice_region_error/util.rs b/src/librustc/infer/error_reporting/nice_region_error/util.rs
index 017f36b..f33f917 100644
--- a/src/librustc/infer/error_reporting/nice_region_error/util.rs
+++ b/src/librustc/infer/error_reporting/nice_region_error/util.rs
@@ -51,11 +51,11 @@
};
let hir = &self.tcx().hir();
- if let Some(node_id) = hir.as_local_node_id(id) {
- if let Some(body_id) = hir.maybe_body_owned_by(node_id) {
+ if let Some(hir_id) = hir.as_local_hir_id(id) {
+ if let Some(body_id) = hir.maybe_body_owned_by(hir_id) {
let body = hir.body(body_id);
let owner_id = hir.body_owner(body_id);
- let fn_decl = hir.fn_decl(owner_id).unwrap();
+ let fn_decl = hir.fn_decl_by_hir_id(owner_id).unwrap();
if let Some(tables) = self.tables {
body.arguments
.iter()
@@ -63,7 +63,7 @@
.filter_map(|(index, arg)| {
// May return None; sometimes the tables are not yet populated.
let ty_hir_id = fn_decl.inputs[index].hir_id;
- let arg_ty_span = hir.span(hir.hir_to_node_id(ty_hir_id));
+ let arg_ty_span = hir.span(ty_hir_id);
let ty = tables.node_type_opt(arg.hir_id)?;
let mut found_anon_region = false;
let new_arg_ty = self.tcx().fold_regions(&ty, &mut false, |r, _| {
diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs
index 1c52b57..328ace5 100644
--- a/src/librustc/infer/opaque_types/mod.rs
+++ b/src/librustc/infer/opaque_types/mod.rs
@@ -819,7 +819,7 @@
},
_ => bug!(
"expected (impl) item, found {}",
- tcx.hir().hir_to_string(opaque_hir_id),
+ tcx.hir().node_to_string(opaque_hir_id),
),
};
if in_definition_scope {
diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs
index 468d909..e90f4ca 100644
--- a/src/librustc/lint/context.rs
+++ b/src/librustc/lint/context.rs
@@ -1399,7 +1399,7 @@
// Visit the crate attributes
if hir_id == hir::CRATE_HIR_ID {
- walk_list!(cx, visit_attribute, tcx.hir().attrs_by_hir_id(hir::CRATE_HIR_ID));
+ walk_list!(cx, visit_attribute, tcx.hir().attrs(hir::CRATE_HIR_ID));
}
}
diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs
index 70c0e83..041944d 100644
--- a/src/librustc/lint/mod.rs
+++ b/src/librustc/lint/mod.rs
@@ -762,7 +762,7 @@
}
pub fn maybe_lint_level_root(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
- let attrs = tcx.hir().attrs_by_hir_id(id);
+ let attrs = tcx.hir().attrs(id);
attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some())
}
diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs
index 0356e7e..63503f5 100644
--- a/src/librustc/middle/dead.rs
+++ b/src/librustc/middle/dead.rs
@@ -292,7 +292,7 @@
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
match ty.node {
TyKind::Def(item_id, _) => {
- let item = self.tcx.hir().expect_item_by_hir_id(item_id.id);
+ let item = self.tcx.hir().expect_item(item_id.id);
intravisit::walk_item(self, item);
}
_ => ()
diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs
index 29c6245..3d2bc6c 100644
--- a/src/librustc/middle/liveness.rs
+++ b/src/librustc/middle/liveness.rs
@@ -1171,7 +1171,7 @@
}
hir::ExprKind::Call(ref f, ref args) => {
- let m = self.ir.tcx.hir().get_module_parent_by_hir_id(expr.hir_id);
+ let m = self.ir.tcx.hir().get_module_parent(expr.hir_id);
let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
self.s.exit_ln
} else {
@@ -1182,7 +1182,7 @@
}
hir::ExprKind::MethodCall(.., ref args) => {
- let m = self.ir.tcx.hir().get_module_parent_by_hir_id(expr.hir_id);
+ let m = self.ir.tcx.hir().get_module_parent(expr.hir_id);
let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
self.s.exit_ln
} else {
diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs
index 3b21b81..192e723 100644
--- a/src/librustc/middle/mem_categorization.rs
+++ b/src/librustc/middle/mem_categorization.rs
@@ -342,9 +342,9 @@
fn from_local(
tcx: TyCtxt<'_>,
tables: &ty::TypeckTables<'_>,
- id: ast::NodeId,
+ id: hir::HirId,
) -> MutabilityCategory {
- let ret = match tcx.hir().get(id) {
+ let ret = match tcx.hir().get_by_hir_id(id) {
Node::Binding(p) => match p.node {
PatKind::Binding(..) => {
let bm = *tables.pat_binding_modes()
@@ -500,7 +500,6 @@
// FIXME
None if self.is_tainted_by_errors() => Err(()),
None => {
- let id = self.tcx.hir().hir_to_node_id(id);
bug!("no type for node {}: {} in mem_categorization",
id, self.tcx.hir().node_to_string(id));
}
@@ -753,15 +752,14 @@
}
Res::Local(var_id) => {
- let var_nid = self.tcx.hir().hir_to_node_id(var_id);
if self.upvars.map_or(false, |upvars| upvars.contains_key(&var_id)) {
- self.cat_upvar(hir_id, span, var_nid)
+ self.cat_upvar(hir_id, span, var_id)
} else {
Ok(cmt_ {
hir_id,
span,
cat: Categorization::Local(var_id),
- mutbl: MutabilityCategory::from_local(self.tcx, self.tables, var_nid),
+ mutbl: MutabilityCategory::from_local(self.tcx, self.tables, var_id),
ty: expr_ty,
note: NoteNone
})
@@ -778,7 +776,7 @@
&self,
hir_id: hir::HirId,
span: Span,
- var_id: ast::NodeId,
+ var_id: hir::HirId,
) -> McResult<cmt_<'tcx>> {
// An upvar can have up to 3 components. We translate first to a
// `Categorization::Upvar`, which is itself a fiction -- it represents the reference to the
@@ -828,13 +826,12 @@
_ => span_bug!(span, "unexpected type for fn in mem_categorization: {:?}", ty),
};
- let var_hir_id = self.tcx.hir().node_to_hir_id(var_id);
let upvar_id = ty::UpvarId {
- var_path: ty::UpvarPath { hir_id: var_hir_id },
+ var_path: ty::UpvarPath { hir_id: var_id },
closure_expr_id: closure_expr_def_id.to_local(),
};
- let var_ty = self.node_ty(var_hir_id)?;
+ let var_ty = self.node_ty(var_id)?;
// Mutability of original variable itself
let var_mutbl = MutabilityCategory::from_local(self.tcx, self.tables, var_id);
diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs
index 363ccd7..628a44c 100644
--- a/src/librustc/middle/reachable.rs
+++ b/src/librustc/middle/reachable.rs
@@ -174,12 +174,12 @@
} else {
let impl_did = self.tcx
.hir()
- .get_parent_did_by_hir_id(hir_id);
+ .get_parent_did(hir_id);
// Check the impl. If the generics on the self
// type of the impl require inlining, this method
// does too.
let impl_hir_id = self.tcx.hir().as_local_hir_id(impl_did).unwrap();
- match self.tcx.hir().expect_item_by_hir_id(impl_hir_id).node {
+ match self.tcx.hir().expect_item(impl_hir_id).node {
hir::ItemKind::Impl(..) => {
let generics = self.tcx.generics_of(impl_did);
generics.requires_monomorphization(self.tcx)
@@ -296,7 +296,7 @@
self.visit_nested_body(body);
}
hir::ImplItemKind::Method(_, body) => {
- let did = self.tcx.hir().get_parent_did_by_hir_id(search_item);
+ let did = self.tcx.hir().get_parent_did(search_item);
if method_might_be_inlined(self.tcx, impl_item, did) {
self.visit_nested_body(body)
}
@@ -318,7 +318,7 @@
_ => {
bug!(
"found unexpected node kind in worklist: {} ({:?})",
- self.tcx.hir().hir_to_string(search_item),
+ self.tcx.hir().node_to_string(search_item),
node,
);
}
diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs
index 8b1eeeb..dfab8e3 100644
--- a/src/librustc/middle/region.rs
+++ b/src/librustc/middle/region.rs
@@ -14,7 +14,6 @@
use std::fmt;
use rustc_macros::HashStable;
use syntax::source_map;
-use syntax::ast;
use syntax_pos::{Span, DUMMY_SP};
use crate::ty::{DefIdTree, TyCtxt};
use crate::ty::query::Providers;
@@ -169,15 +168,15 @@
self.id
}
- pub fn node_id(&self, tcx: TyCtxt<'_>, scope_tree: &ScopeTree) -> ast::NodeId {
+ pub fn hir_id(&self, scope_tree: &ScopeTree) -> hir::HirId {
match scope_tree.root_body {
Some(hir_id) => {
- tcx.hir().hir_to_node_id(hir::HirId {
+ hir::HirId {
owner: hir_id.owner,
local_id: self.item_local_id()
- })
+ }
}
- None => ast::DUMMY_NODE_ID
+ None => hir::DUMMY_HIR_ID
}
}
@@ -185,13 +184,13 @@
/// returned span may not correspond to the span of any `NodeId` in
/// the AST.
pub fn span(&self, tcx: TyCtxt<'_>, scope_tree: &ScopeTree) -> Span {
- let node_id = self.node_id(tcx, scope_tree);
- if node_id == ast::DUMMY_NODE_ID {
+ let hir_id = self.hir_id(scope_tree);
+ if hir_id == hir::DUMMY_HIR_ID {
return DUMMY_SP;
}
- let span = tcx.hir().span(node_id);
+ let span = tcx.hir().span(hir_id);
if let ScopeData::Remainder(first_statement_index) = self.data {
- if let Node::Block(ref blk) = tcx.hir().get(node_id) {
+ if let Node::Block(ref blk) = tcx.hir().get_by_hir_id(hir_id) {
// Want span for scope starting after the
// indexed statement and ending at end of
// `blk`; reuse span of `blk` and shift `lo`
@@ -650,7 +649,7 @@
let param_owner = tcx.parent(br.def_id).unwrap();
let param_owner_id = tcx.hir().as_local_hir_id(param_owner).unwrap();
- let scope = tcx.hir().maybe_body_owned_by_by_hir_id(param_owner_id).map(|body_id| {
+ let scope = tcx.hir().maybe_body_owned_by(param_owner_id).map(|body_id| {
tcx.hir().body(body_id).value.hir_id.local_id
}).unwrap_or_else(|| {
// The lifetime was defined on node that doesn't own a body,
@@ -1337,7 +1336,7 @@
}
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
- let scope_tree = if let Some(body_id) = tcx.hir().maybe_body_owned_by_by_hir_id(id) {
+ let scope_tree = if let Some(body_id) = tcx.hir().maybe_body_owned_by(id) {
let mut visitor = RegionResolutionVisitor {
tcx,
scope_tree: ScopeTree::default(),
diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs
index 48d2a47..76bff50 100644
--- a/src/librustc/middle/resolve_lifetime.rs
+++ b/src/librustc/middle/resolve_lifetime.rs
@@ -625,7 +625,7 @@
// `abstract type MyAnonTy<'b>: MyTrait<'b>;`
// ^ ^ this gets resolved in the scope of
// the exist_ty generics
- let (generics, bounds) = match self.tcx.hir().expect_item_by_hir_id(item_id.id).node
+ let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).node
{
// named existential types are reached via TyKind::Path
// this arm is for `impl Trait` in the types of statics, constants and locals
@@ -1236,7 +1236,7 @@
signal_shadowing_problem(
tcx,
label.name,
- original_lifetime(tcx.hir().span_by_hir_id(hir_id)),
+ original_lifetime(tcx.hir().span(hir_id)),
shadower_label(label.span),
);
return;
@@ -1590,7 +1590,7 @@
if let Some(parent_hir_id) = self.tcx.hir()
.as_local_hir_id(parent_def_id) {
// lifetimes in `derive` expansions don't count (Issue #53738)
- if self.tcx.hir().attrs_by_hir_id(parent_hir_id).iter()
+ if self.tcx.hir().attrs(parent_hir_id).iter()
.any(|attr| attr.check_name(sym::automatically_derived)) {
continue;
}
@@ -1690,7 +1690,7 @@
// Find the start of nested early scopes, e.g., in methods.
let mut index = 0;
if let Some(parent_id) = parent_id {
- let parent = self.tcx.hir().expect_item_by_hir_id(parent_id);
+ let parent = self.tcx.hir().expect_item(parent_id);
if sub_items_have_self_param(&parent.node) {
index += 1; // Self comes before lifetimes
}
@@ -1823,7 +1823,7 @@
// Do not free early-bound regions, only late-bound ones.
} else if let Some(body_id) = outermost_body {
let fn_id = self.tcx.hir().body_owner(body_id);
- match self.tcx.hir().get(fn_id) {
+ match self.tcx.hir().get_by_hir_id(fn_id) {
Node::Item(&hir::Item {
node: hir::ItemKind::Fn(..),
..
@@ -1836,7 +1836,7 @@
node: hir::ImplItemKind::Method(..),
..
}) => {
- let scope = self.tcx.hir().local_def_id(fn_id);
+ let scope = self.tcx.hir().local_def_id_from_hir_id(fn_id);
def = Region::Free(scope, def.id().unwrap());
}
_ => {}
@@ -2065,7 +2065,7 @@
}) => {
if let hir::ItemKind::Trait(.., ref trait_items) = self.tcx
.hir()
- .expect_item_by_hir_id(self.tcx.hir().get_parent_item(parent))
+ .expect_item(self.tcx.hir().get_parent_item(parent))
.node
{
assoc_item_kind = trait_items
@@ -2085,7 +2085,7 @@
}) => {
if let hir::ItemKind::Impl(.., ref self_ty, ref impl_items) = self.tcx
.hir()
- .expect_item_by_hir_id(self.tcx.hir().get_parent_item(parent))
+ .expect_item(self.tcx.hir().get_parent_item(parent))
.node
{
impl_self = Some(self_ty);
@@ -2629,7 +2629,7 @@
signal_shadowing_problem(
self.tcx,
param.name.ident().name,
- original_lifetime(self.tcx.hir().span_by_hir_id(hir_id)),
+ original_lifetime(self.tcx.hir().span(hir_id)),
shadower_lifetime(¶m),
);
return;
@@ -2696,7 +2696,7 @@
debug!(
"insert_lifetime: {} resolved to {:?} span={:?}",
- self.tcx.hir().hir_to_string(lifetime_ref.hir_id),
+ self.tcx.hir().node_to_string(lifetime_ref.hir_id),
def,
self.tcx.sess.source_map().span_to_string(lifetime_ref.span)
);
diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs
index 3d96acb..1d5c1cb 100644
--- a/src/librustc/mir/mod.rs
+++ b/src/librustc/mir/mod.rs
@@ -2565,7 +2565,7 @@
let name = if tcx.sess.opts.debugging_opts.span_free_formats {
format!("[closure@{:?}]", hir_id)
} else {
- format!("[closure@{:?}]", tcx.hir().span_by_hir_id(hir_id))
+ format!("[closure@{:?}]", tcx.hir().span(hir_id))
};
let mut struct_fmt = fmt.debug_struct(&name);
@@ -2585,7 +2585,7 @@
AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| {
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
let name = format!("[generator@{:?}]",
- tcx.hir().span_by_hir_id(hir_id));
+ tcx.hir().span(hir_id));
let mut struct_fmt = fmt.debug_struct(&name);
if let Some(upvars) = tcx.upvars(def_id) {
diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs
index 39ae48b..432a61d 100644
--- a/src/librustc/mir/mono.rs
+++ b/src/librustc/mir/mono.rs
@@ -218,7 +218,7 @@
MonoItem::GlobalAsm(hir_id) => {
Some(hir_id)
}
- }.map(|hir_id| tcx.hir().span_by_hir_id(hir_id))
+ }.map(|hir_id| tcx.hir().span(hir_id))
}
}
diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs
index 42bde35..dcf69fe 100644
--- a/src/librustc/traits/error_reporting.rs
+++ b/src/librustc/traits/error_reporting.rs
@@ -1013,10 +1013,8 @@
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
) {
let hir = self.tcx.hir();
- let parent_node = hir.get_parent_node(
- hir.hir_to_node_id(obligation.cause.body_id),
- );
- let node = hir.find(parent_node);
+ let parent_node = hir.get_parent_node_by_hir_id(obligation.cause.body_id);
+ let node = hir.find_by_hir_id(parent_node);
if let Some(hir::Node::Item(hir::Item {
node: hir::ItemKind::Fn(decl, _, _, body_id),
..
@@ -1098,7 +1096,7 @@
}
Node::Ctor(ref variant_data) => {
let span = variant_data.ctor_hir_id()
- .map(|hir_id| self.tcx.hir().span_by_hir_id(hir_id))
+ .map(|hir_id| self.tcx.hir().span(hir_id))
.unwrap_or(DUMMY_SP);
let span = self.tcx.sess.source_map().def_span(span);
diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs
index b6a1ab9..2d29567 100644
--- a/src/librustc/traits/util.rs
+++ b/src/librustc/traits/util.rs
@@ -654,7 +654,7 @@
pub fn impl_is_default(self, node_item_def_id: DefId) -> bool {
match self.hir().as_local_hir_id(node_item_def_id) {
Some(hir_id) => {
- let item = self.hir().expect_item_by_hir_id(hir_id);
+ let item = self.hir().expect_item(hir_id);
if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.node {
defaultness.is_default()
} else {
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index e5d0653..b84ebd8 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -250,11 +250,9 @@
if let Some(local_id_root) = local_id_root {
if hir_id.owner != local_id_root.index {
ty::tls::with(|tcx| {
- let node_id = tcx.hir().hir_to_node_id(hir_id);
-
bug!("node {} with HirId::owner {:?} cannot be placed in \
TypeckTables with local_id_root {:?}",
- tcx.hir().node_to_string(node_id),
+ tcx.hir().node_to_string(hir_id),
DefId::local(hir_id.owner),
local_id_root)
});
@@ -556,7 +554,7 @@
pub fn node_type(&self, id: hir::HirId) -> Ty<'tcx> {
self.node_type_opt(id).unwrap_or_else(||
bug!("node_type: no type for node `{}`",
- tls::with(|tcx| tcx.hir().hir_to_string(id)))
+ tls::with(|tcx| tcx.hir().node_to_string(id)))
)
}
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index c932586..3614103 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -277,7 +277,7 @@
def => Visibility::Restricted(def.def_id()),
},
hir::VisibilityKind::Inherited => {
- Visibility::Restricted(tcx.hir().get_module_parent_by_hir_id(id))
+ Visibility::Restricted(tcx.hir().get_module_parent(id))
}
}
}
@@ -3016,7 +3016,7 @@
/// Gets the attributes of a definition.
pub fn get_attrs(self, did: DefId) -> Attributes<'tcx> {
if let Some(id) = self.hir().as_local_hir_id(did) {
- Attributes::Borrowed(self.hir().attrs_by_hir_id(id))
+ Attributes::Borrowed(self.hir().attrs(id))
} else {
Attributes::Owned(self.item_attrs(did))
}
@@ -3068,7 +3068,7 @@
pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, Symbol> {
if impl_did.is_local() {
let hir_id = self.hir().as_local_hir_id(impl_did).unwrap();
- Ok(self.hir().span_by_hir_id(hir_id))
+ Ok(self.hir().span(hir_id))
} else {
Err(self.crate_name(impl_did.krate))
}
@@ -3103,7 +3103,7 @@
let scope = match ident.span.modernize_and_adjust(self.expansion_that_defined(scope)) {
Some(actual_expansion) =>
self.hir().definitions().parent_module_of_macro_def(actual_expansion),
- None => self.hir().get_module_parent_by_hir_id(block),
+ None => self.hir().get_module_parent(block),
};
(ident, scope)
}
@@ -3129,7 +3129,7 @@
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
let parent_id = tcx.hir().get_parent_item(id);
let parent_def_id = tcx.hir().local_def_id_from_hir_id(parent_id);
- let parent_item = tcx.hir().expect_item_by_hir_id(parent_id);
+ let parent_item = tcx.hir().expect_item(parent_id);
match parent_item.node {
hir::ItemKind::Impl(.., ref impl_item_refs) => {
if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.hir_id == id) {
@@ -3186,7 +3186,7 @@
fn associated_item_def_ids<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx [DefId] {
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
- let item = tcx.hir().expect_item_by_hir_id(id);
+ let item = tcx.hir().expect_item(id);
match item.node {
hir::ItemKind::Trait(.., ref trait_item_refs) => {
tcx.arena.alloc_from_iter(
@@ -3266,7 +3266,7 @@
);
let body_id = tcx.hir().as_local_hir_id(def_id).map_or(hir::DUMMY_HIR_ID, |id| {
- tcx.hir().maybe_body_owned_by_by_hir_id(id).map_or(id, |body| body.hir_id)
+ tcx.hir().maybe_body_owned_by(id).map_or(id, |body| body.hir_id)
});
let cause = traits::ObligationCause::misc(tcx.def_span(def_id), body_id);
traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause)
diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs
index b79d7f0..d143cc3 100644
--- a/src/librustc/ty/print/pretty.rs
+++ b/src/librustc/ty/print/pretty.rs
@@ -589,7 +589,7 @@
// FIXME(eddyb) should use `def_span`.
if let Some(hir_id) = self.tcx().hir().as_local_hir_id(did) {
- p!(write("@{:?}", self.tcx().hir().span_by_hir_id(hir_id)));
+ p!(write("@{:?}", self.tcx().hir().span(hir_id)));
let mut sep = " ";
for (&var_id, upvar_ty) in self.tcx().upvars(did)
.as_ref()
@@ -631,7 +631,7 @@
if self.tcx().sess.opts.debugging_opts.span_free_formats {
p!(write("@{:?}", hir_id));
} else {
- p!(write("@{:?}", self.tcx().hir().span_by_hir_id(hir_id)));
+ p!(write("@{:?}", self.tcx().hir().span(hir_id)));
}
let mut sep = " ";
for (&var_id, upvar_ty) in self.tcx().upvars(did)
diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs
index 9a00c43..58be2cf 100644
--- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs
+++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs
@@ -88,7 +88,7 @@
}
}
if let NoteClosureEnv(upvar_id) = error.move_from.note {
- err.span_label(bccx.tcx.hir().span_by_hir_id(upvar_id.var_path.hir_id),
+ err.span_label(bccx.tcx.hir().span(upvar_id.var_path.hir_id),
"captured outer variable");
}
err.emit();
diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs
index 9b0dce5..93cea6d 100644
--- a/src/librustc_borrowck/borrowck/mod.rs
+++ b/src/librustc_borrowck/borrowck/mod.rs
@@ -198,7 +198,7 @@
cfg: &cfg::CFG,
) -> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'tcx>) {
let owner_id = tcx.hir().body_owner(body_id);
- let owner_def_id = tcx.hir().local_def_id(owner_id);
+ let owner_def_id = tcx.hir().local_def_id_from_hir_id(owner_id);
let tables = tcx.typeck_tables_of(owner_def_id);
let region_scope_tree = tcx.region_scope_tree(owner_def_id);
let body = tcx.hir().body(body_id);
@@ -389,8 +389,8 @@
}
fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt<'_>) -> HirId {
- let closure_id = tcx.hir().local_def_id_to_node_id(closure_id);
- match tcx.hir().get(closure_id) {
+ let closure_id = tcx.hir().local_def_id_to_hir_id(closure_id);
+ match tcx.hir().get_by_hir_id(closure_id) {
Node::Expr(expr) => match expr.node {
hir::ExprKind::Closure(.., body_id, _, _) => {
body_id.hir_id
@@ -699,7 +699,7 @@
}
move_data::MoveExpr |
- move_data::MovePat => (self.tcx.hir().span_by_hir_id(hir_id), ""),
+ move_data::MovePat => (self.tcx.hir().span(hir_id), ""),
move_data::Captured =>
(match self.tcx.hir().expect_expr_by_hir_id(hir_id).node {
@@ -828,7 +828,7 @@
let mut db = self.cannot_assign(error_span, &descr, Origin::Ast);
if let mc::NoteClosureEnv(upvar_id) = err.cmt.note {
let hir_id = upvar_id.var_path.hir_id;
- let sp = self.tcx.hir().span_by_hir_id(hir_id);
+ let sp = self.tcx.hir().span(hir_id);
let fn_closure_msg = "`Fn` closures cannot capture their enclosing \
environment for modifications";
match (self.tcx.sess.source_map().span_to_snippet(sp), &err.cmt.cat) {
@@ -896,8 +896,7 @@
// to implement two traits for "one operator" is not very intuitive for
// many programmers.
if err.cmt.note == mc::NoteIndex {
- let node_id = self.tcx.hir().hir_to_node_id(err.cmt.hir_id);
- let node = self.tcx.hir().get(node_id);
+ let node = self.tcx.hir().get_by_hir_id(err.cmt.hir_id);
// This pattern probably always matches.
if let Node::Expr(
@@ -1022,8 +1021,8 @@
}
if let ty::ReScope(scope) = *super_scope {
- let node_id = scope.node_id(self.tcx, &self.region_scope_tree);
- match self.tcx.hir().find(node_id) {
+ let hir_id = scope.hir_id(&self.region_scope_tree);
+ match self.tcx.hir().find_by_hir_id(hir_id) {
Some(Node::Stmt(_)) => {
if *sub_scope != ty::ReStatic {
db.note("consider using a `let` binding to increase its lifetime");
@@ -1118,7 +1117,7 @@
"consider changing this closure to take self by mutable reference"
};
let hir_id = self.tcx.hir().local_def_id_to_hir_id(id);
- let help_span = self.tcx.hir().span_by_hir_id(hir_id);
+ let help_span = self.tcx.hir().span(hir_id);
self.cannot_act_on_capture_in_sharable_fn(span,
prefix,
(help_span, help_msg),
@@ -1224,7 +1223,7 @@
Some(ImmutabilityBlame::LocalDeref(hir_id)) => {
match self.local_binding_mode(hir_id) {
ty::BindByReference(..) => {
- let let_span = self.tcx.hir().span_by_hir_id(hir_id);
+ let let_span = self.tcx.hir().span(hir_id);
let suggestion = suggest_ref_mut(self.tcx, let_span);
if let Some(replace_str) = suggestion {
db.span_suggestion(
@@ -1272,7 +1271,7 @@
db: &mut DiagnosticBuilder<'_>,
borrowed_hir_id: hir::HirId,
binding_hir_id: hir::HirId) {
- let let_span = self.tcx.hir().span_by_hir_id(binding_hir_id);
+ let let_span = self.tcx.hir().span(binding_hir_id);
if let ty::BindByValue(..) = self.local_binding_mode(binding_hir_id) {
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(let_span) {
let (ty, is_implicit_self) = self.local_ty(binding_hir_id);
@@ -1290,7 +1289,7 @@
{
let borrow_expr_id = self.tcx.hir().get_parent_node_by_hir_id(borrowed_hir_id);
db.span_suggestion(
- self.tcx.hir().span_by_hir_id(borrow_expr_id),
+ self.tcx.hir().span(borrow_expr_id),
"consider removing the `&mut`, as it is an \
immutable binding to a mutable reference",
snippet,
@@ -1361,7 +1360,7 @@
if *kind == ty::ClosureKind::Fn {
let closure_hir_id =
self.tcx.hir().local_def_id_to_hir_id(upvar_id.closure_expr_id);
- db.span_help(self.tcx.hir().span_by_hir_id(closure_hir_id),
+ db.span_help(self.tcx.hir().span(closure_hir_id),
"consider changing this closure to take \
self by mutable reference");
}
@@ -1370,7 +1369,7 @@
if let Categorization::Deref(..) = err.cmt.cat {
db.span_label(*error_span, "cannot borrow as mutable");
} else if let Categorization::Local(local_id) = err.cmt.cat {
- let span = self.tcx.hir().span_by_hir_id(local_id);
+ let span = self.tcx.hir().span(local_id);
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
if snippet.starts_with("ref mut ") || snippet.starts_with("&mut ") {
db.span_label(*error_span, "cannot reborrow mutably");
@@ -1509,13 +1508,12 @@
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.kind {
LpVar(id) => {
- write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().hir_to_string(id)))
+ write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_string(id)))
}
LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath {hir_id: var_id}, closure_expr_id }) => {
let s = ty::tls::with(|tcx| {
- let var_node_id = tcx.hir().hir_to_node_id(var_id);
- tcx.hir().node_to_string(var_node_id)
+ tcx.hir().node_to_string(var_id)
});
write!(f, "$({} captured by id={:?})", s, closure_expr_id)
}
@@ -1549,8 +1547,7 @@
LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath { hir_id }, closure_expr_id: _ }) => {
let s = ty::tls::with(|tcx| {
- let var_node_id = tcx.hir().hir_to_node_id(hir_id);
- tcx.hir().node_to_string(var_node_id)
+ tcx.hir().node_to_string(hir_id)
});
write!(f, "$({} captured by closure)", s)
}
diff --git a/src/librustc_codegen_ssa/mono_item.rs b/src/librustc_codegen_ssa/mono_item.rs
index 11e9a48..dc50c0e 100644
--- a/src/librustc_codegen_ssa/mono_item.rs
+++ b/src/librustc_codegen_ssa/mono_item.rs
@@ -29,7 +29,7 @@
cx.codegen_static(def_id, cx.tcx().is_mutable_static(def_id));
}
MonoItem::GlobalAsm(hir_id) => {
- let item = cx.tcx().hir().expect_item_by_hir_id(hir_id);
+ let item = cx.tcx().hir().expect_item(hir_id);
if let hir::ItemKind::GlobalAsm(ref ga) = item.node {
cx.codegen_global_asm(ga);
} else {
diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs
index e70c510..683da58 100644
--- a/src/librustc_driver/pretty.rs
+++ b/src/librustc_driver/pretty.rs
@@ -922,7 +922,8 @@
got {:?}",
node);
- tcx.sess.span_fatal(tcx.hir().span(nodeid), &message)
+ let hir_id = tcx.hir().node_to_hir_id(nodeid);
+ tcx.sess.span_fatal(tcx.hir().span(hir_id), &message)
}
}
}
diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs
index 903a2d6..b221b8e 100644
--- a/src/librustc_lint/nonstandard_style.rs
+++ b/src/librustc_lint/nonstandard_style.rs
@@ -254,7 +254,7 @@
let crate_ident = if let Some(name) = &cx.tcx.sess.opts.crate_name {
Some(Ident::from_str(name))
} else {
- attr::find_by_name(&cx.tcx.hir().attrs_by_hir_id(hir::CRATE_HIR_ID), sym::crate_name)
+ attr::find_by_name(&cx.tcx.hir().attrs(hir::CRATE_HIR_ID), sym::crate_name)
.and_then(|attr| attr.meta())
.and_then(|meta| {
meta.name_value_literal().and_then(|lit| {
diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs
index a843ee6..9fc23e4 100644
--- a/src/librustc_lint/types.rs
+++ b/src/librustc_lint/types.rs
@@ -921,7 +921,7 @@
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes {
fn check_foreign_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::ForeignItem) {
let mut vis = ImproperCTypesVisitor { cx };
- let abi = cx.tcx.hir().get_foreign_abi_by_hir_id(it.hir_id);
+ let abi = cx.tcx.hir().get_foreign_abi(it.hir_id);
if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic {
match it.node {
hir::ForeignItemKind::Fn(ref decl, _, _) => {
diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs
index d540b3f..f84ce2f 100644
--- a/src/librustc_lint/unused.rs
+++ b/src/librustc_lint/unused.rs
@@ -136,7 +136,7 @@
descr_post_path: &str,
) -> bool {
if ty.is_unit() || cx.tcx.is_ty_uninhabited_from(
- cx.tcx.hir().get_module_parent_by_hir_id(expr.hir_id), ty)
+ cx.tcx.hir().get_module_parent(expr.hir_id), ty)
{
return true;
}
diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs
index dbf140a..b52b6df 100644
--- a/src/librustc_metadata/encoder.rs
+++ b/src/librustc_metadata/encoder.rs
@@ -579,7 +579,7 @@
};
let enum_id = tcx.hir().as_local_hir_id(enum_did).unwrap();
- let enum_vis = &tcx.hir().expect_item_by_hir_id(enum_id).vis;
+ let enum_vis = &tcx.hir().expect_item(enum_id).vis;
Entry {
kind: EntryKind::Variant(self.lazy(&data)),
@@ -632,7 +632,7 @@
// Variant constructors have the same visibility as the parent enums, unless marked as
// non-exhaustive, in which case they are lowered to `pub(crate)`.
let enum_id = tcx.hir().as_local_hir_id(enum_did).unwrap();
- let enum_vis = &tcx.hir().expect_item_by_hir_id(enum_id).vis;
+ let enum_vis = &tcx.hir().expect_item(enum_id).vis;
let mut ctor_vis = ty::Visibility::from_hir(enum_vis, enum_id, tcx);
if variant.is_field_list_non_exhaustive() && ctor_vis == ty::Visibility::Public {
ctor_vis = ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX));
@@ -751,7 +751,7 @@
};
let struct_id = tcx.hir().as_local_hir_id(adt_def_id).unwrap();
- let struct_vis = &tcx.hir().expect_item_by_hir_id(struct_id).vis;
+ let struct_vis = &tcx.hir().expect_item(struct_id).vis;
let mut ctor_vis = ty::Visibility::from_hir(struct_vis, struct_id, tcx);
for field in &variant.fields {
if ctor_vis.is_at_least(field.vis, tcx) {
diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs
index 9c2ab91..c4a11ef 100644
--- a/src/librustc_mir/borrow_check/mod.rs
+++ b/src/librustc_mir/borrow_check/mod.rs
@@ -177,7 +177,7 @@
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]),
));
- let locals_are_invalidated_at_exit = tcx.hir().body_owner_kind_by_hir_id(id).is_fn_or_closure();
+ let locals_are_invalidated_at_exit = tcx.hir().body_owner_kind(id).is_fn_or_closure();
let borrow_set = Rc::new(BorrowSet::build(
tcx, body, locals_are_invalidated_at_exit, &mdpe.move_data));
diff --git a/src/librustc_mir/borrow_check/move_errors.rs b/src/librustc_mir/borrow_check/move_errors.rs
index 402654c..d152293 100644
--- a/src/librustc_mir/borrow_check/move_errors.rs
+++ b/src/librustc_mir/borrow_check/move_errors.rs
@@ -422,7 +422,7 @@
let upvar = &self.upvars[upvar_field.unwrap().index()];
let upvar_hir_id = upvar.var_hir_id;
let upvar_name = upvar.name;
- let upvar_span = self.infcx.tcx.hir().span_by_hir_id(upvar_hir_id);
+ let upvar_span = self.infcx.tcx.hir().span(upvar_hir_id);
let place_name = self.describe_place(move_place).unwrap();
diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs
index d3c23cf..fc11cd8 100644
--- a/src/librustc_mir/borrow_check/mutability_errors.rs
+++ b/src/librustc_mir/borrow_check/mutability_errors.rs
@@ -304,8 +304,8 @@
err.span_label(span, format!("cannot {ACT}", ACT = act));
let upvar_hir_id = self.upvars[upvar_index.index()].var_hir_id;
- let upvar_node_id = self.infcx.tcx.hir().hir_to_node_id(upvar_hir_id);
- if let Some(Node::Binding(pat)) = self.infcx.tcx.hir().find(upvar_node_id) {
+ if let Some(Node::Binding(pat)) = self.infcx.tcx.hir().find_by_hir_id(upvar_hir_id)
+ {
if let hir::PatKind::Binding(
hir::BindingAnnotation::Unannotated,
_,
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
index 1ec3089..46b6901 100644
--- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
+++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
@@ -230,14 +230,14 @@
},
ty::BoundRegion::BrEnv => {
- let mir_node_id = tcx.hir()
- .as_local_node_id(mir_def_id)
- .expect("non-local mir");
+ let mir_hir_id = tcx.hir()
+ .as_local_hir_id(mir_def_id)
+ .expect("non-local mir");
let def_ty = self.universal_regions.defining_ty;
if let DefiningTy::Closure(def_id, substs) = def_ty {
let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) =
- tcx.hir().expect_expr(mir_node_id).node
+ tcx.hir().expect_expr_by_hir_id(mir_hir_id).node
{
span
} else {
@@ -310,7 +310,7 @@
let scope = error_region.free_region_binding_scope(tcx);
let node = tcx.hir().as_local_hir_id(scope).unwrap_or(hir::DUMMY_HIR_ID);
- let span = tcx.sess.source_map().def_span(tcx.hir().span_by_hir_id(node));
+ let span = tcx.sess.source_map().def_span(tcx.hir().span(node));
if let Some(param) = tcx.hir()
.get_generics(scope)
.and_then(|generics| generics.get_named(name))
@@ -367,8 +367,8 @@
argument_index: usize,
counter: &mut usize,
) -> Option<RegionName> {
- let mir_node_id = infcx.tcx.hir().as_local_node_id(mir_def_id)?;
- let fn_decl = infcx.tcx.hir().fn_decl(mir_node_id)?;
+ let mir_hir_id = infcx.tcx.hir().as_local_hir_id(mir_def_id)?;
+ let fn_decl = infcx.tcx.hir().fn_decl_by_hir_id(mir_hir_id)?;
let argument_hir_ty: &hir::Ty = &fn_decl.inputs[argument_index];
match argument_hir_ty.node {
// This indicates a variable with no type annotation, like
@@ -696,9 +696,9 @@
highlight.highlighting_region_vid(fr, *counter);
let type_name = infcx.extract_type_name(&return_ty, Some(highlight));
- let mir_node_id = tcx.hir().as_local_node_id(mir_def_id).expect("non-local mir");
+ let mir_hir_id = tcx.hir().as_local_hir_id(mir_def_id).expect("non-local mir");
- let (return_span, mir_description) = match tcx.hir().get(mir_node_id) {
+ let (return_span, mir_description) = match tcx.hir().get_by_hir_id(mir_hir_id) {
hir::Node::Expr(hir::Expr {
node: hir::ExprKind::Closure(_, return_ty, _, span, gen_move),
..
@@ -759,9 +759,9 @@
highlight.highlighting_region_vid(fr, *counter);
let type_name = infcx.extract_type_name(&yield_ty, Some(highlight));
- let mir_node_id = tcx.hir().as_local_node_id(mir_def_id).expect("non-local mir");
+ let mir_hir_id = tcx.hir().as_local_hir_id(mir_def_id).expect("non-local mir");
- let yield_span = match tcx.hir().get(mir_node_id) {
+ let yield_span = match tcx.hir().get_by_hir_id(mir_hir_id) {
hir::Node::Expr(hir::Expr {
node: hir::ExprKind::Closure(_, _, _, span, _),
..
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs
index 6ce925c..59fc411 100644
--- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs
+++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs
@@ -73,7 +73,7 @@
debug!("get_upvar_name_and_span_for_region: upvar_hir_id={:?}", upvar_hir_id);
let upvar_name = tcx.hir().name_by_hir_id(upvar_hir_id);
- let upvar_span = tcx.hir().span_by_hir_id(upvar_hir_id);
+ let upvar_span = tcx.hir().span(upvar_hir_id);
debug!("get_upvar_name_and_span_for_region: upvar_name={:?} upvar_span={:?}",
upvar_name, upvar_span);
diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs
index df0110e..a236359 100644
--- a/src/librustc_mir/borrow_check/nll/universal_regions.rs
+++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs
@@ -471,7 +471,7 @@
let tcx = self.infcx.tcx;
let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id);
- match tcx.hir().body_owner_kind_by_hir_id(self.mir_hir_id) {
+ match tcx.hir().body_owner_kind(self.mir_hir_id) {
BodyOwnerKind::Closure |
BodyOwnerKind::Fn => {
let defining_ty = if self.mir_def_id == closure_base_def_id {
diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs
index 3a48f35..a0e45ca 100644
--- a/src/librustc_mir/build/mod.rs
+++ b/src/librustc_mir/build/mod.rs
@@ -55,10 +55,10 @@
(*body_id, ty.span)
}
Node::AnonConst(hir::AnonConst { body, hir_id, .. }) => {
- (*body, tcx.hir().span_by_hir_id(*hir_id))
+ (*body, tcx.hir().span(*hir_id))
}
- _ => span_bug!(tcx.hir().span_by_hir_id(id), "can't build MIR for {:?}", def_id),
+ _ => span_bug!(tcx.hir().span(id), "can't build MIR for {:?}", def_id),
};
tcx.infer_ctxt().enter(|infcx| {
@@ -101,9 +101,9 @@
let owner_id = tcx.hir().body_owner(body_id);
let opt_ty_info;
let self_arg;
- if let Some(ref fn_decl) = tcx.hir().fn_decl(owner_id) {
+ if let Some(ref fn_decl) = tcx.hir().fn_decl_by_hir_id(owner_id) {
let ty_hir_id = fn_decl.inputs[index].hir_id;
- let ty_span = tcx.hir().span_by_hir_id(ty_hir_id);
+ let ty_span = tcx.hir().span(ty_hir_id);
opt_ty_info = Some(ty_span);
self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() {
match fn_decl.implicit_self {
@@ -131,7 +131,7 @@
ty::Generator(gen_def_id, gen_substs, ..) =>
gen_substs.sig(gen_def_id, tcx),
_ =>
- span_bug!(tcx.hir().span_by_hir_id(id),
+ span_bug!(tcx.hir().span(id),
"generator w/o generator type: {:?}", ty),
};
(Some(gen_sig.yield_ty), gen_sig.return_ty)
@@ -535,7 +535,7 @@
let tcx = hir.tcx();
let tcx_hir = tcx.hir();
- let span = tcx_hir.span_by_hir_id(fn_id);
+ let span = tcx_hir.span(fn_id);
let hir_tables = hir.tables();
let fn_def_id = tcx_hir.local_def_id_from_hir_id(fn_id);
diff --git a/src/librustc_mir/hair/cx/block.rs b/src/librustc_mir/hair/cx/block.rs
index 63239a3..d593205 100644
--- a/src/librustc_mir/hair/cx/block.rs
+++ b/src/librustc_mir/hair/cx/block.rs
@@ -49,7 +49,7 @@
for (index, stmt) in stmts.iter().enumerate() {
let hir_id = stmt.hir_id;
let opt_dxn_ext = cx.region_scope_tree.opt_destruction_scope(hir_id.local_id);
- let stmt_span = StatementSpan(cx.tcx.hir().span_by_hir_id(hir_id));
+ let stmt_span = StatementSpan(cx.tcx.hir().span(hir_id));
match stmt.node {
hir::StmtKind::Expr(ref expr) |
hir::StmtKind::Semi(ref expr) => {
diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs
index 89452b2..9f05cf9 100644
--- a/src/librustc_mir/hair/cx/expr.rs
+++ b/src/librustc_mir/hair/cx/expr.rs
@@ -908,12 +908,13 @@
}
Res::Def(DefKind::ConstParam, def_id) => {
- let node_id = cx.tcx.hir().as_local_node_id(def_id).unwrap();
- let item_id = cx.tcx.hir().get_parent_node(node_id);
- let item_def_id = cx.tcx.hir().local_def_id(item_id);
+ let hir_id = cx.tcx.hir().as_local_hir_id(def_id).unwrap();
+ let item_id = cx.tcx.hir().get_parent_node_by_hir_id(hir_id);
+ let item_def_id = cx.tcx.hir().local_def_id_from_hir_id(item_id);
let generics = cx.tcx.generics_of(item_def_id);
- let index = generics.param_def_id_to_index[&cx.tcx.hir().local_def_id(node_id)];
- let name = cx.tcx.hir().name(node_id).as_interned_str();
+ let local_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
+ let index = generics.param_def_id_to_index[&local_def_id];
+ let name = cx.tcx.hir().name_by_hir_id(hir_id).as_interned_str();
let val = ConstValue::Param(ty::ParamConst::new(index, name));
ExprKind::Literal {
literal: cx.tcx.mk_const(
diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs
index b6feac3..ff53cf0 100644
--- a/src/librustc_mir/hair/cx/mod.rs
+++ b/src/librustc_mir/hair/cx/mod.rs
@@ -56,7 +56,7 @@
let tcx = infcx.tcx;
let src_def_id = tcx.hir().local_def_id_from_hir_id(src_id);
let tables = tcx.typeck_tables_of(src_def_id);
- let body_owner_kind = tcx.hir().body_owner_kind_by_hir_id(src_id);
+ let body_owner_kind = tcx.hir().body_owner_kind(src_id);
let constness = match body_owner_kind {
hir::BodyOwnerKind::Const |
@@ -65,7 +65,7 @@
hir::BodyOwnerKind::Fn => hir::Constness::NotConst,
};
- let attrs = tcx.hir().attrs_by_hir_id(src_id);
+ let attrs = tcx.hir().attrs(src_id);
// Some functions always have overflow checks enabled,
// however, they may not get codegen'd, depending on
diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs
index e7fd308..159b526 100644
--- a/src/librustc_mir/hair/pattern/check_match.rs
+++ b/src/librustc_mir/hair/pattern/check_match.rs
@@ -161,7 +161,7 @@
}
}
- let module = self.tcx.hir().get_module_parent_by_hir_id(scrut.hir_id);
+ let module = self.tcx.hir().get_module_parent(scrut.hir_id);
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
let mut have_errors = false;
@@ -193,7 +193,7 @@
// Then, if the match has no arms, check whether the scrutinee
// is uninhabited.
let pat_ty = self.tables.node_type(scrut.hir_id);
- let module = self.tcx.hir().get_module_parent_by_hir_id(scrut.hir_id);
+ let module = self.tcx.hir().get_module_parent(scrut.hir_id);
let mut def_span = None;
let mut missing_variants = vec![];
if inlined_arms.is_empty() {
@@ -261,7 +261,7 @@
}
fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
- let module = self.tcx.hir().get_module_parent_by_hir_id(pat.hir_id);
+ let module = self.tcx.hir().get_module_parent(pat.hir_id);
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
let mut patcx = PatternContext::new(self.tcx,
self.param_env.and(self.identity_substs),
diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs
index 0ce7272..3460c21 100644
--- a/src/librustc_mir/interpret/validity.rs
+++ b/src/librustc_mir/interpret/validity.rs
@@ -175,8 +175,8 @@
// Sometimes the index is beyond the number of upvars (seen
// for a generator).
if let Some((&var_hir_id, _)) = upvars.get_index(field) {
- let var_node_id = self.ecx.tcx.hir().hir_to_node_id(var_hir_id);
- if let hir::Node::Binding(pat) = self.ecx.tcx.hir().get(var_node_id) {
+ let node = self.ecx.tcx.hir().get_by_hir_id(var_hir_id);
+ if let hir::Node::Binding(pat) = node {
if let hir::PatKind::Binding(_, _, ident, _) = pat.node {
name = Some(ident.name);
}
diff --git a/src/librustc_mir/lints.rs b/src/librustc_mir/lints.rs
index 55151a9..a712088 100644
--- a/src/librustc_mir/lints.rs
+++ b/src/librustc_mir/lints.rs
@@ -130,7 +130,7 @@
// recurs.
if !reached_exit_without_self_call && !self_call_locations.is_empty() {
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
- let sp = tcx.sess.source_map().def_span(tcx.hir().span_by_hir_id(hir_id));
+ let sp = tcx.sess.source_map().def_span(tcx.hir().span(hir_id));
let mut db = tcx.struct_span_lint_hir(UNCONDITIONAL_RECURSION,
hir_id,
sp,
diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs
index e530c56..2e74ebc 100644
--- a/src/librustc_mir/monomorphize/collector.rs
+++ b/src/librustc_mir/monomorphize/collector.rs
@@ -455,7 +455,7 @@
let error = format!("reached the recursion limit while instantiating `{}`",
instance);
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
- tcx.sess.span_fatal(tcx.hir().span_by_hir_id(hir_id), &error);
+ tcx.sess.span_fatal(tcx.hir().span(hir_id), &error);
} else {
tcx.sess.fatal(&error);
}
diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs
index 595e599..2bcf058 100644
--- a/src/librustc_mir/monomorphize/item.rs
+++ b/src/librustc_mir/monomorphize/item.rs
@@ -193,7 +193,7 @@
MonoItem::GlobalAsm(hir_id) => {
Some(hir_id)
}
- }.map(|hir_id| tcx.hir().span_by_hir_id(hir_id))
+ }.map(|hir_id| tcx.hir().span(hir_id))
}
}
diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs
index 80a31ef..32153f7 100644
--- a/src/librustc_mir/transform/check_unsafety.rs
+++ b/src/librustc_mir/transform/check_unsafety.rs
@@ -488,7 +488,7 @@
) {
let body_id =
tcx.hir().as_local_hir_id(def_id).and_then(|hir_id| {
- tcx.hir().maybe_body_owned_by_by_hir_id(hir_id)
+ tcx.hir().maybe_body_owned_by(hir_id)
});
let body_id = match body_id {
@@ -527,7 +527,7 @@
let param_env = tcx.param_env(def_id);
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
- let (const_context, min_const_fn) = match tcx.hir().body_owner_kind_by_hir_id(id) {
+ let (const_context, min_const_fn) = match tcx.hir().body_owner_kind(id) {
hir::BodyOwnerKind::Closure => (false, false),
hir::BodyOwnerKind::Fn => (tcx.is_const_fn(def_id), tcx.is_min_const_fn(def_id)),
hir::BodyOwnerKind::Const |
@@ -591,12 +591,12 @@
}
fn report_unused_unsafe(tcx: TyCtxt<'_>, used_unsafe: &FxHashSet<hir::HirId>, id: hir::HirId) {
- let span = tcx.sess.source_map().def_span(tcx.hir().span_by_hir_id(id));
+ let span = tcx.sess.source_map().def_span(tcx.hir().span(id));
let msg = "unnecessary `unsafe` block";
let mut db = tcx.struct_span_lint_hir(UNUSED_UNSAFE, id, span, msg);
db.span_label(span, msg);
if let Some((kind, id)) = is_enclosed(tcx, used_unsafe, id) {
- db.span_label(tcx.sess.source_map().def_span(tcx.hir().span_by_hir_id(id)),
+ db.span_label(tcx.sess.source_map().def_span(tcx.hir().span(id)),
format!("because it's nested under this `unsafe` {}", kind));
}
db.emit();
diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs
index f8e3fc2..5e6f1bc 100644
--- a/src/librustc_mir/transform/inline.rs
+++ b/src/librustc_mir/transform/inline.rs
@@ -70,7 +70,7 @@
// Only do inlining into fn bodies.
let id = self.tcx.hir().as_local_hir_id(self.source.def_id()).unwrap();
- if self.tcx.hir().body_owner_kind_by_hir_id(id).is_fn_or_closure()
+ if self.tcx.hir().body_owner_kind(id).is_fn_or_closure()
&& self.source.promoted.is_none()
{
for (bb, bb_data) in caller_body.basic_blocks().iter_enumerated() {
diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs
index 04dce32..79bb2cf 100644
--- a/src/librustc_mir/transform/mod.rs
+++ b/src/librustc_mir/transform/mod.rs
@@ -208,7 +208,7 @@
fn mir_validated(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx Steal<Body<'tcx>> {
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
- if let hir::BodyOwnerKind::Const = tcx.hir().body_owner_kind_by_hir_id(hir_id) {
+ if let hir::BodyOwnerKind::Const = tcx.hir().body_owner_kind(hir_id) {
// Ensure that we compute the `mir_const_qualif` for constants at
// this point, before we steal the mir-const result.
let _ = tcx.mir_const_qualif(def_id);
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs
index 8a8cc50..b6abfdb 100644
--- a/src/librustc_mir/transform/qualify_consts.rs
+++ b/src/librustc_mir/transform/qualify_consts.rs
@@ -1503,7 +1503,7 @@
let def_id = src.def_id();
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
let mut const_promoted_temps = None;
- let mode = match tcx.hir().body_owner_kind_by_hir_id(id) {
+ let mode = match tcx.hir().body_owner_kind(id) {
hir::BodyOwnerKind::Closure => Mode::NonConstFn,
hir::BodyOwnerKind::Fn => {
if tcx.is_const_fn(def_id) {
diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs
index 7230b69..5397a4a 100644
--- a/src/librustc_passes/rvalue_promotion.rs
+++ b/src/librustc_passes/rvalue_promotion.rs
@@ -165,7 +165,7 @@
impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
fn check_nested_body(&mut self, body_id: hir::BodyId) -> Promotability {
let item_id = self.tcx.hir().body_owner(body_id);
- let item_def_id = self.tcx.hir().local_def_id(item_id);
+ let item_def_id = self.tcx.hir().local_def_id_from_hir_id(item_id);
let outer_in_fn = self.in_fn;
let outer_tables = self.tables;
diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs
index c2cb2f4..9eaa6f9 100644
--- a/src/librustc_privacy/lib.rs
+++ b/src/librustc_privacy/lib.rs
@@ -233,7 +233,7 @@
Node::Item(item) => &item.vis,
Node::ForeignItem(foreign_item) => &foreign_item.vis,
Node::TraitItem(..) | Node::Variant(..) => {
- return def_id_visibility(tcx, tcx.hir().get_parent_did_by_hir_id(hir_id));
+ return def_id_visibility(tcx, tcx.hir().get_parent_did(hir_id));
}
Node::ImplItem(impl_item) => {
match tcx.hir().get_by_hir_id(tcx.hir().get_parent_item(hir_id)) {
@@ -255,7 +255,7 @@
tcx, parent_did,
);
- let adt_def = tcx.adt_def(tcx.hir().get_parent_did_by_hir_id(hir_id));
+ let adt_def = tcx.adt_def(tcx.hir().get_parent_did(hir_id));
let ctor_did = tcx.hir().local_def_id_from_hir_id(
vdata.ctor_hir_id().unwrap());
let variant = adt_def.variant_with_ctor_id(ctor_did);
@@ -294,7 +294,7 @@
// visibility to within the crate.
if ctor_vis == ty::Visibility::Public {
let adt_def =
- tcx.adt_def(tcx.hir().get_parent_did_by_hir_id(hir_id));
+ tcx.adt_def(tcx.hir().get_parent_did(hir_id));
if adt_def.non_enum_variant().is_field_list_non_exhaustive() {
ctor_vis =
ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX));
@@ -311,7 +311,7 @@
}
Node::Expr(expr) => {
return (ty::Visibility::Restricted(
- tcx.hir().get_module_parent_by_hir_id(expr.hir_id)),
+ tcx.hir().get_module_parent(expr.hir_id)),
expr.span, "private")
}
node => bug!("unexpected node kind: {:?}", node)
@@ -501,11 +501,11 @@
if let Some(item) = module.res
.and_then(|res| res.mod_def_id())
.and_then(|def_id| self.tcx.hir().as_local_hir_id(def_id))
- .map(|module_hir_id| self.tcx.hir().expect_item_by_hir_id(module_hir_id))
+ .map(|module_hir_id| self.tcx.hir().expect_item(module_hir_id))
{
if let hir::ItemKind::Mod(m) = &item.node {
for item_id in m.item_ids.as_ref() {
- let item = self.tcx.hir().expect_item_by_hir_id(item_id.id);
+ let item = self.tcx.hir().expect_item(item_id.id);
let def_id = self.tcx.hir().local_def_id_from_hir_id(item_id.id);
if !self.tcx.hygienic_eq(segment.ident, item.ident, def_id) { continue; }
if let hir::ItemKind::Use(..) = item.node {
@@ -764,7 +764,7 @@
let module = if module_id == hir::CRATE_HIR_ID {
&self.tcx.hir().krate().module
} else if let hir::ItemKind::Mod(ref module) =
- self.tcx.hir().expect_item_by_hir_id(module_id).node {
+ self.tcx.hir().expect_item(module_id).node {
module
} else {
unreachable!()
@@ -1690,7 +1690,7 @@
tcx: self.tcx,
item_id,
item_def_id: self.tcx.hir().local_def_id_from_hir_id(item_id),
- span: self.tcx.hir().span_by_hir_id(item_id),
+ span: self.tcx.hir().span(item_id),
required_visibility,
has_pub_restricted: self.has_pub_restricted,
has_old_errors,
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 892a7b1..97124e5 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -2196,12 +2196,12 @@
if let Some(def_id) = self.const_param_def_id(expr) {
// Find the name and index of the const parameter by indexing the generics of the
// parent item and construct a `ParamConst`.
- let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
- let item_id = tcx.hir().get_parent_node(node_id);
- let item_def_id = tcx.hir().local_def_id(item_id);
+ let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
+ let item_id = tcx.hir().get_parent_node_by_hir_id(hir_id);
+ let item_def_id = tcx.hir().local_def_id_from_hir_id(item_id);
let generics = tcx.generics_of(item_def_id);
- let index = generics.param_def_id_to_index[&tcx.hir().local_def_id(node_id)];
- let name = tcx.hir().name(node_id).as_interned_str();
+ let index = generics.param_def_id_to_index[&tcx.hir().local_def_id_from_hir_id(hir_id)];
+ let name = tcx.hir().name_by_hir_id(hir_id).as_interned_str();
const_.val = ConstValue::Param(ty::ParamConst::new(index, name));
}
diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs
index 0207f18..42c7ff6 100644
--- a/src/librustc_typeck/check/callee.rs
+++ b/src/librustc_typeck/check/callee.rs
@@ -354,7 +354,7 @@
let def_span = match def {
Res::Err => None,
Res::Local(id) => {
- Some(self.tcx.hir().span_by_hir_id(id))
+ Some(self.tcx.hir().span(id))
},
_ => def
.opt_def_id()
diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs
index 088ac0e..9460827 100644
--- a/src/librustc_typeck/check/compare_method.rs
+++ b/src/librustc_typeck/check/compare_method.rs
@@ -813,7 +813,7 @@
{
if impl_synthetic != trait_synthetic {
let impl_hir_id = tcx.hir().as_local_hir_id(impl_def_id).unwrap();
- let impl_span = tcx.hir().span_by_hir_id(impl_hir_id);
+ let impl_span = tcx.hir().span(impl_hir_id);
let trait_span = tcx.def_span(trait_def_id);
let mut err = struct_span_err!(tcx.sess,
impl_span,
diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs
index 2003782..a2621ab 100644
--- a/src/librustc_typeck/check/dropck.rs
+++ b/src/librustc_typeck/check/dropck.rs
@@ -213,7 +213,7 @@
// repeated `contains` calls.
if !assumptions_in_impl_context.contains(&predicate) {
- let item_span = tcx.hir().span_by_hir_id(self_type_hir_id);
+ let item_span = tcx.hir().span(self_type_hir_id);
struct_span_err!(
tcx.sess,
drop_impl_span,
diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs
index fa9e0d8..4216880 100644
--- a/src/librustc_typeck/check/expr.rs
+++ b/src/librustc_typeck/check/expr.rs
@@ -180,7 +180,7 @@
self.diverges.set(self.diverges.get() | old_diverges);
self.has_errors.set(self.has_errors.get() | old_has_errors);
- debug!("type of {} is...", self.tcx.hir().hir_to_string(expr.hir_id));
+ debug!("type of {} is...", self.tcx.hir().node_to_string(expr.hir_id));
debug!("... {:?}, expected is {:?}", ty, expected);
ty
diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs
index 71bcf2b..29b4fee 100644
--- a/src/librustc_typeck/check/method/suggest.rs
+++ b/src/librustc_typeck/check/method/suggest.rs
@@ -264,7 +264,7 @@
// local binding
if let &QPath::Resolved(_, ref path) = &qpath {
if let hir::def::Res::Local(hir_id) = path.res {
- let span = tcx.hir().span_by_hir_id(hir_id);
+ let span = tcx.hir().span(hir_id);
let snippet = tcx.sess.source_map().span_to_snippet(span);
let filename = tcx.sess.source_map().span_to_filename(span);
@@ -370,7 +370,7 @@
});
if let Some((field, field_ty)) = field_receiver {
- let scope = self.tcx.hir().get_module_parent_by_hir_id(self.body_id);
+ let scope = self.tcx.hir().get_module_parent(self.body_id);
let is_accessible = field.vis.is_accessible_from(scope, self.tcx);
if is_accessible {
@@ -564,7 +564,7 @@
err: &mut DiagnosticBuilder<'_>,
mut msg: String,
candidates: Vec<DefId>) {
- let module_did = self.tcx.hir().get_module_parent_by_hir_id(self.body_id);
+ let module_did = self.tcx.hir().get_module_parent(self.body_id);
let module_id = self.tcx.hir().as_local_hir_id(module_did).unwrap();
let krate = self.tcx.hir().krate();
let (span, found_use) = UsePlacementFinder::check(self.tcx, krate, module_id);
@@ -897,7 +897,7 @@
}
// Find a `use` statement.
for item_id in &module.item_ids {
- let item = self.tcx.hir().expect_item_by_hir_id(item_id.id);
+ let item = self.tcx.hir().expect_item(item_id.id);
match item.node {
hir::ItemKind::Use(..) => {
// Don't suggest placing a `use` before the prelude
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index ecf7860..10bfe9e 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -622,7 +622,7 @@
fn new(infcx: InferCtxt<'a, 'tcx>, def_id: DefId) -> Self {
let tcx = infcx.tcx;
let item_id = tcx.hir().as_local_hir_id(def_id);
- let body_id = item_id.and_then(|id| tcx.hir().maybe_body_owned_by_by_hir_id(id));
+ let body_id = item_id.and_then(|id| tcx.hir().maybe_body_owned_by(id));
let implicit_region_bound = body_id.map(|body_id| {
let body = tcx.hir().body(body_id);
tcx.mk_region(ty::ReScope(region::Scope {
@@ -821,7 +821,7 @@
}
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
- let span = tcx.hir().span_by_hir_id(id);
+ let span = tcx.hir().span(id);
// Figure out what primary body this item has.
let (body_id, fn_decl) = primary_body_of(tcx, id).unwrap_or_else(|| {
@@ -1193,7 +1193,7 @@
}
let inputs = fn_sig.inputs();
- let span = fcx.tcx.hir().span_by_hir_id(fn_id);
+ let span = fcx.tcx.hir().span(fn_id);
if inputs.len() == 1 {
let arg_is_panic_info = match inputs[0].sty {
ty::Ref(region, ty, mutbl) => match ty.sty {
@@ -1246,7 +1246,7 @@
}
let inputs = fn_sig.inputs();
- let span = fcx.tcx.hir().span_by_hir_id(fn_id);
+ let span = fcx.tcx.hir().span(fn_id);
if inputs.len() == 1 {
let arg_is_alloc_layout = match inputs[0].sty {
ty::Adt(ref adt, _) => {
@@ -1909,11 +1909,11 @@
let variant_i_hir_id = tcx.hir().as_local_hir_id(variant_did).unwrap();
let variant_i = tcx.hir().expect_variant(variant_i_hir_id);
let i_span = match variant_i.node.disr_expr {
- Some(ref expr) => tcx.hir().span_by_hir_id(expr.hir_id),
- None => tcx.hir().span_by_hir_id(variant_i_hir_id)
+ Some(ref expr) => tcx.hir().span(expr.hir_id),
+ None => tcx.hir().span(variant_i_hir_id)
};
let span = match v.node.disr_expr {
- Some(ref expr) => tcx.hir().span_by_hir_id(expr.hir_id),
+ Some(ref expr) => tcx.hir().span(expr.hir_id),
None => v.span
};
struct_span_err!(tcx.sess, span, E0081,
@@ -2181,7 +2181,7 @@
pub fn local_ty(&self, span: Span, nid: hir::HirId) -> LocalTy<'tcx> {
self.locals.borrow().get(&nid).cloned().unwrap_or_else(||
span_bug!(span, "no type for local variable {}",
- self.tcx.hir().hir_to_string(nid))
+ self.tcx.hir().node_to_string(nid))
)
}
@@ -2517,9 +2517,8 @@
Some(&t) => t,
None if self.is_tainted_by_errors() => self.tcx.types.err,
None => {
- let node_id = self.tcx.hir().hir_to_node_id(id);
bug!("no type for node {}: {} in fcx {}",
- node_id, self.tcx.hir().node_to_string(node_id),
+ id, self.tcx.hir().node_to_string(id),
self.tag());
}
}
@@ -4364,7 +4363,7 @@
for (&used, param) in types_used.iter().zip(types) {
if !used {
let id = tcx.hir().as_local_hir_id(param.def_id).unwrap();
- let span = tcx.hir().span_by_hir_id(id);
+ let span = tcx.hir().span(id);
struct_span_err!(tcx.sess, span, E0091, "type parameter `{}` is unused", param.name)
.span_label(span, "unused type parameter")
.emit();
diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs
index bf3381d..5c71039 100644
--- a/src/librustc_typeck/check/regionck.rs
+++ b/src/librustc_typeck/check/regionck.rs
@@ -175,7 +175,7 @@
if self.err_count_since_creation() == 0 {
// regionck assumes typeck succeeded
- rcx.visit_fn_body(fn_id, body, self.tcx.hir().span_by_hir_id(fn_id));
+ rcx.visit_fn_body(fn_id, body, self.tcx.hir().span(fn_id));
}
rcx.resolve_regions_and_report_errors(SuppressRegionErrors::when_nll_is_enabled(self.tcx));
diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs
index bf64643..034ff5f 100644
--- a/src/librustc_typeck/check/wfcheck.rs
+++ b/src/librustc_typeck/check/wfcheck.rs
@@ -70,7 +70,7 @@
/// the types first.
pub fn check_item_well_formed<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) {
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
- let item = tcx.hir().expect_item_by_hir_id(hir_id);
+ let item = tcx.hir().expect_item(hir_id);
debug!("check_item_well_formed(it.hir_id={:?}, it.name={})",
item.hir_id,
diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs
index 5be8228..ffc323f 100644
--- a/src/librustc_typeck/check/writeback.rs
+++ b/src/librustc_typeck/check/writeback.rs
@@ -34,7 +34,7 @@
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn resolve_type_vars_in_body(&self, body: &'tcx hir::Body) -> &'tcx ty::TypeckTables<'tcx> {
let item_id = self.tcx.hir().body_owner(body.id());
- let item_def_id = self.tcx.hir().local_def_id(item_id);
+ let item_def_id = self.tcx.hir().local_def_id_from_hir_id(item_id);
// This attribute causes us to dump some writeback information
// in the form of errors, which is uSymbolfor unit tests.
@@ -47,8 +47,7 @@
// Type only exists for constants and statics, not functions.
match self.tcx.hir().body_owner_kind(item_id) {
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(_) => {
- let item_hir_id = self.tcx.hir().node_to_hir_id(item_id);
- wbcx.visit_node_id(body.value.span, item_hir_id);
+ wbcx.visit_node_id(body.value.span, item_id);
}
hir::BodyOwnerKind::Closure | hir::BodyOwnerKind::Fn => (),
}
@@ -399,7 +398,7 @@
if let ty::UserType::TypeOf(_, user_substs) = c_ty.value {
if self.rustc_dump_user_substs {
// This is a unit-testing mechanism.
- let span = self.tcx().hir().span_by_hir_id(hir_id);
+ let span = self.tcx().hir().span(hir_id);
// We need to buffer the errors in order to guarantee a consistent
// order when emitting them.
let err = self.tcx().sess.struct_span_err(
@@ -774,13 +773,13 @@
impl Locatable for DefIndex {
fn to_span(&self, tcx: TyCtxt<'_>) -> Span {
let hir_id = tcx.hir().def_index_to_hir_id(*self);
- tcx.hir().span_by_hir_id(hir_id)
+ tcx.hir().span(hir_id)
}
}
impl Locatable for hir::HirId {
fn to_span(&self, tcx: TyCtxt<'_>) -> Span {
- tcx.hir().span_by_hir_id(*self)
+ tcx.hir().span(*self)
}
}
diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs
index c724500..dda8677 100644
--- a/src/librustc_typeck/check_unused.rs
+++ b/src/librustc_typeck/check_unused.rs
@@ -121,7 +121,7 @@
for extern_crate in &crates_to_lint {
let id = tcx.hir().as_local_hir_id(extern_crate.def_id).unwrap();
- let item = tcx.hir().expect_item_by_hir_id(id);
+ let item = tcx.hir().expect_item(id);
// If the crate is fully unused, we suggest removing it altogether.
// We do this in any edition.
diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs
index a690eef..e392622 100644
--- a/src/librustc_typeck/coherence/builtin.rs
+++ b/src/librustc_typeck/coherence/builtin.rs
@@ -88,7 +88,7 @@
debug!("visit_implementation_of_copy: self_type={:?} (bound)",
self_type);
- let span = tcx.hir().span_by_hir_id(impl_hir_id);
+ let span = tcx.hir().span(impl_hir_id);
let param_env = tcx.param_env(impl_did);
assert!(!self_type.has_escaping_bound_vars());
@@ -98,7 +98,7 @@
match param_env.can_type_implement_copy(tcx, self_type) {
Ok(()) => {}
Err(CopyImplementationError::InfrigingFields(fields)) => {
- let item = tcx.hir().expect_item_by_hir_id(impl_hir_id);
+ let item = tcx.hir().expect_item(impl_hir_id);
let span = if let ItemKind::Impl(.., Some(ref tr), _, _) = item.node {
tr.path.span
} else {
@@ -115,7 +115,7 @@
err.emit()
}
Err(CopyImplementationError::NotAnAdt) => {
- let item = tcx.hir().expect_item_by_hir_id(impl_hir_id);
+ let item = tcx.hir().expect_item(impl_hir_id);
let span = if let ItemKind::Impl(.., ref ty, _) = item.node {
ty.span
} else {
@@ -161,7 +161,7 @@
let dispatch_from_dyn_trait = tcx.lang_items().dispatch_from_dyn_trait().unwrap();
let impl_hir_id = tcx.hir().as_local_hir_id(impl_did).unwrap();
- let span = tcx.hir().span_by_hir_id(impl_hir_id);
+ let span = tcx.hir().span(impl_hir_id);
let source = tcx.type_of(impl_did);
assert!(!source.has_escaping_bound_vars());
@@ -343,7 +343,7 @@
source,
target);
- let span = gcx.hir().span_by_hir_id(impl_hir_id);
+ let span = gcx.hir().span(impl_hir_id);
let param_env = gcx.param_env(impl_did);
assert!(!source.has_escaping_bound_vars());
@@ -480,11 +480,11 @@
being coerced, none found");
return err_info;
} else if diff_fields.len() > 1 {
- let item = gcx.hir().expect_item_by_hir_id(impl_hir_id);
+ let item = gcx.hir().expect_item(impl_hir_id);
let span = if let ItemKind::Impl(.., Some(ref t), _, _) = item.node {
t.path.span
} else {
- gcx.hir().span_by_hir_id(impl_hir_id)
+ gcx.hir().span(impl_hir_id)
};
let mut err = struct_span_err!(gcx.sess,
diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs
index 43063d7..4e6fcfe 100644
--- a/src/librustc_typeck/coherence/orphan.rs
+++ b/src/librustc_typeck/coherence/orphan.rs
@@ -26,7 +26,7 @@
// "Trait" impl
if let hir::ItemKind::Impl(.., Some(_), _, _) = item.node {
debug!("coherence2::orphan check: trait impl {}",
- self.tcx.hir().hir_to_string(item.hir_id));
+ self.tcx.hir().node_to_string(item.hir_id));
let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap();
let trait_def_id = trait_ref.def_id;
let cm = self.tcx.sess.source_map();
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index d4b2c20..5606d9c 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -395,7 +395,7 @@
}
fn convert_item<'tcx>(tcx: TyCtxt<'tcx>, item_id: hir::HirId) {
- let it = tcx.hir().expect_item_by_hir_id(item_id);
+ let it = tcx.hir().expect_item(item_id);
debug!("convert: item {} with id {}", it.ident, it.hir_id);
let def_id = tcx.hir().local_def_id_from_hir_id(item_id);
match it.node {
@@ -742,7 +742,7 @@
fn trait_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::TraitDef {
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
- let item = tcx.hir().expect_item_by_hir_id(hir_id);
+ let item = tcx.hir().expect_item(hir_id);
let (is_auto, unsafety) = match item.node {
hir::ItemKind::Trait(is_auto, unsafety, ..) => (is_auto == hir::IsAuto::Yes, unsafety),
@@ -1177,7 +1177,7 @@
ImplItemKind::Const(ref ty, _) => icx.to_ty(ty),
ImplItemKind::Existential(_) => {
if tcx
- .impl_trait_ref(tcx.hir().get_parent_did_by_hir_id(hir_id))
+ .impl_trait_ref(tcx.hir().get_parent_did(hir_id))
.is_none()
{
report_assoc_ty_on_inherent_impl(tcx, item.span);
@@ -1187,7 +1187,7 @@
}
ImplItemKind::Type(ref ty) => {
if tcx
- .impl_trait_ref(tcx.hir().get_parent_did_by_hir_id(hir_id))
+ .impl_trait_ref(tcx.hir().get_parent_did(hir_id))
.is_none()
{
report_assoc_ty_on_inherent_impl(tcx, item.span);
@@ -1272,7 +1272,7 @@
..
}) => match *def {
VariantData::Unit(..) | VariantData::Struct(..) => {
- tcx.type_of(tcx.hir().get_parent_did_by_hir_id(hir_id))
+ tcx.type_of(tcx.hir().get_parent_did(hir_id))
}
VariantData::Tuple(..) => {
let substs = InternalSubsts::identity_for_item(tcx, def_id);
@@ -1325,7 +1325,7 @@
..
}) if e.hir_id == hir_id =>
{
- tcx.adt_def(tcx.hir().get_parent_did_by_hir_id(hir_id))
+ tcx.adt_def(tcx.hir().get_parent_did(hir_id))
.repr
.discr_type()
.to_ty(tcx)
@@ -1709,7 +1709,7 @@
node: ForeignItemKind::Fn(ref fn_decl, _, _),
..
}) => {
- let abi = tcx.hir().get_foreign_abi_by_hir_id(hir_id);
+ let abi = tcx.hir().get_foreign_abi(hir_id);
compute_sig_of_foreign_fn_decl(tcx, def_id, fn_decl, abi)
}
@@ -1717,7 +1717,7 @@
node: hir::VariantKind { data, .. },
..
}) if data.ctor_hir_id().is_some() => {
- let ty = tcx.type_of(tcx.hir().get_parent_did_by_hir_id(hir_id));
+ let ty = tcx.type_of(tcx.hir().get_parent_did(hir_id));
let inputs = data.fields()
.iter()
.map(|f| tcx.type_of(tcx.hir().local_def_id_from_hir_id(f.hir_id)));
@@ -1762,7 +1762,7 @@
let icx = ItemCtxt::new(tcx, def_id);
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
- match tcx.hir().expect_item_by_hir_id(hir_id).node {
+ match tcx.hir().expect_item(hir_id).node {
hir::ItemKind::Impl(.., ref opt_trait_ref, _, _) => {
opt_trait_ref.as_ref().map(|ast_trait_ref| {
let selfty = tcx.type_of(def_id);
@@ -1775,7 +1775,7 @@
fn impl_polarity<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> hir::ImplPolarity {
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
- match tcx.hir().expect_item_by_hir_id(hir_id).node {
+ match tcx.hir().expect_item(hir_id).node {
hir::ItemKind::Impl(_, polarity, ..) => polarity,
ref item => bug!("impl_polarity: {:?} not an impl", item),
}
diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs
index ea45884..5dbd667 100644
--- a/src/librustc_typeck/variance/mod.rs
+++ b/src/librustc_typeck/variance/mod.rs
@@ -46,7 +46,7 @@
let id = tcx.hir().as_local_hir_id(item_def_id).expect("expected local def-id");
let unsupported = || {
// Variance not relevant.
- span_bug!(tcx.hir().span_by_hir_id(id), "asked to compute variance for wrong kind of item")
+ span_bug!(tcx.hir().span(id), "asked to compute variance for wrong kind of item")
};
match tcx.hir().get_by_hir_id(id) {
Node::Item(item) => match item.node {
diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs
index b120f99..99f87cc 100644
--- a/src/librustc_typeck/variance/terms.rs
+++ b/src/librustc_typeck/variance/terms.rs
@@ -129,7 +129,7 @@
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
fn visit_item(&mut self, item: &hir::Item) {
debug!("add_inferreds for item {}",
- self.tcx.hir().hir_to_string(item.hir_id));
+ self.tcx.hir().node_to_string(item.hir_id));
match item.node {
hir::ItemKind::Struct(ref struct_def, _) |
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index 5a5540e..c14ae59 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -305,7 +305,7 @@
}
let for_ = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
- match tcx.hir().expect_item_by_hir_id(hir_id).node {
+ match tcx.hir().expect_item(hir_id).node {
hir::ItemKind::Impl(.., ref t, _) => {
t.clean(cx)
}
@@ -327,7 +327,7 @@
let predicates = tcx.explicit_predicates_of(did);
let (trait_items, generics) = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
- match tcx.hir().expect_item_by_hir_id(hir_id).node {
+ match tcx.hir().expect_item(hir_id).node {
hir::ItemKind::Impl(.., ref gen, _, _, ref item_ids) => {
(
item_ids.iter()
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 43cb3dd..4becb42 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -276,7 +276,7 @@
};
let primitives = if root.is_local() {
cx.tcx.hir().krate().module.item_ids.iter().filter_map(|&id| {
- let item = cx.tcx.hir().expect_item_by_hir_id(id.id);
+ let item = cx.tcx.hir().expect_item(id.id);
match item.node {
hir::ItemKind::Mod(_) => {
as_primitive(Res::Def(
@@ -320,7 +320,7 @@
};
let keywords = if root.is_local() {
cx.tcx.hir().krate().module.item_ids.iter().filter_map(|&id| {
- let item = cx.tcx.hir().expect_item_by_hir_id(id.id);
+ let item = cx.tcx.hir().expect_item(id.id);
match item.node {
hir::ItemKind::Mod(_) => {
as_keyword(Res::Def(
@@ -2777,7 +2777,7 @@
},
TyKind::Tup(ref tys) => Tuple(tys.clean(cx)),
TyKind::Def(item_id, _) => {
- let item = cx.tcx.hir().expect_item_by_hir_id(item_id.id);
+ let item = cx.tcx.hir().expect_item(item_id.id);
if let hir::ItemKind::Existential(ref ty) = item.node {
ImplTrait(ty.bounds.clean(cx))
} else {
@@ -2799,7 +2799,7 @@
// Substitute private type aliases
if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(def_id) {
if !cx.renderinfo.borrow().access_levels.is_exported(def_id) {
- alias = Some(&cx.tcx.hir().expect_item_by_hir_id(hir_id).node);
+ alias = Some(&cx.tcx.hir().expect_item(hir_id).node);
}
}
};
@@ -4441,7 +4441,7 @@
let segment = path_it.next()?;
for item_id in mem::replace(&mut items, HirVec::new()).iter() {
- let item = tcx.hir().expect_item_by_hir_id(item_id.id);
+ let item = tcx.hir().expect_item(item_id.id);
if item.ident.name == *segment {
if path_it.peek().is_none() {
return Some(tcx.hir().local_def_id_from_hir_id(item_id.id))
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index eb9de43..ff76579 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -248,7 +248,7 @@
let orig_inside_public_path = self.inside_public_path;
self.inside_public_path &= vis.node.is_pub();
for i in &m.item_ids {
- let item = self.cx.tcx.hir().expect_item_by_hir_id(i.id);
+ let item = self.cx.tcx.hir().expect_item(i.id);
self.visit_item(item, None, &mut om);
}
self.inside_public_path = orig_inside_public_path;
@@ -275,7 +275,7 @@
fn inherits_doc_hidden(cx: &core::DocContext<'_>, mut node: hir::HirId) -> bool {
while let Some(id) = cx.tcx.hir().get_enclosing_scope(node) {
node = id;
- if cx.tcx.hir().attrs_by_hir_id(node)
+ if cx.tcx.hir().attrs(node)
.lists(sym::doc).has_word(sym::hidden) {
return true;
}
@@ -295,7 +295,7 @@
return false;
};
- let use_attrs = tcx.hir().attrs_by_hir_id(id);
+ let use_attrs = tcx.hir().attrs(id);
// Don't inline `doc(hidden)` imports so they can be stripped at a later stage.
let is_no_inline = use_attrs.lists(sym::doc).has_word(sym::no_inline) ||
use_attrs.lists(sym::doc).has_word(sym::hidden);
@@ -346,7 +346,7 @@
Node::Item(&hir::Item { node: hir::ItemKind::Mod(ref m), .. }) if glob => {
let prev = mem::replace(&mut self.inlining, true);
for i in &m.item_ids {
- let i = self.cx.tcx.hir().expect_item_by_hir_id(i.id);
+ let i = self.cx.tcx.hir().expect_item(i.id);
self.visit_item(i, None, om);
}
self.inlining = prev;
@@ -361,7 +361,7 @@
Node::ForeignItem(it) if !glob => {
// Generate a fresh `extern {}` block if we want to inline a foreign item.
om.foreigns.push(hir::ForeignMod {
- abi: tcx.hir().get_foreign_abi_by_hir_id(it.hir_id),
+ abi: tcx.hir().get_foreign_abi(it.hir_id),
items: vec![hir::ForeignItem {
ident: renamed.unwrap_or(it.ident),
.. it.clone()
diff --git a/src/libsyntax/source_map.rs b/src/libsyntax/source_map.rs
index a21d2df..c030726 100644
--- a/src/libsyntax/source_map.rs
+++ b/src/libsyntax/source_map.rs
@@ -191,6 +191,18 @@
/// If a file already exists in the source_map with the same id, that file is returned
/// unmodified
pub fn new_source_file(&self, filename: FileName, src: String) -> Lrc<SourceFile> {
+ self.try_new_source_file(filename, src)
+ .unwrap_or_else(|OffsetOverflowError| {
+ eprintln!("fatal error: rustc does not support files larger than 4GB");
+ errors::FatalError.raise()
+ })
+ }
+
+ fn try_new_source_file(
+ &self,
+ filename: FileName,
+ src: String
+ ) -> Result<Lrc<SourceFile>, OffsetOverflowError> {
let start_pos = self.next_start_pos();
// The path is used to determine the directory for loading submodules and
@@ -212,7 +224,7 @@
was_remapped,
Some(&unmapped_path));
- return match self.source_file_by_stable_id(file_id) {
+ let lrc_sf = match self.source_file_by_stable_id(file_id) {
Some(lrc_sf) => lrc_sf,
None => {
let source_file = Lrc::new(SourceFile::new(
@@ -221,7 +233,7 @@
unmapped_path,
src,
Pos::from_usize(start_pos),
- ));
+ )?);
let mut files = self.files.borrow_mut();
@@ -230,7 +242,8 @@
source_file
}
- }
+ };
+ Ok(lrc_sf)
}
/// Allocates a new SourceFile representing a source file from an external
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index e715837..2dd409b 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -859,6 +859,9 @@
}
}
+#[derive(Debug)]
+pub struct OffsetOverflowError;
+
/// A single source in the `SourceMap`.
#[derive(Clone)]
pub struct SourceFile {
@@ -1040,7 +1043,7 @@
name_was_remapped: bool,
unmapped_path: FileName,
mut src: String,
- start_pos: BytePos) -> SourceFile {
+ start_pos: BytePos) -> Result<SourceFile, OffsetOverflowError> {
remove_bom(&mut src);
let src_hash = {
@@ -1054,11 +1057,14 @@
hasher.finish()
};
let end_pos = start_pos.to_usize() + src.len();
+ if end_pos > u32::max_value() as usize {
+ return Err(OffsetOverflowError);
+ }
let (lines, multibyte_chars, non_narrow_chars) =
analyze_source_file::analyze_source_file(&src[..], start_pos);
- SourceFile {
+ Ok(SourceFile {
name,
name_was_remapped,
unmapped_path: Some(unmapped_path),
@@ -1072,7 +1078,7 @@
multibyte_chars,
non_narrow_chars,
name_hash,
- }
+ })
}
/// Returns the `BytePos` of the beginning of the current line.
diff --git a/src/test/codegen/slice-iter-len-eq-zero.rs b/src/test/codegen/slice-iter-len-eq-zero.rs
new file mode 100644
index 0000000..a551683
--- /dev/null
+++ b/src/test/codegen/slice-iter-len-eq-zero.rs
@@ -0,0 +1,14 @@
+// no-system-llvm
+// compile-flags: -O
+#![crate_type = "lib"]
+
+type Demo = [u8; 3];
+
+// CHECK-LABEL: @slice_iter_len_eq_zero
+#[no_mangle]
+pub fn slice_iter_len_eq_zero(y: std::slice::Iter<'_, Demo>) -> bool {
+ // CHECK-NOT: sub
+ // CHECK: %2 = icmp eq i8* %1, %0
+ // CHECK: ret i1 %2
+ y.len() == 0
+}
diff --git a/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs b/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs
index 40e0115..76554ea 100644
--- a/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs
+++ b/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs
@@ -45,7 +45,7 @@
let item = match cx.tcx.hir().get_by_hir_id(id) {
Node::Item(item) => item,
- _ => cx.tcx.hir().expect_item_by_hir_id(cx.tcx.hir().get_parent_item(id)),
+ _ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(id)),
};
if !attr::contains_name(&item.attrs, Symbol::intern("whitelisted_attr")) {
diff --git a/src/test/run-pass/consts/const-enum-cast.rs b/src/test/run-pass/consts/const-enum-cast.rs
index 3b140d1..a3255c2 100644
--- a/src/test/run-pass/consts/const-enum-cast.rs
+++ b/src/test/run-pass/consts/const-enum-cast.rs
@@ -1,9 +1,8 @@
// run-pass
-#![allow(dead_code)]
#![allow(non_upper_case_globals)]
enum A { A1, A2 }
-enum B { B1=0, B2=2 }
+enum B { B1=4, B2=2 }
pub fn main () {
static c1: isize = A::A2 as isize;
@@ -14,4 +13,14 @@
assert_eq!(c2, 2);
assert_eq!(a1, 1);
assert_eq!(a2, 2);
+
+ // Turns out that adding a let-binding generates totally different MIR.
+ static c1_2: isize = { let v = A::A1; v as isize };
+ static c2_2: isize = { let v = B::B1; v as isize };
+ let a1_2 = { let v = A::A1; v as isize };
+ let a2_2 = { let v = B::B1; v as isize };
+ assert_eq!(c1_2, 0);
+ assert_eq!(c2_2, 4);
+ assert_eq!(a1_2, 0);
+ assert_eq!(a2_2, 4);
}