diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-11-21 18:51:21 +0100 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2023-11-29 23:37:08 +0000 |
commit | 26ac74e2a8e0823218cc84724b49723fd1d437f9 (patch) | |
tree | 70de7f2202dcb08ad877c6ea00ecf0e3a82dcf92 /gcc/rust/parse | |
parent | 3eb942857dfdfbc099d36fe878f55d9e690c143e (diff) | |
download | gcc-26ac74e2a8e0823218cc84724b49723fd1d437f9.zip gcc-26ac74e2a8e0823218cc84724b49723fd1d437f9.tar.gz gcc-26ac74e2a8e0823218cc84724b49723fd1d437f9.tar.bz2 |
Emit an error on unsafe modules
An error should be emitted on unsafe modules during the AST validation
pass as the syntax allows those even though they're not alowed later down
the line.
gcc/rust/ChangeLog:
* ast/rust-item.h: Add safety getter to modules.
* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Check
a module's safety and emit an error when meeting an unsafe module.
* checks/errors/rust-ast-validation.h: Add function prototype.
* parse/rust-parse-impl.h (Parser::parse_module): Move the module locus
to the first token instead of the mod keyword.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/parse')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 8258d6f..5d4865d 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -2429,6 +2429,8 @@ std::unique_ptr<AST::Module> Parser<ManagedTokenSource>::parse_module (AST::Visibility vis, AST::AttrVec outer_attrs) { + location_t locus = lexer.peek_token ()->get_locus (); + Unsafety safety = Unsafety::Normal; if (lexer.peek_token ()->get_id () == UNSAFE) { @@ -2436,7 +2438,6 @@ Parser<ManagedTokenSource>::parse_module (AST::Visibility vis, skip_token (UNSAFE); } - location_t locus = lexer.peek_token ()->get_locus (); skip_token (MOD); const_TokenPtr module_name = expect_token (IDENTIFIER); |