Ppx_inline_test: "Attributes not allowed here"

I’m new to using ppx and I’m having difficulty understanding what is wrong with my testing setup. The error that I am getting is:

         ppx .../automation/dnet/substitution.pp.ml (exit 1)
File "_none_", lines 1-244:
Error: Attributes not allowed here

Any pointers in this respect would be greatly appreciated. I am currently on ocaml 4.14.2 and things seem to work on ocaml 5 in a fresh project, but this project does not yet build on ocaml 5.

Here is the code:

(* this is at the end of the .ml file, not inside any module *)
let%test "subst_restrict_canonicalize_int_empty" =
  let _, subst = fresh 10 empty in
  let new_subst = subst_restrict_canonicalize_int ~max_var:3 subst in
  new_subst.max_var = 3
  && VM.is_empty new_subst.subst

and my dune file contains:

(include_subdirs qualified)
(library
 (name automation)
 (public_name ...)
 (libraries ...)
 (ocamlopt_flags :standard -g)
 (inline_tests)
 (preprocess (pps ppx_inline_test))
)

I am building on

$ ocamlc -v
The OCaml compiler, version 4.14.2

The error was that I had a docstring comment before the let, e.g.

(** this test computes ... *)
let%test "foo" = ...

Which apparently is not allowed, but the error message is not very helpful.