Skip to content

Errors upgrading the turtle crate to the 2018 edition #60222

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
sunjay opened this issue Apr 24, 2019 · 2 comments
Closed

Errors upgrading the turtle crate to the 2018 edition #60222

sunjay opened this issue Apr 24, 2019 · 2 comments
Labels
A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@sunjay
Copy link
Member

sunjay commented Apr 24, 2019

Hi,
I was updating the turtle crate to the 2018 edition (following the instructions in the guide) and I got the error message below. It instructed me to open this issue, and I always do whatever rustc says, so here you go. 😄

$ cargo fix --edition-idioms --features test --broken-code --allow-dirty
    Checking turtle v1.0.0-rc.3 (/home/sunjay/Documents/projects/turtle)
warning: failed to automatically apply fixes suggested by rustc to crate `turtle`

after fixes were automatically applied the compiler reported errors within these files:

  * src/color.rs
  * src/lib.rs
  * src/point.rs
  * src/rand.rs
  * src/speed.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see 
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

The following errors were reported:
error[E0433]: failed to resolve: could not find `distributions` in `self`
   --> src/rand.rs:197:11
    |
197 | use self::distributions::range::SampleRange;
    |           ^^^^^^^^^^^^^ could not find `distributions` in `self`

error[E0432]: unresolved import `crate::rand_crate::*`
   --> src/rand.rs:195:9
    |
195 | pub use crate::rand_crate::*;
    |         ^^^^^^^^^^^^^^^^^^^^ Cannot glob-import a module into itself.

error[E0432]: unresolved import `crate::rand::random`
  --> src/lib.rs:89:23
   |
89 | pub use crate::rand::{random, random_range};
   |                       ^^^^^^ no `random` in `rand`

error[E0432]: unresolved imports `crate::rand::distributions`, `crate::rand::Rng`
 --> src/point.rs:5:5
  |
5 |     distributions::{Distribution, Standard},
  |     ^^^^^^^^^^^^^ could not find `distributions` in `rand`
6 |     RandomRange, Rng,
  |                  ^^^ no `Rng` in `rand`

error[E0432]: unresolved imports `crate::rand::distributions`, `crate::rand::Rng`
 --> src/speed.rs:8:5
  |
8 |     distributions::{Distribution, Standard},
  |     ^^^^^^^^^^^^^ could not find `distributions` in `rand`
9 |     Rng,
  |     ^^^ no `Rng` in `rand`

error[E0432]: unresolved imports `crate::rand::distributions`, `crate::rand::Rng`
   --> src/color.rs:163:5
    |
163 |     distributions::{Distribution, Standard},
    |     ^^^^^^^^^^^^^ could not find `distributions` in `rand`
164 |     Rng,
    |     ^^^ no `Rng` in `rand`

error[E0405]: cannot find trait `Rng` in this scope
   --> src/rand.rs:200:24
    |
200 |     fn random_range<R: Rng>(rng: &mut R, low: Self, high: Self) -> Self;
    |                        ^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
    |
195 | use rand::Rng;
    |
195 | use rand::prelude::Rng;
    |

error[E0405]: cannot find trait `SampleRange` in this scope
   --> src/rand.rs:205:21
    |
205 |     T: PartialOrd + SampleRange,
    |                     ^^^^^^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
    |
195 | use rand::distributions::range::SampleRange;
    |

error[E0405]: cannot find trait `Rng` in this scope
   --> src/rand.rs:207:24
    |
207 |     fn random_range<R: Rng>(rng: &mut R, low: T, high: T) -> T {
    |                        ^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
    |
195 | use rand::Rng;
    |
195 | use rand::prelude::Rng;
    |

error[E0425]: cannot find function `thread_rng` in this scope
   --> src/rand.rs:236:19
    |
236 |     let mut rng = thread_rng();
    |                   ^^^^^^^^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
    |
195 | use rand::prelude::thread_rng;
    |
195 | use rand::thread_rng;
    |

error[E0659]: `rand` is ambiguous (name vs any other name during import resolution)
  --> src/lib.rs:51:5
   |
51 | use rand as rand_crate;
   |     ^^^^ ambiguous name
   |
   = note: `rand` could refer to an extern crate passed with `--extern`
   = help: use `::rand` to refer to this extern crate unambiguously
note: `rand` could also refer to the module defined here
  --> src/lib.rs:83:1
   |
83 | pub mod rand;
   | ^^^^^^^^^^^^^
   = help: use `crate::rand` to refer to this module unambiguously

warning: unused import: `serde_json`
  --> src/lib.rs:47:5
   |
47 | use serde_json;
   |     ^^^^^^^^^^
   |
   = note: #[warn(unused_imports)] on by default

warning: unused import: `self::distributions::range::SampleRange`
   --> src/rand.rs:197:5
    |
197 | use self::distributions::range::SampleRange;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 11 previous errors

Some errors occurred: E0405, E0425, E0432, E0433, E0659.
For more information about an error, try `rustc --explain E0405`.
Original diagnostics will follow.

error[E0432]: unresolved import `crate::rand_crate::*`
   --> src/rand.rs:195:9
    |
195 | pub use crate::rand_crate::*;
    |         ^^^^^^^^^^^^^^^^^^^^ Cannot glob-import a module into itself.

error[E0432]: unresolved import `crate::rand::random`
  --> src/lib.rs:89:23
   |
89 | pub use crate::rand::{random, random_range};
   |                       ^^^^^^ no `random` in `rand`

error[E0432]: unresolved imports `crate::rand::distributions`, `crate::rand::Rng`
 --> src/point.rs:5:5
  |
5 |     distributions::{Distribution, Standard},
  |     ^^^^^^^^^^^^^ could not find `distributions` in `rand`
6 |     RandomRange, Rng,
  |                  ^^^ no `Rng` in `rand`

error[E0432]: unresolved imports `crate::rand::distributions`, `crate::rand::Rng`
 --> src/speed.rs:8:5
  |
8 |     distributions::{Distribution, Standard},
  |     ^^^^^^^^^^^^^ could not find `distributions` in `rand`
9 |     Rng,
  |     ^^^ no `Rng` in `rand`

error[E0432]: unresolved imports `crate::rand::distributions`, `crate::rand::Rng`
   --> src/color.rs:163:5
    |
163 |     distributions::{Distribution, Standard},
    |     ^^^^^^^^^^^^^ could not find `distributions` in `rand`
164 |     Rng,
    |     ^^^ no `Rng` in `rand`

warning: failed to automatically apply fixes suggested by rustc to crate `turtle`

after fixes were automatically applied the compiler reported errors within these files:

  * src/color.rs
  * src/lib.rs
  * src/point.rs
  * src/rand.rs
  * src/speed.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see 
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

The following errors were reported:
error[E0432]: unresolved import `crate::rand_crate::*`
   --> src/rand.rs:195:9
    |
195 | pub use crate::rand_crate::*;
    |         ^^^^^^^^^^^^^^^^^^^^ Cannot glob-import a module into itself.

error[E0432]: unresolved import `crate::rand::random`
  --> src/lib.rs:89:23
   |
89 | pub use crate::rand::{random, random_range};
   |                       ^^^^^^ no `random` in `rand`

error[E0432]: unresolved imports `crate::rand::distributions`, `crate::rand::Rng`
 --> src/point.rs:5:5
  |
5 |     distributions::{Distribution, Standard},
  |     ^^^^^^^^^^^^^ could not find `distributions` in `rand`
6 |     RandomRange, Rng,
  |                  ^^^ no `Rng` in `rand`

error[E0432]: unresolved imports `crate::rand::distributions`, `crate::rand::Rng`
 --> src/speed.rs:8:5
  |
8 |     distributions::{Distribution, Standard},
  |     ^^^^^^^^^^^^^ could not find `distributions` in `rand`
9 |     Rng,
  |     ^^^ no `Rng` in `rand`

error[E0432]: unresolved imports `crate::rand::distributions`, `crate::rand::Rng`
   --> src/color.rs:163:5
    |
163 |     distributions::{Distribution, Standard},
    |     ^^^^^^^^^^^^^ could not find `distributions` in `rand`
164 |     Rng,
    |     ^^^ no `Rng` in `rand`

error[E0405]: cannot find trait `Rng` in this scope
   --> src/rand.rs:200:24
    |
200 |     fn random_range<R: Rng>(rng: &mut R, low: Self, high: Self) -> Self;
    |                        ^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
    |
195 | use rand::Rng;
    |
195 | use rand::prelude::Rng;
    |

error[E0405]: cannot find trait `SampleRange` in this scope
   --> src/rand.rs:205:21
    |
205 |     T: PartialOrd + SampleRange,
    |                     ^^^^^^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
    |
195 | use rand::distributions::range::SampleRange;
    |

error[E0405]: cannot find trait `Rng` in this scope
   --> src/rand.rs:207:24
    |
207 |     fn random_range<R: Rng>(rng: &mut R, low: T, high: T) -> T {
    |                        ^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
    |
195 | use rand::Rng;
    |
195 | use rand::prelude::Rng;
    |

error[E0425]: cannot find function `thread_rng` in this scope
   --> src/rand.rs:236:19
    |
236 |     let mut rng = thread_rng();
    |                   ^^^^^^^^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
    |
195 | use rand::prelude::thread_rng;
    |
195 | use rand::thread_rng;
    |

error[E0659]: `rand` is ambiguous (name vs any other name during import resolution)
  --> src/lib.rs:51:5
   |
51 | use rand as rand_crate;
   |     ^^^^ ambiguous name
   |
   = note: `rand` could refer to an extern crate passed with `--extern`
   = help: use `::rand` to refer to this extern crate unambiguously
note: `rand` could also refer to the module defined here
  --> src/lib.rs:83:1
   |
83 | pub mod rand;
   | ^^^^^^^^^^^^^
   = help: use `crate::rand` to refer to this module unambiguously

error: aborting due to 10 previous errors

Some errors occurred: E0405, E0425, E0432, E0659.
For more information about an error, try `rustc --explain E0405`.
Original diagnostics will follow.

error[E0405]: cannot find trait `Rng` in this scope
   --> src/rand.rs:200:24
    |
200 |     fn random_range<R: Rng>(rng: &mut R, low: Self, high: Self) -> Self;
    |                        ^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
    |
195 | use rand::Rng;
    |
195 | use rand::prelude::Rng;
    |

error[E0405]: cannot find trait `SampleRange` in this scope
   --> src/rand.rs:205:21
    |
205 |     T: PartialOrd + SampleRange,
    |                     ^^^^^^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
    |
195 | use rand::distributions::range::SampleRange;
    |

error[E0405]: cannot find trait `Rng` in this scope
   --> src/rand.rs:207:24
    |
207 |     fn random_range<R: Rng>(rng: &mut R, low: T, high: T) -> T {
    |                        ^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
    |
195 | use rand::Rng;
    |
195 | use rand::prelude::Rng;
    |

error[E0425]: cannot find function `thread_rng` in this scope
   --> src/rand.rs:236:19
    |
236 |     let mut rng = thread_rng();
    |                   ^^^^^^^^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
    |
195 | use rand::prelude::thread_rng;
    |
195 | use rand::thread_rng;
    |

error[E0659]: `rand` is ambiguous (name vs any other name during import resolution)
  --> src/lib.rs:51:5
   |
51 | use rand as rand_crate;
   |     ^^^^ ambiguous name
   |
   = note: `rand` could refer to an extern crate passed with `--extern`
   = help: use `::rand` to refer to this extern crate unambiguously
note: `rand` could also refer to the module defined here
  --> src/lib.rs:83:1
   |
83 | pub mod rand;
   | ^^^^^^^^^^^^^
   = help: use `crate::rand` to refer to this module unambiguously

error: aborting due to 10 previous errors

Some errors occurred: E0405, E0425, E0432, E0659.
For more information about an error, try `rustc --explain E0405`.
error: Could not compile `turtle`.
warning: build failed, waiting for other jobs to finish...
error[E0432]: unresolved import `crate::rand_crate::*`
   --> src/rand.rs:195:9
    |
195 | pub use crate::rand_crate::*;
    |         ^^^^^^^^^^^^^^^^^^^^ Cannot glob-import a module into itself.

error[E0432]: unresolved import `crate::rand::random`
  --> src/lib.rs:89:23
   |
89 | pub use crate::rand::{random, random_range};
   |                       ^^^^^^ no `random` in `rand`

error[E0432]: unresolved imports `crate::rand::distributions`, `crate::rand::Rng`
 --> src/point.rs:5:5
  |
5 |     distributions::{Distribution, Standard},
  |     ^^^^^^^^^^^^^ could not find `distributions` in `rand`
6 |     RandomRange, Rng,
  |                  ^^^ no `Rng` in `rand`

error[E0432]: unresolved imports `crate::rand::distributions`, `crate::rand::Rng`
 --> src/speed.rs:8:5
  |
8 |     distributions::{Distribution, Standard},
  |     ^^^^^^^^^^^^^ could not find `distributions` in `rand`
9 |     Rng,
  |     ^^^ no `Rng` in `rand`

error[E0432]: unresolved imports `crate::rand::distributions`, `crate::rand::Rng`
   --> src/color.rs:163:5
    |
163 |     distributions::{Distribution, Standard},
    |     ^^^^^^^^^^^^^ could not find `distributions` in `rand`
164 |     Rng,
    |     ^^^ no `Rng` in `rand`

error[E0405]: cannot find trait `Rng` in this scope
   --> src/rand.rs:200:24
    |
200 |     fn random_range<R: Rng>(rng: &mut R, low: Self, high: Self) -> Self;
    |                        ^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
    |
195 | use rand::Rng;
    |
195 | use rand::prelude::Rng;
    |

error[E0405]: cannot find trait `SampleRange` in this scope
   --> src/rand.rs:205:21
    |
205 |     T: PartialOrd + SampleRange,
    |                     ^^^^^^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
    |
195 | use rand::distributions::range::SampleRange;
    |

error[E0405]: cannot find trait `Rng` in this scope
   --> src/rand.rs:207:24
    |
207 |     fn random_range<R: Rng>(rng: &mut R, low: T, high: T) -> T {
    |                        ^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
    |
195 | use rand::Rng;
    |
195 | use rand::prelude::Rng;
    |

error[E0425]: cannot find function `thread_rng` in this scope
   --> src/rand.rs:236:19
    |
236 |     let mut rng = thread_rng();
    |                   ^^^^^^^^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
    |
195 | use rand::prelude::thread_rng;
    |
195 | use rand::thread_rng;
    |

error[E0659]: `rand` is ambiguous (name vs any other name during import resolution)
  --> src/lib.rs:51:5
   |
51 | use rand as rand_crate;
   |     ^^^^ ambiguous name
   |
   = note: `rand` could refer to an extern crate passed with `--extern`
   = help: use `::rand` to refer to this extern crate unambiguously
note: `rand` could also refer to the module defined here
  --> src/lib.rs:83:1
   |
83 | pub mod rand;
   | ^^^^^^^^^^^^^
   = help: use `crate::rand` to refer to this module unambiguously

error: aborting due to 10 previous errors

Some errors occurred: E0405, E0425, E0432, E0659.
For more information about an error, try `rustc --explain E0405`.
error: Could not compile `turtle`.

To learn more, run the command again with --verbose.

I think a lot of these have to do with me renaming the rand crate to rand_crate using extern crate rand as rand_crate. This caused a lot of issues because cargo fix --edition removed that line without adequately replacing it everywhere.

Here's a link to the source code just before I started the upgrade: https://github.com/sunjay/turtle/tree/05a5fa118b154c5504bfc9fb770081c2846dd80d

@ehuss
Copy link
Contributor

ehuss commented Apr 24, 2019

I think this is the same as #57672.

@sunjay
Copy link
Member Author

sunjay commented Apr 24, 2019

I think you're right! Thanks! 😄

@sunjay sunjay closed this as completed Apr 24, 2019
@fmease fmease added A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-edition-2018-lints labels Dec 21, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

4 participants