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

Prevent coercion before distributed slice typecheck #83

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

CAD97
Copy link
Contributor

@CAD97 CAD97 commented Mar 6, 2024

Fixes #82

We use a fn() -> &T to prevent value coercions from applying. This does allow contravariant coercion to a subtype (a shorter lifetime), but I believe that since #ty is in a static (cannot contain lifetimes other than the top lifetime 'static) that this is not an exploitable hole. If a hole remains, it's probably to do with for<'a> lifetime binders.

I did test a few methods that fully constrain T to be invariant (e.g. fn(T) -> T), but they all worsened the error messages more than this does, and this appears to be sufficient.

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Good catch.

@dtolnay dtolnay merged commit 0134d31 into dtolnay:master Mar 6, 2024
13 checks passed
@CAD97 CAD97 deleted the slice-coercion-fix branch March 6, 2024 05:20
@dtolnay
Copy link
Owner

dtolnay commented Mar 6, 2024

Published to crates.io in 0.3.24, and also reported as rustsec/advisory-db#1917.

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.

Coercion bypasses DistributedSlice typecheck
2 participants