Skip to content

Commit

Permalink
hir: remove NodeId from TraitRef
Browse files Browse the repository at this point in the history
  • Loading branch information
ljedrz committed Mar 1, 2019
1 parent aa6a9c3 commit 01cf66b
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 15 deletions.
7 changes: 2 additions & 5 deletions src/librustc/hir/lowering.rs
Expand Up @@ -2338,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![],
Expand Down Expand Up @@ -2714,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,
}
}
Expand Down Expand Up @@ -5056,7 +5054,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,
Expand Down
1 change: 0 additions & 1 deletion src/librustc/hir/mod.rs
Expand Up @@ -2062,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,
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustc/ich/impls_hir.rs
Expand Up @@ -385,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,
});
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_typeck/astconv.rs
Expand Up @@ -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))
}));
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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| {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/lib.rs
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/clean/auto_trait.rs
Expand Up @@ -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,
};

Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/clean/blanket_impl.rs
Expand Up @@ -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 =
Expand Down

0 comments on commit 01cf66b

Please sign in to comment.