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 error: c.num == crate_map.len() as u32 #729

Closed
nikomatsakis opened this Issue Feb 22, 2018 · 9 comments

Comments

Projects
None yet
3 participants
@nikomatsakis
Copy link

nikomatsakis commented Feb 22, 2018

I am using the RLS, setup in emacs. I get this error:

thread '<unnamed>' panicked at 'assertion failed: c.num == crate_map.len() as u32', /Users/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/rls-analysis-0.11.0/src/lowering.rs:125:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', libcore/result.rs:945:5

when running on the mathema repository (e.g., this commit)

I don't know how best to reproduce otherwise -- I can try running in VSCode, but I don't have that setup.

@nikomatsakis nikomatsakis changed the title assertion error assertion error: c.num == crate_map.len() as u32 Feb 22, 2018

@nikomatsakis

This comment has been minimized.

Copy link
Author

nikomatsakis commented Feb 22, 2018

When I try in VLS, I just get "RLS: working" seemingly forever. Not sure if there's a way to see more detail.

@nikomatsakis

This comment has been minimized.

Copy link
Author

nikomatsakis commented Feb 22, 2018

I tried rm -rf target and restarting emacs. Got same error.

@nrc nrc added the bug label Feb 22, 2018

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Feb 23, 2018

I can repro and the problem is with the mathema crate when it is referencing Serde. I think it is a combination of how rustc is handling the new extern crate-less crate imports and the Serde crate being pulled in by a macro maybe? The dep crate nums are 1-20 and then 46. So this seems like an invariant in rustc has changed, not sure whether that is a bug or whether we should work around this in rls-analysis.

@nikomatsakis

This comment has been minimized.

Copy link
Author

nikomatsakis commented Feb 24, 2018

@nrc ah of course I totally forgot that I am using new features :)

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Mar 3, 2018

I fixed the direct cause of this by dropping the assumption that crate numbers are sequential. We no longer get this bug, but we get an even weirder one, in:

impl MathemaOptions {
    crate fn directory(&self) -> Fallible<PathBuf> {
        Ok(match &self.directory {
            Some(s) => Path::new(s).to_owned(),
            None => env::current_dir()?,
        })
    }
}

The definition of s has a crate number of 21, which is not a valid crate number. Since it is a local variable, I would expect it to have a crate number of 0, I don't see how it can have any other crate number. I suppose we have gone wrong somewhere in emitting or processing the save-analysis data.

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Mar 5, 2018

Sigh, I was way off-base with the above. The problem seems to be an import:

use extern::{structopt::StructOpt, structopt_derive::StructOpt};

(specifically the first StructOpt, but I suspect they'd all have the same problem)

The crate number for structopt is 11 but that is not a crate which is listed in the save-analysis prelude list of crates.

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Mar 5, 2018

rust-lang/rust#48742 Is the Rust issue for the missing crate thing. I'll need some guideance from compiler folk to solve that. I have a solution to non-sequential crate numbers, but it might be unnecessary if they are only non-sequential because of the missing crates.

@sinkuu

This comment has been minimized.

Copy link
Contributor

sinkuu commented Apr 20, 2018

rust-lang/rust#48742 is fixed.

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Apr 20, 2018

Thanks for the fix @sinkuu !

@nrc nrc closed this Apr 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.