Skip to content

Commit 7658e0f

Browse files
committed
Stop passing the self-type as a separate argument.
1 parent a4da3f8 commit 7658e0f

File tree

38 files changed

+113
-164
lines changed

38 files changed

+113
-164
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
489489
// but the type has region variables, so erase those.
490490
tcx.infer_ctxt()
491491
.build()
492-
.type_implements_trait(
493-
default_trait,
494-
tcx.erase_regions(ty),
495-
ty::List::empty(),
496-
param_env,
497-
)
492+
.type_implements_trait(default_trait, [tcx.erase_regions(ty)], param_env)
498493
.must_apply_modulo_regions()
499494
};
500495

@@ -1707,7 +1702,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17071702
err.span_label(borrow_span, note);
17081703

17091704
let tcx = self.infcx.tcx;
1710-
let ty_params = ty::List::empty();
17111705

17121706
let return_ty = self.regioncx.universal_regions().unnormalized_output_ty;
17131707
let return_ty = tcx.erase_regions(return_ty);
@@ -1716,7 +1710,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17161710
if let Some(iter_trait) = tcx.get_diagnostic_item(sym::Iterator)
17171711
&& self
17181712
.infcx
1719-
.type_implements_trait(iter_trait, return_ty, ty_params, self.param_env)
1713+
.type_implements_trait(iter_trait, [return_ty], self.param_env)
17201714
.must_apply_modulo_regions()
17211715
{
17221716
err.span_suggestion_hidden(

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
547547

548548
if let PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) = context {
549549
let tcx = self.tcx();
550-
let trait_ref = tcx.at(self.last_span).mk_trait_ref(LangItem::Copy, place_ty.ty, []);
550+
let trait_ref = tcx.at(self.last_span).mk_trait_ref(LangItem::Copy, [place_ty.ty]);
551551

552552
// To have a `Copy` operand, the type `T` of the
553553
// value must be `Copy`. Note that we prove that `T: Copy`,
@@ -1271,7 +1271,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
12711271
self.check_rvalue(body, rv, location);
12721272
if !self.unsized_feature_enabled() {
12731273
let trait_ref =
1274-
tcx.at(self.last_span).mk_trait_ref(LangItem::Sized, place_ty, []);
1274+
tcx.at(self.last_span).mk_trait_ref(LangItem::Sized, [place_ty]);
12751275
self.prove_trait_ref(
12761276
trait_ref,
12771277
location.to_locations(),
@@ -1860,7 +1860,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18601860
Operand::Move(place) => {
18611861
// Make sure that repeated elements implement `Copy`.
18621862
let ty = place.ty(body, tcx).ty;
1863-
let trait_ref = tcx.at(span).mk_trait_ref(LangItem::Copy, ty, []);
1863+
let trait_ref = tcx.at(span).mk_trait_ref(LangItem::Copy, [ty]);
18641864

18651865
self.prove_trait_ref(
18661866
trait_ref,
@@ -1873,7 +1873,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18731873
}
18741874

18751875
&Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, ty) => {
1876-
let trait_ref = tcx.at(span).mk_trait_ref(LangItem::Sized, ty, []);
1876+
let trait_ref = tcx.at(span).mk_trait_ref(LangItem::Sized, [ty]);
18771877

18781878
self.prove_trait_ref(
18791879
trait_ref,
@@ -1885,7 +1885,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18851885
Rvalue::ShallowInitBox(operand, ty) => {
18861886
self.check_operand(operand, location);
18871887

1888-
let trait_ref = tcx.at(span).mk_trait_ref(LangItem::Sized, *ty, []);
1888+
let trait_ref = tcx.at(span).mk_trait_ref(LangItem::Sized, [*ty]);
18891889

18901890
self.prove_trait_ref(
18911891
trait_ref,
@@ -1982,11 +1982,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19821982

19831983
CastKind::Pointer(PointerCast::Unsize) => {
19841984
let &ty = ty;
1985-
let trait_ref = tcx.at(span).mk_trait_ref(
1986-
LangItem::CoerceUnsized,
1987-
op.ty(body, tcx),
1988-
[ty.into()],
1989-
);
1985+
let trait_ref = tcx
1986+
.at(span)
1987+
.mk_trait_ref(LangItem::CoerceUnsized, [op.ty(body, tcx), ty]);
19901988

19911989
self.prove_trait_ref(
19921990
trait_ref,

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl Qualif for NeedsNonConstDrop {
158158
ObligationCause::dummy_with_span(cx.body.span),
159159
cx.param_env,
160160
ty::Binder::dummy(ty::TraitPredicate {
161-
trait_ref: cx.tcx.at(cx.body.span).mk_trait_ref(LangItem::Destruct, ty, []),
161+
trait_ref: cx.tcx.at(cx.body.span).mk_trait_ref(LangItem::Destruct, [ty]),
162162
constness: ty::BoundConstness::ConstIfConst,
163163
polarity: ty::ImplPolarity::Positive,
164164
}),

compiler/rustc_hir_analysis/src/bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'tcx> Bounds<'tcx> {
6262
let sized_predicate = self.implicitly_sized.and_then(|span| {
6363
// FIXME: use tcx.at(span).mk_trait_ref(LangItem::Sized) here? This may make no-core code harder to write.
6464
let sized = tcx.lang_items().sized_trait()?;
65-
let trait_ref = ty::Binder::dummy(tcx.mk_trait_ref(sized, param_ty, []));
65+
let trait_ref = ty::Binder::dummy(tcx.mk_trait_ref(sized, [param_ty]));
6666
Some((trait_ref.without_const().to_predicate(tcx), span))
6767
});
6868

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ fn receiver_is_implemented<'tcx>(
17821782
receiver_ty: Ty<'tcx>,
17831783
) -> bool {
17841784
let tcx = wfcx.tcx();
1785-
let trait_ref = ty::Binder::dummy(tcx.mk_trait_ref(receiver_trait_def_id, receiver_ty, []));
1785+
let trait_ref = ty::Binder::dummy(tcx.mk_trait_ref(receiver_trait_def_id, [receiver_ty]));
17861786

17871787
let obligation = traits::Obligation::new(tcx, cause, wfcx.param_env, trait_ref.without_const());
17881788

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,7 @@ fn visit_implementation_of_dispatch_from_dyn<'tcx>(tcx: TyCtxt<'tcx>, impl_did:
315315
cause.clone(),
316316
dispatch_from_dyn_trait,
317317
0,
318-
field.ty(tcx, substs_a),
319-
[field.ty(tcx, substs_b).into()],
318+
[field.ty(tcx, substs_a), field.ty(tcx, substs_b)],
320319
)
321320
}),
322321
);
@@ -558,7 +557,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
558557
// Register an obligation for `A: Trait<B>`.
559558
let cause = traits::ObligationCause::misc(span, impl_hir_id);
560559
let predicate =
561-
predicate_for_trait_def(tcx, param_env, cause, trait_def_id, 0, source, [target.into()]);
560+
predicate_for_trait_def(tcx, param_env, cause, trait_def_id, 0, [source, target]);
562561
let errors = traits::fully_solve_obligation(&infcx, predicate);
563562
if !errors.is_empty() {
564563
infcx.err_ctxt().report_fulfillment_errors(&errors, None);

compiler/rustc_hir_typeck/src/cast.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,9 @@ impl<'a, 'tcx> CastCheck<'tcx> {
498498
let ty = fcx.tcx.erase_regions(ty);
499499
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
500500
let expr_ty = fcx.tcx.erase_regions(expr_ty);
501-
let ty_params = fcx.tcx.mk_substs(std::iter::once(ty::GenericArg::from(expr_ty)));
502501
if fcx
503502
.infcx
504-
.type_implements_trait(from_trait, ty, ty_params, fcx.param_env)
503+
.type_implements_trait(from_trait, [ty, expr_ty], fcx.param_env)
505504
.must_apply_modulo_regions()
506505
{
507506
label = false;

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
630630
cause,
631631
coerce_unsized_did,
632632
0,
633-
coerce_source,
634-
[coerce_target.into()]
633+
[coerce_source, coerce_target]
635634
)];
636635

637636
let mut has_unsized_tuple_coercion = false;
@@ -1086,8 +1085,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10861085
self.infcx
10871086
.type_implements_trait(
10881087
self.tcx.lang_items().deref_mut_trait()?,
1089-
expr_ty,
1090-
ty::List::empty(),
1088+
[expr_ty],
10911089
self.param_env,
10921090
)
10931091
.may_apply()

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,8 +1119,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11191119
.infcx
11201120
.type_implements_trait(
11211121
self.tcx.lang_items().sized_trait().unwrap(),
1122-
lhs_deref_ty,
1123-
ty::List::empty(),
1122+
[lhs_deref_ty],
11241123
self.param_env,
11251124
)
11261125
.may_apply();

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10951095
self.param_env,
10961096
ty::Binder::dummy(self.tcx.mk_trait_ref(
10971097
into_def_id,
1098-
expr_ty, [expected_ty.into()]
1098+
[expr_ty, expected_ty]
10991099
))
11001100
.to_poly_trait_predicate(),
11011101
))

0 commit comments

Comments
 (0)