Skip to content

Commit

Permalink
Fix pub unit type parsing
Browse files Browse the repository at this point in the history
Public unit types where not parsed correctly due to visibility specifiers
within parenthesis. Fixes #2648.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_visibility): Relax constraints
	over public visibility return condition in order to accept pub unit
	types.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
  • Loading branch information
P-E-P authored and philberty committed Oct 16, 2023
1 parent 2b4eb39 commit 1815409
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2296,8 +2296,11 @@ Parser<ManagedTokenSource>::parse_visibility ()
auto vis_loc = lexer.peek_token ()->get_locus ();
lexer.skip_token ();

// create simple pub visibility if no parentheses
if (lexer.peek_token ()->get_id () != LEFT_PAREN)
// create simple pub visibility if
// - found no parentheses
// - found unit type `()`
if (lexer.peek_token ()->get_id () != LEFT_PAREN
|| lexer.peek_token (1)->get_id () == RIGHT_PAREN)
{
return AST::Visibility::create_public (vis_loc);
// or whatever
Expand Down

0 comments on commit 1815409

Please sign in to comment.