Skip to content

Commit

Permalink
WIP more fixes
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc (TokenCollector::visit):
	* expand/rust-cfg-strip.cc:
	* expand/rust-expand-visitor.cc:
	* resolve/rust-ast-resolve-item.cc (ResolveItem::visit):
	* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
  • Loading branch information
P-E-P committed Nov 13, 2023
1 parent 9ead3de commit 959aa8f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
15 changes: 1 addition & 14 deletions gcc/rust/ast/rust-ast-collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1795,13 +1795,6 @@ TokenCollector::visit (Function &function)

push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));

if (function.has_self_param ())
{
visit (function.get_self_param ());
if (!function.get_function_params ().empty ())
push (Rust::Token::make (COMMA, UNDEF_LOCATION));
}

visit_items_joined_by_separator (function.get_function_params ());
push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));

Expand Down Expand Up @@ -2081,13 +2074,7 @@ TokenCollector::visit (TraitItemMethod &item)
push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));

visit (method.get_self_param ());

if (!method.get_function_params ().empty ())
{
push (Rust::Token::make (COMMA, UNDEF_LOCATION));
visit_items_joined_by_separator (method.get_function_params (), COMMA);
}
visit_items_joined_by_separator (method.get_function_params (), COMMA);

push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));

Expand Down
5 changes: 2 additions & 3 deletions gcc/rust/expand/rust-cfg-strip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,9 @@ CfgStrip::maybe_strip_function_params (
if (type->is_marked_for_strip ())
rust_error_at (type->get_locus (),
"cannot strip type in this position");

// increment
++it;
}
// increment
++it;
}
}

Expand Down
4 changes: 1 addition & 3 deletions gcc/rust/expand/rust-expand-visitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,7 @@ ExpandVisitor::expand_function_params (
std::vector<std::unique_ptr<AST::Param>> &params)
{
for (auto &p : params)
{
visit (p);
}
visit (p);
}

void
Expand Down
8 changes: 5 additions & 3 deletions gcc/rust/resolve/rust-ast-resolve-item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -596,13 +596,15 @@ ResolveItem::visit (AST::Function &function)
if (p->is_variadic ())
{
auto param = static_cast<AST::VariadicParam *> (p.get ());
PatternDeclaration::go (param->get_pattern ().get (),
Rib::ItemType::Param, bindings);
if (param->has_pattern ())
PatternDeclaration::go (param->get_pattern ().get (),
Rib::ItemType::Param, bindings);
}
else if (p->is_self ())
{
auto param = static_cast<AST::SelfParam *> (p.get ());
ResolveType::go (param->get_type ().get ());
if (param->has_type ())
ResolveType::go (param->get_type ().get ());
}
else
{
Expand Down
9 changes: 6 additions & 3 deletions gcc/rust/resolve/rust-early-name-resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,8 @@ EarlyNameResolver::visit (AST::BareFunctionType &type)
void
EarlyNameResolver::visit (AST::VariadicParam &param)
{
param.get_pattern ()->accept_vis (*this);
if (param.has_pattern ())
param.get_pattern ()->accept_vis (*this);
}

void
Expand All @@ -1245,8 +1246,10 @@ EarlyNameResolver::visit (AST::FunctionParam &param)
void
EarlyNameResolver::visit (AST::SelfParam &param)
{
param.get_type ()->accept_vis (*this);
param.get_lifetime ().accept_vis (*this);
if (param.has_type ())
param.get_type ()->accept_vis (*this);
if (param.has_lifetime ())
param.get_lifetime ().accept_vis (*this);
}

} // namespace Resolver
Expand Down

0 comments on commit 959aa8f

Please sign in to comment.