Update to latest syn-1.0.16
* fill back missing NOTICE,METADATA,*LICENSE* files
Bug: 150877376
Test: make
Test: atest --host -c --include-subdirs external/rust/crates
Change-Id: Ib5df6b8fb97764214e701a888e44fab3a4245800
diff --git a/tests/repo/mod.rs b/tests/repo/mod.rs
index 02b4e32..6ab8d2e 100644
--- a/tests/repo/mod.rs
+++ b/tests/repo/mod.rs
@@ -1,7 +1,16 @@
-use std::process::Command;
+mod progress;
+use self::progress::Progress;
+use crate::common;
+use anyhow::Result;
+use flate2::read::GzDecoder;
+use std::fs;
+use std::path::Path;
+use tar::Archive;
use walkdir::DirEntry;
+const REVISION: &str = "2c462a2f776b899d46743b1b44eda976e846e61d";
+
pub fn base_dir_filter(entry: &DirEntry) -> bool {
let path = entry.path();
if path.is_dir() {
@@ -10,51 +19,159 @@
if path.extension().map(|e| e != "rs").unwrap_or(true) {
return false;
}
- let path_string = path.to_string_lossy();
- let path_string = if cfg!(windows) {
- path_string.replace('\\', "/").into()
- } else {
- path_string
- };
+
+ let mut path_string = path.to_string_lossy();
+ if cfg!(windows) {
+ path_string = path_string.replace('\\', "/").into();
+ }
+ assert!(path_string.starts_with("tests/rust/src/"));
+ let path = &path_string["tests/rust/src/".len()..];
+
// TODO assert that parsing fails on the parse-fail cases
- if path_string.starts_with("tests/rust/src/test/parse-fail")
- || path_string.starts_with("tests/rust/src/test/compile-fail")
- || path_string.starts_with("tests/rust/src/test/rustfix")
+ if path.starts_with("test/parse-fail")
+ || path.starts_with("test/compile-fail")
+ || path.starts_with("test/rustfix")
{
return false;
}
- if path_string.starts_with("tests/rust/src/test/ui") {
- let stderr_path = path.with_extension("stderr");
+ if path.starts_with("test/ui") {
+ let stderr_path = entry.path().with_extension("stderr");
if stderr_path.exists() {
// Expected to fail in some way
return false;
}
}
- match path_string.as_ref() {
+ match path {
+ // TODO: or-patterns patterns: `Some(1 | 8)`
+ // https://github.com/dtolnay/syn/issues/758
+ "test/mir-opt/exponential-or.rs" |
+ "test/ui/or-patterns/basic-switch.rs" |
+ "test/ui/or-patterns/basic-switchint.rs" |
+ "test/ui/or-patterns/bindings-runpass-1.rs" |
+ "test/ui/or-patterns/bindings-runpass-2.rs" |
+ "test/ui/or-patterns/consistent-bindings.rs" |
+ "test/ui/or-patterns/exhaustiveness-pass.rs" |
+ "test/ui/or-patterns/for-loop.rs" |
+ "test/ui/or-patterns/if-let-while-let.rs" |
+ "test/ui/or-patterns/issue-67514-irrefutable-param.rs" |
+ "test/ui/or-patterns/issue-68785-irrefutable-param-with-at.rs" |
+ "test/ui/or-patterns/let-pattern.rs" |
+ "test/ui/or-patterns/mix-with-wild.rs" |
+ "test/ui/or-patterns/or-patterns-default-binding-modes.rs" |
+ "test/ui/or-patterns/or-patterns-syntactic-pass.rs" |
+ "test/ui/or-patterns/search-via-bindings.rs" |
+ "test/ui/or-patterns/struct-like.rs" |
+
+ // TODO: inner attr in traits: `trait Foo { #![...] }`
+ // https://github.com/dtolnay/syn/issues/759
+ "test/pretty/trait-inner-attr.rs" |
+ "test/ui/parser/inner-attr-in-trait-def.rs" |
+
+ // TODO: const underscore in traits: `trait A { const _: (); }`
+ // https://github.com/dtolnay/syn/issues/760
+ "test/ui/parser/assoc-const-underscore-syntactic-pass.rs" |
+
+ // TODO: top level fn without body: `fn f();`
+ // https://github.com/dtolnay/syn/issues/761
+ "test/ui/parser/fn-body-optional-syntactic-pass.rs" |
+ "test/ui/parser/fn-header-syntactic-pass.rs" |
+
+ // TODO: extern static with value: `extern { static X: u8 = 0; }`
+ // https://github.com/dtolnay/syn/issues/762
+ "test/ui/parser/foreign-static-syntactic-pass.rs" |
+
+ // TODO: extern type with bound: `extern { type A: Ord; }`
+ // https://github.com/dtolnay/syn/issues/763
+ "test/ui/parser/foreign-ty-syntactic-pass.rs" |
+
+ // TODO: top level const/static without value: `const X: u8;`
+ // https://github.com/dtolnay/syn/issues/764
+ "test/ui/parser/item-free-const-no-body-syntactic-pass.rs" |
+ "test/ui/parser/item-free-static-no-body-syntactic-pass.rs" |
+
+ // TODO: mut receiver in fn pointer type: `fn(mut self)`
+ // https://github.com/dtolnay/syn/issues/765
+ "test/ui/parser/self-param-syntactic-pass.rs" |
+
+ // TODO: const trait impls and bounds
+ // https://github.com/dtolnay/syn/issues/766
+ // https://github.com/dtolnay/syn/issues/767
+ "test/ui/rfc-2632-const-trait-impl/assoc-type.rs" |
+ "test/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs" |
+ "test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.rs" |
+ "test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/syntax.rs" |
+ "test/ui/rfc-2632-const-trait-impl/feature-gate.rs" |
+ "test/ui/rfc-2632-const-trait-impl/generic-bound.rs" |
+ "test/ui/rfc-2632-const-trait-impl/syntax.rs" |
+
// Deprecated placement syntax
- "tests/rust/src/test/ui/obsolete-in-place/bad.rs" |
+ "test/ui/obsolete-in-place/bad.rs" |
+
// Deprecated anonymous parameter syntax in traits
- "tests/rust/src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs" |
- "tests/rust/src/test/ui/issues/issue-13105.rs" |
- "tests/rust/src/test/ui/issues/issue-13775.rs" |
- "tests/rust/src/test/ui/issues/issue-34074.rs" |
- // Deprecated await macro syntax
- "tests/rust/src/test/ui/async-await/await-macro.rs" |
+ "test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs" |
+ "test/ui/issues/issue-13105.rs" |
+ "test/ui/issues/issue-13775.rs" |
+ "test/ui/issues/issue-34074.rs" |
+
// 2015-style dyn that libsyntax rejects
- "tests/rust/src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs" |
+ "test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs" |
+
// not actually test cases
- "tests/rust/src/test/ui/include-single-expr-helper.rs" |
- "tests/rust/src/test/ui/include-single-expr-helper-1.rs" |
- "tests/rust/src/test/ui/issues/auxiliary/issue-21146-inc.rs" |
- "tests/rust/src/test/ui/macros/auxiliary/macro-comma-support.rs" |
- "tests/rust/src/test/ui/macros/auxiliary/macro-include-items-expr.rs" => false,
+ "test/rustdoc-ui/test-compile-fail2.rs" |
+ "test/rustdoc-ui/test-compile-fail3.rs" |
+ "test/ui/include-single-expr-helper.rs" |
+ "test/ui/include-single-expr-helper-1.rs" |
+ "test/ui/issues/auxiliary/issue-21146-inc.rs" |
+ "test/ui/macros/auxiliary/macro-comma-support.rs" |
+ "test/ui/macros/auxiliary/macro-include-items-expr.rs" => false,
+
_ => true,
}
}
pub fn clone_rust() {
- let result = Command::new("tests/clone.sh").status().unwrap();
- assert!(result.success());
+ let needs_clone = match fs::read_to_string("tests/rust/COMMIT") {
+ Err(_) => true,
+ Ok(contents) => contents.trim() != REVISION,
+ };
+ if needs_clone {
+ download_and_unpack().unwrap();
+ }
+}
+
+fn download_and_unpack() -> Result<()> {
+ let url = format!(
+ "https://github.com/rust-lang/rust/archive/{}.tar.gz",
+ REVISION
+ );
+ let response = reqwest::blocking::get(&url)?.error_for_status()?;
+ let progress = Progress::new(response);
+ let decoder = GzDecoder::new(progress);
+ let mut archive = Archive::new(decoder);
+ let prefix = format!("rust-{}", REVISION);
+
+ let tests_rust = Path::new("tests/rust");
+ if tests_rust.exists() {
+ fs::remove_dir_all(tests_rust)?;
+ }
+
+ for entry in archive.entries()? {
+ let mut entry = entry?;
+ let path = entry.path()?;
+ if path == Path::new("pax_global_header") {
+ continue;
+ }
+ let relative = path.strip_prefix(&prefix)?;
+ let out = tests_rust.join(relative);
+ entry.unpack(&out)?;
+ if common::travis_ci() {
+ // Something about this makes the travis build not deadlock...
+ errorf!(".");
+ }
+ }
+
+ fs::write("tests/rust/COMMIT", REVISION)?;
+ Ok(())
}
diff --git a/tests/repo/progress.rs b/tests/repo/progress.rs
new file mode 100644
index 0000000..28c8a44
--- /dev/null
+++ b/tests/repo/progress.rs
@@ -0,0 +1,37 @@
+use std::io::{Read, Result};
+use std::time::{Duration, Instant};
+
+pub struct Progress<R> {
+ bytes: usize,
+ tick: Instant,
+ stream: R,
+}
+
+impl<R> Progress<R> {
+ pub fn new(stream: R) -> Self {
+ Progress {
+ bytes: 0,
+ tick: Instant::now() + Duration::from_millis(2000),
+ stream,
+ }
+ }
+}
+
+impl<R: Read> Read for Progress<R> {
+ fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
+ let num = self.stream.read(buf)?;
+ self.bytes += num;
+ let now = Instant::now();
+ if now > self.tick {
+ self.tick = now + Duration::from_millis(500);
+ errorf!("downloading... {} bytes\n", self.bytes);
+ }
+ Ok(num)
+ }
+}
+
+impl<R> Drop for Progress<R> {
+ fn drop(&mut self) {
+ errorf!("done ({} bytes)\n", self.bytes);
+ }
+}