mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 05:38:46 +00:00
Remove some redundant allocations
This commit is contained in:
parent
479d1f7eec
commit
26a1675764
10 changed files with 9 additions and 10 deletions
|
@ -212,7 +212,7 @@ fn update_reference(
|
||||||
find_node_at_offset::<ast::PathExpr>(source_file.syntax(), offset)
|
find_node_at_offset::<ast::PathExpr>(source_file.syntax(), offset)
|
||||||
{
|
{
|
||||||
// tuple variant
|
// tuple variant
|
||||||
(path_expr.path()?.segment()?, path_expr.syntax().parent()?.clone())
|
(path_expr.path()?.segment()?, path_expr.syntax().parent()?)
|
||||||
} else if let Some(record_expr) =
|
} else if let Some(record_expr) =
|
||||||
find_node_at_offset::<ast::RecordExpr>(source_file.syntax(), offset)
|
find_node_at_offset::<ast::RecordExpr>(source_file.syntax(), offset)
|
||||||
{
|
{
|
||||||
|
|
|
@ -150,7 +150,7 @@ impl QualifyCandidate<'_> {
|
||||||
import,
|
import,
|
||||||
trait_method_name,
|
trait_method_name,
|
||||||
generics,
|
generics,
|
||||||
match arg_list.clone() {
|
match arg_list {
|
||||||
Some(args) => make::arg_list(iter::once(receiver).chain(args)),
|
Some(args) => make::arg_list(iter::once(receiver).chain(args)),
|
||||||
None => make::arg_list(iter::once(receiver)),
|
None => make::arg_list(iter::once(receiver)),
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ impl DnfExpr {
|
||||||
pub fn new(expr: CfgExpr) -> Self {
|
pub fn new(expr: CfgExpr) -> Self {
|
||||||
let builder = Builder { expr: DnfExpr { conjunctions: Vec::new() } };
|
let builder = Builder { expr: DnfExpr { conjunctions: Vec::new() } };
|
||||||
|
|
||||||
builder.lower(expr.clone())
|
builder.lower(expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes a list of present or absent atoms in `opts` that cause this expression to evaluate
|
/// Computes a list of present or absent atoms in `opts` that cause this expression to evaluate
|
||||||
|
|
|
@ -147,7 +147,7 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()
|
||||||
.filter_map(|(import_path, definition)| {
|
.filter_map(|(import_path, definition)| {
|
||||||
render_resolution_with_import(
|
render_resolution_with_import(
|
||||||
RenderContext::new(ctx),
|
RenderContext::new(ctx),
|
||||||
ImportEdit { import_path: import_path.clone(), import_scope: import_scope.clone() },
|
ImportEdit { import_path, import_scope: import_scope.clone() },
|
||||||
&definition,
|
&definition,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
|
@ -91,7 +91,7 @@ impl<'a> FunctionRender<'a> {
|
||||||
.zip(params_ty)
|
.zip(params_ty)
|
||||||
.flat_map(|(pat, param_ty)| {
|
.flat_map(|(pat, param_ty)| {
|
||||||
let pat = pat?;
|
let pat = pat?;
|
||||||
let name = pat.to_string();
|
let name = pat;
|
||||||
let arg = name.trim_start_matches("mut ").trim_start_matches('_');
|
let arg = name.trim_start_matches("mut ").trim_start_matches('_');
|
||||||
Some(self.add_arg(arg, param_ty.ty()))
|
Some(self.add_arg(arg, param_ty.ty()))
|
||||||
})
|
})
|
||||||
|
|
|
@ -475,7 +475,7 @@ fn add_target_crate_root(
|
||||||
Some(display_name),
|
Some(display_name),
|
||||||
cfg_options,
|
cfg_options,
|
||||||
env,
|
env,
|
||||||
proc_macro.clone(),
|
proc_macro,
|
||||||
);
|
);
|
||||||
|
|
||||||
crate_id
|
crate_id
|
||||||
|
|
|
@ -658,7 +658,6 @@ impl GlobalState {
|
||||||
log::trace!("updating notifications for {:?}", subscriptions);
|
log::trace!("updating notifications for {:?}", subscriptions);
|
||||||
if self.config.publish_diagnostics {
|
if self.config.publish_diagnostics {
|
||||||
let snapshot = self.snapshot();
|
let snapshot = self.snapshot();
|
||||||
let subscriptions = subscriptions.clone();
|
|
||||||
self.task_pool.handle.spawn(move || {
|
self.task_pool.handle.spawn(move || {
|
||||||
let diagnostics = subscriptions
|
let diagnostics = subscriptions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
@ -55,7 +55,7 @@ impl ast::Attr {
|
||||||
let key = self.simple_name()?;
|
let key = self.simple_name()?;
|
||||||
let value_token = lit.syntax().first_token()?;
|
let value_token = lit.syntax().first_token()?;
|
||||||
|
|
||||||
let value: SmolStr = ast::String::cast(value_token.clone())?.value()?.into();
|
let value: SmolStr = ast::String::cast(value_token)?.value()?.into();
|
||||||
|
|
||||||
Some((key, value))
|
Some((key, value))
|
||||||
}
|
}
|
||||||
|
|
|
@ -599,7 +599,7 @@ impl ast::IntNumber {
|
||||||
text = &text[radix.prefix_len()..];
|
text = &text[radix.prefix_len()..];
|
||||||
|
|
||||||
let buf;
|
let buf;
|
||||||
if text.contains("_") {
|
if text.contains('_') {
|
||||||
buf = text.replace('_', "");
|
buf = text.replace('_', "");
|
||||||
text = buf.as_str();
|
text = buf.as_str();
|
||||||
};
|
};
|
||||||
|
|
|
@ -134,7 +134,7 @@ r#####"
|
||||||
|
|
||||||
buf.push_str(&test)
|
buf.push_str(&test)
|
||||||
}
|
}
|
||||||
let buf = reformat(&buf.to_string())?;
|
let buf = reformat(&buf)?;
|
||||||
codegen::update(&project_root().join("crates/assists/src/tests/generated.rs"), &buf, mode)
|
codegen::update(&project_root().join("crates/assists/src/tests/generated.rs"), &buf, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue