diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-10-16 16:57:53 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-10-19 14:34:44 +0200 |
| commit | 3c9258e604c7f5d3b7e86c34da1f067ff0a60257 (patch) | |
| tree | 96a2c373f7f060355817005e3040d07fdbe77262 /src/libsyntax_pos | |
| parent | ee81739dc1e0f1c4dff9480b52528fb688ef9251 (diff) | |
| download | rust-3c9258e604c7f5d3b7e86c34da1f067ff0a60257.tar.gz rust-3c9258e604c7f5d3b7e86c34da1f067ff0a60257.zip | |
Prefer `Default::default` over `FxHash*::default` in struct constructors
Diffstat (limited to 'src/libsyntax_pos')
| -rw-r--r-- | src/libsyntax_pos/symbol.rs | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index d412412fc65..361353c82e2 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -224,6 +224,7 @@ impl<T: ::std::ops::Deref<Target=str>> PartialEq<T> for Symbol { } // The &'static strs in this type actually point into the arena +#[derive(Default)] pub struct Interner { arena: DroplessArena, names: FxHashMap<&'static str, Symbol>, @@ -232,17 +233,8 @@ pub struct Interner { } impl Interner { - pub fn new() -> Self { - Interner { - arena: DroplessArena::new(), - names: Default::default(), - strings: Default::default(), - gensyms: Default::default(), - } - } - fn prefill(init: &[&str]) -> Self { - let mut this = Interner::new(); + let mut this = Interner::default(); for &string in init { if string == "" { // We can't allocate empty strings in the arena, so handle this here @@ -697,7 +689,7 @@ mod tests { #[test] fn interner_tests() { - let mut i: Interner = Interner::new(); + let mut i: Interner = Interner::default(); // first one is zero: assert_eq!(i.intern("dog"), Symbol(0)); // re-use gets the same entry: |
