File tree Expand file tree Collapse file tree 4 files changed +71
-1
lines changed
compiler/rustc_borrowck/src/region_infer/opaque_types
tests/ui/impl-trait/non-defining-uses Expand file tree Collapse file tree 4 files changed +71
-1
lines changed Original file line number Diff line number Diff line change @@ -503,7 +503,16 @@ pub(crate) fn apply_computed_concrete_opaque_types<'tcx>(
503
503
let mut errors = Vec :: new ( ) ;
504
504
for & ( key, hidden_type) in opaque_types {
505
505
let Some ( expected) = get_concrete_opaque_type ( concrete_opaque_types, key. def_id ) else {
506
- assert ! ( tcx. use_typing_mode_borrowck( ) , "non-defining use in defining scope" ) ;
506
+ if !tcx. use_typing_mode_borrowck ( ) {
507
+ if let ty:: Alias ( ty:: Opaque , alias_ty) = hidden_type. ty . kind ( )
508
+ && alias_ty. def_id == key. def_id . to_def_id ( )
509
+ && alias_ty. args == key. args
510
+ {
511
+ continue ;
512
+ } else {
513
+ unreachable ! ( "non-defining use in defining scope" ) ;
514
+ }
515
+ }
507
516
errors. push ( DeferredOpaqueTypeError :: NonDefiningUseInDefiningScope {
508
517
span : hidden_type. span ,
509
518
opaque_type_key : key,
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `(): ReturnsSend` is not satisfied
2
+ --> $DIR/ice-issue-146191.rs:6:52
3
+ |
4
+ LL | fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
5
+ | ^^^^^^^^^^^^^^^^ the trait `ReturnsSend` is not implemented for `()`
6
+ |
7
+ help: this trait has no implementations, consider adding one
8
+ --> $DIR/ice-issue-146191.rs:14:1
9
+ |
10
+ LL | trait ReturnsSend {}
11
+ | ^^^^^^^^^^^^^^^^^
12
+ note: required by a bound in an opaque type
13
+ --> $DIR/ice-issue-146191.rs:6:57
14
+ |
15
+ LL | fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
16
+ | ^^^^^^^^^^^
17
+
18
+ error[E0733]: recursion in an async block requires boxing
19
+ --> $DIR/ice-issue-146191.rs:8:5
20
+ |
21
+ LL | async { create_complex_future().await }
22
+ | ^^^^^ ----------------------------- recursive call here
23
+ |
24
+ = note: a recursive `async fn` call must introduce indirection such as `Box::pin` to avoid an infinitely sized future
25
+
26
+ error: aborting due to 2 previous errors
27
+
28
+ Some errors have detailed explanations: E0277, E0733.
29
+ For more information about an error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
1
+ error[E0282]: type annotations needed
2
+ --> $DIR/ice-issue-146191.rs:8:5
3
+ |
4
+ LL | async { create_complex_future().await }
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
6
+
7
+ error[E0282]: type annotations needed
8
+ --> $DIR/ice-issue-146191.rs:8:5
9
+ |
10
+ LL | async { create_complex_future().await }
11
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
12
+ |
13
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
14
+
15
+ error: aborting due to 2 previous errors
16
+
17
+ For more information about this error, try `rustc --explain E0282`.
Original file line number Diff line number Diff line change
1
+ //@ edition: 2024
2
+ //@ revisions: current next
3
+ //@[next] compile-flags: -Znext-solver
4
+ //@ ignore-compare-mode-next-solver (explicit revisions)
5
+
6
+ fn create_complex_future ( ) -> impl Future < Output = impl ReturnsSend > {
7
+ //[current]~^ ERROR the trait bound `(): ReturnsSend` is not satisfied
8
+ async { create_complex_future ( ) . await }
9
+ //[current]~^ ERROR recursion in an async block requires
10
+ //[next]~^^ ERROR type annotations needed
11
+ //[next]~| ERROR type annotations needed
12
+ }
13
+
14
+ trait ReturnsSend { }
15
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments