mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 05:13:35 +00:00
prefer default over new
This commit is contained in:
parent
6ca780700d
commit
2462624a7d
46 changed files with 100 additions and 127 deletions
|
|
@ -112,6 +112,10 @@ pub struct Key<K, V, P = (K, V)> {
|
|||
}
|
||||
|
||||
impl<K, V, P> Key<K, V, P> {
|
||||
#[allow(
|
||||
clippy::new_without_default,
|
||||
reason = "this a const fn, so it can't be default yet. See <https://github.com/rust-lang/rust/issues/63065>"
|
||||
)]
|
||||
pub(crate) const fn new() -> Key<K, V, P> {
|
||||
Key { _phantom: PhantomData }
|
||||
}
|
||||
|
|
@ -148,16 +152,11 @@ impl<K: Hash + Eq + 'static, V: 'static> Policy for (K, V) {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct DynMap {
|
||||
pub(crate) map: Map,
|
||||
}
|
||||
|
||||
impl Default for DynMap {
|
||||
fn default() -> Self {
|
||||
DynMap { map: Map::new() }
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
pub struct KeyMap<KEY> {
|
||||
map: DynMap,
|
||||
|
|
|
|||
|
|
@ -2053,7 +2053,7 @@ impl ExprCollector<'_> {
|
|||
f: ast::FormatArgsExpr,
|
||||
syntax_ptr: AstPtr<ast::Expr>,
|
||||
) -> ExprId {
|
||||
let mut args = FormatArgumentsCollector::new();
|
||||
let mut args = FormatArgumentsCollector::default();
|
||||
f.args().for_each(|arg| {
|
||||
args.add(FormatArgument {
|
||||
kind: match arg.name() {
|
||||
|
|
|
|||
|
|
@ -460,10 +460,6 @@ impl FormatArgumentsCollector {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
pub fn add(&mut self, arg: FormatArgument) -> usize {
|
||||
let index = self.arguments.len();
|
||||
if let Some(name) = arg.kind.ident() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue