Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run more doc tests #3865

Merged
merged 1 commit into from Mar 12, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+103 −52
Diff settings

Always

Just for now

@@ -37,8 +37,9 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// if (x & 1 == 2) { … }
/// ```rust
/// # let x = 1;
/// if (x & 1 == 2) { }
/// ```
pub BAD_BIT_MASK,
correctness,
@@ -65,8 +66,9 @@ declare_clippy_lint! {
/// uncommon).
///
/// **Example:**
/// ```ignore
/// if (x | 1 > 3) { … }
/// ```rust
/// # let x = 1;
/// if (x | 1 > 3) { }
/// ```
pub INEFFECTIVE_BIT_MASK,
correctness,
@@ -83,8 +85,9 @@ declare_clippy_lint! {
/// **Known problems:** llvm generates better code for `x & 15 == 0` on x86
///
/// **Example:**
/// ```ignore
/// x & 0x1111 == 0
/// ```rust
/// # let x = 1;
/// if x & 0x1111 == 0 { }
/// ```
pub VERBOSE_BIT_MASK,
style,
@@ -19,8 +19,9 @@ declare_clippy_lint! {
/// calls. We may introduce a whitelist of known pure functions in the future.
///
/// **Example:**
/// ```ignore
/// x + 1 == x + 1
/// ```rust
/// # let x = 1;
/// if x + 1 == x + 1 {}
/// ```
pub EQ_OP,
correctness,
@@ -27,7 +27,9 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// ```rust
/// # fn bar(stool: &str) {}
/// # let x = Some("abc");
/// match x {
/// Some(ref foo) => bar(foo),
/// _ => (),
@@ -59,7 +61,7 @@ declare_clippy_lint! {
///
/// Using `if let` with `else`:
///
/// ```ignore
/// ```rust
/// if let Some(ref foo) = x {
/// bar(foo);
/// } else {
@@ -82,7 +84,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// ```rust,ignore
/// match x {
/// &A(ref y) => foo(y),
/// &B => bar(),
@@ -103,15 +105,19 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// ```rust
/// # fn foo() {}
/// # fn bar() {}
/// let condition: bool = true;
/// match condition {
/// true => foo(),
/// false => bar(),
/// }
/// ```
/// Use if/else instead:
/// ```ignore
/// ```rust
/// # fn foo() {}
/// # fn bar() {}
/// let condition: bool = true;
/// if condition {
/// foo();
@@ -54,8 +54,11 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// x == NAN
/// ```rust
/// # use core::f32::NAN;
/// # let x = 1.0;
///
/// if x == NAN { }
/// ```
pub CMP_NAN,
correctness,
@@ -75,9 +78,11 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// y == 1.23f64
/// y != x // where both are floats
/// ```rust
/// let x = 1.2331f64;
/// let y = 1.2332f64;
/// if y == 1.23f64 { }
/// if y != x {} // where both are floats
/// ```
pub FLOAT_CMP,
correctness,
@@ -114,8 +119,9 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// x % 1
/// ```rust
/// # let x = 1;
/// let a = x % 1;
/// ```
pub MODULO_ONE,
correctness,
@@ -131,7 +137,9 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// ```rust
/// # let v = Some("abc");
///
/// match v {
/// Some(x) => (),
/// y @ _ => (), // easier written as `y`,
@@ -194,8 +202,8 @@ declare_clippy_lint! {
///
/// **Example:**
///
/// ```ignore
/// 0 as *const u32
/// ```rust
/// let a = 0 as *const u32;
/// ```
pub ZERO_PTR,
style,
@@ -2,9 +2,12 @@
//!
//! For example, the lint would catch
//!
//! ```ignore
//! while condition() {
//! update_condition();
//! ```rust
//! let mut a = 1;
//! let x = true;
//!
//! while a < 5 {
//! a = 6;
//! if x {
//! // ...
//! } else {
@@ -16,9 +19,12 @@
//!
//! And suggest something like this:
//!
//! ```ignore
//! while condition() {
//! update_condition();
//! ```rust
//! let mut a = 1;
//! let x = true;
//!
//! while a < 5 {
//! a = 6;
//! if x {
//! // ...
//! println!("Hello, world");
@@ -374,7 +380,7 @@ fn check_and_warn<'a>(ctx: &EarlyContext<'_>, expr: &'a ast::Expr) {
/// continues eating till a non-whitespace character is found.
/// e.g., the string
///
/// ```
/// ```rust
/// {
/// let x = 5;
/// }
@@ -19,7 +19,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust,ignore
/// ```rust
/// let t = b;
/// b = a;
/// a = t;
@@ -41,7 +41,9 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```rust,ignore
/// ```rust
/// # let mut a = 1;
/// # let mut b = 2;
/// a = b;
/// b = a;
/// ```
@@ -511,7 +511,10 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// ```rust
/// # fn foo() {};
/// # fn bar() {};
/// # fn baz() {};
/// if {
/// foo();
/// } == {
@@ -521,7 +524,10 @@ declare_clippy_lint! {
/// }
/// ```
/// is equal to
/// ```ignore
/// ```rust
/// # fn foo() {};
/// # fn bar() {};
/// # fn baz() {};
/// {
/// foo();
/// bar();
@@ -850,13 +856,13 @@ declare_clippy_lint! {
///
/// **Example**
///
/// ```ignore
/// ```rust
/// // Bad
/// fn fun() -> i32 {}
/// fn fun() -> i32 { 1 }
/// let a = fun as i64;
///
/// // Good
/// fn fun2() -> i32 {}
/// fn fun2() -> i32 { 1 }
/// let a = fun2 as usize;
/// ```
pub FN_TO_NUMERIC_CAST,
@@ -1538,9 +1544,11 @@ declare_clippy_lint! {
/// like `#[cfg(target_pointer_width = "64")] ..` instead.
///
/// **Example:**
/// ```rust,ignore
/// vec.len() <= 0
/// 100 > std::i32::MAX
///
/// ```rust
/// let vec: Vec<isize> = vec![];
/// if vec.len() <= 0 {}
/// if 100 > std::i32::MAX {}
/// ```
pub ABSURD_EXTREME_COMPARISONS,
correctness,
@@ -1963,10 +1971,13 @@ declare_clippy_lint! {
/// pieces of code, possibly including external crates.
///
/// **Example:**
/// ```ignore
/// impl<K: Hash + Eq, V> Serialize for HashMap<K, V> { ... }
/// ```rust
/// # use std::collections::HashMap;
/// # use std::hash::Hash;
/// # trait Serialize {};
/// impl<K: Hash + Eq, V> Serialize for HashMap<K, V> { }
///
/// pub foo(map: &mut HashMap<i32, i32>) { .. }
/// pub fn foo(map: &mut HashMap<i32, i32>) { }
/// ```
pub IMPLICIT_HASHER,
style,
@@ -2304,7 +2315,7 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// ```rust,ignore
/// fn x(r: &i32) {
/// unsafe {
/// *(r as *const _ as *mut _) += 1;
@@ -2314,7 +2325,9 @@ declare_clippy_lint! {
///
/// Instead consider using interior mutability types.
///
/// ```ignore
/// ```rust
/// use std::cell::UnsafeCell;
///
/// fn x(r: &UnsafeCell<i32>) {
/// unsafe {
/// *r.get() += 1;
@@ -35,11 +35,13 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// ```rust
/// # let name = "World";
/// print!("Hello {}!\n", name);
/// ```
/// use println!() instead
/// ```ignore
/// ```rust
/// # let name = "World";
/// println!("Hello {}!", name);
/// ```
pub PRINT_WITH_NEWLINE,
@@ -113,7 +115,9 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// ```rust
/// # use std::fmt::Write;
/// # let mut buf = String::new();
/// writeln!(buf, "");
/// ```
pub WRITELN_EMPTY_STRING,
@@ -132,7 +136,10 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// ```rust
/// # use std::fmt::Write;
/// # let mut buf = String::new();
/// # let name = "World";
/// write!(buf, "Hello {}!\n", name);
/// ```
pub WRITE_WITH_NEWLINE,
@@ -151,7 +158,9 @@ declare_clippy_lint! {
/// -- e.g., `writeln!(buf, "{}", env!("FOO"))`.
///
/// **Example:**
/// ```ignore
/// ```rust
/// # use std::fmt::Write;
/// # let mut buf = String::new();
/// writeln!(buf, "{}", "foo");
/// ```
pub WRITE_LITERAL,
@@ -259,8 +268,11 @@ impl EarlyLintPass for Pass {
/// Example:
///
/// Calling this function on
/// ```rust,ignore
/// writeln!(buf, "string to write: {}", something)
/// ```rust
/// # use std::fmt::Write;
/// # let mut buf = String::new();
/// # let something = "something";
/// writeln!(buf, "string to write: {}", something);
/// ```
/// will return
/// ```rust,ignore
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.