blob: 8dbdec418b1faffc4a13f283040c5fc4349ca7ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
//@ check-pass
#![feature(pin_ergonomics)]
#![allow(dead_code, incomplete_features)]
// Makes sure we can handle `&pin mut T` and `&pin const T` as sugar for `Pin<&mut T>` and
// `Pin<&T>`.
use std::pin::Pin;
struct Foo;
impl Foo {
fn baz(self: &pin mut Self) {
}
fn baz_const(self: &pin const Self) {
}
fn baz_lt<'a>(self: &'a pin mut Self) {
}
fn baz_const_lt(self: &'_ pin const Self) {
}
}
fn foo(_: &pin mut Foo) {
}
fn foo_const(x: &pin const Foo) {
}
fn bar(x: &pin mut Foo) {
foo(x);
foo(x); // for this to work we need to automatically reborrow,
// as if the user had written `foo(x.as_mut())`.
Foo::baz(x);
Foo::baz(x);
// make sure we can reborrow &mut as &.
foo_const(x);
Foo::baz_const(x);
let x: &pin const _ = Pin::new(&Foo);
foo_const(x); // make sure reborrowing from & to & works.
foo_const(x);
}
fn main() {}
|