Skip to content

Commit 5ce4ee9

Browse files
committed
Add back Res::matches_ns, implemented in terms of ns
1 parent 05a040f commit 5ce4ee9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/librustc_ast_lowering/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11451145
if let TyKind::Path(ref qself, ref path) = ty.kind {
11461146
if let Some(partial_res) = self.resolver.get_partial_res(ty.id) {
11471147
let res = partial_res.base_res();
1148-
if res.ns().map(|ns| ns != Namespace::TypeNS).unwrap_or(false) {
1148+
if !res.matches_ns(Namespace::TypeNS) {
11491149
debug!(
11501150
"lower_generic_arg: Lowering type argument as const argument: {:?}",
11511151
ty,

src/librustc_hir/def.rs

+5
Original file line numberDiff line numberDiff line change
@@ -461,4 +461,9 @@ impl<Id> Res<Id> {
461461
Res::Err => None,
462462
}
463463
}
464+
465+
/// Always returns `true` if `self` is `Res::Err`
466+
pub fn matches_ns(&self, ns: Namespace) -> bool {
467+
self.ns().map(|actual_ns| actual_ns == ns).unwrap_or(true)
468+
}
464469
}

0 commit comments

Comments
 (0)