THRIFT-5111: Upgrade rust to 1.36.0
Client: Rust
Patch: Jano Svitok

This closes #2050

Also contains portions of THRIFT-4547: Upgrade Swift in docker to 5.1.4
Client: Swift
Patch: Jano Svitok

Linux version 4.2.0 does not have FileHandle.acceptConnectionInBackgroundAndNotify()
implemented. We need at least 5.1 for TSocketServer to run in docker.

In the meantime, URLRequest was moved to FoundationNetworking.
To keep compatibility with previous versions, conditional import is
used.
diff --git a/build/docker/README.md b/build/docker/README.md
index 6f9c024..6f170e1 100644
--- a/build/docker/README.md
+++ b/build/docker/README.md
@@ -194,4 +194,4 @@
 | ruby      | 2.3.1p112     | 2.5.1p57      |       |
 | rust      | 1.34.0        | 1.35.0        |       |
 | smalltalk |               |               | Not in CI |
-| swift     |               | 4.2.1         |       |
+| swift     |               | 5.1.4         |       |
diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile
index 464af0b..c22a859 100644
--- a/build/docker/ubuntu-bionic/Dockerfile
+++ b/build/docker/ubuntu-bionic/Dockerfile
@@ -247,14 +247,14 @@
       ruby-bundler
 
 # Rust dependencies
-RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.35.0 -y
+RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.36.0 -y
 ENV PATH /root/.cargo/bin:$PATH
 
 # Swift on Linux for cross tests
 RUN cd / && \
-    wget --quiet https://swift.org/builds/swift-4.2.1-release/ubuntu1804/swift-4.2.1-RELEASE/swift-4.2.1-RELEASE-ubuntu18.04.tar.gz && \
-    tar xf swift-4.2.1-RELEASE-ubuntu18.04.tar.gz --strip-components=1 && \
-    rm swift-4.2.1-RELEASE-ubuntu18.04.tar.gz && \
+    wget --quiet https://swift.org/builds/swift-5.1.4-release/ubuntu1804/swift-5.1.4-RELEASE/swift-5.1.4-RELEASE-ubuntu18.04.tar.gz && \
+    tar xf swift-5.1.4-RELEASE-ubuntu18.04.tar.gz --strip-components=1 && \
+    rm swift-5.1.4-RELEASE-ubuntu18.04.tar.gz && \
     swift --version
 
 # cppcheck-1.82 has a nasty cpp parser bug, so we're using something newer
diff --git a/lib/swift/Sources/THTTPSessionTransport.swift b/lib/swift/Sources/THTTPSessionTransport.swift
index 3c0af8e..f66da92 100644
--- a/lib/swift/Sources/THTTPSessionTransport.swift
+++ b/lib/swift/Sources/THTTPSessionTransport.swift
@@ -18,8 +18,15 @@
 */
 
 import Foundation
-import Dispatch
 
+// Conditional import for URLRequest
+// It was moved from Foundation to FoundationNetworking in 5.1, but
+// not on Darwin. See  https://stackoverflow.com/a/58606520
+#if canImport(FoundationNetworking)
+import FoundationNetworking
+#endif
+
+import Dispatch
 
 public class THTTPSessionTransport: TAsyncTransport {
   public class Factory : TAsyncTransportFactory {