mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-26 22:05:14 +00:00
Auto merge of #58754 - ljedrz:I_hate_NodeIds, r=Zoxc
Remove NodeId from more HIR nodes The next iteration of HirIdification (#57578). Removes `NodeId` from: - [x] `Stmt` - [x] `Local` - [x] `Field` - [x] `AnonConst` - [x] `TraitItem` - [x] `ImplItem` - [x] `TypeBinding` - [x] `Arg` - [x] `TraitRef` - [x] `VisibilityKind` It will most probably break clippy again; I'd appreciate a **delegate** again if/when it is good to go so I can attach a clippy fix later. r? @Zoxc
This commit is contained in:
commit
c1d2d83ca3
@ -878,7 +878,6 @@ pub fn walk_trait_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_item_ref:
|
||||
pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplItem) {
|
||||
// N.B., deliberately force a compilation error if/when new fields are added.
|
||||
let ImplItem {
|
||||
id: _,
|
||||
hir_id: _,
|
||||
ident,
|
||||
ref vis,
|
||||
@ -1106,7 +1105,7 @@ pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
|
||||
}
|
||||
|
||||
pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {
|
||||
if let VisibilityKind::Restricted { ref path, id: _, hir_id } = vis.node {
|
||||
if let VisibilityKind::Restricted { ref path, hir_id } = vis.node {
|
||||
visitor.visit_id(hir_id);
|
||||
visitor.visit_path(path, hir_id)
|
||||
}
|
||||
|
@ -1151,10 +1151,9 @@ impl<'a> LoweringContext<'a> {
|
||||
|
||||
fn lower_ty_binding(&mut self, b: &TypeBinding,
|
||||
itctx: ImplTraitContext<'_>) -> hir::TypeBinding {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(b.id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(b.id);
|
||||
|
||||
hir::TypeBinding {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: b.ident,
|
||||
ty: self.lower_ty(&b.ty, itctx),
|
||||
@ -1982,14 +1981,13 @@ impl<'a> LoweringContext<'a> {
|
||||
let LoweredNodeId { node_id: _, hir_id } = this.next_id();
|
||||
hir::Ty { node: hir::TyKind::Tup(tys), hir_id, span }
|
||||
};
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = this.next_id();
|
||||
|
||||
(
|
||||
hir::GenericArgs {
|
||||
args: hir_vec![GenericArg::Type(mk_tup(this, inputs, span))],
|
||||
bindings: hir_vec![
|
||||
hir::TypeBinding {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: Ident::from_str(FN_OUTPUT_NAME),
|
||||
ty: output
|
||||
@ -2008,7 +2006,7 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
|
||||
fn lower_local(&mut self, l: &Local) -> (hir::Local, SmallVec<[hir::ItemId; 1]>) {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(l.id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(l.id);
|
||||
let mut ids = SmallVec::<[hir::ItemId; 1]>::new();
|
||||
if self.sess.features_untracked().impl_trait_in_bindings {
|
||||
if let Some(ref ty) = l.ty {
|
||||
@ -2018,7 +2016,6 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
let parent_def_id = DefId::local(self.current_hir_id_owner.last().unwrap().0);
|
||||
(hir::Local {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ty: l.ty
|
||||
.as_ref()
|
||||
@ -2045,9 +2042,8 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
|
||||
fn lower_arg(&mut self, arg: &Arg) -> hir::Arg {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(arg.id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(arg.id);
|
||||
hir::Arg {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
pat: self.lower_pat(&arg.pat),
|
||||
}
|
||||
@ -2327,13 +2323,12 @@ impl<'a> LoweringContext<'a> {
|
||||
};
|
||||
|
||||
// "<Output = T>"
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = this.next_id();
|
||||
let future_params = P(hir::GenericArgs {
|
||||
args: hir_vec![],
|
||||
bindings: hir_vec![hir::TypeBinding {
|
||||
ident: Ident::from_str(FN_OUTPUT_NAME),
|
||||
ty: output_ty,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
span,
|
||||
}],
|
||||
@ -2343,13 +2338,12 @@ impl<'a> LoweringContext<'a> {
|
||||
let future_path =
|
||||
this.std_path(span, &["future", "Future"], Some(future_params), false);
|
||||
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = this.next_id();
|
||||
let mut bounds = vec![
|
||||
hir::GenericBound::Trait(
|
||||
hir::PolyTraitRef {
|
||||
trait_ref: hir::TraitRef {
|
||||
path: future_path,
|
||||
ref_id: node_id,
|
||||
hir_ref_id: hir_id,
|
||||
},
|
||||
bound_generic_params: hir_vec![],
|
||||
@ -2719,10 +2713,9 @@ impl<'a> LoweringContext<'a> {
|
||||
hir::QPath::Resolved(None, path) => path.and_then(|path| path),
|
||||
qpath => bug!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
|
||||
};
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(p.ref_id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(p.ref_id);
|
||||
hir::TraitRef {
|
||||
path,
|
||||
ref_id: node_id,
|
||||
hir_ref_id: hir_id,
|
||||
}
|
||||
}
|
||||
@ -2768,10 +2761,9 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
|
||||
fn lower_field(&mut self, f: &Field) -> hir::Field {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||
|
||||
hir::Field {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: f.ident,
|
||||
expr: P(self.lower_expr(&f.expr)),
|
||||
@ -3123,12 +3115,11 @@ impl<'a> LoweringContext<'a> {
|
||||
hir::VisibilityKind::Public => hir::VisibilityKind::Public,
|
||||
hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar),
|
||||
hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
|
||||
hir::VisibilityKind::Restricted { ref path, id: _, hir_id: _ } => {
|
||||
hir::VisibilityKind::Restricted { ref path, hir_id: _ } => {
|
||||
let id = this.next_id();
|
||||
let path = this.renumber_segment_ids(path);
|
||||
hir::VisibilityKind::Restricted {
|
||||
path,
|
||||
id: id.node_id,
|
||||
hir_id: id.hir_id,
|
||||
}
|
||||
}
|
||||
@ -3230,12 +3221,11 @@ impl<'a> LoweringContext<'a> {
|
||||
hir::VisibilityKind::Public => hir::VisibilityKind::Public,
|
||||
hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar),
|
||||
hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
|
||||
hir::VisibilityKind::Restricted { ref path, id: _, hir_id: _ } => {
|
||||
hir::VisibilityKind::Restricted { ref path, hir_id: _ } => {
|
||||
let id = this.next_id();
|
||||
let path = this.renumber_segment_ids(path);
|
||||
hir::VisibilityKind::Restricted {
|
||||
path: path,
|
||||
id: id.node_id,
|
||||
hir_id: id.hir_id,
|
||||
}
|
||||
}
|
||||
@ -3353,7 +3343,6 @@ impl<'a> LoweringContext<'a> {
|
||||
};
|
||||
|
||||
hir::TraitItem {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: i.ident,
|
||||
attrs: self.lower_attrs(&i.attrs),
|
||||
@ -3429,7 +3418,6 @@ impl<'a> LoweringContext<'a> {
|
||||
};
|
||||
|
||||
hir::ImplItem {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: i.ident,
|
||||
attrs: self.lower_attrs(&i.attrs),
|
||||
@ -3813,9 +3801,8 @@ impl<'a> LoweringContext<'a> {
|
||||
|
||||
fn lower_anon_const(&mut self, c: &AnonConst) -> hir::AnonConst {
|
||||
self.with_new_scopes(|this| {
|
||||
let LoweredNodeId { node_id, hir_id } = this.lower_node_id(c.id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = this.lower_node_id(c.id);
|
||||
hir::AnonConst {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
body: this.lower_body(None, |this| this.lower_expr(&c.value)),
|
||||
}
|
||||
@ -4427,9 +4414,8 @@ impl<'a> LoweringContext<'a> {
|
||||
ThinVec::new(),
|
||||
))
|
||||
};
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||
let match_stmt = hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Expr(match_expr),
|
||||
span: head_sp,
|
||||
@ -4456,9 +4442,8 @@ impl<'a> LoweringContext<'a> {
|
||||
|
||||
let body_block = self.with_loop_scope(e.id, |this| this.lower_block(body, false));
|
||||
let body_expr = P(self.expr_block(body_block, ThinVec::new()));
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||
let body_stmt = hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Expr(body_expr),
|
||||
span: body.span,
|
||||
@ -4639,10 +4624,9 @@ impl<'a> LoweringContext<'a> {
|
||||
let mut ids: SmallVec<[hir::Stmt; 1]> = item_ids
|
||||
.into_iter()
|
||||
.map(|item_id| {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||
|
||||
hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Item(item_id),
|
||||
span: s.span,
|
||||
@ -4650,10 +4634,9 @@ impl<'a> LoweringContext<'a> {
|
||||
})
|
||||
.collect();
|
||||
ids.push({
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(s.id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(s.id);
|
||||
|
||||
hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Local(P(l)),
|
||||
span: s.span,
|
||||
@ -4667,12 +4650,11 @@ impl<'a> LoweringContext<'a> {
|
||||
return self.lower_item_id(it)
|
||||
.into_iter()
|
||||
.map(|item_id| {
|
||||
let LoweredNodeId { node_id, hir_id } = id.take()
|
||||
let LoweredNodeId { node_id: _, hir_id } = id.take()
|
||||
.map(|id| self.lower_node_id(id))
|
||||
.unwrap_or_else(|| self.next_id());
|
||||
|
||||
hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Item(item_id),
|
||||
span: s.span,
|
||||
@ -4681,20 +4663,18 @@ impl<'a> LoweringContext<'a> {
|
||||
.collect();
|
||||
}
|
||||
StmtKind::Expr(ref e) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(s.id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(s.id);
|
||||
|
||||
hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Expr(P(self.lower_expr(e))),
|
||||
span: s.span,
|
||||
}
|
||||
},
|
||||
StmtKind::Semi(ref e) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(s.id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(s.id);
|
||||
|
||||
hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Semi(P(self.lower_expr(e))),
|
||||
span: s.span,
|
||||
@ -4739,7 +4719,6 @@ impl<'a> LoweringContext<'a> {
|
||||
ParamMode::Explicit,
|
||||
explicit_owner,
|
||||
)),
|
||||
id: lowered_id.node_id,
|
||||
hir_id: lowered_id.hir_id,
|
||||
}
|
||||
},
|
||||
@ -4809,10 +4788,9 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
|
||||
fn field(&mut self, ident: Ident, expr: P<hir::Expr>, span: Span) -> hir::Field {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||
|
||||
hir::Field {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident,
|
||||
span,
|
||||
@ -4912,22 +4890,20 @@ impl<'a> LoweringContext<'a> {
|
||||
pat: P<hir::Pat>,
|
||||
source: hir::LocalSource,
|
||||
) -> hir::Stmt {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||
|
||||
let local = hir::Local {
|
||||
pat,
|
||||
ty: None,
|
||||
init: ex,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
span: sp,
|
||||
attrs: ThinVec::new(),
|
||||
source,
|
||||
};
|
||||
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||
hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Local(P(local)),
|
||||
span: sp
|
||||
@ -5075,7 +5051,6 @@ impl<'a> LoweringContext<'a> {
|
||||
bound_generic_params: hir::HirVec::new(),
|
||||
trait_ref: hir::TraitRef {
|
||||
path: path.and_then(|path| path),
|
||||
ref_id: id.node_id,
|
||||
hir_ref_id: id.hir_id,
|
||||
},
|
||||
span,
|
||||
|
@ -386,7 +386,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'hir TraitItem) {
|
||||
debug_assert_eq!(ti.hir_id.owner,
|
||||
self.definitions.opt_def_index(ti.id).unwrap());
|
||||
self.definitions.opt_def_index(self.hir_to_node_id[&ti.hir_id]).unwrap());
|
||||
self.with_dep_node_owner(ti.hir_id.owner, ti, |this| {
|
||||
this.insert(ti.span, ti.hir_id, Node::TraitItem(ti));
|
||||
|
||||
@ -398,7 +398,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'hir ImplItem) {
|
||||
debug_assert_eq!(ii.hir_id.owner,
|
||||
self.definitions.opt_def_index(ii.id).unwrap());
|
||||
self.definitions.opt_def_index(self.hir_to_node_id[&ii.hir_id]).unwrap());
|
||||
self.with_dep_node_owner(ii.hir_id.owner, ii, |this| {
|
||||
this.insert(ii.span, ii.hir_id, Node::ImplItem(ii));
|
||||
|
||||
|
@ -349,7 +349,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
Node::TraitItem(item) => {
|
||||
let def_id = self.local_def_id(item.id);
|
||||
let def_id = self.local_def_id_from_hir_id(item.hir_id);
|
||||
match item.node {
|
||||
TraitItemKind::Const(..) => Some(Def::AssociatedConst(def_id)),
|
||||
TraitItemKind::Method(..) => Some(Def::Method(def_id)),
|
||||
@ -357,7 +357,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
Node::ImplItem(item) => {
|
||||
let def_id = self.local_def_id(item.id);
|
||||
let def_id = self.local_def_id_from_hir_id(item.hir_id);
|
||||
match item.node {
|
||||
ImplItemKind::Const(..) => Some(Def::AssociatedConst(def_id)),
|
||||
ImplItemKind::Method(..) => Some(Def::Method(def_id)),
|
||||
@ -387,7 +387,7 @@ impl<'hir> Map<'hir> {
|
||||
Node::Block(_) |
|
||||
Node::Crate => None,
|
||||
Node::Local(local) => {
|
||||
Some(Def::Local(local.id))
|
||||
Some(Def::Local(self.hir_to_node_id(local.hir_id)))
|
||||
}
|
||||
Node::MacroDef(macro_def) => {
|
||||
Some(Def::Macro(self.local_def_id_from_hir_id(macro_def.hir_id),
|
||||
|
@ -1162,7 +1162,6 @@ impl UnOp {
|
||||
/// A statement.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
pub struct Stmt {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub node: StmtKind,
|
||||
pub span: Span,
|
||||
@ -1170,7 +1169,7 @@ pub struct Stmt {
|
||||
|
||||
impl fmt::Debug for Stmt {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "stmt({}: {})", self.id,
|
||||
write!(f, "stmt({}: {})", self.hir_id,
|
||||
print::to_string(print::NO_ANN, |s| s.print_stmt(self)))
|
||||
}
|
||||
}
|
||||
@ -1208,7 +1207,6 @@ pub struct Local {
|
||||
pub ty: Option<P<Ty>>,
|
||||
/// Initializer expression to set the value, if any.
|
||||
pub init: Option<P<Expr>>,
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub span: Span,
|
||||
pub attrs: ThinVec<Attribute>,
|
||||
@ -1231,7 +1229,6 @@ pub enum Guard {
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct Field {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub ident: Ident,
|
||||
pub expr: P<Expr>,
|
||||
@ -1325,7 +1322,6 @@ impl BodyOwnerKind {
|
||||
/// explicit discriminant values for enum variants.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct AnonConst {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub body: BodyId,
|
||||
}
|
||||
@ -1672,7 +1668,6 @@ pub struct TraitItemId {
|
||||
/// signature) or provided (meaning it has a default implementation).
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct TraitItem {
|
||||
pub id: NodeId,
|
||||
pub ident: Ident,
|
||||
pub hir_id: HirId,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
@ -1715,7 +1710,6 @@ pub struct ImplItemId {
|
||||
/// Represents anything within an `impl` block
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct ImplItem {
|
||||
pub id: NodeId,
|
||||
pub ident: Ident,
|
||||
pub hir_id: HirId,
|
||||
pub vis: Visibility,
|
||||
@ -1743,7 +1737,6 @@ pub enum ImplItemKind {
|
||||
// Bind a type to an associated type: `A=Foo`.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct TypeBinding {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub ident: Ident,
|
||||
pub ty: P<Ty>,
|
||||
@ -1859,7 +1852,6 @@ pub struct InlineAsm {
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct Arg {
|
||||
pub pat: P<Pat>,
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
}
|
||||
|
||||
@ -2070,7 +2062,6 @@ pub enum UseKind {
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct TraitRef {
|
||||
pub path: Path,
|
||||
pub ref_id: NodeId,
|
||||
pub hir_ref_id: HirId,
|
||||
}
|
||||
|
||||
@ -2105,7 +2096,7 @@ pub type Visibility = Spanned<VisibilityKind>;
|
||||
pub enum VisibilityKind {
|
||||
Public,
|
||||
Crate(CrateSugar),
|
||||
Restricted { path: P<Path>, id: NodeId, hir_id: HirId },
|
||||
Restricted { path: P<Path>, hir_id: HirId },
|
||||
Inherited,
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ pub enum AnnNode<'a> {
|
||||
Name(&'a ast::Name),
|
||||
Block(&'a hir::Block),
|
||||
Item(&'a hir::Item),
|
||||
SubItem(ast::NodeId),
|
||||
SubItem(hir::HirId),
|
||||
Expr(&'a hir::Expr),
|
||||
Pat(&'a hir::Pat),
|
||||
}
|
||||
@ -927,7 +927,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
|
||||
pub fn print_trait_item(&mut self, ti: &hir::TraitItem) -> io::Result<()> {
|
||||
self.ann.pre(self, AnnNode::SubItem(ti.id))?;
|
||||
self.ann.pre(self, AnnNode::SubItem(ti.hir_id))?;
|
||||
self.hardbreak_if_not_bol()?;
|
||||
self.maybe_print_comment(ti.span.lo())?;
|
||||
self.print_outer_attributes(&ti.attrs)?;
|
||||
@ -959,11 +959,11 @@ impl<'a> State<'a> {
|
||||
default.as_ref().map(|ty| &**ty))?;
|
||||
}
|
||||
}
|
||||
self.ann.post(self, AnnNode::SubItem(ti.id))
|
||||
self.ann.post(self, AnnNode::SubItem(ti.hir_id))
|
||||
}
|
||||
|
||||
pub fn print_impl_item(&mut self, ii: &hir::ImplItem) -> io::Result<()> {
|
||||
self.ann.pre(self, AnnNode::SubItem(ii.id))?;
|
||||
self.ann.pre(self, AnnNode::SubItem(ii.hir_id))?;
|
||||
self.hardbreak_if_not_bol()?;
|
||||
self.maybe_print_comment(ii.span.lo())?;
|
||||
self.print_outer_attributes(&ii.attrs)?;
|
||||
@ -989,7 +989,7 @@ impl<'a> State<'a> {
|
||||
self.print_associated_type(ii.ident, Some(bounds), None)?;
|
||||
}
|
||||
}
|
||||
self.ann.post(self, AnnNode::SubItem(ii.id))
|
||||
self.ann.post(self, AnnNode::SubItem(ii.hir_id))
|
||||
}
|
||||
|
||||
pub fn print_stmt(&mut self, st: &hir::Stmt) -> io::Result<()> {
|
||||
|
@ -294,7 +294,6 @@ impl_stable_hash_for!(struct hir::MethodSig {
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(struct hir::TypeBinding {
|
||||
id,
|
||||
hir_id,
|
||||
ident -> (ident.name),
|
||||
ty,
|
||||
@ -386,8 +385,7 @@ impl_stable_hash_for!(enum hir::ImplicitSelfKind {
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(struct hir::TraitRef {
|
||||
// Don't hash the ref_id. It is tracked via the thing it is used to access
|
||||
ref_id -> _,
|
||||
// Don't hash the hir_ref_id. It is tracked via the thing it is used to access
|
||||
hir_ref_id -> _,
|
||||
path,
|
||||
});
|
||||
@ -495,7 +493,6 @@ impl_stable_hash_for!(enum hir::UnOp {
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(struct hir::Stmt {
|
||||
id,
|
||||
hir_id,
|
||||
node,
|
||||
span,
|
||||
@ -506,7 +503,6 @@ impl_stable_hash_for!(struct hir::Local {
|
||||
pat,
|
||||
ty,
|
||||
init,
|
||||
id,
|
||||
hir_id,
|
||||
span,
|
||||
attrs,
|
||||
@ -525,7 +521,6 @@ impl_stable_hash_for!(enum hir::Guard {
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(struct hir::Field {
|
||||
id -> _,
|
||||
hir_id -> _,
|
||||
ident,
|
||||
expr,
|
||||
@ -549,7 +544,6 @@ impl_stable_hash_for!(enum hir::UnsafeSource {
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(struct hir::AnonConst {
|
||||
id,
|
||||
hir_id,
|
||||
body
|
||||
});
|
||||
@ -673,7 +667,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem {
|
||||
hcx: &mut StableHashingContext<'a>,
|
||||
hasher: &mut StableHasher<W>) {
|
||||
let hir::TraitItem {
|
||||
id: _,
|
||||
hir_id: _,
|
||||
ident,
|
||||
ref attrs,
|
||||
@ -708,7 +701,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItem {
|
||||
hcx: &mut StableHashingContext<'a>,
|
||||
hasher: &mut StableHasher<W>) {
|
||||
let hir::ImplItem {
|
||||
id: _,
|
||||
hir_id: _,
|
||||
ident,
|
||||
ref vis,
|
||||
@ -756,9 +748,8 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::VisibilityKind {
|
||||
hir::VisibilityKind::Crate(sugar) => {
|
||||
sugar.hash_stable(hcx, hasher);
|
||||
}
|
||||
hir::VisibilityKind::Restricted { ref path, id, hir_id } => {
|
||||
hir::VisibilityKind::Restricted { ref path, hir_id } => {
|
||||
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
|
||||
id.hash_stable(hcx, hasher);
|
||||
hir_id.hash_stable(hcx, hasher);
|
||||
});
|
||||
path.hash_stable(hcx, hasher);
|
||||
@ -962,7 +953,6 @@ impl_stable_hash_for!(enum hir::StmtKind {
|
||||
|
||||
impl_stable_hash_for!(struct hir::Arg {
|
||||
pat,
|
||||
id,
|
||||
hir_id
|
||||
});
|
||||
|
||||
|
@ -729,8 +729,7 @@ impl<'a, 'tcx> LintContext<'tcx> for LateContext<'a, 'tcx> {
|
||||
match span {
|
||||
Some(s) => self.tcx.struct_span_lint_hir(lint, hir_id, s, msg),
|
||||
None => {
|
||||
let node_id = self.tcx.hir().hir_to_node_id(hir_id); // FIXME(@ljedrz): remove later
|
||||
self.tcx.struct_lint_node(lint, node_id, msg)
|
||||
self.tcx.struct_lint_node(lint, hir_id, msg)
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -793,11 +792,11 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
|
||||
run_lints!(self, exit_lint_attrs, attrs);
|
||||
}
|
||||
|
||||
fn with_param_env<F>(&mut self, id: ast::NodeId, f: F)
|
||||
fn with_param_env<F>(&mut self, id: hir::HirId, f: F)
|
||||
where F: FnOnce(&mut Self),
|
||||
{
|
||||
let old_param_env = self.param_env;
|
||||
self.param_env = self.tcx.param_env(self.tcx.hir().local_def_id(id));
|
||||
self.param_env = self.tcx.param_env(self.tcx.hir().local_def_id_from_hir_id(id));
|
||||
f(self);
|
||||
self.param_env = old_param_env;
|
||||
}
|
||||
@ -841,7 +840,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
|
||||
let generics = self.generics.take();
|
||||
self.generics = it.node.generics();
|
||||
self.with_lint_attrs(it.hir_id, &it.attrs, |cx| {
|
||||
cx.with_param_env(it.id, |cx| {
|
||||
cx.with_param_env(it.hir_id, |cx| {
|
||||
run_lints!(cx, check_item, it);
|
||||
hir_visit::walk_item(cx, it);
|
||||
run_lints!(cx, check_item_post, it);
|
||||
@ -852,7 +851,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
|
||||
|
||||
fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem) {
|
||||
self.with_lint_attrs(it.hir_id, &it.attrs, |cx| {
|
||||
cx.with_param_env(it.id, |cx| {
|
||||
cx.with_param_env(it.hir_id, |cx| {
|
||||
run_lints!(cx, check_foreign_item, it);
|
||||
hir_visit::walk_foreign_item(cx, it);
|
||||
run_lints!(cx, check_foreign_item_post, it);
|
||||
@ -983,7 +982,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
|
||||
let generics = self.generics.take();
|
||||
self.generics = Some(&trait_item.generics);
|
||||
self.with_lint_attrs(trait_item.hir_id, &trait_item.attrs, |cx| {
|
||||
cx.with_param_env(trait_item.id, |cx| {
|
||||
cx.with_param_env(trait_item.hir_id, |cx| {
|
||||
run_lints!(cx, check_trait_item, trait_item);
|
||||
hir_visit::walk_trait_item(cx, trait_item);
|
||||
run_lints!(cx, check_trait_item_post, trait_item);
|
||||
@ -996,7 +995,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
|
||||
let generics = self.generics.take();
|
||||
self.generics = Some(&impl_item.generics);
|
||||
self.with_lint_attrs(impl_item.hir_id, &impl_item.attrs, |cx| {
|
||||
cx.with_param_env(impl_item.id, |cx| {
|
||||
cx.with_param_env(impl_item.hir_id, |cx| {
|
||||
run_lints!(cx, check_impl_item, impl_item);
|
||||
hir_visit::walk_impl_item(cx, impl_item);
|
||||
run_lints!(cx, check_impl_item_post, impl_item);
|
||||
|
@ -26,8 +26,8 @@ use syntax_pos;
|
||||
// function, then we should explore its block to check for codes that
|
||||
// may need to be marked as live.
|
||||
fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
node_id: ast::NodeId) -> bool {
|
||||
match tcx.hir().find(node_id) {
|
||||
hir_id: hir::HirId) -> bool {
|
||||
match tcx.hir().find_by_hir_id(hir_id) {
|
||||
Some(Node::Item(..)) |
|
||||
Some(Node::ImplItem(..)) |
|
||||
Some(Node::ForeignItem(..)) |
|
||||
@ -39,33 +39,33 @@ fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
struct MarkSymbolVisitor<'a, 'tcx: 'a> {
|
||||
worklist: Vec<ast::NodeId>,
|
||||
worklist: Vec<hir::HirId>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
tables: &'a ty::TypeckTables<'tcx>,
|
||||
live_symbols: FxHashSet<ast::NodeId>,
|
||||
live_symbols: FxHashSet<hir::HirId>,
|
||||
repr_has_repr_c: bool,
|
||||
in_pat: bool,
|
||||
inherited_pub_visibility: bool,
|
||||
ignore_variant_stack: Vec<DefId>,
|
||||
// maps from tuple struct constructors to tuple struct items
|
||||
struct_constructors: FxHashMap<ast::NodeId, ast::NodeId>,
|
||||
struct_constructors: FxHashMap<hir::HirId, hir::HirId>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||
fn check_def_id(&mut self, def_id: DefId) {
|
||||
if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
|
||||
if should_explore(self.tcx, node_id) ||
|
||||
self.struct_constructors.contains_key(&node_id) {
|
||||
self.worklist.push(node_id);
|
||||
if let Some(hir_id) = self.tcx.hir().as_local_hir_id(def_id) {
|
||||
if should_explore(self.tcx, hir_id) ||
|
||||
self.struct_constructors.contains_key(&hir_id) {
|
||||
self.worklist.push(hir_id);
|
||||
}
|
||||
self.live_symbols.insert(node_id);
|
||||
self.live_symbols.insert(hir_id);
|
||||
}
|
||||
}
|
||||
|
||||
fn insert_def_id(&mut self, def_id: DefId) {
|
||||
if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
|
||||
debug_assert!(!should_explore(self.tcx, node_id));
|
||||
self.live_symbols.insert(node_id);
|
||||
if let Some(hir_id) = self.tcx.hir().as_local_hir_id(def_id) {
|
||||
debug_assert!(!should_explore(self.tcx, hir_id));
|
||||
self.live_symbols.insert(hir_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||
// tuple struct constructor function
|
||||
let id = self.struct_constructors.get(&id).cloned().unwrap_or(id);
|
||||
|
||||
if let Some(node) = self.tcx.hir().find(id) {
|
||||
if let Some(node) = self.tcx.hir().find_by_hir_id(id) {
|
||||
self.live_symbols.insert(id);
|
||||
self.visit_node(node);
|
||||
}
|
||||
@ -217,7 +217,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
|
||||
let live_fields = def.fields().iter().filter(|f| {
|
||||
has_repr_c || inherited_pub_visibility || f.vis.node.is_pub()
|
||||
});
|
||||
self.live_symbols.extend(live_fields.map(|f| f.id));
|
||||
self.live_symbols.extend(live_fields.map(|f| f.hir_id));
|
||||
|
||||
intravisit::walk_struct_def(self, def);
|
||||
}
|
||||
@ -285,7 +285,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>,
|
||||
id: ast::NodeId,
|
||||
id: hir::HirId,
|
||||
attrs: &[ast::Attribute]) -> bool {
|
||||
if attr::contains_name(attrs, "lang") {
|
||||
return true;
|
||||
@ -306,7 +306,7 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>,
|
||||
return true;
|
||||
}
|
||||
|
||||
let def_id = tcx.hir().local_def_id(id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(id);
|
||||
let cg_attrs = tcx.codegen_fn_attrs(def_id);
|
||||
|
||||
// #[used], #[no_mangle], #[export_name], etc also keeps the item alive
|
||||
@ -333,25 +333,25 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>,
|
||||
// 2) We are not sure to be live or not
|
||||
// * Implementation of a trait method
|
||||
struct LifeSeeder<'k, 'tcx: 'k> {
|
||||
worklist: Vec<ast::NodeId>,
|
||||
worklist: Vec<hir::HirId>,
|
||||
krate: &'k hir::Crate,
|
||||
tcx: TyCtxt<'k, 'tcx, 'tcx>,
|
||||
// see `MarkSymbolVisitor::struct_constructors`
|
||||
struct_constructors: FxHashMap<ast::NodeId, ast::NodeId>,
|
||||
struct_constructors: FxHashMap<hir::HirId, hir::HirId>,
|
||||
}
|
||||
|
||||
impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
let allow_dead_code = has_allow_dead_code_or_lang_attr(self.tcx,
|
||||
item.id,
|
||||
item.hir_id,
|
||||
&item.attrs);
|
||||
if allow_dead_code {
|
||||
self.worklist.push(item.id);
|
||||
self.worklist.push(item.hir_id);
|
||||
}
|
||||
match item.node {
|
||||
hir::ItemKind::Enum(ref enum_def, _) if allow_dead_code => {
|
||||
self.worklist.extend(enum_def.variants.iter()
|
||||
.map(|variant| variant.node.data.id()));
|
||||
.map(|variant| variant.node.data.hir_id()));
|
||||
}
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
for trait_item_ref in trait_item_refs {
|
||||
@ -360,9 +360,9 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
|
||||
hir::TraitItemKind::Const(_, Some(_)) |
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => {
|
||||
if has_allow_dead_code_or_lang_attr(self.tcx,
|
||||
trait_item.id,
|
||||
trait_item.hir_id,
|
||||
&trait_item.attrs) {
|
||||
self.worklist.push(trait_item.id);
|
||||
self.worklist.push(trait_item.hir_id);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
@ -374,14 +374,14 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
|
||||
let impl_item = self.krate.impl_item(impl_item_ref.id);
|
||||
if opt_trait.is_some() ||
|
||||
has_allow_dead_code_or_lang_attr(self.tcx,
|
||||
impl_item.id,
|
||||
impl_item.hir_id,
|
||||
&impl_item.attrs) {
|
||||
self.worklist.push(impl_item_ref.id.node_id);
|
||||
self.worklist.push(self.tcx.hir().node_to_hir_id(impl_item_ref.id.node_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Struct(ref variant_data, _) => {
|
||||
self.struct_constructors.insert(variant_data.id(), item.id);
|
||||
self.struct_constructors.insert(variant_data.hir_id(), item.hir_id);
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
@ -400,16 +400,16 @@ fn create_and_seed_worklist<'a, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
access_levels: &privacy::AccessLevels,
|
||||
krate: &hir::Crate,
|
||||
) -> (Vec<ast::NodeId>, FxHashMap<ast::NodeId, ast::NodeId>) {
|
||||
) -> (Vec<hir::HirId>, FxHashMap<hir::HirId, hir::HirId>) {
|
||||
let worklist = access_levels.map.iter().filter_map(|(&id, level)| {
|
||||
if level >= &privacy::AccessLevel::Reachable {
|
||||
Some(id)
|
||||
Some(tcx.hir().node_to_hir_id(id))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}).chain(
|
||||
// Seed entry point
|
||||
tcx.entry_fn(LOCAL_CRATE).map(|(def_id, _)| tcx.hir().as_local_node_id(def_id).unwrap())
|
||||
tcx.entry_fn(LOCAL_CRATE).map(|(def_id, _)| tcx.hir().as_local_hir_id(def_id).unwrap())
|
||||
).collect::<Vec<_>>();
|
||||
|
||||
// Seed implemented trait items
|
||||
@ -427,7 +427,7 @@ fn create_and_seed_worklist<'a, 'tcx>(
|
||||
fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
access_levels: &privacy::AccessLevels,
|
||||
krate: &hir::Crate)
|
||||
-> FxHashSet<ast::NodeId> {
|
||||
-> FxHashSet<hir::HirId> {
|
||||
let (worklist, struct_constructors) = create_and_seed_worklist(tcx, access_levels, krate);
|
||||
let mut symbol_visitor = MarkSymbolVisitor {
|
||||
worklist,
|
||||
@ -446,7 +446,7 @@ fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
struct DeadVisitor<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
live_symbols: FxHashSet<ast::NodeId>,
|
||||
live_symbols: FxHashSet<hir::HirId>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||
@ -461,33 +461,33 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||
| hir::ItemKind::Union(..) => true,
|
||||
_ => false
|
||||
};
|
||||
should_warn && !self.symbol_is_live(item.id)
|
||||
should_warn && !self.symbol_is_live(item.hir_id)
|
||||
}
|
||||
|
||||
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
|
||||
let field_type = self.tcx.type_of(self.tcx.hir().local_def_id(field.id));
|
||||
!field.is_positional()
|
||||
&& !self.symbol_is_live(field.id)
|
||||
&& !self.symbol_is_live(field.hir_id)
|
||||
&& !field_type.is_phantom_data()
|
||||
&& !has_allow_dead_code_or_lang_attr(self.tcx, field.id, &field.attrs)
|
||||
&& !has_allow_dead_code_or_lang_attr(self.tcx, field.hir_id, &field.attrs)
|
||||
}
|
||||
|
||||
fn should_warn_about_variant(&mut self, variant: &hir::VariantKind) -> bool {
|
||||
!self.symbol_is_live(variant.data.id())
|
||||
!self.symbol_is_live(variant.data.hir_id())
|
||||
&& !has_allow_dead_code_or_lang_attr(self.tcx,
|
||||
variant.data.id(),
|
||||
variant.data.hir_id(),
|
||||
&variant.attrs)
|
||||
}
|
||||
|
||||
fn should_warn_about_foreign_item(&mut self, fi: &hir::ForeignItem) -> bool {
|
||||
!self.symbol_is_live(fi.id)
|
||||
&& !has_allow_dead_code_or_lang_attr(self.tcx, fi.id, &fi.attrs)
|
||||
!self.symbol_is_live(fi.hir_id)
|
||||
&& !has_allow_dead_code_or_lang_attr(self.tcx, fi.hir_id, &fi.attrs)
|
||||
}
|
||||
|
||||
// id := node id of an item's definition.
|
||||
// id := HIR id of an item's definition.
|
||||
fn symbol_is_live(
|
||||
&mut self,
|
||||
id: ast::NodeId,
|
||||
id: hir::HirId,
|
||||
) -> bool {
|
||||
if self.live_symbols.contains(&id) {
|
||||
return true;
|
||||
@ -496,12 +496,12 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||
// This is done to handle the case where, for example, the static
|
||||
// method of a private type is used, but the type itself is never
|
||||
// called directly.
|
||||
let def_id = self.tcx.hir().local_def_id(id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(id);
|
||||
let inherent_impls = self.tcx.inherent_impls(def_id);
|
||||
for &impl_did in inherent_impls.iter() {
|
||||
for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] {
|
||||
if let Some(item_node_id) = self.tcx.hir().as_local_node_id(item_did) {
|
||||
if self.live_symbols.contains(&item_node_id) {
|
||||
if let Some(item_hir_id) = self.tcx.hir().as_local_hir_id(item_did) {
|
||||
if self.live_symbols.contains(&item_hir_id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -511,18 +511,18 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn warn_dead_code(&mut self,
|
||||
id: ast::NodeId,
|
||||
id: hir::HirId,
|
||||
span: syntax_pos::Span,
|
||||
name: ast::Name,
|
||||
node_type: &str,
|
||||
participle: &str) {
|
||||
if !name.as_str().starts_with("_") {
|
||||
self.tcx
|
||||
.lint_node(lint::builtin::DEAD_CODE,
|
||||
id,
|
||||
span,
|
||||
&format!("{} is never {}: `{}`",
|
||||
node_type, participle, name));
|
||||
.lint_hir(lint::builtin::DEAD_CODE,
|
||||
id,
|
||||
span,
|
||||
&format!("{} is never {}: `{}`",
|
||||
node_type, participle, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -555,7 +555,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
||||
_ => "used"
|
||||
};
|
||||
self.warn_dead_code(
|
||||
item.id,
|
||||
item.hir_id,
|
||||
span,
|
||||
item.ident.name,
|
||||
item.node.descriptive_variant(),
|
||||
@ -572,7 +572,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
||||
g: &'tcx hir::Generics,
|
||||
id: hir::HirId) {
|
||||
if self.should_warn_about_variant(&variant.node) {
|
||||
self.warn_dead_code(variant.node.data.id(), variant.span, variant.node.ident.name,
|
||||
self.warn_dead_code(variant.node.data.hir_id(), variant.span, variant.node.ident.name,
|
||||
"variant", "constructed");
|
||||
} else {
|
||||
intravisit::walk_variant(self, variant, g, id);
|
||||
@ -581,7 +581,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
||||
|
||||
fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem) {
|
||||
if self.should_warn_about_foreign_item(fi) {
|
||||
self.warn_dead_code(fi.id, fi.span, fi.ident.name,
|
||||
self.warn_dead_code(fi.hir_id, fi.span, fi.ident.name,
|
||||
fi.node.descriptive_variant(), "used");
|
||||
}
|
||||
intravisit::walk_foreign_item(self, fi);
|
||||
@ -589,7 +589,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
||||
|
||||
fn visit_struct_field(&mut self, field: &'tcx hir::StructField) {
|
||||
if self.should_warn_about_field(&field) {
|
||||
self.warn_dead_code(field.id, field.span, field.ident.name, "field", "used");
|
||||
self.warn_dead_code(field.hir_id, field.span, field.ident.name, "field", "used");
|
||||
}
|
||||
intravisit::walk_struct_field(self, field);
|
||||
}
|
||||
@ -597,8 +597,8 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Const(_, body_id) => {
|
||||
if !self.symbol_is_live(impl_item.id) {
|
||||
self.warn_dead_code(impl_item.id,
|
||||
if !self.symbol_is_live(impl_item.hir_id) {
|
||||
self.warn_dead_code(impl_item.hir_id,
|
||||
impl_item.span,
|
||||
impl_item.ident.name,
|
||||
"associated const",
|
||||
@ -607,9 +607,10 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
||||
self.visit_nested_body(body_id)
|
||||
}
|
||||
hir::ImplItemKind::Method(_, body_id) => {
|
||||
if !self.symbol_is_live(impl_item.id) {
|
||||
if !self.symbol_is_live(impl_item.hir_id) {
|
||||
let span = self.tcx.sess.source_map().def_span(impl_item.span);
|
||||
self.warn_dead_code(impl_item.id, span, impl_item.ident.name, "method", "used");
|
||||
self.warn_dead_code(impl_item.hir_id, span, impl_item.ident.name, "method",
|
||||
"used");
|
||||
}
|
||||
self.visit_nested_body(body_id)
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
impl_item: &hir::ImplItem,
|
||||
impl_src: DefId) -> bool {
|
||||
let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id());
|
||||
let generics = tcx.generics_of(tcx.hir().local_def_id(impl_item.id));
|
||||
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(impl_item.hir_id));
|
||||
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
|
||||
return true
|
||||
}
|
||||
|
@ -781,7 +781,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
Method(ref sig, _) => {
|
||||
let tcx = self.tcx;
|
||||
self.visit_early_late(
|
||||
Some(tcx.hir().get_parent(trait_item.id)),
|
||||
Some(tcx.hir().get_parent_item(trait_item.hir_id)),
|
||||
&sig.decl,
|
||||
&trait_item.generics,
|
||||
|this| intravisit::walk_trait_item(this, trait_item),
|
||||
@ -833,7 +833,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
Method(ref sig, _) => {
|
||||
let tcx = self.tcx;
|
||||
self.visit_early_late(
|
||||
Some(tcx.hir().get_parent(impl_item.id)),
|
||||
Some(tcx.hir().get_parent_item(impl_item.hir_id)),
|
||||
&sig.decl,
|
||||
&impl_item.generics,
|
||||
|this| intravisit::walk_impl_item(this, impl_item),
|
||||
@ -1685,7 +1685,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
/// ordering is not important there.
|
||||
fn visit_early_late<F>(
|
||||
&mut self,
|
||||
parent_id: Option<ast::NodeId>,
|
||||
parent_id: Option<hir::HirId>,
|
||||
decl: &'tcx hir::FnDecl,
|
||||
generics: &'tcx hir::Generics,
|
||||
walk: F,
|
||||
@ -1697,7 +1697,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
// 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(parent_id);
|
||||
let parent = self.tcx.hir().expect_item_by_hir_id(parent_id);
|
||||
if sub_items_have_self_param(&parent.node) {
|
||||
index += 1; // Self comes before lifetimes
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ use crate::middle::privacy::AccessLevels;
|
||||
use crate::session::{DiagnosticMessageId, Session};
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::{Span, MultiSpan};
|
||||
use syntax::ast;
|
||||
use syntax::ast::Attribute;
|
||||
use syntax::errors::Applicability;
|
||||
use syntax::feature_gate::{GateIssue, emit_feature_err};
|
||||
@ -356,7 +355,8 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
|
||||
let impl_def_id = self.tcx.hir().local_def_id(self.tcx.hir().get_parent(ii.id));
|
||||
let impl_def_id = self.tcx.hir().local_def_id_from_hir_id(
|
||||
self.tcx.hir().get_parent_item(ii.hir_id));
|
||||
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
|
||||
self.check_missing_stability(ii.hir_id, ii.span, "item");
|
||||
}
|
||||
@ -922,8 +922,8 @@ fn unnecessary_stable_feature_lint<'a, 'tcx>(
|
||||
feature: Symbol,
|
||||
since: Symbol
|
||||
) {
|
||||
tcx.lint_node(lint::builtin::STABLE_FEATURES,
|
||||
ast::CRATE_NODE_ID,
|
||||
tcx.lint_hir(lint::builtin::STABLE_FEATURES,
|
||||
hir::CRATE_HIR_ID,
|
||||
span,
|
||||
&format!("the feature `{}` has been stable since {} and no longer requires \
|
||||
an attribute to enable", feature, since));
|
||||
|
@ -334,9 +334,9 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(
|
||||
FutureCompatOverlapErrorKind::Issue33140 =>
|
||||
lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS,
|
||||
};
|
||||
tcx.struct_span_lint_node(
|
||||
tcx.struct_span_lint_hir(
|
||||
lint,
|
||||
tcx.hir().as_local_node_id(impl_def_id).unwrap(),
|
||||
tcx.hir().as_local_hir_id(impl_def_id).unwrap(),
|
||||
impl_span,
|
||||
&msg)
|
||||
} else {
|
||||
|
@ -65,7 +65,7 @@ use std::sync::mpsc;
|
||||
use std::sync::Arc;
|
||||
use std::marker::PhantomData;
|
||||
use rustc_target::spec::abi;
|
||||
use syntax::ast::{self, NodeId};
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::source_map::MultiSpan;
|
||||
use syntax::edition::Edition;
|
||||
@ -2836,14 +2836,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
self.struct_span_lint_hir(lint, hir_id, span.into(), msg).emit()
|
||||
}
|
||||
|
||||
pub fn lint_node<S: Into<MultiSpan>>(self,
|
||||
lint: &'static Lint,
|
||||
id: NodeId,
|
||||
span: S,
|
||||
msg: &str) {
|
||||
self.struct_span_lint_node(lint, id, span.into(), msg).emit()
|
||||
}
|
||||
|
||||
pub fn lint_hir_note<S: Into<MultiSpan>>(self,
|
||||
lint: &'static Lint,
|
||||
hir_id: HirId,
|
||||
@ -2866,7 +2858,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
err.emit()
|
||||
}
|
||||
|
||||
pub fn lint_level_at_node(self, lint: &'static Lint, mut id: NodeId)
|
||||
pub fn lint_level_at_node(self, lint: &'static Lint, mut id: hir::HirId)
|
||||
-> (lint::Level, lint::LintSource)
|
||||
{
|
||||
// Right now we insert a `with_ignore` node in the dep graph here to
|
||||
@ -2880,11 +2872,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
self.dep_graph.with_ignore(|| {
|
||||
let sets = self.lint_levels(LOCAL_CRATE);
|
||||
loop {
|
||||
let hir_id = self.hir().definitions().node_to_hir_id(id);
|
||||
if let Some(pair) = sets.level_and_source(lint, hir_id, self.sess) {
|
||||
if let Some(pair) = sets.level_and_source(lint, id, self.sess) {
|
||||
return pair
|
||||
}
|
||||
let next = self.hir().get_parent_node(id);
|
||||
let next = self.hir().get_parent_node_by_hir_id(id);
|
||||
if next == id {
|
||||
bug!("lint traversal reached the root of the crate");
|
||||
}
|
||||
@ -2900,23 +2891,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
msg: &str)
|
||||
-> DiagnosticBuilder<'tcx>
|
||||
{
|
||||
let node_id = self.hir().hir_to_node_id(hir_id);
|
||||
let (level, src) = self.lint_level_at_node(lint, node_id);
|
||||
let (level, src) = self.lint_level_at_node(lint, hir_id);
|
||||
lint::struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg)
|
||||
}
|
||||
|
||||
pub fn struct_span_lint_node<S: Into<MultiSpan>>(self,
|
||||
lint: &'static Lint,
|
||||
id: NodeId,
|
||||
span: S,
|
||||
msg: &str)
|
||||
-> DiagnosticBuilder<'tcx>
|
||||
{
|
||||
let (level, src) = self.lint_level_at_node(lint, id);
|
||||
lint::struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg)
|
||||
}
|
||||
|
||||
pub fn struct_lint_node(self, lint: &'static Lint, id: NodeId, msg: &str)
|
||||
pub fn struct_lint_node(self, lint: &'static Lint, id: HirId, msg: &str)
|
||||
-> DiagnosticBuilder<'tcx>
|
||||
{
|
||||
let (level, src) = self.lint_level_at_node(lint, id);
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
use rustc::hir;
|
||||
use rustc::ty::TyCtxt;
|
||||
use syntax::ast;
|
||||
|
||||
use rustc_mir::monomorphize::Instance;
|
||||
|
||||
@ -33,9 +32,9 @@ struct SymbolNamesTest<'a, 'tcx:'a> {
|
||||
|
||||
impl<'a, 'tcx> SymbolNamesTest<'a, 'tcx> {
|
||||
fn process_attrs(&mut self,
|
||||
node_id: ast::NodeId) {
|
||||
hir_id: hir::HirId) {
|
||||
let tcx = self.tcx;
|
||||
let def_id = tcx.hir().local_def_id(node_id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||
for attr in tcx.get_attrs(def_id).iter() {
|
||||
if attr.check_name(SYMBOL_NAME) {
|
||||
// for now, can only use on monomorphic names
|
||||
@ -56,14 +55,14 @@ impl<'a, 'tcx> SymbolNamesTest<'a, 'tcx> {
|
||||
|
||||
impl<'a, 'tcx> hir::itemlikevisit::ItemLikeVisitor<'tcx> for SymbolNamesTest<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
self.process_attrs(item.id);
|
||||
self.process_attrs(item.hir_id);
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
|
||||
self.process_attrs(trait_item.id);
|
||||
self.process_attrs(trait_item.hir_id);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||
self.process_attrs(impl_item.id);
|
||||
self.process_attrs(impl_item.hir_id);
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let mut visitor = IfThisChanged { tcx,
|
||||
if_this_changed: vec![],
|
||||
then_this_would_need: vec![] };
|
||||
visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.hir().krate().attrs);
|
||||
visitor.process_attrs(hir::CRATE_HIR_ID, &tcx.hir().krate().attrs);
|
||||
tcx.hir().krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
|
||||
(visitor.if_this_changed, visitor.then_this_would_need)
|
||||
};
|
||||
@ -87,7 +87,7 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
}
|
||||
|
||||
type Sources = Vec<(Span, DefId, DepNode)>;
|
||||
type Targets = Vec<(Span, ast::Name, ast::NodeId, DepNode)>;
|
||||
type Targets = Vec<(Span, ast::Name, hir::HirId, DepNode)>;
|
||||
|
||||
struct IfThisChanged<'a, 'tcx:'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
@ -110,8 +110,8 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
|
||||
value
|
||||
}
|
||||
|
||||
fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) {
|
||||
let def_id = self.tcx.hir().local_def_id(node_id);
|
||||
fn process_attrs(&mut self, hir_id: hir::HirId, attrs: &[ast::Attribute]) {
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||
let def_path_hash = self.tcx.def_path_hash(def_id);
|
||||
for attr in attrs {
|
||||
if attr.check_name(ATTR_IF_THIS_CHANGED) {
|
||||
@ -151,7 +151,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
|
||||
};
|
||||
self.then_this_would_need.push((attr.span,
|
||||
dep_node_interned.unwrap(),
|
||||
node_id,
|
||||
hir_id,
|
||||
dep_node));
|
||||
}
|
||||
}
|
||||
@ -164,22 +164,22 @@ impl<'a, 'tcx> Visitor<'tcx> for IfThisChanged<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
self.process_attrs(item.id, &item.attrs);
|
||||
self.process_attrs(item.hir_id, &item.attrs);
|
||||
intravisit::walk_item(self, item);
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
|
||||
self.process_attrs(trait_item.id, &trait_item.attrs);
|
||||
self.process_attrs(trait_item.hir_id, &trait_item.attrs);
|
||||
intravisit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||
self.process_attrs(impl_item.id, &impl_item.attrs);
|
||||
self.process_attrs(impl_item.hir_id, &impl_item.attrs);
|
||||
intravisit::walk_impl_item(self, impl_item);
|
||||
}
|
||||
|
||||
fn visit_struct_field(&mut self, s: &'tcx hir::StructField) {
|
||||
self.process_attrs(s.id, &s.attrs);
|
||||
self.process_attrs(s.hir_id, &s.attrs);
|
||||
intravisit::walk_struct_field(self, s);
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ pub struct DirtyCleanVisitor<'a, 'tcx:'a> {
|
||||
impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
|
||||
|
||||
/// Possibly "deserialize" the attribute into a clean/dirty assertion
|
||||
fn assertion_maybe(&mut self, item_id: ast::NodeId, attr: &Attribute)
|
||||
fn assertion_maybe(&mut self, item_id: hir::HirId, attr: &Attribute)
|
||||
-> Option<Assertion>
|
||||
{
|
||||
let is_clean = if attr.check_name(ATTR_DIRTY) {
|
||||
@ -269,7 +269,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
/// Gets the "auto" assertion on pre-validated attr, along with the `except` labels.
|
||||
fn assertion_auto(&mut self, item_id: ast::NodeId, attr: &Attribute, is_clean: bool)
|
||||
fn assertion_auto(&mut self, item_id: hir::HirId, attr: &Attribute, is_clean: bool)
|
||||
-> Assertion
|
||||
{
|
||||
let (name, mut auto) = self.auto_labels(item_id, attr);
|
||||
@ -321,8 +321,8 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
|
||||
|
||||
/// Return all DepNode labels that should be asserted for this item.
|
||||
/// index=0 is the "name" used for error messages
|
||||
fn auto_labels(&mut self, item_id: ast::NodeId, attr: &Attribute) -> (&'static str, Labels) {
|
||||
let node = self.tcx.hir().get(item_id);
|
||||
fn auto_labels(&mut self, item_id: hir::HirId, attr: &Attribute) -> (&'static str, Labels) {
|
||||
let node = self.tcx.hir().get_by_hir_id(item_id);
|
||||
let (name, labels) = match node {
|
||||
HirNode::Item(item) => {
|
||||
match item.node {
|
||||
@ -499,8 +499,8 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_item(&mut self, item_id: ast::NodeId, item_span: Span) {
|
||||
let def_id = self.tcx.hir().local_def_id(item_id);
|
||||
fn check_item(&mut self, item_id: hir::HirId, item_span: Span) {
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item_id);
|
||||
for attr in self.tcx.get_attrs(def_id).iter() {
|
||||
let assertion = match self.assertion_maybe(item_id, attr) {
|
||||
Some(a) => a,
|
||||
@ -519,15 +519,15 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
|
||||
|
||||
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
self.check_item(item.id, item.span);
|
||||
self.check_item(item.hir_id, item.span);
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, item: &hir::TraitItem) {
|
||||
self.check_item(item.id, item.span);
|
||||
self.check_item(item.hir_id, item.span);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, item: &hir::ImplItem) {
|
||||
self.check_item(item.id, item.span);
|
||||
self.check_item(item.hir_id, item.span);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ pub struct MissingDoc {
|
||||
doc_hidden_stack: Vec<bool>,
|
||||
|
||||
/// Private traits or trait items that leaked through. Don't check their methods.
|
||||
private_traits: FxHashSet<ast::NodeId>,
|
||||
private_traits: FxHashSet<hir::HirId>,
|
||||
}
|
||||
|
||||
fn has_doc(attr: &ast::Attribute) -> bool {
|
||||
@ -361,7 +361,7 @@ impl MissingDoc {
|
||||
|
||||
fn check_missing_docs_attrs(&self,
|
||||
cx: &LateContext<'_, '_>,
|
||||
id: Option<ast::NodeId>,
|
||||
id: Option<hir::HirId>,
|
||||
attrs: &[ast::Attribute],
|
||||
sp: Span,
|
||||
desc: &'static str) {
|
||||
@ -380,7 +380,8 @@ impl MissingDoc {
|
||||
// It's an option so the crate root can also use this function (it doesn't
|
||||
// have a NodeId).
|
||||
if let Some(id) = id {
|
||||
if !cx.access_levels.is_exported(id) {
|
||||
let node_id = cx.tcx.hir().hir_to_node_id(id);
|
||||
if !cx.access_levels.is_exported(node_id) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -444,9 +445,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
// Issue #11592, traits are always considered exported, even when private.
|
||||
if let hir::VisibilityKind::Inherited = it.vis.node {
|
||||
self.private_traits.insert(it.id);
|
||||
self.private_traits.insert(it.hir_id);
|
||||
for trait_item_ref in trait_item_refs {
|
||||
self.private_traits.insert(trait_item_ref.id.node_id);
|
||||
let hir_id = cx.tcx.hir().node_to_hir_id(trait_item_ref.id.node_id);
|
||||
self.private_traits.insert(hir_id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -462,7 +464,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||
Some(Node::Item(item)) => {
|
||||
if let hir::VisibilityKind::Inherited = item.vis.node {
|
||||
for impl_item_ref in impl_item_refs {
|
||||
self.private_traits.insert(impl_item_ref.id.node_id);
|
||||
let hir_id = cx.tcx.hir().node_to_hir_id(
|
||||
impl_item_ref.id.node_id);
|
||||
self.private_traits.insert(hir_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -476,11 +480,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||
_ => return,
|
||||
};
|
||||
|
||||
self.check_missing_docs_attrs(cx, Some(it.id), &it.attrs, it.span, desc);
|
||||
self.check_missing_docs_attrs(cx, Some(it.hir_id), &it.attrs, it.span, desc);
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, trait_item: &hir::TraitItem) {
|
||||
if self.private_traits.contains(&trait_item.id) {
|
||||
if self.private_traits.contains(&trait_item.hir_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -491,7 +495,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||
};
|
||||
|
||||
self.check_missing_docs_attrs(cx,
|
||||
Some(trait_item.id),
|
||||
Some(trait_item.hir_id),
|
||||
&trait_item.attrs,
|
||||
trait_item.span,
|
||||
desc);
|
||||
@ -510,7 +514,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||
hir::ImplItemKind::Existential(_) => "an associated existential type",
|
||||
};
|
||||
self.check_missing_docs_attrs(cx,
|
||||
Some(impl_item.id),
|
||||
Some(impl_item.hir_id),
|
||||
&impl_item.attrs,
|
||||
impl_item.span,
|
||||
desc);
|
||||
@ -519,7 +523,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||
fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, sf: &hir::StructField) {
|
||||
if !sf.is_positional() {
|
||||
self.check_missing_docs_attrs(cx,
|
||||
Some(sf.id),
|
||||
Some(sf.hir_id),
|
||||
&sf.attrs,
|
||||
sf.span,
|
||||
"a struct field")
|
||||
@ -528,7 +532,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||
|
||||
fn check_variant(&mut self, cx: &LateContext<'_, '_>, v: &hir::Variant, _: &hir::Generics) {
|
||||
self.check_missing_docs_attrs(cx,
|
||||
Some(v.node.data.id()),
|
||||
Some(v.node.data.hir_id()),
|
||||
&v.node.attrs,
|
||||
v.span,
|
||||
"a variant");
|
||||
@ -1108,11 +1112,12 @@ impl LintPass for UnreachablePub {
|
||||
}
|
||||
|
||||
impl UnreachablePub {
|
||||
fn perform_lint(&self, cx: &LateContext<'_, '_>, what: &str, id: ast::NodeId,
|
||||
fn perform_lint(&self, cx: &LateContext<'_, '_>, what: &str, id: hir::HirId,
|
||||
vis: &hir::Visibility, span: Span, exportable: bool) {
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
let node_id = cx.tcx.hir().hir_to_node_id(id);
|
||||
match vis.node {
|
||||
hir::VisibilityKind::Public if !cx.access_levels.is_reachable(id) => {
|
||||
hir::VisibilityKind::Public if !cx.access_levels.is_reachable(node_id) => {
|
||||
if span.ctxt().outer().expn_info().is_some() {
|
||||
applicability = Applicability::MaybeIncorrect;
|
||||
}
|
||||
@ -1144,20 +1149,20 @@ impl UnreachablePub {
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnreachablePub {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
self.perform_lint(cx, "item", item.id, &item.vis, item.span, true);
|
||||
self.perform_lint(cx, "item", item.hir_id, &item.vis, item.span, true);
|
||||
}
|
||||
|
||||
fn check_foreign_item(&mut self, cx: &LateContext<'_, '_>, foreign_item: &hir::ForeignItem) {
|
||||
self.perform_lint(cx, "item", foreign_item.id, &foreign_item.vis,
|
||||
self.perform_lint(cx, "item", foreign_item.hir_id, &foreign_item.vis,
|
||||
foreign_item.span, true);
|
||||
}
|
||||
|
||||
fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, field: &hir::StructField) {
|
||||
self.perform_lint(cx, "field", field.id, &field.vis, field.span, false);
|
||||
self.perform_lint(cx, "field", field.hir_id, &field.vis, field.span, false);
|
||||
}
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, impl_item: &hir::ImplItem) {
|
||||
self.perform_lint(cx, "item", impl_item.id, &impl_item.vis, impl_item.span, false);
|
||||
self.perform_lint(cx, "item", impl_item.hir_id, &impl_item.vis, impl_item.span, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1667,7 +1667,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
|
||||
intravisit::walk_variant(self, v, g, id);
|
||||
|
||||
if let Some(ref discr) = v.node.disr_expr {
|
||||
let def_id = self.index.tcx.hir().local_def_id(discr.id);
|
||||
let def_id = self.index.tcx.hir().local_def_id_from_hir_id(discr.hir_id);
|
||||
self.index.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id);
|
||||
}
|
||||
}
|
||||
@ -1719,7 +1719,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
|
||||
fn encode_info_for_ty(&mut self, ty: &hir::Ty) {
|
||||
match ty.node {
|
||||
hir::TyKind::Array(_, ref length) => {
|
||||
let def_id = self.tcx.hir().local_def_id(length.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(length.hir_id);
|
||||
self.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id);
|
||||
}
|
||||
_ => {}
|
||||
|
@ -560,7 +560,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||
|
||||
// Now comes the rote stuff:
|
||||
hir::ExprKind::Repeat(ref v, ref count) => {
|
||||
let def_id = cx.tcx.hir().local_def_id(count.id);
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(count.hir_id);
|
||||
let substs = InternalSubsts::identity_for_item(cx.tcx.global_tcx(), def_id);
|
||||
let instance = ty::Instance::resolve(
|
||||
cx.tcx.global_tcx(),
|
||||
|
@ -346,9 +346,9 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
NotUseful => {
|
||||
match source {
|
||||
hir::MatchSource::IfLetDesugar { .. } => {
|
||||
cx.tcx.lint_node(
|
||||
cx.tcx.lint_hir(
|
||||
lint::builtin::IRREFUTABLE_LET_PATTERNS,
|
||||
hir_pat.id,
|
||||
hir_pat.hir_id,
|
||||
pat.span,
|
||||
"irrefutable if-let pattern",
|
||||
);
|
||||
@ -359,16 +359,16 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
match arm_index {
|
||||
// The arm with the user-specified pattern.
|
||||
0 => {
|
||||
cx.tcx.lint_node(
|
||||
cx.tcx.lint_hir(
|
||||
lint::builtin::UNREACHABLE_PATTERNS,
|
||||
hir_pat.id, pat.span,
|
||||
hir_pat.hir_id, pat.span,
|
||||
"unreachable pattern");
|
||||
},
|
||||
// The arm with the wildcard pattern.
|
||||
1 => {
|
||||
cx.tcx.lint_node(
|
||||
cx.tcx.lint_hir(
|
||||
lint::builtin::IRREFUTABLE_LET_PATTERNS,
|
||||
hir_pat.id,
|
||||
hir_pat.hir_id,
|
||||
pat.span,
|
||||
"irrefutable while-let pattern",
|
||||
);
|
||||
@ -379,9 +379,9 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
|
||||
hir::MatchSource::ForLoopDesugar |
|
||||
hir::MatchSource::Normal => {
|
||||
let mut err = cx.tcx.struct_span_lint_node(
|
||||
let mut err = cx.tcx.struct_span_lint_hir(
|
||||
lint::builtin::UNREACHABLE_PATTERNS,
|
||||
hir_pat.id,
|
||||
hir_pat.hir_id,
|
||||
pat.span,
|
||||
"unreachable pattern",
|
||||
);
|
||||
|
@ -955,8 +955,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
||||
debug!("const_to_pat: cv.ty={:?} span={:?}", cv.ty, span);
|
||||
let kind = match cv.ty.sty {
|
||||
ty::Float(_) => {
|
||||
let id = self.tcx.hir().hir_to_node_id(id);
|
||||
self.tcx.lint_node(
|
||||
self.tcx.lint_hir(
|
||||
::rustc::lint::builtin::ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
|
||||
id,
|
||||
span,
|
||||
|
@ -129,12 +129,12 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
// no break */ }`) shouldn't be linted unless it actually
|
||||
// recurs.
|
||||
if !reached_exit_without_self_call && !self_call_locations.is_empty() {
|
||||
let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
|
||||
let sp = tcx.sess.source_map().def_span(tcx.hir().span(node_id));
|
||||
let mut db = tcx.struct_span_lint_node(UNCONDITIONAL_RECURSION,
|
||||
node_id,
|
||||
sp,
|
||||
"function cannot return without recursing");
|
||||
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 mut db = tcx.struct_span_lint_hir(UNCONDITIONAL_RECURSION,
|
||||
hir_id,
|
||||
sp,
|
||||
"function cannot return without recursing");
|
||||
db.span_label(sp, "cannot return without recursing");
|
||||
// offer some help to the programmer.
|
||||
for location in &self_call_locations {
|
||||
|
@ -1006,7 +1006,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
|
||||
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
|
||||
match ii.node {
|
||||
hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => {
|
||||
let def_id = self.tcx.hir().local_def_id(ii.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(ii.hir_id);
|
||||
self.push_if_root(def_id);
|
||||
}
|
||||
_ => { /* Nothing to do here */ }
|
||||
|
@ -553,10 +553,8 @@ fn unsafety_check_result<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||
}
|
||||
|
||||
fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
|
||||
let lint_node_id = match tcx.hir().as_local_node_id(def_id) {
|
||||
Some(node_id) => node_id,
|
||||
None => bug!("checking unsafety for non-local def id {:?}", def_id)
|
||||
};
|
||||
let lint_hir_id = tcx.hir().as_local_hir_id(def_id).unwrap_or_else(||
|
||||
bug!("checking unsafety for non-local def id {:?}", def_id));
|
||||
|
||||
// FIXME: when we make this a hard error, this should have its
|
||||
// own error code.
|
||||
@ -567,10 +565,10 @@ fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D
|
||||
"#[derive] can't be used on a #[repr(packed)] struct that \
|
||||
does not derive Copy (error E0133)".to_string()
|
||||
};
|
||||
tcx.lint_node(SAFE_PACKED_BORROWS,
|
||||
lint_node_id,
|
||||
tcx.def_span(def_id),
|
||||
&message);
|
||||
tcx.lint_hir(SAFE_PACKED_BORROWS,
|
||||
lint_hir_id,
|
||||
tcx.def_span(def_id),
|
||||
&message);
|
||||
}
|
||||
|
||||
/// Returns the `HirId` for an enclosing scope that is also `unsafe`.
|
||||
|
@ -603,10 +603,10 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for ConstPropagator<'b, 'a, 'tcx> {
|
||||
.unwrap()
|
||||
.source_info
|
||||
.span;
|
||||
let node_id = self
|
||||
let hir_id = self
|
||||
.tcx
|
||||
.hir()
|
||||
.as_local_node_id(self.source.def_id())
|
||||
.as_local_hir_id(self.source.def_id())
|
||||
.expect("some part of a failing const eval must be local");
|
||||
use rustc::mir::interpret::EvalErrorKind::*;
|
||||
let msg = match msg {
|
||||
@ -643,9 +643,9 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for ConstPropagator<'b, 'a, 'tcx> {
|
||||
// Need proper const propagator for these
|
||||
_ => return,
|
||||
};
|
||||
self.tcx.lint_node(
|
||||
self.tcx.lint_hir(
|
||||
::rustc::lint::builtin::CONST_ERR,
|
||||
node_id,
|
||||
hir_id,
|
||||
span,
|
||||
&msg,
|
||||
);
|
||||
|
@ -290,10 +290,10 @@ fn def_id_visibility<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||
// Set the correct `TypeckTables` for the given `item_id` (or an empty table if
|
||||
// there is no `TypeckTables` for the item).
|
||||
fn item_tables<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
node_id: ast::NodeId,
|
||||
hir_id: hir::HirId,
|
||||
empty_tables: &'a ty::TypeckTables<'tcx>)
|
||||
-> &'a ty::TypeckTables<'tcx> {
|
||||
let def_id = tcx.hir().local_def_id(node_id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||
if tcx.has_typeck_tables(def_id) { tcx.typeck_tables_of(def_id) } else { empty_tables }
|
||||
}
|
||||
|
||||
@ -841,7 +841,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let orig_current_item = mem::replace(&mut self.current_item, item.id);
|
||||
let orig_tables =
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, item.id, self.empty_tables));
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, item.hir_id, self.empty_tables));
|
||||
intravisit::walk_item(self, item);
|
||||
self.current_item = orig_current_item;
|
||||
self.tables = orig_tables;
|
||||
@ -849,14 +849,14 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem) {
|
||||
let orig_tables =
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, ti.id, self.empty_tables));
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, ti.hir_id, self.empty_tables));
|
||||
intravisit::walk_trait_item(self, ti);
|
||||
self.tables = orig_tables;
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
|
||||
let orig_tables =
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, ii.id, self.empty_tables));
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, ii.hir_id, self.empty_tables));
|
||||
intravisit::walk_impl_item(self, ii);
|
||||
self.tables = orig_tables;
|
||||
}
|
||||
@ -1114,7 +1114,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
|
||||
mem::replace(&mut self.current_item, self.tcx.hir().local_def_id(item.id));
|
||||
let orig_in_body = mem::replace(&mut self.in_body, false);
|
||||
let orig_tables =
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, item.id, self.empty_tables));
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, item.hir_id, self.empty_tables));
|
||||
intravisit::walk_item(self, item);
|
||||
self.tables = orig_tables;
|
||||
self.in_body = orig_in_body;
|
||||
@ -1123,14 +1123,14 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem) {
|
||||
let orig_tables =
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, ti.id, self.empty_tables));
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, ti.hir_id, self.empty_tables));
|
||||
intravisit::walk_trait_item(self, ti);
|
||||
self.tables = orig_tables;
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
|
||||
let orig_tables =
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, ii.id, self.empty_tables));
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, ii.hir_id, self.empty_tables));
|
||||
intravisit::walk_impl_item(self, ii);
|
||||
self.tables = orig_tables;
|
||||
}
|
||||
@ -1318,7 +1318,9 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Const(..) |
|
||||
hir::ImplItemKind::Method(..) => {
|
||||
self.access_levels.is_reachable(impl_item.id)
|
||||
let node_id = self.tcx.hir().hir_to_node_id(
|
||||
impl_item.hir_id);
|
||||
self.access_levels.is_reachable(node_id)
|
||||
}
|
||||
hir::ImplItemKind::Existential(..) |
|
||||
hir::ImplItemKind::Type(_) => false,
|
||||
@ -1340,10 +1342,11 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
// don't erroneously report errors for private
|
||||
// types in private items.
|
||||
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
||||
let node_id = self.tcx.hir().hir_to_node_id(impl_item.hir_id);
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Const(..) |
|
||||
hir::ImplItemKind::Method(..)
|
||||
if self.item_is_public(&impl_item.id, &impl_item.vis) =>
|
||||
if self.item_is_public(&node_id, &impl_item.vis) =>
|
||||
{
|
||||
intravisit::walk_impl_item(self, impl_item)
|
||||
}
|
||||
@ -1495,7 +1498,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
|
||||
struct SearchInterfaceForPrivateItemsVisitor<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
item_id: ast::NodeId,
|
||||
item_id: hir::HirId,
|
||||
item_def_id: DefId,
|
||||
span: Span,
|
||||
/// The visitor checks that each component type is at least this visible.
|
||||
@ -1539,17 +1542,17 @@ impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> {
|
||||
|
||||
fn check_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display) -> bool {
|
||||
if self.leaks_private_dep(def_id) {
|
||||
self.tcx.lint_node(lint::builtin::EXPORTED_PRIVATE_DEPENDENCIES,
|
||||
self.item_id,
|
||||
self.span,
|
||||
&format!("{} `{}` from private dependency '{}' in public \
|
||||
interface", kind, descr,
|
||||
self.tcx.crate_name(def_id.krate)));
|
||||
self.tcx.lint_hir(lint::builtin::EXPORTED_PRIVATE_DEPENDENCIES,
|
||||
self.item_id,
|
||||
self.span,
|
||||
&format!("{} `{}` from private dependency '{}' in public \
|
||||
interface", kind, descr,
|
||||
self.tcx.crate_name(def_id.krate)));
|
||||
|
||||
}
|
||||
|
||||
let node_id = match self.tcx.hir().as_local_node_id(def_id) {
|
||||
Some(node_id) => node_id,
|
||||
let hir_id = match self.tcx.hir().as_local_hir_id(def_id) {
|
||||
Some(hir_id) => hir_id,
|
||||
None => return false,
|
||||
};
|
||||
|
||||
@ -1567,8 +1570,8 @@ impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> {
|
||||
err.emit();
|
||||
} else {
|
||||
let err_code = if kind == "trait" { "E0445" } else { "E0446" };
|
||||
self.tcx.lint_node(lint::builtin::PRIVATE_IN_PUBLIC, node_id, self.span,
|
||||
&format!("{} (error {})", msg, err_code));
|
||||
self.tcx.lint_hir(lint::builtin::PRIVATE_IN_PUBLIC, hir_id, self.span,
|
||||
&format!("{} (error {})", msg, err_code));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1604,20 +1607,20 @@ struct PrivateItemsInPublicInterfacesVisitor<'a, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
|
||||
fn check(&self, item_id: ast::NodeId, required_visibility: ty::Visibility)
|
||||
fn check(&self, item_id: hir::HirId, required_visibility: ty::Visibility)
|
||||
-> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> {
|
||||
let mut has_old_errors = false;
|
||||
|
||||
// Slow path taken only if there any errors in the crate.
|
||||
for &id in self.old_error_set {
|
||||
// Walk up the nodes until we find `item_id` (or we hit a root).
|
||||
let mut id = self.tcx.hir().hir_to_node_id(id);
|
||||
let mut id = id;
|
||||
loop {
|
||||
if id == item_id {
|
||||
has_old_errors = true;
|
||||
break;
|
||||
}
|
||||
let parent = self.tcx.hir().get_parent_node(id);
|
||||
let parent = self.tcx.hir().get_parent_node_by_hir_id(id);
|
||||
if parent == id {
|
||||
break;
|
||||
}
|
||||
@ -1632,8 +1635,8 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
|
||||
SearchInterfaceForPrivateItemsVisitor {
|
||||
tcx: self.tcx,
|
||||
item_id,
|
||||
item_def_id: self.tcx.hir().local_def_id(item_id),
|
||||
span: self.tcx.hir().span(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),
|
||||
required_visibility,
|
||||
has_pub_restricted: self.has_pub_restricted,
|
||||
has_old_errors,
|
||||
@ -1642,9 +1645,9 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_trait_or_impl_item(&self, node_id: ast::NodeId, assoc_item_kind: AssociatedItemKind,
|
||||
fn check_trait_or_impl_item(&self, hir_id: hir::HirId, assoc_item_kind: AssociatedItemKind,
|
||||
defaultness: hir::Defaultness, vis: ty::Visibility) {
|
||||
let mut check = self.check(node_id, vis);
|
||||
let mut check = self.check(hir_id, vis);
|
||||
|
||||
let (check_ty, is_assoc_ty) = match assoc_item_kind {
|
||||
AssociatedItemKind::Const | AssociatedItemKind::Method { .. } => (true, false),
|
||||
@ -1682,30 +1685,31 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||
// Subitems of these items have inherited publicity.
|
||||
hir::ItemKind::Const(..) | hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Fn(..) | hir::ItemKind::Ty(..) => {
|
||||
self.check(item.id, item_visibility).generics().predicates().ty();
|
||||
self.check(item.hir_id, item_visibility).generics().predicates().ty();
|
||||
}
|
||||
hir::ItemKind::Existential(..) => {
|
||||
// `ty()` for existential types is the underlying type,
|
||||
// it's not a part of interface, so we skip it.
|
||||
self.check(item.id, item_visibility).generics().predicates();
|
||||
self.check(item.hir_id, item_visibility).generics().predicates();
|
||||
}
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
self.check(item.id, item_visibility).generics().predicates();
|
||||
self.check(item.hir_id, item_visibility).generics().predicates();
|
||||
|
||||
for trait_item_ref in trait_item_refs {
|
||||
self.check_trait_or_impl_item(trait_item_ref.id.node_id, trait_item_ref.kind,
|
||||
let hir_id = tcx.hir().node_to_hir_id(trait_item_ref.id.node_id);
|
||||
self.check_trait_or_impl_item(hir_id, trait_item_ref.kind,
|
||||
trait_item_ref.defaultness, item_visibility);
|
||||
}
|
||||
}
|
||||
hir::ItemKind::TraitAlias(..) => {
|
||||
self.check(item.id, item_visibility).generics().predicates();
|
||||
self.check(item.hir_id, item_visibility).generics().predicates();
|
||||
}
|
||||
hir::ItemKind::Enum(ref def, _) => {
|
||||
self.check(item.id, item_visibility).generics().predicates();
|
||||
self.check(item.hir_id, item_visibility).generics().predicates();
|
||||
|
||||
for variant in &def.variants {
|
||||
for field in variant.node.data.fields() {
|
||||
self.check(field.id, item_visibility).ty();
|
||||
self.check(field.hir_id, item_visibility).ty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1713,17 +1717,17 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||
hir::ItemKind::ForeignMod(ref foreign_mod) => {
|
||||
for foreign_item in &foreign_mod.items {
|
||||
let vis = ty::Visibility::from_hir(&foreign_item.vis, item.id, tcx);
|
||||
self.check(foreign_item.id, vis).generics().predicates().ty();
|
||||
self.check(foreign_item.hir_id, vis).generics().predicates().ty();
|
||||
}
|
||||
}
|
||||
// Subitems of structs and unions have their own publicity.
|
||||
hir::ItemKind::Struct(ref struct_def, _) |
|
||||
hir::ItemKind::Union(ref struct_def, _) => {
|
||||
self.check(item.id, item_visibility).generics().predicates();
|
||||
self.check(item.hir_id, item_visibility).generics().predicates();
|
||||
|
||||
for field in struct_def.fields() {
|
||||
let field_visibility = ty::Visibility::from_hir(&field.vis, item.id, tcx);
|
||||
self.check(field.id, min(item_visibility, field_visibility, tcx)).ty();
|
||||
self.check(field.hir_id, min(item_visibility, field_visibility, tcx)).ty();
|
||||
}
|
||||
}
|
||||
// An inherent impl is public when its type is public
|
||||
@ -1732,7 +1736,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||
// Subitems of trait impls have inherited publicity.
|
||||
hir::ItemKind::Impl(.., ref trait_ref, _, ref impl_item_refs) => {
|
||||
let impl_vis = ty::Visibility::of_impl(item.id, tcx, &Default::default());
|
||||
self.check(item.id, impl_vis).generics().predicates();
|
||||
self.check(item.hir_id, impl_vis).generics().predicates();
|
||||
for impl_item_ref in impl_item_refs {
|
||||
let impl_item = tcx.hir().impl_item(impl_item_ref.id);
|
||||
let impl_item_vis = if trait_ref.is_none() {
|
||||
@ -1740,7 +1744,8 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||
} else {
|
||||
impl_vis
|
||||
};
|
||||
self.check_trait_or_impl_item(impl_item_ref.id.node_id, impl_item_ref.kind,
|
||||
let hir_id = tcx.hir().node_to_hir_id(impl_item_ref.id.node_id);
|
||||
self.check_trait_or_impl_item(hir_id, impl_item_ref.kind,
|
||||
impl_item_ref.defaultness, impl_item_vis);
|
||||
}
|
||||
}
|
||||
|
@ -612,8 +612,8 @@ struct ClauseDumper<'a, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ClauseDumper<'a, 'tcx> {
|
||||
fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) {
|
||||
let def_id = self.tcx.hir().local_def_id(node_id);
|
||||
fn process_attrs(&mut self, hir_id: hir::HirId, attrs: &[ast::Attribute]) {
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||
for attr in attrs {
|
||||
let mut clauses = None;
|
||||
|
||||
@ -655,22 +655,22 @@ impl<'a, 'tcx> Visitor<'tcx> for ClauseDumper<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
self.process_attrs(item.id, &item.attrs);
|
||||
self.process_attrs(item.hir_id, &item.attrs);
|
||||
intravisit::walk_item(self, item);
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
|
||||
self.process_attrs(trait_item.id, &trait_item.attrs);
|
||||
self.process_attrs(trait_item.hir_id, &trait_item.attrs);
|
||||
intravisit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||
self.process_attrs(impl_item.id, &impl_item.attrs);
|
||||
self.process_attrs(impl_item.hir_id, &impl_item.attrs);
|
||||
intravisit::walk_impl_item(self, impl_item);
|
||||
}
|
||||
|
||||
fn visit_struct_field(&mut self, s: &'tcx hir::StructField) {
|
||||
self.process_attrs(s.id, &s.attrs);
|
||||
self.process_attrs(s.hir_id, &s.attrs);
|
||||
intravisit::walk_struct_field(self, s);
|
||||
}
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||
// specify type to assert that error was already reported in Err case:
|
||||
let predicate: Result<_, ErrorReported> =
|
||||
self.ast_type_binding_to_poly_projection_predicate(
|
||||
trait_ref.ref_id, poly_trait_ref, binding, speculative, &mut dup_bindings);
|
||||
trait_ref.hir_ref_id, poly_trait_ref, binding, speculative, &mut dup_bindings);
|
||||
// okay to ignore Err because of ErrorReported (see above)
|
||||
Some((predicate.ok()?, binding.span))
|
||||
}));
|
||||
@ -802,7 +802,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||
|
||||
fn ast_type_binding_to_poly_projection_predicate(
|
||||
&self,
|
||||
ref_id: ast::NodeId,
|
||||
hir_ref_id: hir::HirId,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
binding: &ConvertedBinding<'tcx>,
|
||||
speculative: bool,
|
||||
@ -874,7 +874,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||
binding.item_name, binding.span)
|
||||
}?;
|
||||
|
||||
let hir_ref_id = self.tcx().hir().node_to_hir_id(ref_id);
|
||||
let (assoc_ident, def_scope) =
|
||||
tcx.adjust_ident(binding.item_name, candidate.def_id(), hir_ref_id);
|
||||
let assoc_ty = tcx.associated_items(candidate.def_id()).find(|i| {
|
||||
@ -1798,7 +1797,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||
self.associated_path_to_ty(ast_ty.hir_id, ast_ty.span, ty, def, segment, false).0
|
||||
}
|
||||
hir::TyKind::Array(ref ty, ref length) => {
|
||||
let length_def_id = tcx.hir().local_def_id(length.id);
|
||||
let length_def_id = tcx.hir().local_def_id_from_hir_id(length.hir_id);
|
||||
let substs = InternalSubsts::identity_for_item(tcx, length_def_id);
|
||||
let length = ty::LazyConst::Unevaluated(length_def_id, substs);
|
||||
let length = tcx.mk_lazy_const(length);
|
||||
|
@ -227,7 +227,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
self.demand_eqtype_pat(pat.span, expected, rhs_ty, match_discrim_span);
|
||||
common_type
|
||||
}
|
||||
PatKind::Binding(ba, var_id, _, _, ref sub) => {
|
||||
PatKind::Binding(ba, _, var_id, _, ref sub) => {
|
||||
let bm = if ba == hir::BindingAnnotation::Unannotated {
|
||||
def_bm
|
||||
} else {
|
||||
@ -239,7 +239,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
.pat_binding_modes_mut()
|
||||
.insert(pat.hir_id, bm);
|
||||
debug!("check_pat_walk: pat.hir_id={:?} bm={:?}", pat.hir_id, bm);
|
||||
let local_ty = self.local_ty(pat.span, pat.id).decl_ty;
|
||||
let local_ty = self.local_ty(pat.span, pat.hir_id).decl_ty;
|
||||
match bm {
|
||||
ty::BindByReference(mutbl) => {
|
||||
// if the binding is like
|
||||
@ -265,7 +265,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
// if there are multiple arms, make sure they all agree on
|
||||
// what the type of the binding `x` ought to be
|
||||
if var_id != pat.id {
|
||||
if var_id != pat.hir_id {
|
||||
let vt = self.local_ty(pat.span, var_id).decl_ty;
|
||||
self.demand_eqtype_pat(pat.span, vt, local_ty, match_discrim_span);
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ use crate::TypeAndSubsts;
|
||||
use crate::lint;
|
||||
use crate::util::captures::Captures;
|
||||
use crate::util::common::{ErrorReported, indenter};
|
||||
use crate::util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, HirIdMap, NodeMap};
|
||||
use crate::util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, HirIdMap};
|
||||
|
||||
pub use self::Expectation::*;
|
||||
use self::autoderef::Autoderef;
|
||||
@ -194,7 +194,7 @@ pub struct Inherited<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
|
||||
tables: MaybeInProgressTables<'a, 'tcx>,
|
||||
|
||||
locals: RefCell<NodeMap<LocalTy<'tcx>>>,
|
||||
locals: RefCell<HirIdMap<LocalTy<'tcx>>>,
|
||||
|
||||
fulfillment_cx: RefCell<Box<dyn TraitEngine<'tcx>>>,
|
||||
|
||||
@ -943,7 +943,7 @@ struct GatherLocalsVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> GatherLocalsVisitor<'a, 'gcx, 'tcx> {
|
||||
fn assign(&mut self, span: Span, nid: ast::NodeId, ty_opt: Option<LocalTy<'tcx>>) -> Ty<'tcx> {
|
||||
fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<LocalTy<'tcx>>) -> Ty<'tcx> {
|
||||
match ty_opt {
|
||||
None => {
|
||||
// infer the variable's type
|
||||
@ -994,19 +994,19 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> {
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
self.assign(local.span, local.id, local_ty);
|
||||
self.assign(local.span, local.hir_id, local_ty);
|
||||
|
||||
debug!("Local variable {:?} is assigned type {}",
|
||||
local.pat,
|
||||
self.fcx.ty_to_string(
|
||||
self.fcx.locals.borrow().get(&local.id).unwrap().clone().decl_ty));
|
||||
self.fcx.locals.borrow().get(&local.hir_id).unwrap().clone().decl_ty));
|
||||
intravisit::walk_local(self, local);
|
||||
}
|
||||
|
||||
// Add pattern bindings.
|
||||
fn visit_pat(&mut self, p: &'gcx hir::Pat) {
|
||||
if let PatKind::Binding(_, _, _, ident, _) = p.node {
|
||||
let var_ty = self.assign(p.span, p.id, None);
|
||||
let var_ty = self.assign(p.span, p.hir_id, None);
|
||||
|
||||
if !self.fcx.tcx.features().unsized_locals {
|
||||
self.fcx.require_type_is_sized(var_ty, p.span,
|
||||
@ -1016,7 +1016,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> {
|
||||
debug!("Pattern binding {} is assigned to {} with type {:?}",
|
||||
ident,
|
||||
self.fcx.ty_to_string(
|
||||
self.fcx.locals.borrow().get(&p.id).unwrap().clone().decl_ty),
|
||||
self.fcx.locals.borrow().get(&p.hir_id).unwrap().clone().decl_ty),
|
||||
var_ty);
|
||||
}
|
||||
intravisit::walk_pat(self, p);
|
||||
@ -1554,7 +1554,8 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
// Check existing impl methods to see if they are both present in trait
|
||||
// and compatible with trait signature
|
||||
for impl_item in impl_items() {
|
||||
let ty_impl_item = tcx.associated_item(tcx.hir().local_def_id(impl_item.id));
|
||||
let ty_impl_item = tcx.associated_item(
|
||||
tcx.hir().local_def_id_from_hir_id(impl_item.hir_id));
|
||||
let ty_trait_item = tcx.associated_items(impl_trait_ref.def_id)
|
||||
.find(|ac| Namespace::from(&impl_item.node) == Namespace::from(ac.kind) &&
|
||||
tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id))
|
||||
@ -1870,7 +1871,7 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
for v in vs {
|
||||
if let Some(ref e) = v.node.disr_expr {
|
||||
tcx.typeck_tables_of(tcx.hir().local_def_id(e.id));
|
||||
tcx.typeck_tables_of(tcx.hir().local_def_id_from_hir_id(e.hir_id));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2124,10 +2125,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
format!("{:?}", self_ptr)
|
||||
}
|
||||
|
||||
pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> LocalTy<'tcx> {
|
||||
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().node_to_string(nid))
|
||||
self.tcx.hir().hir_to_string(nid))
|
||||
)
|
||||
}
|
||||
|
||||
@ -4552,7 +4553,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
tcx.mk_array(element_ty, args.len() as u64)
|
||||
}
|
||||
ExprKind::Repeat(ref element, ref count) => {
|
||||
let count_def_id = tcx.hir().local_def_id(count.id);
|
||||
let count_def_id = tcx.hir().local_def_id_from_hir_id(count.hir_id);
|
||||
let param_env = ty::ParamEnv::empty();
|
||||
let substs = InternalSubsts::identity_for_item(tcx.global_tcx(), count_def_id);
|
||||
let instance = ty::Instance::resolve(
|
||||
@ -4805,7 +4806,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
// See #44848.
|
||||
let ref_bindings = local.pat.contains_explicit_ref_binding();
|
||||
|
||||
let local_ty = self.local_ty(init.span, local.id).revealed_ty;
|
||||
let local_ty = self.local_ty(init.span, local.hir_id).revealed_ty;
|
||||
if let Some(m) = ref_bindings {
|
||||
// Somewhat subtle: if we have a `ref` binding in the pattern,
|
||||
// we want to avoid introducing coercions for the RHS. This is
|
||||
@ -4824,7 +4825,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn check_decl_local(&self, local: &'gcx hir::Local) {
|
||||
let t = self.local_ty(local.span, local.id).decl_ty;
|
||||
let t = self.local_ty(local.span, local.hir_id).decl_ty;
|
||||
self.write_ty(local.hir_id, t);
|
||||
|
||||
if let Some(ref init) = local.init {
|
||||
@ -5378,7 +5379,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
match def {
|
||||
Def::Local(nid) | Def::Upvar(nid, ..) => {
|
||||
let ty = self.local_ty(span, nid).decl_ty;
|
||||
let hid = self.tcx.hir().node_to_hir_id(nid);
|
||||
let ty = self.local_ty(span, hid).decl_ty;
|
||||
let ty = self.normalize_associated_types_in(span, &ty);
|
||||
self.write_ty(hir_id, ty);
|
||||
return (ty, def);
|
||||
|
@ -108,14 +108,14 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def
|
||||
check_item_fn(tcx, item);
|
||||
}
|
||||
hir::ItemKind::Static(ref ty, ..) => {
|
||||
check_item_type(tcx, item.id, ty.span, false);
|
||||
check_item_type(tcx, item.hir_id, ty.span, false);
|
||||
}
|
||||
hir::ItemKind::Const(ref ty, ..) => {
|
||||
check_item_type(tcx, item.id, ty.span, false);
|
||||
check_item_type(tcx, item.hir_id, ty.span, false);
|
||||
}
|
||||
hir::ItemKind::ForeignMod(ref module) => for it in module.items.iter() {
|
||||
if let hir::ForeignItemKind::Static(ref ty, ..) = it.node {
|
||||
check_item_type(tcx, it.id, ty.span, true);
|
||||
check_item_type(tcx, it.hir_id, ty.span, true);
|
||||
}
|
||||
},
|
||||
hir::ItemKind::Struct(ref struct_def, ref ast_generics) => {
|
||||
@ -157,7 +157,7 @@ pub fn check_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
|
||||
hir::TraitItemKind::Method(ref sig, _) => Some(sig),
|
||||
_ => None
|
||||
};
|
||||
check_associated_item(tcx, trait_item.id, trait_item.span, method_sig);
|
||||
check_associated_item(tcx, trait_item.hir_id, trait_item.span, method_sig);
|
||||
}
|
||||
|
||||
pub fn check_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
|
||||
@ -168,18 +168,18 @@ pub fn check_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
|
||||
hir::ImplItemKind::Method(ref sig, _) => Some(sig),
|
||||
_ => None
|
||||
};
|
||||
check_associated_item(tcx, impl_item.id, impl_item.span, method_sig);
|
||||
check_associated_item(tcx, impl_item.hir_id, impl_item.span, method_sig);
|
||||
}
|
||||
|
||||
fn check_associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
item_id: ast::NodeId,
|
||||
item_id: hir::HirId,
|
||||
span: Span,
|
||||
sig_if_method: Option<&hir::MethodSig>) {
|
||||
debug!("check_associated_item: {:?}", item_id);
|
||||
|
||||
let code = ObligationCauseCode::MiscObligation;
|
||||
for_id(tcx, item_id, span).with_fcx(|fcx, tcx| {
|
||||
let item = fcx.tcx.associated_item(fcx.tcx.hir().local_def_id(item_id));
|
||||
let item = fcx.tcx.associated_item(fcx.tcx.hir().local_def_id_from_hir_id(item_id));
|
||||
|
||||
let (mut implied_bounds, self_ty) = match item.container {
|
||||
ty::TraitContainer(_) => (vec![], fcx.tcx.mk_self_type()),
|
||||
@ -220,16 +220,15 @@ fn check_associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
fn for_item<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, item: &hir::Item)
|
||||
-> CheckWfFcxBuilder<'a, 'gcx, 'tcx> {
|
||||
for_id(tcx, item.id, item.span)
|
||||
for_id(tcx, item.hir_id, item.span)
|
||||
}
|
||||
|
||||
fn for_id<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, id: ast::NodeId, span: Span)
|
||||
fn for_id<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, id: hir::HirId, span: Span)
|
||||
-> CheckWfFcxBuilder<'a, 'gcx, 'tcx> {
|
||||
let def_id = tcx.hir().local_def_id(id);
|
||||
let hir_id = tcx.hir().node_to_hir_id(id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(id);
|
||||
CheckWfFcxBuilder {
|
||||
inherited: Inherited::build(tcx, def_id),
|
||||
id: hir_id,
|
||||
id,
|
||||
span,
|
||||
param_env: tcx.param_env(def_id),
|
||||
}
|
||||
@ -339,14 +338,14 @@ fn check_item_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) {
|
||||
|
||||
fn check_item_type<'a, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
item_id: ast::NodeId,
|
||||
item_id: hir::HirId,
|
||||
ty_span: Span,
|
||||
allow_foreign_ty: bool,
|
||||
) {
|
||||
debug!("check_item_type: {:?}", item_id);
|
||||
|
||||
for_id(tcx, item_id, ty_span).with_fcx(|fcx, gcx| {
|
||||
let ty = gcx.type_of(gcx.hir().local_def_id(item_id));
|
||||
let ty = gcx.type_of(gcx.hir().local_def_id_from_hir_id(item_id));
|
||||
let item_ty = fcx.normalize_associated_types_in(ty_span, &ty);
|
||||
|
||||
let mut forbid_unsized = true;
|
||||
@ -1025,13 +1024,13 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'a, 'tcx> {
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
|
||||
debug!("visit_trait_item: {:?}", trait_item);
|
||||
let def_id = self.tcx.hir().local_def_id(trait_item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(trait_item.hir_id);
|
||||
self.tcx.ensure().check_trait_item_well_formed(def_id);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||
debug!("visit_impl_item: {:?}", impl_item);
|
||||
let def_id = self.tcx.hir().local_def_id(impl_item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(impl_item.hir_id);
|
||||
self.tcx.ensure().check_impl_item_well_formed(def_id);
|
||||
}
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> {
|
||||
|
||||
fn visit_local(&mut self, l: &'gcx hir::Local) {
|
||||
intravisit::walk_local(self, l);
|
||||
let var_ty = self.fcx.local_ty(l.span, l.id).decl_ty;
|
||||
let var_ty = self.fcx.local_ty(l.span, l.hir_id).decl_ty;
|
||||
let var_ty = self.resolve(&var_ty, &l.span);
|
||||
self.write_ty_to_tables(l.hir_id, var_ty);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CheckVisitor<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
if let hir::ItemKind::Use(ref path, _) = item.node {
|
||||
self.check_import(item.id, path.span);
|
||||
self.check_import(item.hir_id, path.span);
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,14 +51,13 @@ struct CheckVisitor<'a, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> CheckVisitor<'a, 'tcx> {
|
||||
fn check_import(&self, id: ast::NodeId, span: Span) {
|
||||
let def_id = self.tcx.hir().local_def_id(id);
|
||||
fn check_import(&self, id: hir::HirId, span: Span) {
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(id);
|
||||
if !self.tcx.maybe_unused_trait_import(def_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
let import_def_id = self.tcx.hir().local_def_id(id);
|
||||
if self.used_trait_imports.contains(&import_def_id) {
|
||||
if self.used_trait_imports.contains(&def_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -67,7 +66,7 @@ impl<'a, 'tcx> CheckVisitor<'a, 'tcx> {
|
||||
} else {
|
||||
"unused import".to_owned()
|
||||
};
|
||||
self.tcx.lint_node(lint::builtin::UNUSED_IMPORTS, id, span, &msg);
|
||||
self.tcx.lint_hir(lint::builtin::UNUSED_IMPORTS, id, span, &msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,8 +120,8 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
|
||||
});
|
||||
|
||||
for extern_crate in &crates_to_lint {
|
||||
let id = tcx.hir().as_local_node_id(extern_crate.def_id).unwrap();
|
||||
let item = tcx.hir().expect_item(id);
|
||||
let id = tcx.hir().as_local_hir_id(extern_crate.def_id).unwrap();
|
||||
let item = tcx.hir().expect_item_by_hir_id(id);
|
||||
|
||||
// If the crate is fully unused, we suggest removing it altogether.
|
||||
// We do this in any edition.
|
||||
@ -135,7 +134,7 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
|
||||
.map(|attr| attr.span)
|
||||
.fold(span, |acc, attr_span| acc.to(attr_span));
|
||||
|
||||
tcx.struct_span_lint_node(lint, id, span, msg)
|
||||
tcx.struct_span_lint_hir(lint, id, span, msg)
|
||||
.span_suggestion_short(
|
||||
span_with_attrs,
|
||||
"remove it",
|
||||
@ -177,7 +176,7 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
|
||||
None => format!("use {};", item.ident.name),
|
||||
};
|
||||
let replacement = visibility_qualified(&item.vis, base_replacement);
|
||||
tcx.struct_span_lint_node(lint, id, extern_crate.span, msg)
|
||||
tcx.struct_span_lint_hir(lint, id, extern_crate.span, msg)
|
||||
.span_suggestion_short(
|
||||
extern_crate.span,
|
||||
&help,
|
||||
|
@ -36,11 +36,11 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
|
||||
|
||||
for &item2 in &impl_items2[..] {
|
||||
if (name, namespace) == name_and_namespace(item2) {
|
||||
let node_id = self.tcx.hir().as_local_node_id(impl1);
|
||||
let mut err = if used_to_be_allowed && node_id.is_some() {
|
||||
self.tcx.struct_span_lint_node(
|
||||
let hir_id = self.tcx.hir().as_local_hir_id(impl1);
|
||||
let mut err = if used_to_be_allowed && hir_id.is_some() {
|
||||
self.tcx.struct_span_lint_hir(
|
||||
lint::builtin::INCOHERENT_FUNDAMENTAL_IMPLS,
|
||||
node_id.unwrap(),
|
||||
hir_id.unwrap(),
|
||||
self.tcx.span_of_impl(item1).unwrap(),
|
||||
&format!("duplicate definitions with name `{}` (E0592)", name)
|
||||
)
|
||||
|
@ -152,12 +152,12 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
|
||||
convert_trait_item(self.tcx, trait_item.id);
|
||||
convert_trait_item(self.tcx, trait_item.hir_id);
|
||||
intravisit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||
convert_impl_item(self.tcx, impl_item.id);
|
||||
convert_impl_item(self.tcx, impl_item.hir_id);
|
||||
intravisit::walk_impl_item(self, impl_item);
|
||||
}
|
||||
}
|
||||
@ -479,9 +479,9 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_item_id: ast::NodeId) {
|
||||
let trait_item = tcx.hir().expect_trait_item(trait_item_id);
|
||||
let def_id = tcx.hir().local_def_id(trait_item.id);
|
||||
fn convert_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_item_id: hir::HirId) {
|
||||
let trait_item = tcx.hir().expect_trait_item_by_hir_id(trait_item_id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(trait_item.hir_id);
|
||||
tcx.generics_of(def_id);
|
||||
|
||||
match trait_item.node {
|
||||
@ -500,12 +500,12 @@ fn convert_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_item_id: ast:
|
||||
tcx.predicates_of(def_id);
|
||||
}
|
||||
|
||||
fn convert_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_id: ast::NodeId) {
|
||||
let def_id = tcx.hir().local_def_id(impl_item_id);
|
||||
fn convert_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_id: hir::HirId) {
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(impl_item_id);
|
||||
tcx.generics_of(def_id);
|
||||
tcx.type_of(def_id);
|
||||
tcx.predicates_of(def_id);
|
||||
if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item(impl_item_id).node {
|
||||
if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item_by_hir_id(impl_item_id).node {
|
||||
tcx.fn_sig(def_id);
|
||||
}
|
||||
}
|
||||
@ -532,7 +532,7 @@ fn convert_enum_variant_types<'a, 'tcx>(
|
||||
let wrapped_discr = prev_discr.map_or(initial, |d| d.wrap_incr(tcx));
|
||||
prev_discr = Some(
|
||||
if let Some(ref e) = variant.node.disr_expr {
|
||||
let expr_did = tcx.hir().local_def_id(e.id);
|
||||
let expr_did = tcx.hir().local_def_id_from_hir_id(e.hir_id);
|
||||
def.eval_explicit_discr(tcx, expr_did)
|
||||
} else if let Some(discr) = repr_type.disr_incr(tcx, prev_discr) {
|
||||
Some(discr)
|
||||
@ -637,7 +637,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad
|
||||
let did = tcx.hir().local_def_id(v.node.data.id());
|
||||
let discr = if let Some(ref e) = v.node.disr_expr {
|
||||
distance_from_explicit = 0;
|
||||
ty::VariantDiscr::Explicit(tcx.hir().local_def_id(e.id))
|
||||
ty::VariantDiscr::Explicit(tcx.hir().local_def_id_from_hir_id(e.hir_id))
|
||||
} else {
|
||||
ty::VariantDiscr::Relative(distance_from_explicit)
|
||||
};
|
||||
@ -1142,11 +1142,11 @@ fn report_assoc_ty_on_inherent_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span:
|
||||
fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
|
||||
use rustc::hir::*;
|
||||
|
||||
let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
|
||||
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
|
||||
let icx = ItemCtxt::new(tcx, def_id);
|
||||
|
||||
match tcx.hir().get(node_id) {
|
||||
match tcx.hir().get_by_hir_id(hir_id) {
|
||||
Node::TraitItem(item) => match item.node {
|
||||
TraitItemKind::Method(..) => {
|
||||
let substs = InternalSubsts::identity_for_item(tcx, def_id);
|
||||
@ -1166,7 +1166,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
|
||||
ImplItemKind::Const(ref ty, _) => icx.to_ty(ty),
|
||||
ImplItemKind::Existential(_) => {
|
||||
if tcx
|
||||
.impl_trait_ref(tcx.hir().get_parent_did(node_id))
|
||||
.impl_trait_ref(tcx.hir().get_parent_did_by_hir_id(hir_id))
|
||||
.is_none()
|
||||
{
|
||||
report_assoc_ty_on_inherent_impl(tcx, item.span);
|
||||
@ -1176,7 +1176,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
|
||||
}
|
||||
ImplItemKind::Type(ref ty) => {
|
||||
if tcx
|
||||
.impl_trait_ref(tcx.hir().get_parent_did(node_id))
|
||||
.impl_trait_ref(tcx.hir().get_parent_did_by_hir_id(hir_id))
|
||||
.is_none()
|
||||
{
|
||||
report_assoc_ty_on_inherent_impl(tcx, item.span);
|
||||
@ -1259,7 +1259,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
|
||||
..
|
||||
}) => match *def {
|
||||
VariantData::Unit(..) | VariantData::Struct(..) => {
|
||||
tcx.type_of(tcx.hir().get_parent_did(node_id))
|
||||
tcx.type_of(tcx.hir().get_parent_did_by_hir_id(hir_id))
|
||||
}
|
||||
VariantData::Tuple(..) => {
|
||||
let substs = InternalSubsts::identity_for_item(tcx, def_id);
|
||||
@ -1274,7 +1274,6 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
|
||||
..
|
||||
}) => {
|
||||
if gen.is_some() {
|
||||
let hir_id = tcx.hir().node_to_hir_id(node_id);
|
||||
return tcx.typeck_tables_of(def_id).node_type(hir_id);
|
||||
}
|
||||
|
||||
@ -1285,7 +1284,9 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
|
||||
tcx.mk_closure(def_id, substs)
|
||||
}
|
||||
|
||||
Node::AnonConst(_) => match tcx.hir().get(tcx.hir().get_parent_node(node_id)) {
|
||||
Node::AnonConst(_) => match tcx.hir().get_by_hir_id(
|
||||
tcx.hir().get_parent_node_by_hir_id(hir_id))
|
||||
{
|
||||
Node::Ty(&hir::Ty {
|
||||
node: hir::TyKind::Array(_, ref constant),
|
||||
..
|
||||
@ -1297,7 +1298,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
|
||||
| Node::Expr(&hir::Expr {
|
||||
node: ExprKind::Repeat(_, ref constant),
|
||||
..
|
||||
}) if constant.id == node_id =>
|
||||
}) if constant.hir_id == hir_id =>
|
||||
{
|
||||
tcx.types.usize
|
||||
}
|
||||
@ -1309,9 +1310,9 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
|
||||
..
|
||||
},
|
||||
..
|
||||
}) if e.id == node_id =>
|
||||
}) if e.hir_id == hir_id =>
|
||||
{
|
||||
tcx.adt_def(tcx.hir().get_parent_did(node_id))
|
||||
tcx.adt_def(tcx.hir().get_parent_did_by_hir_id(hir_id))
|
||||
.repr
|
||||
.discr_type()
|
||||
.to_ty(tcx)
|
||||
@ -1484,7 +1485,7 @@ fn find_existential_constraints<'a, 'tcx>(
|
||||
}
|
||||
}
|
||||
fn visit_impl_item(&mut self, it: &'tcx ImplItem) {
|
||||
let def_id = self.tcx.hir().local_def_id(it.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
// the existential type itself or its children are not within its reveal scope
|
||||
if def_id != self.def_id {
|
||||
self.check(def_id);
|
||||
@ -1492,7 +1493,7 @@ fn find_existential_constraints<'a, 'tcx>(
|
||||
}
|
||||
}
|
||||
fn visit_trait_item(&mut self, it: &'tcx TraitItem) {
|
||||
let def_id = self.tcx.hir().local_def_id(it.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
self.check(def_id);
|
||||
intravisit::walk_trait_item(self, it);
|
||||
}
|
||||
@ -2062,7 +2063,8 @@ fn explicit_predicates_of<'a, 'tcx>(
|
||||
};
|
||||
|
||||
let assoc_ty =
|
||||
tcx.mk_projection(tcx.hir().local_def_id(trait_item.id), self_trait_ref.substs);
|
||||
tcx.mk_projection(tcx.hir().local_def_id_from_hir_id(trait_item.hir_id),
|
||||
self_trait_ref.substs);
|
||||
|
||||
let bounds = compute_bounds(
|
||||
&ItemCtxt::new(tcx, def_id),
|
||||
|
@ -386,8 +386,8 @@ pub fn hir_trait_to_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_trait:
|
||||
// In case there are any projections etc, find the "environment"
|
||||
// def-id that will be used to determine the traits/predicates in
|
||||
// scope. This is derived from the enclosing item-like thing.
|
||||
let env_node_id = tcx.hir().get_parent(hir_trait.ref_id);
|
||||
let env_def_id = tcx.hir().local_def_id(env_node_id);
|
||||
let env_hir_id = tcx.hir().get_parent_item(hir_trait.hir_ref_id);
|
||||
let env_def_id = tcx.hir().local_def_id_from_hir_id(env_hir_id);
|
||||
let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id);
|
||||
let mut projections = Vec::new();
|
||||
let (principal, _) = astconv::AstConv::instantiate_poly_trait_ref_inner(
|
||||
|
@ -6,7 +6,6 @@
|
||||
use hir::def_id::DefId;
|
||||
use rustc::ty::subst::{UnpackedKind, SubstsRef};
|
||||
use rustc::ty::{self, Ty, TyCtxt};
|
||||
use syntax::ast;
|
||||
use rustc::hir;
|
||||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||
|
||||
@ -72,31 +71,31 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
|
||||
match item.node {
|
||||
hir::ItemKind::Struct(ref struct_def, _) |
|
||||
hir::ItemKind::Union(ref struct_def, _) => {
|
||||
self.visit_node_helper(item.id);
|
||||
self.visit_node_helper(item.hir_id);
|
||||
|
||||
if let hir::VariantData::Tuple(..) = *struct_def {
|
||||
self.visit_node_helper(struct_def.id());
|
||||
self.visit_node_helper(struct_def.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
hir::ItemKind::Enum(ref enum_def, _) => {
|
||||
self.visit_node_helper(item.id);
|
||||
self.visit_node_helper(item.hir_id);
|
||||
|
||||
for variant in &enum_def.variants {
|
||||
if let hir::VariantData::Tuple(..) = variant.node.data {
|
||||
self.visit_node_helper(variant.node.data.id());
|
||||
self.visit_node_helper(variant.node.data.hir_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hir::ItemKind::Fn(..) => {
|
||||
self.visit_node_helper(item.id);
|
||||
self.visit_node_helper(item.hir_id);
|
||||
}
|
||||
|
||||
hir::ItemKind::ForeignMod(ref foreign_mod) => {
|
||||
for foreign_item in &foreign_mod.items {
|
||||
if let hir::ForeignItemKind::Fn(..) = foreign_item.node {
|
||||
self.visit_node_helper(foreign_item.id);
|
||||
self.visit_node_helper(foreign_item.hir_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -107,21 +106,21 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem) {
|
||||
if let hir::TraitItemKind::Method(..) = trait_item.node {
|
||||
self.visit_node_helper(trait_item.id);
|
||||
self.visit_node_helper(trait_item.hir_id);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
|
||||
if let hir::ImplItemKind::Method(..) = impl_item.node {
|
||||
self.visit_node_helper(impl_item.id);
|
||||
self.visit_node_helper(impl_item.hir_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||
fn visit_node_helper(&mut self, id: ast::NodeId) {
|
||||
fn visit_node_helper(&mut self, id: hir::HirId) {
|
||||
let tcx = self.terms_cx.tcx;
|
||||
let def_id = tcx.hir().local_def_id(id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(id);
|
||||
self.build_constraints_for_item(def_id);
|
||||
}
|
||||
|
||||
@ -138,7 +137,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
let id = tcx.hir().as_local_node_id(def_id).unwrap();
|
||||
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
let inferred_start = self.terms_cx.inferred_starts[&id];
|
||||
let current_item = &CurrentItem { inferred_start };
|
||||
match tcx.type_of(def_id).sty {
|
||||
@ -356,7 +355,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
let (local, remote) = if let Some(id) = self.tcx().hir().as_local_node_id(def_id) {
|
||||
let (local, remote) = if let Some(id) = self.tcx().hir().as_local_hir_id(def_id) {
|
||||
(Some(self.terms_cx.inferred_starts[&id]), None)
|
||||
} else {
|
||||
(None, Some(self.tcx().variances_of(def_id)))
|
||||
|
@ -83,7 +83,7 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> {
|
||||
|
||||
let solutions = &self.solutions;
|
||||
self.terms_cx.inferred_starts.iter().map(|(&id, &InferredIndex(start))| {
|
||||
let def_id = tcx.hir().local_def_id(id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(id);
|
||||
let generics = tcx.generics_of(def_id);
|
||||
|
||||
let mut variances = solutions[start..start+generics.count()].to_vec();
|
||||
|
@ -12,10 +12,9 @@
|
||||
use arena::TypedArena;
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
use rustc::hir;
|
||||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||
use crate::util::nodemap::NodeMap;
|
||||
use crate::util::nodemap::HirIdMap;
|
||||
|
||||
use self::VarianceTerm::*;
|
||||
|
||||
@ -55,11 +54,11 @@ pub struct TermsContext<'a, 'tcx: 'a> {
|
||||
// For marker types, UnsafeCell, and other lang items where
|
||||
// variance is hardcoded, records the item-id and the hardcoded
|
||||
// variance.
|
||||
pub lang_items: Vec<(ast::NodeId, Vec<ty::Variance>)>,
|
||||
pub lang_items: Vec<(hir::HirId, Vec<ty::Variance>)>,
|
||||
|
||||
// Maps from the node id of an item to the first inferred index
|
||||
// used for its type & region parameters.
|
||||
pub inferred_starts: NodeMap<InferredIndex>,
|
||||
pub inferred_starts: HirIdMap<InferredIndex>,
|
||||
|
||||
// Maps from an InferredIndex to the term for that variable.
|
||||
pub inferred_terms: Vec<VarianceTermPtr<'a>>,
|
||||
@ -86,7 +85,7 @@ pub fn determine_parameters_to_be_inferred<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>
|
||||
terms_cx
|
||||
}
|
||||
|
||||
fn lang_items(tcx: TyCtxt<'_, '_, '_>) -> Vec<(ast::NodeId, Vec<ty::Variance>)> {
|
||||
fn lang_items(tcx: TyCtxt<'_, '_, '_>) -> Vec<(hir::HirId, Vec<ty::Variance>)> {
|
||||
let lang_items = tcx.lang_items();
|
||||
let all = vec![
|
||||
(lang_items.phantom_data(), vec![ty::Covariant]),
|
||||
@ -96,14 +95,14 @@ fn lang_items(tcx: TyCtxt<'_, '_, '_>) -> Vec<(ast::NodeId, Vec<ty::Variance>)>
|
||||
all.into_iter() // iterating over (Option<DefId>, Variance)
|
||||
.filter(|&(ref d,_)| d.is_some())
|
||||
.map(|(d, v)| (d.unwrap(), v)) // (DefId, Variance)
|
||||
.filter_map(|(d, v)| tcx.hir().as_local_node_id(d).map(|n| (n, v))) // (NodeId, Variance)
|
||||
.filter_map(|(d, v)| tcx.hir().as_local_hir_id(d).map(|n| (n, v))) // (HirId, Variance)
|
||||
.collect()
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TermsContext<'a, 'tcx> {
|
||||
fn add_inferreds_for_item(&mut self, id: ast::NodeId) {
|
||||
fn add_inferreds_for_item(&mut self, id: hir::HirId) {
|
||||
let tcx = self.tcx;
|
||||
let def_id = tcx.hir().local_def_id(id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(id);
|
||||
let count = tcx.generics_of(def_id).count();
|
||||
|
||||
if count == 0 {
|
||||
@ -134,31 +133,31 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
|
||||
match item.node {
|
||||
hir::ItemKind::Struct(ref struct_def, _) |
|
||||
hir::ItemKind::Union(ref struct_def, _) => {
|
||||
self.add_inferreds_for_item(item.id);
|
||||
self.add_inferreds_for_item(item.hir_id);
|
||||
|
||||
if let hir::VariantData::Tuple(..) = *struct_def {
|
||||
self.add_inferreds_for_item(struct_def.id());
|
||||
self.add_inferreds_for_item(struct_def.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
hir::ItemKind::Enum(ref enum_def, _) => {
|
||||
self.add_inferreds_for_item(item.id);
|
||||
self.add_inferreds_for_item(item.hir_id);
|
||||
|
||||
for variant in &enum_def.variants {
|
||||
if let hir::VariantData::Tuple(..) = variant.node.data {
|
||||
self.add_inferreds_for_item(variant.node.data.id());
|
||||
self.add_inferreds_for_item(variant.node.data.hir_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hir::ItemKind::Fn(..) => {
|
||||
self.add_inferreds_for_item(item.id);
|
||||
self.add_inferreds_for_item(item.hir_id);
|
||||
}
|
||||
|
||||
hir::ItemKind::ForeignMod(ref foreign_mod) => {
|
||||
for foreign_item in &foreign_mod.items {
|
||||
if let hir::ForeignItemKind::Fn(..) = foreign_item.node {
|
||||
self.add_inferreds_for_item(foreign_item.id);
|
||||
self.add_inferreds_for_item(foreign_item.hir_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,13 +168,13 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem) {
|
||||
if let hir::TraitItemKind::Method(..) = trait_item.node {
|
||||
self.add_inferreds_for_item(trait_item.id);
|
||||
self.add_inferreds_for_item(trait_item.hir_id);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
|
||||
if let hir::ImplItemKind::Method(..) = impl_item.node {
|
||||
self.add_inferreds_for_item(impl_item.id);
|
||||
self.add_inferreds_for_item(impl_item.hir_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,6 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
||||
if result.is_auto() {
|
||||
let trait_ = hir::TraitRef {
|
||||
path: get_path_for_type(self.cx.tcx, trait_def_id, hir::def::Def::Trait),
|
||||
ref_id: ast::DUMMY_NODE_ID,
|
||||
hir_ref_id: hir::DUMMY_HIR_ID,
|
||||
};
|
||||
|
||||
|
@ -123,7 +123,6 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
|
||||
path: get_path_for_type(infcx.tcx,
|
||||
trait_def_id,
|
||||
hir::def::Def::Trait),
|
||||
ref_id: ast::DUMMY_NODE_ID,
|
||||
hir_ref_id: hir::DUMMY_HIR_ID,
|
||||
};
|
||||
let provided_trait_methods =
|
||||
|
@ -2022,14 +2022,15 @@ impl Clean<Item> for hir::TraitItem {
|
||||
AssociatedTypeItem(bounds.clean(cx), default.clean(cx))
|
||||
}
|
||||
};
|
||||
let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
|
||||
Item {
|
||||
name: Some(self.ident.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.span.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: local_did,
|
||||
visibility: None,
|
||||
stability: get_stability(cx, cx.tcx.hir().local_def_id(self.id)),
|
||||
deprecation: get_deprecation(cx, cx.tcx.hir().local_def_id(self.id)),
|
||||
stability: get_stability(cx, local_did),
|
||||
deprecation: get_deprecation(cx, local_did),
|
||||
inner,
|
||||
}
|
||||
}
|
||||
@ -2054,14 +2055,15 @@ impl Clean<Item> for hir::ImplItem {
|
||||
generics: Generics::default(),
|
||||
}, true),
|
||||
};
|
||||
let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
|
||||
Item {
|
||||
name: Some(self.ident.name.clean(cx)),
|
||||
source: self.span.clean(cx),
|
||||
attrs: self.attrs.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: local_did,
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: get_stability(cx, cx.tcx.hir().local_def_id(self.id)),
|
||||
deprecation: get_deprecation(cx, cx.tcx.hir().local_def_id(self.id)),
|
||||
stability: get_stability(cx, local_did),
|
||||
deprecation: get_deprecation(cx, local_did),
|
||||
inner,
|
||||
}
|
||||
}
|
||||
@ -2531,7 +2533,7 @@ impl Clean<Type> for hir::Ty {
|
||||
}
|
||||
TyKind::Slice(ref ty) => Slice(box ty.clean(cx)),
|
||||
TyKind::Array(ref ty, ref length) => {
|
||||
let def_id = cx.tcx.hir().local_def_id(length.id);
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(length.hir_id);
|
||||
let param_env = cx.tcx.param_env(def_id);
|
||||
let substs = InternalSubsts::identity_for_item(cx.tcx, def_id);
|
||||
let cid = GlobalId {
|
||||
|
@ -473,9 +473,9 @@ fn resolution_failure(
|
||||
) {
|
||||
let sp = span_of_attrs(attrs);
|
||||
|
||||
let mut diag = cx.tcx.struct_span_lint_node(
|
||||
let mut diag = cx.tcx.struct_span_lint_hir(
|
||||
lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE,
|
||||
NodeId::from_u32(0),
|
||||
hir::CRATE_HIR_ID,
|
||||
sp,
|
||||
&format!("`[{}]` cannot be resolved, ignoring it...", path_str),
|
||||
);
|
||||
|
@ -1,12 +1,12 @@
|
||||
//! Contains information about "passes", used to modify crate information during the documentation
|
||||
//! process.
|
||||
|
||||
use rustc::hir;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::lint as lint;
|
||||
use rustc::middle::privacy::AccessLevels;
|
||||
use rustc::util::nodemap::DefIdSet;
|
||||
use std::mem;
|
||||
use syntax::ast::NodeId;
|
||||
use syntax_pos::{DUMMY_SP, Span};
|
||||
use std::ops::Range;
|
||||
|
||||
@ -312,18 +312,18 @@ pub fn look_for_tests<'a, 'tcx: 'a, 'rcx: 'a>(
|
||||
|
||||
if find_testable_code(&dox, &mut tests, ErrorCodes::No).is_ok() {
|
||||
if check_missing_code == true && tests.found_tests == 0 {
|
||||
let mut diag = cx.tcx.struct_span_lint_node(
|
||||
let mut diag = cx.tcx.struct_span_lint_hir(
|
||||
lint::builtin::MISSING_DOC_CODE_EXAMPLES,
|
||||
NodeId::from_u32(0),
|
||||
hir::CRATE_HIR_ID,
|
||||
span_of_attrs(&item.attrs),
|
||||
"Missing code example in this documentation");
|
||||
diag.emit();
|
||||
} else if check_missing_code == false &&
|
||||
tests.found_tests > 0 &&
|
||||
!cx.renderinfo.borrow().access_levels.is_doc_reachable(item.def_id) {
|
||||
let mut diag = cx.tcx.struct_span_lint_node(
|
||||
let mut diag = cx.tcx.struct_span_lint_hir(
|
||||
lint::builtin::PRIVATE_DOC_TESTS,
|
||||
NodeId::from_u32(0),
|
||||
hir::CRATE_HIR_ID,
|
||||
span_of_attrs(&item.attrs),
|
||||
"Documentation test in private item");
|
||||
diag.emit();
|
||||
|
Loading…
Reference in New Issue
Block a user