rust/compiler
bors 1de00d1ac5 Auto merge of #100096 - compiler-errors:fn-return-must-be-sized, r=jackh726
a fn pointer doesn't implement `Fn`/`FnMut`/`FnOnce` if its return type isn't sized

I stumbled upon #83915 which hasn't received much attention recently, and I wanted to revive it since this is one existing soundness hole that seems pretty easy to fix.

I'm not actually sure that the [alternative approach described here](https://github.com/rust-lang/rust/pull/83915#issuecomment-823643322) is sufficient, given the `src/test/ui/function-pointer/unsized-ret.rs` example I provided below. Rebasing the branch mentioned in that comment and testing that UI test, it seems that we actually end up only observing that `str: !Sized` during monomorphization, whereupon we ICE. Even if we were to fix that ICE, ideally we'd be raising an error that a fn pointer is being used badly during _typecheck_ instead of monomorphization, hence adapting the original approach in #83915.

I am happy to close this if people would prefer we rebase the original PR and land that -- I am partly opening to be annoying and get people thinking about this unsoundness again ❤️ 😸

cc: `@estebank` and `@nikomatsakis`
r? types

Here's a link to the thread: https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/PR.20.2383915/near/235421351 for more context.
2022-09-21 04:35:20 +00:00
..
rustc
rustc_apfloat
rustc_arena
rustc_ast Rollup merge of #93628 - est31:stabilize_let_else, r=joshtriplett 2022-09-17 15:31:06 +05:30
rustc_ast_lowering Simplify rpitit handling on lower_fn_decl 2022-09-19 09:30:39 -03:00
rustc_ast_passes Only enable the let_else feature on bootstrap 2022-09-15 21:06:45 +02:00
rustc_ast_pretty make mk_attr_id part of ParseSess 2022-09-14 08:49:10 +08:00
rustc_attr Only enable the let_else feature on bootstrap 2022-09-15 21:06:45 +02:00
rustc_borrowck Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank 2022-09-20 12:09:52 +00:00
rustc_builtin_macros Rollup merge of #100250 - cjgillot:recover-token-stream, r=Aaron1011 2022-09-20 10:12:56 -07:00
rustc_codegen_cranelift Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank 2022-09-20 12:09:52 +00:00
rustc_codegen_gcc Remove dead broken code from const zst handling in backends 2022-09-06 14:09:49 +00:00
rustc_codegen_llvm Use LLVM C-API to build atomic cmpxchg and fence 2022-09-18 16:01:57 -07:00
rustc_codegen_ssa Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank 2022-09-20 12:09:52 +00:00
rustc_const_eval Rollup merge of #102021 - lcnr:tyConst-fun, r=b-naber,BoxyUwU 2022-09-20 10:13:01 -07:00
rustc_data_structures Only enable the let_else feature on bootstrap 2022-09-15 21:06:45 +02:00
rustc_driver Only enable the let_else feature on bootstrap 2022-09-15 21:06:45 +02:00
rustc_error_codes
rustc_error_messages Auto merge of #101924 - jackh726:revert-static-hrtb-error, r=compiler-errors 2022-09-19 04:56:14 +00:00
rustc_errors Rollup merge of #101790 - TaKO8Ki:do-not-suggest-placeholder-to-const-and-static-without-type, r=compiler-errors 2022-09-17 15:31:08 +05:30
rustc_expand Only enable the let_else feature on bootstrap 2022-09-15 21:06:45 +02:00
rustc_feature Rollup merge of #101713 - Bryanskiy:AccessLevels, r=petrochenkov 2022-09-17 23:30:49 +02:00
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #93628 - est31:stabilize_let_else, r=joshtriplett 2022-09-17 15:31:06 +05:30
rustc_hir_pretty Handle generic parameters. 2022-09-09 01:31:46 +00:00
rustc_incremental Only enable the let_else feature on bootstrap 2022-09-15 21:06:45 +02:00
rustc_index Only enable the let_else feature on bootstrap 2022-09-15 21:06:45 +02:00
rustc_infer remove the Subst trait, always use EarlyBinder 2022-09-19 11:37:27 +02:00
rustc_interface Only enable the let_else feature on bootstrap 2022-09-15 21:06:45 +02:00
rustc_lexer remove unnecessary PartialOrd and Ord 2022-09-08 06:15:33 +09:00
rustc_lint Rollup merge of #101912 - crlf0710:compiler_update_unicode_15, r=Manishearth 2022-09-18 02:55:29 +02:00
rustc_lint_defs Compute lint_levels by definition 2022-09-14 19:02:44 +02:00
rustc_llvm Use LLVM C-API to build atomic cmpxchg and fence 2022-09-18 16:01:57 -07:00
rustc_log
rustc_macros Only enable the let_else feature on bootstrap 2022-09-15 21:06:45 +02:00
rustc_metadata Auto merge of #101806 - BelovDV:issue-fix-fn-find_library, r=petrochenkov 2022-09-20 07:10:18 +00:00
rustc_middle Auto merge of #102061 - notriddle:rollup-kwu9vp8, r=notriddle 2022-09-20 19:10:11 +00:00
rustc_mir_build Rollup merge of #102021 - lcnr:tyConst-fun, r=b-naber,BoxyUwU 2022-09-20 10:13:01 -07:00
rustc_mir_dataflow Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank 2022-09-20 12:09:52 +00:00
rustc_mir_transform Rollup merge of #102021 - lcnr:tyConst-fun, r=b-naber,BoxyUwU 2022-09-20 10:13:01 -07:00
rustc_monomorphize Rollup merge of #93628 - est31:stabilize_let_else, r=joshtriplett 2022-09-17 15:31:06 +05:30
rustc_parse Rollup merge of #100250 - cjgillot:recover-token-stream, r=Aaron1011 2022-09-20 10:12:56 -07:00
rustc_parse_format
rustc_passes Rollup merge of #101713 - Bryanskiy:AccessLevels, r=petrochenkov 2022-09-17 23:30:49 +02:00
rustc_plugin_impl
rustc_privacy Rollup merge of #101713 - Bryanskiy:AccessLevels, r=petrochenkov 2022-09-17 23:30:49 +02:00
rustc_query_impl Rollup merge of #101801 - SparrowLii:query_depth_note, r=estebank 2022-09-17 19:27:06 +02:00
rustc_query_system Rollup merge of #101801 - SparrowLii:query_depth_note, r=estebank 2022-09-17 19:27:06 +02:00
rustc_resolve Rollup merge of #101713 - Bryanskiy:AccessLevels, r=petrochenkov 2022-09-17 23:30:49 +02:00
rustc_save_analysis Only enable the let_else feature on bootstrap 2022-09-15 21:06:45 +02:00
rustc_serialize Rollup merge of #101014 - isikkema:fix-zmeta-stats-file-encoder-no-read-perms, r=isikkema 2022-09-20 10:12:57 -07:00
rustc_session Only enable the let_else feature on bootstrap 2022-09-15 21:06:45 +02:00
rustc_smir Only keep one version of ImplicitSelfKind. 2022-09-13 19:18:23 +02:00
rustc_span Rollup merge of #101713 - Bryanskiy:AccessLevels, r=petrochenkov 2022-09-17 23:30:49 +02:00
rustc_symbol_mangling remove the Subst trait, always use EarlyBinder 2022-09-19 11:37:27 +02:00
rustc_target Rollup merge of #93628 - est31:stabilize_let_else, r=joshtriplett 2022-09-17 15:31:06 +05:30
rustc_trait_selection Auto merge of #100096 - compiler-errors:fn-return-must-be-sized, r=jackh726 2022-09-21 04:35:20 +00:00
rustc_traits remove the Subst trait, always use EarlyBinder 2022-09-19 11:37:27 +02:00
rustc_transmute Auto merge of #100726 - jswrenn:transmute, r=oli-obk 2022-09-04 07:55:44 +00:00
rustc_ty_utils remove the Subst trait, always use EarlyBinder 2022-09-19 11:37:27 +02:00
rustc_type_ir Address code review comments 2022-09-13 14:50:12 -07:00
rustc_typeck Rollup merge of #102021 - lcnr:tyConst-fun, r=b-naber,BoxyUwU 2022-09-20 10:13:01 -07:00