Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions src/cargo/ops/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,8 @@ impl FixArgs {
if edition == "2018" { cmd.arg("-Wrust-2018-idioms"); }
}
}
match &self.prepare_for_edition {
PrepareFor::Edition(edition) => {
cmd.arg("-W").arg(format!("rust-{}-compatibility", edition));
}
PrepareFor::Next => {
let edition = self.next_edition();
cmd.arg("-W").arg(format!("rust-{}-compatibility", edition));
}
PrepareFor::None => {}
if let Some(edition) = self.prepare_for_edition_resolve() {
cmd.arg("-W").arg(format!("rust-{}-compatibility", edition));
}
}

Expand All @@ -558,10 +551,9 @@ impl FixArgs {
/// actually be able to fix anything! If it looks like this is happening
/// then yield an error to the user, indicating that this is happening.
fn verify_not_preparing_for_enabled_edition(&self) -> CargoResult<()> {
let edition = match &self.prepare_for_edition {
PrepareFor::Edition(s) => s,
PrepareFor::Next => self.next_edition(),
PrepareFor::None => return Ok(()),
let edition = match self.prepare_for_edition_resolve() {
Some(s) => s,
None => return Ok(()),
};
let enabled = match &self.enabled_edition {
Some(s) => s,
Expand Down Expand Up @@ -590,10 +582,9 @@ impl FixArgs {
///
/// If this is the case, issue a warning.
fn warn_if_preparing_probably_inert(&self) -> CargoResult<()> {
let edition = match &self.prepare_for_edition {
PrepareFor::Edition(s) => s,
PrepareFor::Next => self.next_edition(),
PrepareFor::None => return Ok(()),
let edition = match self.prepare_for_edition_resolve() {
Some(s) => s,
None => return Ok(()),
};
let path = match &self.file {
Some(s) => s,
Expand All @@ -616,6 +607,14 @@ impl FixArgs {
Ok(())
}

fn prepare_for_edition_resolve(&self) -> Option<&str> {
match &self.prepare_for_edition {
PrepareFor::Edition(s) => Some(s),
PrepareFor::Next => Some(self.next_edition()),
PrepareFor::None => None,
}
}

fn next_edition(&self) -> &str {
match self.enabled_edition.as_ref().map(|s| &**s) {
// 2015 -> 2018,
Expand Down