File tree 3 files changed +43
-2
lines changed
compiler/rustc_mir_transform/src/shim
tests/ui/async-await/async-drop 3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -121,9 +121,10 @@ pub(super) fn build_async_drop_shim<'tcx>(
121
121
parent_args. as_coroutine ( ) . resume_ty ( ) ,
122
122
) ) ) ;
123
123
body. phase = MirPhase :: Runtime ( RuntimePhase :: Initial ) ;
124
- if !needs_async_drop {
124
+ if !needs_async_drop || matches ! ( drop_ty . kind ( ) , ty :: Error ( _ ) ) {
125
125
// Returning noop body for types without `need async drop`
126
- // (or sync Drop in case of !`need async drop` && `need drop`)
126
+ // (or sync Drop in case of !`need async drop` && `need drop`).
127
+ // And also for error types.
127
128
return body;
128
129
}
129
130
Original file line number Diff line number Diff line change
1
+ //@compile-flags: -Zvalidate-mir -Zinline-mir=yes --crate-type=lib
2
+
3
+ #![ feature( async_drop) ]
4
+ #![ allow( incomplete_features) ]
5
+
6
+ use std:: {
7
+ future:: { Future , async_drop_in_place} ,
8
+ pin:: pin,
9
+ task:: Context ,
10
+ } ;
11
+
12
+ fn wrong ( ) -> impl Sized {
13
+ //~^ ERROR: the size for values of type `str` cannot be known at compilation time
14
+ * "abc" // Doesn't implement Sized
15
+ }
16
+ fn weird ( context : & mut Context < ' _ > ) {
17
+ let mut e = wrong ( ) ;
18
+ let h = unsafe { async_drop_in_place ( & raw mut e) } ;
19
+ let i = pin ! ( h) ;
20
+ i. poll ( context) ;
21
+ }
Original file line number Diff line number Diff line change
1
+ error[E0277]: the size for values of type `str` cannot be known at compilation time
2
+ --> $DIR/open-drop-error2.rs:12:15
3
+ |
4
+ LL | fn wrong() -> impl Sized {
5
+ | ^^^^^^^^^^ doesn't have a size known at compile-time
6
+ LL |
7
+ LL | *"abc" // Doesn't implement Sized
8
+ | ------ return type was inferred to be `str` here
9
+ |
10
+ = help: the trait `Sized` is not implemented for `str`
11
+ help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression
12
+ |
13
+ LL - *"abc" // Doesn't implement Sized
14
+ LL + "abc" // Doesn't implement Sized
15
+ |
16
+
17
+ error: aborting due to 1 previous error
18
+
19
+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments