Skip to content

Commit 25c4760

Browse files
committed
Some cleanup around trait_method lookup
1 parent 9e4c3f4 commit 25c4760

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

compiler/rustc_mir_build/src/build/matches/test.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
250250
let ref_str_ty = tcx.mk_imm_ref(re_erased, tcx.types.str_);
251251
let ref_str = self.temp(ref_str_ty, test.span);
252252
let deref = tcx.require_lang_item(LangItem::Deref, None);
253-
let method = trait_method(tcx, deref, sym::deref, ty, &[]);
253+
let method = trait_method(tcx, deref, sym::deref, ty, []);
254254
let eq_block = self.cfg.start_new_block();
255255
self.cfg.push_assign(block, source_info, ref_string, Rvalue::Ref(re_erased, BorrowKind::Shared, place));
256256
self.cfg.terminate(
@@ -444,8 +444,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
444444
bug!("non_scalar_compare called on non-reference type: {}", ty);
445445
};
446446

447-
let eq_def_id = self.tcx.require_lang_item(LangItem::PartialEq, None);
448-
let method = trait_method(self.tcx, eq_def_id, sym::eq, deref_ty, &[deref_ty.into()]);
447+
let eq_def_id = self.tcx.require_lang_item(LangItem::PartialEq, Some(source_info.span));
448+
let method = trait_method(self.tcx, eq_def_id, sym::eq, deref_ty, [deref_ty.into()]);
449449

450450
let bool_ty = self.tcx.types.bool;
451451
let eq_result = self.temp(bool_ty, source_info.span);
@@ -838,9 +838,9 @@ fn trait_method<'tcx>(
838838
trait_def_id: DefId,
839839
method_name: Symbol,
840840
self_ty: Ty<'tcx>,
841-
params: &[GenericArg<'tcx>],
841+
params: impl IntoIterator<Item = GenericArg<'tcx>, IntoIter: ExactSizeIterator>,
842842
) -> ConstantKind<'tcx> {
843-
let substs = tcx.mk_substs_trait(self_ty, params.iter().copied());
843+
let substs = tcx.mk_substs_trait(self_ty, params);
844844

845845
// The unhygienic comparison here is acceptable because this is only
846846
// used on known traits.
@@ -850,8 +850,7 @@ fn trait_method<'tcx>(
850850
.find(|item| item.kind == ty::AssocKind::Fn)
851851
.expect("trait method not found");
852852

853-
let method_ty = tcx.bound_type_of(item.def_id);
854-
let method_ty = method_ty.subst(tcx, substs);
853+
let method_ty = tcx.mk_fn_def(item.def_id, substs);
855854

856855
ConstantKind::zero_sized(method_ty)
857856
}

compiler/rustc_mir_build/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! This crate also contains the match exhaustiveness and usefulness checking.
44
#![allow(rustc::potential_query_instability)]
55
#![feature(assert_matches)]
6+
#![feature(associated_type_bounds)]
67
#![feature(box_patterns)]
78
#![feature(control_flow_enum)]
89
#![feature(if_let_guard)]

0 commit comments

Comments
 (0)