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: path.segments.len() >= 2 #15528

Closed
sp3d opened this issue Jul 8, 2014 · 3 comments
Closed

ICE: path.segments.len() >= 2 #15528

sp3d opened this issue Jul 8, 2014 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@sp3d
Copy link
Contributor

sp3d commented Jul 8, 2014

use std::io::File::open;

fn main()
{
    open();
}

Compiling this program with rustc 0.11.0 (00cdd639a93ec1dcad85cebc52214eeba0441c93 2014-07-07 22:46:41 +0000) on Linux x86_64 gives the backtrace below:

task 'rustc' failed at 'assertion failed: path.segments.len() >= 2', /build/rust-git/src/rust/src/librustc/middle/typeck/check/mod.rs:4161

stack backtrace:
   1:     0x7f2a68a39080 - rt::backtrace::imp::write::h3a9330aff54dee28SMp
   2:     0x7f2a68a3e150 - <unknown>
   3:     0x7f2a6ab58b10 - unwind::begin_unwind_inner::hfe47ee6b84c3939ecZd
   4:     0x7f2a6ab58540 - unwind::begin_unwind_fmt::he04f3e5b01900555FWd
   5:     0x7f2a6b72bc00 - middle::typeck::check::instantiate_path::h1016c26f531c3d957Vh
   6:     0x7f2a6b7de710 - <unknown>
   7:     0x7f2a6b7de710 - <unknown>
   8:     0x7f2a6b7fbbb0 - middle::typeck::check::check_stmt::h79062ff9891ae6cbNmh
   9:     0x7f2a6b7b4680 - <unknown>
  10:     0x7f2a6b7afd60 - <unknown>
  11:     0x7f2a6b7afa90 - <unknown>
  12:     0x7f2a6b7a9d90 - middle::typeck::check::check_item::hf06283fc4609bdb5Efd
  13:     0x7f2a6b7af890 - middle::typeck::check::check_item_types::h9c1f790e4c79589fLHc
  14:     0x7f2a6b921810 - middle::typeck::check_crate::hfc3a3f5789d20299UNC
  15:     0x7f2a6bcda3e0 - driver::driver::phase_3_run_analysis_passes::hfcad747638c229814tq
  16:     0x7f2a6bcd6270 - driver::driver::compile_input::h99a1bc2d7a2f07d6Kgq
  17:     0x7f2a6bd8bc50 - <unknown>
  18:     0x7f2a6bd9fe40 - <unknown>
  19:     0x7f2a6bd9fb10 - <unknown>
  20:     0x7f2a6ae9e900 - <unknown>
  21:     0x7f2a6aba8c50 - rust_try
  22:     0x7f2a6ab556e0 - unwind::try::h24c27a0406a3ae46BNd
  23:     0x7f2a6ab553f0 - task::Task::run::h63d086c1974a8f2aXYc
  24:     0x7f2a6ae9e6d0 - <unknown>
  25:     0x7f2a6ab57940 - <unknown>
  26:     0x7f2a684bc060 - start_thread
  27:     0x7f2a6a827489 - __clone
  28:                0x0 - <unknown>
@edwardw
Copy link
Contributor

edwardw commented Jul 14, 2014

The bug here seems not to be the assertion failure itself, but rather that use std::io::File::open; should be rejected. As a matter of fact, such a import is rejected for non-std module:

mod a {
    pub struct Foo;
    impl Foo { pub fn bar() {} }
}

fn main() {
    use a::Foo::bar;    // error: Cannot import from a trait or type implementation
    bar();
}

So it is at least inconsistent that use std::io::File::open; turns out to be legitimate.

@edwardw
Copy link
Contributor

edwardw commented Jul 18, 2014

I can confirm that this bug has been fixed as a side effect of #15733. Basically, the assertion assert!(path.segments.len() >= 2); in rustc/middle/typeck/check/mod.rs will always hold now.

@alexcrichton
Copy link
Member

Hurray! I think the tests over there suffice for this as well.

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 18, 2023
Enable `rust_analyzer` for cfgs when code is being analyzed by rust-analyzer

This allows one to have r-a skip analysis/replace macros that work not well with r-a at all by gating them behind this cfg (an example being the `quote` macro which r-a struggles with in terms of performance).
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) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants