aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/lib.rs46
1 files changed, 23 insertions, 23 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index b7eabaabb..30cc34403 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),
@@ -234,6 +233,10 @@ impl Crate {
234 pub fn cfg(&self, db: &dyn HirDatabase) -> CfgOptions { 233 pub fn cfg(&self, db: &dyn HirDatabase) -> CfgOptions {
235 db.crate_graph()[self.id].cfg_options.clone() 234 db.crate_graph()[self.id].cfg_options.clone()
236 } 235 }
236
237 pub fn potential_cfg(&self, db: &dyn HirDatabase) -> CfgOptions {
238 db.crate_graph()[self.id].potential_cfg_options.clone()
239 }
237} 240}
238 241
239#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 242#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -1846,7 +1849,7 @@ impl TypeParam {
1846 1849
1847 pub fn trait_bounds(self, db: &dyn HirDatabase) -> Vec<Trait> { 1850 pub fn trait_bounds(self, db: &dyn HirDatabase) -> Vec<Trait> {
1848 db.generic_predicates_for_param(self.id) 1851 db.generic_predicates_for_param(self.id)
1849 .into_iter() 1852 .iter()
1850 .filter_map(|pred| match &pred.skip_binders().skip_binders() { 1853 .filter_map(|pred| match &pred.skip_binders().skip_binders() {
1851 hir_ty::WhereClause::Implemented(trait_ref) => { 1854 hir_ty::WhereClause::Implemented(trait_ref) => {
1852 Some(Trait::from(trait_ref.hir_trait_id())) 1855 Some(Trait::from(trait_ref.hir_trait_id()))
@@ -1951,7 +1954,7 @@ impl Impl {
1951 all.extend( 1954 all.extend(
1952 db.inherent_impls_in_crate(id) 1955 db.inherent_impls_in_crate(id)
1953 .for_self_ty(&ty) 1956 .for_self_ty(&ty)
1954 .into_iter() 1957 .iter()
1955 .cloned() 1958 .cloned()
1956 .map(Self::from) 1959 .map(Self::from)
1957 .filter(filter), 1960 .filter(filter),
@@ -2232,8 +2235,8 @@ impl Type {
2232 } 2235 }
2233 2236
2234 pub fn is_packed(&self, db: &dyn HirDatabase) -> bool { 2237 pub fn is_packed(&self, db: &dyn HirDatabase) -> bool {
2235 let adt_id = match self.ty.kind(&Interner) { 2238 let adt_id = match *self.ty.kind(&Interner) {
2236 &TyKind::Adt(hir_ty::AdtId(adt_id), ..) => adt_id, 2239 TyKind::Adt(hir_ty::AdtId(adt_id), ..) => adt_id,
2237 _ => return false, 2240 _ => return false,
2238 }; 2241 };
2239 2242
@@ -2287,9 +2290,9 @@ impl Type {
2287 } 2290 }
2288 2291
2289 pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(Field, Type)> { 2292 pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(Field, Type)> {
2290 let (variant_id, substs) = match self.ty.kind(&Interner) { 2293 let (variant_id, substs) = match *self.ty.kind(&Interner) {
2291 &TyKind::Adt(hir_ty::AdtId(AdtId::StructId(s)), ref substs) => (s.into(), substs), 2294 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), 2295 TyKind::Adt(hir_ty::AdtId(AdtId::UnionId(u)), ref substs) => (u.into(), substs),
2293 _ => return Vec::new(), 2296 _ => return Vec::new(),
2294 }; 2297 };
2295 2298
@@ -2488,20 +2491,17 @@ impl Type {
2488 cb: &mut impl FnMut(Type), 2491 cb: &mut impl FnMut(Type),
2489 ) { 2492 ) {
2490 for pred in bounds { 2493 for pred in bounds {
2491 match pred.skip_binders() { 2494 if let WhereClause::Implemented(trait_ref) = pred.skip_binders() {
2492 WhereClause::Implemented(trait_ref) => { 2495 cb(type_.clone());
2493 cb(type_.clone()); 2496 // 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 2497 for ty in trait_ref
2495 for ty in trait_ref 2498 .substitution
2496 .substitution 2499 .iter(&Interner)
2497 .iter(&Interner) 2500 .skip(1)
2498 .skip(1) 2501 .filter_map(|a| a.ty(&Interner))
2499 .filter_map(|a| a.ty(&Interner)) 2502 {
2500 { 2503 walk_type(db, &type_.derived(ty.clone()), cb);
2501 walk_type(db, &type_.derived(ty.clone()), cb);
2502 }
2503 } 2504 }
2504 _ => (),
2505 } 2505 }
2506 } 2506 }
2507 } 2507 }
@@ -2514,7 +2514,7 @@ impl Type {
2514 walk_substs(db, type_, substs, cb); 2514 walk_substs(db, type_, substs, cb);
2515 } 2515 }
2516 TyKind::AssociatedType(_, substs) => { 2516 TyKind::AssociatedType(_, substs) => {
2517 if let Some(_) = ty.associated_type_parent_trait(db) { 2517 if ty.associated_type_parent_trait(db).is_some() {
2518 cb(type_.derived(ty.clone())); 2518 cb(type_.derived(ty.clone()));
2519 } 2519 }
2520 walk_substs(db, type_, substs, cb); 2520 walk_substs(db, type_, substs, cb);