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: assertion failed: leak_check(infcx, &skol_map, snapshot).is_ok() #22872

Closed
bytwise opened this issue Feb 27, 2015 · 14 comments · Fixed by #54946
Closed

ICE: assertion failed: leak_check(infcx, &skol_map, snapshot).is_ok() #22872

bytwise opened this issue Feb 27, 2015 · 14 comments · Fixed by #54946
Labels
A-typesystem Area: The type system C-bug Category: This is a bug. 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

@bytwise
Copy link
Contributor

bytwise commented Feb 27, 2015

Code:

trait Wrap<'b> {
    fn foo(&'b mut self);
}

struct Wrapper<P>(P);

impl<'b, P> Wrap<'b> for Wrapper<P>
where P: Process<'b>,
      <P as Process<'b>>::Item: Iterator {
    fn foo(&mut self) {}
}


pub trait Process<'a> {
    type Item;
    fn bar(&'a self);
}

fn push_process<P>(process: P) where P: Process<'static> {
    let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process));
}

fn main() {}

Output:

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
thread 'rustc' panicked at 'assertion failed: leak_check(infcx, &skol_map, snapshot).is_ok()', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc/middle/infer/higher_ranked/mod.rs:561

stack backtrace:
   1:        0x10a98b4b5 - sys::backtrace::write::h64ca2fb259c4ae97lCt
   2:        0x10a9ad94f - failure::on_fail::h64ff5ae6887860cc0Hz
   3:        0x10a9195ca - rt::unwind::begin_unwind_inner::h1d4bc098fd350446Qpz
   4:        0x107a5b05c - rt::unwind::begin_unwind::h14752733970416986751
   5:        0x107de5abb - middle::traits::select::SelectionContext<'cx, 'tcx>::vtable_impl::hddc0cc735340ecc8snT
   6:        0x107df3983 - middle::infer::InferCtxt<'a, 'tcx>::try::h7243598630119042649
   7:        0x107de02d7 - middle::traits::select::SelectionContext<'cx, 'tcx>::confirm_candidate::hac288b7baea2474883S
   8:        0x107dc1b0d - middle::traits::select::SelectionContext<'cx, 'tcx>::select::h40303230723bb5b2GmR
   9:        0x107dbf4a1 - middle::traits::fulfill::FulfillmentContext<'tcx>::select::hd311ca92298c935c5uP
  10:        0x107dbe95f - middle::traits::fulfill::FulfillmentContext<'tcx>::select_where_possible::h0ddf391ab631b9dcbuP
  11:        0x107706075 - check::vtable::select_fcx_obligations_where_possible::hadc6eeee207ed13f6lb
  12:        0x107705812 - check::vtable::select_all_fcx_obligations_or_error::h185f88f1cc7da26fdkb
  13:        0x107789b8a - check::check_bare_fn::h92d153344310f88bH3j
  14:        0x1077816f5 - check::check_item::hffd8f154a5736127umk
  15:        0x10784906f - check_crate::unboxed_closure.30671
  16:        0x107844873 - check_crate::h32fc7f8788be683523x
  17:        0x1071b4982 - driver::phase_3_run_analysis_passes::h4c5cf0d8fe5d55degwa
  18:        0x10719b420 - driver::compile_input::h31580cbd7ea87613xba
  19:        0x107266fda - monitor::unboxed_closure.22557
  20:        0x107265735 - thunk::F.Invoke<A, R>::invoke::h6367419564961841226
  21:        0x107264510 - rt::unwind::try::try_fn::h7763956589852599824
  22:        0x10aa142a9 - rust_try_inner
  23:        0x10aa14296 - rust_try
  24:        0x107264c0c - thunk::F.Invoke<A, R>::invoke::h16724184168577887652
  25:        0x10a99b154 - sys::thread::thread_start::hbd8f2f8bdd3a3baadrw
  26:     0x7fff877a32fc - _pthread_body
  27:     0x7fff877a3279 - _pthread_body

Rust version:

rustc 1.0.0-nightly (b47aebe3f 2015-02-26) (built 2015-02-26)
binary: rustc
commit-hash: b47aebe3fc2da06c760fd8ea19f84cbc41d34831
commit-date: 2015-02-26
build-date: 2015-02-26
host: x86_64-apple-darwin
release: 1.0.0-nightly
@kmcallister kmcallister added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-typesystem Area: The type system labels Mar 2, 2015
@ghost ghost 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 16, 2015
@pmarcelll
Copy link
Contributor

I can't reproduce it on rustc 1.2.0-nightly (0250ff9a5 2015-06-17).

@apasel422
Copy link
Contributor

With rustc 1.3.0-nightly (e4e93196e 2015-07-14), this yields:

foo.rs:20:36: 20:62 error: the trait `for<'b> Process<'b>` is not implemented for the type `P` [E0277]
foo.rs:20     let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process));
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~
foo.rs:20:36: 20:62 help: run `rustc --explain E0277` to see a detailed explanation
foo.rs:20:36: 20:62 error: the trait `for<'b> core::iter::Iterator` is not implemented for the type `<P as Process<'b>>::Item` [E0277]
foo.rs:20     let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process));
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~
foo.rs:20:36: 20:62 help: run `rustc --explain E0277` to see a detailed explanation
foo.rs:20:36: 20:62 note: `<P as Process<'b>>::Item` is not an iterator; maybe try calling `.iter()` or a similar method
foo.rs:20     let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process));
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~
foo.rs:20:36: 20:62 error: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
foo.rs:20     let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process));
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~
note: first, the lifetime cannot outlive lifetime ReSkolemized(0, BrNamed(DefId { krate: 0, node: 64 }, "\'b"(61)))...
foo.rs:20:36: 20:62 note: ...so that trait type parameters matches those specified on the impl (expected `Wrap<'b>`, found `Wrap<'_>`)
foo.rs:20     let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process));
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~
note: but, the lifetime must be valid for the static lifetime...
foo.rs:20:36: 20:62 note: ...so that trait type parameters matches those specified on the impl (expected `Process<'_>`, found `Process<'static>`)
foo.rs:20     let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process));
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 3 previous errors

@ebfull
Copy link
Contributor

ebfull commented Sep 12, 2015

This isn't fixed yet. The tests that were added only pass because debug assertions are disabled when @bors tests stuff.

@eddyb eddyb reopened this Sep 12, 2015
@apasel422
Copy link
Contributor

@ebfull Can you elaborate on this? Does this still cause an ICE?

On Saturday, September 12, 2015, Eduard Burtescu [email protected]
wrote:

Reopened #22872 #22872.


Reply to this email directly or view it on GitHub
#22872 (comment).

@eddyb
Copy link
Member

eddyb commented Sep 12, 2015

@apasel422 Yes, it always had, just that debug assertions became opt-in.

@apasel422
Copy link
Contributor

Is there an issue open to get bors to run with debug assertions enabled,
then? Seems dangerous not to.

On Saturday, September 12, 2015, Eduard Burtescu [email protected]
wrote:

@apasel422 https://github.com/apasel422 Yes, it always had, just that
debug assertions became opt-in.


Reply to this email directly or view it on GitHub
#22872 (comment).

@nikomatsakis
Copy link
Contributor

Yes, we need to have bors checking with debug-assertions! (Or else we should just never use them in rustc, perhaps.)

@arielb1
Copy link
Contributor

arielb1 commented Sep 14, 2015

@nikomatsakis

seems like the debug assertion is wrong because of #21974

@arielb1
Copy link
Contributor

arielb1 commented Sep 14, 2015

maybe match_poly_trait_refs can detect this however. Actually, that can't work, given that we select cache_fresh_trait_pred=Binder(TraitPredicate(<P as Process<'static>>)), candidate=Ok(Some(ParamCandidate(Binder (<P as Process<'static>>))))

@pnkfelix
Copy link
Member

Yes, we need to have bors checking with debug-assertions! (Or else we should just never use them in rustc, perhaps.)

having such a build configuration is related to #17166 and #27010

@Stebalien
Copy link
Contributor

Based on the comments here, this should probably not be labeled E-needstest.

@alexcrichton alexcrichton removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 19, 2016
@Mark-Simulacrum
Copy link
Member

Today, this produces the following, which is presumably correct? Either way, marking as E-needstest.

error[E0277]: the trait bound `for<'b> P: Process<'b>` is not satisfied
  --> test.rs:20:36
   |
20 |     let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process));
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'b> Process<'b>` is not implemented for `P`
   |
   = help: consider adding a `where for<'b> P: Process<'b>` bound
   = note: required because of the requirements on the impl of `for<'b> Wrap<'b>` for `Wrapper<P>`
   = note: required for the cast to the object type `for<'b> Wrap<'b>`

error[E0277]: the trait bound `for<'b> <P as Process<'b>>::Item: std::iter::Iterator` is not satisfied
  --> test.rs:20:36
   |
20 |     let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process));
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'b> std::iter::Iterator` is not implemented for `<P as Process<'b>>::Item`
   |
   = note: `<P as Process<'b>>::Item` is not an iterator; maybe try calling `.iter()` or a similar method
   = note: required because of the requirements on the impl of `for<'b> Wrap<'b>` for `Wrapper<P>`
   = note: required for the cast to the object type `for<'b> Wrap<'b>`

error: aborting due to 2 previous errors

@Mark-Simulacrum Mark-Simulacrum added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 6, 2017
@eddyb
Copy link
Member

eddyb commented May 6, 2017

@Mark-Simulacrum Is that with debug assertions enabled?

@Mark-Simulacrum
Copy link
Member

I think so. The way I check is with RUST_LOG=debug, which outputs debug logging... this is also on a rustc compiled locally with debug-assertions = true in the config.toml.

@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. and removed C-bug Category: This is a bug. labels Jul 22, 2017
estebank added a commit to estebank/rust that referenced this issue Oct 10, 2018
bors added a commit that referenced this issue Oct 15, 2018
Add filtering option to `rustc_on_unimplemented` and reword `Iterator` E0277 errors

 - Add more targetting filters for arrays to `rustc_on_unimplemented` (Fix #53766)
 - Detect one element array of `Range` type, which is potentially a typo:
   `for _ in [0..10] {}` where iterating between `0` and `10` was intended.
   (Fix #23141)
 - Suggest `.bytes()` and `.chars()` for `String`.
 - Suggest borrowing or `.iter()` on arrays (Fix #36391)
 - Suggest using range literal when iterating on integers (Fix #34353)
 - Do not suggest `.iter()` by default (Fix #50773, fix #46806)
 - Add regression test (Fix #22872)
bors added a commit that referenced this issue Oct 17, 2018
Add filtering option to `rustc_on_unimplemented` and reword `Iterator` E0277 errors

 - Add more targetting filters for arrays to `rustc_on_unimplemented` (Fix #53766)
 - Detect one element array of `Range` type, which is potentially a typo:
   `for _ in [0..10] {}` where iterating between `0` and `10` was intended.
   (Fix #23141)
 - Suggest `.bytes()` and `.chars()` for `String`.
 - Suggest borrowing or `.iter()` on arrays (Fix #36391)
 - Suggest using range literal when iterating on integers (Fix #34353)
 - Do not suggest `.iter()` by default (Fix #50773, fix #46806)
 - Add regression test (Fix #22872)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system C-bug Category: This is a bug. 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

Successfully merging a pull request may close this issue.