Add Res::ns() instead of matches_ns()
This commit is contained in:
parent
c35007dbbe
commit
18e7a1b799
2 changed files with 8 additions and 7 deletions
|
|
@ -1145,7 +1145,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
if let TyKind::Path(ref qself, ref path) = ty.kind {
|
||||
if let Some(partial_res) = self.resolver.get_partial_res(ty.id) {
|
||||
let res = partial_res.base_res();
|
||||
if !res.matches_ns(Namespace::TypeNS) {
|
||||
if res.ns().map(|ns| ns != Namespace::TypeNS).unwrap_or(false) {
|
||||
debug!(
|
||||
"lower_generic_arg: Lowering type argument as const argument: {:?}",
|
||||
ty,
|
||||
|
|
|
|||
|
|
@ -451,13 +451,14 @@ impl<Id> Res<Id> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn matches_ns(&self, ns: Namespace) -> bool {
|
||||
/// Returns `None` if this is `Res::Err`
|
||||
pub fn ns(&self) -> Option<Namespace> {
|
||||
match self {
|
||||
Res::Def(kind, ..) => kind.ns() == Some(ns),
|
||||
Res::PrimTy(..) | Res::SelfTy(..) | Res::ToolMod => ns == Namespace::TypeNS,
|
||||
Res::SelfCtor(..) | Res::Local(..) => ns == Namespace::ValueNS,
|
||||
Res::NonMacroAttr(..) => ns == Namespace::MacroNS,
|
||||
Res::Err => true,
|
||||
Res::Def(kind, ..) => kind.ns(),
|
||||
Res::PrimTy(..) | Res::SelfTy(..) | Res::ToolMod => Some(Namespace::TypeNS),
|
||||
Res::SelfCtor(..) | Res::Local(..) => Some(Namespace::ValueNS),
|
||||
Res::NonMacroAttr(..) => Some(Namespace::MacroNS),
|
||||
Res::Err => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue