Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Do not use gen as binding name
If we ever start testing every edition, using a new keyword unnecessarily will cause divergent output, so pre-emptively change `gen` into `generator`.
  • Loading branch information
estebank committed Jun 25, 2025
commit f1fb323dda177b0e39ef1c9dcdfc1190e7c107ee
12 changes: 6 additions & 6 deletions tests/ui/coroutine/auto-trait-regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,31 @@ fn assert_foo<T: Foo>(f: T) {}
fn main() {
// Make sure 'static is erased for coroutine interiors so we can't match it in trait selection
let x: &'static _ = &OnlyFooIfStaticRef(No);
let gen = #[coroutine] move || {
let generator = #[coroutine] move || {
let x = x;
yield;
assert_foo(x);
};
assert_foo(gen);
assert_foo(generator);
//~^ ERROR implementation of `Foo` is not general enough

// Allow impls which matches any lifetime
let x = &OnlyFooIfRef(No);
let gen = #[coroutine] move || {
let generator = #[coroutine] move || {
let x = x;
yield;
assert_foo(x);
};
assert_foo(gen); // ok
assert_foo(generator); // ok

// Disallow impls which relates lifetimes in the coroutine interior
let gen = #[coroutine] move || {
let generator = #[coroutine] move || {
let a = A(&mut true, &mut true, No);
//~^ ERROR borrow may still be in use when coroutine yields
//~| ERROR borrow may still be in use when coroutine yields
yield;
assert_foo(a);
};
assert_foo(gen);
assert_foo(generator);
//~^ ERROR not general enough
}
8 changes: 4 additions & 4 deletions tests/ui/coroutine/auto-trait-regions.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ LL | let gen = #[coroutine] static move || {
error: implementation of `Foo` is not general enough
--> $DIR/auto-trait-regions.rs:31:5
|
LL | assert_foo(gen);
| ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
LL | assert_foo(generator);
| ^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
= note: `&'0 OnlyFooIfStaticRef` must implement `Foo`, for any lifetime `'0`...
= note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef`

error: implementation of `Foo` is not general enough
--> $DIR/auto-trait-regions.rs:51:5
|
LL | assert_foo(gen);
| ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
LL | assert_foo(generator);
| ^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
= note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`...
= note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2`
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/coroutine/clone-impl-static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
#![feature(coroutines, coroutine_clone, stmt_expr_attributes)]

fn main() {
let gen = #[coroutine]
let generator = #[coroutine]
static move || {
yield;
};
check_copy(&gen);
check_copy(&generator);
//~^ ERROR Copy` is not satisfied
check_clone(&gen);
check_clone(&generator);
//~^ ERROR Clone` is not satisfied
}

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/coroutine/clone-impl-static.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0277]: the trait bound `{static coroutine@$DIR/clone-impl-static.rs:11:5: 11:19}: Copy` is not satisfied
--> $DIR/clone-impl-static.rs:14:16
|
LL | check_copy(&gen);
| ---------- ^^^^ the trait `Copy` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:11:5: 11:19}`
LL | check_copy(&generator);
| ---------- ^^^^^^^^^^ the trait `Copy` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:11:5: 11:19}`
| |
| required by a bound introduced by this call
|
Expand All @@ -15,8 +15,8 @@ LL | fn check_copy<T: Copy>(_x: &T) {}
error[E0277]: the trait bound `{static coroutine@$DIR/clone-impl-static.rs:11:5: 11:19}: Clone` is not satisfied
--> $DIR/clone-impl-static.rs:16:17
|
LL | check_clone(&gen);
| ----------- ^^^^ the trait `Clone` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:11:5: 11:19}`
LL | check_clone(&generator);
| ----------- ^^^^^^^^^^ the trait `Clone` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:11:5: 11:19}`
| |
| required by a bound introduced by this call
|
Expand Down