diff options
| author | Michael Goulet <michael@errs.io> | 2023-10-02 21:39:07 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-10-04 21:09:54 +0000 |
| commit | 1f079cfb440c05578fce656999d363d916500850 (patch) | |
| tree | 48dee8630d241feb221f675f73a9b2d2f85f0c65 | |
| parent | 89b14ae212e50f7a92800c4cb4f7cdefd2b1495e (diff) | |
| download | rust-1f079cfb440c05578fce656999d363d916500850.tar.gz rust-1f079cfb440c05578fce656999d363d916500850.zip | |
Point to closure return instead of output if defaulted
| -rw-r--r-- | compiler/rustc_hir_typeck/src/check.rs | 6 | ||||
| -rw-r--r-- | src/tools/clippy/tests/ui/crashes/ice-6251.stderr | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs index 1fa0ec173a7..c8ffd7d1506 100644 --- a/compiler/rustc_hir_typeck/src/check.rs +++ b/compiler/rustc_hir_typeck/src/check.rs @@ -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. diff --git a/src/tools/clippy/tests/ui/crashes/ice-6251.stderr b/src/tools/clippy/tests/ui/crashes/ice-6251.stderr index aaebdabcbd5..11081dc8087 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6251.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6251.stderr @@ -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 |
