Skip to content

Commit 4c41620

Browse files
committed
Don't println! in Drop (see rust-lang/rust#29488)
1 parent 5ad0f7b commit 4c41620

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

couchbase-lite/src/replicator.rs

+9-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
fl_slice::{fl_slice_empty, flslice_as_str, AsFlSlice, FlSliceOwner},
1313
Database, Result,
1414
};
15-
use log::{error, info};
15+
use log::{debug, error, info};
1616
use std::{
1717
convert::TryFrom, mem, os::raw::c_void, panic::catch_unwind, process::abort, ptr, ptr::NonNull,
1818
};
@@ -23,13 +23,6 @@ struct CallContext {
2323
after_pull_ctx: *mut c_void,
2424
}
2525

26-
impl Drop for CallContext {
27-
fn drop(&mut self) {
28-
println!("CallContext.drop()");
29-
// fields are dropped implicitely (I think)
30-
}
31-
}
32-
3326
pub(crate) struct Replicator {
3427
inner: NonNull<C4Replicator>,
3528
c_callback_on_status_changed: C4ReplicatorStatusChangedCallback,
@@ -45,7 +38,6 @@ unsafe impl Send for Replicator {}
4538

4639
impl Drop for Replicator {
4740
fn drop(&mut self) {
48-
println!("Replicator.drop()");
4941
unsafe {
5042
c4repl_free(self.inner.as_ptr());
5143
(self.free_callback_f)(self.callback_context.as_ptr());
@@ -108,7 +100,7 @@ impl Replicator {
108100
G: FnMut(&str, &str, C4RevisionFlags, &str) -> String + Send,
109101
{
110102
let call_result = catch_unwind(|| {
111-
println!("call_before_push");
103+
debug!("call_before_push");
112104
let call_context = ctx as *mut CallContext;
113105
let call_context = match call_context.as_ref() {
114106
None => panic!("Internal error - null callback context"),
@@ -127,13 +119,14 @@ impl Replicator {
127119
(*boxed_before_push_hook)(rust_id, rust_rev, flags, body_string);
128120
call_result
129121
});
122+
#[allow(clippy::match_wild_err_arm)]
130123
match call_result {
131-
Err(_) => {
124+
Err(_error) => {
132125
error!("Replicator::call_before_push catch panic aborting");
133126
panic!();
134127
}
135128
Ok(result) => {
136-
println!("before_push hook returned {:?}", result);
129+
debug!("before_push hook returned {:?}", result);
137130
let copy = FLSlice_Copy(result.as_str().as_flslice());
138131
copy.as_flslice()
139132
}
@@ -168,13 +161,14 @@ impl Replicator {
168161
(*boxed_after_pull_hook)(rust_id, rust_rev, flags, body_string);
169162
call_result
170163
});
164+
#[allow(clippy::match_wild_err_arm)]
171165
match call_result {
172-
Err(_) => {
166+
Err(_error) => {
173167
error!("Replicator::call_after_pull catch panic aborting");
174168
panic!();
175169
}
176170
Ok(result) => {
177-
println!("after_pull hook returned {:?}", result);
171+
debug!("after_pull hook returned {:?}", result);
178172
let copy = FLSlice_Copy(result.as_str().as_flslice());
179173
copy.as_flslice()
180174
}
@@ -187,7 +181,7 @@ impl Replicator {
187181
let boxed_state_change: *mut F = Box::into_raw(Box::new(state_changed_callback));
188182
let boxed_before_push: *mut G =
189183
before_push.map_or_else(ptr::null_mut, |f| Box::into_raw(Box::new(f)));
190-
println!("boxed_before_push={:?}", boxed_before_push);
184+
debug!("boxed_before_push={:?}", boxed_before_push);
191185
let boxed_after_pull: *mut H =
192186
after_pull.map_or_else(ptr::null_mut, |f| Box::into_raw(Box::new(f)));
193187
let callback_context = CallContext {

0 commit comments

Comments
 (0)