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

Stabilize Rc, Arc and Pin as method receivers #56805

Merged
merged 3 commits into from
Dec 22, 2018

Commits on Dec 20, 2018

  1. Stabilize Rc, Arc and Pin as method receivers

    This lets you write methods using `self: Rc<Self>`, `self: Arc<Self>`, `self: Pin<&mut Self>`, `self: Pin<Box<Self>`, and other combinations involving `Pin` and another stdlib receiver type, without needing the `arbitrary_self_types`. Other user-created receiver types can be used, but they still require the feature flag to use.
    
    This is implemented by introducing a new trait, `Receiver`, which the method receiver's type must implement if the `arbitrary_self_types` feature is not enabled. To keep composed receiver types such as `&Arc<Self>` unstable, the receiver type is also required to implement `Deref<Target=Self>` when the feature flag is not enabled.
    
    This lets you use `self: Rc<Self>` and `self: Arc<Self>` in stable Rust, which was not allowed previously. It was agreed that they would be stabilized in rust-lang#55786. `self: Pin<&Self>` and other pinned receiver types do not require the `arbitrary_self_types` feature, but they cannot be used on stable because `Pin` still requires the `pin` feature.
    mikeyhew committed Dec 20, 2018
    Configuration menu
    Copy the full SHA
    153f5a7 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1d93c61 View commit details
    Browse the repository at this point in the history
  3. Refactor and add comments to code in receiver_is_valid

    also updated some error messages
    
    removed the code manually checking for `receiver_ty: Deref<Target=self_ty>`, in favour of using autoderef but only doing one iteration. This will cause error messages to be more consistent. Before, a "mismatched method receiver" error would be emitted when `receiver_ty` was valid except for a lifetime parameter, but only when `feature(arbitrary_self_types)` was enabled, and without the feature flag the error would be "uncoercible receiver". Now it emits "mismatched method receiver" in both cases.
    mikeyhew committed Dec 20, 2018
    Configuration menu
    Copy the full SHA
    286503a View commit details
    Browse the repository at this point in the history