Skip to content

Commit 94d2028

Browse files
authored
Rollup merge of rust-lang#109446 - spastorino:new-rpitit-17, r=compiler-errors
Do not suggest bounds restrictions for synthesized RPITITs Before this PR we were getting ... ``` warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes --> tests/ui/async-await/in-trait/missing-send-bound.rs:5:12 | 5 | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ | = note: see issue rust-lang#91611 <rust-lang#91611> for more information = note: `#[warn(incomplete_features)]` on by default error: future cannot be sent between threads safely --> tests/ui/async-await/in-trait/missing-send-bound.rs:17:20 | 17 | assert_is_send(test::<T>()); | ^^^^^^^^^^^ future returned by `test` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>` note: future is not `Send` as it awaits another future which is not `Send` --> tests/ui/async-await/in-trait/missing-send-bound.rs:13:5 | 13 | T::bar().await; | ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send` note: required by a bound in `assert_is_send` --> tests/ui/async-await/in-trait/missing-send-bound.rs:21:27 | 21 | fn assert_is_send(_: impl Send) {} | ^^^^ required by this bound in `assert_is_send` help: consider further restricting the associated type | 16 | fn test2<T: Foo>() where impl Future<Output = ()>: Send { | ++++++++++++++++++++++++++++++++++++ error: aborting due to previous error; 1 warning emitted ``` and we want this output ... ``` warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/missing-send-bound.rs:5:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ | = note: see issue rust-lang#91611 <rust-lang#91611> for more information = note: `#[warn(incomplete_features)]` on by default error: future cannot be sent between threads safely --> $DIR/missing-send-bound.rs:17:20 | LL | assert_is_send(test::<T>()); | ^^^^^^^^^^^ future returned by `test` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>` note: future is not `Send` as it awaits another future which is not `Send` --> $DIR/missing-send-bound.rs:13:5 | LL | T::bar().await; | ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send` note: required by a bound in `assert_is_send` --> $DIR/missing-send-bound.rs:21:27 | LL | fn assert_is_send(_: impl Send) {} | ^^^^ required by this bound in `assert_is_send` error: aborting due to previous error; 1 warning emitted ``` r? `@compiler-errors`
2 parents fef1fc4 + 3b04ad2 commit 94d2028

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+1
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ fn suggest_restriction<'tcx>(
420420
) {
421421
if hir_generics.where_clause_span.from_expansion()
422422
|| hir_generics.where_clause_span.desugaring_kind().is_some()
423+
|| projection.map_or(false, |projection| tcx.opt_rpitit_info(projection.def_id).is_some())
423424
{
424425
return;
425426
}

tests/ui/async-await/in-trait/missing-send-bound.stderr renamed to tests/ui/async-await/in-trait/missing-send-bound.current.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/missing-send-bound.rs:3:12
2+
--> $DIR/missing-send-bound.rs:5:12
33
|
44
LL | #![feature(async_fn_in_trait)]
55
| ^^^^^^^^^^^^^^^^^
@@ -8,19 +8,19 @@ LL | #![feature(async_fn_in_trait)]
88
= note: `#[warn(incomplete_features)]` on by default
99

1010
error: future cannot be sent between threads safely
11-
--> $DIR/missing-send-bound.rs:15:20
11+
--> $DIR/missing-send-bound.rs:17:20
1212
|
1313
LL | assert_is_send(test::<T>());
1414
| ^^^^^^^^^^^ future returned by `test` is not `Send`
1515
|
1616
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>`
1717
note: future is not `Send` as it awaits another future which is not `Send`
18-
--> $DIR/missing-send-bound.rs:11:5
18+
--> $DIR/missing-send-bound.rs:13:5
1919
|
2020
LL | T::bar().await;
2121
| ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send`
2222
note: required by a bound in `assert_is_send`
23-
--> $DIR/missing-send-bound.rs:19:27
23+
--> $DIR/missing-send-bound.rs:21:27
2424
|
2525
LL | fn assert_is_send(_: impl Send) {}
2626
| ^^^^ required by this bound in `assert_is_send`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/missing-send-bound.rs:5:12
3+
|
4+
LL | #![feature(async_fn_in_trait)]
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error: future cannot be sent between threads safely
11+
--> $DIR/missing-send-bound.rs:17:20
12+
|
13+
LL | assert_is_send(test::<T>());
14+
| ^^^^^^^^^^^ future returned by `test` is not `Send`
15+
|
16+
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>`
17+
note: future is not `Send` as it awaits another future which is not `Send`
18+
--> $DIR/missing-send-bound.rs:13:5
19+
|
20+
LL | T::bar().await;
21+
| ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send`
22+
note: required by a bound in `assert_is_send`
23+
--> $DIR/missing-send-bound.rs:21:27
24+
|
25+
LL | fn assert_is_send(_: impl Send) {}
26+
| ^^^^ required by this bound in `assert_is_send`
27+
28+
error: aborting due to previous error; 1 warning emitted
29+

tests/ui/async-await/in-trait/missing-send-bound.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// edition:2021
2+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
3+
// revisions: current next
24

35
#![feature(async_fn_in_trait)]
46
//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes

0 commit comments

Comments
 (0)