#[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
);
};
-
- 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");
})
}
-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);
}
}
-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);
}
}
-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),
-use std::collections::{BTreeMap, BTreeSet};
+use std::collections::BTreeMap;
use std::fmt;
use std::path::PathBuf;
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))
}