From 1ef55002c2db4ca68df31306290b019c7fbfb4fb Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 27 Mar 2021 21:51:00 +0100 Subject: Cleanup ide_db imports --- crates/ide_db/src/call_info/tests.rs | 3 ++- crates/ide_db/src/helpers/insert_use.rs | 3 ++- crates/ide_db/src/label.rs | 2 +- crates/ide_db/src/search.rs | 3 +-- crates/ide_db/src/source_change.rs | 2 ++ crates/ide_db/src/traits.rs | 3 +-- crates/ide_db/src/traits/tests.rs | 3 ++- crates/ide_db/src/ty_filter.rs | 6 ++++-- 8 files changed, 15 insertions(+), 10 deletions(-) diff --git a/crates/ide_db/src/call_info/tests.rs b/crates/ide_db/src/call_info/tests.rs index 75ab3eb6e..281a081a3 100644 --- a/crates/ide_db/src/call_info/tests.rs +++ b/crates/ide_db/src/call_info/tests.rs @@ -1,8 +1,9 @@ -use crate::RootDatabase; use base_db::{fixture::ChangeFixture, FilePosition}; use expect_test::{expect, Expect}; use test_utils::RangeOrOffset; +use crate::RootDatabase; + /// Creates analysis from a multi-file fixture, returns positions marked with $0. pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { let change_fixture = ChangeFixture::parse(ra_fixture); diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs index e681ced80..be3a22725 100644 --- a/crates/ide_db/src/helpers/insert_use.rs +++ b/crates/ide_db/src/helpers/insert_use.rs @@ -1,7 +1,6 @@ //! Handle syntactic aspects of inserting a new `use`. use std::{cmp::Ordering, iter::successors}; -use crate::RootDatabase; use hir::Semantics; use itertools::{EitherOrBoth, Itertools}; use syntax::{ @@ -14,6 +13,8 @@ use syntax::{ AstToken, InsertPosition, NodeOrToken, SyntaxElement, SyntaxNode, SyntaxToken, }; +use crate::RootDatabase; + pub use hir::PrefixKind; #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/crates/ide_db/src/label.rs b/crates/ide_db/src/label.rs index c0e89e72f..1f1e715c9 100644 --- a/crates/ide_db/src/label.rs +++ b/crates/ide_db/src/label.rs @@ -1,4 +1,4 @@ -//! See `Label` +//! See [`Label`] use std::fmt; /// A type to specify UI label, like an entry in the list of assists. Enforces diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index 3634b2b26..b55e3851e 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs @@ -12,9 +12,8 @@ use once_cell::unsync::Lazy; use rustc_hash::FxHashMap; use syntax::{ast, match_ast, AstNode, TextRange, TextSize}; -use crate::defs::NameClass; use crate::{ - defs::{Definition, NameRefClass}, + defs::{Definition, NameClass, NameRefClass}, RootDatabase, }; diff --git a/crates/ide_db/src/source_change.rs b/crates/ide_db/src/source_change.rs index b36455d49..846530f78 100644 --- a/crates/ide_db/src/source_change.rs +++ b/crates/ide_db/src/source_change.rs @@ -37,6 +37,8 @@ impl SourceChange { } } + /// Inserts a [`TextEdit`] for the given [`FileId`]. This properly handles merging existing + /// edits for a file if some already exist. pub fn insert_source_edit(&mut self, file_id: FileId, edit: TextEdit) { match self.source_file_edits.entry(file_id) { Entry::Occupied(mut entry) => { diff --git a/crates/ide_db/src/traits.rs b/crates/ide_db/src/traits.rs index 78a43f587..66ae81c73 100644 --- a/crates/ide_db/src/traits.rs +++ b/crates/ide_db/src/traits.rs @@ -61,7 +61,7 @@ pub fn get_missing_assoc_items( resolve_target_trait(sema, impl_def).map_or(vec![], |target_trait| { target_trait .items(sema.db) - .iter() + .into_iter() .filter(|i| match i { hir::AssocItem::Function(f) => { !impl_fns_consts.contains(&f.name(sema.db).to_string()) @@ -72,7 +72,6 @@ pub fn get_missing_assoc_items( .map(|n| !impl_fns_consts.contains(&n.to_string())) .unwrap_or_default(), }) - .cloned() .collect() }) } diff --git a/crates/ide_db/src/traits/tests.rs b/crates/ide_db/src/traits/tests.rs index 84bb25505..2a5482024 100644 --- a/crates/ide_db/src/traits/tests.rs +++ b/crates/ide_db/src/traits/tests.rs @@ -1,10 +1,11 @@ -use crate::RootDatabase; use base_db::{fixture::ChangeFixture, FilePosition}; use expect_test::{expect, Expect}; use hir::Semantics; use syntax::ast::{self, AstNode}; use test_utils::RangeOrOffset; +use crate::RootDatabase; + /// Creates analysis from a multi-file fixture, returns positions marked with $0. pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { let change_fixture = ChangeFixture::parse(ra_fixture); diff --git a/crates/ide_db/src/ty_filter.rs b/crates/ide_db/src/ty_filter.rs index f8406851b..988ecd060 100644 --- a/crates/ide_db/src/ty_filter.rs +++ b/crates/ide_db/src/ty_filter.rs @@ -2,11 +2,13 @@ //! Use case for structures in this module is, for example, situation when you need to process //! only certain `Enum`s. -use crate::RootDatabase; -use hir::{Adt, Semantics, Type}; use std::iter; + +use hir::{Adt, Semantics, Type}; use syntax::ast::{self, make}; +use crate::RootDatabase; + /// Enum types that implement `std::ops::Try` trait. #[derive(Clone, Copy)] pub enum TryEnum { -- cgit v1.2.3