-
- crate fn trait_method(
- &mut self,
- trait_def_id: DefId,
- method_name: Symbol,
- self_ty: Ty<'tcx>,
- params: &[GenericArg<'tcx>],
- ) -> &'tcx ty::Const<'tcx> {
- let substs = self.tcx.mk_substs_trait(self_ty, params);
-
- // The unhygienic comparison here is acceptable because this is only
- // used on known traits.
- let item = self
- .tcx
- .associated_items(trait_def_id)
- .filter_by_name_unhygienic(method_name)
- .find(|item| item.kind == ty::AssocKind::Fn)
- .expect("trait method not found");
-
- let method_ty = self.tcx.type_of(item.def_id);
- let method_ty = method_ty.subst(self.tcx, substs);
- ty::Const::zero_sized(self.tcx, method_ty)
- }
-
- crate fn all_fields(&mut self, adt_def: &ty::AdtDef, variant_index: VariantIdx) -> Vec<Field> {
- (0..adt_def.variants[variant_index].fields.len()).map(Field::new).collect()
- }
-
- crate fn needs_drop(&mut self, ty: Ty<'tcx>) -> bool {
- ty.needs_drop(self.tcx, self.param_env)
- }
-
- crate fn infcx(&self) -> &'a InferCtxt<'a, 'tcx> {
- self.infcx
- }
-
- crate fn tcx(&self) -> TyCtxt<'tcx> {
- self.tcx
- }
-
- crate fn typeck_results(&self) -> &'a ty::TypeckResults<'tcx> {
- self.typeck_results
- }
-
- crate fn check_overflow(&self) -> bool {
- self.check_overflow
- }
-
- crate fn type_is_copy_modulo_regions(&self, ty: Ty<'tcx>, span: Span) -> bool {
- self.infcx.type_is_copy_modulo_regions(self.param_env, ty, span)
- }