1
Fork 0

Prefer Default::default over FxHash*::default in struct constructors

This commit is contained in:
Oliver Scherer 2018-10-16 16:57:53 +02:00
parent ee81739dc1
commit 3c9258e604
82 changed files with 237 additions and 362 deletions

View file

@ -178,7 +178,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
inner: ImplItem(Impl {
unsafety: hir::Unsafety::Normal,
generics: new_generics,
provided_trait_methods: FxHashSet::default(),
provided_trait_methods: Default::default(),
trait_: Some(trait_.clean(self.cx)),
for_: ty.clean(self.cx),
items: Vec::new(),
@ -267,9 +267,9 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
// all intermediate RegionVids. At the end, all constraints should
// be between Regions (aka region variables). This gives us the information
// we need to create the Generics.
let mut finished: FxHashMap<_, Vec<_>> = FxHashMap::default();
let mut finished: FxHashMap<_, Vec<_>> = Default::default();
let mut vid_map: FxHashMap<RegionTarget, RegionDeps> = FxHashMap::default();
let mut vid_map: FxHashMap<RegionTarget, RegionDeps> = Default::default();
// Flattening is done in two parts. First, we insert all of the constraints
// into a map. Each RegionTarget (either a RegionVid or a Region) maps
@ -577,11 +577,11 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
} = full_generics.clean(self.cx);
let mut has_sized = FxHashSet::default();
let mut ty_to_bounds: FxHashMap<_, FxHashSet<_>> = FxHashMap::default();
let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = FxHashMap::default();
let mut ty_to_traits: FxHashMap<Type, FxHashSet<Type>> = FxHashMap::default();
let mut ty_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default();
let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default();
let mut ty_to_traits: FxHashMap<Type, FxHashSet<Type>> = Default::default();
let mut ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)> = FxHashMap::default();
let mut ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)> = Default::default();
for (orig_p, p) in clean_where_predicates {
match p {

View file

@ -368,7 +368,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
.into_iter()
.map(|meth| meth.ident.to_string())
.collect()
}).unwrap_or(FxHashSet::default());
}).unwrap_or_default();
debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id());

View file

@ -75,8 +75,7 @@ use self::cfg::Cfg;
use self::auto_trait::AutoTraitFinder;
use self::blanket_impl::BlanketImplFinder;
thread_local!(pub static MAX_DEF_ID: RefCell<FxHashMap<CrateNum, DefId>> =
RefCell::new(FxHashMap::default()));
thread_local!(pub static MAX_DEF_ID: RefCell<FxHashMap<CrateNum, DefId>> = Default::default());
const FN_OUTPUT_NAME: &'static str = "Output";
@ -3388,7 +3387,7 @@ impl Clean<Vec<Item>> for doctree::Impl {
.into_iter()
.map(|meth| meth.ident.to_string())
.collect()
}).unwrap_or(FxHashSet::default());
}).unwrap_or_default();
ret.push(Item {
name: None,