about summary refs log tree commit diff
path: root/src/libstd/path
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-11-14 09:18:10 -0800
committerJorge Aparicio <japaricious@gmail.com>2014-12-18 12:09:07 -0500
commitddb2466f6a1bb66f22824334022a4cee61c73bdc (patch)
tree9cb97d3e4c4521b56d0776e5f7bda81e62135be4 /src/libstd/path
parentc0b2885ee12b79c99ac8245edb6eebaaa8e7fef1 (diff)
downloadrust-ddb2466f6a1bb66f22824334022a4cee61c73bdc.tar.gz
rust-ddb2466f6a1bb66f22824334022a4cee61c73bdc.zip
librustc: Always parse `macro!()`/`macro![]` as expressions if not
followed by a semicolon.

This allows code like `vec![1i, 2, 3].len();` to work.

This breaks code that uses macros as statements without putting
semicolons after them, such as:

    fn main() {
        ...
        assert!(a == b)
        assert!(c == d)
        println(...);
    }

It also breaks code that uses macros as items without semicolons:

    local_data_key!(foo)

    fn main() {
        println("hello world")
    }

Add semicolons to fix this code. Those two examples can be fixed as
follows:

    fn main() {
        ...
        assert!(a == b);
        assert!(c == d);
        println(...);
    }

    local_data_key!(foo);

    fn main() {
        println("hello world")
    }

RFC #378.

Closes #18635.

[breaking-change]
Diffstat (limited to 'src/libstd/path')
-rw-r--r--src/libstd/path/posix.rs42
-rw-r--r--src/libstd/path/windows.rs42
2 files changed, 42 insertions, 42 deletions
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs
index bea51712253..f872aa8e9a4 100644
--- a/src/libstd/path/posix.rs
+++ b/src/libstd/path/posix.rs
@@ -447,7 +447,7 @@ mod tests {
     use str;
     use str::StrPrelude;
 
-    macro_rules! t(
+    macro_rules! t {
         (s: $path:expr, $exp:expr) => (
             {
                 let path = $path;
@@ -460,7 +460,7 @@ mod tests {
                 assert!(path.as_vec() == $exp);
             }
         )
-    )
+    }
 
     #[test]
     fn test_paths() {
@@ -533,14 +533,14 @@ mod tests {
 
     #[test]
     fn test_display_str() {
-        macro_rules! t(
+        macro_rules! t {
             ($path:expr, $disp:ident, $exp:expr) => (
                 {
                     let path = Path::new($path);
                     assert!(path.$disp().to_string() == $exp);
                 }
             )
-        )
+        }
         t!("foo", display, "foo");
         t!(b"foo\x80", display, "foo\u{FFFD}");
         t!(b"foo\xFFbar", display, "foo\u{FFFD}bar");
@@ -563,7 +563,7 @@ mod tests {
                     assert!(mo.as_slice() == $exp);
                 }
             )
-        )
+        );
 
         t!("foo", "foo");
         t!(b"foo\x80", "foo\u{FFFD}");
@@ -585,7 +585,7 @@ mod tests {
                     assert!(f == $expf);
                 }
             )
-        )
+        );
 
         t!(b"foo", "foo", "foo");
         t!(b"foo/bar", "foo/bar", "bar");
@@ -619,7 +619,7 @@ mod tests {
                     assert!(path.$op() == $exp);
                 }
             );
-        )
+        );
 
         t!(v: b"a/b/c", filename, Some(b"c"));
         t!(v: b"a/b/c\xFF", filename, Some(b"c\xFF"));
@@ -693,7 +693,7 @@ mod tests {
                     assert!(p1 == p2.join(join));
                 }
             )
-        )
+        );
 
         t!(s: "a/b/c", "..");
         t!(s: "/a/b/c", "d");
@@ -712,7 +712,7 @@ mod tests {
                     assert!(p.as_str() == Some($exp));
                 }
             )
-        )
+        );
 
         t!(s: "a/b/c", "d", "a/b/c/d");
         t!(s: "/a/b/c", "d", "/a/b/c/d");
@@ -739,7 +739,7 @@ mod tests {
                     assert!(p.as_vec() == $exp);
                 }
             )
-        )
+        );
 
         t!(s: "a/b/c", ["d", "e"], "a/b/c/d/e");
         t!(s: "a/b/c", ["d", "/e"], "/e");
@@ -769,7 +769,7 @@ mod tests {
                     assert!(result == $right);
                 }
             )
-        )
+        );
 
         t!(b: b"a/b/c", b"a/b", true);
         t!(b: b"a", b".", true);
@@ -817,7 +817,7 @@ mod tests {
                     assert!(res.as_str() == Some($exp));
                 }
             )
-        )
+        );
 
         t!(s: "a/b/c", "..", "a/b");
         t!(s: "/a/b/c", "d", "/a/b/c/d");
@@ -844,7 +844,7 @@ mod tests {
                     assert!(res.as_vec() == $exp);
                 }
             )
-        )
+        );
 
         t!(s: "a/b/c", ["d", "e"], "a/b/c/d/e");
         t!(s: "a/b/c", ["..", "d"], "a/b/d");
@@ -928,7 +928,7 @@ mod tests {
                     assert!(p1 == p2.$with(arg));
                 }
             )
-        )
+        );
 
         t!(v: b"a/b/c", set_filename, with_filename, b"d");
         t!(v: b"/", set_filename, with_filename, b"foo");
@@ -982,7 +982,7 @@ mod tests {
                     assert!(path.extension() == $ext);
                 }
             )
-        )
+        );
 
         t!(v: Path::new(b"a/b/c"), Some(b"c"), b"a/b", Some(b"c"), None);
         t!(v: Path::new(b"a/b/\xFF"), Some(b"\xFF"), b"a/b", Some(b"\xFF"), None);
@@ -1029,7 +1029,7 @@ mod tests {
                     assert_eq!(path.is_relative(), $rel);
                 }
             )
-        )
+        );
         t!(s: "a/b/c", false, true);
         t!(s: "/a/b/c", true, false);
         t!(s: "a", false, true);
@@ -1050,7 +1050,7 @@ mod tests {
                     assert_eq!(path.is_ancestor_of(&dest), $exp);
                 }
             )
-        )
+        );
 
         t!(s: "a/b/c", "a/b/c/d", true);
         t!(s: "a/b/c", "a/b/c", true);
@@ -1091,7 +1091,7 @@ mod tests {
                     assert_eq!(path.ends_with_path(&child), $exp);
                 }
             )
-        )
+        );
 
         t!(s: "a/b/c", "c", true);
         t!(s: "a/b/c", "d", false);
@@ -1124,7 +1124,7 @@ mod tests {
                     assert_eq!(res.as_ref().and_then(|x| x.as_str()), $exp);
                 }
             )
-        )
+        );
 
         t!(s: "a/b/c", "a/b", Some("c"));
         t!(s: "a/b/c", "a/b/d", Some("../c"));
@@ -1186,7 +1186,7 @@ mod tests {
                     assert_eq!(comps, exp)
                 }
             )
-        )
+        );
 
         t!(b: b"a/b/c", [b"a", b"b", b"c"]);
         t!(b: b"/\xFF/a/\x80", [b"\xFF", b"a", b"\x80"]);
@@ -1218,7 +1218,7 @@ mod tests {
                     assert_eq!(comps, exp);
                 }
             )
-        )
+        );
 
         t!(b: b"a/b/c", [Some("a"), Some("b"), Some("c")]);
         t!(b: b"/\xFF/a/\x80", [None, Some("a"), None]);
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs
index 8b18d1d8cd4..b376f6d0d5b 100644
--- a/src/libstd/path/windows.rs
+++ b/src/libstd/path/windows.rs
@@ -1122,7 +1122,7 @@ mod tests {
     use super::*;
     use super::parse_prefix;
 
-    macro_rules! t(
+    macro_rules! t {
         (s: $path:expr, $exp:expr) => (
             {
                 let path = $path;
@@ -1135,7 +1135,7 @@ mod tests {
                 assert!(path.as_vec() == $exp);
             }
         )
-    )
+    }
 
     #[test]
     fn test_parse_prefix() {
@@ -1149,7 +1149,7 @@ mod tests {
                             "parse_prefix(\"{}\"): expected {}, found {}", path, exp, res);
                 }
             )
-        )
+        );
 
         t!("\\\\SERVER\\share\\foo", Some(UNCPrefix(6,5)));
         t!("\\\\", None);
@@ -1348,7 +1348,7 @@ mod tests {
                     assert_eq!(f, $expf);
                 }
             )
-        )
+        );
 
         t!("foo", "foo", "foo");
         t!("foo\\bar", "foo\\bar", "bar");
@@ -1380,7 +1380,7 @@ mod tests {
                     assert!(path.$op() == $exp);
                 }
             )
-        )
+        );
 
         t!(v: b"a\\b\\c", filename, Some(b"c"));
         t!(s: "a\\b\\c", filename_str, "c");
@@ -1491,7 +1491,7 @@ mod tests {
                     assert!(p1 == p2.join(join));
                 }
             )
-        )
+        );
 
         t!(s: "a\\b\\c", "..");
         t!(s: "\\a\\b\\c", "d");
@@ -1524,7 +1524,7 @@ mod tests {
                     assert_eq!(p.as_str(), Some($exp));
                 }
             )
-        )
+        );
 
         t!(s: "a\\b\\c", "d", "a\\b\\c\\d");
         t!(s: "\\a\\b\\c", "d", "\\a\\b\\c\\d");
@@ -1582,7 +1582,7 @@ mod tests {
                     assert_eq!(p.as_vec(), $exp);
                 }
             )
-        )
+        );
 
         t!(s: "a\\b\\c", ["d", "e"], "a\\b\\c\\d\\e");
         t!(s: "a\\b\\c", ["d", "\\e"], "\\e");
@@ -1617,7 +1617,7 @@ mod tests {
                     assert!(result == $right);
                 }
             )
-        )
+        );
 
         t!(s: "a\\b\\c", "a\\b", true);
         t!(s: "a", ".", true);
@@ -1694,7 +1694,7 @@ mod tests {
                     assert_eq!(res.as_str(), Some($exp));
                 }
             )
-        )
+        );
 
         t!(s: "a\\b\\c", "..", "a\\b");
         t!(s: "\\a\\b\\c", "d", "\\a\\b\\c\\d");
@@ -1723,7 +1723,7 @@ mod tests {
                     assert_eq!(res.as_vec(), $exp);
                 }
             )
-        )
+        );
 
         t!(s: "a\\b\\c", ["d", "e"], "a\\b\\c\\d\\e");
         t!(s: "a\\b\\c", ["..", "d"], "a\\b\\d");
@@ -1749,7 +1749,7 @@ mod tests {
                             pstr, stringify!($op), arg, exp, res.as_str().unwrap());
                 }
             )
-        )
+        );
 
         t!(s: "a\\b\\c", with_filename, "d", "a\\b\\d");
         t!(s: ".", with_filename, "foo", "foo");
@@ -1842,7 +1842,7 @@ mod tests {
                     assert!(p1 == p2.$with(arg));
                 }
             )
-        )
+        );
 
         t!(v: b"a\\b\\c", set_filename, with_filename, b"d");
         t!(v: b"\\", set_filename, with_filename, b"foo");
@@ -1897,7 +1897,7 @@ mod tests {
                     assert!(path.extension() == $ext);
                 }
             )
-        )
+        );
 
         t!(v: Path::new(b"a\\b\\c"), Some(b"c"), b"a\\b", Some(b"c"), None);
         t!(s: Path::new("a\\b\\c"), Some("c"), Some("a\\b"), Some("c"), None);
@@ -1951,7 +1951,7 @@ mod tests {
                             path.as_str().unwrap(), rel, b);
                 }
             )
-        )
+        );
         t!("a\\b\\c", false, false, false, true);
         t!("\\a\\b\\c", false, true, false, false);
         t!("a", false, false, false, true);
@@ -1984,7 +1984,7 @@ mod tests {
                             path.as_str().unwrap(), dest.as_str().unwrap(), exp, res);
                 }
             )
-        )
+        );
 
         t!(s: "a\\b\\c", "a\\b\\c\\d", true);
         t!(s: "a\\b\\c", "a\\b\\c", true);
@@ -2083,7 +2083,7 @@ mod tests {
                     assert_eq!(path.ends_with_path(&child), $exp);
                 }
             );
-        )
+        );
 
         t!(s: "a\\b\\c", "c", true);
         t!(s: "a\\b\\c", "d", false);
@@ -2120,7 +2120,7 @@ mod tests {
                             res.as_ref().and_then(|x| x.as_str()));
                 }
             )
-        )
+        );
 
         t!(s: "a\\b\\c", "a\\b", Some("c"));
         t!(s: "a\\b\\c", "a\\b\\d", Some("..\\c"));
@@ -2255,7 +2255,7 @@ mod tests {
                     assert_eq!(comps, exp);
                 }
             );
-        )
+        );
 
         t!(s: b"a\\b\\c", ["a", "b", "c"]);
         t!(s: "a\\b\\c", ["a", "b", "c"]);
@@ -2311,7 +2311,7 @@ mod tests {
                     assert_eq!(comps, exp);
                 }
             )
-        )
+        );
 
         t!(s: "a\\b\\c", [b"a", b"b", b"c"]);
         t!(s: ".", [b"."]);
@@ -2329,7 +2329,7 @@ mod tests {
                     assert!(make_non_verbatim(&path) == exp);
                 }
             )
-        )
+        );
 
         t!(r"\a\b\c", Some(r"\a\b\c"));
         t!(r"a\b\c", Some(r"a\b\c"));