-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
treatment of subtyping in trait matching is unsound #5781
Comments
nominating for maturity milestone 1: Well defined. |
I have a local fix for this that simply makes trait matching invariant. It causes a number of compilation errors. The proper fix is to infer variance (#3598). I agree with the nomination that without settling this, the language is not well-defined. |
accepted for well-defined milestone |
Note: work on variance inference is underway, so this should be addressable soon-ish. |
PR #10153 includes a general variance inference pass that should allow us to address this |
I believe this was accidentally fixed by DST, as @edwardw's code changes to variance were effectively introduced. I have rebased all test cases here and they are correctly rejected. Will close after a PR to add tests. |
… borrows still in scope". This issue was fixed by PR rust-lang#12828 and rust-lang#5781. All that was left was to add tests. Closes rust-lang#12223.
Fix a broken link in CONTRIBUTING.md changelog: none
We currently assume (at least in vtable.rs. though not in infer) that self types are contravariant. This is not sound since the
Self
type can appear anywhere, including return types.For example, this program compiles:
Note that we have "produced" a
*uint
even though there is no function in this program that returns one. In this case, it's harmless, but of course one can construct other more harmful examples (particularly if we add other forms of subtyping such as struct inheritance or datasort refinements).The fix is a straight-forward modification (search for FIXMEs) but it invalidates a number of existing impls based around
*const T
and I didn't feel like dealing with the fallout as part of the patch I'm working on.See also #3598---effectively we need a way to infer/declare variance for the Self parameter as well.
The text was updated successfully, but these errors were encountered: