]> gcc.gnu.org Git - gcc.git/commitdiff
gccrs: Add async const function ast validation pass
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 22 Nov 2023 09:44:08 +0000 (10:44 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 30 Jan 2024 11:36:47 +0000 (12:36 +0100)
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>
gcc/rust/checks/errors/rust-ast-validation.cc

index 4b209908f9e52e52cb05f2775f0b1a94e40f2c71..54276e8fd599af1bed86070428a5d1b7135dab0d 100644 (file)
@@ -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 (
This page took 0.073658 seconds and 5 git commands to generate.