I’ve opened https://github.com/rust-lang-nursery/edition-guide/pull/69 which hopefully will help others in this area. It makes sense after your explanation, but I think calling it out explicitly in the guide will help others not trip over this (at least until https://github.com/rust-lang/cargo/issues/5778) is complete.
I re-did the steps with the correct flags and I am still getting some false positive lints (maybe I should bug report)?
main.rs:
//! Rust belt is a 2D video game inspired by Asteroids.
//! It runs atop the Piston game engine for graphics and SDL2 for sound.
#![feature(rust_2018_preview)]
#![warn(rust_2018_idioms)]
extern crate ai_behavior;
extern crate music;
extern crate opengl_graphics;
extern crate piston_window;
extern crate rand;
extern crate sprite;
use piston_window::{OpenGL, PistonWindow, Size, WindowSettings};
use opengl_graphics::GlGraphics;
mod game;
mod menu;
mod settings;
mod story;
/// Creates a new window and runs the game starts the main menu.
fn main() {
let game_title = "Rust Belt";
let game_window_size = Size {
width: 1024,
height: 768,
};
let opengl = OpenGL::V3_2;
let mut window: PistonWindow = WindowSettings::new(
game_title,
[game_window_size.width, game_window_size.height],
).opengl(opengl)
.samples(4)
.exit_on_esc(true)
.build()
.unwrap_or_else(|error| panic!("Failed to build PistonWindow: {}", error));
let mut gl = GlGraphics::new(opengl);
menu::run(&mut window, &mut gl, game_window_size);
}
Cargo.toml:
cargo-features = ["edition"]
[package]
name = "rust-belt"
version = "1.2.0"
authors = [
"johnthagen <johnthagen@gmail.com>",
"theandrewdavis <theandrewdavis@gmail.com>",
"mcdenhoed <mcdenhoed@gmail.com>",
]
edition = '2018'
[dependencies]
piston_window = "0.80.0"
piston2d-opengl_graphics = "0.53.0"
piston-music = "0.24.0"
piston2d-sprite = "0.45.0"
piston-ai_behavior = "0.24.0"
rand = "0.5.4"
>cargo +nightly fix --allow-dirty
Checking rust-belt v1.2.0 (file:///C:/Users/User/PycharmProjects/rust-belt)
Fixing src\story.rs (3 fixes)
Fixing src\game\models\vector.rs (8 fixes)
Fixing src\game\mod.rs (9 fixes)
Fixing src\menu.rs (7 fixes)
Fixing src\game\models\mod.rs (7 fixes)
Fixing src\game\models\player.rs (14 fixes)
Fixing src\game\color.rs (9 fixes)
Fixing src\settings.rs (3 fixes)
Fixing src\game\models\bullet.rs (3 fixes)
Fixing src\game\models\asteroid.rs (4 fixes)
warning: unused extern crate
--> src\main.rs:6:1
|
6 | extern crate ai_behavior;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
|
note: lint level defined here
--> src\main.rs:4:9
|
4 | #![warn(rust_2018_idioms)]
| ^^^^^^^^^^^^^^^^
= note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)]
warning: `extern crate` is not idiomatic in the new edition
--> src\main.rs:7:1
|
7 | extern crate music;
| ^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
warning: unused extern crate
--> src\main.rs:8:1
|
8 | extern crate opengl_graphics;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
warning: unused extern crate
--> src\main.rs:9:1
|
9 | extern crate piston_window;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
warning: `extern crate` is not idiomatic in the new edition
--> src\main.rs:10:1
|
10 | extern crate rand;
| ^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
warning: unused extern crate
--> src\main.rs:11:1
|
11 | extern crate sprite;
| ^^^^^^^^^^^^^^^^^^^^ help: remove it
Finished dev [unoptimized + debuginfo] target(s) in 2.51s
The lints that say help: convert it to a 'use' should all say remove it. Removing the extern crate's allows the project to build and run without warnings. Is this something that should be reported?