Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform FSA on a GC entry point's return type #143

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

jacob-hughes
Copy link
Collaborator

Previously, when we encountered a GC FSA entry-point (e.g. Gc::new) we performed FSA on the argument type of that entry point. When Gc::new was our only entry point, this worked fine, because it would always resolve to the T in Gc<T>.

However, with the addition the of Gc::from conversion trait entry point, we can end up being overly conservative with FSA for no good reason. Consider the following:

    let x: Gc<HasRef> = Gc::from(Box::new(HasRef::default()));

Where the argument type to this entry-point is Box<HasRef>, but the actual constructed Gc type is Gc<HasRef>. Using our previous approach, we would have to perform FSA on Box<HasRef>, even though the Box is never used in the context of GC. On large codebases, this lead to FSA rejecting sound Gc<T>s.

This commit therefore tweaks FSA to check the return type of an entry-point, which should always be some Gc<T> (we assert! this, because if it isn't, something has gone very wrong.)

Previously, when we encountered a GC FSA entry-point (e.g. `Gc::new`) we
performed FSA on the argument type of that entry point. When `Gc::new`
was our only entry point, this worked fine, because it would always
resolve to the `T` in `Gc<T>`.

However, with the addition the of `Gc::from` conversion trait entry
point, we can end up being overly conservative with FSA for no good
reason. Consider the following:

```rust
    let x: Gc<HasRef> = Gc::from(Box::new(HasRef::default()));
```

Where the argument type to this entry-point is `Box<HasRef>`, but the
actual constructed `Gc` type is `Gc<HasRef>`. Using our previous
approach, we would have to perform FSA on `Box<HasRef>`, even though the
`Box` is never used in the context of GC. On large codebases, this lead
to FSA rejecting sound `Gc<T>`s.

This commit therefore tweaks FSA to check the return type of an
entry-point, which should always be some `Gc<T>` (we assert! this,
because if it isn't, something has gone very wrong.)
@ltratt ltratt added this pull request to the merge queue Nov 11, 2024
Merged via the queue into softdevteam:master with commit d7f9891 Nov 11, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants