clippy::redudant_borrow

This commit is contained in:
Maan2003
2021-06-13 09:24:16 +05:30
parent d6737e55fb
commit c9b4ac5be4
114 changed files with 285 additions and 285 deletions

View File

@@ -123,7 +123,7 @@ impl CargoTargetSpec {
let res = CargoTargetSpec {
workspace_root: cargo_ws.workspace_root().to_path_buf(),
cargo_toml: package_data.manifest.clone(),
package: cargo_ws.package_flag(&package_data),
package: cargo_ws.package_flag(package_data),
target: target_data.name.clone(),
target_kind: target_data.kind,
};

View File

@@ -126,7 +126,7 @@ fn load_crate_graph(
}
}
}
let source_roots = source_root_config.partition(&vfs);
let source_roots = source_root_config.partition(vfs);
analysis_change.set_roots(source_roots);
analysis_change.set_crate_graph(crate_graph);

View File

@@ -47,7 +47,7 @@ impl DiagnosticCollection {
) {
let diagnostics = self.check.entry(file_id).or_default();
for existing_diagnostic in diagnostics.iter() {
if are_diagnostics_equal(&existing_diagnostic, &diagnostic) {
if are_diagnostics_equal(existing_diagnostic, &diagnostic) {
return;
}
}

View File

@@ -224,7 +224,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
let mut message = rd.message.clone();
for child in &rd.children {
let child = map_rust_child_diagnostic(config, workspace_root, &child);
let child = map_rust_child_diagnostic(config, workspace_root, child);
match child {
MappedRustChildDiagnostic::SubDiagnostic(sub) => {
subdiagnostics.push(sub);
@@ -268,7 +268,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
primary_spans
.iter()
.flat_map(|primary_span| {
let primary_location = primary_location(config, workspace_root, &primary_span);
let primary_location = primary_location(config, workspace_root, primary_span);
let mut message = message.clone();
if needs_primary_span_label {
@@ -298,7 +298,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
// generated that code.
let is_in_macro_call = i != 0;
let secondary_location = location(config, workspace_root, &span);
let secondary_location = location(config, workspace_root, span);
if secondary_location == primary_location {
continue;
}

View File

@@ -194,7 +194,7 @@ impl GlobalState {
change.change_file(file.file_id, text);
}
if has_fs_changes {
let roots = self.source_root_config.partition(&vfs);
let roots = self.source_root_config.partition(vfs);
change.set_roots(roots);
}
change
@@ -291,7 +291,7 @@ impl GlobalStateSnapshot {
}
pub(crate) fn url_file_version(&self, url: &Url) -> Option<i32> {
let path = from_proto::vfs_path(&url).ok()?;
let path = from_proto::vfs_path(url).ok()?;
Some(self.mem_docs.get(&path)?.version)
}
@@ -300,7 +300,7 @@ impl GlobalStateSnapshot {
base.pop();
let path = base.join(&path.path).unwrap();
let path = path.as_path().unwrap();
url_from_abs_path(&path)
url_from_abs_path(path)
}
pub(crate) fn cargo_target_for_crate_root(
@@ -312,7 +312,7 @@ impl GlobalStateSnapshot {
let path = path.as_path()?;
self.workspaces.iter().find_map(|ws| match ws {
ProjectWorkspace::Cargo { cargo, .. } => {
cargo.target_by_root(&path).map(|it| (cargo, it))
cargo.target_by_root(path).map(|it| (cargo, it))
}
ProjectWorkspace::Json { .. } => None,
ProjectWorkspace::DetachedFiles { .. } => None,
@@ -323,7 +323,7 @@ impl GlobalStateSnapshot {
pub(crate) fn file_id_to_url(vfs: &vfs::Vfs, id: FileId) -> Url {
let path = vfs.file_path(id);
let path = path.as_path().unwrap();
url_from_abs_path(&path)
url_from_abs_path(path)
}
pub(crate) fn url_to_file_id(vfs: &vfs::Vfs, url: &Url) -> Result<FileId> {

View File

@@ -1396,7 +1396,7 @@ pub(crate) fn handle_semantic_tokens_full_delta(
if let Some(prev_id) = &cached_tokens.result_id {
if *prev_id == params.previous_result_id {
let delta = to_proto::semantic_token_delta(&cached_tokens, &semantic_tokens);
let delta = to_proto::semantic_token_delta(cached_tokens, &semantic_tokens);
*cached_tokens = semantic_tokens;
return Ok(Some(delta.into()));
}
@@ -1540,7 +1540,7 @@ fn runnable_action_links(
snap: &GlobalStateSnapshot,
runnable: Runnable,
) -> Option<lsp_ext::CommandLinkGroup> {
let cargo_spec = CargoTargetSpec::for_file(&snap, runnable.nav.file_id).ok()?;
let cargo_spec = CargoTargetSpec::for_file(snap, runnable.nav.file_id).ok()?;
let hover_config = snap.config.hover();
if !hover_config.runnable() || should_skip_target(&runnable, cargo_spec.as_ref()) {
return None;
@@ -1624,7 +1624,7 @@ fn run_rustfmt(
text_document: TextDocumentIdentifier,
range: Option<lsp_types::Range>,
) -> Result<Option<Vec<lsp_types::TextEdit>>> {
let file_id = from_proto::file_id(&snap, &text_document.uri)?;
let file_id = from_proto::file_id(snap, &text_document.uri)?;
let file = snap.analysis.file_text(file_id)?;
let crate_ids = snap.analysis.crate_for(file_id)?;
@@ -1671,7 +1671,7 @@ fn run_rustfmt(
.into());
}
let frange = from_proto::file_range(&snap, text_document, range)?;
let frange = from_proto::file_range(snap, text_document, range)?;
let start_line = line_index.index.line_col(frange.range.start()).line;
let end_line = line_index.index.line_col(frange.range.end()).line;

View File

@@ -124,7 +124,7 @@ pub(crate) fn apply_document_changes(
match change.range {
Some(range) => {
if !index_valid.covers(range.end.line) {
line_index.index = Arc::new(ide::LineIndex::new(&old_text));
line_index.index = Arc::new(ide::LineIndex::new(old_text));
}
index_valid = IndexValid::UpToLineExclusive(range.start.line);
let range = from_proto::text_range(&line_index, range);

View File

@@ -740,7 +740,7 @@ impl GlobalState {
let subscriptions = self
.mem_docs
.keys()
.map(|path| self.vfs.read().0.file_id(&path).unwrap())
.map(|path| self.vfs.read().0.file_id(path).unwrap())
.collect::<Vec<_>>();
log::trace!("updating notifications for {:?}", subscriptions);

View File

@@ -405,7 +405,7 @@ pub(crate) fn semantic_tokens(
text_range =
TextRange::new(text_range.start(), text_range.end() - TextSize::of('\n'));
}
let range = range(&line_index, text_range);
let range = range(line_index, text_range);
builder.push(range, token_index, modifier_bitset);
}
}
@@ -781,7 +781,7 @@ pub(crate) fn snippet_workspace_edit(
document_changes.extend_from_slice(&ops);
}
for (file_id, edit) in source_change.source_file_edits {
let edit = snippet_text_document_edit(&snap, source_change.is_snippet, file_id, edit)?;
let edit = snippet_text_document_edit(snap, source_change.is_snippet, file_id, edit)?;
document_changes.push(lsp_ext::SnippetDocumentChangeOperation::Edit(edit));
}
let mut workspace_edit = lsp_ext::SnippetWorkspaceEdit {
@@ -957,7 +957,7 @@ pub(crate) fn code_lens(
let annotation_range = range(&line_index, annotation.range);
let action = run.action();
let r = runnable(&snap, run)?;
let r = runnable(snap, run)?;
let command = if debug {
command::debug_single(&r)
@@ -1236,12 +1236,12 @@ fn main() {
assert_eq!(folds.len(), 4);
let line_index = LineIndex {
index: Arc::new(ide::LineIndex::new(&text)),
index: Arc::new(ide::LineIndex::new(text)),
endings: LineEndings::Unix,
encoding: OffsetEncoding::Utf16,
};
let converted: Vec<lsp_types::FoldingRange> =
folds.into_iter().map(|it| folding_range(&text, &line_index, true, it)).collect();
folds.into_iter().map(|it| folding_range(text, &line_index, true, it)).collect();
let expected_lines = [(0, 2), (4, 10), (5, 6), (7, 9)];
assert_eq!(converted.len(), expected_lines.len());