Skip to content

Commit 2c471a5

Browse files
authored
Merge pull request rust-lang#3152 from topecongiro/do-not-override-edition-in-rustfmt-toml
Use edition in rustfmt.toml when no command line argument is passed
2 parents b2706eb + 6fa804d commit 2c471a5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/bin/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ struct GetOptsOptions {
438438
emit_mode: EmitMode,
439439
backup: bool,
440440
check: bool,
441-
edition: Edition,
441+
edition: Option<Edition>,
442442
color: Option<Color>,
443443
file_lines: FileLines, // Default is all lines in all files.
444444
unstable_features: bool,
@@ -503,7 +503,7 @@ impl GetOptsOptions {
503503
}
504504

505505
if let Some(ref edition_str) = matches.opt_str("edition") {
506-
options.edition = edition_from_edition_str(edition_str)?;
506+
options.edition = Some(edition_from_edition_str(edition_str)?);
507507
}
508508

509509
if matches.opt_present("backup") {
@@ -559,7 +559,9 @@ impl CliOptions for GetOptsOptions {
559559
if let Some(error_on_unformatted) = self.error_on_unformatted {
560560
config.set().error_on_unformatted(error_on_unformatted);
561561
}
562-
config.set().edition(self.edition);
562+
if let Some(edition) = self.edition {
563+
config.set().edition(edition);
564+
}
563565
if self.check {
564566
config.set().emit_mode(EmitMode::Diff);
565567
} else {

0 commit comments

Comments
 (0)