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

Interaction with uniform_paths canaries can hide import errors and lead to strange ICEs. #54253

Closed
eddyb opened this issue Sep 15, 2018 · 0 comments · Fixed by #54116
Closed
Assignees
Labels
A-resolve Area: Path resolution I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@eddyb
Copy link
Member

eddyb commented Sep 15, 2018

Reduced from RLS' source (on the Rust 2018 edition):

// Dummy import to introduce `uniform_paths` canaries.
use std;

// fn version() -> &'static str {""}

mod foo {
    // Error *not* reported, despite `version` being commented out above!
    use crate::version; 
    
    fn bar() {
        version();
    }
}

fn main() {}

The use std; import is the one introducing the canaries - if it's changed to use ::std;, the error for version is emitted. With no import errors, various parts of the compiler can ICE.
(currently attempted .def_id() on invalid def: Err, triggered by lints trying to run on foo::bar)

I'll try to fix it during #54116, as it was discovered during my attempt to fix RLS for that PR.

@eddyb eddyb added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 15, 2018
@eddyb eddyb self-assigned this Sep 15, 2018
@eddyb eddyb added the A-resolve Area: Path resolution label Sep 15, 2018
bors added a commit that referenced this issue Sep 15, 2018
rustc_resolve: allow only core, std, meta and --extern in Rust 2018 paths.

As per #53166 (comment):
* Rust 2018 imports can no longer refer to crates not in "extern prelude"
  * `::foo` won't load a crate named `foo` unless `foo` is in the "extern prelude"
  * `extern crate foo;`, however, remains unchanged (can load arbitrary crates)
* `--extern crate_name` is added (note the lack of `=path`) as an unstable option
  * adds `crate_name` to the "extern prelude" (see above)
  * crate is searched in sysroot & library paths, just like `extern crate crate_name`.
  * `Cargo` support will be added later
* `core`, `std` and ~~`proc_macro`~~ `meta` are *always* available in the extern prelude
  * warning for interaction with `no_std` / `no_core` will be added later
  * **EDIT**: `proc_macro` was replaced by `meta`, see #53166 (comment)
    * note that there is no crate named `meta` being added, so `use meta::...;` will fail, we're only whitelisting it so we can start producing `uniform_paths` compatibility errors

Fixes #54006 (as the example now requires `--extern alloc`, which is unstable).
Fixes #54253 (hit during fixing RLS).

r? @petrochenkov cc @aturon @alexcrichton @Centril @joshtriplett
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Path resolution I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant