diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-11-14 09:18:10 -0800 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-12-18 12:09:07 -0500 |
| commit | ddb2466f6a1bb66f22824334022a4cee61c73bdc (patch) | |
| tree | 9cb97d3e4c4521b56d0776e5f7bda81e62135be4 /src/libstd/path/posix.rs | |
| parent | c0b2885ee12b79c99ac8245edb6eebaaa8e7fef1 (diff) | |
| download | rust-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/posix.rs')
| -rw-r--r-- | src/libstd/path/posix.rs | 42 |
1 files changed, 21 insertions, 21 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]); |
