rust-lang/rustfix

Incorrectly fixes single `use` when mixing this crate and external crates

russelltg opened this issue · 1 comments

Given the code:

# Cargo.toml
[package]
name = "test-badfix"
version = "0.1.0"

[dependencies]
futures = "*"
// src/lib.rs
#![feature(rust_2018_preview)]

extern crate futures;

mod a;

pub struct Useful;
// src/a.rs
pub use {
    Useful,
    futures::Future,
};

A call to cargo fix --prepare-for 2018 causes a.rs to be changed to:

pub use crate::{
    Useful,
    futures::Future,
};

Which doesn't really seem right, it seems

pub use {
    crate::Useful,
    futures::Future,
};

would be more correct.

Interestingly enough, the code generated by rustfix does compile...not sure if that's intended behavior, but is unrelated as the code

#![feature(rust_2018_preview)]

extern crate futures;

use crate::futures::Future;

compiles fine.

Thanks for the report! I've moved this over to rust-lang/rust#52215 where the code for this lint lives