Skip to content

absolute_path_not_starting_with_crate lint firing twice for the same import #50978

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

Closed
alexcrichton opened this issue May 22, 2018 · 1 comment · Fixed by #50982
Closed

absolute_path_not_starting_with_crate lint firing twice for the same import #50978

alexcrichton opened this issue May 22, 2018 · 1 comment · Fixed by #50982
Labels
A-edition-2018 Area: The 2018 edition F-rust_2018_preview `#![feature(rust_2018_preview)]`

Comments

@alexcrichton
Copy link
Member

The absolute_path_not_starting_with_crate lint is firing twice for the same import (even after #50969) which cause rustfix to get confused and many warnings continue to get emitted:

#![crate_type = "rlib"]
#![allow(unused_imports, dead_code)]
#![feature(rust_2018_preview)]
#![warn(rust_2018_compatibility)]

mod foo {
    pub fn bar() {}
}

mod another {
    use foo::{self, bar};
}
$ rustc foo.rs
warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
  --> foo.rs:11:9
   |
11 |     use foo::{self, bar};
   |         ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self, bar}`
   |
note: lint level defined here
  --> foo.rs:4:9
   |
4  | #![warn(rust_2018_compatibility)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^
   = note: #[warn(absolute_path_not_starting_with_crate)] implied by #[warn(rust_2018_compatibility)]
   = 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
  --> foo.rs:11:15
   |
11 |     use foo::{self, bar};
   |               ^^^^ help: use `crate`: `crate::self`
   |
   = 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
@alexcrichton alexcrichton added the F-rust_2018_preview `#![feature(rust_2018_preview)]` label May 22, 2018
@alexcrichton
Copy link
Member Author

cc @nikomatsakis

alexcrichton added a commit to alexcrichton/rust that referenced this issue May 22, 2018
This commit fixes another issue in the `absolute_path_not_starting_with_crate`
lint where it warns twice about an import which may contain `self`. It turns out
there were a few more locations that needed updating to use `root_id` and
`root_span` introduced in rust-lang#50970 and after that it looks to work like a charm!

Closes rust-lang#50978
bors added a commit that referenced this issue May 23, 2018
rustc: Fix another double-lint issue with `crate::`

This commit fixes another issue in the `absolute_path_not_starting_with_crate`
lint where it warns twice about an import which may contain `self`. It turns out
there were a few more locations that needed updating to use `root_id` and
`root_span` introduced in #50970 and after that it looks to work like a charm!

Closes #50978
@fmease fmease added the A-edition-2018 Area: The 2018 edition label Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2018 Area: The 2018 edition F-rust_2018_preview `#![feature(rust_2018_preview)]`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants