Sema: discard self should not be allowed in inlinable methods of non-frozen types.

`discard self` requires knowledge of the internal layout of the type in order to clean
up its fields while bypassing its public `deinit`. Inlinable code can get copied into
and run from outside of the defining module, so this is impossible to implement.
Fixes rdar://160815058.
This commit is contained in:
Joe Groff
2025-10-16 18:54:49 -07:00
parent 860f2db0f8
commit 6f2811110d
5 changed files with 105 additions and 9 deletions

View File

@@ -8,6 +8,7 @@
// CHECK: @_alwaysEmitIntoClient public consuming func AEIC_discard() { discard self }
// CHECK: @inlinable public consuming func inlinable_discard() { discard self }
@frozen
public struct MoveOnlyStruct: ~Copyable {
let x = 0