rust: upgrade to Rust 1.51.0

This includes new CVE patches from upstream gentoo.

BUG=chromium:1192744
TEST=CQ & SDK builder

Change-Id: I6df4317c501b5ff81efbe4370426cb5479587e59
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/chromiumos-overlay/+/2787395
Tested-by: George Burgess <gbiv@chromium.org>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
diff --git a/dev-lang/rust/files/rust-1.51.0-Handle-sparse-git-repo-without-erroring.patch b/dev-lang/rust/files/rust-1.51.0-Handle-sparse-git-repo-without-erroring.patch
new file mode 100644
index 0000000..fe536c9
--- /dev/null
+++ b/dev-lang/rust/files/rust-1.51.0-Handle-sparse-git-repo-without-erroring.patch
@@ -0,0 +1,62 @@
+Cherry-pick of https://github.com/rust-lang/cargo/pull/8775, so that
+cargo works with git worktrees.
+
+diff --git a/src/tools/cargo/src/cargo/sources/path.rs b/src/tools/cargo/src/cargo/sources/path.rs
+index 64b0f77ed..f7dcfee7b 100644
+--- a/src/tools/cargo/src/cargo/sources/path.rs
++++ b/src/tools/cargo/src/cargo/sources/path.rs
+@@ -191,12 +191,25 @@ impl<'cfg> PathSource<'cfg> {
+         let index = repo
+             .index()
+             .chain_err(|| format!("failed to open git index at {}", repo.path().display()))?;
+-        let repo_root = repo.workdir().ok_or_else(|| {
+-            anyhow::format_err!(
++        let repo_root = if let Some(root) = repo.workdir() {
++            root
++        } else if !repo.is_bare() {
++            // Sparse-checkouts (and possibly other git
++            // configurations) make libgit2 confused but there's still
++            // an actual non-bare repo here.
++            if let Some(r) = repo.path().parent() {
++                r
++            } else {
++                return Err(anyhow::format_err!(
++                    "repo path missing .git subfolder even when non-bare",
++                ));
++            }
++        } else {
++            return Err(anyhow::format_err!(
+                 "did not expect repo at {} to be bare",
+                 repo.path().display()
+-            )
+-        })?;
++            ));
++        };
+         let repo_relative_path = match paths::strip_prefix_canonical(root, repo_root) {
+             Ok(p) => p,
+             Err(e) => {
+@@ -225,9 +238,21 @@ impl<'cfg> PathSource<'cfg> {
+     ) -> CargoResult<Vec<PathBuf>> {
+         warn!("list_files_git {}", pkg.package_id());
+         let index = repo.index()?;
+-        let root = repo
+-            .workdir()
+-            .ok_or_else(|| anyhow::format_err!("can't list files on a bare repository"))?;
++        let root = if let Some(root) = repo.workdir() {
++            root
++        } else if !repo.is_bare() {
++            // Sparse-checkouts (and possibly other git
++            // configurations) make libgit2 confused but there's still
++            // an actual non-bare repo here.
++            if let Some(r) = repo.path().parent() {
++                r
++            } else {
++                return Err(anyhow::format_err!("malformed non-bare repository root",));
++            }
++        } else {
++            return Err(anyhow::format_err!("can't list files on a bare repository",));
++        };
++
+         let pkg_path = pkg.root();
+
+         let mut ret = Vec::<PathBuf>::new();