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

trait lang item on a struct #20875

Closed
apreiml opened this issue Jan 10, 2015 · 13 comments
Closed

trait lang item on a struct #20875

apreiml opened this issue Jan 10, 2015 · 13 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@apreiml
Copy link
Contributor

apreiml commented Jan 10, 2015

thread 'rustc' panicked at 'assertion failed: did.krate != ast::LOCAL_CRATE', /build/buildd/rust-nightly-201501100408~14f9d1f~trusty/src/librustc/middle/ty.rs:5407

stack backtrace:
   1:     0x2ae1b47dd480 - sys::backtrace::write::h62c31c8ce34639e5Jzt
   2:     0x2ae1b47ff6a0 - <unknown>
   3:     0x2ae1b476d210 - rt::unwind::begin_unwind_inner::he6cbf3e88d73f0799tz
   4:     0x2ae1b6036a70 - <unknown>
   5:     0x2ae1b63d0fd0 - middle::ty::lookup_trait_def::hdfbea244d3d6f091YK8
   6:     0x2ae1b63f2700 - middle::ty::predicates_for_trait_ref::he697e3d5878aab355L8
   7:     0x2ae1b63ca680 - middle::traits::util::Elaborator<'cx, 'tcx>.Iterator::next::h50ca4a7d9ffad3d9fiU
   8:     0x2ae1b6427160 - middle::ty::required_region_bounds::h4b25d429295ec69eKi9
   9:     0x2ae1b5138730 - <unknown>
  10:     0x2ae1b5126470 - <unknown>
  11:     0x2ae1b5176c50 - <unknown>
  12:     0x2ae1b525c500 - <unknown>
  13:     0x2ae1b5257040 - check_crate::h79cca79b16d5148023x
  14:     0x2ae1b43df660 - driver::phase_3_run_analysis_passes::h1b173e994da54b02gwa
  15:     0x2ae1b43c7fa0 - driver::compile_input::hff268245321ca983xba
  16:     0x2ae1b4497c40 - <unknown>
  17:     0x2ae1b4497aa0 - <unknown>
  18:     0x2ae1b4496820 - <unknown>
  19:     0x2ae1b48645c0 - <unknown>
  20:     0x2ae1b48645b0 - rust_try
  21:     0x2ae1b4496b10 - <unknown>
  22:     0x2ae1b47ed540 - <unknown>
  23:     0x2ae1ba30c0c0 - start_thread
  24:     0x2ae1b4df9ec9 - __clone
  25:                0x0 - <unknown>

make: *** [main.o] Error 101

Version (nightly from : http://ppa.launchpad.net/hansjorg/rust/ubuntu)

rustc 1.0.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.0.0-dev

I've tried to compile: https://github.com/apreiml/rustboot

@crumblingstatue
Copy link
Contributor

Here is a test case:

#![no_std]

#![feature(lang_items)]
#[lang="sized"]

struct Foo; // can be omitted

struct Bar<T> {field: T}

fn main() {}

The ICE happens at least when the sized lang item is improperly defined (is not a trait), and a generic item is defined.

@flaper87 flaper87 added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 10, 2015
@zhangpf
Copy link

zhangpf commented Jan 20, 2015

http://is.gd/SpIRJe
encounter the same problem.

@pnkfelix
Copy link
Member

cc @nikomatsakis

@pnkfelix
Copy link
Member

(actually maybe this does not really need @nikomatsakis 's attention; I suspect we could just make the code check a bit more carefully that the Sized lang-item matches expectations (and issue a proper error when it does not.)

@tamird
Copy link
Contributor

tamird commented Apr 22, 2015

Triage bump: still ICEs.

#![feature(no_std,lang_items)]
#![no_std]

#[lang="sized"]
struct Bar<T> {field: T}

fn main() {}

@bltavares
Copy link
Contributor

I could not compile the latest example and I'm not sure what is causing it.
http://is.gd/O7SWvV

Removing the lang pragma makes it compile, but I guess that is that is a change on the semantics.

@steveklabnik
Copy link
Member

@alexcrichton the recent changes to no_std probably change these samples, huh? Any ideas on how to reproduce?

@arielb1
Copy link
Contributor

arielb1 commented Oct 25, 2015

@steveklabnik

Use no_core instead of no_std. However, as a rule, we don't type-check lang items (e.g. you can cause also cause an easy ICE if you add type parameters or associated items to Sized).

@bltavares
Copy link
Contributor

Is this the same ICE?

#![feature(no_core,lang_items)]
#![no_core]

#[lang="sized"]
struct Bar<T> {field: T}

fn main() {}

The error message is different than the OP's 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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'No def'n found for DefId { krate: 0, node: DefIndex(2) => Bar } in tcx.super_predicates', ../src/librustc/middle/ty/mod.rs:1897

@arielb1
Copy link
Contributor

arielb1 commented Oct 25, 2015

@bltavares
Sure. lang_items is unstable for a reason.

@bltavares
Copy link
Contributor

@arielb1 Cool. I will add it to steveklabnik/glacier then.

bltavares pushed a commit to bltavares/glacier that referenced this issue Oct 25, 2015
@arielb1
Copy link
Contributor

arielb1 commented Oct 25, 2015

@bltavares

It is unlikely to be fixed.

@brson brson added P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 23, 2017
@Mark-Simulacrum Mark-Simulacrum changed the title rustc panicked trait lang item on a struct Jun 13, 2017
@Mark-Simulacrum
Copy link
Member

This ICE is effectively caused by #9307, so I'm going to close in favor of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests