Skip to content

Commit e907558

Browse files
committed
---
yaml --- r: 150685 b: refs/heads/try2 c: 767ed1a h: refs/heads/master i: 150683: 637fac2 v: v3
1 parent 83bbb91 commit e907558

File tree

9 files changed

+80
-115
lines changed

9 files changed

+80
-115
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: e2c84a78b4a3e95ea0def29172022ef4cf695958
8+
refs/heads/try2: 767ed1a71f07e869e07bde138845e16b320908ec
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libglob/lib.rs

Lines changed: 10 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -43,7 +43,6 @@ use std::path::is_sep;
4343
pub struct Paths {
4444
root: Path,
4545
dir_patterns: Vec<Pattern>,
46-
require_dir: bool,
4746
options: MatchOptions,
4847
todo: Vec<(Path,uint)>,
4948
}
@@ -52,7 +51,7 @@ pub struct Paths {
5251
/// Return an iterator that produces all the Paths that match the given pattern,
5352
/// which may be absolute or relative to the current working directory.
5453
///
55-
/// This method uses the default match options and is equivalent to calling
54+
/// is method uses the default match options and is equivalent to calling
5655
/// `glob_with(pattern, MatchOptions::new())`. Use `glob_with` directly if you
5756
/// want to use non-default match options.
5857
///
@@ -107,7 +106,6 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Paths {
107106
return Paths {
108107
root: root,
109108
dir_patterns: Vec::new(),
110-
require_dir: false,
111109
options: options,
112110
todo: Vec::new(),
113111
};
@@ -119,21 +117,13 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Paths {
119117
let dir_patterns = pattern.slice_from(cmp::min(root_len, pattern.len()))
120118
.split_terminator(is_sep)
121119
.map(|s| Pattern::new(s))
122-
.collect::<Vec<Pattern>>();
123-
let require_dir = pattern.chars().next_back().map(is_sep) == Some(true);
120+
.collect();
124121

125-
let mut todo = Vec::new();
126-
if dir_patterns.len() > 0 {
127-
// Shouldn't happen, but we're using -1 as a special index.
128-
assert!(dir_patterns.len() < -1 as uint);
129-
130-
fill_todo(&mut todo, dir_patterns.as_slice(), 0, &root, options);
131-
}
122+
let todo = list_dir_sorted(&root).move_iter().map(|x|(x,0u)).collect();
132123

133124
Paths {
134125
root: root,
135126
dir_patterns: dir_patterns,
136-
require_dir: require_dir,
137127
options: options,
138128
todo: todo,
139129
}
@@ -148,12 +138,6 @@ impl Iterator<Path> for Paths {
148138
}
149139

150140
let (path,idx) = self.todo.pop().unwrap();
151-
// idx -1: was already checked by fill_todo, maybe path was '.' or
152-
// '..' that we can't match here because of normalization.
153-
if idx == -1 as uint {
154-
if self.require_dir && !path.is_dir() { continue; }
155-
return Some(path);
156-
}
157141
let ref pattern = *self.dir_patterns.get(idx);
158142

159143
if pattern.matches_with(match path.filename_str() {
@@ -168,27 +152,23 @@ impl Iterator<Path> for Paths {
168152
if idx == self.dir_patterns.len() - 1 {
169153
// it is not possible for a pattern to match a directory *AND* its children
170154
// so we don't need to check the children
171-
172-
if !self.require_dir || path.is_dir() {
173-
return Some(path);
174-
}
155+
return Some(path);
175156
} else {
176-
fill_todo(&mut self.todo, self.dir_patterns.as_slice(),
177-
idx + 1, &path, self.options);
157+
self.todo.extend(list_dir_sorted(&path).move_iter().map(|x|(x,idx+1)));
178158
}
179159
}
180160
}
181161
}
182162

183163
}
184164

185-
fn list_dir_sorted(path: &Path) -> Option<Vec<Path>> {
165+
fn list_dir_sorted(path: &Path) -> Vec<Path> {
186166
match fs::readdir(path) {
187167
Ok(mut children) => {
188168
children.sort_by(|p1, p2| p2.filename().cmp(&p1.filename()));
189-
Some(children.move_iter().collect())
169+
children.move_iter().collect()
190170
}
191-
Err(..) => None
171+
Err(..) => Vec::new()
192172
}
193173
}
194174

@@ -455,72 +435,6 @@ impl Pattern {
455435

456436
}
457437

458-
// Fills `todo` with paths under `path` to be matched by `patterns[idx]`,
459-
// special-casing patterns to match `.` and `..`, and avoiding `readdir()`
460-
// calls when there are no metacharacters in the pattern.
461-
fn fill_todo(todo: &mut Vec<(Path, uint)>, patterns: &[Pattern], idx: uint, path: &Path,
462-
options: MatchOptions) {
463-
// convert a pattern that's just many Char(_) to a string
464-
fn pattern_as_str(pattern: &Pattern) -> Option<~str> {
465-
let mut s = ~"";
466-
for token in pattern.tokens.iter() {
467-
match *token {
468-
Char(c) => s.push_char(c),
469-
_ => return None
470-
}
471-
}
472-
return Some(s);
473-
}
474-
475-
let add = |todo: &mut Vec<_>, next_path: Path| {
476-
if idx + 1 == patterns.len() {
477-
// We know it's good, so don't make the iterator match this path
478-
// against the pattern again. In particular, it can't match
479-
// . or .. globs since these never show up as path components.
480-
todo.push((next_path, -1 as uint));
481-
} else {
482-
fill_todo(todo, patterns, idx + 1, &next_path, options);
483-
}
484-
};
485-
486-
let pattern = &patterns[idx];
487-
488-
match pattern_as_str(pattern) {
489-
Some(s) => {
490-
// This pattern component doesn't have any metacharacters, so we
491-
// don't need to read the current directory to know where to
492-
// continue. So instead of passing control back to the iterator,
493-
// we can just check for that one entry and potentially recurse
494-
// right away.
495-
let special = "." == s || ".." == s;
496-
let next_path = path.join(s);
497-
if (special && path.is_dir()) || (!special && next_path.exists()) {
498-
add(todo, next_path);
499-
}
500-
},
501-
None => {
502-
match list_dir_sorted(path) {
503-
Some(entries) => {
504-
todo.extend(entries.move_iter().map(|x|(x, idx)));
505-
506-
// Matching the special directory entries . and .. that refer to
507-
// the current and parent directory respectively requires that
508-
// the pattern has a leading dot, even if the `MatchOptions` field
509-
// `require_literal_leading_dot` is not set.
510-
if pattern.tokens.len() > 0 && pattern.tokens.get(0) == &Char('.') {
511-
for &special in [".", ".."].iter() {
512-
if pattern.matches_with(special, options) {
513-
add(todo, path.join(special));
514-
}
515-
}
516-
}
517-
}
518-
None => {}
519-
}
520-
}
521-
}
522-
}
523-
524438
fn parse_char_specifiers(s: &[char]) -> Vec<CharSpecifier> {
525439
let mut cs = Vec::new();
526440
let mut i = 0;
@@ -653,7 +567,7 @@ mod test {
653567
fn test_absolute_pattern() {
654568
// assume that the filesystem is not empty!
655569
assert!(glob("/*").next().is_some());
656-
assert!(glob("//").next().is_some());
570+
assert!(glob("//").next().is_none());
657571

658572
// check windows absolute paths with host/device components
659573
let root_with_device = os::getcwd().root_path().unwrap().join("*");

branches/try2/src/librustc/middle/borrowck/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,13 @@ pub fn opt_loan_path(cmt: mc::cmt) -> Option<@LoanPath> {
274274
match cmt.cat {
275275
mc::cat_rvalue(..) |
276276
mc::cat_static_item |
277-
mc::cat_copied_upvar(_) => {
277+
mc::cat_copied_upvar(mc::CopiedUpvar { onceness: ast::Many, .. }) => {
278278
None
279279
}
280280

281281
mc::cat_local(id) |
282282
mc::cat_arg(id) |
283+
mc::cat_copied_upvar(mc::CopiedUpvar { upvar_id: id, .. }) |
283284
mc::cat_upvar(ty::UpvarId {var_id: id, ..}, _) => {
284285
Some(@LpVar(id))
285286
}

branches/try2/src/libstd/io/mem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl<'a> BufWriter<'a> {
237237

238238
impl<'a> Writer for BufWriter<'a> {
239239
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
240-
// return an error if the entire write does not fit in the buffer
240+
// raises a condition if the entire write does not fit in the buffer
241241
let max_size = self.buf.len();
242242
if self.pos >= max_size || (self.pos + buf.len()) > max_size {
243243
return Err(IoError {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let x = ~1;
13+
let f: proc() = proc() {
14+
let _a = x;
15+
drop(x);
16+
//~^ ERROR: use of moved value: `x`
17+
};
18+
f();
19+
}

branches/try2/src/test/compile-fail/issue-11925.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
fn main() {
1212
let r = {
1313
let x = ~42;
14-
let f = proc() &x; //~ ERROR: borrowed value does not live long enough
14+
let f = proc() &x; //~ ERROR: `x` does not live long enough
1515
f()
1616
};
1717

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let (tx, rx) = channel();
13+
spawn(proc() {
14+
loop {
15+
let tx = tx;
16+
//~^ ERROR: use of moved value: `tx`
17+
tx.send(1);
18+
}
19+
});
20+
}
21+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let f = proc() {};
13+
(proc() {
14+
f();
15+
f();
16+
//~^ ERROR: use of moved value: `f`
17+
})()
18+
}

branches/try2/src/test/run-pass/glob-std.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010

1111
// ignore-win32 TempDir may cause IoError on windows: #10462
1212

13-
#![feature(macro_rules)]
13+
#[feature(macro_rules)];
1414

1515
extern crate glob;
1616

1717
use glob::glob;
18-
use std::os;
18+
use std::unstable::finally::Finally;
19+
use std::{os, unstable};
1920
use std::io;
2021
use std::io::TempDir;
2122

@@ -28,9 +29,9 @@ macro_rules! assert_eq ( ($e1:expr, $e2:expr) => (
2829
pub fn main() {
2930
fn mk_file(path: &str, directory: bool) {
3031
if directory {
31-
io::fs::mkdir(&Path::new(path), io::UserRWX).unwrap();
32+
io::fs::mkdir(&Path::new(path), io::UserRWX);
3233
} else {
33-
io::File::create(&Path::new(path)).unwrap();
34+
io::File::create(&Path::new(path));
3435
}
3536
}
3637

@@ -71,8 +72,8 @@ pub fn main() {
7172
mk_file("xyz/z", false);
7273

7374
assert_eq!(glob_vec(""), Vec::new());
74-
assert_eq!(glob_vec("."), vec!(os::getcwd()));
75-
assert_eq!(glob_vec(".."), vec!(os::getcwd().join("..")));
75+
assert_eq!(glob_vec("."), Vec::new());
76+
assert_eq!(glob_vec(".."), Vec::new());
7677

7778
assert_eq!(glob_vec("aaa"), vec!(abs_path("aaa")));
7879
assert_eq!(glob_vec("aaa/"), vec!(abs_path("aaa")));
@@ -130,15 +131,6 @@ pub fn main() {
130131
abs_path("aaa/tomato/tomato.txt"),
131132
abs_path("aaa/tomato/tomoto.txt")));
132133

133-
assert_eq!(glob_vec("./aaa"), vec!(abs_path("aaa")));
134-
assert_eq!(glob_vec("./*"), glob_vec("*"));
135-
assert_eq!(glob_vec("*/..").pop().unwrap(), abs_path("."));
136-
assert_eq!(glob_vec("aaa/../bbb"), vec!(abs_path("bbb")));
137-
assert_eq!(glob_vec("nonexistent/../bbb"), Vec::new());
138-
assert_eq!(glob_vec("aaa/tomato/tomato.txt/.."), Vec::new());
139-
140-
assert_eq!(glob_vec("aaa/tomato/tomato.txt/"), Vec::new());
141-
142134
assert_eq!(glob_vec("aa[a]"), vec!(abs_path("aaa")));
143135
assert_eq!(glob_vec("aa[abc]"), vec!(abs_path("aaa")));
144136
assert_eq!(glob_vec("a[bca]a"), vec!(abs_path("aaa")));

0 commit comments

Comments
 (0)