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 using 'impl Trait' with an infinity recursive function #65561

Closed
lszxb opened this issue Oct 18, 2019 · 4 comments · Fixed by #65777

Comments

@lszxb
Copy link

@lszxb lszxb commented Oct 18, 2019

fn main() {
    test();
}

fn test() -> impl TraitA {
    test()
}

trait TraitA {}

Error message

error: internal compiler error: src\librustc_mir\util\elaborate_drops.rs:826: open drop from non-ADT `[type error]`

thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:925:9

Additionally, the compiler warns that the function cannot return.

Compiler version

binary: rustc
commit-hash: 0e8a4b441c5da21a2cb19448728ade5baa299c66
commit-date: 2019-10-16
host: x86_64-pc-windows-msvc
release: 1.40.0-nightly
LLVM version: 9.0

Backtrace

stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: <std::io::IoSliceMut as core::fmt::Debug>::fmt
   3: std::panicking::take_hook
   4: std::panicking::take_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: <rustc_errors::Level as core::fmt::Debug>::fmt
   8: rustc_errors::HandlerInner::abort_if_errors_and_should_abort
   9: rustc_errors::Handler::bug
  10: rustc::util::bug::bug_fmt
  11: rustc::ty::wf::object_region_bounds
  12: rustc::ty::wf::object_region_bounds
  13: rustc::ty::wf::object_region_bounds
  14: rustc::util::bug::bug_fmt
  15: rustc::util::bug::bug_fmt
  16: rustc_mir::util::elaborate_drops::Unwind::is_cleanup
  17: <rustc_mir::borrow_check::nll::constraints::graph::Reverse as rustc_mir::borrow_check::nll::constraints::graph::ConstraintGraphDirecton>::start_region
  18: rustc::ty::print::pretty::<impl core::fmt::Display for rustc::ty::subst::GenericArg>::fmt
  19: rustc::middle::weak_lang_items::<impl rustc::ty::context::TyCtxt>::is_weak_lang_item
  20: rustc::dep_graph::graph::DepGraph::assert_ignored
  21: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::try_print_query_stack
  22: rustc::ty::<impl rustc::ty::context::TyCtxt>::instance_mir
  23: rustc_mir::monomorphize::collector::collect_crate_mono_items
  24: rustc_mir::monomorphize::collector::collect_crate_mono_items
  25: <rustc_mir::interpret::snapshot::InterpSnapshot as core::cmp::PartialEq>::eq
  26: <rustc_mir::interpret::intrinsics::type_name::AbsolutePathPrinter as core::fmt::Write>::write_str
  27: rustc_mir::monomorphize::collector::collect_crate_mono_items
  28: <rustc_mir::interpret::intrinsics::type_name::AbsolutePathPrinter as core::fmt::Write>::write_str
  29: rustc_mir::monomorphize::partitioning::compute_codegen_unit_name
  30: <rustc_codegen_llvm::ModuleLlvm as core::ops::drop::Drop>::drop
  31: <rustc_codegen_llvm::back::lto::ThinBuffer as core::ops::drop::Drop>::drop
  32: <rustc_codegen_llvm::debuginfo::metadata::MemberDescription as core::fmt::Debug>::fmt
  33: <rustc_codegen_llvm::debuginfo::metadata::MemberDescription as core::fmt::Debug>::fmt
  34: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  35: <rustc_interface::util::ReplaceBodyWithLoop as syntax::mut_visit::MutVisitor>::visit_mac
  36: <env_logger::filter::inner::Filter as core::fmt::Debug>::fmt
  37: rustc_interface::passes::BoxedResolver::complete
  38: rustc_interface::interface::Compiler::output_file
  39: rustc_interface::passes::BoxedResolver::to_expansion_result
  40: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::ongoing_codegen
  41: <syntax_pos::symbol::LocalInternedString as core::fmt::Display>::fmt
  42: <rustc_driver::Compilation as core::fmt::Debug>::fmt
  43: <syntax_pos::symbol::LocalInternedString as core::fmt::Display>::fmt
  44: <syntax_pos::symbol::LocalInternedString as core::fmt::Display>::fmt
  45: _rust_maybe_catch_panic
  46: <syntax_pos::symbol::LocalInternedString as core::fmt::Display>::fmt
  47: ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Send$u2b$core..marker..Sync$GT$$GT$..from..StringError$u20$as$u20$core..fmt..Display$GT$3fmt17
  48: std::sys::windows::thread::Thread::new
  49: BaseThreadInitThunk
  50: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@Centril

This comment has been minimized.

Copy link
Member

@Centril Centril commented Oct 19, 2019

In 1.37.0 this used to say:

error[E0391]: cycle detected when processing `test::{{opaque}}#0`
 --> <source>:7:14
  |
7 | fn test() -> impl TraitA {
  |              ^^^^^^^^^^^
  |

note: ...which requires processing `test`...
 --> <source>:7:26
  |
7 |   fn test() -> impl TraitA {
  |  __________________________^
8 | |     test()
9 | | }
  | |_^
  = note: ...which again requires processing `test::{{opaque}}#0`, completing the cycle

note: cycle used when checking item types in top-level module
 --> <source>:3:1
  |
3 | fn main() {
  | ^^^^^^^^^

error[E0720]: opaque type expands to a recursive type
 --> <source>:7:14
  |
7 | fn test() -> impl TraitA {
  |              ^^^^^^^^^^^ expands to self-referential type
  |
  = note: type resolves to itself


error: aborting due to 2 previous errors
@Centril

This comment has been minimized.

Copy link
Member

@Centril Centril commented Oct 19, 2019

Suggested prio: P-high.

cc @pnkfelix @matthewjasper

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

@nikomatsakis nikomatsakis commented Oct 24, 2019

I'm tagging this as E-needs-bisection -- it'd be good to know exactly what broke this!

@lqd

This comment has been minimized.

Copy link
Contributor

@lqd lqd commented Oct 25, 2019

Even if #65777 will likely fix this, here's the bisection: a5e7bb3, which is the #63043 rollup of:

  • #62423 (Fix cycle error with existential types)
  • #62979 (Cleanup save-analysis JsonDumper)
  • #62982 (Don't access a static just for its size and alignment)
  • #63013 (add repr(transparent) to IoSliceMut where missing)
  • #63014 (Stop bare trait lint applying to macro call sites)
  • #63036 (Add lib section to rustc_lexer's Cargo.toml)

where #62423 seems the most probable candidate, as this issue's code used to produce a cycle error indeed before this PR.

@lqd lqd removed the E-needs-bisection label Oct 25, 2019
bors added a commit that referenced this issue Oct 26, 2019
…vidtwco

Don't ICE for completely unexpandable `impl Trait` types

Save the resolution of these types (to themselves) to the typeck tables so that they will eventually reach E0720.

closes #65561
Centril added a commit to Centril/rust that referenced this issue Oct 26, 2019
…nsion, r=davidtwco

Don't ICE for completely unexpandable `impl Trait` types

Save the resolution of these types (to themselves) to the typeck tables so that they will eventually reach E0720.

closes rust-lang#65561
Centril added a commit to Centril/rust that referenced this issue Oct 26, 2019
…nsion, r=davidtwco

Don't ICE for completely unexpandable `impl Trait` types

Save the resolution of these types (to themselves) to the typeck tables so that they will eventually reach E0720.

closes rust-lang#65561
@bors bors closed this in 5406f7a Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.