Skip to content

Commit 833854f

Browse files
committed
stdlib: SE-0101: make old APIs unavailable (sizeof, alignof, strideof)
1 parent 382d215 commit 833854f

File tree

1 file changed

+12
-34
lines changed

1 file changed

+12
-34
lines changed

stdlib/public/core/Builtin.swift

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,34 @@ import SwiftShims
1515
// Definitions that make elements of Builtin usable in real code
1616
// without gobs of boilerplate.
1717

18-
/// Returns the contiguous memory footprint of `T`.
19-
///
20-
/// Does not include any dynamically-allocated or "remote" storage.
21-
/// In particular, `sizeof(X.self)`, when `X` is a class type, is the
22-
/// same regardless of how many stored properties `X` has.
23-
@available(*, deprecated, message: "use MemoryLayout<T>.size instead.")
24-
@_transparent
18+
@available(*, unavailable, message: "use MemoryLayout<T>.size instead.")
2519
public func sizeof<T>(_:T.Type) -> Int {
26-
return Int(Builtin.sizeof(T.self))
20+
Builtin.unreachable()
2721
}
2822

29-
/// Returns the contiguous memory footprint of `T`.
30-
///
31-
/// Does not include any dynamically-allocated or "remote" storage.
32-
/// In particular, `sizeof(a)`, when `a` is a class instance, is the
33-
/// same regardless of how many stored properties `a` has.
34-
@available(*, deprecated, message: "use MemoryLayout<T>.size instead.")
35-
@_transparent
23+
@available(*, unavailable, message: "use MemoryLayout<T>.size instead.")
3624
public func sizeofValue<T>(_:T) -> Int {
37-
return sizeof(T.self)
25+
Builtin.unreachable()
3826
}
3927

40-
/// Returns the minimum memory alignment of `T`.
41-
@available(*, deprecated, message: "use MemoryLayout<T>.alignment instead.")
42-
@_transparent
28+
@available(*, unavailable, message: "use MemoryLayout<T>.alignment instead.")
4329
public func alignof<T>(_:T.Type) -> Int {
44-
return Int(Builtin.alignof(T.self))
30+
Builtin.unreachable()
4531
}
4632

47-
/// Returns the minimum memory alignment of `T`.
48-
@available(*, deprecated, message: "use MemoryLayout<T>.alignment instead.")
49-
@_transparent
33+
@available(*, unavailable, message: "use MemoryLayout<T>.alignment instead.")
5034
public func alignofValue<T>(_:T) -> Int {
51-
return alignof(T.self)
35+
Builtin.unreachable()
5236
}
5337

54-
/// Returns the least possible interval between distinct instances of
55-
/// `T` in memory. The result is always positive.
56-
@available(*, deprecated, message: "use MemoryLayout<T>.stride instead.")
57-
@_transparent
38+
@available(*, unavailable, message: "use MemoryLayout<T>.stride instead.")
5839
public func strideof<T>(_:T.Type) -> Int {
59-
return Int(Builtin.strideof_nonzero(T.self))
40+
Builtin.unreachable()
6041
}
6142

62-
/// Returns the least possible interval between distinct instances of
63-
/// `T` in memory. The result is always positive.
64-
@available(*, deprecated, message: "use MemoryLayout<T>.stride instead.")
65-
@_transparent
43+
@available(*, unavailable, message: "use MemoryLayout<T>.stride instead.")
6644
public func strideofValue<T>(_:T) -> Int {
67-
return strideof(T.self)
45+
Builtin.unreachable()
6846
}
6947

7048
// This function is the implementation of the `_roundUp` overload set. It is

0 commit comments

Comments
 (0)