Skip to content

Commit 30eb9d3

Browse files
committed
Update to rust master
1 parent f2d2d39 commit 30eb9d3

File tree

14 files changed

+33
-39
lines changed

14 files changed

+33
-39
lines changed

examples/add.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1313
*/
1414

15-
#![feature(old_orphan_check)]
1615
#![deny(warnings)]
1716

1817
extern crate git2;
@@ -34,21 +33,22 @@ fn run(args: &Args) -> Result<(), git2::Error> {
3433
let repo = try!(Repository::open(&Path::new(".")));
3534
let mut index = try!(repo.index());
3635

37-
let cb = if args.flag_verbose || args.flag_update {
38-
Some(|path: &[u8], _matched_spec: &[u8]| -> int {
39-
let path = Path::new(path);
40-
let status = repo.status_file(&path).unwrap();
36+
let cb = (&mut |&mut: path: &[u8], _matched_spec: &[u8]| -> int {
37+
let path = Path::new(path);
38+
let status = repo.status_file(&path).unwrap();
4139

42-
let ret = if status.contains(git2::STATUS_WT_MODIFIED) ||
43-
status.contains(git2::STATUS_WT_NEW) {
44-
println!("add '{}'", path.display());
45-
0
46-
} else {
47-
1
48-
};
40+
let ret = if status.contains(git2::STATUS_WT_MODIFIED) ||
41+
status.contains(git2::STATUS_WT_NEW) {
42+
println!("add '{}'", path.display());
43+
0
44+
} else {
45+
1
46+
};
4947

50-
if args.flag_dry_run {1} else {ret}
51-
})
48+
if args.flag_dry_run {1} else {ret}
49+
}) as &mut git2::IndexMatchedPath;
50+
let cb = if args.flag_verbose || args.flag_update {
51+
Some(cb)
5252
} else {
5353
None
5454
};

examples/clone.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1313
*/
1414

15-
#![feature(old_orphan_check)]
1615
#![deny(warnings)]
1716

1817
extern crate git2;

examples/fetch.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1313
*/
1414

15-
#![feature(old_orphan_check)]
1615
#![deny(warnings)]
1716

1817
extern crate git2;

examples/init.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1313
*/
1414

15-
#![feature(old_orphan_check)]
1615
#![deny(warnings)]
1716

1817
extern crate git2;

examples/log.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1313
*/
1414

15-
#![feature(macro_rules, old_orphan_check)]
15+
#![feature(macro_rules)]
1616
#![deny(warnings)]
1717

1818
extern crate "rustc-serialize" as rustc_serialize;

examples/ls-remote.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1313
*/
1414

15-
#![feature(old_orphan_check)]
1615
#![deny(warnings)]
1716

1817
extern crate git2;

examples/rev-list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1414
*/
1515

16-
#![feature(slicing_syntax, old_orphan_check)]
16+
#![feature(slicing_syntax)]
1717
#![deny(warnings)]
1818

1919
extern crate git2;

examples/rev-parse.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1313
*/
1414

15-
#![feature(old_orphan_check)]
1615
#![deny(warnings)]
1716

1817
extern crate git2;

examples/status.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1313
*/
1414

15-
#![feature(old_orphan_check)]
1615
#![deny(warnings)]
1716

1817
extern crate git2;

src/build.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,7 @@ extern fn progress_cb(path: *const c_char,
432432
};
433433
let path = CString::new(path, false);
434434
panic::wrap(|| {
435-
callback.call_mut((path.as_bytes_no_nul(),
436-
completed as uint, total as uint));
435+
callback(path.as_bytes_no_nul(), completed as uint, total as uint);
437436
});
438437
}
439438
}

src/index.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct IndexEntries<'index> {
2727
/// Used by `Index::{add_all,remove_all,update_all}`. The first argument is the
2828
/// path, and the second is the patchspec that matched it. Return 0 to confirm
2929
/// the operation on the item, > 0 to skip the item, and < 0 to abort the scan.
30-
pub type IndexMatchedPath<'a> = |&[u8], &[u8]|: 'a -> int;
30+
pub type IndexMatchedPath<'a> = FnMut(&[u8], &[u8]) -> int + 'a;
3131

3232
/// A structure to represent an entry or a file inside of an index.
3333
///
@@ -162,7 +162,7 @@ impl Index {
162162
pub fn add_all<T: ToCStr>(&mut self,
163163
pathspecs: &[T],
164164
flag: IndexAddOption,
165-
mut cb: Option<IndexMatchedPath>)
165+
mut cb: Option<&mut IndexMatchedPath>)
166166
-> Result<(), Error> {
167167
let arr = pathspecs.iter().map(|t| t.to_c_str()).collect::<Vec<CString>>();
168168
let strarray = arr.iter().map(|c| c.as_ptr())
@@ -299,7 +299,7 @@ impl Index {
299299
/// the item, > 0 to skip the item, and < 0 to abort the scan.
300300
pub fn remove_all<T: ToCStr>(&mut self,
301301
pathspecs: &[T],
302-
mut cb: Option<IndexMatchedPath>)
302+
mut cb: Option<&mut IndexMatchedPath>)
303303
-> Result<(), Error> {
304304
let arr = pathspecs.iter().map(|t| t.to_c_str()).collect::<Vec<CString>>();
305305
let strarray = arr.iter().map(|c| c.as_ptr())
@@ -338,7 +338,7 @@ impl Index {
338338
/// updating the item, > 0 to skip the item, and < 0 to abort the scan.
339339
pub fn update_all<T: ToCStr>(&mut self,
340340
pathspecs: &[T],
341-
mut cb: Option<IndexMatchedPath>)
341+
mut cb: Option<&mut IndexMatchedPath>)
342342
-> Result<(), Error> {
343343
let arr = pathspecs.iter().map(|t| t.to_c_str()).collect::<Vec<CString>>();
344344
let strarray = arr.iter().map(|c| c.as_ptr())
@@ -408,7 +408,7 @@ extern fn index_matched_path_cb(path: *const libc::c_char,
408408
unsafe {
409409
let path = CString::new(path, false);
410410
let matched_pathspec = CString::new(matched_pathspec, false);
411-
let payload = payload as *mut IndexMatchedPath;
411+
let payload = payload as *mut &mut IndexMatchedPath;
412412
(*payload)(path.as_bytes_no_nul(),
413413
matched_pathspec.as_bytes_no_nul()) as libc::c_int
414414
}
@@ -516,23 +516,24 @@ mod tests {
516516
fs::mkdir(&root.join("foo"), io::USER_DIR).unwrap();
517517
File::create(&root.join("foo/bar")).unwrap();
518518
let mut called = false;
519-
index.add_all(&["foo"], ::ADD_DEFAULT, Some(|a: &[u8], b: &[u8]| {
519+
index.add_all(&["foo"], ::ADD_DEFAULT,
520+
Some((&mut |&mut: a: &[u8], b: &[u8]| {
520521
assert!(!called);
521522
called = true;
522523
assert_eq!(b, b"foo");
523524
assert_eq!(a, b"foo/bar");
524525
0
525-
})).unwrap();
526+
}) as &mut super::IndexMatchedPath)).unwrap();
526527
assert!(called);
527528

528529
called = false;
529-
index.remove_all(&["."], Some(|a: &[u8], b: &[u8]| {
530+
index.remove_all(&["."], Some((&mut |&mut: a: &[u8], b: &[u8]| {
530531
assert!(!called);
531532
called = true;
532533
assert_eq!(b, b".");
533534
assert_eq!(a, b"foo/bar");
534535
0
535-
})).unwrap();
536+
}) as &mut super::IndexMatchedPath)).unwrap();
536537
assert!(called);
537538
}
538539

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
//! source `Repository`, to ensure that they do not outlive the repository
6464
//! itself.
6565
66-
#![feature(macro_rules, unsafe_destructor, unboxed_closures)]
66+
#![feature(macro_rules, unsafe_destructor)]
6767
#![feature(associated_types)]
6868
#![deny(missing_docs)]
6969
#![cfg_attr(test, deny(warnings))]

src/remote_callbacks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ extern fn credentials_cb(ret: *mut *mut raw::git_cred,
224224

225225
let cred_type = CredentialType::from_bits_truncate(allowed_types as uint);
226226
match panic::wrap(|| {
227-
callback.call_mut((url, username_from_url, cred_type))
227+
callback(url, username_from_url, cred_type)
228228
}) {
229229
Some(Ok(cred)) => {
230230
// Turns out it's a memory safety issue if we pass through any
@@ -252,7 +252,7 @@ extern fn transfer_progress_cb(stats: *const raw::git_transfer_progress,
252252
};
253253
let progress = Progress::from_raw(stats);
254254
let ok = panic::wrap(move || {
255-
callback.call_mut((progress,))
255+
callback(progress)
256256
}).unwrap_or(false);
257257
if ok {0} else {-1}
258258
}
@@ -270,7 +270,7 @@ extern fn sideband_progress_cb(str: *const c_char,
270270
let ptr = str as *const u8;
271271
let buf = slice::from_raw_buf(&ptr, len as uint);
272272
let ok = panic::wrap(|| {
273-
callback.call_mut((buf,))
273+
callback(buf)
274274
}).unwrap_or(false);
275275
if ok {0} else {-1}
276276
}
@@ -291,7 +291,7 @@ extern fn update_tips_cb(refname: *const c_char,
291291
let a = Oid::from_raw(a);
292292
let b = Oid::from_raw(b);
293293
let ok = panic::wrap(|| {
294-
callback.call_mut((refname, a, b))
294+
callback(refname, a, b)
295295
}).unwrap_or(false);
296296
if ok {0} else {-1}
297297
}

src/repo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ impl RepositoryInitOptions {
12011201
raw::GIT_REPOSITORY_INIT_OPTIONS_VERSION), 0);
12021202
opts.flags = self.flags;
12031203
opts.mode = self.mode;
1204-
let cstr = |a: &Option<CString>| {
1204+
let cstr = |&: a: &Option<CString>| {
12051205
a.as_ref().map(|s| s.as_ptr()).unwrap_or(0 as *const _)
12061206
};
12071207
opts.workdir_path = cstr(&self.workdir_path);

0 commit comments

Comments
 (0)