diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-06-28 11:30:57 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-07-07 13:46:54 +0000 |
commit | b0da1695a86d2057ccd10b2b124f99c8fe335e82 (patch) | |
tree | bbc3c899146516a3e153d9014130f07fe9de7157 | |
parent | ff0e18be3f1e6bb848a479e7ff148eac61633d0d (diff) | |
download | gcc-b0da1695a86d2057ccd10b2b124f99c8fe335e82.zip gcc-b0da1695a86d2057ccd10b2b124f99c8fe335e82.tar.gz gcc-b0da1695a86d2057ccd10b2b124f99c8fe335e82.tar.bz2 |
collector: Fix method self parameter
Fix visitor for self parameter in methods.
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit): Fix self
param output.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r-- | gcc/rust/ast/rust-ast-collector.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gcc/rust/ast/rust-ast-collector.cc b/gcc/rust/ast/rust-ast-collector.cc index 7bf827e..04c0397 100644 --- a/gcc/rust/ast/rust-ast-collector.cc +++ b/gcc/rust/ast/rust-ast-collector.cc @@ -1600,7 +1600,7 @@ TokenCollector::visit (Method &method) push (Rust::Token::make_identifier (Location (), std::move (method_name))); push (Rust::Token::make (LEFT_PAREN, Location ())); - push (Rust::Token::make (SELF, Location ())); + visit (method.get_self_param ()); if (!method.get_function_params ().empty ()) { push (Rust::Token::make (COMMA, Location ())); @@ -2028,20 +2028,21 @@ TokenCollector::visit (SelfParam ¶m) { if (param.get_has_ref ()) { - push (Rust::Token::make (AMP, param.get_locus ())); + push (Rust::Token::make (AMP, Location ())); if (param.has_lifetime ()) { auto lifetime = param.get_lifetime (); visit (lifetime); } + if (param.get_is_mut ()) + push (Rust::Token::make (MUT, Location ())); } - - if (param.get_is_mut ()) + push (Rust::Token::make (SELF, Location ())); + if (param.has_type ()) { - push (Rust::Token::make (MUT, Location ())); + push (Rust::Token::make (COLON, Location ())); + visit (param.get_type ()); } - - push (Rust::Token::make (SELF, Location ())); } void |