From 5ac6804bb3a07b959e8c2c3534255a8d6bb4948c Mon Sep 17 00:00:00 2001 From: Maan2003 Date: Sun, 13 Jun 2021 09:48:15 +0530 Subject: cargo fmt --- crates/hir_def/src/lib.rs | 51 ++++++++++------------ crates/hir_expand/src/eager.rs | 11 +++-- crates/hir_ty/src/chalk_db.rs | 3 +- crates/hir_ty/src/infer/expr.rs | 8 +--- crates/ide/src/syntax_highlighting/highlight.rs | 8 ++-- crates/ide_assists/src/assist_context.rs | 3 +- crates/ide_db/src/search.rs | 4 +- crates/proc_macro_api/src/process.rs | 4 +- crates/proc_macro_srv/src/proc_macro/diagnostic.rs | 7 +-- 9 files changed, 38 insertions(+), 61 deletions(-) (limited to 'crates') diff --git a/crates/hir_def/src/lib.rs b/crates/hir_def/src/lib.rs index 3e7d496d5..303083c6d 100644 --- a/crates/hir_def/src/lib.rs +++ b/crates/hir_def/src/lib.rs @@ -731,12 +731,11 @@ fn macro_call_as_call_id( ) .map(MacroCallId::from) } else { - Ok(def - .as_lazy_macro( - db.upcast(), - krate, - MacroCallKind::FnLike { ast_id: call.ast_id, fragment }, - )) + Ok(def.as_lazy_macro( + db.upcast(), + krate, + MacroCallKind::FnLike { ast_id: call.ast_id, fragment }, + )) }; Ok(res) } @@ -755,16 +754,15 @@ fn derive_macro_as_call_id( .segments() .last() .ok_or_else(|| UnresolvedMacro { path: item_attr.path.clone() })?; - let res = def - .as_lazy_macro( - db.upcast(), - krate, - MacroCallKind::Derive { - ast_id: item_attr.ast_id, - derive_name: last_segment.to_string(), - derive_attr_index: derive_attr.ast_index, - }, - ); + let res = def.as_lazy_macro( + db.upcast(), + krate, + MacroCallKind::Derive { + ast_id: item_attr.ast_id, + derive_name: last_segment.to_string(), + derive_attr_index: derive_attr.ast_index, + }, + ); Ok(res) } @@ -792,16 +790,15 @@ fn attr_macro_as_call_id( // The parentheses are always disposed here. arg.delimiter = None; - let res = def - .as_lazy_macro( - db.upcast(), - krate, - MacroCallKind::Attr { - ast_id: item_attr.ast_id, - attr_name: last_segment.to_string(), - attr_args: arg, - invoc_attr_index: macro_attr.id.ast_index, - }, - ); + let res = def.as_lazy_macro( + db.upcast(), + krate, + MacroCallKind::Attr { + ast_id: item_attr.ast_id, + attr_name: last_segment.to_string(), + attr_args: arg, + invoc_attr_index: macro_attr.id.ast_index, + }, + ); Ok(res) } diff --git a/crates/hir_expand/src/eager.rs b/crates/hir_expand/src/eager.rs index 07799ed2f..ddafaddf7 100644 --- a/crates/hir_expand/src/eager.rs +++ b/crates/hir_expand/src/eager.rs @@ -177,12 +177,11 @@ fn lazy_expand( let ast_id = db.ast_id_map(macro_call.file_id).ast_id(¯o_call.value); let fragment = crate::to_fragment_kind(¯o_call.value); - let id: MacroCallId = def - .as_lazy_macro( - db, - krate, - MacroCallKind::FnLike { ast_id: macro_call.with_value(ast_id), fragment }, - ); + let id: MacroCallId = def.as_lazy_macro( + db, + krate, + MacroCallKind::FnLike { ast_id: macro_call.with_value(ast_id), fragment }, + ); let err = db.macro_expand_error(id); let value = db.parse_or_expand(id.as_file()).map(|node| InFile::new(id.as_file(), node)); diff --git a/crates/hir_ty/src/chalk_db.rs b/crates/hir_ty/src/chalk_db.rs index 1dab19000..34c3f6bd9 100644 --- a/crates/hir_ty/src/chalk_db.rs +++ b/crates/hir_ty/src/chalk_db.rs @@ -430,8 +430,7 @@ pub(crate) fn trait_datum_query( fundamental: false, }; let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars); - let associated_ty_ids = - trait_data.associated_types().map(to_assoc_type_id).collect(); + let associated_ty_ids = trait_data.associated_types().map(to_assoc_type_id).collect(); let trait_datum_bound = rust_ir::TraitDatumBound { where_clauses }; let well_known = lang_attr(db.upcast(), trait_).and_then(|name| well_known_trait_from_lang_attr(&name)); diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 4805c0a00..5ea2e5934 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -327,13 +327,7 @@ impl<'a> InferenceContext<'a> { self.normalize_associated_types_in(ret_ty) } Expr::MethodCall { receiver, args, method_name, generic_args } => self - .infer_method_call( - tgt_expr, - *receiver, - args, - method_name, - generic_args.as_deref(), - ), + .infer_method_call(tgt_expr, *receiver, args, method_name, generic_args.as_deref()), Expr::Match { expr, arms } => { let input_ty = self.infer_expr(*expr, &Expectation::none()); diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index e2cec21bc..7a53268e8 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -526,11 +526,9 @@ fn highlight_name_ref_by_syntax( }; match parent.kind() { - METHOD_CALL_EXPR => { - ast::MethodCallExpr::cast(parent) - .and_then(|it| highlight_method_call(sema, krate, &it)) - .unwrap_or_else(|| SymbolKind::Function.into()) - } + METHOD_CALL_EXPR => ast::MethodCallExpr::cast(parent) + .and_then(|it| highlight_method_call(sema, krate, &it)) + .unwrap_or_else(|| SymbolKind::Function.into()), FIELD_EXPR => { let h = HlTag::Symbol(SymbolKind::Field); let is_union = ast::FieldExpr::cast(parent) diff --git a/crates/ide_assists/src/assist_context.rs b/crates/ide_assists/src/assist_context.rs index d207cacb2..36a2bf89a 100644 --- a/crates/ide_assists/src/assist_context.rs +++ b/crates/ide_assists/src/assist_context.rs @@ -291,8 +291,7 @@ impl AssistBuilder { algo::diff(old.syntax(), new.syntax()).into_text_edit(&mut self.edit) } pub(crate) fn create_file(&mut self, dst: AnchoredPathBuf, content: impl Into) { - let file_system_edit = - FileSystemEdit::CreateFile { dst, initial_contents: content.into() }; + let file_system_edit = FileSystemEdit::CreateFile { dst, initial_contents: content.into() }; self.source_change.push_file_system_edit(file_system_edit); } diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index 8bfbba4bb..a840e06a6 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs @@ -490,9 +490,7 @@ impl<'a> FindUsages<'a> { Some(NameRefClass::FieldShorthand { local_ref: local, field_ref: field }) => { let FileRange { file_id, range } = self.sema.original_range(name_ref.syntax()); let access = match self.def { - Definition::Field(_) if field == self.def => { - reference_access(&field, name_ref) - } + Definition::Field(_) if field == self.def => reference_access(&field, name_ref), Definition::Local(l) if local == l => { reference_access(&Definition::Local(local), name_ref) } diff --git a/crates/proc_macro_api/src/process.rs b/crates/proc_macro_api/src/process.rs index a9e43be62..38eac6c17 100644 --- a/crates/proc_macro_api/src/process.rs +++ b/crates/proc_macro_api/src/process.rs @@ -76,9 +76,7 @@ impl ProcMacroProcessSrv { .map_err(|_| tt::ExpansionError::Unknown("proc macro server crashed".into()))?; match res { - Some(Response::Error(err)) => { - Err(tt::ExpansionError::ExpansionError(err.message)) - } + Some(Response::Error(err)) => Err(tt::ExpansionError::ExpansionError(err.message)), Some(res) => Ok(res.try_into().map_err(|err| { tt::ExpansionError::Unknown(format!("Fail to get response, reason : {:#?} ", err)) })?), diff --git a/crates/proc_macro_srv/src/proc_macro/diagnostic.rs b/crates/proc_macro_srv/src/proc_macro/diagnostic.rs index a30818982..9ceda2a47 100644 --- a/crates/proc_macro_srv/src/proc_macro/diagnostic.rs +++ b/crates/proc_macro_srv/src/proc_macro/diagnostic.rs @@ -101,12 +101,7 @@ impl Diagnostic { S: MultiSpan, T: Into, { - Diagnostic { - level, - message: message.into(), - spans: spans.into_spans(), - children: vec![], - } + Diagnostic { level, message: message.into(), spans: spans.into_spans(), children: vec![] } } diagnostic_child_methods!(span_error, error, Level::Error); -- cgit v1.2.3