Skip to content

Commit

Permalink
Point to closure return instead of output if defaulted
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Oct 4, 2023
1 parent 89b14ae commit 1f079cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion compiler/rustc_hir_typeck/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ pub(super) fn check_fn<'a, 'tcx>(

fcx.typeck_results.borrow_mut().liberated_fn_sigs_mut().insert(fn_id, fn_sig);

fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
let return_or_body_span = match decl.output {
hir::FnRetTy::DefaultReturn(_) => body.value.span,
hir::FnRetTy::Return(ty) => ty.span,
};
fcx.require_type_is_sized(declared_ret_ty, return_or_body_span, traits::SizedReturnType);
fcx.check_return_expr(&body.value, false);

// We insert the deferred_generator_interiors entry after visiting the body.
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/tests/ui/crashes/ice-6251.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: &[u8]| x }]> {
| +

error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/ice-6251.rs:4:53
--> $DIR/ice-6251.rs:4:54
|
LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
| ^ doesn't have a size known at compile-time
| ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `[u8]`
= note: the return type of a function must have a statically known size
Expand Down

0 comments on commit 1f079cf

Please sign in to comment.