|
7 | 7 | //! [rustc dev guide]:https://rustc-dev-guide.rust-lang.org/traits/resolution.html#candidate-assembly
|
8 | 8 | use hir::LangItem;
|
9 | 9 | use rustc_hir as hir;
|
10 |
| -use rustc_hir::def_id::DefId; |
11 |
| -use rustc_infer::traits::ObligationCause; |
12 | 10 | use rustc_infer::traits::{Obligation, SelectionError, TraitObligation};
|
13 |
| -use rustc_lint_defs::builtin::DEREF_INTO_DYN_SUPERTRAIT; |
14 | 11 | use rustc_middle::ty::print::with_no_trimmed_paths;
|
15 |
| -use rustc_middle::ty::{self, ToPredicate, Ty, TypeVisitable}; |
| 12 | +use rustc_middle::ty::{self, TypeVisitable}; |
16 | 13 | use rustc_target::spec::abi::Abi;
|
17 | 14 |
|
18 |
| -use crate::traits; |
19 | 15 | use crate::traits::coherence::Conflict;
|
20 |
| -use crate::traits::query::evaluate_obligation::InferCtxtExt; |
21 | 16 | use crate::traits::{util, SelectionResult};
|
22 | 17 | use crate::traits::{Ambiguous, ErrorReporting, Overflow, Unimplemented};
|
23 | 18 |
|
@@ -702,56 +697,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
702 | 697 | })
|
703 | 698 | }
|
704 | 699 |
|
705 |
| - /// Temporary migration for #89190 |
706 |
| - fn need_migrate_deref_output_trait_object( |
707 |
| - &mut self, |
708 |
| - ty: Ty<'tcx>, |
709 |
| - param_env: ty::ParamEnv<'tcx>, |
710 |
| - cause: &ObligationCause<'tcx>, |
711 |
| - ) -> Option<(Ty<'tcx>, DefId)> { |
712 |
| - let tcx = self.tcx(); |
713 |
| - if tcx.features().trait_upcasting { |
714 |
| - return None; |
715 |
| - } |
716 |
| - |
717 |
| - // <ty as Deref> |
718 |
| - let trait_ref = ty::TraitRef { |
719 |
| - def_id: tcx.lang_items().deref_trait()?, |
720 |
| - substs: tcx.mk_substs_trait(ty, &[]), |
721 |
| - }; |
722 |
| - |
723 |
| - let obligation = traits::Obligation::new( |
724 |
| - cause.clone(), |
725 |
| - param_env, |
726 |
| - ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx), |
727 |
| - ); |
728 |
| - if !self.infcx.predicate_may_hold(&obligation) { |
729 |
| - return None; |
730 |
| - } |
731 |
| - |
732 |
| - let ty = traits::normalize_projection_type( |
733 |
| - self, |
734 |
| - param_env, |
735 |
| - ty::ProjectionTy { |
736 |
| - item_def_id: tcx.lang_items().deref_target()?, |
737 |
| - substs: trait_ref.substs, |
738 |
| - }, |
739 |
| - cause.clone(), |
740 |
| - 0, |
741 |
| - // We're *intentionally* throwing these away, |
742 |
| - // since we don't actually use them. |
743 |
| - &mut vec![], |
744 |
| - ) |
745 |
| - .ty() |
746 |
| - .unwrap(); |
747 |
| - |
748 |
| - if let ty::Dynamic(data, ..) = ty.kind() { |
749 |
| - Some((ty, data.principal_def_id()?)) |
750 |
| - } else { |
751 |
| - None |
752 |
| - } |
753 |
| - } |
754 |
| - |
755 | 700 | /// Searches for unsizing that might apply to `obligation`.
|
756 | 701 | fn assemble_candidates_for_unsizing(
|
757 | 702 | &mut self,
|
@@ -809,30 +754,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
809 | 754 | let principal_a = data_a.principal().unwrap();
|
810 | 755 | let target_trait_did = principal_def_id_b.unwrap();
|
811 | 756 | let source_trait_ref = principal_a.with_self_ty(self.tcx(), source);
|
812 |
| - if let Some((deref_output_ty, deref_output_trait_did)) = self |
813 |
| - .need_migrate_deref_output_trait_object( |
814 |
| - source, |
815 |
| - obligation.param_env, |
816 |
| - &obligation.cause, |
817 |
| - ) |
818 |
| - { |
819 |
| - if deref_output_trait_did == target_trait_did { |
820 |
| - self.tcx().struct_span_lint_hir( |
821 |
| - DEREF_INTO_DYN_SUPERTRAIT, |
822 |
| - obligation.cause.body_id, |
823 |
| - obligation.cause.span, |
824 |
| - |lint| { |
825 |
| - lint.build(&format!( |
826 |
| - "`{}` implements `Deref` with supertrait `{}` as output", |
827 |
| - source, |
828 |
| - deref_output_ty |
829 |
| - )).emit(); |
830 |
| - }, |
831 |
| - ); |
832 |
| - return; |
833 |
| - } |
834 |
| - } |
835 |
| - |
836 | 757 | for (idx, upcast_trait_ref) in
|
837 | 758 | util::supertraits(self.tcx(), source_trait_ref).enumerate()
|
838 | 759 | {
|
|
0 commit comments