about summary refs log tree commit diff
path: root/src/libstd/path
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2014-06-18 20:25:36 +0200
committerAlex Crichton <alex@alexcrichton.com>2014-06-18 17:02:22 -0700
commit108b8b6dc707775bd54aeea7820e0d473f556718 (patch)
treea848b9df4646e3311158381252a211a4b8ee2771 /src/libstd/path
parentabf7e933df0c732f14b5b8906161e74e72cd26ca (diff)
downloadrust-108b8b6dc707775bd54aeea7820e0d473f556718.tar.gz
rust-108b8b6dc707775bd54aeea7820e0d473f556718.zip
Deprecate the bytes!() macro.
Replace its usage with byte string literals, except in `bytes!()` tests.
Also add a new snapshot, to be able to use the new b"foo" syntax.

The src/etc/2014-06-rewrite-bytes-macros.py script automatically
rewrites `bytes!()` invocations into byte string literals.
Pass it filenames as arguments to generate a diff that you can inspect,
or `--apply` followed by filenames to apply the changes in place.
Diffs can be piped into `tip` or `pygmentize -l diff` for coloring.
Diffstat (limited to 'src/libstd/path')
-rw-r--r--src/libstd/path/mod.rs4
-rw-r--r--src/libstd/path/posix.rs265
-rw-r--r--src/libstd/path/windows.rs107
3 files changed, 173 insertions, 203 deletions
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs
index 7d15893af24..e55dc165895 100644
--- a/src/libstd/path/mod.rs
+++ b/src/libstd/path/mod.rs
@@ -219,7 +219,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
                 let dot = '.' as u8;
                 match name.rposition_elem(&dot) {
                     None | Some(0) => name,
-                    Some(1) if name == bytes!("..") => name,
+                    Some(1) if name == b".." => name,
                     Some(pos) => name.slice_to(pos)
                 }
             })
@@ -242,7 +242,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
                 let dot = '.' as u8;
                 match name.rposition_elem(&dot) {
                     None | Some(0) => None,
-                    Some(1) if name == bytes!("..") => None,
+                    Some(1) if name == b".." => None,
                     Some(pos) => Some(name.slice_from(pos+1))
                 }
             }
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs
index 494428de3a5..d98cfb7d8ee 100644
--- a/src/libstd/path/posix.rs
+++ b/src/libstd/path/posix.rs
@@ -142,7 +142,7 @@ impl GenericPathUnsafe for Path {
     unsafe fn set_filename_unchecked<T: BytesContainer>(&mut self, filename: T) {
         let filename = filename.container_as_bytes();
         match self.sepidx {
-            None if bytes!("..") == self.repr.as_slice() => {
+            None if b".." == self.repr.as_slice() => {
                 let mut v = Vec::with_capacity(3 + filename.len());
                 v.push_all(dot_dot_static);
                 v.push(SEP_BYTE);
@@ -153,7 +153,7 @@ impl GenericPathUnsafe for Path {
             None => {
                 self.repr = Path::normalize(filename);
             }
-            Some(idx) if self.repr.slice_from(idx+1) == bytes!("..") => {
+            Some(idx) if self.repr.slice_from(idx+1) == b".." => {
                 let mut v = Vec::with_capacity(self.repr.len() + 1 + filename.len());
                 v.push_all(self.repr.as_slice());
                 v.push(SEP_BYTE);
@@ -202,20 +202,20 @@ impl GenericPath for Path {
 
     fn dirname<'a>(&'a self) -> &'a [u8] {
         match self.sepidx {
-            None if bytes!("..") == self.repr.as_slice() => self.repr.as_slice(),
+            None if b".." == self.repr.as_slice() => self.repr.as_slice(),
             None => dot_static,
             Some(0) => self.repr.slice_to(1),
-            Some(idx) if self.repr.slice_from(idx+1) == bytes!("..") => self.repr.as_slice(),
+            Some(idx) if self.repr.slice_from(idx+1) == b".." => self.repr.as_slice(),
             Some(idx) => self.repr.slice_to(idx)
         }
     }
 
     fn filename<'a>(&'a self) -> Option<&'a [u8]> {
         match self.sepidx {
-            None if bytes!(".") == self.repr.as_slice() ||
-                bytes!("..") == self.repr.as_slice() => None,
+            None if b"." == self.repr.as_slice() ||
+                b".." == self.repr.as_slice() => None,
             None => Some(self.repr.as_slice()),
-            Some(idx) if self.repr.slice_from(idx+1) == bytes!("..") => None,
+            Some(idx) if self.repr.slice_from(idx+1) == b".." => None,
             Some(0) if self.repr.slice_from(1).is_empty() => None,
             Some(idx) => Some(self.repr.slice_from(idx+1))
         }
@@ -223,13 +223,13 @@ impl GenericPath for Path {
 
     fn pop(&mut self) -> bool {
         match self.sepidx {
-            None if bytes!(".") == self.repr.as_slice() => false,
+            None if b"." == self.repr.as_slice() => false,
             None => {
                 self.repr = vec!['.' as u8];
                 self.sepidx = None;
                 true
             }
-            Some(0) if bytes!("/") == self.repr.as_slice() => false,
+            Some(0) if b"/" == self.repr.as_slice() => false,
             Some(idx) => {
                 if idx == 0 {
                     self.repr.truncate(idx+1);
@@ -261,19 +261,19 @@ impl GenericPath for Path {
         } else {
             let mut ita = self.components();
             let mut itb = other.components();
-            if bytes!(".") == self.repr.as_slice() {
+            if b"." == self.repr.as_slice() {
                 return match itb.next() {
                     None => true,
-                    Some(b) => b != bytes!("..")
+                    Some(b) => b != b".."
                 };
             }
             loop {
                 match (ita.next(), itb.next()) {
                     (None, _) => break,
                     (Some(a), Some(b)) if a == b => { continue },
-                    (Some(a), _) if a == bytes!("..") => {
+                    (Some(a), _) if a == b".." => {
                         // if ita contains only .. components, it's an ancestor
-                        return ita.all(|x| x == bytes!(".."));
+                        return ita.all(|x| x == b"..");
                     }
                     _ => return false
                 }
@@ -303,8 +303,8 @@ impl GenericPath for Path {
                     }
                     (None, _) => comps.push(dot_dot_static),
                     (Some(a), Some(b)) if comps.is_empty() && a == b => (),
-                    (Some(a), Some(b)) if b == bytes!(".") => comps.push(a),
-                    (Some(_), Some(b)) if b == bytes!("..") => return None,
+                    (Some(a), Some(b)) if b == b"." => comps.push(a),
+                    (Some(_), Some(b)) if b == b".." => return None,
                     (Some(a), Some(_)) => {
                         comps.push(dot_dot_static);
                         for _ in itb {
@@ -425,8 +425,8 @@ fn normalize_helper<'a>(v: &'a [u8], is_abs: bool) -> Option<Vec<&'a [u8]>> {
     let mut changed = false;
     for comp in v.split(is_sep_byte) {
         if comp.is_empty() { changed = true }
-        else if comp == bytes!(".") { changed = true }
-        else if comp == bytes!("..") {
+        else if comp == b"." { changed = true }
+        else if comp == b".." {
             if is_abs && comps.is_empty() { changed = true }
             else if comps.len() == n_up { comps.push(dot_dot_static); n_up += 1 }
             else { comps.pop().unwrap(); changed = true }
@@ -434,7 +434,7 @@ fn normalize_helper<'a>(v: &'a [u8], is_abs: bool) -> Option<Vec<&'a [u8]>> {
     }
     if changed {
         if comps.is_empty() && !is_abs {
-            if v == bytes!(".") {
+            if v == b"." {
                 return None;
             }
             comps.push(dot_static);
@@ -445,8 +445,8 @@ fn normalize_helper<'a>(v: &'a [u8], is_abs: bool) -> Option<Vec<&'a [u8]>> {
     }
 }
 
-static dot_static: &'static [u8] = bytes!(".");
-static dot_dot_static: &'static [u8] = bytes!("..");
+static dot_static: &'static [u8] = b".";
+static dot_dot_static: &'static [u8] = b"..";
 
 #[cfg(test)]
 mod tests {
@@ -470,24 +470,15 @@ mod tests {
         )
     )
 
-    macro_rules! b(
-        ($($arg:expr),+) => (
-            {
-                static the_bytes: &'static [u8] = bytes!($($arg),+);
-                the_bytes
-            }
-        )
-    )
-
     #[test]
     fn test_paths() {
         let empty: &[u8] = [];
-        t!(v: Path::new(empty), b!("."));
-        t!(v: Path::new(b!("/")), b!("/"));
-        t!(v: Path::new(b!("a/b/c")), b!("a/b/c"));
-        t!(v: Path::new(b!("a/b/c", 0xff)), b!("a/b/c", 0xff));
-        t!(v: Path::new(b!(0xff, "/../foo", 0x80)), b!("foo", 0x80));
-        let p = Path::new(b!("a/b/c", 0xff));
+        t!(v: Path::new(empty), b".");
+        t!(v: Path::new(b"/"), b"/");
+        t!(v: Path::new(b"a/b/c"), b"a/b/c");
+        t!(v: Path::new(b"a/b/c\xFF"), b"a/b/c\xFF");
+        t!(v: Path::new(b"\xFF/../foo\x80"), b"foo\x80");
+        let p = Path::new(b"a/b/c\xFF");
         assert!(p.as_str() == None);
 
         t!(s: Path::new(""), ".");
@@ -513,18 +504,18 @@ mod tests {
         t!(s: Path::new("foo/../../.."), "../..");
         t!(s: Path::new("foo/../../bar"), "../bar");
 
-        assert_eq!(Path::new(b!("foo/bar")).into_vec().as_slice(), b!("foo/bar"));
-        assert_eq!(Path::new(b!("/foo/../../bar")).into_vec().as_slice(),
-                   b!("/bar"));
+        assert_eq!(Path::new(b"foo/bar").into_vec().as_slice(), b"foo/bar");
+        assert_eq!(Path::new(b"/foo/../../bar").into_vec().as_slice(),
+                   b"/bar");
 
-        let p = Path::new(b!("foo/bar", 0x80));
+        let p = Path::new(b"foo/bar\x80");
         assert!(p.as_str() == None);
     }
 
     #[test]
     fn test_opt_paths() {
-        assert!(Path::new_opt(b!("foo/bar", 0)) == None);
-        t!(v: Path::new_opt(b!("foo/bar")).unwrap(), b!("foo/bar"));
+        assert!(Path::new_opt(b"foo/bar\0") == None);
+        t!(v: Path::new_opt(b"foo/bar").unwrap(), b"foo/bar");
         assert!(Path::new_opt("foo/bar\0") == None);
         t!(s: Path::new_opt("foo/bar").unwrap(), "foo/bar");
     }
@@ -533,17 +524,17 @@ mod tests {
     fn test_null_byte() {
         use task;
         let result = task::try(proc() {
-            Path::new(b!("foo/bar", 0))
+            Path::new(b"foo/bar\0")
         });
         assert!(result.is_err());
 
         let result = task::try(proc() {
-            Path::new("test").set_filename(b!("f", 0, "o"))
+            Path::new("test").set_filename(b"f\0o")
         });
         assert!(result.is_err());
 
         let result = task::try(proc() {
-            Path::new("test").push(b!("f", 0, "o"));
+            Path::new("test").push(b"f\0o");
         });
         assert!(result.is_err());
     }
@@ -559,11 +550,11 @@ mod tests {
             )
         )
         t!("foo", display, "foo");
-        t!(b!("foo", 0x80), display, "foo\uFFFD");
-        t!(b!("foo", 0xff, "bar"), display, "foo\uFFFDbar");
-        t!(b!("foo", 0xff, "/bar"), filename_display, "bar");
-        t!(b!("foo/", 0xff, "bar"), filename_display, "\uFFFDbar");
-        t!(b!("/"), filename_display, "");
+        t!(b"foo\x80", display, "foo\uFFFD");
+        t!(b"foo\xFFbar", display, "foo\uFFFDbar");
+        t!(b"foo\xFF/bar", filename_display, "bar");
+        t!(b"foo/\xFFbar", filename_display, "\uFFFDbar");
+        t!(b"/", filename_display, "");
 
         macro_rules! t(
             ($path:expr, $exp:expr) => (
@@ -583,11 +574,11 @@ mod tests {
         )
 
         t!("foo", "foo");
-        t!(b!("foo", 0x80), "foo\uFFFD");
-        t!(b!("foo", 0xff, "bar"), "foo\uFFFDbar");
-        t!(b!("foo", 0xff, "/bar"), "bar", filename);
-        t!(b!("foo/", 0xff, "bar"), "\uFFFDbar", filename);
-        t!(b!("/"), "", filename);
+        t!(b"foo\x80", "foo\uFFFD");
+        t!(b"foo\xFFbar", "foo\uFFFDbar");
+        t!(b"foo\xFF/bar", "bar", filename);
+        t!(b"foo/\xFFbar", "\uFFFDbar", filename);
+        t!(b"/", "", filename);
     }
 
     #[test]
@@ -604,13 +595,13 @@ mod tests {
             )
         )
 
-        t!(b!("foo"), "foo", "foo");
-        t!(b!("foo/bar"), "foo/bar", "bar");
-        t!(b!("/"), "/", "");
-        t!(b!("foo", 0xff), "foo\uFFFD", "foo\uFFFD");
-        t!(b!("foo", 0xff, "/bar"), "foo\uFFFD/bar", "bar");
-        t!(b!("foo/", 0xff, "bar"), "foo/\uFFFDbar", "\uFFFDbar");
-        t!(b!(0xff, "foo/bar", 0xff), "\uFFFDfoo/bar\uFFFD", "bar\uFFFD");
+        t!(b"foo", "foo", "foo");
+        t!(b"foo/bar", "foo/bar", "bar");
+        t!(b"/", "/", "");
+        t!(b"foo\xFF", "foo\uFFFD", "foo\uFFFD");
+        t!(b"foo\xFF/bar", "foo\uFFFD/bar", "bar");
+        t!(b"foo/\xFFbar", "foo/\uFFFDbar", "\uFFFDbar");
+        t!(b"\xFFfoo/bar\xFF", "\uFFFDfoo/bar\uFFFD", "bar\uFFFD");
     }
 
     #[test]
@@ -638,9 +629,9 @@ mod tests {
             );
         )
 
-        t!(v: b!("a/b/c"), filename, Some(b!("c")));
-        t!(v: b!("a/b/c", 0xff), filename, Some(b!("c", 0xff)));
-        t!(v: b!("a/b", 0xff, "/c"), filename, Some(b!("c")));
+        t!(v: b"a/b/c", filename, Some(b"c"));
+        t!(v: b"a/b/c\xFF", filename, Some(b"c\xFF"));
+        t!(v: b"a/b\xFF/c", filename, Some(b"c"));
         t!(s: "a/b/c", filename, Some("c"), opt);
         t!(s: "/a/b/c", filename, Some("c"), opt);
         t!(s: "a", filename, Some("a"), opt);
@@ -650,9 +641,9 @@ mod tests {
         t!(s: "..", filename, None, opt);
         t!(s: "../..", filename, None, opt);
 
-        t!(v: b!("a/b/c"), dirname, b!("a/b"));
-        t!(v: b!("a/b/c", 0xff), dirname, b!("a/b"));
-        t!(v: b!("a/b", 0xff, "/c"), dirname, b!("a/b", 0xff));
+        t!(v: b"a/b/c", dirname, b"a/b");
+        t!(v: b"a/b/c\xFF", dirname, b"a/b");
+        t!(v: b"a/b\xFF/c", dirname, b"a/b\xFF");
         t!(s: "a/b/c", dirname, "a/b");
         t!(s: "/a/b/c", dirname, "/a/b");
         t!(s: "a", dirname, ".");
@@ -662,9 +653,9 @@ mod tests {
         t!(s: "..", dirname, "..");
         t!(s: "../..", dirname, "../..");
 
-        t!(v: b!("hi/there.txt"), filestem, Some(b!("there")));
-        t!(v: b!("hi/there", 0x80, ".txt"), filestem, Some(b!("there", 0x80)));
-        t!(v: b!("hi/there.t", 0x80, "xt"), filestem, Some(b!("there")));
+        t!(v: b"hi/there.txt", filestem, Some(b"there"));
+        t!(v: b"hi/there\x80.txt", filestem, Some(b"there\x80"));
+        t!(v: b"hi/there.t\x80xt", filestem, Some(b"there"));
         t!(s: "hi/there.txt", filestem, Some("there"), opt);
         t!(s: "hi/there", filestem, Some("there"), opt);
         t!(s: "there.txt", filestem, Some("there"), opt);
@@ -678,11 +669,11 @@ mod tests {
         t!(s: "..", filestem, None, opt);
         t!(s: "../..", filestem, None, opt);
 
-        t!(v: b!("hi/there.txt"), extension, Some(b!("txt")));
-        t!(v: b!("hi/there", 0x80, ".txt"), extension, Some(b!("txt")));
-        t!(v: b!("hi/there.t", 0x80, "xt"), extension, Some(b!("t", 0x80, "xt")));
-        t!(v: b!("hi/there"), extension, None);
-        t!(v: b!("hi/there", 0x80), extension, None);
+        t!(v: b"hi/there.txt", extension, Some(b"txt"));
+        t!(v: b"hi/there\x80.txt", extension, Some(b"txt"));
+        t!(v: b"hi/there.t\x80xt", extension, Some(b"t\x80xt"));
+        t!(v: b"hi/there", extension, None);
+        t!(v: b"hi/there\x80", extension, None);
         t!(s: "hi/there.txt", extension, Some("txt"), opt);
         t!(s: "hi/there", extension, None, opt);
         t!(s: "there.txt", extension, Some("txt"), opt);
@@ -762,9 +753,9 @@ mod tests {
         t!(s: "a/b/c", ["d", "/e"], "/e");
         t!(s: "a/b/c", ["d", "/e", "f"], "/e/f");
         t!(s: "a/b/c", ["d".to_string(), "e".to_string()], "a/b/c/d/e");
-        t!(v: b!("a/b/c"), [b!("d"), b!("e")], b!("a/b/c/d/e"));
-        t!(v: b!("a/b/c"), [b!("d"), b!("/e"), b!("f")], b!("/e/f"));
-        t!(v: b!("a/b/c"), [Vec::from_slice(b!("d")), Vec::from_slice(b!("e"))], b!("a/b/c/d/e"));
+        t!(v: b"a/b/c", [b"d", b"e"], b"a/b/c/d/e");
+        t!(v: b"a/b/c", [b"d", b"/e", b"f"], b"/e/f");
+        t!(v: b"a/b/c", [Vec::from_slice(b"d"), Vec::from_slice(b"e")], b"a/b/c/d/e");
     }
 
     #[test]
@@ -778,25 +769,25 @@ mod tests {
                     assert!(result == $right);
                 }
             );
-            (v: [$($path:expr),+], [$($left:expr),+], $right:expr) => (
+            (b: $path:expr, $left:expr, $right:expr) => (
                 {
-                    let mut p = Path::new(b!($($path),+));
+                    let mut p = Path::new($path);
                     let result = p.pop();
-                    assert!(p.as_vec() == b!($($left),+));
+                    assert!(p.as_vec() == $left);
                     assert!(result == $right);
                 }
             )
         )
 
-        t!(v: ["a/b/c"], ["a/b"], true);
-        t!(v: ["a"], ["."], true);
-        t!(v: ["."], ["."], false);
-        t!(v: ["/a"], ["/"], true);
-        t!(v: ["/"], ["/"], false);
-        t!(v: ["a/b/c", 0x80], ["a/b"], true);
-        t!(v: ["a/b", 0x80, "/c"], ["a/b", 0x80], true);
-        t!(v: [0xff], ["."], true);
-        t!(v: ["/", 0xff], ["/"], true);
+        t!(b: b"a/b/c", b"a/b", true);
+        t!(b: b"a", b".", true);
+        t!(b: b".", b".", false);
+        t!(b: b"/a", b"/", true);
+        t!(b: b"/", b"/", false);
+        t!(b: b"a/b/c\x80", b"a/b", true);
+        t!(b: b"a/b\x80/c", b"a/b\x80", true);
+        t!(b: b"\xFF", b".", true);
+        t!(b: b"/\xFF", b"/", true);
         t!(s: "a/b/c", "a/b", true);
         t!(s: "a", ".", true);
         t!(s: ".", ".", false);
@@ -806,15 +797,15 @@ mod tests {
 
     #[test]
     fn test_root_path() {
-        assert!(Path::new(b!("a/b/c")).root_path() == None);
-        assert!(Path::new(b!("/a/b/c")).root_path() == Some(Path::new("/")));
+        assert!(Path::new(b"a/b/c").root_path() == None);
+        assert!(Path::new(b"/a/b/c").root_path() == Some(Path::new("/")));
     }
 
     #[test]
     fn test_join() {
-        t!(v: Path::new(b!("a/b/c")).join(b!("..")), b!("a/b"));
-        t!(v: Path::new(b!("/a/b/c")).join(b!("d")), b!("/a/b/c/d"));
-        t!(v: Path::new(b!("a/", 0x80, "/c")).join(b!(0xff)), b!("a/", 0x80, "/c/", 0xff));
+        t!(v: Path::new(b"a/b/c").join(b".."), b"a/b");
+        t!(v: Path::new(b"/a/b/c").join(b"d"), b"/a/b/c/d");
+        t!(v: Path::new(b"a/\x80/c").join(b"\xFF"), b"a/\x80/c/\xFF");
         t!(s: Path::new("a/b/c").join(".."), "a/b");
         t!(s: Path::new("/a/b/c").join("d"), "/a/b/c/d");
         t!(s: Path::new("a/b").join("c/d"), "a/b/c/d");
@@ -867,18 +858,18 @@ mod tests {
         t!(s: "a/b/c", ["..", "d"], "a/b/d");
         t!(s: "a/b/c", ["d", "/e", "f"], "/e/f");
         t!(s: "a/b/c", ["d".to_string(), "e".to_string()], "a/b/c/d/e");
-        t!(v: b!("a/b/c"), [b!("d"), b!("e")], b!("a/b/c/d/e"));
-        t!(v: b!("a/b/c"), [Vec::from_slice(b!("d")), Vec::from_slice(b!("e"))], b!("a/b/c/d/e"));
+        t!(v: b"a/b/c", [b"d", b"e"], b"a/b/c/d/e");
+        t!(v: b"a/b/c", [Vec::from_slice(b"d"), Vec::from_slice(b"e")], b"a/b/c/d/e");
     }
 
     #[test]
     fn test_with_helpers() {
         let empty: &[u8] = [];
 
-        t!(v: Path::new(b!("a/b/c")).with_filename(b!("d")), b!("a/b/d"));
-        t!(v: Path::new(b!("a/b/c", 0xff)).with_filename(b!(0x80)), b!("a/b/", 0x80));
-        t!(v: Path::new(b!("/", 0xff, "/foo")).with_filename(b!(0xcd)),
-              b!("/", 0xff, "/", 0xcd));
+        t!(v: Path::new(b"a/b/c").with_filename(b"d"), b"a/b/d");
+        t!(v: Path::new(b"a/b/c\xFF").with_filename(b"\x80"), b"a/b/\x80");
+        t!(v: Path::new(b"/\xFF/foo").with_filename(b"\xCD"),
+              b"/\xFF/\xCD");
         t!(s: Path::new("a/b/c").with_filename("d"), "a/b/d");
         t!(s: Path::new(".").with_filename("foo"), "foo");
         t!(s: Path::new("/a/b/c").with_filename("d"), "/a/b/d");
@@ -899,13 +890,13 @@ mod tests {
         t!(s: Path::new("..").with_filename(""), "..");
         t!(s: Path::new("../..").with_filename(""), "../..");
 
-        t!(v: Path::new(b!("hi/there", 0x80, ".txt")).with_extension(b!("exe")),
-              b!("hi/there", 0x80, ".exe"));
-        t!(v: Path::new(b!("hi/there.txt", 0x80)).with_extension(b!(0xff)),
-              b!("hi/there.", 0xff));
-        t!(v: Path::new(b!("hi/there", 0x80)).with_extension(b!(0xff)),
-              b!("hi/there", 0x80, ".", 0xff));
-        t!(v: Path::new(b!("hi/there.", 0xff)).with_extension(empty), b!("hi/there"));
+        t!(v: Path::new(b"hi/there\x80.txt").with_extension(b"exe"),
+              b"hi/there\x80.exe");
+        t!(v: Path::new(b"hi/there.txt\x80").with_extension(b"\xFF"),
+              b"hi/there.\xFF");
+        t!(v: Path::new(b"hi/there\x80").with_extension(b"\xFF"),
+              b"hi/there\x80.\xFF");
+        t!(v: Path::new(b"hi/there.\xFF").with_extension(empty), b"hi/there");
         t!(s: Path::new("hi/there.txt").with_extension("exe"), "hi/there.exe");
         t!(s: Path::new("hi/there.txt").with_extension(""), "hi/there");
         t!(s: Path::new("hi/there.txt").with_extension("."), "hi/there..");
@@ -947,17 +938,17 @@ mod tests {
             )
         )
 
-        t!(v: b!("a/b/c"), set_filename, with_filename, b!("d"));
-        t!(v: b!("/"), set_filename, with_filename, b!("foo"));
-        t!(v: b!(0x80), set_filename, with_filename, b!(0xff));
+        t!(v: b"a/b/c", set_filename, with_filename, b"d");
+        t!(v: b"/", set_filename, with_filename, b"foo");
+        t!(v: b"\x80", set_filename, with_filename, b"\xFF");
         t!(s: "a/b/c", set_filename, with_filename, "d");
         t!(s: "/", set_filename, with_filename, "foo");
         t!(s: ".", set_filename, with_filename, "foo");
         t!(s: "a/b", set_filename, with_filename, "");
         t!(s: "a", set_filename, with_filename, "");
 
-        t!(v: b!("hi/there.txt"), set_extension, with_extension, b!("exe"));
-        t!(v: b!("hi/there.t", 0x80, "xt"), set_extension, with_extension, b!("exe", 0xff));
+        t!(v: b"hi/there.txt", set_extension, with_extension, b"exe");
+        t!(v: b"hi/there.t\x80xt", set_extension, with_extension, b"exe\xFF");
         t!(s: "hi/there.txt", set_extension, with_extension, "exe");
         t!(s: "hi/there.", set_extension, with_extension, "txt");
         t!(s: "hi/there", set_extension, with_extension, "txt");
@@ -1001,10 +992,10 @@ mod tests {
             )
         )
 
-        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/", 0xff)), Some(b!(0xff)), b!("a/b"), Some(b!(0xff)), None);
-        t!(v: Path::new(b!("hi/there.", 0xff)), Some(b!("there.", 0xff)), b!("hi"),
-              Some(b!("there")), Some(b!(0xff)));
+        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);
+        t!(v: Path::new(b"hi/there.\xFF"), Some(b"there.\xFF"), b"hi",
+              Some(b"there"), Some(b"\xFF"));
         t!(s: Path::new("a/b/c"), Some("c"), Some("a/b"), Some("c"), None);
         t!(s: Path::new("."), None, Some("."), None, None);
         t!(s: Path::new("/"), None, Some("/"), None, None);
@@ -1018,16 +1009,16 @@ mod tests {
         t!(s: Path::new("hi/.there"), Some(".there"), Some("hi"), Some(".there"), None);
         t!(s: Path::new("hi/..there"), Some("..there"), Some("hi"),
               Some("."), Some("there"));
-        t!(s: Path::new(b!("a/b/", 0xff)), None, Some("a/b"), None, None);
-        t!(s: Path::new(b!("a/b/", 0xff, ".txt")), None, Some("a/b"), None, Some("txt"));
-        t!(s: Path::new(b!("a/b/c.", 0x80)), None, Some("a/b"), Some("c"), None);
-        t!(s: Path::new(b!(0xff, "/b")), Some("b"), None, Some("b"), None);
+        t!(s: Path::new(b"a/b/\xFF"), None, Some("a/b"), None, None);
+        t!(s: Path::new(b"a/b/\xFF.txt"), None, Some("a/b"), None, Some("txt"));
+        t!(s: Path::new(b"a/b/c.\x80"), None, Some("a/b"), Some("c"), None);
+        t!(s: Path::new(b"\xFF/b"), Some("b"), None, Some("b"), None);
     }
 
     #[test]
     fn test_dir_path() {
-        t!(v: Path::new(b!("hi/there", 0x80)).dir_path(), b!("hi"));
-        t!(v: Path::new(b!("hi", 0xff, "/there")).dir_path(), b!("hi", 0xff));
+        t!(v: Path::new(b"hi/there\x80").dir_path(), b"hi");
+        t!(v: Path::new(b"hi\xFF/there").dir_path(), b"hi\xFF");
         t!(s: Path::new("hi/there").dir_path(), "hi");
         t!(s: Path::new("hi").dir_path(), ".");
         t!(s: Path::new("/hi").dir_path(), "/");
@@ -1125,9 +1116,9 @@ mod tests {
         t!(s: "/a/b/c", "d/e/f", false);
         t!(s: "a/b/c", "a/b", false);
         t!(s: "a/b/c", "b", false);
-        t!(v: b!("a/b/c"), b!("b/c"), true);
-        t!(v: b!("a/b/", 0xff), b!(0xff), true);
-        t!(v: b!("a/b/", 0xff), b!("b/", 0xff), true);
+        t!(v: b"a/b/c", b"b/c", true);
+        t!(v: b"a/b/\xFF", b"\xFF", true);
+        t!(v: b"a/b/\xFF", b"b/\xFF", true);
     }
 
     #[test]
@@ -1192,11 +1183,11 @@ mod tests {
                             comps, exps);
                 }
             );
-            (v: [$($arg:expr),+], [$([$($exp:expr),*]),*]) => (
+            (b: $arg:expr, [$($exp:expr),*]) => (
                 {
-                    let path = Path::new(b!($($arg),+));
+                    let path = Path::new($arg);
                     let comps = path.components().collect::<Vec<&[u8]>>();
-                    let exp: &[&[u8]] = [$(b!($($exp),*)),*];
+                    let exp: &[&[u8]] = [$($exp),*];
                     assert_eq!(comps.as_slice(), exp);
                     let comps = path.components().rev().collect::<Vec<&[u8]>>();
                     let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&[u8]>>();
@@ -1205,9 +1196,9 @@ mod tests {
             )
         )
 
-        t!(v: ["a/b/c"], [["a"], ["b"], ["c"]]);
-        t!(v: ["/", 0xff, "/a/", 0x80], [[0xff], ["a"], [0x80]]);
-        t!(v: ["../../foo", 0xcd, "bar"], [[".."], [".."], ["foo", 0xcd, "bar"]]);
+        t!(b: b"a/b/c", [b"a", b"b", b"c"]);
+        t!(b: b"/\xFF/a/\x80", [b"\xFF", b"a", b"\x80"]);
+        t!(b: b"../../foo\xCDbar", [b"..", b"..", b"foo\xCDbar"]);
         t!(s: "a/b/c", ["a", "b", "c"]);
         t!(s: "a/b/d", ["a", "b", "d"]);
         t!(s: "a/b/cd", ["a", "b", "cd"]);
@@ -1224,9 +1215,9 @@ mod tests {
     #[test]
     fn test_str_components() {
         macro_rules! t(
-            (v: [$($arg:expr),+], $exp:expr) => (
+            (b: $arg:expr, $exp:expr) => (
                 {
-                    let path = Path::new(b!($($arg),+));
+                    let path = Path::new($arg);
                     let comps = path.str_components().collect::<Vec<Option<&str>>>();
                     let exp: &[Option<&str>] = $exp;
                     assert_eq!(comps.as_slice(), exp);
@@ -1237,9 +1228,9 @@ mod tests {
             )
         )
 
-        t!(v: ["a/b/c"], [Some("a"), Some("b"), Some("c")]);
-        t!(v: ["/", 0xff, "/a/", 0x80], [None, Some("a"), None]);
-        t!(v: ["../../foo", 0xcd, "bar"], [Some(".."), Some(".."), None]);
+        t!(b: b"a/b/c", [Some("a"), Some("b"), Some("c")]);
+        t!(b: b"/\xFF/a/\x80", [None, Some("a"), None]);
+        t!(b: b"../../foo\xCDbar", [Some(".."), Some(".."), None]);
         // str_components is a wrapper around components, so no need to do
         // the full set of tests
     }
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs
index 553c7af18cb..4d6f8d0888f 100644
--- a/src/libstd/path/windows.rs
+++ b/src/libstd/path/windows.rs
@@ -1123,15 +1123,6 @@ mod tests {
         )
     )
 
-    macro_rules! b(
-        ($($arg:expr),+) => (
-            {
-                static the_bytes: &'static [u8] = bytes!($($arg),+);
-                the_bytes
-            }
-        )
-    )
-
     #[test]
     fn test_parse_prefix() {
         macro_rules! t(
@@ -1196,9 +1187,9 @@ mod tests {
     #[test]
     fn test_paths() {
         let empty: &[u8] = [];
-        t!(v: Path::new(empty), b!("."));
-        t!(v: Path::new(b!("\\")), b!("\\"));
-        t!(v: Path::new(b!("a\\b\\c")), b!("a\\b\\c"));
+        t!(v: Path::new(empty), b".");
+        t!(v: Path::new(b"\\"), b"\\");
+        t!(v: Path::new(b"a\\b\\c"), b"a\\b\\c");
 
         t!(s: Path::new(""), ".");
         t!(s: Path::new("\\"), "\\");
@@ -1230,8 +1221,8 @@ mod tests {
         t!(s: Path::new("foo\\..\\..\\.."), "..\\..");
         t!(s: Path::new("foo\\..\\..\\bar"), "..\\bar");
 
-        assert_eq!(Path::new(b!("foo\\bar")).into_vec().as_slice(), b!("foo\\bar"));
-        assert_eq!(Path::new(b!("\\foo\\..\\..\\bar")).into_vec().as_slice(), b!("\\bar"));
+        assert_eq!(Path::new(b"foo\\bar").into_vec().as_slice(), b"foo\\bar");
+        assert_eq!(Path::new(b"\\foo\\..\\..\\bar").into_vec().as_slice(), b"\\bar");
 
         t!(s: Path::new("\\\\a"), "\\a");
         t!(s: Path::new("\\\\a\\"), "\\a");
@@ -1284,9 +1275,9 @@ mod tests {
 
     #[test]
     fn test_opt_paths() {
-        assert!(Path::new_opt(b!("foo\\bar", 0)) == None);
-        assert!(Path::new_opt(b!("foo\\bar", 0x80)) == None);
-        t!(v: Path::new_opt(b!("foo\\bar")).unwrap(), b!("foo\\bar"));
+        assert!(Path::new_opt(b"foo\\bar\0") == None);
+        assert!(Path::new_opt(b"foo\\bar\x80") == None);
+        t!(v: Path::new_opt(b"foo\\bar").unwrap(), b"foo\\bar");
         assert!(Path::new_opt("foo\\bar\0") == None);
         t!(s: Path::new_opt("foo\\bar").unwrap(), "foo\\bar");
     }
@@ -1295,17 +1286,17 @@ mod tests {
     fn test_null_byte() {
         use task;
         let result = task::try(proc() {
-            Path::new(b!("foo/bar", 0))
+            Path::new(b"foo/bar\0")
         });
         assert!(result.is_err());
 
         let result = task::try(proc() {
-            Path::new("test").set_filename(b!("f", 0, "o"))
+            Path::new("test").set_filename(b"f\0o")
         });
         assert!(result.is_err());
 
         let result = task::try(proc() {
-            Path::new("test").push(b!("f", 0, "o"));
+            Path::new("test").push(b"f\0o");
         });
         assert!(result.is_err());
     }
@@ -1313,20 +1304,20 @@ mod tests {
     #[test]
     #[should_fail]
     fn test_not_utf8_fail() {
-        Path::new(b!("hello", 0x80, ".txt"));
+        Path::new(b"hello\x80.txt");
     }
 
     #[test]
     fn test_display_str() {
         let path = Path::new("foo");
         assert_eq!(path.display().to_str(), "foo".to_string());
-        let path = Path::new(b!("\\"));
+        let path = Path::new(b"\\");
         assert_eq!(path.filename_display().to_str(), "".to_string());
 
         let path = Path::new("foo");
         let mo = path.display().as_maybe_owned();
         assert_eq!(mo.as_slice(), "foo");
-        let path = Path::new(b!("\\"));
+        let path = Path::new(b"\\");
         let mo = path.filename_display().as_maybe_owned();
         assert_eq!(mo.as_slice(), "");
     }
@@ -1377,7 +1368,7 @@ mod tests {
             )
         )
 
-        t!(v: b!("a\\b\\c"), filename, Some(b!("c")));
+        t!(v: b"a\\b\\c", filename, Some(b"c"));
         t!(s: "a\\b\\c", filename_str, "c");
         t!(s: "\\a\\b\\c", filename_str, "c");
         t!(s: "a", filename_str, "a");
@@ -1410,7 +1401,7 @@ mod tests {
         t!(s: "\\\\.\\", filename_str, None, opt);
         t!(s: "\\\\?\\a\\b\\", filename_str, "b");
 
-        t!(v: b!("a\\b\\c"), dirname, b!("a\\b"));
+        t!(v: b"a\\b\\c", dirname, b"a\\b");
         t!(s: "a\\b\\c", dirname_str, "a\\b");
         t!(s: "\\a\\b\\c", dirname_str, "\\a\\b");
         t!(s: "a", dirname_str, ".");
@@ -1441,7 +1432,7 @@ mod tests {
         t!(s: "\\\\.\\foo", dirname_str, "\\\\.\\foo");
         t!(s: "\\\\?\\a\\b\\", dirname_str, "\\\\?\\a");
 
-        t!(v: b!("hi\\there.txt"), filestem, Some(b!("there")));
+        t!(v: b"hi\\there.txt", filestem, Some(b"there"));
         t!(s: "hi\\there.txt", filestem_str, "there");
         t!(s: "hi\\there", filestem_str, "there");
         t!(s: "there.txt", filestem_str, "there");
@@ -1456,8 +1447,8 @@ mod tests {
         t!(s: "..\\..", filestem_str, None, opt);
         // filestem is based on filename, so we don't need the full set of prefix tests
 
-        t!(v: b!("hi\\there.txt"), extension, Some(b!("txt")));
-        t!(v: b!("hi\\there"), extension, None);
+        t!(v: b"hi\\there.txt", extension, Some(b"txt"));
+        t!(v: b"hi\\there", extension, None);
         t!(s: "hi\\there.txt", extension_str, Some("txt"), opt);
         t!(s: "hi\\there", extension_str, None, opt);
         t!(s: "there.txt", extension_str, Some("txt"), opt);
@@ -1583,10 +1574,10 @@ mod tests {
         t!(s: "a\\b\\c", ["d", "\\e"], "\\e");
         t!(s: "a\\b\\c", ["d", "\\e", "f"], "\\e\\f");
         t!(s: "a\\b\\c", ["d".to_string(), "e".to_string()], "a\\b\\c\\d\\e");
-        t!(v: b!("a\\b\\c"), [b!("d"), b!("e")], b!("a\\b\\c\\d\\e"));
-        t!(v: b!("a\\b\\c"), [b!("d"), b!("\\e"), b!("f")], b!("\\e\\f"));
-        t!(v: b!("a\\b\\c"), [Vec::from_slice(b!("d")), Vec::from_slice(b!("e"))],
-           b!("a\\b\\c\\d\\e"));
+        t!(v: b"a\\b\\c", [b"d", b"e"], b"a\\b\\c\\d\\e");
+        t!(v: b"a\\b\\c", [b"d", b"\\e", b"f"], b"\\e\\f");
+        t!(v: b"a\\b\\c", [Vec::from_slice(b"d"), Vec::from_slice(b"e")],
+           b"a\\b\\c\\d\\e");
     }
 
     #[test]
@@ -1604,11 +1595,11 @@ mod tests {
                     assert!(result == $right);
                 }
             );
-            (v: [$($path:expr),+], [$($left:expr),+], $right:expr) => (
+            (b: $path:expr, $left:expr, $right:expr) => (
                 {
-                    let mut p = Path::new(b!($($path),+));
+                    let mut p = Path::new($path);
                     let result = p.pop();
-                    assert_eq!(p.as_vec(), b!($($left),+));
+                    assert_eq!(p.as_vec(), $left);
                     assert!(result == $right);
                 }
             )
@@ -1619,11 +1610,11 @@ mod tests {
         t!(s: ".", ".", false);
         t!(s: "\\a", "\\", true);
         t!(s: "\\", "\\", false);
-        t!(v: ["a\\b\\c"], ["a\\b"], true);
-        t!(v: ["a"], ["."], true);
-        t!(v: ["."], ["."], false);
-        t!(v: ["\\a"], ["\\"], true);
-        t!(v: ["\\"], ["\\"], false);
+        t!(b: b"a\\b\\c", b"a\\b", true);
+        t!(b: b"a", b".", true);
+        t!(b: b".", b".", false);
+        t!(b: b"\\a", b"\\", true);
+        t!(b: b"\\", b"\\", false);
 
         t!(s: "C:\\a\\b", "C:\\a", true);
         t!(s: "C:\\a", "C:\\", true);
@@ -1672,8 +1663,8 @@ mod tests {
         t!(s: Path::new("a\\b").join("\\c\\d"), "\\c\\d");
         t!(s: Path::new(".").join("a\\b"), "a\\b");
         t!(s: Path::new("\\").join("a\\b"), "\\a\\b");
-        t!(v: Path::new(b!("a\\b\\c")).join(b!("..")), b!("a\\b"));
-        t!(v: Path::new(b!("\\a\\b\\c")).join(b!("d")), b!("\\a\\b\\c\\d"));
+        t!(v: Path::new(b"a\\b\\c").join(b".."), b"a\\b");
+        t!(v: Path::new(b"\\a\\b\\c").join(b"d"), b"\\a\\b\\c\\d");
         // full join testing is covered under test_push_path, so no need for
         // the full set of prefix tests
     }
@@ -1724,9 +1715,9 @@ mod tests {
         t!(s: "a\\b\\c", ["..", "d"], "a\\b\\d");
         t!(s: "a\\b\\c", ["d", "\\e", "f"], "\\e\\f");
         t!(s: "a\\b\\c", ["d".to_string(), "e".to_string()], "a\\b\\c\\d\\e");
-        t!(v: b!("a\\b\\c"), [b!("d"), b!("e")], b!("a\\b\\c\\d\\e"));
-        t!(v: b!("a\\b\\c"), [Vec::from_slice(b!("d")), Vec::from_slice(b!("e"))],
-           b!("a\\b\\c\\d\\e"));
+        t!(v: b"a\\b\\c", [b"d", b"e"], b"a\\b\\c\\d\\e");
+        t!(v: b"a\\b\\c", [Vec::from_slice(b"d"), Vec::from_slice(b"e")],
+           b"a\\b\\c\\d\\e");
     }
 
     #[test]
@@ -1839,15 +1830,15 @@ mod tests {
             )
         )
 
-        t!(v: b!("a\\b\\c"), set_filename, with_filename, b!("d"));
-        t!(v: b!("\\"), set_filename, with_filename, b!("foo"));
+        t!(v: b"a\\b\\c", set_filename, with_filename, b"d");
+        t!(v: b"\\", set_filename, with_filename, b"foo");
         t!(s: "a\\b\\c", set_filename, with_filename, "d");
         t!(s: "\\", set_filename, with_filename, "foo");
         t!(s: ".", set_filename, with_filename, "foo");
         t!(s: "a\\b", set_filename, with_filename, "");
         t!(s: "a", set_filename, with_filename, "");
 
-        t!(v: b!("hi\\there.txt"), set_extension, with_extension, b!("exe"));
+        t!(v: b"hi\\there.txt", set_extension, with_extension, b"exe");
         t!(s: "hi\\there.txt", set_extension, with_extension, "exe");
         t!(s: "hi\\there.", set_extension, with_extension, "txt");
         t!(s: "hi\\there", set_extension, with_extension, "txt");
@@ -1894,7 +1885,7 @@ mod tests {
             )
         )
 
-        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\\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);
         t!(s: Path::new("."), None, Some("."), None, None);
         t!(s: Path::new("\\"), None, Some("\\"), None, None);
@@ -2250,21 +2241,9 @@ mod tests {
                     assert_eq!(comps, exp);
                 }
             );
-            (v: [$($arg:expr),+], $exp:expr) => (
-                {
-                    let path = Path::new(b!($($arg),+));
-                    let comps = path.str_components().map(|x|x.unwrap()).collect::<Vec<&str>>();
-                    let exp: &[&str] = $exp;
-                    assert_eq!(comps.as_slice(), exp);
-                    let comps = path.str_components().rev().map(|x|x.unwrap())
-                                .collect::<Vec<&str>>();
-                    let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&str>>();
-                    assert_eq!(comps, exp);
-                }
-            )
         )
 
-        t!(v: ["a\\b\\c"], ["a", "b", "c"]);
+        t!(s: b"a\\b\\c", ["a", "b", "c"]);
         t!(s: "a\\b\\c", ["a", "b", "c"]);
         t!(s: "a\\b\\d", ["a", "b", "d"]);
         t!(s: "a\\b\\cd", ["a", "b", "cd"]);
@@ -2320,8 +2299,8 @@ mod tests {
             )
         )
 
-        t!(s: "a\\b\\c", [b!("a"), b!("b"), b!("c")]);
-        t!(s: ".", [b!(".")]);
+        t!(s: "a\\b\\c", [b"a", b"b", b"c"]);
+        t!(s: ".", [b"."]);
         // since this is really a wrapper around str_components, those tests suffice
     }