You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rustfmt is removing the :: prefix of absolute imports, which breaks when that import must differentiate between the crate of that name and a clashing module. An example:
$ cat src/lib.rs
// an empty module that shares the name of another crate, no problem
mod std {}
// i can access the original crate through ::std
use ::std::string;
$ cargo build
...
Finished dev [unoptimized + debuginfo] target(s) in 0.00s // <----- successful build
$ rustfmt --version
rustfmt 1.4.9-nightly (33e3667 2019-10-07)
$ rustfmt src/lib.rs
$ cat src/lib.rs
// an empty module that shares the name of another crate, no problem
mod std {}
// i can access the original crate through ::std
use std::string; // <------------ note the removed :: prefix
$ cargo build
Compiling fmt v0.1.0 (/tmp/fmt)
error[E0432]: unresolved import `std::string`
--> src/lib.rs:5:5
|
5 | use std::string;
| ^^^^^^^^^^^ no `string` in `std`
error[E0659]: `std` is ambiguous (name vs any other name during import resolution)
--> src/lib.rs:5:5
|
5 | use std::string;
| ^^^ ambiguous name
|
= note: `std` could refer to a built-in crate
= help: use `::std` to refer to this crate unambiguously
note: `std` could also refer to the module defined here
--> src/lib.rs:2:1
|
2 | mod std {}
| ^^^^^^^^^^
= help: use `crate::std` to refer to this module unambiguously
error: aborting due to 2 previous errors
The text was updated successfully, but these errors were encountered:
Have you tried including edition either via --edition 2018 arg or in your rustfmt config file? rustfmt 2.0 will switch the default edition to 2018 but it currently defaults to 2015
Rustfmt is removing the
::
prefix of absolute imports, which breaks when that import must differentiate between the crate of that name and a clashing module. An example:The text was updated successfully, but these errors were encountered: