Skip to content

Conversation

@P-E-P
Copy link
Member

@P-E-P P-E-P commented Nov 17, 2025

We made heavy use of error state within some AST node and it was the source of multiple errors, and caused confusion with (null) pointers. This commit removes some error state usage within our parser in an attempt to remove those error states later.

@P-E-P P-E-P marked this pull request as draft November 18, 2025 14:18
@P-E-P P-E-P force-pushed the parser_error_values branch 4 times, most recently from 8b3ff51 to 719a040 Compare November 20, 2025 17:14
@P-E-P P-E-P force-pushed the parser_error_values branch 9 times, most recently from d32440f to 393cac3 Compare December 3, 2025 12:08
@P-E-P P-E-P force-pushed the parser_error_values branch 6 times, most recently from 6bd7eeb to f9adc09 Compare December 3, 2025 21:11
@P-E-P P-E-P marked this pull request as ready for review December 3, 2025 21:11
We made heavy use of error state within some AST node and it was the
source of multiple errors, and caused confusion with (null) pointers.
This commit removes some error state use within our parser in an attempt
to remove those error states later.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_inner_attributes): Change
	return type to avoid empty/error values that may break invariants in
	the AST.
	(Parser::parse_inner_attribute): Likewise.
	(Parser::parse_outer_attribute): Likewise.
	(Parser::parse_outer_attributes): Likewise.
	(Parser::parse_attribute_body): Likewise.
	(Parser::parse_simple_path): Likewise.
	(Parser::parse_macro_invocation): Likewise.
	(Parser::parse_visibility): Likewise.
	(Parser::parse_use_tree): Likewise.
	(Parser::parse_delim_token_tree): Likewise.
	(Parser::parse_identifier_or_keyword_token): Likewise.
	(Parser::parse_token_tree): Likewise.
	(Parser::parse_macro_rules_def): Likewise.
	(Parser::parse_decl_macro_def): Likewise.
	(Parser::parse_macro_invocation): Likewise.
	(Parser::parse_macro_rule): Likewise.
	(Parser::parse_macro_matcher): Likewise.
	(Parser::parse_type_path_segment): Likewise.
	(Parser::parse_path_expr_segment): Likewise.
	(Parser::parse_type): Likewise.
	(Parser::parse_type_no_bounds): Likewise.
	(Parser::parse_items): Circumvent GCC 5 to 7 bug.
	(is_simple_path_segment): Move to utility file.
	(token_id_matches_delims): Likewise.
	(is_likely_path_next): Remove unused function.
	(Parser::parse_attr_input): Return a structure instead of a tuple.
	* expand/rust-macro-builtins-offset-of.cc: Adapt call to expected.
	* ast/rust-ast.cc (AttributeParser::parse_path_meta_item): Use empty
	vector when an error is encountered.
	* expand/rust-macro-builtins-include.cc: Likewise.
	* parse/rust-parse.h: Update prototypes.
	* parse/rust-parse-impl-proc-macro.cc: Likewise.
	* ast/rust-ast.h: Remove error state from Visibility.
	* ast/rust-item.h: Use private visibility instead of error.
	* ast/rust-macro.h: Likewise.
	* expand/rust-macro-expand.cc: Likewise.
	* hir/rust-ast-lower.cc: Remove error case.
	* rust-session-manager.cc: Use private visibility
	* parse/rust-parse-utils.h: New file.
	* parse/rust-parse-error.h: New file.

gcc/testsuite/ChangeLog:

	* rust/compile/macros/mbe/macro-issue3608.rs: Update error messages.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
@P-E-P P-E-P force-pushed the parser_error_values branch from f9adc09 to 3dccc1a Compare December 3, 2025 21:11
@P-E-P P-E-P added this pull request to the merge queue Dec 3, 2025
Merged via the queue into Rust-GCC:master with commit 40765b8 Dec 3, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant