From 76b49007f3400a6bc5af5586c2a31121c2525568 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Fri, 19 Apr 2019 08:54:26 -0500 Subject: [PATCH] don't pre-allocate the default edition string --- src/librustdoc/config.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 0a403f61e9c23..d17d27271ce62 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -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; @@ -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();