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

Assertion failed in rustc : !(self.has_self && idx == 0) #46568

Closed
dwarfmaster opened this issue Dec 7, 2017 · 1 comment
Closed

Assertion failed in rustc : !(self.has_self && idx == 0) #46568

dwarfmaster opened this issue Dec 7, 2017 · 1 comment
Labels
A-resolve Area: Name resolution C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@dwarfmaster
Copy link

dwarfmaster commented Dec 7, 2017

When using cargo build to build one of my projects, I got the error the compiler unexpectedly panicked. this is a bug. I tried to minimize my code and got to this point.

I tried this code:

use std::rc::{Rc};
use std::marker::{PhantomData};

pub trait Arrow<'a,A,B>
where A : 'a,
      B : 'a
{
    fn bind<C,Y> (self, y: Y) -> Bind<B,Self,Y>
    where Self: Sized + 'a,
          Y: Arrow<'a,B,C>
    {
    }
}

pub struct Bind<B,X,Y> {
    mid : PhantomData<B>,
    fst : X,
    snd : Rc<Y>,
}

with the command rustc --crate-type lib src/lib.rs

I got the error :

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.22.1 (05e2e1c41 2017-11-22) running on x86_64-unknown-linux-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'assertion failed: !(self.has_self && idx == 0)', /checkout/src/librustc/ty/mod.rs:788:16

Meta

rustc --version --verbose :

rustc 1.22.1 (05e2e1c41 2017-11-22)
binary: rustc
commit-hash: 05e2e1c41414e8fc73d0f267ea8dab1a3eeeaa99
commit-date: 2017-11-22
host: x86_64-unknown-linux-gnu
release: 1.22.1
LLVM version: 4.0

backtrace :

note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: rustc::ty::Generics::type_param
   7: rustc::infer::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::report_region_errors
   8: rustc::infer::InferCtxt::resolve_regions_and_report_errors
   9: rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::regionck_item
  10: rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor::check_associated_item
  11: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'v>>::visit_trait_item
  12: rustc_typeck::check_crate::{{closure}}
  13: rustc_typeck::check_crate
  14: rustc::ty::context::TyCtxt::create_and_enter
  15: rustc_driver::driver::compile_input
  16: rustc_driver::run_compiler
@estebank estebank added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-resolve Area: Name resolution labels Dec 7, 2017
@SWW13
Copy link

SWW13 commented Dec 12, 2017

I can reproduce this with:

trait TraitB { }
trait TraitA {
        fn a<'a, B>(b: B) where &'a B: TraitB;
}

arielb1 added a commit to arielb1/rust that referenced this issue Dec 14, 2017
Nested generics (aka method generics) in trait methods don't have an
*additional* Self parameter in their own type parameter list (they have
a Self parameter in the parent generics), so don't try to check we're
correctly adjusting for it.

Fixes rust-lang#46568.
bors added a commit that referenced this issue Dec 16, 2017
fix broken assertion in type_param

Nested generics (aka method generics) in trait methods don't have an
*additional* Self parameter in their own type parameter list (they have
a Self parameter in the parent generics), so don't try to check we're
correctly adjusting for it.

Fixes #46568.

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name resolution C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants