Skip to content

Commit 4c9480a

Browse files
authored
Merge pull request #426 from ehuss/dyn-bare-trait
Fix `bare_trait_objects` warning.
2 parents ac56526 + 38dcc32 commit 4c9480a

12 files changed

+29
-29
lines changed

git2-curl/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn factory(remote: &git2::Remote, handle: Arc<Mutex<Easy>>)
9494

9595
impl SmartSubtransport for CurlTransport {
9696
fn action(&self, url: &str, action: Service)
97-
-> Result<Box<SmartSubtransportStream>, Error> {
97+
-> Result<Box<dyn SmartSubtransportStream>, Error> {
9898
let mut base_url = self.base_url.lock().unwrap();
9999
if base_url.len() == 0 {
100100
*base_url = url.to_string();
@@ -131,7 +131,7 @@ impl SmartSubtransport for CurlTransport {
131131
}
132132

133133
impl CurlSubtransport {
134-
fn err<E: Into<Box<error::Error+Send+Sync>>>(&self, err: E) -> io::Error {
134+
fn err<E: Into<Box<dyn error::Error+Send+Sync>>>(&self, err: E) -> io::Error {
135135
io::Error::new(io::ErrorKind::Other, err)
136136
}
137137

src/build.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct RepoBuilder<'cb> {
2626
/// Type of callback passed to `RepoBuilder::remote_create`.
2727
///
2828
/// The second and third arguments are the remote's name and the remote's url.
29-
pub type RemoteCreate<'cb> = for<'a> FnMut(&'a Repository, &str, &str)
29+
pub type RemoteCreate<'cb> = dyn for<'a> FnMut(&'a Repository, &str, &str)
3030
-> Result<Remote<'a>, Error> + 'cb;
3131

3232
/// A builder struct for configuring checkouts of a repository.
@@ -50,7 +50,7 @@ pub struct CheckoutBuilder<'cb> {
5050
///
5151
/// The first argument is the path for the notification, the next is the numver
5252
/// of completed steps so far, and the final is the total number of steps.
53-
pub type Progress<'a> = FnMut(Option<&Path>, usize, usize) + 'a;
53+
pub type Progress<'a> = dyn FnMut(Option<&Path>, usize, usize) + 'a;
5454

5555
/// Checkout notifications callback.
5656
///
@@ -59,7 +59,7 @@ pub type Progress<'a> = FnMut(Option<&Path>, usize, usize) + 'a;
5959
///
6060
/// The callback must return a bool specifying whether the checkout should
6161
/// continue.
62-
pub type Notify<'a> = FnMut(CheckoutNotificationType, Option<&Path>,
62+
pub type Notify<'a> = dyn FnMut(CheckoutNotificationType, Option<&Path>,
6363
Option<DiffFile>, Option<DiffFile>,
6464
Option<DiffFile>) -> bool + 'a;
6565

src/diff.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ pub enum DiffBinaryKind {
102102
Delta,
103103
}
104104

105-
type PrintCb<'a> = FnMut(DiffDelta, Option<DiffHunk>, DiffLine) -> bool + 'a;
105+
type PrintCb<'a> = dyn FnMut(DiffDelta, Option<DiffHunk>, DiffLine) -> bool + 'a;
106106

107-
pub type FileCb<'a> = FnMut(DiffDelta, f32) -> bool + 'a;
108-
pub type BinaryCb<'a> = FnMut(DiffDelta, DiffBinary) -> bool + 'a;
109-
pub type HunkCb<'a> = FnMut(DiffDelta, DiffHunk) -> bool + 'a;
110-
pub type LineCb<'a> = FnMut(DiffDelta, Option<DiffHunk>, DiffLine) -> bool + 'a;
107+
pub type FileCb<'a> = dyn FnMut(DiffDelta, f32) -> bool + 'a;
108+
pub type BinaryCb<'a> = dyn FnMut(DiffDelta, DiffBinary) -> bool + 'a;
109+
pub type HunkCb<'a> = dyn FnMut(DiffDelta, DiffHunk) -> bool + 'a;
110+
pub type LineCb<'a> = dyn FnMut(DiffDelta, Option<DiffHunk>, DiffLine) -> bool + 'a;
111111

112112
struct ForeachCallbacks<'a, 'b: 'a, 'c, 'd: 'c, 'e, 'f: 'e, 'g, 'h: 'g> {
113113
file: &'a mut FileCb<'b>,

src/index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub struct IndexConflict {
4747
/// Used by `Index::{add_all,remove_all,update_all}`. The first argument is the
4848
/// path, and the second is the patchspec that matched it. Return 0 to confirm
4949
/// the operation on the item, > 0 to skip the item, and < 0 to abort the scan.
50-
pub type IndexMatchedPath<'a> = FnMut(&Path, &[u8]) -> i32 + 'a;
50+
pub type IndexMatchedPath<'a> = dyn FnMut(&Path, &[u8]) -> i32 + 'a;
5151

5252
/// A structure to represent an entry or a file inside of an index.
5353
///

src/odb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<'repo> io::Write for OdbWriter<'repo> {
312312
fn flush(&mut self) -> io::Result<()> { Ok(()) }
313313
}
314314

315-
pub type ForeachCb<'a> = FnMut(&Oid) -> bool + 'a;
315+
pub type ForeachCb<'a> = dyn FnMut(&Oid) -> bool + 'a;
316316

317317
struct ForeachCbData<'a> {
318318
pub callback: &'a mut ForeachCb<'a>

src/packbuilder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ pub enum PackBuilderStage {
1414
Deltafication,
1515
}
1616

17-
pub type ProgressCb<'a> = FnMut(PackBuilderStage, u32, u32) -> bool + 'a;
18-
pub type ForEachCb<'a> = FnMut(&[u8]) -> bool + 'a;
17+
pub type ProgressCb<'a> = dyn FnMut(PackBuilderStage, u32, u32) -> bool + 'a;
18+
pub type ForEachCb<'a> = dyn FnMut(&[u8]) -> bool + 'a;
1919

2020
/// A builder for creating a packfile
2121
pub struct PackBuilder<'repo> {

src/panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::any::Any;
22
use std::cell::RefCell;
33

4-
thread_local!(static LAST_ERROR: RefCell<Option<Box<Any + Send>>> = {
4+
thread_local!(static LAST_ERROR: RefCell<Option<Box<dyn Any + Send>>> = {
55
RefCell::new(None)
66
});
77

src/remote_callbacks.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ enum ProgressState {
4141
/// * `username_from_url` - the username that was embedded in the url, or `None`
4242
/// if it was not included.
4343
/// * `allowed_types` - a bitmask stating which cred types are ok to return.
44-
pub type Credentials<'a> = FnMut(&str, Option<&str>, CredentialType)
44+
pub type Credentials<'a> = dyn FnMut(&str, Option<&str>, CredentialType)
4545
-> Result<Cred, Error> + 'a;
4646

4747
/// Callback to be invoked while a transfer is in progress.
@@ -51,15 +51,15 @@ pub type Credentials<'a> = FnMut(&str, Option<&str>, CredentialType)
5151
/// continue. A return value of `false` will cancel the transfer.
5252
///
5353
/// * `progress` - the progress being made so far.
54-
pub type TransferProgress<'a> = FnMut(Progress) -> bool + 'a;
54+
pub type TransferProgress<'a> = dyn FnMut(Progress) -> bool + 'a;
5555

5656
/// Callback for receiving messages delivered by the transport.
5757
///
5858
/// The return value indicates whether the network operation should continue.
59-
pub type TransportMessage<'a> = FnMut(&[u8]) -> bool + 'a;
59+
pub type TransportMessage<'a> = dyn FnMut(&[u8]) -> bool + 'a;
6060

6161
/// Callback for whenever a reference is updated locally.
62-
pub type UpdateTips<'a> = FnMut(&str, Oid, Oid) -> bool + 'a;
62+
pub type UpdateTips<'a> = dyn FnMut(&str, Oid, Oid) -> bool + 'a;
6363

6464
/// Callback for a custom certificate check.
6565
///
@@ -68,14 +68,14 @@ pub type UpdateTips<'a> = FnMut(&str, Oid, Oid) -> bool + 'a;
6868
///
6969
/// The second argument is the hostname for the connection is passed as the last
7070
/// argument.
71-
pub type CertificateCheck<'a> = FnMut(&Cert, &str) -> bool + 'a;
71+
pub type CertificateCheck<'a> = dyn FnMut(&Cert, &str) -> bool + 'a;
7272

7373
/// Callback for each updated reference on push.
7474
///
7575
/// The first argument here is the `refname` of the reference, and the second is
7676
/// the status message sent by a server. If the status is `Some` then the update
7777
/// was rejected by the remote server with a reason why.
78-
pub type PushUpdateReference<'a> = FnMut(&str, Option<&str>) -> Result<(), Error> + 'a;
78+
pub type PushUpdateReference<'a> = dyn FnMut(&str, Option<&str>) -> Result<(), Error> + 'a;
7979

8080
impl<'a> Default for RemoteCallbacks<'a> {
8181
fn default() -> Self {

src/stash.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ use std::mem;
99
///
1010
/// Return `true` to continue processing, or `false` to
1111
/// abort the stash application.
12-
pub type StashApplyProgressCb<'a> = FnMut(StashApplyProgress) -> bool + 'a;
12+
pub type StashApplyProgressCb<'a> = dyn FnMut(StashApplyProgress) -> bool + 'a;
1313

1414
/// This is a callback function you can provide to iterate over all the
1515
/// stashed states that will be invoked per entry.
16-
pub type StashCb<'a> = FnMut(usize, &str, &Oid) -> bool + 'a;
16+
pub type StashCb<'a> = dyn FnMut(usize, &str, &Oid) -> bool + 'a;
1717

1818
#[allow(unused)]
1919
/// Stash application options structure

src/transport.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub trait SmartSubtransport: Send + 'static {
4040
/// returns a stream which can be read and written from in order to
4141
/// negotiate the git protocol.
4242
fn action(&self, url: &str, action: Service)
43-
-> Result<Box<SmartSubtransportStream>, Error>;
43+
-> Result<Box<dyn SmartSubtransportStream>, Error>;
4444

4545
/// Terminates a connection with the remote.
4646
///
@@ -73,7 +73,7 @@ pub trait SmartSubtransportStream: Read + Write + Send + 'static {}
7373

7474
impl<T: Read + Write + Send + 'static> SmartSubtransportStream for T {}
7575

76-
type TransportFactory = Fn(&Remote) -> Result<Transport, Error> + Send + Sync +
76+
type TransportFactory = dyn Fn(&Remote) -> Result<Transport, Error> + Send + Sync +
7777
'static;
7878

7979
/// Boxed data payload used for registering new transports.
@@ -88,15 +88,15 @@ struct TransportData {
8888
#[repr(C)]
8989
struct RawSmartSubtransport {
9090
raw: raw::git_smart_subtransport,
91-
obj: Box<SmartSubtransport>,
91+
obj: Box<dyn SmartSubtransport>,
9292
}
9393

9494
/// Instance of a `git_smart_subtransport_stream`, must use `#[repr(C)]` to
9595
/// ensure that the C fields come first.
9696
#[repr(C)]
9797
struct RawSmartSubtransportStream {
9898
raw: raw::git_smart_subtransport_stream,
99-
obj: Box<SmartSubtransportStream>,
99+
obj: Box<dyn SmartSubtransportStream>,
100100
}
101101

102102
/// Add a custom transport definition, to be used in addition to the built-in

src/tree.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl<'repo> Tree<'repo> {
199199
}
200200
}
201201

202-
type TreeWalkCb<'a, T> = FnMut(&str, &TreeEntry) -> T + 'a;
202+
type TreeWalkCb<'a, T> = dyn FnMut(&str, &TreeEntry) -> T + 'a;
203203

204204
extern fn treewalk_cb<T: Into<i32>>(root: *const c_char, entry: *const raw::git_tree_entry, payload: *mut c_void) -> c_int {
205205
match panic::wrap(|| unsafe {

src/treebuilder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'repo> TreeBuilder<'repo> {
9898
}
9999
}
100100

101-
type FilterCb<'a> = FnMut(&TreeEntry) -> bool + 'a;
101+
type FilterCb<'a> = dyn FnMut(&TreeEntry) -> bool + 'a;
102102

103103
extern fn filter_cb(entry: *const raw::git_tree_entry,
104104
payload: *mut c_void) -> c_int {

0 commit comments

Comments
 (0)