rust-lang/rls

Building failed: no method named `expect_none` found for enum `Option<u32>` in the current scope

cjwcommuny opened this issue · 3 comments

I tried to build rls with cargo +nightly build --release --locked, but got the following errors:

error[E0599]: no method named `expect_none` found for enum `Option<Fingerprint>` in the current scope
    --> /Users/cjw/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-705.0.0/src/lib.rs:2003:48
     |
2003 |                 cache[index].replace(sub_hash).expect_none("Cache slot was filled");
     |                                                ^^^^^^^^^^^ method not found in `Option<Fingerprint>`

error[E0599]: no method named `expect_none` found for enum `Option<u32>` in the current scope
   --> /Users/cjw/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-705.0.0/src/hygiene.rs:121:54
    |
121 |             expn_data.orig_id.replace(self.as_u32()).expect_none("orig_id should be None");
    |                                                      ^^^^^^^^^^^ method not found in `Option<u32>`

error[E0599]: no method named `expect_none` found for enum `Option<u32>` in the current scope
   --> /Users/cjw/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-705.0.0/src/hygiene.rs:205:42
    |
205 |             data.orig_id.replace(raw_id).expect_none("orig_id should be None");
    |                                          ^^^^^^^^^^^ method not found in `Option<u32>`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0599`.
error: could not compile `rustc-ap-rustc_span`

The commit I built with is 78a36bd.

Versions:

cargo 1.53.0-nightly (65d57e6f3 2021-04-04)
rustc 1.53.0-nightly (361bfce30 2021-04-07)

I'm new to rust development, anyone can help?

You'd need to use an older nightly to compile from source (nightly-2021-02-06 or one from around that range may work). RLS depends on a couple packages that in turn have dependencies on some of the compiler internals which they consume via auto published crates of those internals, and that's where this failure is coming from (rustc-ap-rustc_span).

Building any of those from source typically requires a somewhat narrow range of nightly toolchains.This happens because those auto published crate versions of the internals are just a point-in-time snapshot, and sooner or later they get out of sync with the latest compiler which is what has happened here.

#1726 will fix the current state and allow using more recently nightly toolchains, but for now you'd have to use an older one

You'd need to use an older nightly to compile from source (nightly-2021-02-06 or one from around that range may work). RLS depends on a couple packages that in turn have dependencies on some of the compiler internals which they consume via auto published crates of those internals, and that's where this failure is coming from (rustc-ap-rustc_span).

Building any of those from source typically requires a somewhat narrow range of nightly toolchains.This happens because those auto published crate versions of the internals are just a point-in-time snapshot, and sooner or later they get out of sync with the latest compiler which is what has happened here.

#1726 will fix the current state and allow using more recently nightly toolchains, but for now you'd have to use an older one

Can we know exactly what version rustc is needed to build a specific version rls?

Can we know exactly what version rustc is needed to build a specific version rls?

As mentioned in my last comment there's not an exact single one, but many versions of the nightly compiler that can be used across a range of weeks or sometimes even months. Now that #1726 has been merged you should be able to build RLS using a bleeding edge nightly again.

In cases where compilation fails against one of the AP crates, one approach to find a nightly that can be used is to look at the specific version (branch or tag) of racer and/or rustfmt which the version of RLS you're working with depends on.

For example, RLS at 78a36bd depended on racer v2.1.44, and looking at the toolchain file for racer v2.1.44 shows nightly-2021-02-06. Therefore you should be able to use that same nightly version (nightly-2021-02-06) to compile that version RLS as well