diff options
| author | Frank King <frankking1729@gmail.com> | 2025-03-16 21:19:57 +0800 |
|---|---|---|
| committer | Frank King <frankking1729@gmail.com> | 2025-06-15 10:21:29 +0800 |
| commit | 2090f40770c37b78af02c4db3ee8fdbefd438dcf (patch) | |
| tree | a8068a0eb849c6a6caa3d1487eb58c9aeb1b8503 /tests/ui/async-await | |
| parent | e627f88f88de85cc52ff1c99a076909084806c98 (diff) | |
| download | rust-2090f40770c37b78af02c4db3ee8fdbefd438dcf.tar.gz rust-2090f40770c37b78af02c4db3ee8fdbefd438dcf.zip | |
Move `tests/ui/async-await/pin-ergonomics` to `tests/ui`
Diffstat (limited to 'tests/ui/async-await')
17 files changed, 0 insertions, 513 deletions
diff --git a/tests/ui/async-await/pin-ergonomics/borrow-mut-xor-share.rs b/tests/ui/async-await/pin-ergonomics/borrow-mut-xor-share.rs deleted file mode 100644 index c5363eafef5..00000000000 --- a/tests/ui/async-await/pin-ergonomics/borrow-mut-xor-share.rs +++ /dev/null @@ -1,59 +0,0 @@ -#![feature(pin_ergonomics)] -#![allow(dead_code, incomplete_features)] - -// Makes sure `&pin mut place` and `&pin const place` cannot violate the mut-xor-share rules. - -use std::pin::Pin; - -struct Foo; - -fn foo_mut(_: &mut Foo) { -} - -fn foo_ref(_: &Foo) { -} - -fn foo_pin_mut(_: Pin<&mut Foo>) { -} - -fn foo_pin_ref(_: Pin<&Foo>) { -} - -fn bar() { - let foo = Foo; - foo_pin_mut(&pin mut foo); //~ ERROR cannot borrow `foo` as mutable, as it is not declared as mutable - - let mut foo = Foo; - let x = &pin mut foo; - foo_pin_ref(&pin const foo); //~ ERROR cannot borrow `foo` as immutable because it is also borrowed as mutable - foo_pin_mut(&pin mut foo); //~ ERROR cannot borrow `foo` as mutable more than once at a time - foo_ref(&foo); //~ ERROR cannot borrow `foo` as immutable because it is also borrowed as mutable - foo_mut(&mut foo); //~ ERROR cannot borrow `foo` as mutable more than once at a time - - foo_pin_mut(x); - - let mut foo = Foo; - let x = &pin const foo; - foo_pin_ref(&pin const foo); // ok - foo_pin_mut(&pin mut foo); //~ ERROR cannot borrow `foo` as mutable because it is also borrowed as immutable - foo_ref(&foo); // ok - foo_mut(&mut foo); //~ ERROR cannot borrow `foo` as mutable because it is also borrowed as immutable - - foo_pin_ref(x); - - let mut foo = Foo; - let x = &mut foo; - foo_pin_ref(&pin const foo); //~ ERROR cannot borrow `foo` as immutable because it is also borrowed as mutable - foo_pin_mut(&pin mut foo); //~ ERROR cannot borrow `foo` as mutable more than once at a time - - foo_mut(x); - - let mut foo = Foo; - let x = &foo; - foo_pin_ref(&pin const foo); // ok - foo_pin_mut(&pin mut foo); //~ ERROR cannot borrow `foo` as mutable because it is also borrowed as immutable - - foo_ref(x); -} - -fn main() {} diff --git a/tests/ui/async-await/pin-ergonomics/borrow-mut-xor-share.stderr b/tests/ui/async-await/pin-ergonomics/borrow-mut-xor-share.stderr deleted file mode 100644 index 47d990b2ec9..00000000000 --- a/tests/ui/async-await/pin-ergonomics/borrow-mut-xor-share.stderr +++ /dev/null @@ -1,121 +0,0 @@ -error[E0596]: cannot borrow `foo` as mutable, as it is not declared as mutable - --> $DIR/borrow-mut-xor-share.rs:24:17 - | -LL | foo_pin_mut(&pin mut foo); - | ^^^^^^^^^^^^ cannot borrow as mutable - | -help: consider changing this to be mutable - | -LL | let mut foo = Foo; - | +++ - -error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable - --> $DIR/borrow-mut-xor-share.rs:28:17 - | -LL | let x = &pin mut foo; - | ------------ mutable borrow occurs here -LL | foo_pin_ref(&pin const foo); - | ^^^^^^^^^^^^^^ immutable borrow occurs here -... -LL | foo_pin_mut(x); - | - mutable borrow later used here - -error[E0499]: cannot borrow `foo` as mutable more than once at a time - --> $DIR/borrow-mut-xor-share.rs:29:17 - | -LL | let x = &pin mut foo; - | ------------ first mutable borrow occurs here -LL | foo_pin_ref(&pin const foo); -LL | foo_pin_mut(&pin mut foo); - | ^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | foo_pin_mut(x); - | - first borrow later used here - -error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable - --> $DIR/borrow-mut-xor-share.rs:30:13 - | -LL | let x = &pin mut foo; - | ------------ mutable borrow occurs here -... -LL | foo_ref(&foo); - | ^^^^ immutable borrow occurs here -... -LL | foo_pin_mut(x); - | - mutable borrow later used here - -error[E0499]: cannot borrow `foo` as mutable more than once at a time - --> $DIR/borrow-mut-xor-share.rs:31:13 - | -LL | let x = &pin mut foo; - | ------------ first mutable borrow occurs here -... -LL | foo_mut(&mut foo); - | ^^^^^^^^ second mutable borrow occurs here -LL | -LL | foo_pin_mut(x); - | - first borrow later used here - -error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable - --> $DIR/borrow-mut-xor-share.rs:38:17 - | -LL | let x = &pin const foo; - | -------------- immutable borrow occurs here -LL | foo_pin_ref(&pin const foo); // ok -LL | foo_pin_mut(&pin mut foo); - | ^^^^^^^^^^^^ mutable borrow occurs here -... -LL | foo_pin_ref(x); - | - immutable borrow later used here - -error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable - --> $DIR/borrow-mut-xor-share.rs:40:13 - | -LL | let x = &pin const foo; - | -------------- immutable borrow occurs here -... -LL | foo_mut(&mut foo); - | ^^^^^^^^ mutable borrow occurs here -LL | -LL | foo_pin_ref(x); - | - immutable borrow later used here - -error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable - --> $DIR/borrow-mut-xor-share.rs:46:17 - | -LL | let x = &mut foo; - | -------- mutable borrow occurs here -LL | foo_pin_ref(&pin const foo); - | ^^^^^^^^^^^^^^ immutable borrow occurs here -... -LL | foo_mut(x); - | - mutable borrow later used here - -error[E0499]: cannot borrow `foo` as mutable more than once at a time - --> $DIR/borrow-mut-xor-share.rs:47:17 - | -LL | let x = &mut foo; - | -------- first mutable borrow occurs here -LL | foo_pin_ref(&pin const foo); -LL | foo_pin_mut(&pin mut foo); - | ^^^^^^^^^^^^ second mutable borrow occurs here -LL | -LL | foo_mut(x); - | - first borrow later used here - -error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable - --> $DIR/borrow-mut-xor-share.rs:54:17 - | -LL | let x = &foo; - | ---- immutable borrow occurs here -LL | foo_pin_ref(&pin const foo); // ok -LL | foo_pin_mut(&pin mut foo); - | ^^^^^^^^^^^^ mutable borrow occurs here -LL | -LL | foo_ref(x); - | - immutable borrow later used here - -error: aborting due to 10 previous errors - -Some errors have detailed explanations: E0499, E0502, E0596. -For more information about an error, try `rustc --explain E0499`. diff --git a/tests/ui/async-await/pin-ergonomics/borrow.rs b/tests/ui/async-await/pin-ergonomics/borrow.rs deleted file mode 100644 index e33f3c1fa26..00000000000 --- a/tests/ui/async-await/pin-ergonomics/borrow.rs +++ /dev/null @@ -1,31 +0,0 @@ -//@ check-pass - -#![feature(pin_ergonomics)] -#![allow(dead_code, incomplete_features)] - -// Makes sure we can handle `&pin mut place` and `&pin const place` as sugar for -// `unsafe { Pin::new_unchecked(&mut place) }` and `Pin::new(&place)`. - -use std::pin::Pin; - -struct Foo; - -fn foo_pin_mut(_: Pin<&mut Foo>) { -} - -fn foo_pin_ref(_: Pin<&Foo>) { -} - -fn bar() { - let mut x: Pin<&mut _> = &pin mut Foo; - foo_pin_mut(x.as_mut()); - foo_pin_mut(x.as_mut()); - foo_pin_ref(x); - - let x: Pin<&_> = &pin const Foo; - - foo_pin_ref(x); - foo_pin_ref(x); -} - -fn main() {} diff --git a/tests/ui/async-await/pin-ergonomics/coerce-non-pointer-pin.rs b/tests/ui/async-await/pin-ergonomics/coerce-non-pointer-pin.rs deleted file mode 100644 index a95665f126d..00000000000 --- a/tests/ui/async-await/pin-ergonomics/coerce-non-pointer-pin.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ check-pass - -#![feature(pin_ergonomics)] -//~^ WARN the feature `pin_ergonomics` is incomplete - -use std::pin::Pin; - -fn main() { - let _: Pin<Box<()>> = Box::pin(()); -} diff --git a/tests/ui/async-await/pin-ergonomics/coerce-non-pointer-pin.stderr b/tests/ui/async-await/pin-ergonomics/coerce-non-pointer-pin.stderr deleted file mode 100644 index 2deb5b09884..00000000000 --- a/tests/ui/async-await/pin-ergonomics/coerce-non-pointer-pin.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `pin_ergonomics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/coerce-non-pointer-pin.rs:3:12 - | -LL | #![feature(pin_ergonomics)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #130494 <https://github.com/rust-lang/rust/issues/130494> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-arg.rs b/tests/ui/async-await/pin-ergonomics/reborrow-arg.rs deleted file mode 100644 index 2008bd1f52d..00000000000 --- a/tests/ui/async-await/pin-ergonomics/reborrow-arg.rs +++ /dev/null @@ -1,36 +0,0 @@ -//@ check-pass - -#![feature(pin_ergonomics)] -#![allow(dead_code, incomplete_features)] - -use std::pin::Pin; - -struct Foo; - -impl Foo { - fn baz(self: Pin<&mut Self>) { - } -} - -fn foo(_: Pin<&mut Foo>) { -} - -fn foo_const(_: Pin<&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); - - foo_const(x); // make sure we can reborrow &mut as &. - - let x: Pin<&Foo> = Pin::new(&Foo); - - foo_const(x); // make sure reborrowing from & to & works. -} - -fn main() {} diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-const-as-mut.rs b/tests/ui/async-await/pin-ergonomics/reborrow-const-as-mut.rs deleted file mode 100644 index 27c70a7b4df..00000000000 --- a/tests/ui/async-await/pin-ergonomics/reborrow-const-as-mut.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(pin_ergonomics)] -#![allow(dead_code, incomplete_features)] - -// make sure we can't accidentally reborrow Pin<&T> as Pin<&mut T> - -use std::pin::Pin; - -struct Foo; - -fn foo(_: Pin<&mut Foo>) { -} - -fn bar(x: Pin<&Foo>) { - foo(x); //~ ERROR mismatched types - //| ERROR types differ in mutability -} - -fn main() {} diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-const-as-mut.stderr b/tests/ui/async-await/pin-ergonomics/reborrow-const-as-mut.stderr deleted file mode 100644 index 36bbf1c493a..00000000000 --- a/tests/ui/async-await/pin-ergonomics/reborrow-const-as-mut.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/reborrow-const-as-mut.rs:14:9 - | -LL | foo(x); - | --- ^ types differ in mutability - | | - | arguments to this function are incorrect - | - = note: expected struct `Pin<&mut Foo>` - found struct `Pin<&Foo>` -note: function defined here - --> $DIR/reborrow-const-as-mut.rs:10:4 - | -LL | fn foo(_: Pin<&mut Foo>) { - | ^^^ ---------------- - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-once.rs b/tests/ui/async-await/pin-ergonomics/reborrow-once.rs deleted file mode 100644 index 241efadef7d..00000000000 --- a/tests/ui/async-await/pin-ergonomics/reborrow-once.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(pin_ergonomics)] -#![allow(dead_code, incomplete_features)] - -// Make sure with pin reborrowing that we can only get one mutable reborrow of a pinned reference. - -use std::pin::{pin, Pin}; - -fn twice(_: Pin<&mut i32>, _: Pin<&mut i32>) {} - -fn main() { - let x = pin!(42); - twice(x, x); //~ ERROR cannot borrow -} diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-once.stderr b/tests/ui/async-await/pin-ergonomics/reborrow-once.stderr deleted file mode 100644 index dc8e424ad2a..00000000000 --- a/tests/ui/async-await/pin-ergonomics/reborrow-once.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0499]: cannot borrow `*x.pointer` as mutable more than once at a time - --> $DIR/reborrow-once.rs:12:14 - | -LL | twice(x, x); - | ----- - ^ second mutable borrow occurs here - | | | - | | first mutable borrow occurs here - | first borrow later used by call - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-self.rs b/tests/ui/async-await/pin-ergonomics/reborrow-self.rs deleted file mode 100644 index ee617617da0..00000000000 --- a/tests/ui/async-await/pin-ergonomics/reborrow-self.rs +++ /dev/null @@ -1,33 +0,0 @@ -//@ check-pass - -#![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(); // 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() {} diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-shorter.rs b/tests/ui/async-await/pin-ergonomics/reborrow-shorter.rs deleted file mode 100644 index 06c266e0035..00000000000 --- a/tests/ui/async-await/pin-ergonomics/reborrow-shorter.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@check-pass - -#![feature(pin_ergonomics)] -#![allow(dead_code, incomplete_features)] - -use std::pin::Pin; - -fn shorter<'b, T: 'b>(_: Pin<&'b mut T>) {} - -fn test<'a: 'b, 'b, T: 'a>(x: Pin<&'a mut T>) { - shorter::<'b>(x); -} - -fn main() {} diff --git a/tests/ui/async-await/pin-ergonomics/sugar-ambiguity.rs b/tests/ui/async-await/pin-ergonomics/sugar-ambiguity.rs deleted file mode 100644 index d183000931e..00000000000 --- a/tests/ui/async-await/pin-ergonomics/sugar-ambiguity.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ check-pass -#![feature(pin_ergonomics)] -#![allow(dead_code, incomplete_features)] - -// Handle the case where there's ambiguity between pin as a contextual keyword and pin as a path. - -struct Foo; - -mod pin { - pub struct Foo; -} - -fn main() { - let _x: &pin ::Foo = &pin::Foo; -} diff --git a/tests/ui/async-await/pin-ergonomics/sugar-no-const.rs b/tests/ui/async-await/pin-ergonomics/sugar-no-const.rs deleted file mode 100644 index dd6456b6034..00000000000 --- a/tests/ui/async-await/pin-ergonomics/sugar-no-const.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![feature(pin_ergonomics)] -#![allow(incomplete_features)] - -// Makes sure we don't accidentally accept `&pin Foo` without the `const` keyword. - -fn main() { - let _x: &pin i32 = todo!(); //~ ERROR found `i32` -} diff --git a/tests/ui/async-await/pin-ergonomics/sugar-no-const.stderr b/tests/ui/async-await/pin-ergonomics/sugar-no-const.stderr deleted file mode 100644 index 062b6d3f487..00000000000 --- a/tests/ui/async-await/pin-ergonomics/sugar-no-const.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: expected one of `!`, `(`, `::`, `;`, `<`, or `=`, found `i32` - --> $DIR/sugar-no-const.rs:7:18 - | -LL | let _x: &pin i32 = todo!(); - | - ^^^ expected one of `!`, `(`, `::`, `;`, `<`, or `=` - | | - | while parsing the type for `_x` - | -help: there is a keyword `in` with a similar name - | -LL - let _x: &pin i32 = todo!(); -LL + let _x: &in i32 = todo!(); - | - -error: aborting due to 1 previous error - diff --git a/tests/ui/async-await/pin-ergonomics/sugar-self.rs b/tests/ui/async-await/pin-ergonomics/sugar-self.rs deleted file mode 100644 index 3d71b54b1ae..00000000000 --- a/tests/ui/async-await/pin-ergonomics/sugar-self.rs +++ /dev/null @@ -1,46 +0,0 @@ -//@ check-pass - -#![feature(pin_ergonomics)] -#![allow(dead_code, incomplete_features)] - -// Makes sure we can handle `&pin mut self` and `&pin const self` as sugar for -// `self: Pin<&mut Self>` and `self: Pin<&Self>`. - -use std::pin::Pin; - -struct Foo; - -impl Foo { - fn baz(&pin mut self) {} - - fn baz_const(&pin const self) {} - - fn baz_lt<'a>(&'a pin mut self) {} - - fn baz_const_lt(&'_ pin const self) {} -} - -fn foo(_: &pin mut Foo) {} - -fn foo_const(_: &pin const Foo) {} - -fn bar(x: &pin mut Foo) { - // For the calls below to work we need to automatically reborrow, - // as if the user had written `foo(x.as_mut())`. - foo(x); - foo(x); - - 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() {} diff --git a/tests/ui/async-await/pin-ergonomics/sugar.rs b/tests/ui/async-await/pin-ergonomics/sugar.rs deleted file mode 100644 index 8dbdec418b1..00000000000 --- a/tests/ui/async-await/pin-ergonomics/sugar.rs +++ /dev/null @@ -1,51 +0,0 @@ -//@ 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() {} |
