From b0da1695a86d2057ccd10b2b124f99c8fe335e82 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Wed, 28 Jun 2023 11:30:57 +0200 Subject: 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 --- gcc/rust/ast/rust-ast-collector.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'gcc') 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 -- cgit v1.1