Point to closure return instead of output if defaulted · rust-lang/rust@1f079cf (original) (raw)
File tree
2 files changed
lines changed
- compiler/rustc_hir_typeck/src
- src/tools/clippy/tests/ui/crashes
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -113,7 +113,11 @@ pub(super) fn check_fn<'a, 'tcx>( | ||
113 | 113 | |
114 | 114 | fcx.typeck_results.borrow_mut().liberated_fn_sigs_mut().insert(fn_id, fn_sig); |
115 | 115 | |
116 | - fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType); | |
116 | +let return_or_body_span = match decl.output { | |
117 | + hir::FnRetTy::DefaultReturn(_) => body.value.span, | |
118 | + hir::FnRetTy::Return(ty) => ty.span, | |
119 | +}; | |
120 | + fcx.require_type_is_sized(declared_ret_ty, return_or_body_span, traits::SizedReturnType); | |
117 | 121 | fcx.check_return_expr(&body.value, false); |
118 | 122 | |
119 | 123 | // We insert the deferred_generator_interiors entry after visiting the body. |
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
@@ -12,10 +12,10 @@ LL | fn bug() -> impl Iterator<Item = [(); { | x: &[u8] | x }]> { | |
12 | 12 | | + | |
13 | 13 | ||
14 | 14 | error[E0277]: the size for values of type `[u8]` cannot be known at compilation time | |
15 | - --> $DIR/ice-6251.rs:4:53 | ||
15 | + --> $DIR/ice-6251.rs:4:54 | ||
16 | 16 | | | |
17 | 17 | LL | fn bug() -> impl Iterator<Item = [(); { | x: [u8] |
18 | - | ^ doesn't have a size known at compile-time | ||
18 | + | ^ doesn't have a size known at compile-time | ||
19 | 19 | | | |
20 | 20 | = help: the trait `std:📑:Sized` is not implemented for `[u8]` | |
21 | 21 | = note: the return type of a function must have a statically known size |