|
1 | 1 | use crate::mir::interpret::{AllocRange, ConstValue, GlobalAlloc, Pointer, Provenance, Scalar}; |
2 | 2 | use crate::ty::subst::{GenericArg, GenericArgKind, Subst}; |
3 | | -use crate::ty::{self, ConstInt, DefIdTree, ParamConst, ScalarInt, Ty, TyCtxt, TypeFoldable}; |
| 3 | +use crate::ty::{self, ConstInt, DefIdTree, ParamConst, ScalarInt, Term, Ty, TyCtxt, TypeFoldable}; |
4 | 4 | use rustc_apfloat::ieee::{Double, Single}; |
5 | 5 | use rustc_data_structures::fx::FxHashMap; |
6 | 6 | use rustc_data_structures::sso::SsoHashSet; |
@@ -799,7 +799,7 @@ pub trait PrettyPrinter<'tcx>: |
799 | 799 | let trait_ref = proj_ref.required_poly_trait_ref(self.tcx()); |
800 | 800 |
|
801 | 801 | // Projection type entry -- the def-id for naming, and the ty. |
802 | | - let proj_ty = (proj_ref.projection_def_id(), proj_ref.ty()); |
| 802 | + let proj_ty = (proj_ref.projection_def_id(), proj_ref.term()); |
803 | 803 |
|
804 | 804 | self.insert_trait_and_projection( |
805 | 805 | trait_ref, |
@@ -850,8 +850,10 @@ pub trait PrettyPrinter<'tcx>: |
850 | 850 | } |
851 | 851 |
|
852 | 852 | p!(")"); |
853 | | - if !return_ty.skip_binder().is_unit() { |
854 | | - p!("-> ", print(return_ty)); |
| 853 | + if let Term::Ty(ty) = return_ty.skip_binder() { |
| 854 | + if !ty.is_unit() { |
| 855 | + p!("-> ", print(return_ty)); |
| 856 | + } |
855 | 857 | } |
856 | 858 | p!(write("{}", if paren_needed { ")" } else { "" })); |
857 | 859 |
|
@@ -902,14 +904,15 @@ pub trait PrettyPrinter<'tcx>: |
902 | 904 | first = false; |
903 | 905 | } |
904 | 906 |
|
905 | | - for (assoc_item_def_id, ty) in assoc_items { |
| 907 | + for (assoc_item_def_id, term) in assoc_items { |
| 908 | + let ty = if let Term::Ty(ty) = term.skip_binder() { ty } else { continue }; |
906 | 909 | if !first { |
907 | 910 | p!(", "); |
908 | 911 | } |
909 | 912 | p!(write("{} = ", self.tcx().associated_item(assoc_item_def_id).ident)); |
910 | 913 |
|
911 | 914 | // Skip printing `<[generator@] as Generator<_>>::Return` from async blocks |
912 | | - match ty.skip_binder().kind() { |
| 915 | + match ty.kind() { |
913 | 916 | ty::Projection(ty::ProjectionTy { item_def_id, .. }) |
914 | 917 | if Some(*item_def_id) == self.tcx().lang_items().generator_return() => |
915 | 918 | { |
@@ -943,8 +946,11 @@ pub trait PrettyPrinter<'tcx>: |
943 | 946 | fn insert_trait_and_projection( |
944 | 947 | &mut self, |
945 | 948 | trait_ref: ty::PolyTraitRef<'tcx>, |
946 | | - proj_ty: Option<(DefId, ty::Binder<'tcx, Ty<'tcx>>)>, |
947 | | - traits: &mut BTreeMap<ty::PolyTraitRef<'tcx>, BTreeMap<DefId, ty::Binder<'tcx, Ty<'tcx>>>>, |
| 949 | + proj_ty: Option<(DefId, ty::Binder<'tcx, Term<'tcx>>)>, |
| 950 | + traits: &mut BTreeMap< |
| 951 | + ty::PolyTraitRef<'tcx>, |
| 952 | + BTreeMap<DefId, ty::Binder<'tcx, Term<'tcx>>>, |
| 953 | + >, |
948 | 954 | fn_traits: &mut BTreeMap<ty::PolyTraitRef<'tcx>, OpaqueFnEntry<'tcx>>, |
949 | 955 | ) { |
950 | 956 | let trait_def_id = trait_ref.def_id(); |
@@ -2716,5 +2722,5 @@ pub struct OpaqueFnEntry<'tcx> { |
2716 | 2722 | has_fn_once: bool, |
2717 | 2723 | fn_mut_trait_ref: Option<ty::PolyTraitRef<'tcx>>, |
2718 | 2724 | fn_trait_ref: Option<ty::PolyTraitRef<'tcx>>, |
2719 | | - return_ty: Option<ty::Binder<'tcx, Ty<'tcx>>>, |
| 2725 | + return_ty: Option<ty::Binder<'tcx, Term<'tcx>>>, |
2720 | 2726 | } |
0 commit comments