]> git.lizzy.rs Git - rust.git/commitdiff
Add ui tests
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 24 Apr 2017 14:26:04 +0000 (16:26 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Tue, 25 Apr 2017 10:21:28 +0000 (12:21 +0200)
src/libsyntax/parse/parser.rs
src/test/compile-fail/auxiliary/foo/bar.rs [deleted file]
src/test/compile-fail/auxiliary/foo/mod.rs [deleted file]
src/test/compile-fail/invalid-module-declaration.rs [deleted file]
src/test/ui/invalid-module-declaration/auxiliary/foo/bar.rs [new file with mode: 0644]
src/test/ui/invalid-module-declaration/auxiliary/foo/mod.rs [new file with mode: 0644]
src/test/ui/invalid-module-declaration/invalid-module-declaration.rs [new file with mode: 0644]
src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr [new file with mode: 0644]

index 9df791c1c124efb48ee6b096f40bc2aed6aad298..afdb0cc4fdb791a484a63a819b86fb1804830466 100644 (file)
 use symbol::{Symbol, keywords};
 use util::ThinVec;
 
+use std::cmp;
 use std::collections::HashSet;
 use std::mem;
-use std::path::{Path, PathBuf};
-use std::rc::Rc;
+use std::path::{self, Path, PathBuf};
 use std::slice;
 
 bitflags! {
@@ -5367,7 +5367,7 @@ fn submod_path(&mut self,
                 "cannot declare a new module at this location");
             if id_sp != syntax_pos::DUMMY_SP {
                 let src_path = PathBuf::from(self.sess.codemap().span_to_filename(id_sp));
-                if let Some(stem) = src_path.clone().file_stem() {
+                if let Some(stem) = src_path.file_stem() {
                     let mut dest_path = src_path.clone();
                     dest_path.set_file_name(stem);
                     dest_path.push("mod.rs");
@@ -5385,10 +5385,7 @@ fn submod_path(&mut self,
             }
             Err(err)
         } else {
-            match paths.result {
-                Ok(succ) => Ok(succ),
-                Err(err) => Err(self.span_fatal_err(id_sp, err)),
-            }
+            paths.result.map_err(|err| self.span_fatal_err(id_sp, err))
         }
     }
 
diff --git a/src/test/compile-fail/auxiliary/foo/bar.rs b/src/test/compile-fail/auxiliary/foo/bar.rs
deleted file mode 100644 (file)
index 4b6b4f5..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-pub mod baz;
diff --git a/src/test/compile-fail/auxiliary/foo/mod.rs b/src/test/compile-fail/auxiliary/foo/mod.rs
deleted file mode 100644 (file)
index 6d77fb6..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-pub mod bar;
diff --git a/src/test/compile-fail/invalid-module-declaration.rs b/src/test/compile-fail/invalid-module-declaration.rs
deleted file mode 100644 (file)
index c15cfb8..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// ignore-tidy-linelength
-
-// error-pattern: cannot declare a new module at this location
-// error-pattern: maybe move this module
-
-mod auxiliary {
-    mod foo;
-}
-
-fn main() {}
diff --git a/src/test/ui/invalid-module-declaration/auxiliary/foo/bar.rs b/src/test/ui/invalid-module-declaration/auxiliary/foo/bar.rs
new file mode 100644 (file)
index 0000000..4b6b4f5
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub mod baz;
diff --git a/src/test/ui/invalid-module-declaration/auxiliary/foo/mod.rs b/src/test/ui/invalid-module-declaration/auxiliary/foo/mod.rs
new file mode 100644 (file)
index 0000000..6d77fb6
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub mod bar;
diff --git a/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs b/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs
new file mode 100644 (file)
index 0000000..c15cfb8
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-tidy-linelength
+
+// error-pattern: cannot declare a new module at this location
+// error-pattern: maybe move this module
+
+mod auxiliary {
+    mod foo;
+}
+
+fn main() {}
diff --git a/src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr b/src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr
new file mode 100644 (file)
index 0000000..3e9b21c
--- /dev/null
@@ -0,0 +1,14 @@
+error: cannot declare a new module at this location
+  --> $DIR/auxiliary/foo/bar.rs:11:9
+   |
+11 | pub mod baz;
+   |         ^^^
+   |
+note: maybe move this module `$DIR/auxiliary/foo/bar.rs` to its own directory via `$DIR/auxiliary/foo/bar/mod.rs`
+  --> $DIR/auxiliary/foo/bar.rs:11:9
+   |
+11 | pub mod baz;
+   |         ^^^
+
+error: aborting due to previous error
+