Skip to content

Compiler panic when implementing a trait for another trait with a lifetime in a lib #18943

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

Closed
pmsanford opened this issue Nov 14, 2014 · 3 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@pmsanford
Copy link

This code will cause a compiler panic

#![crate_type = "lib"]

trait Foo for Sized? { }

trait Bar { }

impl<'a> Foo for Bar + 'a { }

link to run: http://is.gd/MC2wAS

message:

error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' panicked at 'assertion failed: bounds.is_none()', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/librustc/metadata/encoder.rs:1231

This panic only occurs when building as a lib, whether by the #![crate_type = "lib"] attribute or with the --crate-type lib command line option. If you remove the crate_type attribute and add a fn main() {} it does not panic.

@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 14, 2014
@tomjakubowski
Copy link
Contributor

Backtrace I got with that example:

task 'rustc' panicked at 'assertion failed: bounds.is_none()', /build/rust-git/src/rust/src/librustc/metadata/encoder.rs:1231

stack backtrace:
   1:     0x7fdb42752c20 - rt::backtrace::imp::write::hcc244d480521f5e9Pdt
   2:     0x7fdb42755ca0 - <unknown>
   3:     0x7fdb42f13c80 - unwind::begin_unwind_inner::h5eadd82ce47d0284E9c
   4:     0x7fdb432c0680 - <unknown>
   5:     0x7fdb43a535d0 - <unknown>
   6:     0x7fdb43a58d70 - <unknown>
   7:     0x7fdb435066c0 - <unknown>
   8:     0x7fdb435066c0 - <unknown>
   9:     0x7fdb43a5ae20 - <unknown>
  10:     0x7fdb43a5f320 - <unknown>
  11:     0x7fdb43684470 - metadata::encoder::encode_metadata::h633a4478d051f03eSbw
  12:     0x7fdb43683c70 - middle::trans::base::write_metadata::h30a48bed88474a06zQi
  13:     0x7fdb43685950 - middle::trans::base::trans_crate::haaa13fd4751fa866GYi
  14:     0x7fdb43a9fe70 - driver::driver::phase_4_translate_to_llvm::h85e6560af237b5f1kkC
  15:     0x7fdb43a97470 - driver::driver::compile_input::h02996843b5f2a565eRB
  16:     0x7fdb43b1a800 - <unknown>
  17:     0x7fdb43b1a6f0 - <unknown>
  18:     0x7fdb432f3bc0 - <unknown>
  19:     0x7fdb432f39b0 - <unknown>
  20:     0x7fdb44344a30 - <unknown>
  21:     0x7fdb42f60e00 - <unknown>
  22:     0x7fdb42f60df0 - rust_try
  23:     0x7fdb42f11600 - unwind::try::h333ab25385d8e012mYc
  24:     0x7fdb42f11490 - task::Task::run::h2157d702c714dd0du4b
  25:     0x7fdb44344770 - <unknown>
  26:     0x7fdb42f12ca0 - <unknown>
  27:     0x7fdb3def3060 - start_thread
  28:     0x7fdb42be4489 - __clone
  29:                0x0 - <unknown>

rustc version is rustc 0.13.0-dev (7a86aa83e 2014-11-12 21:07:09 +0000)

@msiemens
Copy link
Contributor

I got a more detailled backtrace:

stack backtrace:
   1:     0x7f5363c08220 - rt::backtrace::imp::write::h64ddbb80732cebe7mft
   2:     0x7f5363c0b2a0 - failure::on_fail::h94b40e248cb876efXAt
   3:     0x7f53643da330 - unwind::begin_unwind_inner::h95c06af1b5484b5aE9c
   4:     0x7f53647a7390 - unwind::begin_unwind::h2953665953488925265
   5:     0x7f536500c360 - metadata::encoder::encode_info_for_item::h2fdf288e1d9b50a1X2u
   6:     0x7f53650120b0 - metadata::encoder::my_visit_item::closure.140832
   7:     0x7f5364a29320 - ast_map::Map<'ast>::with_path_next::h5678203148237041916
   8:     0x7f5364a29320 - ast_map::Map<'ast>::with_path_next::h5678203148237041916
   9:     0x7f53650140b0 - visit::walk_mod::h4122475244020002523
  10:     0x7f53650187b0 - metadata::encoder::encode_metadata_inner::he495ee9af76720e0wbw
  11:     0x7f5364bd25e0 - metadata::encoder::encode_metadata::h4800ccb08c786519Zaw
  12:     0x7f5364bd1dc0 - middle::trans::base::write_metadata::ha68b38aa6474f49aRPi
  13:     0x7f5364bd3b40 - middle::trans::base::trans_crate::hfdcd15c7cca1daefYXi
  14:     0x7f536505eda0 - driver::driver::phase_4_translate_to_llvm::h6acbdd487716233dyjC
  15:     0x7f5365054410 - driver::driver::compile_input::h6b78440b664993f7sQB
  16:     0x7f53650db7c0 - driver::run_compiler::h1e6c21018535d044JGF
  17:     0x7f53650db6b0 - driver::run::closure.146249
  18:     0x7f53647dcd20 - task::TaskBuilder<S>::try_future::closure.104741
  19:     0x7f53647dcb10 - task::TaskBuilder<S>::spawn_internal::closure.104712
  20:     0x7f5365934b50 - task::NativeSpawner.Spawner::spawn::closure.2549
  21:     0x7f536442f1e0 - rust_try_inner
  22:     0x7f536442f1d0 - rust_try
  23:     0x7f53643d7cb0 - unwind::try::h164a60eea6d3f88cmYc
  24:     0x7f53643d7b40 - task::Task::run::had29636eca7af1a3u4b
  25:     0x7f5365934890 - task::NativeSpawner.Spawner::spawn::closure.2475
  26:     0x7f53643d9350 - thread::thread_start::h1833ce4dca7b1a7erpc
  27:     0x7f535f3fae20 - start_thread
  28:     0x7f53640a5b59 - clone
  29:                0x0 - <unknown>

with

$ rustc --version
rustc 0.13.0-nightly (5745e4195 2014-11-12 22:57:16 +0000)

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

This now compiles:

#![crate_type = "lib"]

trait Foo { }

trait Bar { }

impl<'a> Foo for Bar + 'a { }

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 21, 2015
@bors bors closed this as completed in 2cf4791 May 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

6 participants