diff options
| author | Ellen <supbscripter@gmail.com> | 2022-01-12 03:19:52 +0000 |
|---|---|---|
| committer | Ellen <supbscripter@gmail.com> | 2022-01-15 01:16:55 +0000 |
| commit | 71bbb603f4108bc1f0bc8c8395ec725bb66e7802 (patch) | |
| tree | 668ba88d044cebf908cedfcd9a3479f401fa86f3 /compiler/rustc_middle/src/ty/print | |
| parent | b0ec3e09a996f2cb35be7710fd1003c3c38f1667 (diff) | |
| download | rust-71bbb603f4108bc1f0bc8c8395ec725bb66e7802.tar.gz rust-71bbb603f4108bc1f0bc8c8395ec725bb66e7802.zip | |
initial revert
Diffstat (limited to 'compiler/rustc_middle/src/ty/print')
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 350386f8d93..f5d3861bab4 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1153,28 +1153,29 @@ pub trait PrettyPrinter<'tcx>: } match ct.val { - ty::ConstKind::Unevaluated(uv) => { - if let Some(promoted) = uv.promoted { - let substs = uv.substs_.unwrap(); - p!(print_value_path(uv.def.did, substs)); - p!(write("::{:?}", promoted)); - } else { - let tcx = self.tcx(); - match tcx.def_kind(uv.def.did) { - DefKind::Static | DefKind::Const | DefKind::AssocConst => { - p!(print_value_path(uv.def.did, uv.substs(tcx))) - } - _ => { - if uv.def.is_local() { - let span = tcx.def_span(uv.def.did); - if let Ok(snip) = tcx.sess.source_map().span_to_snippet(span) { - p!(write("{}", snip)) - } else { - print_underscore!() - } + ty::ConstKind::Unevaluated(ty::Unevaluated { + def, + substs, + promoted: Some(promoted), + }) => { + p!(print_value_path(def.did, substs)); + p!(write("::{:?}", promoted)); + } + ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted: None }) => { + match self.tcx().def_kind(def.did) { + DefKind::Static | DefKind::Const | DefKind::AssocConst => { + p!(print_value_path(def.did, substs)) + } + _ => { + if def.is_local() { + let span = self.tcx().def_span(def.did); + if let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span) { + p!(write("{}", snip)) } else { print_underscore!() } + } else { + print_underscore!() } } } @@ -1419,7 +1420,7 @@ pub trait PrettyPrinter<'tcx>: // Aggregates, printed as array/tuple/struct/variant construction syntax. // - // NB: the `potentially_has_param_types_or_consts` check ensures that we can use + // NB: the `has_param_types_or_consts` check ensures that we can use // the `destructure_const` query with an empty `ty::ParamEnv` without // introducing ICEs (e.g. via `layout_of`) from missing bounds. // E.g. `transmute([0usize; 2]): (u8, *mut T)` needs to know `T: Sized` @@ -1427,9 +1428,7 @@ pub trait PrettyPrinter<'tcx>: // // FIXME(eddyb) for `--emit=mir`/`-Z dump-mir`, we should provide the // correct `ty::ParamEnv` to allow printing *all* constant values. - (_, ty::Array(..) | ty::Tuple(..) | ty::Adt(..)) - if !ty.potentially_has_param_types_or_consts() => - { + (_, ty::Array(..) | ty::Tuple(..) | ty::Adt(..)) if !ty.has_param_types_or_consts() => { let contents = self.tcx().destructure_const( ty::ParamEnv::reveal_all() .and(self.tcx().mk_const(ty::Const { val: ty::ConstKind::Value(ct), ty })), @@ -2246,7 +2245,6 @@ impl<'tcx, F: fmt::Write> FmtPrinter<'_, 'tcx, F> { T: TypeFoldable<'tcx>, { struct LateBoundRegionNameCollector<'a, 'tcx> { - tcx: TyCtxt<'tcx>, used_region_names: &'a mut FxHashSet<Symbol>, type_collector: SsoHashSet<Ty<'tcx>>, } @@ -2254,10 +2252,6 @@ impl<'tcx, F: fmt::Write> FmtPrinter<'_, 'tcx, F> { impl<'tcx> ty::fold::TypeVisitor<'tcx> for LateBoundRegionNameCollector<'_, 'tcx> { type BreakTy = (); - fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> { - Some(self.tcx) - } - #[instrument(skip(self), level = "trace")] fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> { trace!("address: {:p}", r); @@ -2288,7 +2282,6 @@ impl<'tcx, F: fmt::Write> FmtPrinter<'_, 'tcx, F> { self.used_region_names.clear(); let mut collector = LateBoundRegionNameCollector { - tcx: self.tcx, used_region_names: &mut self.used_region_names, type_collector: SsoHashSet::new(), }; @@ -2546,8 +2539,8 @@ define_print_and_forward_display! { print_value_path(closure_def_id, &[]), write("` implements the trait `{}`", kind)) } - ty::PredicateKind::ConstEvaluatable(uv) => { - p!("the constant `", print_value_path(uv.def.did, uv.substs_.map_or(&[], |x| x)), "` can be evaluated") + ty::PredicateKind::ConstEvaluatable(def, substs) => { + p!("the constant `", print_value_path(def.did, substs), "` can be evaluated") } ty::PredicateKind::ConstEquate(c1, c2) => { p!("the constant `", print(c1), "` equals `", print(c2), "`") |
