diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_def/src/attr.rs | 4 | ||||
-rw-r--r-- | crates/hir_ty/src/chalk_db.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/consteval.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/lower.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 4 | ||||
-rw-r--r-- | crates/ide/src/hover.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/references/rename.rs | 2 | ||||
-rw-r--r-- | crates/ide_assists/src/handlers/apply_demorgan.rs | 4 | ||||
-rw-r--r-- | crates/ide_assists/src/handlers/fill_match_arms.rs | 2 | ||||
-rw-r--r-- | crates/ide_completion/src/context.rs | 2 | ||||
-rw-r--r-- | crates/ide_completion/src/patterns.rs | 6 | ||||
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 2 |
12 files changed, 17 insertions, 17 deletions
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index 2b21cf927..d07adb084 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs | |||
@@ -583,13 +583,13 @@ impl AttrSourceMap { | |||
583 | .get(id.ast_index as usize) | 583 | .get(id.ast_index as usize) |
584 | .unwrap_or_else(|| panic!("cannot find doc comment at index {:?}", id)) | 584 | .unwrap_or_else(|| panic!("cannot find doc comment at index {:?}", id)) |
585 | .clone() | 585 | .clone() |
586 | .map(|attr| Either::Right(attr)) | 586 | .map(Either::Right) |
587 | } else { | 587 | } else { |
588 | self.attrs | 588 | self.attrs |
589 | .get(id.ast_index as usize) | 589 | .get(id.ast_index as usize) |
590 | .unwrap_or_else(|| panic!("cannot find `Attr` at index {:?}", id)) | 590 | .unwrap_or_else(|| panic!("cannot find `Attr` at index {:?}", id)) |
591 | .clone() | 591 | .clone() |
592 | .map(|attr| Either::Left(attr)) | 592 | .map(Either::Left) |
593 | } | 593 | } |
594 | } | 594 | } |
595 | } | 595 | } |
diff --git a/crates/hir_ty/src/chalk_db.rs b/crates/hir_ty/src/chalk_db.rs index 4e042bf42..1dab19000 100644 --- a/crates/hir_ty/src/chalk_db.rs +++ b/crates/hir_ty/src/chalk_db.rs | |||
@@ -431,7 +431,7 @@ pub(crate) fn trait_datum_query( | |||
431 | }; | 431 | }; |
432 | let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars); | 432 | let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars); |
433 | let associated_ty_ids = | 433 | let associated_ty_ids = |
434 | trait_data.associated_types().map(|type_alias| to_assoc_type_id(type_alias)).collect(); | 434 | trait_data.associated_types().map(to_assoc_type_id).collect(); |
435 | let trait_datum_bound = rust_ir::TraitDatumBound { where_clauses }; | 435 | let trait_datum_bound = rust_ir::TraitDatumBound { where_clauses }; |
436 | let well_known = | 436 | let well_known = |
437 | lang_attr(db.upcast(), trait_).and_then(|name| well_known_trait_from_lang_attr(&name)); | 437 | lang_attr(db.upcast(), trait_).and_then(|name| well_known_trait_from_lang_attr(&name)); |
diff --git a/crates/hir_ty/src/consteval.rs b/crates/hir_ty/src/consteval.rs index e3ceb3d62..6f0bf8f8c 100644 --- a/crates/hir_ty/src/consteval.rs +++ b/crates/hir_ty/src/consteval.rs | |||
@@ -49,7 +49,7 @@ pub fn usize_const(value: Option<u64>) -> Const { | |||
49 | ConstData { | 49 | ConstData { |
50 | ty: TyKind::Scalar(chalk_ir::Scalar::Uint(chalk_ir::UintTy::Usize)).intern(&Interner), | 50 | ty: TyKind::Scalar(chalk_ir::Scalar::Uint(chalk_ir::UintTy::Usize)).intern(&Interner), |
51 | value: ConstValue::Concrete(chalk_ir::ConcreteConst { | 51 | value: ConstValue::Concrete(chalk_ir::ConcreteConst { |
52 | interned: value.map(|value| ConstScalar::Usize(value)).unwrap_or(ConstScalar::Unknown), | 52 | interned: value.map(ConstScalar::Usize).unwrap_or(ConstScalar::Unknown), |
53 | }), | 53 | }), |
54 | } | 54 | } |
55 | .intern(&Interner) | 55 | .intern(&Interner) |
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 0b8f21e5d..a8a9f5ca1 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -784,7 +784,7 @@ impl<'a> TyLoweringContext<'a> { | |||
784 | let trait_ref = match bound { | 784 | let trait_ref = match bound { |
785 | TypeBound::Path(path) => { | 785 | TypeBound::Path(path) => { |
786 | bindings = self.lower_trait_ref_from_path(path, Some(self_ty)); | 786 | bindings = self.lower_trait_ref_from_path(path, Some(self_ty)); |
787 | bindings.clone().map(WhereClause::Implemented).map(|b| crate::wrap_empty_binders(b)) | 787 | bindings.clone().map(WhereClause::Implemented).map(crate::wrap_empty_binders) |
788 | } | 788 | } |
789 | TypeBound::Lifetime(_) => None, | 789 | TypeBound::Lifetime(_) => None, |
790 | TypeBound::Error => None, | 790 | TypeBound::Error => None, |
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 8c00a6369..f3d390961 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs | |||
@@ -60,7 +60,7 @@ impl TyFingerprint { | |||
60 | TyKind::Adt(AdtId(adt), _) => TyFingerprint::Adt(*adt), | 60 | TyKind::Adt(AdtId(adt), _) => TyFingerprint::Adt(*adt), |
61 | TyKind::Raw(mutability, ..) => TyFingerprint::RawPtr(*mutability), | 61 | TyKind::Raw(mutability, ..) => TyFingerprint::RawPtr(*mutability), |
62 | TyKind::Foreign(alias_id, ..) => TyFingerprint::ForeignType(*alias_id), | 62 | TyKind::Foreign(alias_id, ..) => TyFingerprint::ForeignType(*alias_id), |
63 | TyKind::Dyn(_) => ty.dyn_trait().map(|trait_| TyFingerprint::Dyn(trait_))?, | 63 | TyKind::Dyn(_) => ty.dyn_trait().map(TyFingerprint::Dyn)?, |
64 | _ => return None, | 64 | _ => return None, |
65 | }; | 65 | }; |
66 | Some(fp) | 66 | Some(fp) |
@@ -77,7 +77,7 @@ impl TyFingerprint { | |||
77 | TyKind::Adt(AdtId(adt), _) => TyFingerprint::Adt(*adt), | 77 | TyKind::Adt(AdtId(adt), _) => TyFingerprint::Adt(*adt), |
78 | TyKind::Raw(mutability, ..) => TyFingerprint::RawPtr(*mutability), | 78 | TyKind::Raw(mutability, ..) => TyFingerprint::RawPtr(*mutability), |
79 | TyKind::Foreign(alias_id, ..) => TyFingerprint::ForeignType(*alias_id), | 79 | TyKind::Foreign(alias_id, ..) => TyFingerprint::ForeignType(*alias_id), |
80 | TyKind::Dyn(_) => ty.dyn_trait().map(|trait_| TyFingerprint::Dyn(trait_))?, | 80 | TyKind::Dyn(_) => ty.dyn_trait().map(TyFingerprint::Dyn)?, |
81 | TyKind::Ref(_, _, ty) => return TyFingerprint::for_trait_impl(ty), | 81 | TyKind::Ref(_, _, ty) => return TyFingerprint::for_trait_impl(ty), |
82 | TyKind::Tuple(_, subst) => { | 82 | TyKind::Tuple(_, subst) => { |
83 | let first_ty = subst.interned().get(0).map(|arg| arg.assert_ty_ref(&Interner)); | 83 | let first_ty = subst.interned().get(0).map(|arg| arg.assert_ty_ref(&Interner)); |
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 4ba4f61d8..c08516805 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs | |||
@@ -288,7 +288,7 @@ fn runnable_action( | |||
288 | ) -> Option<HoverAction> { | 288 | ) -> Option<HoverAction> { |
289 | match def { | 289 | match def { |
290 | Definition::ModuleDef(it) => match it { | 290 | Definition::ModuleDef(it) => match it { |
291 | ModuleDef::Module(it) => runnable_mod(sema, it).map(|it| HoverAction::Runnable(it)), | 291 | ModuleDef::Module(it) => runnable_mod(sema, it).map(HoverAction::Runnable), |
292 | ModuleDef::Function(func) => { | 292 | ModuleDef::Function(func) => { |
293 | let src = func.source(sema.db)?; | 293 | let src = func.source(sema.db)?; |
294 | if src.file_id != file_id.into() { | 294 | if src.file_id != file_id.into() { |
diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index 02b171bda..50cc1f963 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs | |||
@@ -426,7 +426,7 @@ fn text_edit_from_self_param(self_param: &ast::SelfParam, new_name: &str) -> Opt | |||
426 | None | 426 | None |
427 | } | 427 | } |
428 | 428 | ||
429 | let impl_def = self_param.syntax().ancestors().find_map(|it| ast::Impl::cast(it))?; | 429 | let impl_def = self_param.syntax().ancestors().find_map(ast::Impl::cast)?; |
430 | let type_name = target_type_name(&impl_def)?; | 430 | let type_name = target_type_name(&impl_def)?; |
431 | 431 | ||
432 | let mut replacement_text = String::from(new_name); | 432 | let mut replacement_text = String::from(new_name); |
diff --git a/crates/ide_assists/src/handlers/apply_demorgan.rs b/crates/ide_assists/src/handlers/apply_demorgan.rs index 5c936a510..c93959e66 100644 --- a/crates/ide_assists/src/handlers/apply_demorgan.rs +++ b/crates/ide_assists/src/handlers/apply_demorgan.rs | |||
@@ -78,12 +78,12 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext) -> Option<( | |||
78 | terms.sort_by_key(|t| t.syntax().text_range().start()); | 78 | terms.sort_by_key(|t| t.syntax().text_range().start()); |
79 | let mut terms = VecDeque::from(terms); | 79 | let mut terms = VecDeque::from(terms); |
80 | 80 | ||
81 | let paren_expr = expr.syntax().parent().and_then(|parent| ast::ParenExpr::cast(parent)); | 81 | let paren_expr = expr.syntax().parent().and_then(ast::ParenExpr::cast); |
82 | 82 | ||
83 | let neg_expr = paren_expr | 83 | let neg_expr = paren_expr |
84 | .clone() | 84 | .clone() |
85 | .and_then(|paren_expr| paren_expr.syntax().parent()) | 85 | .and_then(|paren_expr| paren_expr.syntax().parent()) |
86 | .and_then(|parent| ast::PrefixExpr::cast(parent)) | 86 | .and_then(ast::PrefixExpr::cast) |
87 | .and_then(|prefix_expr| { | 87 | .and_then(|prefix_expr| { |
88 | if prefix_expr.op_kind().unwrap() == ast::PrefixOp::Not { | 88 | if prefix_expr.op_kind().unwrap() == ast::PrefixOp::Not { |
89 | Some(prefix_expr) | 89 | Some(prefix_expr) |
diff --git a/crates/ide_assists/src/handlers/fill_match_arms.rs b/crates/ide_assists/src/handlers/fill_match_arms.rs index c8bc923f5..5a43bdd6f 100644 --- a/crates/ide_assists/src/handlers/fill_match_arms.rs +++ b/crates/ide_assists/src/handlers/fill_match_arms.rs | |||
@@ -202,7 +202,7 @@ impl ExtendedEnum { | |||
202 | fn variants(self, db: &RootDatabase) -> Vec<ExtendedVariant> { | 202 | fn variants(self, db: &RootDatabase) -> Vec<ExtendedVariant> { |
203 | match self { | 203 | match self { |
204 | ExtendedEnum::Enum(e) => { | 204 | ExtendedEnum::Enum(e) => { |
205 | e.variants(db).into_iter().map(|x| ExtendedVariant::Variant(x)).collect::<Vec<_>>() | 205 | e.variants(db).into_iter().map(ExtendedVariant::Variant).collect::<Vec<_>>() |
206 | } | 206 | } |
207 | ExtendedEnum::Bool => { | 207 | ExtendedEnum::Bool => { |
208 | Vec::<ExtendedVariant>::from([ExtendedVariant::True, ExtendedVariant::False]) | 208 | Vec::<ExtendedVariant>::from([ExtendedVariant::True, ExtendedVariant::False]) |
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index e4abe2742..4c3929a26 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs | |||
@@ -380,7 +380,7 @@ impl<'a> CompletionContext<'a> { | |||
380 | (|| { | 380 | (|| { |
381 | let expr_field = self.token.prev_sibling_or_token()? | 381 | let expr_field = self.token.prev_sibling_or_token()? |
382 | .into_node() | 382 | .into_node() |
383 | .and_then(|node| ast::RecordExprField::cast(node))?; | 383 | .and_then(ast::RecordExprField::cast)?; |
384 | let (_, _, ty) = self.sema.resolve_record_field(&expr_field)?; | 384 | let (_, _, ty) = self.sema.resolve_record_field(&expr_field)?; |
385 | Some(( | 385 | Some(( |
386 | Some(ty), | 386 | Some(ty), |
diff --git a/crates/ide_completion/src/patterns.rs b/crates/ide_completion/src/patterns.rs index c567ac63d..72e67e3c4 100644 --- a/crates/ide_completion/src/patterns.rs +++ b/crates/ide_completion/src/patterns.rs | |||
@@ -259,7 +259,7 @@ fn test_inside_impl_trait_block() { | |||
259 | } | 259 | } |
260 | 260 | ||
261 | pub(crate) fn previous_token(element: SyntaxElement) -> Option<SyntaxToken> { | 261 | pub(crate) fn previous_token(element: SyntaxElement) -> Option<SyntaxToken> { |
262 | element.into_token().and_then(|it| previous_non_trivia_token(it)) | 262 | element.into_token().and_then(previous_non_trivia_token) |
263 | } | 263 | } |
264 | 264 | ||
265 | /// Check if the token previous to the previous one is `for`. | 265 | /// Check if the token previous to the previous one is `for`. |
@@ -267,8 +267,8 @@ pub(crate) fn previous_token(element: SyntaxElement) -> Option<SyntaxToken> { | |||
267 | pub(crate) fn for_is_prev2(element: SyntaxElement) -> bool { | 267 | pub(crate) fn for_is_prev2(element: SyntaxElement) -> bool { |
268 | element | 268 | element |
269 | .into_token() | 269 | .into_token() |
270 | .and_then(|it| previous_non_trivia_token(it)) | 270 | .and_then(previous_non_trivia_token) |
271 | .and_then(|it| previous_non_trivia_token(it)) | 271 | .and_then(previous_non_trivia_token) |
272 | .filter(|it| it.kind() == T![for]) | 272 | .filter(|it| it.kind() == T![for]) |
273 | .is_some() | 273 | .is_some() |
274 | } | 274 | } |
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 59339d401..a81e398c4 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -781,7 +781,7 @@ pub(crate) fn handle_completion_resolve( | |||
781 | let resolve_data = match original_completion | 781 | let resolve_data = match original_completion |
782 | .data | 782 | .data |
783 | .take() | 783 | .take() |
784 | .map(|data| serde_json::from_value::<CompletionResolveData>(data)) | 784 | .map(serde_json::from_value::<CompletionResolveData>) |
785 | .transpose()? | 785 | .transpose()? |
786 | { | 786 | { |
787 | Some(data) => data, | 787 | Some(data) => data, |