mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-02 04:48:13 +00:00
cargo fmt
This commit is contained in:
parent
87f837cec7
commit
7535bb4661
571 changed files with 2210 additions and 2458 deletions
|
|
@ -1,12 +1,13 @@
|
|||
//! Renderer for function calls.
|
||||
|
||||
use hir::{db::HirDatabase, AsAssocItem, HirDisplay};
|
||||
use hir::{AsAssocItem, HirDisplay, db::HirDatabase};
|
||||
use ide_db::{SnippetCap, SymbolKind};
|
||||
use itertools::Itertools;
|
||||
use stdx::{format_to, to_lower_snake_case};
|
||||
use syntax::{format_smolstr, AstNode, SmolStr, ToSmolStr};
|
||||
use syntax::{AstNode, SmolStr, ToSmolStr, format_smolstr};
|
||||
|
||||
use crate::{
|
||||
CallableSnippets,
|
||||
context::{
|
||||
CompleteSemicolon, CompletionContext, DotAccess, DotAccessKind, PathCompletionCtx, PathKind,
|
||||
},
|
||||
|
|
@ -15,9 +16,8 @@ use crate::{
|
|||
CompletionRelevanceReturnType, CompletionRelevanceTraitInfo,
|
||||
},
|
||||
render::{
|
||||
compute_exact_name_match, compute_ref_match, compute_type_match, match_types, RenderContext,
|
||||
RenderContext, compute_exact_name_match, compute_ref_match, compute_type_match, match_types,
|
||||
},
|
||||
CallableSnippets,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -293,11 +293,7 @@ fn ref_of_param(ctx: &CompletionContext<'_>, arg: &str, ty: &hir::Type) -> &'sta
|
|||
for (name, local) in ctx.locals.iter().sorted_by_key(|&(k, _)| k.clone()) {
|
||||
if name.as_str() == arg {
|
||||
return if local.ty(ctx.db) == derefed_ty {
|
||||
if ty.is_mutable_reference() {
|
||||
"&mut "
|
||||
} else {
|
||||
"&"
|
||||
}
|
||||
if ty.is_mutable_reference() { "&mut " } else { "&" }
|
||||
} else {
|
||||
""
|
||||
};
|
||||
|
|
@ -398,8 +394,8 @@ fn params(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
tests::{check_edit, check_edit_with_config, TEST_CONFIG},
|
||||
CallableSnippets, CompletionConfig,
|
||||
tests::{TEST_CONFIG, check_edit, check_edit_with_config},
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -1,23 +1,22 @@
|
|||
//! Renderer for `enum` variants.
|
||||
|
||||
use hir::{db::HirDatabase, StructKind};
|
||||
use hir::{StructKind, db::HirDatabase};
|
||||
use ide_db::{
|
||||
documentation::{Documentation, HasDocs},
|
||||
SymbolKind,
|
||||
documentation::{Documentation, HasDocs},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
CompletionItemKind, CompletionRelevance, CompletionRelevanceReturnType,
|
||||
context::{CompletionContext, PathCompletionCtx, PathKind},
|
||||
item::{Builder, CompletionItem, CompletionRelevanceFn},
|
||||
render::{
|
||||
compute_type_match,
|
||||
RenderContext, compute_type_match,
|
||||
variant::{
|
||||
format_literal_label, format_literal_lookup, render_record_lit, render_tuple_lit,
|
||||
visible_fields, RenderedLiteral,
|
||||
RenderedLiteral, format_literal_label, format_literal_lookup, render_record_lit,
|
||||
render_tuple_lit, visible_fields,
|
||||
},
|
||||
RenderContext,
|
||||
},
|
||||
CompletionItemKind, CompletionRelevance, CompletionRelevanceReturnType,
|
||||
};
|
||||
|
||||
pub(crate) fn render_variant_lit(
|
||||
|
|
@ -164,11 +163,7 @@ impl Variant {
|
|||
Variant::Struct(it) => visible_fields(ctx, &fields, it)?,
|
||||
Variant::EnumVariant(it) => visible_fields(ctx, &fields, it)?,
|
||||
};
|
||||
if !fields_omitted {
|
||||
Some(visible_fields)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if !fields_omitted { Some(visible_fields) } else { None }
|
||||
}
|
||||
|
||||
fn kind(self, db: &dyn HirDatabase) -> StructKind {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
//! Renderer for macro invocations.
|
||||
|
||||
use hir::HirDisplay;
|
||||
use ide_db::{documentation::Documentation, SymbolKind};
|
||||
use syntax::{format_smolstr, SmolStr, ToSmolStr};
|
||||
use ide_db::{SymbolKind, documentation::Documentation};
|
||||
use syntax::{SmolStr, ToSmolStr, format_smolstr};
|
||||
|
||||
use crate::{
|
||||
context::{PathCompletionCtx, PathKind, PatternContext},
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
//! Renderer for patterns.
|
||||
|
||||
use hir::{db::HirDatabase, Name, StructKind};
|
||||
use ide_db::{documentation::HasDocs, SnippetCap};
|
||||
use hir::{Name, StructKind, db::HirDatabase};
|
||||
use ide_db::{SnippetCap, documentation::HasDocs};
|
||||
use itertools::Itertools;
|
||||
use syntax::{Edition, SmolStr, ToSmolStr};
|
||||
|
||||
use crate::{
|
||||
CompletionItem, CompletionItemKind,
|
||||
context::{ParamContext, ParamKind, PathCompletionCtx, PatternContext},
|
||||
render::{
|
||||
variant::{format_literal_label, format_literal_lookup, visible_fields},
|
||||
RenderContext,
|
||||
variant::{format_literal_label, format_literal_lookup, visible_fields},
|
||||
},
|
||||
CompletionItem, CompletionItemKind,
|
||||
};
|
||||
|
||||
pub(crate) fn render_struct_pat(
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ use itertools::Itertools;
|
|||
use syntax::ToSmolStr;
|
||||
|
||||
use crate::{
|
||||
render::{
|
||||
variant::{format_literal_label, format_literal_lookup, visible_fields},
|
||||
RenderContext,
|
||||
},
|
||||
CompletionItem, CompletionItemKind,
|
||||
render::{
|
||||
RenderContext,
|
||||
variant::{format_literal_label, format_literal_lookup, visible_fields},
|
||||
},
|
||||
};
|
||||
|
||||
pub(crate) fn render_union_literal(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! Code common to structs, unions, and enum variants.
|
||||
|
||||
use crate::context::CompletionContext;
|
||||
use hir::{sym, HasAttrs, HasCrate, HasVisibility, HirDisplay, StructKind};
|
||||
use hir::{HasAttrs, HasCrate, HasVisibility, HirDisplay, StructKind, sym};
|
||||
use ide_db::SnippetCap;
|
||||
use itertools::Itertools;
|
||||
use syntax::SmolStr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue