rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

fix(import_granularity): do not merge aliases

Open sivizius opened this issue 2 years ago • 7 comments

Fixes #6027.

Related: #4991.

sivizius avatar Jan 15 '24 18:01 sivizius

use {
    super::harriblex,
    super::harriblex::{
        Iraquant,
        Mediviction
    },
};

should be merged to:

use super::harriblex::{self, Iraquant, Mediviction};

and not:

use super::{
    harriblex,
    harriblex::{Iraquant, Mediviction},
};

But my change neither introduced nor fixed this. I will try to fix this as well, but this is technically a different issue and thus topic of a separate PR, right?

sivizius avatar Jan 16 '24 10:01 sivizius

use {
    super::harriblex,
    super::harriblex::{
        Iraquant,
        Mediviction
    },
};

should be merged to:

use super::harriblex::{self, Iraquant, Mediviction};

and not:

use super::{
    harriblex,
    harriblex::{Iraquant, Mediviction},
};

But my change neither introduced nor fixed this. I will try to fix this as well, but this is technically a different issue and thus topic of a separate PR, right?

What you've highlighted is not an issue. I know there's been prior discussion on the topic, but I couldn't find the exact link I was thinking about. I was able to find https://github.com/rust-lang/rustfmt/issues/3750, which mentions the issue. Ultimately, use super::harriblex; and use super::harriblex::{self}; are semantically different, and we don't want to make any formatting changes that would break those semantics.

ytmimi avatar Jan 16 '24 16:01 ytmimi

I rebased it, is there anything else left to do?

sivizius avatar Mar 05 '24 10:03 sivizius

I still need to take another look at this one. After I understood what the max_depth changes were doing I questioned whether or not a.equal_except_alias(b) was the right comparison to make in the take_while closure. Did you investigate whether or not it's possible to create a new function that takes the aliases into account when comparing a and b?

ytmimi avatar Mar 05 '24 14:03 ytmimi