Skip to content

Commit 812854c

Browse files
committed
Remove usage of DUMMY_HIR_ID in calls to ObligationClause::misc
Use `ObligationClause::dummy()` when appropriate or replace `hir::DUMMY_HIR_ID` by `hir::CRATE_HIR_ID`, as used in `ObligationClause::dummy()`.
1 parent 4d1fbac commit 812854c

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

src/librustc_trait_selection/traits/auto_trait.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
187187
// to store all of the necessary region/lifetime bounds in the InferContext, as well as
188188
// an additional sanity check.
189189
let mut fulfill = FulfillmentContext::new();
190-
fulfill.register_bound(
191-
&infcx,
192-
full_env,
193-
ty,
194-
trait_did,
195-
ObligationCause::misc(DUMMY_SP, hir::DUMMY_HIR_ID),
196-
);
190+
fulfill.register_bound(&infcx, full_env, ty, trait_did, ObligationCause::dummy());
197191
fulfill.select_all_or_error(&infcx).unwrap_or_else(|e| {
198192
panic!("Unable to fulfill trait {:?} for '{:?}': {:?}", trait_did, ty, e)
199193
});
@@ -292,7 +286,7 @@ impl AutoTraitFinder<'tcx> {
292286
user_env.caller_bounds.iter().cloned().collect();
293287

294288
let mut new_env = param_env;
295-
let dummy_cause = ObligationCause::misc(DUMMY_SP, hir::DUMMY_HIR_ID);
289+
let dummy_cause = ObligationCause::dummy();
296290

297291
while let Some(pred) = predicates.pop_front() {
298292
infcx.clear_caches();
@@ -615,7 +609,7 @@ impl AutoTraitFinder<'tcx> {
615609
select: &mut SelectionContext<'_, 'tcx>,
616610
only_projections: bool,
617611
) -> bool {
618-
let dummy_cause = ObligationCause::misc(DUMMY_SP, hir::DUMMY_HIR_ID);
612+
let dummy_cause = ObligationCause::dummy();
619613

620614
for (obligation, mut predicate) in nested.map(|o| (o.clone(), o.predicate)) {
621615
let is_new_pred = fresh_preds.insert(self.clean_pred(select.infcx(), predicate));

src/librustc_trait_selection/traits/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_middle::middle::region;
3131
use rustc_middle::ty::fold::TypeFoldable;
3232
use rustc_middle::ty::subst::{InternalSubsts, SubstsRef};
3333
use rustc_middle::ty::{self, GenericParamDefKind, ToPredicate, Ty, TyCtxt, WithConstness};
34-
use rustc_span::{Span, DUMMY_SP};
34+
use rustc_span::Span;
3535

3636
use std::fmt::Debug;
3737

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

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

src/librustc_traits/normalize_projection_ty.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
use rustc_hir as hir;
21
use rustc_infer::infer::canonical::{Canonical, QueryResponse};
32
use rustc_infer::infer::TyCtxtInferExt;
43
use rustc_infer::traits::TraitEngineExt as _;
54
use rustc_middle::ty::query::Providers;
65
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
7-
use rustc_span::DUMMY_SP;
86
use rustc_trait_selection::infer::InferCtxtBuilderExt;
97
use rustc_trait_selection::traits::query::{
108
normalize::NormalizationResult, CanonicalProjectionGoal, NoSolution,
@@ -27,7 +25,7 @@ fn normalize_projection_ty<'tcx>(
2725
&goal,
2826
|infcx, fulfill_cx, ParamEnvAnd { param_env, value: goal }| {
2927
let selcx = &mut SelectionContext::new(infcx);
30-
let cause = ObligationCause::misc(DUMMY_SP, hir::DUMMY_HIR_ID);
28+
let cause = ObligationCause::dummy();
3129
let mut obligations = vec![];
3230
let answer = traits::normalize_projection_type(
3331
selcx,

0 commit comments

Comments
 (0)