Skip to content

Commit 021a140

Browse files
committed
hir: remove NodeId from Block
1 parent 63b4dd9 commit 021a140

File tree

24 files changed

+121
-135
lines changed

24 files changed

+121
-135
lines changed

src/librustc/hir/lowering.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2804,10 +2804,9 @@ impl<'a> LoweringContext<'a> {
28042804
}
28052805
}
28062806

2807-
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(b.id);
2807+
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(b.id);
28082808

28092809
P(hir::Block {
2810-
id: node_id,
28112810
hir_id,
28122811
stmts: stmts.into(),
28132812
expr,
@@ -3887,11 +3886,10 @@ impl<'a> LoweringContext<'a> {
38873886
// Wrap the `if let` expr in a block.
38883887
let span = els.span;
38893888
let els = P(self.lower_expr(els));
3890-
let LoweredNodeId { node_id, hir_id } = self.next_id();
3889+
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
38913890
let blk = P(hir::Block {
38923891
stmts: hir_vec![],
38933892
expr: Some(els),
3894-
id: node_id,
38953893
hir_id,
38963894
rules: hir::DefaultBlock,
38973895
span,
@@ -4965,12 +4963,11 @@ impl<'a> LoweringContext<'a> {
49654963
stmts: hir::HirVec<hir::Stmt>,
49664964
expr: Option<P<hir::Expr>>,
49674965
) -> hir::Block {
4968-
let LoweredNodeId { node_id, hir_id } = self.next_id();
4966+
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
49694967

49704968
hir::Block {
49714969
stmts,
49724970
expr,
4973-
id: node_id,
49744971
hir_id,
49754972
rules: hir::DefaultBlock,
49764973
span,

src/librustc/hir/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,6 @@ pub struct Block {
822822
/// An expression at the end of the block
823823
/// without a semicolon, if any.
824824
pub expr: Option<P<Expr>>,
825-
pub id: NodeId,
826825
pub hir_id: HirId,
827826
/// Distinguishes between `unsafe { ... }` and `{ ... }`.
828827
pub rules: BlockCheckMode,

src/librustc/ich/impls_hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ impl_stable_hash_for!(struct hir::MacroDef {
415415
impl_stable_hash_for!(struct hir::Block {
416416
stmts,
417417
expr,
418-
id -> _,
419418
hir_id -> _,
420419
rules,
421420
span,

src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
629629
/// Indicates that the value of `blk` will be consumed, meaning either copied or moved
630630
/// depending on its type.
631631
fn walk_block(&mut self, blk: &hir::Block) {
632-
debug!("walk_block(blk.id={})", blk.id);
632+
debug!("walk_block(blk.hir_id={})", blk.hir_id);
633633

634634
for stmt in &blk.stmts {
635635
self.walk_stmt(stmt);

src/librustc/middle/liveness.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
950950
fn propagate_through_block(&mut self, blk: &hir::Block, succ: LiveNode)
951951
-> LiveNode {
952952
if blk.targeted_by_break {
953-
self.break_ln.insert(blk.id, succ);
953+
let node_id = self.ir.tcx.hir().hir_to_node_id(blk.hir_id);
954+
self.break_ln.insert(node_id, succ);
954955
}
955956
let succ = self.propagate_through_opt_expr(blk.expr.as_ref().map(|e| &**e), succ);
956957
blk.stmts.iter().rev().fold(succ, |succ, stmt| {
@@ -1386,7 +1387,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
13861387
}
13871388
}
13881389
debug!("propagate_through_loop: using id for loop body {} {}",
1389-
expr.id, self.ir.tcx.hir().node_to_pretty_string(body.id));
1390+
expr.id, self.ir.tcx.hir().hir_to_pretty_string(body.hir_id));
13901391

13911392

13921393
self.break_ln.insert(expr.id, succ);

src/librustc/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ fn record_var_lifetime(visitor: &mut RegionResolutionVisitor<'_, '_>,
745745
}
746746

747747
fn resolve_block<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, blk: &'tcx hir::Block) {
748-
debug!("resolve_block(blk.id={:?})", blk.id);
748+
debug!("resolve_block(blk.hir_id={:?})", blk.hir_id);
749749

750750
let prev_cx = visitor.cx;
751751

src/librustc/mir/interpret/error.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::{fmt, env};
22

3+
use crate::hir;
34
use crate::hir::map::definitions::DefPathData;
45
use crate::mir;
56
use crate::ty::{self, Ty, layout};
@@ -14,7 +15,6 @@ use crate::ty::query::TyCtxtAt;
1415
use errors::DiagnosticBuilder;
1516

1617
use syntax_pos::{Pos, Span};
17-
use syntax::ast;
1818
use syntax::symbol::Symbol;
1919

2020
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
@@ -50,7 +50,7 @@ pub struct ConstEvalErr<'tcx> {
5050
pub struct FrameInfo<'tcx> {
5151
pub call_site: Span, // this span is in the caller!
5252
pub instance: ty::Instance<'tcx>,
53-
pub lint_root: Option<ast::NodeId>,
53+
pub lint_root: Option<hir::HirId>,
5454
}
5555

5656
impl<'tcx> fmt::Display for FrameInfo<'tcx> {
@@ -98,7 +98,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
9898
pub fn report_as_lint(&self,
9999
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
100100
message: &str,
101-
lint_root: ast::NodeId,
101+
lint_root: hir::HirId,
102102
) -> ErrorHandled {
103103
let lint = self.struct_generic(
104104
tcx,
@@ -118,7 +118,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
118118
&self,
119119
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
120120
message: &str,
121-
lint_root: Option<ast::NodeId>,
121+
lint_root: Option<hir::HirId>,
122122
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
123123
match self.error {
124124
EvalErrorKind::Layout(LayoutError::Unknown(_)) |
@@ -129,15 +129,15 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
129129
}
130130
trace!("reporting const eval failure at {:?}", self.span);
131131
let mut err = if let Some(lint_root) = lint_root {
132-
let node_id = self.stacktrace
132+
let hir_id = self.stacktrace
133133
.iter()
134134
.rev()
135135
.filter_map(|frame| frame.lint_root)
136136
.next()
137137
.unwrap_or(lint_root);
138-
tcx.struct_span_lint_node(
138+
tcx.struct_span_lint_hir(
139139
crate::rustc::lint::builtin::CONST_ERR,
140-
node_id,
140+
hir_id,
141141
tcx.span,
142142
message,
143143
)

src/librustc/mir/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ pub enum Safety {
413413
/// Unsafe because of an unsafe fn
414414
FnUnsafe,
415415
/// Unsafe because of an `unsafe` block
416-
ExplicitUnsafe(ast::NodeId),
416+
ExplicitUnsafe(hir::HirId),
417417
}
418418

419419
impl_stable_hash_for!(struct Mir<'tcx> {
@@ -2098,8 +2098,8 @@ pub struct SourceScopeData {
20982098

20992099
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
21002100
pub struct SourceScopeLocalData {
2101-
/// A NodeId with lint levels equivalent to this scope's lint levels.
2102-
pub lint_root: ast::NodeId,
2101+
/// A HirId with lint levels equivalent to this scope's lint levels.
2102+
pub lint_root: hir::HirId,
21032103
/// The unsafe block that contains this node.
21042104
pub safety: Safety,
21052105
}
@@ -2849,8 +2849,8 @@ pub enum UnsafetyViolationKind {
28492849
General,
28502850
/// Permitted in const fn and regular fns.
28512851
GeneralAndConstFn,
2852-
ExternStatic(ast::NodeId),
2853-
BorrowPacked(ast::NodeId),
2852+
ExternStatic(hir::HirId),
2853+
BorrowPacked(hir::HirId),
28542854
}
28552855

28562856
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
@@ -2867,7 +2867,7 @@ pub struct UnsafetyCheckResult {
28672867
pub violations: Lrc<[UnsafetyViolation]>,
28682868
/// unsafe blocks in this function, along with whether they are used. This is
28692869
/// used for the "unused_unsafe" lint.
2870-
pub unsafe_blocks: Lrc<[(ast::NodeId, bool)]>,
2870+
pub unsafe_blocks: Lrc<[(hir::HirId, bool)]>,
28712871
}
28722872

28732873
/// The layout of generator state

src/librustc/traits/object_safety.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
use super::elaborate_predicates;
1212

13+
use crate::hir;
1314
use crate::hir::def_id::DefId;
1415
use crate::lint;
1516
use crate::traits::{self, Obligation, ObligationCause};
@@ -129,7 +130,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
129130
// It's also hard to get a use site span, so we use the method definition span.
130131
self.lint_node_note(
131132
lint::builtin::WHERE_CLAUSES_OBJECT_SAFETY,
132-
ast::CRATE_NODE_ID,
133+
hir::CRATE_HIR_ID,
133134
*span,
134135
&format!("the trait `{}` cannot be made into an object",
135136
self.item_path_str(trait_def_id)),

src/librustc/ty/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,11 +2859,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
28592859

28602860
pub fn lint_node_note<S: Into<MultiSpan>>(self,
28612861
lint: &'static Lint,
2862-
id: NodeId,
2862+
id: hir::HirId,
28632863
span: S,
28642864
msg: &str,
28652865
note: &str) {
2866-
let mut err = self.struct_span_lint_node(lint, id, span.into(), msg);
2866+
let mut err = self.struct_span_lint_hir(lint, id, span.into(), msg);
28672867
err.note(note);
28682868
err.emit()
28692869
}

0 commit comments

Comments
 (0)