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

Lint suggesting `crate::` makes overlapping suggestions #52754

Closed
alexcrichton opened this Issue Jul 26, 2018 · 3 comments

Comments

Projects
None yet
1 participant
@alexcrichton
Copy link
Member

alexcrichton commented Jul 26, 2018

First reported at rust-lang/cargo#5797, this code:

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

fn generic_return<T>() {
}

pub struct B{}

pub mod submod {
    pub fn test() {
        ::generic_return::<::B>();
    }
}

fn main() {}

yields these warnings:

warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
  --> src/main.rs:11:9
   |
11 |         ::generic_return::<::B>();
   |         ^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::generic_return::<::B>`
   |
note: lint level defined here
  --> src/main.rs:2:9
   |
2  | #![warn(rust_2018_compatibility)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^
   = note: #[warn(absolute_paths_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
  --> src/main.rs:11:28
   |
11 |         ::generic_return::<::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

unfortunately though, the overlapping suggestions here means that rustfix can't apply a fix!

@alexcrichton

This comment has been minimized.

Copy link
Member Author

alexcrichton commented Jul 26, 2018

Carrying over the preview 2 milestone from #51210

@alexcrichton

This comment has been minimized.

Copy link
Member Author

alexcrichton commented Jul 26, 2018

The impact of this issue can also be mitigated by rust-lang/cargo#5813

@alexcrichton alexcrichton self-assigned this Jul 31, 2018

alexcrichton added a commit to alexcrichton/cargo that referenced this issue Jul 31, 2018

fix: Iteratively apply suggestions from the compiler
This commit updates the `cargo fix` implementation to iteratively apply fixes
from the compiler instead of only once. Currently the compiler can sometimes
emit overlapping suggestions, such as in the case of transitioning

    ::foo::<::Bar>();

to ...

    crate::foo::<crate::Bar>();

and `rustfix` rightfully can't handle overlapping suggestions as there's no
clear way of how to disambiguate the fixes. To fix this problem Cargo will now
run `rustc` and `rustfix` multiple times, attempting to reach a steady state
where no fixes failed to apply.

Naturally this is a pretty tricky thing to do and we want to be sure that Cargo
doesn't loop forever, for example. A number of safeguards are in place to
prevent Cargo from going off into the weeds when fixing files, notably avoiding
to reattempt fixes if no successful fixes ended up being applied.

Closes rust-lang#5813
Closes rust-lang/rust#52754
@alexcrichton

This comment has been minimized.

Copy link
Member Author

alexcrichton commented Jul 31, 2018

I'm gonna consider this closed with rust-lang/cargo#5842 as it'll be worked around in Cargo

alexcrichton added a commit to alexcrichton/cargo that referenced this issue Jul 31, 2018

fix: Iteratively apply suggestions from the compiler
This commit updates the `cargo fix` implementation to iteratively apply fixes
from the compiler instead of only once. Currently the compiler can sometimes
emit overlapping suggestions, such as in the case of transitioning

    ::foo::<::Bar>();

to ...

    crate::foo::<crate::Bar>();

and `rustfix` rightfully can't handle overlapping suggestions as there's no
clear way of how to disambiguate the fixes. To fix this problem Cargo will now
run `rustc` and `rustfix` multiple times, attempting to reach a steady state
where no fixes failed to apply.

Naturally this is a pretty tricky thing to do and we want to be sure that Cargo
doesn't loop forever, for example. A number of safeguards are in place to
prevent Cargo from going off into the weeds when fixing files, notably avoiding
to reattempt fixes if no successful fixes ended up being applied.

Closes rust-lang#5813
Closes rust-lang/rust#52754

alexcrichton added a commit to alexcrichton/cargo that referenced this issue Jul 31, 2018

fix: Iteratively apply suggestions from the compiler
This commit updates the `cargo fix` implementation to iteratively apply fixes
from the compiler instead of only once. Currently the compiler can sometimes
emit overlapping suggestions, such as in the case of transitioning

    ::foo::<::Bar>();

to ...

    crate::foo::<crate::Bar>();

and `rustfix` rightfully can't handle overlapping suggestions as there's no
clear way of how to disambiguate the fixes. To fix this problem Cargo will now
run `rustc` and `rustfix` multiple times, attempting to reach a steady state
where no fixes failed to apply.

Naturally this is a pretty tricky thing to do and we want to be sure that Cargo
doesn't loop forever, for example. A number of safeguards are in place to
prevent Cargo from going off into the weeds when fixing files, notably avoiding
to reattempt fixes if no successful fixes ended up being applied.

Closes rust-lang#5813
Closes rust-lang/rust#52754

alexcrichton added a commit to alexcrichton/cargo that referenced this issue Jul 31, 2018

fix: Iteratively apply suggestions from the compiler
This commit updates the `cargo fix` implementation to iteratively apply fixes
from the compiler instead of only once. Currently the compiler can sometimes
emit overlapping suggestions, such as in the case of transitioning

    ::foo::<::Bar>();

to ...

    crate::foo::<crate::Bar>();

and `rustfix` rightfully can't handle overlapping suggestions as there's no
clear way of how to disambiguate the fixes. To fix this problem Cargo will now
run `rustc` and `rustfix` multiple times, attempting to reach a steady state
where no fixes failed to apply.

Naturally this is a pretty tricky thing to do and we want to be sure that Cargo
doesn't loop forever, for example. A number of safeguards are in place to
prevent Cargo from going off into the weeds when fixing files, notably avoiding
to reattempt fixes if no successful fixes ended up being applied.

Closes rust-lang#5813
Closes rust-lang/rust#52754

bors added a commit to rust-lang/cargo that referenced this issue Aug 1, 2018

Auto merge of #5842 - alexcrichton:fix-lots, r=ehuss
fix: Iteratively apply suggestions from the compiler

This commit updates the `cargo fix` implementation to iteratively apply fixes
from the compiler instead of only once. Currently the compiler can sometimes
emit overlapping suggestions, such as in the case of transitioning

    ::foo::<::Bar>();

to ...

    crate::foo::<crate::Bar>();

and `rustfix` rightfully can't handle overlapping suggestions as there's no
clear way of how to disambiguate the fixes. To fix this problem Cargo will now
run `rustc` and `rustfix` multiple times, attempting to reach a steady state
where no fixes failed to apply.

Naturally this is a pretty tricky thing to do and we want to be sure that Cargo
doesn't loop forever, for example. A number of safeguards are in place to
prevent Cargo from going off into the weeds when fixing files, notably avoiding
to reattempt fixes if no successful fixes ended up being applied.

Closes #5813
Closes rust-lang/rust#52754
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.