-
Notifications
You must be signed in to change notification settings - Fork 62
Conversation
This requires #![feature(crate_in_paths)] #![deny(absolute_path_starting_with_module)] on `rustc 1.27.0-nightly (8ff4b4206 2018-05-08)`, so we're not really there yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
cargo-fix/src/cli.rs
Outdated
.arg( | ||
Arg::with_name("edition") | ||
.long("prepare-for") | ||
.help("Fix warnigns in preparation of an edition upgrade") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warnigns
r#" | ||
#![allow(unused)] | ||
#![feature(crate_in_paths)] | ||
#![warn(absolute_path_starting_with_module)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be necessary, right?
cargo-fix/src/cli.rs
Outdated
info!("edition upgrade!"); | ||
let mut rustc_flags = env::var_os("RUSTC_FLAGS").unwrap_or_else(|| "".into()); | ||
rustc_flags.push("-A warnings -W rust_2018_breakage"); | ||
cmd.env("RUSTC_FLAGS", &rustc_flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be RUSTFLAGS?
Fix env var name, list explicit allow lints I'd like to have a way to disable all lints and than individually enable the breakage lint group, but sadly `-A warnings -D rust-2018-breakage` doesn't seem to work. So, let's list the default lint groups for now.
cargo-fix/src/cli.rs
Outdated
if let Some("2018") = matches.value_of("edition") { | ||
info!("edition upgrade!"); | ||
let mut rustc_flags = env::var_os("RUSTFLAGS").unwrap_or_else(|| "".into()); | ||
rustc_flags.push("-W rust-2018-breakage -A unused -A nonstandard-style -A bad-style"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come these specific -A
flags were required? I'd actually sort of expect that we don't pass any extra arguments other than the -W
for the lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want just the breakage links here -- but other lints might trigger. And I don't know how to disabled everything but one lint group in a clever way :(
I'd like to have a way to disable all lints and than individually enable
the breakage lint group, but sadly-A warnings -D rust-2018-breakage
doesn't seem to work. So, let's list the default lint groups for now.– commit message of fe2526e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm is it bad though if other warnings are emitted? Or is it bad if we fix some otherwise fixable warnings along the way?
I'm worried about this being an ever-growing list :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm all for fixing as many things as possible, but it might send the wrong message in this specific context. E.g., if I run cargo fix --prepare-for 2018
and it removes a bunch of (unused) mut
s I might end up thinking that this is required for the new edition.
I'll try and play around with filtering by the lint group that triggered a lint. If that's possible we can just add the -W rust-2018-breakage
and skip fixing other lints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can run without edition lints, and if any diagnostics appear, ask the user to fix them first. If none appear, do what you do now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True yeah we could filter, but I'd imagine that for most maintained codebases they're already warning-free, so I wouldn't expect something like this to come up much in practice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't even mean filtering, just abort if there are any (and tell the user the reason for the abort)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have seen many new rustaceans who have crates that are full of warnings, because they're used to that from other languages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sure yeah that's a possibility, although I'm still not sure why we would go out of our way to worry about other lints. Everything should work A-OK if we purely pass -W rust-2018-breakage
. The user will be informed, as they always are, of lints that couldn't be fixed. Anything that comes up which is fixable as part of the breakage lint is already fixed.
"src/lib.rs", | ||
r#" | ||
#![allow(unused)] | ||
#![feature(crate_in_paths)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh gee this is gonna make for a not-so-great user experience :(
If users don't have this enabled then rustfix will accidentally deduce that its fixes broke your crate, so they'll all be backed out. That's a bummer...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah…
Without the feature flag, we don't 'fix' anything, though, so I don't see how we could ever revert fixes?
Ok after some conversation on gitter it looks like we're adding another step to the cheat sheet which is that you need to add @killercup given that can we, in the meantime, read the crate root source file and just grep for the string "rust_2018_preview"? If that string is present we can turn on the breakage lint but otherwise I don't think we should automatically enable it. Otherwise we're gonna get a lot of bug reports I think because rustfix says "please file a bug if a fix was applied and it then failed" |
To be clear, this can't happen due to lack of a feature flag, the lints are designed to only trigger if the features required for their replacement are enabled. The failure case here is that not having the feature means you don't get the warning, not that not having the feature gives you a broken warning. |
Ok cool, I seem to have been confused then. I remembered running |
133b2be
to
a956e9e
Compare
👍 |
This requires
on
rustc 1.27.0-nightly (8ff4b4206 2018-05-08)
, so we're not really there yet.