diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-11-17 22:33:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-17 22:33:21 +0100 |
| commit | 43fa2918d1e4dfd90f83ce46aac8373ae8120068 (patch) | |
| tree | 450ccfac1cd4b1b2c6a8224466d104984702229a /compiler | |
| parent | 68a8109ddbb44fdfdd455036d2e53a8bf3545d4e (diff) | |
| parent | 75afb22331daececeba38a3efb0134348d6c14d9 (diff) | |
| download | rust-43fa2918d1e4dfd90f83ce46aac8373ae8120068.tar.gz rust-43fa2918d1e4dfd90f83ce46aac8373ae8120068.zip | |
Rollup merge of #104508 - compiler-errors:dyn-return, r=oli-obk
Check `dyn*` return type correctly In `check_fn`, if the declared return type is `dyn Trait`, then we check the return type separately to produce better diagnostics, because this is never valid -- however, when `dyn*` was introduced, this check was never adjusted to only account for *unsized* `dyn Trait` and not *sized* `dyn* Trait`. Fixes #104501
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_typeck/src/check.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs index 1578cddd490..b9e90e47e50 100644 --- a/compiler/rustc_hir_typeck/src/check.rs +++ b/compiler/rustc_hir_typeck/src/check.rs @@ -102,7 +102,7 @@ pub(super) fn check_fn<'a, 'tcx>( inherited.typeck_results.borrow_mut().liberated_fn_sigs_mut().insert(fn_id, fn_sig); - if let ty::Dynamic(..) = declared_ret_ty.kind() { + if let ty::Dynamic(_, _, ty::Dyn) = declared_ret_ty.kind() { // FIXME: We need to verify that the return type is `Sized` after the return expression has // been evaluated so that we have types available for all the nodes being returned, but that // requires the coerced evaluated type to be stored. Moving `check_return_expr` before this |
