Skip to content

Commit

Permalink
Remove usage of DUMMY_HIR_ID in calls to ObligationClause::misc
Browse files Browse the repository at this point in the history
Use `ObligationClause::dummy()` when appropriate or replace
`hir::DUMMY_HIR_ID` by `hir::CRATE_HIR_ID`, as used in
`ObligationClause::dummy()`.
  • Loading branch information
marmeladema committed Apr 12, 2020
1 parent 4d1fbac commit 812854c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
12 changes: 3 additions & 9 deletions src/librustc_trait_selection/traits/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
// to store all of the necessary region/lifetime bounds in the InferContext, as well as
// an additional sanity check.
let mut fulfill = FulfillmentContext::new();
fulfill.register_bound(
&infcx,
full_env,
ty,
trait_did,
ObligationCause::misc(DUMMY_SP, hir::DUMMY_HIR_ID),
);
fulfill.register_bound(&infcx, full_env, ty, trait_did, ObligationCause::dummy());
fulfill.select_all_or_error(&infcx).unwrap_or_else(|e| {
panic!("Unable to fulfill trait {:?} for '{:?}': {:?}", trait_did, ty, e)
});
Expand Down Expand Up @@ -292,7 +286,7 @@ impl AutoTraitFinder<'tcx> {
user_env.caller_bounds.iter().cloned().collect();

let mut new_env = param_env;
let dummy_cause = ObligationCause::misc(DUMMY_SP, hir::DUMMY_HIR_ID);
let dummy_cause = ObligationCause::dummy();

while let Some(pred) = predicates.pop_front() {
infcx.clear_caches();
Expand Down Expand Up @@ -615,7 +609,7 @@ impl AutoTraitFinder<'tcx> {
select: &mut SelectionContext<'_, 'tcx>,
only_projections: bool,
) -> bool {
let dummy_cause = ObligationCause::misc(DUMMY_SP, hir::DUMMY_HIR_ID);
let dummy_cause = ObligationCause::dummy();

for (obligation, mut predicate) in nested.map(|o| (o.clone(), o.predicate)) {
let is_new_pred = fresh_preds.insert(self.clean_pred(select.infcx(), predicate));
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trait_selection/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use rustc_middle::middle::region;
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::subst::{InternalSubsts, SubstsRef};
use rustc_middle::ty::{self, GenericParamDefKind, ToPredicate, Ty, TyCtxt, WithConstness};
use rustc_span::{Span, DUMMY_SP};
use rustc_span::Span;

use std::fmt::Debug;

Expand Down Expand Up @@ -136,7 +136,7 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'tcx>(
let trait_ref = ty::TraitRef { def_id, substs: infcx.tcx.mk_substs_trait(ty, &[]) };
let obligation = Obligation {
param_env,
cause: ObligationCause::misc(span, hir::DUMMY_HIR_ID),
cause: ObligationCause::misc(span, hir::CRATE_HIR_ID),
recursion_depth: 0,
predicate: trait_ref.without_const().to_predicate(),
};
Expand All @@ -163,7 +163,7 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'tcx>(
// We can use a dummy node-id here because we won't pay any mind
// to region obligations that arise (there shouldn't really be any
// anyhow).
let cause = ObligationCause::misc(span, hir::DUMMY_HIR_ID);
let cause = ObligationCause::misc(span, hir::CRATE_HIR_ID);

fulfill_cx.register_bound(infcx, param_env, ty, def_id, cause);

Expand Down
4 changes: 1 addition & 3 deletions src/librustc_traits/normalize_projection_ty.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use rustc_hir as hir;
use rustc_infer::infer::canonical::{Canonical, QueryResponse};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_infer::traits::TraitEngineExt as _;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
use rustc_span::DUMMY_SP;
use rustc_trait_selection::infer::InferCtxtBuilderExt;
use rustc_trait_selection::traits::query::{
normalize::NormalizationResult, CanonicalProjectionGoal, NoSolution,
Expand All @@ -27,7 +25,7 @@ fn normalize_projection_ty<'tcx>(
&goal,
|infcx, fulfill_cx, ParamEnvAnd { param_env, value: goal }| {
let selcx = &mut SelectionContext::new(infcx);
let cause = ObligationCause::misc(DUMMY_SP, hir::DUMMY_HIR_ID);
let cause = ObligationCause::dummy();
let mut obligations = vec![];
let answer = traits::normalize_projection_type(
selcx,
Expand Down

0 comments on commit 812854c

Please sign in to comment.