diff options
| author | Joshua Nelson <jyn514@gmail.com> | 2020-08-25 16:45:12 -0400 |
|---|---|---|
| committer | Joshua Nelson <jyn514@gmail.com> | 2020-08-25 16:45:12 -0400 |
| commit | 5ce4ee9687dcc7c31b7e5a6b0dbae31064861433 (patch) | |
| tree | ddf4e54363f64985b4d5192f582204795fa66fc9 | |
| parent | 05a040f406009a22600a9e0c37738ad0643cf811 (diff) | |
| download | rust-5ce4ee9687dcc7c31b7e5a6b0dbae31064861433.tar.gz rust-5ce4ee9687dcc7c31b7e5a6b0dbae31064861433.zip | |
Add back `Res::matches_ns`, implemented in terms of `ns`
| -rw-r--r-- | src/librustc_ast_lowering/lib.rs | 2 | ||||
| -rw-r--r-- | src/librustc_hir/def.rs | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index d61db171aa2..586355fe613 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -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, diff --git a/src/librustc_hir/def.rs b/src/librustc_hir/def.rs index 67f20aa848f..72310061d5c 100644 --- a/src/librustc_hir/def.rs +++ b/src/librustc_hir/def.rs @@ -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) + } } |
