mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
adjust hir_def::TypeBound::as_path
This commit is contained in:
parent
b217e9cc50
commit
d9e6377b91
3 changed files with 13 additions and 6 deletions
|
@ -304,7 +304,7 @@ struct S<'a, 'b: 'a, T: Copy + 'a + 'b, const K: u8 = 0> {
|
||||||
field: &'a &'b T,
|
field: &'a &'b T,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Tuple<T: Copy>(T);
|
struct Tuple<T: Copy, U: ?Sized>(T, U);
|
||||||
|
|
||||||
impl<'a, 'b: 'a, T: Copy + 'a + 'b, const K: u8 = 0> S<'a, 'b, T, K> {
|
impl<'a, 'b: 'a, T: Copy + 'a + 'b, const K: u8 = 0> S<'a, 'b, T, K> {
|
||||||
fn f<G: 'a>(arg: impl Copy) -> impl Copy {}
|
fn f<G: 'a>(arg: impl Copy) -> impl Copy {}
|
||||||
|
@ -325,11 +325,13 @@ trait Tr<'a, T: 'a>: Super where Self: for<'a> Tr<'a, T> {}
|
||||||
pub(self) field: &'a &'b T,
|
pub(self) field: &'a &'b T,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(self) struct Tuple<T>(
|
pub(self) struct Tuple<T, U>(
|
||||||
pub(self) 0: T,
|
pub(self) 0: T,
|
||||||
|
pub(self) 1: U,
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
T: Copy;
|
T: Copy,
|
||||||
|
U: ?Sized;
|
||||||
|
|
||||||
impl<'a, 'b, T, const K: u8> S<'a, 'b, T, K>
|
impl<'a, 'b, T, const K: u8> S<'a, 'b, T, K>
|
||||||
where
|
where
|
||||||
|
|
|
@ -332,9 +332,10 @@ impl TypeBound {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_path(&self) -> Option<&Path> {
|
pub fn as_path(&self) -> Option<(&Path, &TraitBoundModifier)> {
|
||||||
match self {
|
match self {
|
||||||
TypeBound::Path(p, _) | TypeBound::ForLifetime(_, p) => Some(p),
|
TypeBound::Path(p, m) => Some((p, m)),
|
||||||
|
TypeBound::ForLifetime(_, p) => Some((p, &TraitBoundModifier::None)),
|
||||||
TypeBound::Lifetime(_) | TypeBound::Error => None,
|
TypeBound::Lifetime(_) | TypeBound::Error => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use hir_def::{
|
||||||
intern::Interned,
|
intern::Interned,
|
||||||
path::Path,
|
path::Path,
|
||||||
resolver::{HasResolver, TypeNs},
|
resolver::{HasResolver, TypeNs},
|
||||||
type_ref::TypeRef,
|
type_ref::{TraitBoundModifier, TypeRef},
|
||||||
AssocContainerId, GenericDefId, Lookup, TraitId, TypeAliasId, TypeParamId,
|
AssocContainerId, GenericDefId, Lookup, TraitId, TypeAliasId, TypeParamId,
|
||||||
};
|
};
|
||||||
use hir_expand::name::{name, Name};
|
use hir_expand::name::{name, Name};
|
||||||
|
@ -58,6 +58,10 @@ fn direct_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> Vec<TraitId> {
|
||||||
},
|
},
|
||||||
WherePredicate::Lifetime { .. } => None,
|
WherePredicate::Lifetime { .. } => None,
|
||||||
})
|
})
|
||||||
|
.filter_map(|(path, bound_modifier)| match bound_modifier {
|
||||||
|
TraitBoundModifier::None => Some(path),
|
||||||
|
TraitBoundModifier::Maybe => None,
|
||||||
|
})
|
||||||
.filter_map(|path| match resolver.resolve_path_in_type_ns_fully(db, path.mod_path()) {
|
.filter_map(|path| match resolver.resolve_path_in_type_ns_fully(db, path.mod_path()) {
|
||||||
Some(TypeNs::TraitId(t)) => Some(t),
|
Some(TypeNs::TraitId(t)) => Some(t),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue