Skip to content

Commit

Permalink
Add back Res::matches_ns, implemented in terms of ns
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Aug 25, 2020
1 parent 05a040f commit 5ce4ee9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc_ast_lowering/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.ns().map(|ns| ns != Namespace::TypeNS).unwrap_or(false) {
if !res.matches_ns(Namespace::TypeNS) {
debug!(
"lower_generic_arg: Lowering type argument as const argument: {:?}",
ty,
Expand Down
5 changes: 5 additions & 0 deletions src/librustc_hir/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,4 +461,9 @@ impl<Id> Res<Id> {
Res::Err => None,
}
}

/// Always returns `true` if `self` is `Res::Err`
pub fn matches_ns(&self, ns: Namespace) -> bool {
self.ns().map(|actual_ns| actual_ns == ns).unwrap_or(true)
}
}

0 comments on commit 5ce4ee9

Please sign in to comment.