Skip to content

Commit c727edc

Browse files
committed
Remove some useless ty::Binder::dummy calls
1 parent 91d495f commit c727edc

File tree

5 files changed

+14
-32
lines changed

5 files changed

+14
-32
lines changed

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,7 @@ fn receiver_is_implemented<'tcx>(
17841784
receiver_ty: Ty<'tcx>,
17851785
) -> bool {
17861786
let tcx = wfcx.tcx();
1787-
let trait_ref = ty::Binder::dummy(ty::TraitRef::new(tcx, receiver_trait_def_id, [receiver_ty]));
1787+
let trait_ref = ty::TraitRef::new(tcx, receiver_trait_def_id, [receiver_ty]);
17881788

17891789
let obligation = traits::Obligation::new(tcx, cause, wfcx.param_env, trait_ref);
17901790

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,11 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
340340
tcx,
341341
cause.clone(),
342342
param_env,
343-
ty::Binder::dummy(ty::TraitRef::new(
343+
ty::TraitRef::new(
344344
tcx,
345345
dispatch_from_dyn_trait,
346346
[field.ty(tcx, substs_a), field.ty(tcx, substs_b)],
347-
)),
347+
),
348348
));
349349
}
350350
let errors = ocx.select_all_or_error();

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,10 +1096,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10961096
self.tcx,
10971097
self.misc(expr.span),
10981098
self.param_env,
1099-
ty::Binder::dummy(ty::TraitRef::new(self.tcx,
1099+
ty::TraitRef::new(self.tcx,
11001100
into_def_id,
11011101
[expr_ty, expected_ty]
1102-
)),
1102+
),
11031103
))
11041104
{
11051105
let sugg = if expr.precedence().order() >= PREC_POSTFIX {
@@ -1438,7 +1438,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14381438
&& !results.expr_adjustments(callee_expr).iter().any(|adj| matches!(adj.kind, ty::adjustment::Adjust::Deref(..)))
14391439
// Check that we're in fact trying to clone into the expected type
14401440
&& self.can_coerce(*pointee_ty, expected_ty)
1441-
&& let trait_ref = ty::Binder::dummy(ty::TraitRef::new(self.tcx, clone_trait_did, [expected_ty]))
1441+
&& let trait_ref = ty::TraitRef::new(self.tcx, clone_trait_did, [expected_ty])
14421442
// And the expected type doesn't implement `Clone`
14431443
&& !self.predicate_must_hold_considering_regions(&traits::Obligation::new(
14441444
self.tcx,

compiler/rustc_trait_selection/src/solve/trait_goals.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
313313
Self::consider_implied_clause(
314314
ecx,
315315
goal,
316-
ty::Binder::dummy(ty::TraitRef::new(
317-
tcx,
318-
goal.predicate.def_id(),
319-
[self_ty, generator.resume_ty()],
320-
))
321-
.to_predicate(tcx),
316+
ty::TraitRef::new(tcx, goal.predicate.def_id(), [self_ty, generator.resume_ty()])
317+
.to_predicate(tcx),
322318
// Technically, we need to check that the generator types are Sized,
323319
// but that's already proven by the generator being WF.
324320
[],
@@ -363,10 +359,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
363359
data.iter().map(|pred| goal.with(tcx, pred.with_self_ty(tcx, a_ty))),
364360
);
365361
// The type must be Sized to be unsized.
366-
ecx.add_goal(goal.with(
367-
tcx,
368-
ty::Binder::dummy(ty::TraitRef::new(tcx, sized_def_id, [a_ty])),
369-
));
362+
ecx.add_goal(goal.with(tcx, ty::TraitRef::new(tcx, sized_def_id, [a_ty])));
370363
// The type must outlive the lifetime of the `dyn` we're unsizing into.
371364
ecx.add_goal(
372365
goal.with(tcx, ty::Binder::dummy(ty::OutlivesPredicate(a_ty, region))),
@@ -415,11 +408,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
415408
ecx.eq(goal.param_env, unsized_a_ty, b_ty)?;
416409
ecx.add_goal(goal.with(
417410
tcx,
418-
ty::Binder::dummy(ty::TraitRef::new(
419-
tcx,
420-
goal.predicate.def_id(),
421-
[a_tail_ty, b_tail_ty],
422-
)),
411+
ty::TraitRef::new(tcx, goal.predicate.def_id(), [a_tail_ty, b_tail_ty]),
423412
));
424413
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
425414
}
@@ -438,11 +427,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
438427
// Similar to ADTs, require that the rest of the fields are equal.
439428
ecx.add_goal(goal.with(
440429
tcx,
441-
ty::Binder::dummy(ty::TraitRef::new(
442-
tcx,
443-
goal.predicate.def_id(),
444-
[*a_last_ty, *b_last_ty],
445-
)),
430+
ty::TraitRef::new(tcx, goal.predicate.def_id(), [*a_last_ty, *b_last_ty]),
446431
));
447432
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
448433
}

compiler/rustc_trait_selection/src/traits/object_safety.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ fn receiver_is_dispatchable<'tcx>(
784784
if param.index == 0 { unsized_self_ty.into() } else { tcx.mk_param_from_def(param) }
785785
});
786786

787-
ty::Binder::dummy(ty::TraitRef::new(tcx, trait_def_id, substs)).to_predicate(tcx)
787+
ty::TraitRef::new(tcx, trait_def_id, substs).to_predicate(tcx)
788788
};
789789

790790
let caller_bounds =
@@ -799,11 +799,8 @@ fn receiver_is_dispatchable<'tcx>(
799799

800800
// Receiver: DispatchFromDyn<Receiver[Self => U]>
801801
let obligation = {
802-
let predicate = ty::Binder::dummy(ty::TraitRef::new(
803-
tcx,
804-
dispatch_from_dyn_did,
805-
[receiver_ty, unsized_receiver_ty],
806-
));
802+
let predicate =
803+
ty::TraitRef::new(tcx, dispatch_from_dyn_did, [receiver_ty, unsized_receiver_ty]);
807804

808805
Obligation::new(tcx, ObligationCause::dummy(), param_env, predicate)
809806
};

0 commit comments

Comments
 (0)