Skip to content

Commit 7e285e1

Browse files
Run cargo fmt
1 parent 8318035 commit 7e285e1

35 files changed

+190
-45
lines changed

crates/hir-def/src/path.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ impl<'a> PathSegments<'a> {
188188
}
189189

190190
impl GenericArgs {
191-
pub(crate) fn from_ast(lower_ctx: &LowerCtx<'_>, node: ast::GenericArgList) -> Option<GenericArgs> {
191+
pub(crate) fn from_ast(
192+
lower_ctx: &LowerCtx<'_>,
193+
node: ast::GenericArgList,
194+
) -> Option<GenericArgs> {
192195
lower::lower_generic_args(lower_ctx, node)
193196
}
194197

crates/hir-ty/src/autoderef.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ impl Iterator for Autoderef<'_, '_> {
7070
}
7171
}
7272

73-
pub(crate) fn autoderef_step(table: &mut InferenceTable<'_>, ty: Ty) -> Option<(AutoderefKind, Ty)> {
73+
pub(crate) fn autoderef_step(
74+
table: &mut InferenceTable<'_>,
75+
ty: Ty,
76+
) -> Option<(AutoderefKind, Ty)> {
7477
if let Some(derefed) = builtin_deref(&ty) {
7578
Some((AutoderefKind::Builtin, table.resolve_ty_shallow(derefed)))
7679
} else {

crates/hir-ty/src/display.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,11 @@ fn write_bounds_like_dyn_trait(
952952
Ok(())
953953
}
954954

955-
fn fmt_trait_ref(tr: &TraitRef, f: &mut HirFormatter<'_>, use_as: bool) -> Result<(), HirDisplayError> {
955+
fn fmt_trait_ref(
956+
tr: &TraitRef,
957+
f: &mut HirFormatter<'_>,
958+
use_as: bool,
959+
) -> Result<(), HirDisplayError> {
956960
if f.should_truncate() {
957961
return write!(f, "{}", TYPE_HINT_TRUNCATION);
958962
}

crates/hir-ty/src/infer.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,12 @@ trait PatLike: Into<ExprOrPatId> + Copy {
140140
impl PatLike for ExprId {
141141
type BindingMode = ();
142142

143-
fn infer(this: &mut InferenceContext<'_>, id: Self, expected_ty: &Ty, _: Self::BindingMode) -> Ty {
143+
fn infer(
144+
this: &mut InferenceContext<'_>,
145+
id: Self,
146+
expected_ty: &Ty,
147+
_: Self::BindingMode,
148+
) -> Ty {
144149
this.infer_assignee_expr(id, expected_ty)
145150
}
146151
}

crates/hir/src/display.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,10 @@ impl HirDisplay for ConstParam {
289289
}
290290
}
291291

292-
fn write_generic_params(def: GenericDefId, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
292+
fn write_generic_params(
293+
def: GenericDefId,
294+
f: &mut HirFormatter<'_>,
295+
) -> Result<(), HirDisplayError> {
293296
let params = f.db.generic_params(def);
294297
if params.lifetimes.is_empty()
295298
&& params.type_or_consts.iter().all(|x| x.1.const_param().is_none())
@@ -381,8 +384,9 @@ fn write_where_clause(def: GenericDefId, f: &mut HirFormatter<'_>) -> Result<(),
381384
let prev_pred =
382385
if pred_idx == 0 { None } else { Some(&params.where_predicates[pred_idx - 1]) };
383386

384-
let new_predicate =
385-
|f: &mut HirFormatter<'_>| f.write_str(if pred_idx == 0 { "\n " } else { ",\n " });
387+
let new_predicate = |f: &mut HirFormatter<'_>| {
388+
f.write_str(if pred_idx == 0 { "\n " } else { ",\n " })
389+
};
386390

387391
match pred {
388392
WherePredicate::TypeBound { target, .. } if is_unnamed_type_target(target) => {}

crates/ide-assists/src/handlers/add_missing_impl_members.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ pub(crate) fn add_missing_impl_members(acc: &mut Assists, ctx: &AssistContext<'_
8585
// $0fn bar(&self) {}
8686
// }
8787
// ```
88-
pub(crate) fn add_missing_default_members(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
88+
pub(crate) fn add_missing_default_members(
89+
acc: &mut Assists,
90+
ctx: &AssistContext<'_>,
91+
) -> Option<()> {
8992
add_missing_impl_members_inner(
9093
acc,
9194
ctx,

crates/ide-assists/src/handlers/auto_import.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<
142142
Some(())
143143
}
144144

145-
pub(super) fn find_importable_node(ctx: &AssistContext<'_>) -> Option<(ImportAssets, SyntaxElement)> {
145+
pub(super) fn find_importable_node(
146+
ctx: &AssistContext<'_>,
147+
) -> Option<(ImportAssets, SyntaxElement)> {
146148
if let Some(path_under_caret) = ctx.find_node_at_offset_with_descend::<ast::Path>() {
147149
ImportAssets::for_exact_path(&path_under_caret, &ctx.sema)
148150
.zip(Some(path_under_caret.syntax().clone().into()))

crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
3232
// }
3333
// }
3434
// ```
35-
pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
35+
pub(crate) fn convert_iter_for_each_to_for(
36+
acc: &mut Assists,
37+
ctx: &AssistContext<'_>,
38+
) -> Option<()> {
3639
let method = ctx.find_node_at_offset::<ast::MethodCallExpr>()?;
3740

3841
let closure = match method.arg_list()?.args().next()? {
@@ -91,7 +94,10 @@ pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContex
9194
// });
9295
// }
9396
// ```
94-
pub(crate) fn convert_for_loop_with_for_each(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
97+
pub(crate) fn convert_for_loop_with_for_each(
98+
acc: &mut Assists,
99+
ctx: &AssistContext<'_>,
100+
) -> Option<()> {
95101
let for_loop = ctx.find_node_at_offset::<ast::ForExpr>()?;
96102
let iterable = for_loop.iterable()?;
97103
let pat = for_loop.pat()?;

crates/ide-assists/src/handlers/extract_function.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,11 @@ fn generic_parents(parent: &SyntaxNode) -> Vec<GenericParent> {
10421042
}
10431043

10441044
/// checks if relevant var is used with `&mut` access inside body
1045-
fn has_exclusive_usages(ctx: &AssistContext<'_>, usages: &LocalUsages, body: &FunctionBody) -> bool {
1045+
fn has_exclusive_usages(
1046+
ctx: &AssistContext<'_>,
1047+
usages: &LocalUsages,
1048+
body: &FunctionBody,
1049+
) -> bool {
10461050
usages
10471051
.iter()
10481052
.filter(|reference| body.contains_range(reference.range))

crates/ide-assists/src/handlers/generate_enum_projection_method.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ use crate::{
3636
// }
3737
// }
3838
// ```
39-
pub(crate) fn generate_enum_try_into_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
39+
pub(crate) fn generate_enum_try_into_method(
40+
acc: &mut Assists,
41+
ctx: &AssistContext<'_>,
42+
) -> Option<()> {
4043
generate_enum_projection_method(
4144
acc,
4245
ctx,

crates/ide-assists/src/handlers/generate_from_impl_for_enum.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ use crate::{utils::generate_trait_impl_text, AssistContext, AssistId, AssistKind
2020
// }
2121
// }
2222
// ```
23-
pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
23+
pub(crate) fn generate_from_impl_for_enum(
24+
acc: &mut Assists,
25+
ctx: &AssistContext<'_>,
26+
) -> Option<()> {
2427
let variant = ctx.find_node_at_offset::<ast::Variant>()?;
2528
let variant_name = variant.name()?;
2629
let enum_ = ast::Adt::Enum(variant.parent_enum());

crates/ide-assists/src/handlers/move_bounds.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
2020
// f(x)
2121
// }
2222
// ```
23-
pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
23+
pub(crate) fn move_bounds_to_where_clause(
24+
acc: &mut Assists,
25+
ctx: &AssistContext<'_>,
26+
) -> Option<()> {
2427
let type_param_list = ctx.find_node_at_offset::<ast::GenericParamList>()?;
2528

2629
let mut type_params = type_param_list.type_or_const_params();

crates/ide-assists/src/handlers/move_guard.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext<'_>)
9191
// }
9292
// }
9393
// ```
94-
pub(crate) fn move_arm_cond_to_match_guard(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
94+
pub(crate) fn move_arm_cond_to_match_guard(
95+
acc: &mut Assists,
96+
ctx: &AssistContext<'_>,
97+
) -> Option<()> {
9598
let match_arm: MatchArm = ctx.find_node_at_offset::<MatchArm>()?;
9699
let match_pat = match_arm.pat()?;
97100
let arm_body = match_arm.expr()?;

crates/ide-assists/src/handlers/reorder_fields.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ fn replace<T: AstNode + PartialEq>(
8686
});
8787
}
8888

89-
fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext<'_>) -> Option<FxHashMap<String, usize>> {
89+
fn compute_fields_ranks(
90+
path: &ast::Path,
91+
ctx: &AssistContext<'_>,
92+
) -> Option<FxHashMap<String, usize>> {
9093
let strukt = match ctx.sema.resolve_path(path) {
9194
Some(hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Struct(it)))) => it,
9295
_ => return None,

crates/ide-assists/src/handlers/reorder_impl_items.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ pub(crate) fn reorder_impl_items(acc: &mut Assists, ctx: &AssistContext<'_>) ->
9393
)
9494
}
9595

96-
fn compute_item_ranks(path: &ast::Path, ctx: &AssistContext<'_>) -> Option<FxHashMap<String, usize>> {
96+
fn compute_item_ranks(
97+
path: &ast::Path,
98+
ctx: &AssistContext<'_>,
99+
) -> Option<FxHashMap<String, usize>> {
97100
let td = trait_definition(path, &ctx.sema)?;
98101

99102
Some(

crates/ide-assists/src/handlers/replace_try_expr_with_match.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ use crate::assist_context::{AssistContext, Assists};
3434
// };
3535
// }
3636
// ```
37-
pub(crate) fn replace_try_expr_with_match(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
37+
pub(crate) fn replace_try_expr_with_match(
38+
acc: &mut Assists,
39+
ctx: &AssistContext<'_>,
40+
) -> Option<()> {
3841
let qm_kw = ctx.find_token_syntax_at_offset(T![?])?;
3942
let qm_kw_parent = qm_kw.parent().and_then(ast::TryExpr::cast)?;
4043

crates/ide-completion/src/completions.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ impl Completions {
144144
item.add_to(self);
145145
}
146146

147-
pub(crate) fn add_keyword_snippet(&mut self, ctx: &CompletionContext<'_>, kw: &str, snippet: &str) {
147+
pub(crate) fn add_keyword_snippet(
148+
&mut self,
149+
ctx: &CompletionContext<'_>,
150+
kw: &str,
151+
snippet: &str,
152+
) {
148153
let mut item = CompletionItem::new(CompletionItemKind::Keyword, ctx.source_range(), kw);
149154

150155
match ctx.config.snippet_cap {
@@ -348,7 +353,11 @@ impl Completions {
348353
));
349354
}
350355

351-
pub(crate) fn add_type_alias(&mut self, ctx: &CompletionContext<'_>, type_alias: hir::TypeAlias) {
356+
pub(crate) fn add_type_alias(
357+
&mut self,
358+
ctx: &CompletionContext<'_>,
359+
type_alias: hir::TypeAlias,
360+
) {
352361
let is_private_editable = match ctx.is_visible(&type_alias) {
353362
Visible::Yes => false,
354363
Visible::Editable => true,
@@ -661,7 +670,11 @@ pub(super) fn complete_name_ref(
661670
}
662671
}
663672

664-
fn complete_patterns(acc: &mut Completions, ctx: &CompletionContext<'_>, pattern_ctx: &PatternContext) {
673+
fn complete_patterns(
674+
acc: &mut Completions,
675+
ctx: &CompletionContext<'_>,
676+
pattern_ctx: &PatternContext,
677+
) {
665678
flyimport::import_on_the_fly_pat(acc, ctx, pattern_ctx);
666679
fn_param::complete_fn_param(acc, ctx, pattern_ctx);
667680
pattern::complete_pattern(acc, ctx, pattern_ctx);

crates/ide-completion/src/completions/attribute/repr.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ use syntax::ast;
55

66
use crate::{context::CompletionContext, item::CompletionItem, Completions};
77

8-
pub(super) fn complete_repr(acc: &mut Completions, ctx: &CompletionContext<'_>, input: ast::TokenTree) {
8+
pub(super) fn complete_repr(
9+
acc: &mut Completions,
10+
ctx: &CompletionContext<'_>,
11+
input: ast::TokenTree,
12+
) {
913
if let Some(existing_reprs) = super::parse_comma_sep_expr(input) {
1014
for &ReprCompletion { label, snippet, lookup, collides } in REPR_COMPLETIONS {
1115
let repr_already_annotated = existing_reprs

crates/ide-completion/src/completions/dot.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ use crate::{
88
};
99

1010
/// Complete dot accesses, i.e. fields or methods.
11-
pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext<'_>, dot_access: &DotAccess) {
11+
pub(crate) fn complete_dot(
12+
acc: &mut Completions,
13+
ctx: &CompletionContext<'_>,
14+
dot_access: &DotAccess,
15+
) {
1216
let receiver_ty = match dot_access {
1317
DotAccess { receiver_ty: Some(receiver_ty), .. } => &receiver_ty.original,
1418
_ => return,

crates/ide-completion/src/completions/field.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ pub(crate) fn complete_field_list_tuple_variant(
3030
}
3131
}
3232

33-
pub(crate) fn complete_field_list_record_variant(acc: &mut Completions, ctx: &CompletionContext<'_>) {
33+
pub(crate) fn complete_field_list_record_variant(
34+
acc: &mut Completions,
35+
ctx: &CompletionContext<'_>,
36+
) {
3437
if ctx.qualifier_ctx.vis_node.is_none() {
3538
let mut add_keyword = |kw, snippet| acc.add_keyword_snippet(ctx, kw, snippet);
3639
add_keyword("pub(crate)", "pub(crate)");

crates/ide-completion/src/render.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ pub(crate) fn render_tuple_field(
158158
item.build()
159159
}
160160

161-
pub(crate) fn render_type_inference(ty_string: String, ctx: &CompletionContext<'_>) -> CompletionItem {
161+
pub(crate) fn render_type_inference(
162+
ty_string: String,
163+
ctx: &CompletionContext<'_>,
164+
) -> CompletionItem {
162165
let mut builder =
163166
CompletionItem::new(CompletionItemKind::InferredType, ctx.source_range(), ty_string);
164167
builder.set_relevance(CompletionRelevance { is_definite: true, ..Default::default() });

crates/ide-db/src/defs.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ pub enum IdentClass {
130130
}
131131

132132
impl IdentClass {
133-
pub fn classify_node(sema: &Semantics<'_, RootDatabase>, node: &SyntaxNode) -> Option<IdentClass> {
133+
pub fn classify_node(
134+
sema: &Semantics<'_, RootDatabase>,
135+
node: &SyntaxNode,
136+
) -> Option<IdentClass> {
134137
match_ast! {
135138
match node {
136139
ast::Name(name) => NameClass::classify(sema, &name).map(IdentClass::NameClass),
@@ -238,7 +241,10 @@ impl NameClass {
238241
};
239242
return Some(NameClass::Definition(definition));
240243

241-
fn classify_item(sema: &Semantics<'_, RootDatabase>, item: ast::Item) -> Option<Definition> {
244+
fn classify_item(
245+
sema: &Semantics<'_, RootDatabase>,
246+
item: ast::Item,
247+
) -> Option<Definition> {
242248
let definition = match item {
243249
ast::Item::MacroRules(it) => {
244250
Definition::Macro(sema.to_def(&ast::Macro::MacroRules(it))?)

crates/ide-db/src/imports/import_assets.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ impl ImportAssets {
218218
}
219219

220220
/// This may return non-absolute paths if a part of the returned path is already imported into scope.
221-
pub fn search_for_relative_paths(&self, sema: &Semantics<'_, RootDatabase>) -> Vec<LocatedImport> {
221+
pub fn search_for_relative_paths(
222+
&self,
223+
sema: &Semantics<'_, RootDatabase>,
224+
) -> Vec<LocatedImport> {
222225
let _p = profile::span("import_assets::search_for_relative_paths");
223226
self.search_for(sema, None)
224227
}

crates/ide-db/src/rename.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ macro_rules! _bail {
6666
pub use _bail as bail;
6767

6868
impl Definition {
69-
pub fn rename(&self, sema: &Semantics<'_, RootDatabase>, new_name: &str) -> Result<SourceChange> {
69+
pub fn rename(
70+
&self,
71+
sema: &Semantics<'_, RootDatabase>,
72+
new_name: &str,
73+
) -> Result<SourceChange> {
7074
match *self {
7175
Definition::Module(module) => rename_mod(sema, module, new_name),
7276
Definition::BuiltinType(_) => {

crates/ide-diagnostics/src/handlers/unlinked_file.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ use crate::{fix, Assist, Diagnostic, DiagnosticsContext, Severity};
1818
//
1919
// This diagnostic is shown for files that are not included in any crate, or files that are part of
2020
// crates rust-analyzer failed to discover. The file will not have IDE features available.
21-
pub(crate) fn unlinked_file(ctx: &DiagnosticsContext<'_>, acc: &mut Vec<Diagnostic>, file_id: FileId) {
21+
pub(crate) fn unlinked_file(
22+
ctx: &DiagnosticsContext<'_>,
23+
acc: &mut Vec<Diagnostic>,
24+
file_id: FileId,
25+
) {
2226
// Limit diagnostic to the first few characters in the file. This matches how VS Code
2327
// renders it with the full span, but on other editors, and is less invasive.
2428
let range = ctx.sema.db.parse(file_id).syntax_node().text_range();

crates/ide-ssr/src/from_comment.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ use crate::MatchFinder;
1515
/// Attempts to build an SSR MatchFinder from a comment at the given file
1616
/// range. If successful, returns the MatchFinder and a TextRange covering
1717
/// comment.
18-
pub fn ssr_from_comment(db: &RootDatabase, frange: FileRange) -> Option<(MatchFinder<'_>, TextRange)> {
18+
pub fn ssr_from_comment(
19+
db: &RootDatabase,
20+
frange: FileRange,
21+
) -> Option<(MatchFinder<'_>, TextRange)> {
1922
let comment = {
2023
let file = db.parse(frange.file_id);
2124
file.tree().syntax().token_at_offset(frange.range.start()).find_map(ast::Comment::cast)

crates/ide-ssr/src/nester.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ impl MatchCollector {
5454
}
5555

5656
/// Attempts to add `m` as a sub-match of `existing`.
57-
fn try_add_sub_match(m: Match, existing: &mut Match, sema: &hir::Semantics<'_, ide_db::RootDatabase>) {
57+
fn try_add_sub_match(
58+
m: Match,
59+
existing: &mut Match,
60+
sema: &hir::Semantics<'_, ide_db::RootDatabase>,
61+
) {
5862
for p in existing.placeholder_values.values_mut() {
5963
// Note, no need to check if p.range.file is equal to m.range.file, since we
6064
// already know we're within `existing`.

0 commit comments

Comments
 (0)