diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-10-30 12:02:17 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-30 12:02:17 +0000 |
commit | a9daecd2a35f7caebb02feb4dbb2dc89f3165cdb (patch) | |
tree | e20c3965e480c2ce76ee5276a2b8a3b96fd3ba9a /gcc | |
parent | cba61d8dcbe1ac0fb23a96b2974541b201292465 (diff) | |
parent | a66dd96413432095ef13e6429f7acb3cb06f4f0f (diff) | |
download | gcc-a9daecd2a35f7caebb02feb4dbb2dc89f3165cdb.zip gcc-a9daecd2a35f7caebb02feb4dbb2dc89f3165cdb.tar.gz gcc-a9daecd2a35f7caebb02feb4dbb2dc89f3165cdb.tar.bz2 |
Merge #778
778: Add location info in AST::TypeBoundWhereClauseItem and HIR::TypeBoundWhereClauseItem r=philberty a=npate012
Location info has been added to AST::TypeBoundWhereClauseItem and HIR::TypeBoundWhereClauseItem. parse_type_bound_where_clause_item () has been modified to fetch location info and store it in AST::TypeBoundWhereClauseItem.
Fixes #766
Signed-off-by: Nirmal Patel <npate012@gmail.com>
Co-authored-by: Nirmal Patel <npate012@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-item.h | 8 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-type.h | 3 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-item.h | 6 | ||||
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 4 |
4 files changed, 15 insertions, 6 deletions
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 323548a..39411f8 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -228,6 +228,7 @@ class TypeBoundWhereClauseItem : public WhereClauseItem std::unique_ptr<Type> bound_type; std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds; NodeId node_id; + Location locus; public: // Returns whether the item has ForLifetimes @@ -238,11 +239,12 @@ public: TypeBoundWhereClauseItem ( std::vector<LifetimeParam> for_lifetimes, std::unique_ptr<Type> bound_type, - std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds) + std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, + Location locus) : for_lifetimes (std::move (for_lifetimes)), bound_type (std::move (bound_type)), type_param_bounds (std::move (type_param_bounds)), - node_id (Analysis::Mappings::get ()->get_next_node_id ()) + node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus) {} // Copy constructor requires clone @@ -298,6 +300,8 @@ public: NodeId get_node_id () const override final { return node_id; } + Location get_locus () const { return locus; } + protected: // Clone function implementation as (not pure) virtual method TypeBoundWhereClauseItem *clone_where_clause_item_impl () const override diff --git a/gcc/rust/hir/rust-ast-lower-type.h b/gcc/rust/hir/rust-ast-lower-type.h index 8205d07..f44825c 100644 --- a/gcc/rust/hir/rust-ast-lower-type.h +++ b/gcc/rust/hir/rust-ast-lower-type.h @@ -479,7 +479,8 @@ public: translated = new HIR::TypeBoundWhereClauseItem (mapping, std::move (for_lifetimes), std::move (bound_type), - std::move (type_param_bounds)); + std::move (type_param_bounds), + item.get_locus ()); } private: diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h index 21f0781..9b8793f 100644 --- a/gcc/rust/hir/tree/rust-hir-item.h +++ b/gcc/rust/hir/tree/rust-hir-item.h @@ -218,6 +218,7 @@ class TypeBoundWhereClauseItem : public WhereClauseItem std::unique_ptr<Type> bound_type; std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds; Analysis::NodeMapping mappings; + Location locus; public: // Returns whether the item has ForLifetimes @@ -229,11 +230,12 @@ public: TypeBoundWhereClauseItem ( Analysis::NodeMapping mappings, std::vector<LifetimeParam> for_lifetimes, std::unique_ptr<Type> bound_type, - std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds) + std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, + Location locus) : for_lifetimes (std::move (for_lifetimes)), bound_type (std::move (bound_type)), type_param_bounds (std::move (type_param_bounds)), - mappings (std::move (mappings)) + mappings (std::move (mappings)), locus (locus) {} // Copy constructor requires clone diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 8bddfcd..52aba4f 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -3612,10 +3612,12 @@ Parser<ManagedTokenSource>::parse_type_bound_where_clause_item () std::vector<std::unique_ptr<AST::TypeParamBound>> type_param_bounds = parse_type_param_bounds (); + Location locus = lexer.peek_token ()->get_locus (); + return std::unique_ptr<AST::TypeBoundWhereClauseItem> ( new AST::TypeBoundWhereClauseItem (std::move (for_lifetimes), std::move (type), - std::move (type_param_bounds))); + std::move (type_param_bounds), locus)); } // Parses a for lifetimes clause, including the for keyword and angle brackets. |