Skip to content

Commit 3aaf46a

Browse files
committed
Formatted changes.
1 parent d7e36c3 commit 3aaf46a

File tree

3 files changed

+23
-29
lines changed

3 files changed

+23
-29
lines changed

crates/ra_assists/src/handlers/add_missing_impl_members.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use ra_syntax::{
66

77
use crate::{
88
ast_transform::{self, AstTransform, QualifyPaths, SubstituteTypeParams},
9-
Assist, AssistCtx, AssistId,
109
utils::{get_missing_impl_items, resolve_target_trait},
10+
Assist, AssistCtx, AssistId,
1111
};
1212

1313
#[derive(PartialEq)]
@@ -129,7 +129,7 @@ fn add_missing_impl_members_inner(
129129
ast::ImplItem::FnDef(def) => match mode {
130130
AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(),
131131
AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(),
132-
}
132+
},
133133
_ => mode == AddMissingImplMembersMode::NoDefaultMethods,
134134
})
135135
.collect::<Vec<_>>();

crates/ra_assists/src/utils.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ use hir::db::HirDatabase;
99

1010
use rustc_hash::FxHashSet;
1111

12-
/// Generate a collection of associated items that are missing from a
12+
/// Generate a collection of associated items that are missing from a
1313
/// `impl Trait for` block.
1414
pub fn get_missing_impl_items(
1515
db: &impl HirDatabase,
1616
analyzer: &hir::SourceAnalyzer,
1717
impl_block: &ast::ImplBlock,
1818
) -> Vec<hir::AssocItem> {
19-
2019
// Names must be unique between constants and functions. However, type aliases
2120
// may share the same name as a function or constant.
2221
let mut impl_fns_consts = FxHashSet::default();
@@ -53,9 +52,10 @@ pub fn get_missing_impl_items(
5352
.filter(|i| match i {
5453
hir::AssocItem::Function(f) => !impl_fns_consts.contains(&f.name(db).to_string()),
5554
hir::AssocItem::TypeAlias(t) => !impl_type.contains(&t.name(db).to_string()),
56-
hir::AssocItem::Const(c) => {
57-
c.name(db).map(|n| !impl_fns_consts.contains(&n.to_string())).unwrap_or_default()
58-
}
55+
hir::AssocItem::Const(c) => c
56+
.name(db)
57+
.map(|n| !impl_fns_consts.contains(&n.to_string()))
58+
.unwrap_or_default(),
5959
})
6060
.map(|i| i.clone())
6161
.collect()

crates/ra_ide/src/completion/complete_trait_impl.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,55 @@ use crate::completion::{
22
CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions,
33
};
44

5-
use ra_syntax::{ast::{self, edit}, AstNode, SyntaxKind, TextRange};
65
use hir::{self, Docs, HasSource};
6+
use ra_syntax::{
7+
ast::{self, edit},
8+
AstNode, SyntaxKind, TextRange,
9+
};
710

811
use ra_assists::utils::get_missing_impl_items;
912

1013
/// Analyzes the specified `CompletionContext` and provides magic completions
1114
/// if the context falls within a `impl Trait for` block.
12-
///
15+
///
1316
/// # Completion Activation
14-
/// The completion will activate when a user begins to type a function
17+
/// The completion will activate when a user begins to type a function
1518
/// definition, an associated type, or an associated constant.
16-
///
19+
///
1720
/// ### Functions
1821
/// ```ignore
1922
/// trait SomeTrait {
2023
/// fn foo(&self);
2124
/// }
22-
///
25+
///
2326
/// impl SomeTrait for () {
2427
/// fn <|>
2528
/// }
2629
/// ```
27-
///
30+
///
2831
/// ### Associated Types
2932
/// ```ignore
3033
/// trait SomeTrait {
3134
/// type SomeType;
3235
/// }
33-
///
36+
///
3437
/// impl SomeTrait for () {
3538
/// type <|>
3639
/// }
3740
/// ```
38-
///
41+
///
3942
/// ### Associated Constants
4043
/// ```ignore
4144
/// trait SomeTrait {
4245
/// const SOME_CONST: u16;
4346
/// }
44-
///
47+
///
4548
/// impl SomeTrait for () {
4649
/// const <|>
4750
/// }
4851
/// ```
4952
pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext) {
50-
51-
// it is possible to have a parent `fn` and `impl` block. Ignore completion
53+
// it is possible to have a parent `fn` and `impl` block. Ignore completion
5254
// attempts from within a `fn` block.
5355
if ctx.function_syntax.is_some() {
5456
return;
@@ -111,11 +113,7 @@ fn add_type_alias_impl(
111113
.add_to(acc);
112114
}
113115

114-
fn add_const_impl(
115-
acc: &mut Completions,
116-
ctx: &CompletionContext,
117-
const_: &hir::Const,
118-
) {
116+
fn add_const_impl(acc: &mut Completions, ctx: &CompletionContext, const_: &hir::Const) {
119117
let snippet = make_const_compl_syntax(&const_.source(ctx.db).value);
120118

121119
CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone())
@@ -131,12 +129,8 @@ fn make_const_compl_syntax(const_: &ast::ConstDef) -> String {
131129
let const_start = const_.syntax().text_range().start();
132130
let const_end = const_.syntax().text_range().end();
133131

134-
let start = const_
135-
.syntax()
136-
.first_child_or_token()
137-
.map_or(
138-
const_start,
139-
|f| f.text_range().start());
132+
let start =
133+
const_.syntax().first_child_or_token().map_or(const_start, |f| f.text_range().start());
140134

141135
let end = const_
142136
.syntax()

0 commit comments

Comments
 (0)