diff options
| author | kadmin <julianknodt@gmail.com> | 2022-01-13 07:39:58 +0000 |
|---|---|---|
| committer | kadmin <julianknodt@gmail.com> | 2022-01-17 20:01:22 +0000 |
| commit | 1c1ce2fbda9c5d385fcb222d98d948aa4616fe91 (patch) | |
| tree | cd857aabfa5104ae08da5c00114dbe6cddb765c2 /compiler/rustc_middle/src/ty/print | |
| parent | f396888c4d816f7d0980aba041014169dd71a2a7 (diff) | |
| download | rust-1c1ce2fbda9c5d385fcb222d98d948aa4616fe91.tar.gz rust-1c1ce2fbda9c5d385fcb222d98d948aa4616fe91.zip | |
Add term to ExistentialProjection
Also prevent ICE when adding a const in associated const equality.
Diffstat (limited to 'compiler/rustc_middle/src/ty/print')
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index c6b03739927..bbdaf248a9e 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -905,29 +905,27 @@ pub trait PrettyPrinter<'tcx>: } for (assoc_item_def_id, term) in assoc_items { - let ty = match term.skip_binder() { - Term::Ty(ty) => ty, - Term::Const(c) => { - p!(print(c)); - continue; - } - }; if !first { p!(", "); } p!(write("{} = ", self.tcx().associated_item(assoc_item_def_id).ident)); - // Skip printing `<[generator@] as Generator<_>>::Return` from async blocks - match ty.kind() { - ty::Projection(ty::ProjectionTy { item_def_id, .. }) - if Some(*item_def_id) == self.tcx().lang_items().generator_return() => - { - p!("[async output]") + match term.skip_binder() { + Term::Ty(ty) => { + // Skip printing `<[generator@] as Generator<_>>::Return` from async blocks + if matches!( + ty.kind(), ty::Projection(ty::ProjectionTy { item_def_id, .. }) + if Some(*item_def_id) == self.tcx().lang_items().generator_return() + ) { + p!("[async output]") + } else { + p!(print(ty)) + } } - _ => { - p!(print(ty)) + Term::Const(c) => { + p!(print(c)); } - } + }; first = false; } @@ -1031,7 +1029,11 @@ pub trait PrettyPrinter<'tcx>: let mut projections = predicates.projection_bounds(); if let (Some(proj), None) = (projections.next(), projections.next()) { let tys: Vec<_> = args.iter().map(|k| k.expect_ty()).collect(); - p!(pretty_fn_sig(&tys, false, proj.skip_binder().ty)); + p!(pretty_fn_sig( + &tys, + false, + proj.skip_binder().term.ty().expect("Return type was a const") + )); resugared = true; } } @@ -2454,7 +2456,7 @@ define_print_and_forward_display! { ty::ExistentialProjection<'tcx> { let name = cx.tcx().associated_item(self.item_def_id).ident; - p!(write("{} = ", name), print(self.ty)) + p!(write("{} = ", name), print(self.term)) } ty::ExistentialPredicate<'tcx> { |
