Skip to content

Commit 02f5817

Browse files
authored
Unrolled build for rust-lang#137635
Rollup merge of rust-lang#137635 - compiler-errors:constrain-unstable, r=SparrowLii Don't suggest constraining unstable associated types Fixes rust-lang#137624 This could be made a bit more specific, considering the local crate's stability or nightly status or something, but I think in general we should not be suggesting associated type bounds on unstable associated items.
2 parents ac91805 + 9313580 commit 02f5817

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>(
136136
) {
137137
if hir_generics.where_clause_span.from_expansion()
138138
|| hir_generics.where_clause_span.desugaring_kind().is_some()
139-
|| projection.is_some_and(|projection| tcx.is_impl_trait_in_trait(projection.def_id))
139+
|| projection.is_some_and(|projection| {
140+
tcx.is_impl_trait_in_trait(projection.def_id)
141+
|| tcx.lookup_stability(projection.def_id).is_some_and(|stab| stab.is_unstable())
142+
})
140143
{
141144
return;
142145
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Ensure that we don't suggest constraining `CallRefFuture` here,
2+
// since that isn't stable.
3+
4+
fn spawn<F: AsyncFn() + Send>(f: F) {
5+
check_send(f());
6+
//~^ ERROR cannot be sent between threads safely
7+
}
8+
9+
fn check_send<T: Send>(_: T) {}
10+
11+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0277]: `<F as AsyncFnMut<()>>::CallRefFuture<'_>` cannot be sent between threads safely
2+
--> $DIR/suggest-constrain.rs:5:16
3+
|
4+
LL | check_send(f());
5+
| ---------- ^^^ `<F as AsyncFnMut<()>>::CallRefFuture<'_>` cannot be sent between threads safely
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= help: the trait `Send` is not implemented for `<F as AsyncFnMut<()>>::CallRefFuture<'_>`
10+
note: required by a bound in `check_send`
11+
--> $DIR/suggest-constrain.rs:9:18
12+
|
13+
LL | fn check_send<T: Send>(_: T) {}
14+
| ^^^^ required by this bound in `check_send`
15+
16+
error: aborting due to 1 previous error
17+
18+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)