You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
unsized_fn_params should not accept types that don't have a dynamically fixed size (such as extern types) #115709
In terms of MIR semantics I think we want to view a function call as making copies of its arguments. This requires at least dynamically determining the size of the argument, and therefore we shouldn't accept extern type arguments.
I was extremely surprised earlier today when I learned that this code is getting accepted.
There is no generic bound to distinguish extern types from other unsized types, so the options we have are
require the unsized type to be concrete enough that we can determine its tail, and ensure it is not extern
raise the error during monomorphization / codegen
Trying to actually build any such code will lead to ICEs such as
Unfortunately just rejecting locals/arguments that are not known to be dyn-sized as a MIR pass does not work: the forget_unsized function in the standard library would stop compiling.
So currently something post-monomorphization is the only option. Is there even some place that check could be put without being duplicated across all codegen backends (and Miri)?
changed the title [-]unsized_fn_params should not accept types that don't have a dynamically fixed size[/-][+]unsized_fn_params should not accept types that don't have a dynamically fixed size (such as `extern` types)[/+]on Sep 10, 2023
In #116115 we agreed that this is not worth a post-mono check; this needs proper design to find a way that makes this work without a post-mono check. So for now we are living with the ICEs.
Activity
SNCPlay42 commentedon Sep 9, 2023
See also #79409.
rust-lang/rfcs#2984 and rust-lang/rfcs#3396 are open RFCs that attempt to address this.
RalfJung commentedon Sep 9, 2023
Unfortunately just rejecting locals/arguments that are not known to be dyn-sized as a MIR pass does not work: the forget_unsized function in the standard library would stop compiling.
So currently something post-monomorphization is the only option. Is there even some place that check could be put without being duplicated across all codegen backends (and Miri)?
[-]unsized_fn_params should not accept types that don't have a dynamically fixed size[/-][+]unsized_fn_params should not accept types that don't have a dynamically fixed size (such as `extern` types)[/+]Auto merge of rust-lang#115748 - RalfJung:post-mono, r=<try>
Auto merge of rust-lang#115748 - RalfJung:post-mono, r=<try>
Auto merge of rust-lang#115748 - RalfJung:post-mono, r=<try>
Auto merge of rust-lang#115748 - RalfJung:post-mono, r=oli-obk
Auto merge of rust-lang#115748 - RalfJung:post-mono, r=oli-obk
Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
Auto merge of rust-lang#116115 - RalfJung:dyn-unsized-args, r=<try>
Auto merge of rust-lang#116115 - RalfJung:dyn-unsized-args, r=<try>
Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
RalfJung commentedon Dec 2, 2023
In #116115 we agreed that this is not worth a post-mono check; this needs proper design to find a way that makes this work without a post-mono check. So for now we are living with the ICEs.
Rollup merge of rust-lang#118551 - RalfJung:extern-types-bugs, r=comp…
Unrolled build for rust-lang#118551
Rollup merge of #118551 - RalfJung:extern-types-bugs, r=compiler-errors
Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
Auto merge of #115748 - RalfJung:post-mono, r=oli-obk