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

Migration lint for use crate::... has incorrect suggestions for braced use #50673

Closed
alexcrichton opened this issue May 11, 2018 · 1 comment
Closed
Labels
A-rust-2018-preview Area: The 2018 edition preview

Comments

@alexcrichton
Copy link
Member

The following code:

#![warn(rust_2018_breakage)]
#![feature(rust_2018_preview)]

use foo::{a, b};

mod foo {
    crate fn a() {}
    crate fn b() {}
}

fn main() {
    a();
    b();
}

yields:

warning: Absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
 --> src/main.rs:4:11
  |
4 | use foo::{a, b};
  |           ^ help: use `crate`: `crate::a`
  |
note: lint level defined here
 --> src/main.rs:1:9
  |
1 | #![warn(rust_2018_breakage)]
  |         ^^^^^^^^^^^^^^^^^^
  = note: #[warn(absolute_path_starting_with_module)] implied by #[warn(rust_2018_breakage)]
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
  = note: for more information, see issue TBD

warning: Absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
 --> src/main.rs:4:14
  |
4 | use foo::{a, b};
  |              ^ help: use `crate`: `crate::b`
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
  = note: for more information, see issue TBD

but when rustfix automatically applies the suggestions they end up breaking compilation because the suggested fix isn't syntactically valid

@nikomatsakis
Copy link
Contributor

I'll have to figure out what we can do here. I suspect handling this in its full generality will be hard but that if we're careful we can address most cases (e.g., the one here) — or at least detect when we are giving wrong suggestions. Also relevant to my comment in 50672.

bors added a commit that referenced this issue May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust-2018-preview Area: The 2018 edition preview
Projects
None yet
Development

No branches or pull requests

2 participants