   }
 }
 
-/// Convert an arbitrary binary integer to an Int, reinterpreting signed
-/// -> unsigned if needed but trapping if the result is otherwise not
-/// expressible.
-func unsafeBinaryIntegerToInt<T: BinaryInteger>(_ value: T) -> Int {
-    if T.isSigned {
-        return numericCast(value)
-    }
-
-    let uintValue: UInt = numericCast(value)
-    return Int(bitPattern: uintValue)
-}
-
-/// Convert from an Int to an arbitrary binary integer, reinterpreting signed ->
-/// unsigned if needed but trapping if the result is otherwise not expressible.
-func unsafeBinaryIntegerFromInt<T: BinaryInteger>(_ value: Int) -> T {
-  if T.isSigned {
-    return numericCast(value)
-  }
-
-  let uintValue = UInt(bitPattern: value)
-  return numericCast(uintValue)
-}
-
-extension CustomNSError
-    where Self: RawRepresentable, Self.RawValue: FixedWidthInteger {
+extension CustomNSError where Self: RawRepresentable, Self.RawValue: SignedInteger {
   // The error code of Error with integral raw values is the raw value.
   public var errorCode: Int {
-    return unsafeBinaryIntegerToInt(self.rawValue)
+    return numericCast(self.rawValue)
+  }
+}
+
+extension CustomNSError where Self: RawRepresentable, Self.RawValue: UnsignedInteger {
+  // The error code of Error with integral raw values is the raw value.
+  public var errorCode: Int {
+    return numericCast(self.rawValue)
   }
 }
 

    }

    self.init(rawValue: RawValue(_bridgedNSError.code))
  }

  public var hashValue: Int { return _code }

  public var _domain: String { return Self._nsErrorDomain }
}

extension _BridgedNSError where Self.RawValue: SignedInteger {
  public var _code: Int { return Int(rawValue) }

  public init?(_bridgedNSError: NSError) {
