Skip to content

Commit 75afb22

Browse files
committedNov 16, 2022
Check dyn* return type correctly
1 parent 63c748e commit 75afb22

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed
 

‎compiler/rustc_hir_typeck/src/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub(super) fn check_fn<'a, 'tcx>(
100100

101101
inherited.typeck_results.borrow_mut().liberated_fn_sigs_mut().insert(fn_id, fn_sig);
102102

103-
if let ty::Dynamic(..) = declared_ret_ty.kind() {
103+
if let ty::Dynamic(_, _, ty::Dyn) = declared_ret_ty.kind() {
104104
// FIXME: We need to verify that the return type is `Sized` after the return expression has
105105
// been evaluated so that we have types available for all the nodes being returned, but that
106106
// requires the coerced evaluated type to be stored. Moving `check_return_expr` before this

‎src/test/ui/dyn-star/return.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
3+
#![feature(dyn_star)]
4+
//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
5+
6+
fn _foo() -> dyn* Unpin {
7+
4usize
8+
}
9+
10+
fn main() {}

‎src/test/ui/dyn-star/return.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/return.rs:3:12
3+
|
4+
LL | #![feature(dyn_star)]
5+
| ^^^^^^^^
6+
|
7+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+

0 commit comments

Comments
 (0)