@@ -794,18 +794,25 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
794
794
// The auto impl might apply; we don't know.
795
795
candidates. ambiguous = true ;
796
796
}
797
- ty:: Coroutine ( coroutine_def_id, _)
798
- if self . tcx ( ) . is_lang_item ( def_id, LangItem :: Unpin ) =>
799
- {
800
- match self . tcx ( ) . coroutine_movability ( coroutine_def_id) {
801
- hir:: Movability :: Static => {
802
- // Immovable coroutines are never `Unpin`, so
803
- // suppress the normal auto-impl candidate for it.
797
+ ty:: Coroutine ( coroutine_def_id, _) => {
798
+ if self . tcx ( ) . is_lang_item ( def_id, LangItem :: Unpin ) {
799
+ match self . tcx ( ) . coroutine_movability ( coroutine_def_id) {
800
+ hir:: Movability :: Static => {
801
+ // Immovable coroutines are never `Unpin`, so
802
+ // suppress the normal auto-impl candidate for it.
803
+ }
804
+ hir:: Movability :: Movable => {
805
+ // Movable coroutines are always `Unpin`, so add an
806
+ // unconditional builtin candidate with no sub-obligations.
807
+ candidates. vec . push ( BuiltinCandidate ) ;
808
+ }
804
809
}
805
- hir:: Movability :: Movable => {
806
- // Movable coroutines are always `Unpin`, so add an
807
- // unconditional builtin candidate.
808
- candidates. vec . push ( BuiltinCandidate ) ;
810
+ } else {
811
+ if self . should_stall_coroutine ( coroutine_def_id) {
812
+ candidates. ambiguous = true ;
813
+ } else {
814
+ // Coroutines implement all other auto traits normally.
815
+ candidates. vec . push ( AutoImplCandidate ) ;
809
816
}
810
817
}
811
818
}
@@ -842,12 +849,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
842
849
}
843
850
}
844
851
845
- ty:: CoroutineWitness ( def_id, _) => {
846
- if self . should_stall_coroutine_witness ( def_id) {
847
- candidates. ambiguous = true ;
848
- } else {
849
- candidates. vec . push ( AutoImplCandidate ) ;
850
- }
852
+ ty:: CoroutineWitness ( ..) => {
853
+ candidates. vec . push ( AutoImplCandidate ) ;
851
854
}
852
855
853
856
ty:: Bool
@@ -866,7 +869,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
866
869
| ty:: FnPtr ( ..)
867
870
| ty:: Closure ( ..)
868
871
| ty:: CoroutineClosure ( ..)
869
- | ty:: Coroutine ( ..)
870
872
| ty:: Never
871
873
| ty:: Tuple ( _)
872
874
| ty:: UnsafeBinder ( _) => {
@@ -1153,15 +1155,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1153
1155
ty:: Ref ( _, _, hir:: Mutability :: Mut ) => { }
1154
1156
1155
1157
ty:: Coroutine ( coroutine_def_id, args) => {
1158
+ if self . should_stall_coroutine ( coroutine_def_id) {
1159
+ candidates. ambiguous = true ;
1160
+ return ;
1161
+ }
1162
+
1156
1163
match self . tcx ( ) . coroutine_movability ( coroutine_def_id) {
1157
1164
hir:: Movability :: Static => { }
1158
1165
hir:: Movability :: Movable => {
1159
1166
if self . tcx ( ) . features ( ) . coroutine_clone ( ) {
1160
1167
let resolved_upvars =
1161
1168
self . infcx . shallow_resolve ( args. as_coroutine ( ) . tupled_upvars_ty ( ) ) ;
1162
- let resolved_witness =
1163
- self . infcx . shallow_resolve ( args. as_coroutine ( ) . witness ( ) ) ;
1164
- if resolved_upvars. is_ty_var ( ) || resolved_witness. is_ty_var ( ) {
1169
+ if resolved_upvars. is_ty_var ( ) {
1165
1170
// Not yet resolved.
1166
1171
candidates. ambiguous = true ;
1167
1172
} else {
@@ -1194,12 +1199,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1194
1199
}
1195
1200
}
1196
1201
1197
- ty:: CoroutineWitness ( coroutine_def_id, _) => {
1198
- if self . should_stall_coroutine_witness ( coroutine_def_id) {
1199
- candidates. ambiguous = true ;
1200
- } else {
1201
- candidates. vec . push ( SizedCandidate ) ;
1202
- }
1202
+ ty:: CoroutineWitness ( ..) => {
1203
+ candidates. vec . push ( SizedCandidate ) ;
1203
1204
}
1204
1205
1205
1206
// Fallback to whatever user-defined impls or param-env clauses exist in this case.
@@ -1238,7 +1239,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1238
1239
| ty:: RawPtr ( ..)
1239
1240
| ty:: Char
1240
1241
| ty:: Ref ( ..)
1241
- | ty:: Coroutine ( ..)
1242
1242
| ty:: Array ( ..)
1243
1243
| ty:: Closure ( ..)
1244
1244
| ty:: CoroutineClosure ( ..)
@@ -1247,14 +1247,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1247
1247
candidates. vec . push ( SizedCandidate ) ;
1248
1248
}
1249
1249
1250
- ty:: CoroutineWitness ( coroutine_def_id, _) => {
1251
- if self . should_stall_coroutine_witness ( coroutine_def_id) {
1250
+ ty:: Coroutine ( coroutine_def_id, _) => {
1251
+ if self . should_stall_coroutine ( coroutine_def_id) {
1252
1252
candidates. ambiguous = true ;
1253
1253
} else {
1254
1254
candidates. vec . push ( SizedCandidate ) ;
1255
1255
}
1256
1256
}
1257
1257
1258
+ ty:: CoroutineWitness ( ..) => {
1259
+ candidates. vec . push ( SizedCandidate ) ;
1260
+ }
1261
+
1258
1262
// Conditionally `Sized`.
1259
1263
ty:: Tuple ( ..) | ty:: Pat ( ..) | ty:: Adt ( ..) | ty:: UnsafeBinder ( _) => {
1260
1264
candidates. vec . push ( SizedCandidate ) ;
0 commit comments