Rust: store in the DB if a library function or const had a body

When skipping bodies in library code, we lose the information whether a
body was originally present. This can be important, for example when
determining whether a trait method has a default implementation.

With this change that information can be recovered via the
`hasImplementation` predicate.
This commit is contained in:
Paolo Tranquilli
2025-06-02 16:15:37 +02:00
parent 77c40da51a
commit 667eed9b9b
11 changed files with 109 additions and 13 deletions

View File

@@ -951,6 +951,10 @@ class _:
todo!()
```
"""
has_implementation: predicate | doc("this constant has an implementation") | desc("""
This is the same as `hasBody` for source code, but for library code (for which we always skip
the body), this will hold when the body was present in the original code.
""") | rust.detach
@annotate(ConstArg)
@@ -1882,6 +1886,10 @@ class _:
class _:
param_list: drop
attrs: drop
has_implementation: predicate | doc("this function has an implementation") | desc("""
This is the same as `hasBody` for source code, but for library code (for which we always skip
the body), this will hold when the body was present in the original code.
""") | rust.detach
@annotate(ClosureExpr, add_bases=[Callable])