File tree Expand file tree Collapse file tree 7 files changed +91
-30
lines changed
compiler/rustc_mir_transform/src
ui/async-await/async-drop Expand file tree Collapse file tree 7 files changed +91
-30
lines changed Original file line number Diff line number Diff line change 1
1
use std:: { fmt, iter, mem} ;
2
2
3
3
use rustc_abi:: { FIRST_VARIANT , FieldIdx , VariantIdx } ;
4
+ use rustc_hir:: def:: DefKind ;
4
5
use rustc_hir:: lang_items:: LangItem ;
5
6
use rustc_index:: Idx ;
6
7
use rustc_middle:: mir:: * ;
@@ -254,8 +255,19 @@ where
254
255
// impl_item_refs may be empty if drop fn is not implemented in 'impl AsyncDrop for ...'
255
256
// (#140974).
256
257
// Such code will report error, so just generate sync drop here and return
257
- let Some ( drop_fn_def_id) =
258
- tcx. associated_item_def_ids ( drop_trait) . into_iter ( ) . nth ( 0 ) . copied ( )
258
+ let Some ( drop_fn_def_id) = tcx
259
+ . associated_item_def_ids ( drop_trait)
260
+ . first ( )
261
+ . and_then ( |def_id| {
262
+ if tcx. def_kind ( def_id) == DefKind :: AssocFn
263
+ && tcx. check_args_compatible ( * def_id, trait_args)
264
+ {
265
+ Some ( def_id)
266
+ } else {
267
+ None
268
+ }
269
+ } )
270
+ . copied ( )
259
271
else {
260
272
tcx. dcx ( ) . span_delayed_bug (
261
273
self . elaborator . body ( ) . span ,
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ //@ edition: 2024
2
+ // ex-ice: #140500
3
+ #![ crate_type = "lib" ]
4
+ #![ feature( async_drop) ]
5
+ #![ expect( incomplete_features) ]
6
+ use std:: future:: AsyncDrop ;
7
+ struct A ;
8
+ impl Drop for A {
9
+ fn drop ( & mut self ) { }
10
+ }
11
+ impl AsyncDrop for A {
12
+ fn drop ( _wrong : impl Sized ) { } //~ ERROR: method `drop` has a `self: Pin<&mut Self>` declaration in the trait, but not in the impl
13
+ }
14
+ async fn bar ( ) {
15
+ A ;
16
+ }
Original file line number Diff line number Diff line change
1
+ error[E0186]: method `drop` has a `self: Pin<&mut Self>` declaration in the trait, but not in the impl
2
+ --> $DIR/type-parameter.rs:12:5
3
+ |
4
+ LL | fn drop(_wrong: impl Sized) {}
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `self: Pin<&mut Self>` in impl
6
+ |
7
+ = note: `drop` from trait: `fn(Pin<&mut Self>) -> impl Future<Output = ()>`
8
+
9
+ error: aborting due to 1 previous error
10
+
11
+ For more information about this error, try `rustc --explain E0186`.
Original file line number Diff line number Diff line change
1
+ // Ex-ice: #140484
2
+ //@ edition: 2024
3
+ #![ crate_type = "lib" ]
4
+ #![ allow( incomplete_features) ]
5
+ #![ allow( non_camel_case_types) ]
6
+ #![ feature( async_drop) ]
7
+ use std:: future:: AsyncDrop ;
8
+ struct a ;
9
+ impl Drop for a { //~ ERROR: not all trait items implemented, missing: `drop`
10
+ fn b ( ) { } //~ ERROR: method `b` is not a member of trait `Drop`
11
+ }
12
+ impl AsyncDrop for a { //~ ERROR: not all trait items implemented, missing: `drop`
13
+ type c = ( ) ;
14
+ //~^ ERROR: type `c` is not a member of trait `AsyncDrop`
15
+ }
16
+ async fn bar ( ) {
17
+ a;
18
+ }
Original file line number Diff line number Diff line change
1
+ error[E0407]: method `b` is not a member of trait `Drop`
2
+ --> $DIR/unexpected-sort.rs:10:5
3
+ |
4
+ LL | fn b() {}
5
+ | ^^^^^^^^^ not a member of trait `Drop`
6
+
7
+ error[E0437]: type `c` is not a member of trait `AsyncDrop`
8
+ --> $DIR/unexpected-sort.rs:13:5
9
+ |
10
+ LL | type c = ();
11
+ | ^^^^^^^^^^^^ not a member of trait `AsyncDrop`
12
+
13
+ error[E0046]: not all trait items implemented, missing: `drop`
14
+ --> $DIR/unexpected-sort.rs:9:1
15
+ |
16
+ LL | impl Drop for a {
17
+ | ^^^^^^^^^^^^^^^ missing `drop` in implementation
18
+ |
19
+ = help: implement the missing item: `fn drop(&mut self) { todo!() }`
20
+
21
+ error[E0046]: not all trait items implemented, missing: `drop`
22
+ --> $DIR/unexpected-sort.rs:12:1
23
+ |
24
+ LL | impl AsyncDrop for a {
25
+ | ^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation
26
+ |
27
+ = help: implement the missing item: `async fn drop(self: Pin<&mut Self>) { todo!() }`
28
+
29
+ error: aborting due to 4 previous errors
30
+
31
+ Some errors have detailed explanations: E0046, E0407, E0437.
32
+ For more information about an error, try `rustc --explain E0046`.
You can’t perform that action at this time.
0 commit comments