X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_ast_lowering%2Fsrc%2Flib.rs;h=ce5893efa926d4651383bd38f07267020f84f23b;hb=5e04567ac7fb2d1e35cc52a02d499b6027b58a76;hp=8281164ab12070dc60beb1c3979baa1e692e75df;hpb=d10b47ef69a36590a04c76e8868093d251adfec6;p=rust.git diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 8281164ab12..ce5893efa92 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -175,12 +175,7 @@ fn legacy_const_generic_args(&self, expr: &Expr) -> Option> { return None; } - let partial_res = self.partial_res_map.get(&expr.id)?; - if partial_res.unresolved_segments() != 0 { - return None; - } - - if let Res::Def(DefKind::Fn, def_id) = partial_res.base_res() { + if let Res::Def(DefKind::Fn, def_id) = self.partial_res_map.get(&expr.id)?.full_res()? { // We only support cross-crate argument rewriting. Uses // within the same crate should be updated to use the new // const generics style. @@ -753,12 +748,7 @@ fn lower_res(&mut self, res: Res) -> Res { } fn expect_full_res(&mut self, id: NodeId) -> Res { - self.resolver.get_partial_res(id).map_or(Res::Err, |pr| { - if pr.unresolved_segments() != 0 { - panic!("path not fully resolved: {:?}", pr); - } - pr.base_res() - }) + self.resolver.get_partial_res(id).map_or(Res::Err, |pr| pr.expect_full_res()) } fn expect_full_res_from_use(&mut self, id: NodeId) -> impl Iterator> { @@ -1138,8 +1128,11 @@ fn lower_generic_arg( // type and value namespaces. If we resolved the path in the value namespace, we // transform it into a generic const argument. TyKind::Path(ref qself, ref path) => { - if let Some(partial_res) = self.resolver.get_partial_res(ty.id) { - let res = partial_res.base_res(); + if let Some(res) = self + .resolver + .get_partial_res(ty.id) + .and_then(|partial_res| partial_res.full_res()) + { if !res.matches_ns(Namespace::TypeNS) { debug!( "lower_generic_arg: Lowering type argument as const argument: {:?}", @@ -1206,8 +1199,7 @@ fn lower_path_ty( // by `ty_path`. if qself.is_none() && let Some(partial_res) = self.resolver.get_partial_res(t.id) - && partial_res.unresolved_segments() == 0 - && let Res::Def(DefKind::Trait | DefKind::TraitAlias, _) = partial_res.base_res() + && let Some(Res::Def(DefKind::Trait | DefKind::TraitAlias, _)) = partial_res.full_res() { let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| { let poly_trait_ref = this.ast_arena.ptr.alloc(PolyTraitRef {