From: Pierre-Emmanuel Patry Date: Wed, 28 Jun 2023 09:30:57 +0000 (+0200) Subject: gccrs: collector: Fix method self parameter X-Git-Tag: basepoints/gcc-15~2393 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac88cb00f73e7d3d3dbeb210b7e9e9d129b69952;p=thirdparty%2Fgcc.git gccrs: 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 --- diff --git a/gcc/rust/ast/rust-ast-collector.cc b/gcc/rust/ast/rust-ast-collector.cc index 7bf827e7bb75..04c0397a8b76 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