about summary refs log tree commit diff
path: root/src/libstd/path
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2014-01-15 14:39:08 -0500
committerNiko Matsakis <niko@alum.mit.edu>2014-01-15 18:34:38 -0500
commit419ac4a1b899ba88fb360b4c71c08f3610564cd4 (patch)
treea67114bd33e84818930d054f29ac81b726a88198 /src/libstd/path
parent149fc76698318f8f7cdfaa37a818e347721764e7 (diff)
downloadrust-419ac4a1b899ba88fb360b4c71c08f3610564cd4.tar.gz
rust-419ac4a1b899ba88fb360b4c71c08f3610564cd4.zip
Issue #3511 - Rationalize temporary lifetimes.
Major changes:

- Define temporary scopes in a syntax-based way that basically defaults
  to the innermost statement or conditional block, except for in
  a `let` initializer, where we default to the innermost block. Rules
  are documented in the code, but not in the manual (yet).
  See new test run-pass/cleanup-value-scopes.rs for examples.
- Refactors Datum to better define cleanup roles.
- Refactor cleanup scopes to not be tied to basic blocks, permitting
  us to have a very large number of scopes (one per AST node).
- Introduce nascent documentation in trans/doc.rs covering datums and
  cleanup in a more comprehensive way.
Diffstat (limited to 'src/libstd/path')
-rw-r--r--src/libstd/path/posix.rs13
-rw-r--r--src/libstd/path/windows.rs14
2 files changed, 20 insertions, 7 deletions
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs
index 7b94de6c094..e2ddabc1714 100644
--- a/src/libstd/path/posix.rs
+++ b/src/libstd/path/posix.rs
@@ -237,7 +237,10 @@ impl GenericPath for Path {
             let mut ita = self.components();
             let mut itb = other.components();
             if bytes!(".") == self.repr {
-                return itb.next() != Some(bytes!(".."));
+                return match itb.next() {
+                    None => true,
+                    Some(b) => b != bytes!("..")
+                };
             }
             loop {
                 match (ita.next(), itb.next()) {
@@ -463,7 +466,10 @@ mod tests {
 
     macro_rules! b(
         ($($arg:expr),+) => (
-            bytes!($($arg),+)
+            {
+                static the_bytes: &'static [u8] = bytes!($($arg),+);
+                the_bytes
+            }
         )
     )
 
@@ -689,7 +695,8 @@ mod tests {
             );
             (v: $path:expr, $op:ident, $exp:expr) => (
                 {
-                    let path = Path::new($path);
+                    let arg = $path;
+                    let path = Path::new(arg);
                     assert_eq!(path.$op(), $exp);
                 }
             );
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs
index 09b00be7e9d..cf2163265e4 100644
--- a/src/libstd/path/windows.rs
+++ b/src/libstd/path/windows.rs
@@ -1074,7 +1074,10 @@ mod tests {
 
     macro_rules! b(
         ($($arg:expr),+) => (
-            bytes!($($arg),+)
+            {
+                static the_bytes: &'static [u8] = bytes!($($arg),+);
+                the_bytes
+            }
         )
     )
 
@@ -1372,20 +1375,23 @@ mod tests {
         macro_rules! t(
             (s: $path:expr, $op:ident, $exp:expr) => (
                 {
-                    let path = Path::new($path);
+                    let path = $path;
+                    let path = Path::new(path);
                     assert_eq!(path.$op(), Some($exp));
                 }
             );
             (s: $path:expr, $op:ident, $exp:expr, opt) => (
                 {
-                    let path = Path::new($path);
+                    let path = $path;
+                    let path = Path::new(path);
                     let left = path.$op();
                     assert_eq!(left, $exp);
                 }
             );
             (v: $path:expr, $op:ident, $exp:expr) => (
                 {
-                    let path = Path::new($path);
+                    let path = $path;
+                    let path = Path::new(path);
                     assert_eq!(path.$op(), $exp);
                 }
             )