forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#130633 - eholk:pin-reborrow-self, r=compiler-errors Add support for reborrowing pinned method receivers This builds on rust-lang#130526 to add pinned reborrowing for method receivers. This enables the folllowing examples to work: ```rust #![feature(pin_ergonomics)] #![allow(incomplete_features)] use std::pin::Pin; pub struct Foo; impl Foo { fn foo(self: Pin<&mut Self>) { } fn baz(self: Pin<&Self>) { } } pub fn bar(x: Pin<&mut Foo>) { x.foo(); x.foo(); x.baz(); // Pin<&mut Foo> is downgraded to Pin<&Foo> } pub fn baaz(x: Pin<&Foo>) { x.baz(); x.baz(); } ``` This PR includes the original one, which is currently in the commit queue, but the only code changes are in the latest commit (d3c53aa). rust-lang#130494 r? `@compiler-errors`
- Loading branch information
Showing
7 changed files
with
171 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
//@ check-pass | ||
//@ignore-test | ||
|
||
// Currently ignored due to self reborrowing not being implemented for Pin | ||
|
||
#![feature(pin_ergonomics)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::pin::Pin; | ||
|
||
struct Foo; | ||
pub struct Foo; | ||
|
||
impl Foo { | ||
fn foo(self: Pin<&mut Self>) { | ||
} | ||
|
||
fn baz(self: Pin<&Self>) { | ||
} | ||
} | ||
|
||
fn bar(x: Pin<&mut Foo>) { | ||
pub fn bar(x: Pin<&mut Foo>) { | ||
x.foo(); | ||
x.foo(); // for this to work we need to automatically reborrow, | ||
// as if the user had written `x.as_mut().foo()`. | ||
|
||
Foo::baz(x); | ||
|
||
x.baz(); | ||
} | ||
|
||
pub fn baaz(x: Pin<&Foo>) { | ||
x.baz(); | ||
x.baz(); | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters