aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-21 16:11:21 +0100
committerGitHub <[email protected]>2021-06-21 16:11:21 +0100
commit56e61bdfea5454dec4408a4947e037bcd042c886 (patch)
tree0bc42cbfcf5b6b502ad9fc3079cb4bdc5e8f110f /crates/hir
parent25bf451c8426a68ecfdc3a1d1be1db9702dd41d8 (diff)
parent47747cd4120e260a144242aadd7732e11d133fe4 (diff)
Merge #9165
9165: Apply some clippy suggestions r=matklad a=clemenswasser Co-authored-by: Clemens Wasser <[email protected]>
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/lib.rs42
1 files changed, 19 insertions, 23 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index b7eabaabb..88490fea9 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -219,8 +219,7 @@ impl Crate {
219 let doc_url = doc_attr_q.tt_values().map(|tt| { 219 let doc_url = doc_attr_q.tt_values().map(|tt| {
220 let name = tt.token_trees.iter() 220 let name = tt.token_trees.iter()
221 .skip_while(|tt| !matches!(tt, TokenTree::Leaf(Leaf::Ident(Ident{text: ref ident, ..})) if ident == "html_root_url")) 221 .skip_while(|tt| !matches!(tt, TokenTree::Leaf(Leaf::Ident(Ident{text: ref ident, ..})) if ident == "html_root_url"))
222 .skip(2) 222 .nth(2);
223 .next();
224 223
225 match name { 224 match name {
226 Some(TokenTree::Leaf(Leaf::Literal(Literal{ref text, ..}))) => Some(text), 225 Some(TokenTree::Leaf(Leaf::Literal(Literal{ref text, ..}))) => Some(text),
@@ -1846,7 +1845,7 @@ impl TypeParam {
1846 1845
1847 pub fn trait_bounds(self, db: &dyn HirDatabase) -> Vec<Trait> { 1846 pub fn trait_bounds(self, db: &dyn HirDatabase) -> Vec<Trait> {
1848 db.generic_predicates_for_param(self.id) 1847 db.generic_predicates_for_param(self.id)
1849 .into_iter() 1848 .iter()
1850 .filter_map(|pred| match &pred.skip_binders().skip_binders() { 1849 .filter_map(|pred| match &pred.skip_binders().skip_binders() {
1851 hir_ty::WhereClause::Implemented(trait_ref) => { 1850 hir_ty::WhereClause::Implemented(trait_ref) => {
1852 Some(Trait::from(trait_ref.hir_trait_id())) 1851 Some(Trait::from(trait_ref.hir_trait_id()))
@@ -1951,7 +1950,7 @@ impl Impl {
1951 all.extend( 1950 all.extend(
1952 db.inherent_impls_in_crate(id) 1951 db.inherent_impls_in_crate(id)
1953 .for_self_ty(&ty) 1952 .for_self_ty(&ty)
1954 .into_iter() 1953 .iter()
1955 .cloned() 1954 .cloned()
1956 .map(Self::from) 1955 .map(Self::from)
1957 .filter(filter), 1956 .filter(filter),
@@ -2232,8 +2231,8 @@ impl Type {
2232 } 2231 }
2233 2232
2234 pub fn is_packed(&self, db: &dyn HirDatabase) -> bool { 2233 pub fn is_packed(&self, db: &dyn HirDatabase) -> bool {
2235 let adt_id = match self.ty.kind(&Interner) { 2234 let adt_id = match *self.ty.kind(&Interner) {
2236 &TyKind::Adt(hir_ty::AdtId(adt_id), ..) => adt_id, 2235 TyKind::Adt(hir_ty::AdtId(adt_id), ..) => adt_id,
2237 _ => return false, 2236 _ => return false,
2238 }; 2237 };
2239 2238
@@ -2287,9 +2286,9 @@ impl Type {
2287 } 2286 }
2288 2287
2289 pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(Field, Type)> { 2288 pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(Field, Type)> {
2290 let (variant_id, substs) = match self.ty.kind(&Interner) { 2289 let (variant_id, substs) = match *self.ty.kind(&Interner) {
2291 &TyKind::Adt(hir_ty::AdtId(AdtId::StructId(s)), ref substs) => (s.into(), substs), 2290 TyKind::Adt(hir_ty::AdtId(AdtId::StructId(s)), ref substs) => (s.into(), substs),
2292 &TyKind::Adt(hir_ty::AdtId(AdtId::UnionId(u)), ref substs) => (u.into(), substs), 2291 TyKind::Adt(hir_ty::AdtId(AdtId::UnionId(u)), ref substs) => (u.into(), substs),
2293 _ => return Vec::new(), 2292 _ => return Vec::new(),
2294 }; 2293 };
2295 2294
@@ -2488,20 +2487,17 @@ impl Type {
2488 cb: &mut impl FnMut(Type), 2487 cb: &mut impl FnMut(Type),
2489 ) { 2488 ) {
2490 for pred in bounds { 2489 for pred in bounds {
2491 match pred.skip_binders() { 2490 if let WhereClause::Implemented(trait_ref) = pred.skip_binders() {
2492 WhereClause::Implemented(trait_ref) => { 2491 cb(type_.clone());
2493 cb(type_.clone()); 2492 // skip the self type. it's likely the type we just got the bounds from
2494 // skip the self type. it's likely the type we just got the bounds from 2493 for ty in trait_ref
2495 for ty in trait_ref 2494 .substitution
2496 .substitution 2495 .iter(&Interner)
2497 .iter(&Interner) 2496 .skip(1)
2498 .skip(1) 2497 .filter_map(|a| a.ty(&Interner))
2499 .filter_map(|a| a.ty(&Interner)) 2498 {
2500 { 2499 walk_type(db, &type_.derived(ty.clone()), cb);
2501 walk_type(db, &type_.derived(ty.clone()), cb);
2502 }
2503 } 2500 }
2504 _ => (),
2505 } 2501 }
2506 } 2502 }
2507 } 2503 }
@@ -2514,7 +2510,7 @@ impl Type {
2514 walk_substs(db, type_, substs, cb); 2510 walk_substs(db, type_, substs, cb);
2515 } 2511 }
2516 TyKind::AssociatedType(_, substs) => { 2512 TyKind::AssociatedType(_, substs) => {
2517 if let Some(_) = ty.associated_type_parent_trait(db) { 2513 if ty.associated_type_parent_trait(db).is_some() {
2518 cb(type_.derived(ty.clone())); 2514 cb(type_.derived(ty.clone()));
2519 } 2515 }
2520 walk_substs(db, type_, substs, cb); 2516 walk_substs(db, type_, substs, cb);