Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE when debug-printing an instance #55464

Closed
RalfJung opened this issue Oct 29, 2018 · 5 comments
Closed

ICE when debug-printing an instance #55464

RalfJung opened this issue Oct 29, 2018 · 5 comments
Assignees
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@RalfJung
Copy link
Member

RalfJung commented Oct 29, 2018

Even with #55199 landed, we still get ICEs when printing some instances. This is witnessed by applying this patch. Subsequently, building libcore fails.

Show backtrace
Building stage1 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
   Compiling core v0.0.0 (/home/r/src/rust/rustc.2/src/libcore)                                                                                                                                                    
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', librustc/ty/subst.rs:268:41                                                                                                      
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
             at librustc/util/common.rs:51
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:480
   6: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:390
   7: rust_begin_unwind
             at libstd/panicking.rs:325
   8: core::panicking::panic_fmt
             at libcore/panicking.rs:77
   9: core::panicking::panic_bounds_check
             at libcore/panicking.rs:59
  10: rustc::ty::context::tls::with
             at librustc/ty/subst.rs:268
             at librustc/util/ppaux.rs:322
             at ./libcore/result.rs:647
             at librustc/util/ppaux.rs:322
             at librustc/ty/context.rs:2168
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2113
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2168
  11: rustc::util::ppaux::PrintContext::parameterized
             at librustc/util/ppaux.rs:265
  12: rustc::util::ppaux::parameterized
             at librustc/util/ppaux.rs:563
  13: <rustc::ty::instance::Instance<'tcx> as core::fmt::Display>::fmt
             at librustc/ty/instance.rs:185
  14: core::fmt::write
             at libcore/fmt/mod.rs:1102
             at libcore/fmt/mod.rs:1049
  15: rustc_mir::const_eval::const_eval_raw_provider
             at ./libcore/fmt/mod.rs:226
             at ./liballoc/string.rs:2150
             at librustc_mir/const_eval.rs:617
  16: rustc::ty::query::__query_compute::const_eval_raw
             at librustc/ty/query/plumbing.rs:834
             at librustc/ty/query/plumbing.rs:796
  17: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval_raw<'tcx>>::compute
             at librustc/ty/query/plumbing.rs:826
  18: rustc::ty::context::tls::with_context
             at librustc/dep_graph/graph.rs:275
             at librustc/ty/context.rs:2038
             at librustc/ty/context.rs:1977
             at librustc/ty/context.rs:2037
             at librustc/dep_graph/graph.rs:274
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2113
             at librustc/ty/context.rs:2122
  19: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/dep_graph/graph.rs:268
  20: rustc::ty::context::tls::with_related_context
             at librustc/dep_graph/graph.rs:208
             at librustc/ty/query/plumbing.rs:550
             at librustc/ty/query/plumbing.rs:208
             at librustc/ty/context.rs:2038
             at librustc/ty/context.rs:1977
             at librustc/ty/context.rs:2037
             at librustc/ty/query/plumbing.rs:207
             at librustc/ty/context.rs:2138
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2113
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2133
  21: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/ty/query/plumbing.rs:197
             at librustc/ty/query/plumbing.rs:543
  22: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at librustc/ty/query/plumbing.rs:424
             at librustc/ty/query/plumbing.rs:629
             at librustc/ty/query/plumbing.rs:640
  23: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::const_eval_raw
             at librustc/ty/query/plumbing.rs:888
             at librustc/ty/query/plumbing.rs:881
  24: rustc_mir::const_eval::const_eval_provider
             at librustc_mir/const_eval.rs:584
  25: rustc::ty::query::__query_compute::const_eval
             at librustc/ty/query/plumbing.rs:834
             at librustc/ty/query/plumbing.rs:796
  26: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval<'tcx>>::compute
             at librustc/ty/query/plumbing.rs:826
  27: rustc::ty::context::tls::with_context
             at librustc/dep_graph/graph.rs:275
             at librustc/ty/context.rs:2038
             at librustc/ty/context.rs:1977
             at librustc/ty/context.rs:2037
             at librustc/dep_graph/graph.rs:274
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2113
             at librustc/ty/context.rs:2122
  28: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/dep_graph/graph.rs:268
  29: rustc::ty::context::tls::with_related_context
             at librustc/dep_graph/graph.rs:208
             at librustc/ty/query/plumbing.rs:550
             at librustc/ty/query/plumbing.rs:208
             at librustc/ty/context.rs:2038
             at librustc/ty/context.rs:1977
             at librustc/ty/context.rs:2037
             at librustc/ty/query/plumbing.rs:207
             at librustc/ty/context.rs:2138
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2113
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2133
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/ty/query/plumbing.rs:197
             at librustc/ty/query/plumbing.rs:543
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at librustc/ty/query/plumbing.rs:424
             at librustc/ty/query/plumbing.rs:629
             at librustc/ty/query/plumbing.rs:640
  32: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_const
             at librustc/ty/query/plumbing.rs:888
             at librustc/ty/query/plumbing.rs:881
             at librustc/traits/project.rs:451
  33: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
             at librustc/ty/structural_impls.rs:1043
             at librustc/ty/structural_impls.rs:712
  34: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
             at librustc/traits/project.rs:367
  35: rustc::traits::project::normalize
             at ./librustc/ty/structural_impls.rs:751
             at ./librustc/traits/project.rs:345
             at ./librustc/traits/project.rs:304
             at ./librustc/traits/project.rs:288
  36: rustc::infer::InferCtxt::partially_normalize_associated_types_in
             at ./librustc/infer/mod.rs:1466
  37: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::normalize_ty
             at librustc_typeck/check/mod.rs:685
             at librustc_typeck/check/mod.rs:2311
             at librustc_typeck/check/mod.rs:1934
  38: <(dyn rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o)>::ast_ty_to_ty
             at librustc_typeck/astconv.rs:1506
  39: <(dyn rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o)>::create_substs_for_generic_args
             at librustc_typeck/check/mod.rs:2355
             at librustc_typeck/check/mod.rs:5162
             at librustc_typeck/astconv.rs:502
  40: rustc_typeck::check::FnCtxt::instantiate_value_path
             at librustc_typeck/check/mod.rs:5131
  41: rustc_typeck::check::FnCtxt::check_expr_kind
             at librustc_typeck/check/mod.rs:3934
  42: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
             at librustc_typeck/check/mod.rs:3755
  43: rustc_typeck::check::FnCtxt::check_expr_kind
             at librustc_typeck/check/mod.rs:3063
             at librustc_typeck/check/mod.rs:3067
             at librustc_typeck/check/callee.rs:52
             at librustc_typeck/check/mod.rs:4166
  44: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
             at librustc_typeck/check/mod.rs:3755
  45: rustc_typeck::check::FnCtxt::with_breakable_ctxt
             at librustc_typeck/check/mod.rs:3063
             at librustc_typeck/check/mod.rs:4612
             at ./libcore/option.rs:424
             at librustc_typeck/check/mod.rs:4612
             at librustc_typeck/check/mod.rs:5293
  46: rustc_typeck::check::FnCtxt::check_block_with_expected
             at librustc_typeck/check/mod.rs:4605
  47: rustc_typeck::check::FnCtxt::check_expr_kind
             at librustc_typeck/check/mod.rs:4163
  48: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
             at librustc_typeck/check/mod.rs:3755
  49: rustc_typeck::check::FnCtxt::check_expr_kind
             at librustc_typeck/check/mod.rs:3908
  50: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
             at librustc_typeck/check/mod.rs:3755
  51: rustc_typeck::check::FnCtxt::check_argument_types
             at librustc_typeck/check/mod.rs:3063
             at librustc_typeck/check/mod.rs:2888
  52: rustc_typeck::check::FnCtxt::check_method_argument_types
             at librustc_typeck/check/mod.rs:2711
  53: rustc_typeck::check::FnCtxt::check_expr_kind
             at librustc_typeck/check/mod.rs:3179
             at librustc_typeck/check/mod.rs:4169
  54: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
             at librustc_typeck/check/mod.rs:3755
  55: rustc_typeck::check::FnCtxt::with_breakable_ctxt
             at librustc_typeck/check/mod.rs:3063
             at librustc_typeck/check/mod.rs:4612
             at ./libcore/option.rs:424
             at librustc_typeck/check/mod.rs:4612
             at librustc_typeck/check/mod.rs:5293
  56: rustc_typeck::check::FnCtxt::check_block_with_expected
             at librustc_typeck/check/mod.rs:4605
  57: rustc_typeck::check::FnCtxt::check_expr_kind
             at librustc_typeck/check/mod.rs:4163
  58: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
             at librustc_typeck/check/mod.rs:3755
  59: rustc_typeck::check::FnCtxt::check_return_expr
             at librustc_typeck/check/mod.rs:3063
             at librustc_typeck/check/mod.rs:3057
             at librustc_typeck/check/mod.rs:3195
  60: rustc_typeck::check::check_fn
             at librustc_typeck/check/mod.rs:1103
  61: rustc::ty::context::tls::with_context::{{closure}}
             at librustc_typeck/check/mod.rs:866
             at librustc_typeck/check/mod.rs:621
             at ./librustc/infer/mod.rs:526
             at ./librustc/ty/context.rs:1674
             at ./librustc/ty/context.rs:2038
             at ./librustc/ty/context.rs:1977
             at ./librustc/ty/context.rs:2037
             at ./librustc/ty/context.rs:1673
             at ./librustc/ty/context.rs:2138
             at ./librustc/ty/context.rs:2122
  62: rustc::ty::context::GlobalCtxt::enter_local
             at ./librustc/ty/context.rs:2113
             at ./librustc/ty/context.rs:2122
             at ./librustc/ty/context.rs:2133
             at ./librustc/ty/context.rs:1666
  63: rustc::infer::InferCtxtBuilder::enter
             at ./librustc/infer/mod.rs:525
  64: rustc_typeck::check::typeck_tables_of
             at librustc_typeck/check/mod.rs:621
             at librustc_typeck/check/mod.rs:850
  65: rustc::ty::query::__query_compute::typeck_tables_of
             at librustc/ty/query/plumbing.rs:834
             at librustc/ty/query/plumbing.rs:796
  66: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_tables_of<'tcx>>::compute
             at librustc/ty/query/plumbing.rs:826
  67: rustc::ty::context::tls::with_context
             at librustc/dep_graph/graph.rs:275
             at librustc/ty/context.rs:2038
             at librustc/ty/context.rs:1977
             at librustc/ty/context.rs:2037
             at librustc/dep_graph/graph.rs:274
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2113
             at librustc/ty/context.rs:2122
  68: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/dep_graph/graph.rs:268
  69: rustc::ty::context::tls::with_related_context
             at librustc/dep_graph/graph.rs:208
             at librustc/ty/query/plumbing.rs:550
             at librustc/ty/query/plumbing.rs:208
             at librustc/ty/context.rs:2038
             at librustc/ty/context.rs:1977
             at librustc/ty/context.rs:2037
             at librustc/ty/query/plumbing.rs:207
             at librustc/ty/context.rs:2138
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2113
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2133
  70: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/ty/query/plumbing.rs:197
             at librustc/ty/query/plumbing.rs:543
  71: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at librustc/ty/query/plumbing.rs:424
             at librustc/ty/query/plumbing.rs:629
             at librustc/ty/query/plumbing.rs:640
  72: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
             at librustc/ty/query/plumbing.rs:602
  73: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::par_body_owners
             at librustc_typeck/check/mod.rs:723
             at ./librustc/ty/mod.rs:2553
             at ./libcore/iter/iterator.rs:614
             at ./libcore/slice/mod.rs:2906
             at ./libcore/iter/iterator.rs:614
             at ./librustc/ty/mod.rs:2552
  74: rustc_typeck::check::typeck_item_bodies
             at librustc_typeck/check/mod.rs:722
             at ./librustc/session/mod.rs:323
             at librustc_typeck/check/mod.rs:721
  75: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_item_bodies<'tcx>>::compute
             at librustc/ty/query/plumbing.rs:826
  76: rustc::ty::context::tls::with_context
             at librustc/dep_graph/graph.rs:275
             at librustc/ty/context.rs:2038
             at librustc/ty/context.rs:1977
             at librustc/ty/context.rs:2037
             at librustc/dep_graph/graph.rs:274
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2113
             at librustc/ty/context.rs:2122
  77: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/dep_graph/graph.rs:268
  78: rustc::ty::context::tls::with_related_context
             at librustc/dep_graph/graph.rs:208
             at librustc/ty/query/plumbing.rs:550
             at librustc/ty/query/plumbing.rs:208
             at librustc/ty/context.rs:2038
             at librustc/ty/context.rs:1977
             at librustc/ty/context.rs:2037
             at librustc/ty/query/plumbing.rs:207
             at librustc/ty/context.rs:2138
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2113
             at librustc/ty/context.rs:2122
             at librustc/ty/context.rs:2133
  79: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/ty/query/plumbing.rs:197
             at librustc/ty/query/plumbing.rs:543
  80: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at librustc/ty/query/plumbing.rs:424
             at librustc/ty/query/plumbing.rs:629
             at librustc/ty/query/plumbing.rs:640
  81: rustc::util::common::time
             at librustc_typeck/check/mod.rs:714
             at librustc_typeck/lib.rs:360
             at ./librustc/util/common.rs:163
             at ./librustc/util/common.rs:157
  82: rustc_typeck::check_crate
             at librustc_typeck/lib.rs:360
  83: rustc::ty::context::tls::enter_context
             at librustc_driver/driver.rs:1289
             at ./librustc/ty/context.rs:2070
             at ./librustc/ty/context.rs:2038
             at ./librustc/ty/context.rs:1977
             at ./librustc/ty/context.rs:2037
  84: <std::thread::local::LocalKey<T>>::with
             at ./librustc/ty/context.rs:2069
             at ./librustc/ty/context.rs:2027
             at ./libstd/thread/local.rs:300
             at ./libstd/thread/local.rs:254
             at ./librustc/ty/context.rs:2019
             at ./libstd/thread/local.rs:300
             at ./libstd/thread/local.rs:254
  85: rustc::ty::context::TyCtxt::create_and_enter
             at ./librustc/ty/context.rs:2011
             at ./librustc/ty/context.rs:2049
             at ./librustc/ty/context.rs:1247
  86: rustc_driver::driver::phase_3_run_analysis_passes
             at librustc_driver/driver.rs:1263
  87: rustc_driver::driver::compile_input
             at librustc_driver/driver.rs:287
  88: rustc_driver::run_compiler_with_pool
             at librustc_driver/lib.rs:544
  89: <scoped_tls::ScopedKey<T>>::set
             at librustc_driver/lib.rs:466
             at librustc_driver/driver.rs:76
             at /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  90: rustc_driver::run_compiler
             at librustc_driver/driver.rs:75
             at librustc_driver/lib.rs:465
  91: <scoped_tls::ScopedKey<T>>::set
             at librustc_driver/lib.rs:1717
             at librustc_driver/lib.rs:181
             at /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
             at ./libsyntax/lib.rs:106
             at /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  92: std::panicking::try::do_call
             at ./libsyntax/lib.rs:105
             at librustc_driver/lib.rs:180
             at librustc_driver/lib.rs:1632
             at ./libstd/panic.rs:313
             at ./libstd/panicking.rs:310
  93: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  94: std::panicking::try
             at ./libstd/panicking.rs:289
  95: rustc_driver::run
             at ./libstd/panic.rs:392
             at librustc_driver/lib.rs:1546
             at librustc_driver/lib.rs:1557
             at librustc_driver/lib.rs:1631
             at librustc_driver/lib.rs:179
  96: rustc_driver::main
             at librustc_driver/lib.rs:1710
  97: std::rt::lang_start::{{closure}}
             at ./libstd/rt.rs:74
  98: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  99: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
query stack during panic:
#0 [const_eval_raw] const-evaluating `hash::Hasher::write_u16::{{constant}}`
#1 [const_eval] const-evaluating + checking `hash::Hasher::write_u16::{{constant}}`
#2 [typeck_tables_of] processing `hash::Hasher::write_u16`
#3 [typeck_item_bodies] type-checking all item bodies
end of query stack

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.31.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z always-encode-mir -Z mir-emit-validate=1 -Z force-unstable-if-unmarked -C opt-level=2 -C incremental -C prefer-dynamic -C debuginfo=1 -C debug-assertions=y -C link-args=-Wl,-rpath,$ORIGIN/../lib --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `core`.                                                                                                                                                                                   

Cc @oli-obk

@RalfJung
Copy link
Member Author

The offending out-of-bounds access is at

if has_self {
print!(f, self, write("<"), print_display(substs.type_at(0)), write(" as "))?;
}

@zackmdavis zackmdavis added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Oct 29, 2018
@RalfJung
Copy link
Member Author

@oli-obk Any idea what this could be caused by? Any hints where I could start debugging this?

@oli-obk
Copy link
Contributor

oli-obk commented Nov 12, 2018

Nope, sorry. It's been in my queue to address, but low in it.

From the snippet you posted I'm assuming that the has_self computation is wrong. The query path is hash::Hasher::write_u16::{{constant}}, I'd start looking at which constants are available. I'm assuming the code believes it has Self since we are in a method impl. But constants other than associated constants don't have this.

@RalfJung
Copy link
Member Author

RalfJung commented Jan 9, 2019

I heard that @eddyb is working on refactoring this printing code, maybe even fixing this issue along the way. Is there any place to follow that progress?

@eddyb it'd be great if you could inline something like this patch if/when you did that refactoring, that'll ensure (in a debug build) that we don't ICE any more when printing constants' instances.

@RalfJung
Copy link
Member Author

RalfJung commented Feb 9, 2019

This will be fixed by #58140

bors added a commit that referenced this issue Mar 14, 2019
Refactor ppaux out of existence.

A long-time coming, this PR reorganizes and rewrites the pretty-printing architecture of rustc, specifically the parts that involve the typesystem (which used to be in `rustc::util::ppaux`).

*Note: these commits used to be in #57967 before being split off.*

The new API (i.e. the `Printer` and `PrettyPrint` traits) is in `rustc::ty::print`.

Design points, roughly:
* using associated types in `Printer` to allow building e.g. an AST, not just printing as a side-effect
* several overloading points for implementers of `PrettyPrinter`, e.g. how `<...>` is printed
* for `fmt::Display` impls, the value to print is lifted to the `ty::tls` `tcx`, and everything after that stays within the `ty::print` API, which requires `'tcx` to match between values and the printer's `tcx`, without going through `fmt::Display` again

Most of the behavior is unchanged, except for a few details, which should be clear from the test changes.

r? @nikomatsakis

Fixes #55464
bors added a commit that referenced this issue Mar 15, 2019
Refactor ppaux out of existence.

A long-time coming, this PR reorganizes and rewrites the pretty-printing architecture of rustc, specifically the parts that involve the typesystem (which used to be in `rustc::util::ppaux`).

*Note: these commits used to be in #57967 before being split off.*

The new API (i.e. the `Printer` and `PrettyPrint` traits) is in `rustc::ty::print`.

Design points, roughly:
* using associated types in `Printer` to allow building e.g. an AST, not just printing as a side-effect
* several overloading points for implementers of `PrettyPrinter`, e.g. how `<...>` is printed
* for `fmt::Display` impls, the value to print is lifted to the `ty::tls` `tcx`, and everything after that stays within the `ty::print` API, which requires `'tcx` to match between values and the printer's `tcx`, without going through `fmt::Display` again

Most of the behavior is unchanged, except for a few details, which should be clear from the test changes.

r? @nikomatsakis

Fixes #55464
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants