diff options
| author | Gary Guo <gary@garyguo.net> | 2026-05-01 20:50:50 +0100 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2026-10-11 11:06:46 +0100 |
| commit | 71293ee9f3a8b222dc72bfa41275bd05c29eedbd (patch) | |
| tree | e66898aa92a33f6b45707627738069722dbe6842 /tools/perf/scripts/python/export-to-sqlite.py | |
| parent | 29213c00ccaa55e8ba01cfc79a93e000b0fcacc4 (diff) | |
rust: pin-init: internal: pin_data: self-referential drop order checks
Check drop order to ensure that usage of lifetime inside self-referential
struct is consistent with the order that the fields will dropped in drop
glue.
First, fields are checked according to their index to ensure that if `a`
borrows from `b`, `b` must outlive `a`. This is simple and produces a very
good diagnostic when misused.
Lifetime bounds can also be indirectly crafted with implied bounds that
make fields well-formed. For example, in this struct
struct Foo {
x: &'b &'a (),
a: String,
y: PrintOnDrop<&'b str>,
b: String,
}
`&'b &'a ()` will imply that `a` outlive `b`, which is inconsistent with
the actual drop order. For this case, create a `__drop_order_check`
function with field lifetimes and outlive relationship of them as generic
parameter, and ask Rust to prove that the types are well-formed inside the
generated function, to ensure that the bad implied bounds cannot happen.
The `__drop_order_check` also need to correlate lifetimes or types captured
by generics and the field lifetimes. Do this by inserting outlive bounds
when a field mentions a specific type or lifetime parameter.
Acked-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20261008-dev-selfref-v2-6-e280b3c8fba5@garyguo.net/
Signed-off-by: Gary Guo <gary@garyguo.net>
Diffstat (limited to 'tools/perf/scripts/python/export-to-sqlite.py')
0 files changed, 0 insertions, 0 deletions
