Skip to content

Commit b660c5a

Browse files
bors[bot]taiki-e
andauthored
Merge #515
515: Deny warnings for doc tests r=jeehoonkang a=taiki-e There are some unused imports/`mut`s. Refs: rust-lang/futures-rs#1672, tokio-rs/tokio#1539 Co-authored-by: Taiki Endo <[email protected]>
2 parents 5c74eb1 + 7cb7218 commit b660c5a

File tree

19 files changed

+91
-63
lines changed

19 files changed

+91
-63
lines changed

crossbeam-channel/src/channel.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ pub fn bounded<T>(cap: usize) -> (Sender<T>, Receiver<T>) {
136136
/// Using an `after` channel for timeouts:
137137
///
138138
/// ```
139-
/// # fn main() {
140139
/// use std::time::Duration;
141140
/// use crossbeam_channel::{after, select, unbounded};
142141
///
@@ -147,7 +146,6 @@ pub fn bounded<T>(cap: usize) -> (Sender<T>, Receiver<T>) {
147146
/// recv(r) -> msg => println!("received {:?}", msg),
148147
/// recv(after(timeout)) -> _ => println!("timed out"),
149148
/// }
150-
/// # }
151149
/// ```
152150
///
153151
/// When the message gets sent:
@@ -187,9 +185,8 @@ pub fn after(duration: Duration) -> Receiver<Instant> {
187185
/// Using a `never` channel to optionally add a timeout to [`select!`]:
188186
///
189187
/// ```
190-
/// # fn main() {
191188
/// use std::thread;
192-
/// use std::time::{Duration, Instant};
189+
/// use std::time::Duration;
193190
/// use crossbeam_channel::{after, select, never, unbounded};
194191
///
195192
/// let (s, r) = unbounded();
@@ -211,7 +208,6 @@ pub fn after(duration: Duration) -> Receiver<Instant> {
211208
/// recv(r) -> msg => assert_eq!(msg, Ok(1)),
212209
/// recv(timeout) -> _ => println!("timed out"),
213210
/// }
214-
/// # }
215211
/// ```
216212
///
217213
/// [`select!`]: macro.select.html
@@ -597,9 +593,9 @@ impl<T> fmt::Debug for Sender<T> {
597593
/// let (s, r) = unbounded();
598594
///
599595
/// thread::spawn(move || {
600-
/// s.send(1);
596+
/// let _ = s.send(1);
601597
/// thread::sleep(Duration::from_secs(1));
602-
/// s.send(2);
598+
/// let _ = s.send(2);
603599
/// });
604600
///
605601
/// assert_eq!(r.recv(), Ok(1)); // Received immediately.

crossbeam-channel/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@
122122
//! It's also possible to share senders and receivers by reference:
123123
//!
124124
//! ```
125-
//! # fn main() {
126-
//! use std::thread;
127125
//! use crossbeam_channel::bounded;
128126
//! use crossbeam_utils::thread::scope;
129127
//!
@@ -140,7 +138,6 @@
140138
//! s.send(1).unwrap();
141139
//! r.recv().unwrap();
142140
//! }).unwrap();
143-
//! # }
144141
//! ```
145142
//!
146143
//! # Disconnection
@@ -269,7 +266,6 @@
269266
//! An example of receiving a message from two channels:
270267
//!
271268
//! ```
272-
//! # fn main() {
273269
//! use std::thread;
274270
//! use std::time::Duration;
275271
//! use crossbeam_channel::{select, unbounded};
@@ -286,7 +282,6 @@
286282
//! recv(r2) -> msg => assert_eq!(msg, Ok(20)),
287283
//! default(Duration::from_secs(1)) => println!("timed out"),
288284
//! }
289-
//! # }
290285
//! ```
291286
//!
292287
//! If you need to select over a dynamically created list of channel operations, use [`Select`]
@@ -306,7 +301,6 @@
306301
//! An example that prints elapsed time every 50 milliseconds for the duration of 1 second:
307302
//!
308303
//! ```
309-
//! # fn main() {
310304
//! use std::time::{Duration, Instant};
311305
//! use crossbeam_channel::{after, select, tick};
312306
//!
@@ -320,7 +314,6 @@
320314
//! recv(timeout) -> _ => break,
321315
//! }
322316
//! }
323-
//! # }
324317
//! ```
325318
//!
326319
//! [`std::sync::mpsc`]: https://doc.rust-lang.org/std/sync/mpsc/index.html
@@ -338,6 +331,13 @@
338331
//! [`Sender`]: struct.Sender.html
339332
//! [`Receiver`]: struct.Receiver.html
340333
334+
#![doc(test(
335+
no_crate_inject,
336+
attr(
337+
deny(warnings, rust_2018_idioms),
338+
allow(dead_code, unused_assignments, unused_variables)
339+
)
340+
))]
341341
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
342342
#![cfg_attr(not(feature = "std"), no_std)]
343343

crossbeam-channel/src/select.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ impl<'a> Select<'a> {
615615
/// # Examples
616616
///
617617
/// ```
618-
/// use std::thread;
619618
/// use crossbeam_channel::{unbounded, Select};
620619
///
621620
/// let (s, r) = unbounded::<i32>();
@@ -638,7 +637,6 @@ impl<'a> Select<'a> {
638637
/// # Examples
639638
///
640639
/// ```
641-
/// use std::thread;
642640
/// use crossbeam_channel::{unbounded, Select};
643641
///
644642
/// let (s, r) = unbounded::<i32>();
@@ -669,7 +667,6 @@ impl<'a> Select<'a> {
669667
/// # Examples
670668
///
671669
/// ```
672-
/// use std::thread;
673670
/// use crossbeam_channel::{unbounded, Select};
674671
///
675672
/// let (s1, r1) = unbounded::<i32>();
@@ -728,7 +725,6 @@ impl<'a> Select<'a> {
728725
/// # Examples
729726
///
730727
/// ```
731-
/// use std::thread;
732728
/// use crossbeam_channel::{unbounded, Select};
733729
///
734730
/// let (s1, r1) = unbounded();
@@ -874,7 +870,6 @@ impl<'a> Select<'a> {
874870
/// # Examples
875871
///
876872
/// ```
877-
/// use std::thread;
878873
/// use crossbeam_channel::{unbounded, Select};
879874
///
880875
/// let (s1, r1) = unbounded();

crossbeam-channel/src/select_macro.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,8 +1076,6 @@ macro_rules! crossbeam_channel_internal {
10761076
/// Block until a send or a receive operation is selected:
10771077
///
10781078
/// ```
1079-
/// # fn main() {
1080-
/// use std::thread;
10811079
/// use crossbeam_channel::{select, unbounded};
10821080
///
10831081
/// let (s1, r1) = unbounded();
@@ -1092,13 +1090,11 @@ macro_rules! crossbeam_channel_internal {
10921090
/// assert_eq!(r2.recv(), Ok(20));
10931091
/// }
10941092
/// }
1095-
/// # }
10961093
/// ```
10971094
///
10981095
/// Select from a set of operations without blocking:
10991096
///
11001097
/// ```
1101-
/// # fn main() {
11021098
/// use std::thread;
11031099
/// use std::time::Duration;
11041100
/// use crossbeam_channel::{select, unbounded};
@@ -1121,13 +1117,11 @@ macro_rules! crossbeam_channel_internal {
11211117
/// recv(r2) -> msg => panic!(),
11221118
/// default => println!("not ready"),
11231119
/// }
1124-
/// # }
11251120
/// ```
11261121
///
11271122
/// Select over a set of operations with a timeout:
11281123
///
11291124
/// ```
1130-
/// # fn main() {
11311125
/// use std::thread;
11321126
/// use std::time::Duration;
11331127
/// use crossbeam_channel::{select, unbounded};
@@ -1150,13 +1144,11 @@ macro_rules! crossbeam_channel_internal {
11501144
/// recv(r2) -> msg => panic!(),
11511145
/// default(Duration::from_millis(100)) => println!("timed out"),
11521146
/// }
1153-
/// # }
11541147
/// ```
11551148
///
11561149
/// Optionally add a receive operation to `select!` using [`never`]:
11571150
///
11581151
/// ```
1159-
/// # fn main() {
11601152
/// use std::thread;
11611153
/// use std::time::Duration;
11621154
/// use crossbeam_channel::{select, never, unbounded};
@@ -1181,7 +1173,6 @@ macro_rules! crossbeam_channel_internal {
11811173
/// recv(r1) -> msg => panic!(),
11821174
/// recv(r2.unwrap_or(&never())) -> msg => assert_eq!(msg, Ok(20)),
11831175
/// }
1184-
/// # }
11851176
/// ```
11861177
///
11871178
/// To optionally add a timeout to `select!`, see the [example] for [`never`].

crossbeam-deque/src/deque.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ impl<T> Stealer<T> {
665665
/// let s = w1.stealer();
666666
/// let w2 = Worker::new_fifo();
667667
///
668-
/// s.steal_batch(&w2);
668+
/// let _ = s.steal_batch(&w2);
669669
/// assert_eq!(w2.pop(), Some(1));
670670
/// assert_eq!(w2.pop(), Some(2));
671671
/// ```
@@ -1384,7 +1384,7 @@ impl<T> Injector<T> {
13841384
/// q.push(4);
13851385
///
13861386
/// let w = Worker::new_fifo();
1387-
/// q.steal_batch(&w);
1387+
/// let _ = q.steal_batch(&w);
13881388
/// assert_eq!(w.pop(), Some(1));
13891389
/// assert_eq!(w.pop(), Some(2));
13901390
/// ```

crossbeam-deque/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
//! An implementation of this work-stealing strategy:
5151
//!
5252
//! ```
53-
//! use crossbeam_deque::{Injector, Steal, Stealer, Worker};
53+
//! use crossbeam_deque::{Injector, Stealer, Worker};
5454
//! use std::iter;
5555
//!
5656
//! fn find_task<T>(
@@ -86,6 +86,13 @@
8686
//! [`steal_batch()`]: struct.Stealer.html#method.steal_batch
8787
//! [`steal_batch_and_pop()`]: struct.Stealer.html#method.steal_batch_and_pop
8888
89+
#![doc(test(
90+
no_crate_inject,
91+
attr(
92+
deny(warnings, rust_2018_idioms),
93+
allow(dead_code, unused_assignments, unused_variables)
94+
)
95+
))]
8996
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
9097
#![cfg_attr(not(feature = "std"), no_std)]
9198

crossbeam-epoch/src/atomic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl<T> Atomic<T> {
225225
/// # Examples
226226
///
227227
/// ```
228-
/// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared};
228+
/// use crossbeam_epoch::{Atomic, Owned, Shared};
229229
/// use std::sync::atomic::Ordering::SeqCst;
230230
///
231231
/// let a = Atomic::new(1234);
@@ -247,7 +247,7 @@ impl<T> Atomic<T> {
247247
/// # Examples
248248
///
249249
/// ```
250-
/// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared};
250+
/// use crossbeam_epoch::{self as epoch, Atomic, Shared};
251251
/// use std::sync::atomic::Ordering::SeqCst;
252252
///
253253
/// let a = Atomic::new(1234);
@@ -280,7 +280,7 @@ impl<T> Atomic<T> {
280280
/// let a = Atomic::new(1234);
281281
///
282282
/// let guard = &epoch::pin();
283-
/// let mut curr = a.load(SeqCst, guard);
283+
/// let curr = a.load(SeqCst, guard);
284284
/// let res1 = a.compare_and_set(curr, Shared::null(), SeqCst, guard);
285285
/// let res2 = a.compare_and_set(curr, Owned::new(5678), SeqCst, guard);
286286
/// ```
@@ -689,7 +689,7 @@ impl<T> Owned<T> {
689689
/// # Examples
690690
///
691691
/// ```
692-
/// use crossbeam_epoch::{self as epoch, Owned};
692+
/// use crossbeam_epoch::Owned;
693693
///
694694
/// let o = Owned::new(1234);
695695
/// let b: Box<i32> = o.into_box();
@@ -1114,7 +1114,7 @@ impl<T> From<*const T> for Shared<'_, T> {
11141114
/// ```
11151115
/// use crossbeam_epoch::Shared;
11161116
///
1117-
/// let p = unsafe { Shared::from(Box::into_raw(Box::new(1234)) as *const _) };
1117+
/// let p = Shared::from(Box::into_raw(Box::new(1234)) as *const _);
11181118
/// assert!(!p.is_null());
11191119
/// ```
11201120
fn from(raw: *const T) -> Self {

crossbeam-epoch/src/guard.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::internal::Local;
3030
/// For example:
3131
///
3232
/// ```
33-
/// use crossbeam_epoch::{self as epoch, Atomic, Owned};
33+
/// use crossbeam_epoch::{self as epoch, Atomic};
3434
/// use std::sync::atomic::Ordering::SeqCst;
3535
///
3636
/// // Create a heap-allocated number.
@@ -289,11 +289,9 @@ impl Guard {
289289
/// use crossbeam_epoch as epoch;
290290
///
291291
/// let guard = &epoch::pin();
292-
/// unsafe {
293-
/// guard.defer(move || {
294-
/// println!("This better be printed as soon as possible!");
295-
/// });
296-
/// }
292+
/// guard.defer(move || {
293+
/// println!("This better be printed as soon as possible!");
294+
/// });
297295
/// guard.flush();
298296
/// ```
299297
///
@@ -318,8 +316,6 @@ impl Guard {
318316
/// ```
319317
/// use crossbeam_epoch::{self as epoch, Atomic};
320318
/// use std::sync::atomic::Ordering::SeqCst;
321-
/// use std::thread;
322-
/// use std::time::Duration;
323319
///
324320
/// let a = Atomic::new(777);
325321
/// let mut guard = epoch::pin();
@@ -407,8 +403,8 @@ impl Guard {
407403
/// ```
408404
/// use crossbeam_epoch as epoch;
409405
///
410-
/// let mut guard1 = epoch::pin();
411-
/// let mut guard2 = epoch::pin();
406+
/// let guard1 = epoch::pin();
407+
/// let guard2 = epoch::pin();
412408
/// assert!(guard1.collector() == guard2.collector());
413409
/// ```
414410
///

crossbeam-epoch/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@
5454
//! [`pin`]: fn.pin.html
5555
//! [`defer`]: struct.Guard.html#method.defer
5656
57+
#![doc(test(
58+
no_crate_inject,
59+
attr(
60+
deny(warnings, rust_2018_idioms),
61+
allow(dead_code, unused_assignments, unused_variables)
62+
)
63+
))]
5764
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
5865
#![cfg_attr(not(feature = "std"), no_std)]
5966
#![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic))]

crossbeam-epoch/src/sync/queue.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ impl<T> Queue<T> {
6363
/// Attempts to atomically place `n` into the `next` pointer of `onto`, and returns `true` on
6464
/// success. The queue's `tail` pointer may be updated.
6565
#[inline(always)]
66-
fn push_internal(&self, onto: Shared<'_, Node<T>>, new: Shared<'_, Node<T>>, guard: &Guard) -> bool {
66+
fn push_internal(
67+
&self,
68+
onto: Shared<'_, Node<T>>,
69+
new: Shared<'_, Node<T>>,
70+
guard: &Guard,
71+
) -> bool {
6772
// is `onto` the actual tail?
6873
let o = unsafe { onto.deref() };
6974
let next = o.next.load(Acquire, guard);
@@ -205,8 +210,8 @@ impl<T> Drop for Queue<T> {
205210
#[cfg(test)]
206211
mod test {
207212
use super::*;
208-
use crossbeam_utils::thread;
209213
use crate::pin;
214+
use crossbeam_utils::thread;
210215

211216
struct Queue<T> {
212217
queue: super::Queue<T>,

0 commit comments

Comments
 (0)