diff options
| -rw-r--r-- | src/librustc/session/config.rs | 31 | ||||
| -rw-r--r-- | src/librustc_typeck/lib.rs | 6 | ||||
| -rw-r--r-- | src/librustdoc/config.rs | 10 |
3 files changed, 17 insertions, 30 deletions
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 00dfe9aca39..d3a734cbc6e 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -285,7 +285,7 @@ impl OutputTypes { #[derive(Clone, Hash)] pub struct Externs(BTreeMap<String, ExternEntry>); -#[derive(Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug)] +#[derive(Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug, Default)] pub struct ExternEntry { pub locations: BTreeSet<Option<String>>, pub is_private_dep: bool @@ -2337,26 +2337,17 @@ pub fn build_session_options_and_crate_config( ); }; - - externs + let entry = externs .entry(name.to_owned()) - .and_modify(|e| { - e.locations.insert(location.clone()); - - // Crates start out being not private, - // and go to being private if we see an '--extern-private' - // flag - e.is_private_dep |= private; - }) - .or_insert_with(|| { - let mut locations = BTreeSet::new(); - locations.insert(location); - - ExternEntry { - locations: locations, - is_private_dep: private - } - }); + .or_default(); + + + entry.locations.insert(location.clone()); + + // Crates start out being not private, + // and go to being private if we see an '--extern-private' + // flag + entry.is_private_dep |= private; } let crate_name = matches.opt_str("crate-name"); diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 401d7457517..21d1af229dd 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -176,7 +176,7 @@ fn require_same_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }) } -pub fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, main_def_id: DefId) { +fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, main_def_id: DefId) { let main_id = tcx.hir().as_local_hir_id(main_def_id).unwrap(); let main_span = tcx.def_span(main_def_id); let main_t = tcx.type_of(main_def_id); @@ -241,7 +241,7 @@ pub fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, main_def_id: DefI } } -pub fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, start_def_id: DefId) { +fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, start_def_id: DefId) { let start_id = tcx.hir().as_local_hir_id(start_def_id).unwrap(); let start_span = tcx.def_span(start_def_id); let start_t = tcx.type_of(start_def_id); @@ -298,7 +298,7 @@ pub fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, start_def_id: De } } -pub fn check_for_entry_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { +fn check_for_entry_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { match tcx.entry_fn(LOCAL_CRATE) { Some((def_id, EntryFnType::Main)) => check_main_fn_ty(tcx, def_id), Some((def_id, EntryFnType::Start)) => check_start_fn_ty(tcx, def_id), diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 8a669cad514..a4d2a3be863 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -1,4 +1,4 @@ -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::BTreeMap; use std::fmt; use std::path::PathBuf; @@ -590,12 +590,8 @@ fn parse_externs(matches: &getopts::Matches) -> Result<Externs, String> { let name = name.to_string(); // For Rustdoc purposes, we can treat all externs as public externs.entry(name) - .and_modify(|e| { e.locations.insert(location.clone()); } ) - .or_insert_with(|| { - let mut locations = BTreeSet::new(); - locations.insert(location); - ExternEntry { locations, is_private_dep: false } - }); + .or_default() + .locations.insert(location.clone()); } Ok(Externs::new(externs)) } |
