From ed79c31f0929059cb1933a52b0d6a154497fd206 Mon Sep 17 00:00:00 2001 From: David Wood Date: Wed, 8 Aug 2018 21:37:58 +0200 Subject: [PATCH] Tidy no longer fails when there are no files or subdirectories in a test directory. --- ...ature-nll-overrides-migrate.edition.stderr | 9 +++++++ ...feature-nll-overrides-migrate.zflag.stderr | 9 +++++++ .../borrowck-migrate-to-nll.edition.stderr | 24 +++++++++++++++++++ .../borrowck-migrate-to-nll.zflag.stderr | 24 +++++++++++++++++++ .../ui/borrowck/issue-45983.migrate.stderr | 12 ++++++++++ src/test/ui/obsolete-in-place/bad.bad.stderr | 18 ++++++++++++++ src/tools/tidy/src/lib.rs | 20 +++++++++------- 7 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.edition.stderr create mode 100644 src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.zflag.stderr create mode 100644 src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr create mode 100644 src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr create mode 100644 src/test/ui/borrowck/issue-45983.migrate.stderr create mode 100644 src/test/ui/obsolete-in-place/bad.bad.stderr diff --git a/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.edition.stderr b/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.edition.stderr new file mode 100644 index 00000000000..fa82efa3533 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.edition.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-feature-nll-overrides-migrate.rs:32:17 + | +LL | (|| { let bar = foo; bar.take() })(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.zflag.stderr b/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.zflag.stderr new file mode 100644 index 00000000000..fa82efa3533 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.zflag.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-feature-nll-overrides-migrate.rs:32:17 + | +LL | (|| { let bar = foo; bar.take() })(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr b/src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr new file mode 100644 index 00000000000..f5a9db36406 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr @@ -0,0 +1,24 @@ +warning[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-migrate-to-nll.rs:35:17 + | +LL | (|| { let bar = foo; bar.take() })(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content + | + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. + +warning[E0507]: cannot move out of `foo`, as it is immutable for the pattern guard + --> $DIR/borrowck-migrate-to-nll.rs:35:17 + | +LL | (|| { let bar = foo; bar.take() })(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | cannot move out of `foo`, as it is immutable for the pattern guard + | cannot move + | + = note: variables bound in patterns are immutable until the end of the pattern guard + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. + diff --git a/src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr b/src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr new file mode 100644 index 00000000000..f5a9db36406 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr @@ -0,0 +1,24 @@ +warning[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-migrate-to-nll.rs:35:17 + | +LL | (|| { let bar = foo; bar.take() })(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content + | + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. + +warning[E0507]: cannot move out of `foo`, as it is immutable for the pattern guard + --> $DIR/borrowck-migrate-to-nll.rs:35:17 + | +LL | (|| { let bar = foo; bar.take() })(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | cannot move out of `foo`, as it is immutable for the pattern guard + | cannot move + | + = note: variables bound in patterns are immutable until the end of the pattern guard + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. + diff --git a/src/test/ui/borrowck/issue-45983.migrate.stderr b/src/test/ui/borrowck/issue-45983.migrate.stderr new file mode 100644 index 00000000000..db7cedffd8f --- /dev/null +++ b/src/test/ui/borrowck/issue-45983.migrate.stderr @@ -0,0 +1,12 @@ +error: borrowed data cannot be stored outside of its closure + --> $DIR/issue-45983.rs:36:27 + | +LL | let x = None; + | - borrowed data cannot be stored into here... +LL | give_any(|y| x = Some(y)); + | --- ^ cannot be stored outside of its closure + | | + | ...because it cannot outlive this closure + +error: aborting due to previous error + diff --git a/src/test/ui/obsolete-in-place/bad.bad.stderr b/src/test/ui/obsolete-in-place/bad.bad.stderr new file mode 100644 index 00000000000..f870c09d6e5 --- /dev/null +++ b/src/test/ui/obsolete-in-place/bad.bad.stderr @@ -0,0 +1,18 @@ +error: emplacement syntax is obsolete (for now, anyway) + --> $DIR/bad.rs:19:5 + | +LL | x <- y; //[bad]~ ERROR emplacement syntax is obsolete + | ^^^^^^ + | + = note: for more information, see + +error: emplacement syntax is obsolete (for now, anyway) + --> $DIR/bad.rs:20:5 + | +LL | in(foo) { bar }; //[bad]~ ERROR emplacement syntax is obsolete + | ^^^^^^^^^^^^^^^ + | + = note: for more information, see + +error: aborting due to 2 previous errors + diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index bb041b39785..85254c6abb5 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -89,16 +89,18 @@ fn walk_many(paths: &[&Path], skip: &mut dyn FnMut(&Path) -> bool, f: &mut dyn F } fn walk(path: &Path, skip: &mut dyn FnMut(&Path) -> bool, f: &mut dyn FnMut(&Path)) { - for entry in t!(fs::read_dir(path), path) { - let entry = t!(entry); - let kind = t!(entry.file_type()); - let path = entry.path(); - if kind.is_dir() { - if !skip(&path) { - walk(&path, skip, f); + if let Ok(dir) = fs::read_dir(path) { + for entry in dir { + let entry = t!(entry); + let kind = t!(entry.file_type()); + let path = entry.path(); + if kind.is_dir() { + if !skip(&path) { + walk(&path, skip, f); + } + } else { + f(&path); } - } else { - f(&path); } } }