File tree Expand file tree Collapse file tree 3 files changed +66
-2
lines changed
compiler/rustc_mir_transform/src
tests/ui/async-await/async-drop Expand file tree Collapse file tree 3 files changed +66
-2
lines changed Original file line number Diff line number Diff line change 11use std:: { fmt, iter, mem} ;
22
33use rustc_abi:: { FIRST_VARIANT , FieldIdx , VariantIdx } ;
4+ use rustc_hir:: def:: DefKind ;
45use rustc_hir:: lang_items:: LangItem ;
56use rustc_index:: Idx ;
67use rustc_middle:: mir:: * ;
@@ -254,8 +255,13 @@ where
254255 // impl_item_refs may be empty if drop fn is not implemented in 'impl AsyncDrop for ...'
255256 // (#140974).
256257 // 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 { Some ( def_id) } else { None }
263+ } )
264+ . copied ( )
259265 else {
260266 tcx. dcx ( ) . span_delayed_bug (
261267 self . elaborator . body ( ) . span ,
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 ; //~ ERROR: associated type in `impl` without body
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: associated type in `impl` without body
2+ --> $DIR/unexpected-sort.rs:13:5
3+ |
4+ LL | type c;
5+ | ^^^^^^-
6+ | |
7+ | help: provide a definition for the type: `= <type>;`
8+
9+ error[E0407]: method `b` is not a member of trait `Drop`
10+ --> $DIR/unexpected-sort.rs:10:5
11+ |
12+ LL | fn b() {}
13+ | ^^^^^^^^^ not a member of trait `Drop`
14+
15+ error[E0437]: type `c` is not a member of trait `AsyncDrop`
16+ --> $DIR/unexpected-sort.rs:13:5
17+ |
18+ LL | type c;
19+ | ^^^^^^^ not a member of trait `AsyncDrop`
20+
21+ error[E0046]: not all trait items implemented, missing: `drop`
22+ --> $DIR/unexpected-sort.rs:9:1
23+ |
24+ LL | impl Drop for a {
25+ | ^^^^^^^^^^^^^^^ missing `drop` in implementation
26+ |
27+ = help: implement the missing item: `fn drop(&mut self) { todo!() }`
28+
29+ error[E0046]: not all trait items implemented, missing: `drop`
30+ --> $DIR/unexpected-sort.rs:12:1
31+ |
32+ LL | impl AsyncDrop for a {
33+ | ^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation
34+ |
35+ = help: implement the missing item: `async fn drop(self: Pin<&mut Self>) { todo!() }`
36+
37+ error: aborting due to 5 previous errors
38+
39+ Some errors have detailed explanations: E0046, E0407, E0437.
40+ For more information about an error, try `rustc --explain E0046`.
You can’t perform that action at this time.
0 commit comments