aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/checks/errors/rust-ast-validation.cc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-11-22 10:44:08 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-30 12:36:47 +0100
commit04b3089a47c5ccfb86b29a9c64157d5d4f755c1c (patch)
tree3c68ceeacba71ca19e635b380154a6e832da059b /gcc/rust/checks/errors/rust-ast-validation.cc
parent68990dbeadc5f4b90c0aa14387cb80d0f411aa43 (diff)
downloadgcc-04b3089a47c5ccfb86b29a9c64157d5d4f755c1c.zip
gcc-04b3089a47c5ccfb86b29a9c64157d5d4f755c1c.tar.gz
gcc-04b3089a47c5ccfb86b29a9c64157d5d4f755c1c.tar.bz2
gccrs: Add async const function ast validation pass
Add a check during AST validation pass to ensure functions are either const or async but not both. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add async const check. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/checks/errors/rust-ast-validation.cc')
-rw-r--r--gcc/rust/checks/errors/rust-ast-validation.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/rust/checks/errors/rust-ast-validation.cc b/gcc/rust/checks/errors/rust-ast-validation.cc
index 4b20990..54276e8 100644
--- a/gcc/rust/checks/errors/rust-ast-validation.cc
+++ b/gcc/rust/checks/errors/rust-ast-validation.cc
@@ -98,6 +98,11 @@ ASTValidation::visit (AST::Function &function)
std::set<Context> valid_context
= {Context::INHERENT_IMPL, Context::TRAIT_IMPL};
+ const auto &qualifiers = function.get_qualifiers ();
+ if (qualifiers.is_async () && qualifiers.is_const ())
+ rust_error_at (function.get_locus (),
+ "functions cannot be both %<const%> and %<async%>");
+
if (valid_context.find (context.back ()) == valid_context.end ()
&& function.has_self_param ())
rust_error_at (