mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Rollup merge of #4331 - phansch:doctests_restriction, r=flip1995
Doctests: Enable running doc tests for restriction lints changelog: Enabled remaining doc tests for lint documentation page master: 202 passed; 0 failed; 122 ignored; 0 measured; 0 filtered out this PR: 231 passed; 0 failed; 123 ignored; 0 measured; 0 filtered out Closes #4319 (assuming this is merged after #4329 and #4330)
This commit is contained in:
commit
93c3da223f
12 changed files with 57 additions and 16 deletions
|
@ -16,7 +16,8 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// a + 1
|
||||
/// # let a = 0;
|
||||
/// a + 1;
|
||||
/// ```
|
||||
pub INTEGER_ARITHMETIC,
|
||||
restriction,
|
||||
|
@ -33,7 +34,8 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// a + 1.0
|
||||
/// # let a = 0.0;
|
||||
/// a + 1.0;
|
||||
/// ```
|
||||
pub FLOAT_ARITHMETIC,
|
||||
restriction,
|
||||
|
|
|
@ -16,6 +16,9 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// # fn a() {}
|
||||
/// # fn b() {}
|
||||
/// # let x: i32 = 1;
|
||||
/// if x.is_positive() {
|
||||
/// a();
|
||||
/// } else if x.is_negative() {
|
||||
|
@ -26,6 +29,9 @@ declare_clippy_lint! {
|
|||
/// Could be written:
|
||||
///
|
||||
/// ```rust
|
||||
/// # fn a() {}
|
||||
/// # fn b() {}
|
||||
/// # let x: i32 = 1;
|
||||
/// if x.is_positive() {
|
||||
/// a();
|
||||
/// } else if x.is_negative() {
|
||||
|
|
|
@ -47,7 +47,7 @@ declare_clippy_lint! {
|
|||
/// **Known problems:** Hopefully none.
|
||||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// ```rust,no_run
|
||||
/// // Vector
|
||||
/// let x = vec![0; 5];
|
||||
///
|
||||
|
|
|
@ -115,7 +115,7 @@ macro_rules! declare_clippy_lint {
|
|||
};
|
||||
{ $(#[$attr:meta])* pub $name:tt, restriction, $description:tt } => {
|
||||
declare_tool_lint! {
|
||||
pub clippy::$name, Allow, $description, report_in_external_macro: true
|
||||
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
|
||||
}
|
||||
};
|
||||
{ $(#[$attr:meta])* pub $name:tt, cargo, $description:tt } => {
|
||||
|
|
|
@ -211,6 +211,8 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// # enum Foo { A(usize), B(usize) }
|
||||
/// # let x = Foo::B(1);
|
||||
/// match x {
|
||||
/// A => {},
|
||||
/// _ => {},
|
||||
|
|
|
@ -14,6 +14,8 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// # use std::mem;
|
||||
/// # use std::rc::Rc;
|
||||
/// mem::forget(Rc::new(55))
|
||||
/// ```
|
||||
pub MEM_FORGET,
|
||||
|
|
|
@ -40,8 +40,19 @@ declare_clippy_lint! {
|
|||
/// **Known problems:** None.
|
||||
///
|
||||
/// **Example:**
|
||||
///
|
||||
/// Using unwrap on an `Option`:
|
||||
///
|
||||
/// ```rust
|
||||
/// x.unwrap()
|
||||
/// let opt = Some(1);
|
||||
/// opt.unwrap();
|
||||
/// ```
|
||||
///
|
||||
/// Better:
|
||||
///
|
||||
/// ```rust
|
||||
/// let opt = Some(1);
|
||||
/// opt.expect("more helpful message");
|
||||
/// ```
|
||||
pub OPTION_UNWRAP_USED,
|
||||
restriction,
|
||||
|
@ -62,8 +73,18 @@ declare_clippy_lint! {
|
|||
/// **Known problems:** None.
|
||||
///
|
||||
/// **Example:**
|
||||
/// Using unwrap on an `Option`:
|
||||
///
|
||||
/// ```rust
|
||||
/// x.unwrap()
|
||||
/// let res: Result<usize, ()> = Ok(1);
|
||||
/// res.unwrap();
|
||||
/// ```
|
||||
///
|
||||
/// Better:
|
||||
///
|
||||
/// ```rust
|
||||
/// let res: Result<usize, ()> = Ok(1);
|
||||
/// res.expect("more helpful message");
|
||||
/// ```
|
||||
pub RESULT_UNWRAP_USED,
|
||||
restriction,
|
||||
|
@ -141,9 +162,10 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// impl X {
|
||||
/// pub fn as_str(self) -> &str {
|
||||
/// ..
|
||||
/// # struct X;
|
||||
/// impl<'a> X {
|
||||
/// pub fn as_str(self) -> &'a str {
|
||||
/// "foo"
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
|
@ -474,7 +496,9 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// x.clone()
|
||||
/// # use std::rc::Rc;
|
||||
/// let x = Rc::new(1);
|
||||
/// x.clone();
|
||||
/// ```
|
||||
pub CLONE_ON_REF_PTR,
|
||||
restriction,
|
||||
|
|
|
@ -226,8 +226,9 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// const ONE = 1.00f64;
|
||||
/// x == ONE // where both are floats
|
||||
/// let x: f64 = 1.0;
|
||||
/// const ONE: f64 = 1.00;
|
||||
/// x == ONE; // where both are floats
|
||||
/// ```
|
||||
pub FLOAT_CMP_CONST,
|
||||
restriction,
|
||||
|
|
|
@ -33,7 +33,7 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// struct Baz;
|
||||
/// impl Baz {
|
||||
/// fn priv() {} // ok
|
||||
/// fn private() {} // ok
|
||||
/// }
|
||||
///
|
||||
/// impl Bar for Baz {
|
||||
|
@ -42,8 +42,8 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// pub struct PubBaz;
|
||||
/// impl PubBaz {
|
||||
/// fn priv() {} // ok
|
||||
/// pub not_ptriv() {} // missing #[inline]
|
||||
/// fn private() {} // ok
|
||||
/// pub fn not_ptrivate() {} // missing #[inline]
|
||||
/// }
|
||||
///
|
||||
/// impl Bar for PubBaz {
|
||||
|
|
|
@ -20,6 +20,7 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// # let x = 1;
|
||||
/// let x = &x;
|
||||
/// ```
|
||||
pub SHADOW_SAME,
|
||||
|
@ -41,10 +42,12 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// let x = 2;
|
||||
/// let x = x + 1;
|
||||
/// ```
|
||||
/// use different variable name:
|
||||
/// ```rust
|
||||
/// let x = 2;
|
||||
/// let y = x + 1;
|
||||
/// ```
|
||||
pub SHADOW_REUSE,
|
||||
|
|
|
@ -48,7 +48,7 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// ```rust
|
||||
/// let x = "Hello".to_owned();
|
||||
/// x + ", World"
|
||||
/// x + ", World";
|
||||
/// ```
|
||||
pub STRING_ADD,
|
||||
restriction,
|
||||
|
|
|
@ -77,6 +77,7 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// # let foo = "bar";
|
||||
/// println!("{:?}", foo);
|
||||
/// ```
|
||||
pub USE_DEBUG,
|
||||
|
|
Loading…
Reference in a new issue