about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-08-30 15:10:28 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2022-09-05 14:20:25 +1000
commit6d850d936bae9745b68b08c6e1d62a1b1cc6bc84 (patch)
tree3865708cbf3c8b65fc779965ac3db424ce267792 /compiler/rustc_ast_lowering/src
parentee244bf1961cec6279bd4a91f9bcdc1339f74c97 (diff)
downloadrust-6d850d936bae9745b68b08c6e1d62a1b1cc6bc84.tar.gz
rust-6d850d936bae9745b68b08c6e1d62a1b1cc6bc84.zip
Make `hir::PathSegment::res` non-optional.
Diffstat (limited to 'compiler/rustc_ast_lowering/src')
-rw-r--r--compiler/rustc_ast_lowering/src/expr.rs5
-rw-r--r--compiler/rustc_ast_lowering/src/item.rs7
-rw-r--r--compiler/rustc_ast_lowering/src/lib.rs8
-rw-r--r--compiler/rustc_ast_lowering/src/pat.rs19
-rw-r--r--compiler/rustc_ast_lowering/src/path.rs2
5 files changed, 25 insertions, 16 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index 7df3520422c..a41d4b01e0e 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -1776,12 +1776,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
         binding: hir::HirId,
         attrs: AttrVec,
     ) -> hir::Expr<'hir> {
+        let res = Res::Local(binding);
         let expr_path = hir::ExprKind::Path(hir::QPath::Resolved(
             None,
             self.arena.alloc(hir::Path {
                 span: self.lower_span(span),
-                res: Res::Local(binding),
-                segments: arena_vec![self; hir::PathSegment::from_ident(ident)],
+                res,
+                segments: arena_vec![self; hir::PathSegment::from_ident(ident, res)],
             }),
         ));
 
diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs
index fd338ffc0c5..e3f02968d4d 100644
--- a/compiler/rustc_ast_lowering/src/item.rs
+++ b/compiler/rustc_ast_lowering/src/item.rs
@@ -1431,10 +1431,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
             GenericParamKind::Const { .. } => None,
             GenericParamKind::Type { .. } => {
                 let def_id = self.local_def_id(id).to_def_id();
+                let res = Res::Def(DefKind::TyParam, def_id);
                 let ty_path = self.arena.alloc(hir::Path {
                     span: param_span,
-                    res: Res::Def(DefKind::TyParam, def_id),
-                    segments: self.arena.alloc_from_iter([hir::PathSegment::from_ident(ident)]),
+                    res,
+                    segments: self
+                        .arena
+                        .alloc_from_iter([hir::PathSegment::from_ident(ident, res)]),
                 });
                 let ty_id = self.next_id();
                 let bounded_ty =
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 9a960356a85..bc183c6e313 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -1267,7 +1267,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                     self.arena.alloc(hir::Path {
                         res,
                         segments: arena_vec![self; hir::PathSegment::from_ident(
-                            Ident::with_dummy_span(kw::SelfUpper)
+                            Ident::with_dummy_span(kw::SelfUpper),
+                            res
                         )],
                         span: self.lower_span(t.span),
                     }),
@@ -2193,12 +2194,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
             hir::PredicateOrigin::ImplTrait,
         );
 
+        let res = Res::Def(DefKind::TyParam, def_id.to_def_id());
         let ty = hir::TyKind::Path(hir::QPath::Resolved(
             None,
             self.arena.alloc(hir::Path {
                 span: self.lower_span(span),
-                res: Res::Def(DefKind::TyParam, def_id.to_def_id()),
-                segments: arena_vec![self; hir::PathSegment::from_ident(self.lower_ident(ident))],
+                res,
+                segments: arena_vec![self; hir::PathSegment::from_ident(self.lower_ident(ident), res)],
             }),
         ));
 
diff --git a/compiler/rustc_ast_lowering/src/pat.rs b/compiler/rustc_ast_lowering/src/pat.rs
index 1efa19a3a82..61c32816e17 100644
--- a/compiler/rustc_ast_lowering/src/pat.rs
+++ b/compiler/rustc_ast_lowering/src/pat.rs
@@ -254,14 +254,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                     lower_sub(self),
                 )
             }
-            Some(res) => hir::PatKind::Path(hir::QPath::Resolved(
-                None,
-                self.arena.alloc(hir::Path {
-                    span: self.lower_span(ident.span),
-                    res: self.lower_res(res),
-                    segments: arena_vec![self; hir::PathSegment::from_ident(self.lower_ident(ident))],
-                }),
-            )),
+            Some(res) => {
+                let res = self.lower_res(res);
+                hir::PatKind::Path(hir::QPath::Resolved(
+                    None,
+                    self.arena.alloc(hir::Path {
+                        span: self.lower_span(ident.span),
+                        res,
+                        segments: arena_vec![self; hir::PathSegment::from_ident(self.lower_ident(ident), res)],
+                    }),
+            ))
+            }
         }
     }
 
diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs
index 897c7215805..6ec8bcbc1e5 100644
--- a/compiler/rustc_ast_lowering/src/path.rs
+++ b/compiler/rustc_ast_lowering/src/path.rs
@@ -259,7 +259,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
         hir::PathSegment {
             ident: self.lower_ident(segment.ident),
             hir_id: Some(id),
-            res: Some(self.lower_res(res)),
+            res: self.lower_res(res),
             infer_args,
             args: if generic_args.is_empty() && generic_args.span.is_empty() {
                 None