Skip to content

Commit 76b4900

Browse files
don't pre-allocate the default edition string
1 parent e61ff77 commit 76b4900

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/librustdoc/config.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc::session::config::{nightly_options, build_codegen_options, build_debug
1313
use rustc::session::search_paths::SearchPath;
1414
use rustc_driver;
1515
use rustc_target::spec::TargetTriple;
16-
use syntax::edition::Edition;
16+
use syntax::edition::{Edition, DEFAULT_EDITION};
1717

1818
use crate::core::new_handler;
1919
use crate::externalfiles::ExternalHtml;
@@ -386,13 +386,16 @@ impl Options {
386386
}
387387
}
388388

389-
let edition = matches.opt_str("edition").unwrap_or("2015".to_string());
390-
let edition = match edition.parse() {
391-
Ok(e) => e,
392-
Err(_) => {
393-
diag.struct_err("could not parse edition").emit();
394-
return Err(1);
389+
let edition = if let Some(e) = matches.opt_str("edition") {
390+
match e.parse() {
391+
Ok(e) => e,
392+
Err(_) => {
393+
diag.struct_err("could not parse edition").emit();
394+
return Err(1);
395+
}
395396
}
397+
} else {
398+
DEFAULT_EDITION
396399
};
397400

398401
let mut id_map = html::markdown::IdMap::new();

0 commit comments

Comments
 (0)