Skip to content

Commit

Permalink
don't pre-allocate the default edition string
Browse files Browse the repository at this point in the history
  • Loading branch information
QuietMisdreavus committed May 6, 2019
1 parent e61ff77 commit 76b4900
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc::session::config::{nightly_options, build_codegen_options, build_debug
use rustc::session::search_paths::SearchPath;
use rustc_driver;
use rustc_target::spec::TargetTriple;
use syntax::edition::Edition;
use syntax::edition::{Edition, DEFAULT_EDITION};

use crate::core::new_handler;
use crate::externalfiles::ExternalHtml;
Expand Down Expand Up @@ -386,13 +386,16 @@ impl Options {
}
}

let edition = matches.opt_str("edition").unwrap_or("2015".to_string());
let edition = match edition.parse() {
Ok(e) => e,
Err(_) => {
diag.struct_err("could not parse edition").emit();
return Err(1);
let edition = if let Some(e) = matches.opt_str("edition") {
match e.parse() {
Ok(e) => e,
Err(_) => {
diag.struct_err("could not parse edition").emit();
return Err(1);
}
}
} else {
DEFAULT_EDITION
};

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

0 comments on commit 76b4900

Please sign in to comment.