Skip to content

Commit ccf555c

Browse files
Dave AbrahamsDave Abrahams
authored andcommitted
[stdlib] Improve unavailable diagnostics
Making these generic and removing inout from the arguments cuts down on the number of useless notes we give users when they try to use them. Arguably the compiler should do better, but this moves our test results along.
1 parent 0d1477a commit ccf555c

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -914,43 +914,6 @@ extension ${Self} : Strideable {
914914
// Deprecated operators
915915
//===----------------------------------------------------------------------===//
916916

917-
@_transparent
918-
@available(*, unavailable, message: "Use truncatingRemainder instead")
919-
public func % (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
920-
fatalError("% is not available.")
921-
}
922-
923-
@_transparent
924-
@available(*, unavailable, message: "Use formTruncatingRemainder instead")
925-
public func %= (lhs: inout ${Self}, rhs: ${Self}) {
926-
fatalError("%= is not available.")
927-
}
928-
929-
@_transparent
930-
@available(*, unavailable, message: "use += 1")
931-
@discardableResult
932-
public prefix func ++ (rhs: inout ${Self}) -> ${Self} {
933-
fatalError("++ is not available")
934-
}
935-
@_transparent
936-
@available(*, unavailable, message: "use -= 1")
937-
@discardableResult
938-
public prefix func -- (rhs: inout ${Self}) -> ${Self} {
939-
fatalError("-- is not available")
940-
}
941-
@_transparent
942-
@available(*, unavailable, message: "use += 1")
943-
@discardableResult
944-
public postfix func ++ (lhs: inout ${Self}) -> ${Self} {
945-
fatalError("++ is not available")
946-
}
947-
@_transparent
948-
@available(*, unavailable, message: "use -= 1")
949-
@discardableResult
950-
public postfix func -- (lhs: inout ${Self}) -> ${Self} {
951-
fatalError("-- is not available")
952-
}
953-
954917
% if bits == 80:
955918
#endif
956919
% end
@@ -1006,3 +969,40 @@ extension ${Self} {
1006969
}
1007970

1008971
% end # for (bits, signed) in allInts()
972+
973+
@_transparent
974+
@available(*, unavailable, message: "Use truncatingRemainder instead")
975+
public func % <T: FloatingPoint> (lhs: T, rhs: T) -> T {
976+
fatalError("% is not available.")
977+
}
978+
979+
@_transparent
980+
@available(*, unavailable, message: "Use formTruncatingRemainder instead")
981+
public func %= <T: FloatingPoint> (lhs: T, rhs: T) {
982+
fatalError("%= is not available.")
983+
}
984+
985+
@_transparent
986+
@available(*, unavailable, message: "use += 1")
987+
@discardableResult
988+
public prefix func ++ <T: Arithmetic> (rhs: T) -> T {
989+
fatalError("++ is not available")
990+
}
991+
@_transparent
992+
@available(*, unavailable, message: "use -= 1")
993+
@discardableResult
994+
public prefix func -- <T: Arithmetic> (rhs: T) -> T {
995+
fatalError("-- is not available")
996+
}
997+
@_transparent
998+
@available(*, unavailable, message: "use += 1")
999+
@discardableResult
1000+
public postfix func ++ <T: Arithmetic> (lhs: T) -> T {
1001+
fatalError("++ is not available")
1002+
}
1003+
@_transparent
1004+
@available(*, unavailable, message: "use -= 1")
1005+
@discardableResult
1006+
public postfix func -- <T: Arithmetic> (lhs: T) -> T {
1007+
fatalError("-- is not available")
1008+
}

0 commit comments

Comments
 (0)