fix or ignore failing doc tests

This commit is contained in:
Andy Russell 2019-03-05 17:23:50 -05:00
parent fe96ffeac9
commit a9de64a151
No known key found for this signature in database
GPG key ID: BE2221033EDBC374
44 changed files with 137 additions and 127 deletions

View file

@ -15,13 +15,13 @@ declare_clippy_lint! {
/// **Known problems:** None
///
/// **Example:**
/// ```rust
/// assert!(false)
/// ```no_run
/// assert!(false);
/// // or
/// assert!(true)
/// assert!(true);
/// // or
/// const B: bool = false;
/// assert!(B)
/// assert!(B);
/// ```
pub ASSERTIONS_ON_CONSTANTS,
style,

View file

@ -17,7 +17,7 @@ declare_clippy_lint! {
/// implementations that differ from the regular `Op` impl.
///
/// **Example:**
/// ```rust
/// ```ignore
/// let mut a = 5;
/// ...
/// a = a + b;
@ -39,7 +39,7 @@ declare_clippy_lint! {
/// written as `a = a op a op b` as it's less confusing.
///
/// **Example:**
/// ```rust
/// ```ignore
/// let mut a = 5;
/// ...
/// a += a + b;

View file

@ -34,7 +34,7 @@ declare_clippy_lint! {
/// done the measurement.
///
/// **Example:**
/// ```rust
/// ```ignore
/// #[inline(always)]
/// fn not_quite_hot_code(..) { ... }
/// ```
@ -57,7 +57,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// // Bad
/// #[deny(dead_code)]
/// extern crate foo;
@ -88,7 +88,7 @@ declare_clippy_lint! {
/// **Example:**
/// ```rust
/// #[deprecated(since = "forever")]
/// fn something_else(..) { ... }
/// fn something_else() { /* ... */ }
/// ```
pub DEPRECATED_SEMVER,
correctness,

View file

@ -37,7 +37,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// if (x & 1 == 2) { … }
/// ```
pub BAD_BIT_MASK,
@ -65,7 +65,7 @@ declare_clippy_lint! {
/// uncommon).
///
/// **Example:**
/// ```rust
/// ```ignore
/// if (x | 1 > 3) { … }
/// ```
pub INEFFECTIVE_BIT_MASK,
@ -83,7 +83,7 @@ declare_clippy_lint! {
/// **Known problems:** llvm generates better code for `x & 15 == 0` on x86
///
/// **Example:**
/// ```rust
/// ```ignore
/// x & 0x1111 == 0
/// ```
pub VERBOSE_BIT_MASK,

View file

@ -16,7 +16,7 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// if { true } ..
/// if { true } { /* ... */ }
/// ```
pub BLOCK_IN_IF_CONDITION_EXPR,
style,
@ -32,10 +32,10 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// if { let x = somefunc(); x } ..
/// ```ignore
/// if { let x = somefunc(); x } {}
/// // or
/// if somefunc(|x| { x == 47 }) ..
/// if somefunc(|x| { x == 47 }) {}
/// ```
pub BLOCK_IN_IF_CONDITION_STMT,
style,

View file

@ -21,7 +21,7 @@ declare_clippy_lint! {
/// `&&`. Ignores `|`, `&` and `^`.
///
/// **Example:**
/// ```rust
/// ```ignore
/// if a && true // should be: if a
/// if !(a == b) // should be: if a != b
/// ```
@ -39,7 +39,7 @@ declare_clippy_lint! {
/// **Known problems:** Ignores short circuiting behavior.
///
/// **Example:**
/// ```rust
/// ```ignore
/// if a && b || a { ... }
/// ```
/// The `b` is unnecessary, the expression is equivalent to `if a`.

View file

@ -13,12 +13,12 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// const FOO: &'static [(&'static str, &'static str, fn(&Bar) -> bool)] =
/// &[...]
/// ```
/// This code can be rewritten as
/// ```rust
/// ```ignore
/// const FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...]
/// ```
pub CONST_STATIC_LIFETIME,

View file

@ -18,7 +18,7 @@ declare_clippy_lint! {
/// **Known problems:** Hopefully none.
///
/// **Example:**
/// ```rust
/// ```ignore
/// if a == b {
/// …
/// } else if a == b {
@ -29,7 +29,7 @@ declare_clippy_lint! {
/// Note that this lint ignores all conditions with a function call as it could
/// have side effects:
///
/// ```rust
/// ```ignore
/// if foo() {
/// …
/// } else if foo() { // not linted
@ -50,7 +50,7 @@ declare_clippy_lint! {
/// **Known problems:** Hopefully none.
///
/// **Example:**
/// ```rust
/// ```ignore
/// let foo = if … {
/// 42
/// } else {

View file

@ -16,14 +16,14 @@ declare_clippy_lint! {
/// default-generated `Hash` implementation with an explicitly defined
/// `PartialEq`. In particular, the following must hold for any type:
///
/// ```rust
/// ```text
/// k1 == k2 ⇒ hash(k1) == hash(k2)
/// ```
///
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// #[derive(Hash)]
/// struct Foo;
///

View file

@ -17,7 +17,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// let mut lock_guard = mutex.lock();
/// std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex
/// // still locked

View file

@ -88,7 +88,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// // lib.rs
/// mod foo;
/// // foo.rs

View file

@ -19,7 +19,7 @@ declare_clippy_lint! {
/// calls. We may introduce a whitelist of known pure functions in the future.
///
/// **Example:**
/// ```rust
/// ```ignore
/// x + 1 == x + 1
/// ```
pub EQ_OP,
@ -37,7 +37,7 @@ declare_clippy_lint! {
/// **Known problems:** None
///
/// **Example:**
/// ```rust
/// ```ignore
/// &x == y
/// ```
pub OP_REF,

View file

@ -15,7 +15,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// 0 / x;
/// 0 * x;
/// x & 0

View file

@ -23,7 +23,7 @@ declare_clippy_lint! {
/// details.
///
/// **Example:**
/// ```rust
/// ```ignore
/// xs.map(|x| foo(x))
/// ```
/// where `foo(_)` is a plain function that takes the exact argument type of

View file

@ -19,7 +19,8 @@ declare_clippy_lint! {
/// **Known problems:** Hopefully none.
///
/// **Example:**
/// ```rust
/// ```no_run
/// # #![allow(const_err)]
/// let x = [1, 2, 3, 4];
///
/// // Bad

View file

@ -12,8 +12,10 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// repeat(1_u8).iter().collect::<Vec<_>>()
/// ```no_run
/// use std::iter;
///
/// iter::repeat(1_u8).collect::<Vec<_>>();
/// ```
pub INFINITE_ITER,
correctness,

View file

@ -13,8 +13,8 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// let bad_ref: &usize = std::mem::zeroed();
/// ```no_run
/// let bad_ref: &usize = unsafe { std::mem::zeroed() };
/// ```
pub INVALID_REF,
correctness,

View file

@ -22,7 +22,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// if x.len() == 0 {
/// ..
/// }
@ -31,7 +31,7 @@ declare_clippy_lint! {
/// }
/// ```
/// instead use
/// ```rust
/// ```ignore
/// if x.is_empty() {
/// ..
/// }
@ -57,7 +57,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// impl X {
/// pub fn len(&self) -> usize {
/// ..

View file

@ -20,7 +20,7 @@ declare_clippy_lint! {
/// **Example:**
///
/// ```rust
/// 61864918973511
/// let x: u64 = 61864918973511;
/// ```
pub UNREADABLE_LITERAL,
style,
@ -40,7 +40,7 @@ declare_clippy_lint! {
/// **Example:**
///
/// ```rust
/// 2_32
/// 2_32;
/// ```
pub MISTYPED_LITERAL_SUFFIXES,
correctness,
@ -59,7 +59,7 @@ declare_clippy_lint! {
/// **Example:**
///
/// ```rust
/// 618_64_9189_73_511
/// let x: u64 = 618_64_9189_73_511;
/// ```
pub INCONSISTENT_DIGIT_GROUPING,
style,
@ -78,7 +78,7 @@ declare_clippy_lint! {
/// **Example:**
///
/// ```rust
/// 6186491_8973511
/// let x: u64 = 6186491_8973511;
/// ```
pub LARGE_DIGIT_GROUPS,
pedantic,

View file

@ -41,7 +41,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// for i in 0..src.len() {
/// dst[i + 64] = src[i];
/// }
@ -61,7 +61,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// for i in 0..vec.len() {
/// println!("{}", vec[i]);
/// }
@ -81,7 +81,7 @@ declare_clippy_lint! {
/// types.
///
/// **Example:**
/// ```rust
/// ```ignore
/// // with `y` a `Vec` or slice:
/// for x in y.iter() {
/// ..
@ -107,14 +107,14 @@ declare_clippy_lint! {
/// **Known problems:** None
///
/// **Example:**
/// ```rust
/// ```ignore
/// // with `y` a `Vec` or slice:
/// for x in y.into_iter() {
/// ..
/// }
/// ```
/// can be rewritten to
/// ```rust
/// ```ignore
/// for x in y {
/// ..
/// }
@ -137,7 +137,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// for x in y.next() {
/// ..
/// }
@ -156,14 +156,14 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// for x in option {
/// ..
/// }
/// ```
///
/// This should be
/// ```rust
/// ```ignore
/// if let Some(x) = option {
/// ..
/// }
@ -182,14 +182,14 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// for x in result {
/// ..
/// }
/// ```
///
/// This should be
/// ```rust
/// ```ignore
/// if let Ok(x) = result {
/// ..
/// }
@ -237,7 +237,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// vec.iter().map(|x| /* some operation returning () */).collect::<Vec<_>>();
/// ```
pub UNUSED_COLLECT,
@ -256,7 +256,7 @@ declare_clippy_lint! {
/// None
///
/// **Example:**
/// ```rust
/// ```ignore
/// let len = iterator.collect::<Vec<_>>().len();
/// // should be
/// let len = iterator.count();
@ -280,7 +280,7 @@ declare_clippy_lint! {
/// paths through the program, which would be complex and error-prone.
///
/// **Example:**
/// ```rust
/// ```ignore
/// for x in 5..10 - 5 {
/// ..
/// } // oops, stray `-`
@ -301,7 +301,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// for i in 0..v.len() { foo(v[i]);
/// for i in 0..v.len() { bar(i, v[i]); }
/// ```
@ -320,7 +320,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```no_run
/// loop {}
/// ```
pub EMPTY_LOOP,
@ -337,7 +337,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// while let Some(val) = iter() {
/// ..
/// }
@ -357,7 +357,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// for (k, _) in &map {
/// ..
/// }
@ -365,7 +365,7 @@ declare_clippy_lint! {
///
/// could be replaced by
///
/// ```rust
/// ```ignore
/// for k in map.keys() {
/// ..
/// }

View file

@ -27,7 +27,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// match x {
/// Some(ref foo) => bar(foo),
/// _ => (),
@ -59,7 +59,7 @@ declare_clippy_lint! {
///
/// Using `if let` with `else`:
///
/// ```rust
/// ```ignore
/// if let Some(ref foo) = x {
/// bar(foo);
/// } else {
@ -82,7 +82,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// match x {
/// &A(ref y) => foo(y),
/// &B => bar(),
@ -103,7 +103,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// let condition: bool = true;
/// match condition {
/// true => foo(),
@ -111,7 +111,7 @@ declare_clippy_lint! {
/// }
/// ```
/// Use if/else instead:
/// ```rust
/// ```ignore
/// let condition: bool = true;
/// if condition {
/// foo();
@ -157,7 +157,7 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// let x: Result(i32, &str) = Ok(3);
/// let x: Result<i32, &str> = Ok(3);
/// match x {
/// Ok(_) => println!("ok"),
/// Err(_) => panic!("err"),

View file

@ -17,6 +17,8 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// use std::mem;
///
/// mem::discriminant(&"hello");
/// mem::discriminant(&&Some(2));
/// ```

View file

@ -17,6 +17,8 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// use std::mem;
///
/// let mut an_option = Some(0);
/// let replaced = mem::replace(&mut an_option, None);
/// ```

View file

@ -84,7 +84,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// struct X;
/// impl X {
/// fn add(&self, other: &X) -> X {
@ -116,7 +116,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// impl X {
/// fn as_str(self) -> &str {
/// ..
@ -160,7 +160,7 @@ declare_clippy_lint! {
/// **Known problems:** The error type needs to implement `Debug`
///
/// **Example:**
/// ```rust
/// ```ignore
/// x.ok().expect("why did I do this again?")
/// ```
pub OK_EXPECT,
@ -228,7 +228,7 @@ declare_clippy_lint! {
/// **Known problems:** The order of the arguments is not in execution order.
///
/// **Example:**
/// ```rust
/// ```ignore
/// opt.map_or(None, |a| a + 1)
/// ```
pub OPTION_MAP_OR_NONE,
@ -445,7 +445,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// impl Foo {
/// fn new(..) -> NotAFoo {
/// }
@ -568,13 +568,13 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// let some_vec = vec![0, 1, 2, 3];
/// let mut some_vec = vec![0, 1, 2, 3];
/// let last = some_vec.get(3).unwrap();
/// *some_vec.get_mut(0).unwrap() = 1;
/// ```
/// The correct use would be:
/// ```rust
/// let some_vec = vec![0, 1, 2, 3];
/// let mut some_vec = vec![0, 1, 2, 3];
/// let last = some_vec[3];
/// some_vec[0] = 1;
/// ```
@ -605,7 +605,7 @@ declare_clippy_lint! {
/// let def = String::from("def");
/// let mut s = String::new();
/// s.push_str(abc);
/// s.push_str(&def));
/// s.push_str(&def);
/// ```
pub STRING_EXTEND_CHARS,
style,
@ -645,7 +645,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// name.chars().last() == Some('_') || name.chars().next_back() == Some('-')
/// ```
pub CHARS_LAST_CMP,

View file

@ -15,7 +15,7 @@ declare_clippy_lint! {
/// **Known problems:** None
///
/// **Example:**
/// ```rust
/// ```ignore
/// min(0, max(100, x))
/// ```
/// It will always be equal to `0`. Probably the author meant to clamp the value

View file

@ -34,7 +34,7 @@ declare_clippy_lint! {
/// dereferences, e.g. changing `*x` to `x` within the function.
///
/// **Example:**
/// ```rust
/// ```ignore
/// fn foo(ref x: u8) -> bool {
/// ..
/// }
@ -53,7 +53,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// x == NAN
/// ```
pub CMP_NAN,
@ -74,7 +74,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// y == 1.23f64
/// y != x // where both are floats
/// ```
@ -113,7 +113,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// x % 1
/// ```
pub MODULO_ONE,
@ -130,7 +130,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// match v {
/// Some(x) => (),
/// y @ _ => (), // easier written as `y`,
@ -193,7 +193,7 @@ declare_clippy_lint! {
///
/// **Example:**
///
/// ```rust
/// ```ignore
/// 0 as *const u32
/// ```
pub ZERO_PTR,

View file

@ -18,7 +18,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// let { a: _, b: ref b, c: _ } = ..
/// ```
pub UNNEEDED_FIELD_PATTERN,
@ -71,6 +71,7 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// let mut x = 3;
/// --x;
/// ```
pub DOUBLE_NEG,
@ -159,7 +160,7 @@ declare_clippy_lint! {
///
/// **Example:**
///
/// ```rust
/// ```ignore
/// impl<u32> Foo<u32> {
/// fn impl_func(&self) -> u32 {
/// 42

View file

@ -15,7 +15,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// my_vec.push(&mut value)
/// ```
pub UNNECESSARY_MUT_PASSED,

View file

@ -15,7 +15,7 @@ declare_clippy_lint! {
/// **Known problems:** This only catches integers (for now).
///
/// **Example:**
/// ```rust
/// ```ignore
/// x * -1
/// ```
pub NEG_MULTIPLY,

View file

@ -29,7 +29,7 @@ declare_clippy_lint! {
///
/// **Example:**
///
/// ```rust
/// ```ignore
/// struct Foo(Bar);
///
/// impl Foo {
@ -41,7 +41,7 @@ declare_clippy_lint! {
///
/// Instead, use:
///
/// ```rust
/// ```ignore
/// struct Foo(Bar);
///
/// impl Default for Foo {

View file

@ -16,7 +16,7 @@ declare_clippy_lint! {
/// **Known problems:** None?
///
/// **Example:**
/// ```rust
/// ```ignore
/// let checked_exp = something;
/// let checked_expr = something_else;
/// ```
@ -35,7 +35,7 @@ declare_clippy_lint! {
/// **Known problems:** None?
///
/// **Example:**
/// ```rust
/// ```ignore
/// let (a, b, c, d, e, f, g) = (...);
/// ```
pub MANY_SINGLE_CHAR_NAMES,

View file

@ -13,7 +13,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// for result in iter {
/// if let Some(bench) = try!(result).parse().ok() {
/// vec.push(bench)
@ -22,7 +22,7 @@ declare_clippy_lint! {
/// ```
/// Could be written:
///
/// ```rust
/// ```ignore
/// for result in iter {
/// if let Ok(bench) = try!(result).parse() {
/// vec.push(bench)

View file

@ -16,7 +16,9 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// OpenOptions::new().read(true).truncate(true)
/// use std::fs::OpenOptions;
///
/// OpenOptions::new().read(true).truncate(true);
/// ```
pub NONSENSICAL_OPEN_OPTIONS,
correctness,

View file

@ -18,7 +18,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```no_run
/// panic!("This `panic!` is probably missing a parameter there: {}");
/// ```
pub PANIC_PARAMS,
@ -34,7 +34,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```no_run
/// unimplemented!();
/// ```
pub UNIMPLEMENTED,

View file

@ -41,7 +41,7 @@ declare_clippy_lint! {
/// function before applying the lint suggestions in this case.
///
/// **Example:**
/// ```rust
/// ```ignore
/// fn foo(&Vec<u32>) { .. }
/// ```
pub PTR_ARG,
@ -59,7 +59,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// if x == ptr::null {
/// ..
/// }
@ -86,7 +86,7 @@ declare_clippy_lint! {
/// case is unlikely anyway.
///
/// **Example:**
/// ```rust
/// ```ignore
/// fn foo(&Foo) -> &mut Bar { .. }
/// ```
pub MUT_FROM_REF,

View file

@ -18,7 +18,7 @@ declare_clippy_lint! {
/// **Known problems:** None
///
/// **Example:**
/// ```rust
/// ```ignore
/// if option.is_none() {
/// return None;
/// }
@ -26,7 +26,7 @@ declare_clippy_lint! {
///
/// Could be written:
///
/// ```rust
/// ```ignore
/// option?;
/// ```
pub QUESTION_MARK,

View file

@ -19,7 +19,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// for x in (5..5).step_by(0) {
/// ..
/// }

View file

@ -21,11 +21,11 @@ declare_clippy_lint! {
/// bar: u8,
/// }
///
/// let foo = Foo{ bar: bar }
/// let foo = Foo { bar: bar };
/// ```
/// the last line can be simplified to
/// ```rust
/// let foo = Foo{ bar }
/// ```ignore
/// let foo = Foo { bar };
/// ```
pub REDUNDANT_FIELD_NAMES,
style,

View file

@ -20,7 +20,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// Regex::new("|")
/// ```
pub INVALID_REGEX,
@ -39,7 +39,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// Regex::new("^foobar")
/// ```
pub TRIVIAL_REGEX,
@ -58,7 +58,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// regex!("foo|bar")
/// ```
pub REGEX_MACRO,

View file

@ -19,13 +19,13 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// fn foo(x: usize) {
/// fn foo(x: usize) -> usize {
/// return x;
/// }
/// ```
/// simplify to
/// ```rust
/// fn foo(x: usize) {
/// fn foo(x: usize) -> usize {
/// x
/// }
/// ```

View file

@ -14,7 +14,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// impl Add for Foo {
/// type Output = Foo;
///
@ -37,7 +37,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// impl AddAssign for Foo {
/// fn add_assign(&mut self, other: Foo) {
/// *self = *self - other;

View file

@ -19,7 +19,7 @@ declare_clippy_lint! {
/// sized objects in `extradata` arguments to save an allocation.
///
/// **Example:**
/// ```rust
/// ```ignore
/// let ptr: *const T = core::intrinsics::transmute('x')
/// ```
pub WRONG_TRANSMUTE,

View file

@ -509,7 +509,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// if {
/// foo();
/// } == {
@ -519,7 +519,7 @@ declare_clippy_lint! {
/// }
/// ```
/// is equal to
/// ```rust
/// ```ignore
/// {
/// foo();
/// bar();
@ -848,7 +848,7 @@ declare_clippy_lint! {
///
/// **Example**
///
/// ```rust
/// ```ignore
/// // Bad
/// fn fun() -> i32 {}
/// let a = fun as i64;
@ -1536,7 +1536,7 @@ declare_clippy_lint! {
/// like `#[cfg(target_pointer_width = "64")] ..` instead.
///
/// **Example:**
/// ```rust
/// ```ignore
/// vec.len() <= 0
/// 100 > std::i32::MAX
/// ```
@ -1961,7 +1961,7 @@ declare_clippy_lint! {
/// pieces of code, possibly including external crates.
///
/// **Example:**
/// ```rust
/// ```ignore
/// impl<K: Hash + Eq, V> Serialize for HashMap<K, V> { ... }
///
/// pub foo(map: &mut HashMap<i32, i32>) { .. }
@ -2302,7 +2302,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// fn x(r: &i32) {
/// unsafe {
/// *(r as *const _ as *mut _) += 1;
@ -2312,7 +2312,7 @@ declare_clippy_lint! {
///
/// Instead consider using interior mutability types.
///
/// ```rust
/// ```ignore
/// fn x(r: &UnsafeCell<i32>) {
/// unsafe {
/// *r.get() += 1;

View file

@ -35,11 +35,11 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// print!("Hello {}!\n", name);
/// ```
/// use println!() instead
/// ```rust
/// ```ignore
/// println!("Hello {}!", name);
/// ```
pub PRINT_WITH_NEWLINE,
@ -113,12 +113,12 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// writeln!("");
/// ```ignore
/// writeln!(buf, "");
/// ```
pub WRITELN_EMPTY_STRING,
style,
"using `writeln!(\"\")` with an empty string"
"using `writeln!(buf, \"\")` with an empty string"
}
declare_clippy_lint! {
@ -132,7 +132,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// ```ignore
/// write!(buf, "Hello {}!\n", name);
/// ```
pub WRITE_WITH_NEWLINE,
@ -151,7 +151,7 @@ declare_clippy_lint! {
/// -- e.g., `writeln!(buf, "{}", env!("FOO"))`.
///
/// **Example:**
/// ```rust
/// ```ignore
/// writeln!(buf, "{}", "foo");
/// ```
pub WRITE_LITERAL,