-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Reject specialized Drop impls. #23638
Merged
bors
merged 11 commits into
rust-lang:master
from
pnkfelix:fsk-reject-specialized-drops
Mar 25, 2015
Merged
Reject specialized Drop impls. #23638
bors
merged 11 commits into
rust-lang:master
from
pnkfelix:fsk-reject-specialized-drops
Mar 25, 2015
Commits on Mar 24, 2015
-
Remove unnecessary bounds from Drop impl for
Arc
andarc::Weak
andone of the helper method impls.
Configuration menu - View commit details
-
Copy full SHA for 5fa4b4c - Browse repository at this point
Copy the full SHA 5fa4b4cView commit details -
Added
T:Send
bound tosync::mpsc::Receiver
andsync::mpsc::Sender
.This was necessary to avoid specialized `Drop` impls for the two structs.
Configuration menu - View commit details
-
Copy full SHA for 0adab50 - Browse repository at this point
Copy the full SHA 0adab50View commit details -
Configuration menu - View commit details
-
Copy full SHA for 26a79e3 - Browse repository at this point
Copy the full SHA 26a79e3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1249e60 - Browse repository at this point
Copy the full SHA 1249e60View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1e71d2e - Browse repository at this point
Copy the full SHA 1e71d2eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 018eeb7 - Browse repository at this point
Copy the full SHA 018eeb7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 123b5c1 - Browse repository at this point
Copy the full SHA 123b5c1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5f57fd5 - Browse repository at this point
Copy the full SHA 5f57fd5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 290c8de - Browse repository at this point
Copy the full SHA 290c8deView commit details -
Reject specialized Drop impls.
See Issue 8142 for discussion. This makes it illegal for a Drop impl to be more specialized than the original item. So for example, all of the following are now rejected (when they would have been blindly accepted before): ```rust struct S<A> { ... }; impl Drop for S<i8> { ... } // error: specialized to concrete type struct T<'a> { ... }; impl Drop for T<'static> { ... } // error: specialized to concrete region struct U<A> { ... }; impl<A:Clone> Drop for U<A> { ... } // error: added extra type requirement struct V<'a,'b>; impl<'a,'b:a> Drop for V<'a,'b> { ... } // error: added extra region requirement ``` Due to examples like the above, this is a [breaking-change]. (The fix is to either remove the specialization from the `Drop` impl, or to transcribe the requirements into the struct/enum definition; examples of both are shown in the PR's fixed to `libstd`.) ---- This is likely to be the last thing blocking the removal of the `#[unsafe_destructor]` attribute. Includes two new error codes for the new dropck check. Update run-pass tests to accommodate new dropck pass. Update tests and docs to reflect new destructor restriction. ---- Implementation notes: We identify Drop impl specialization by not being as parametric as the struct/enum definition via unification. More specifically: 1. Attempt unification of a skolemized instance of the struct/enum with an instance of the Drop impl's type expression where all of the impl's generics (i.e. the free variables of the type expression) have been replaced with unification variables. 2. If unification fails, then reject Drop impl as specialized. 3. If unification succeeds, check if any of the skolemized variables "leaked" into the constraint set for the inference context; if so, then reject Drop impl as specialized. 4. Otherwise, unification succeeded without leaking skolemized variables: accept the Drop impl. We identify whether a Drop impl is injecting new predicates by simply looking whether the predicate, after an appropriate substitution, appears on the struct/enum definition.
Configuration menu - View commit details
-
Copy full SHA for 5b2e869 - Browse repository at this point
Copy the full SHA 5b2e869View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1955e05 - Browse repository at this point
Copy the full SHA 1955e05View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.