Skip to content

Commit

Permalink
Split out method receivers in feature gate test
Browse files Browse the repository at this point in the history
  • Loading branch information
eholk committed Oct 1, 2024
1 parent 3dfb30c commit 9b52fb5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
4 changes: 3 additions & 1 deletion tests/ui/feature-gates/feature-gate-pin_ergonomics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ fn foo(_: Pin<&mut Foo>) {
fn bar(mut x: Pin<&mut Foo>) {
foo(x);
foo(x); //~ ERROR use of moved value: `x`
}

x.foo(); //~ ERROR use of moved value: `x`
fn baz(mut x: Pin<&mut Foo>) {
x.foo();
x.foo(); //~ ERROR use of moved value: `x`
}

Expand Down
27 changes: 3 additions & 24 deletions tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,10 @@ LL | fn foo(_: Pin<&mut Foo>) {
| in this function

error[E0382]: use of moved value: `x`
--> $DIR/feature-gate-pin_ergonomics.rs:19:5
--> $DIR/feature-gate-pin_ergonomics.rs:22:5
|
LL | fn bar(mut x: Pin<&mut Foo>) {
| ----- move occurs because `x` has type `Pin<&mut Foo>`, which does not implement the `Copy` trait
LL | foo(x);
LL | foo(x);
| - value moved here
LL |
LL | x.foo();
| ^ value used here after move
|
note: consider changing this parameter type in function `foo` to borrow instead if owning the value isn't necessary
--> $DIR/feature-gate-pin_ergonomics.rs:12:11
|
LL | fn foo(_: Pin<&mut Foo>) {
| --- ^^^^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function

error[E0382]: use of moved value: `x`
--> $DIR/feature-gate-pin_ergonomics.rs:20:5
|
LL | fn bar(mut x: Pin<&mut Foo>) {
LL | fn baz(mut x: Pin<&mut Foo>) {
| ----- move occurs because `x` has type `Pin<&mut Foo>`, which does not implement the `Copy` trait
...
LL | x.foo();
| ----- `x` moved due to this method call
LL | x.foo();
Expand All @@ -57,6 +36,6 @@ help: consider reborrowing the `Pin` instead of moving it
LL | x.as_mut().foo();
| +++++++++

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0382`.

0 comments on commit 9b52fb5

Please sign in to comment.