Skip to content

Unexpected failure when using ContravariantLifetime #15577

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
Denommus opened this issue Jul 10, 2014 · 2 comments
Closed

Unexpected failure when using ContravariantLifetime #15577

Denommus opened this issue Jul 10, 2014 · 2 comments

Comments

@Denommus
Copy link
Contributor

I'm in Arch Linux x86_64

This is the repository and branch where the bug in question happened: https://github.com/Denommus/xpath-rs/tree/rust-bug

After some study, I found out the smallest code that causes the issue:

use std::kinds::marker::ContravariantLifetime;

struct Foo<'a> {
    foo: *const int,
    lf: ContravariantLifetime<'a>
}

impl<'a> Drop for Foo<'a> {
    fn drop(&mut self) {
    }
}

When trying to cargo build or cargo test it, I get the following error:

   Compiling xpath v0.1.0 (file:/home/yuri/Projetos/PistonDevelopers/xpath-rs)
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. 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' failed at 'index out of bounds: the len is 0 but the index is 0', /build/rust-git/src/rust/src/librustc/middle/subst.rs:405

stack backtrace:
   1:     0x7fd280653440 - rt::backtrace::imp::write::hd9494d95b8843aac9Mp
   2:     0x7fd280656ca0 - <unknown>
   3:     0x7fd280e11660 - unwind::begin_unwind_inner::h86c91288dccdf7edcZd
   4:     0x7fd280e112b0 - unwind::begin_unwind_fmt::h1cb579d85bd16aefFWd
   5:     0x7fd280e11270 - rust_begin_unwind
   6:     0x7fd280e4cde0 - failure::begin_unwind::h4bcdf2c748255fc2srj
   7:     0x7fd280e50670 - failure::fail_bounds_check::hdab871e57fe12ae2Epj
   8:     0x7fd281564060 - <unknown>
   9:     0x7fd281564020 - <unknown>
  10:     0x7fd281562b30 - <unknown>
  11:     0x7fd281562960 - <unknown>
  12:     0x7fd28150af40 - middle::subst::SubstFolder<'a>.TypeFolder::fold_ty::h13798902dd9366ecRMU
  13:     0x7fd28150ae50 - <unknown>
  14:     0x7fd281685fd0 - middle::ty::lookup_field_type::h45aac711c7fa1076qeS
  15:     0x7fd281547e60 - middle::ty::struct_fields::hb5d9b2dc874148eeHmS
  16:     0x7fd2816b10e0 - <unknown>
  17:     0x7fd28164e5d0 - middle::ty::type_contents::hc7f87097be3796b7AsP
  18:     0x7fd2819fa0d0 - <unknown>
  19:     0x7fd2819fcfc0 - middle::kind::check_crate::h567230afc53cc6d1sxQ
  20:     0x7fd281d2da50 - driver::driver::phase_3_run_analysis_passes::h6dd6f772dd74de516Eq
  21:     0x7fd281d28eb0 - driver::driver::compile_input::h74d2c1dd617400e9Mrq
  22:     0x7fd281ddf670 - <unknown>
  23:     0x7fd281ddf580 - <unknown>
  24:     0x7fd281df2dd0 - <unknown>
  25:     0x7fd281df2b60 - <unknown>
  26:     0x7fd283e0ff80 - <unknown>
  27:     0x7fd280e60dc0 - rust_try
  28:     0x7fd280e0e6e0 - unwind::try::h62bccd25ee1c5a2dBNd
  29:     0x7fd280e0e440 - task::Task::run::h899cbe26c861f39cXYc
  30:     0x7fd283e0fd70 - <unknown>
  31:     0x7fd280e106c0 - <unknown>
  32:     0x7fd2800da060 - start_thread
  33:     0x7fd280ad9489 - __clone
  34:                0x0 - <unknown>

Could not execute process `rustc src/lib.rs --crate-name xpath --crate-type lib -g --test --out-dir /home/yuri/Projetos/PistonDevelopers/xpath-rs/target/test -L /home/yuri/Projetos/PistonDevelopers/xpath-rs/target/test -L /home/yuri/Projetos/PistonDevelopers/xpath-rs/target/test/deps` (status=101)
@Denommus
Copy link
Contributor Author

I have made a case with the smallest code that throws the error. It seems it needs both the ContravariantLifetime and an impl for the trait Drop:
https://gist.github.com/Denommus/3ca9490178387b78dc2f

@sfackler
Copy link
Member

Duplicate of #15557. Should be fixed by #15585.

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants