mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Merge #6846
6846: Remove some redundant allocations r=kjeremy a=kjeremy Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
This commit is contained in:
commit
10f6332831
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)
|
||||
{
|
||||
// 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) =
|
||||
find_node_at_offset::<ast::RecordExpr>(source_file.syntax(), offset)
|
||||
{
|
||||
|
|
|
@ -150,7 +150,7 @@ impl QualifyCandidate<'_> {
|
|||
import,
|
||||
trait_method_name,
|
||||
generics,
|
||||
match arg_list.clone() {
|
||||
match arg_list {
|
||||
Some(args) => make::arg_list(iter::once(receiver).chain(args)),
|
||||
None => make::arg_list(iter::once(receiver)),
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ impl DnfExpr {
|
|||
pub fn new(expr: CfgExpr) -> Self {
|
||||
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
|
||||
|
|
|
@ -147,7 +147,7 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()
|
|||
.filter_map(|(import_path, definition)| {
|
||||
render_resolution_with_import(
|
||||
RenderContext::new(ctx),
|
||||
ImportEdit { import_path: import_path.clone(), import_scope: import_scope.clone() },
|
||||
ImportEdit { import_path, import_scope: import_scope.clone() },
|
||||
&definition,
|
||||
)
|
||||
});
|
||||
|
|
|
@ -91,7 +91,7 @@ impl<'a> FunctionRender<'a> {
|
|||
.zip(params_ty)
|
||||
.flat_map(|(pat, param_ty)| {
|
||||
let pat = pat?;
|
||||
let name = pat.to_string();
|
||||
let name = pat;
|
||||
let arg = name.trim_start_matches("mut ").trim_start_matches('_');
|
||||
Some(self.add_arg(arg, param_ty.ty()))
|
||||
})
|
||||
|
|
|
@ -475,7 +475,7 @@ fn add_target_crate_root(
|
|||
Some(display_name),
|
||||
cfg_options,
|
||||
env,
|
||||
proc_macro.clone(),
|
||||
proc_macro,
|
||||
);
|
||||
|
||||
crate_id
|
||||
|
|
|
@ -658,7 +658,6 @@ impl GlobalState {
|
|||
log::trace!("updating notifications for {:?}", subscriptions);
|
||||
if self.config.publish_diagnostics {
|
||||
let snapshot = self.snapshot();
|
||||
let subscriptions = subscriptions.clone();
|
||||
self.task_pool.handle.spawn(move || {
|
||||
let diagnostics = subscriptions
|
||||
.into_iter()
|
||||
|
|
|
@ -55,7 +55,7 @@ impl ast::Attr {
|
|||
let key = self.simple_name()?;
|
||||
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))
|
||||
}
|
||||
|
|
|
@ -599,7 +599,7 @@ impl ast::IntNumber {
|
|||
text = &text[radix.prefix_len()..];
|
||||
|
||||
let buf;
|
||||
if text.contains("_") {
|
||||
if text.contains('_') {
|
||||
buf = text.replace('_', "");
|
||||
text = buf.as_str();
|
||||
};
|
||||
|
|
|
@ -134,7 +134,7 @@ r#####"
|
|||
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue