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

Doctests: Enable running doc tests for restriction lints #4331

Merged
merged 1 commit into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions clippy_lints/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// a + 1
/// # let a = 0;
/// a + 1;
/// ```
pub INTEGER_ARITHMETIC,
restriction,
Expand All @@ -33,7 +34,8 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// a + 1.0
/// # let a = 0.0;
/// a + 1.0;
/// ```
pub FLOAT_ARITHMETIC,
restriction,
Expand Down
6 changes: 6 additions & 0 deletions clippy_lints/src/else_if_without_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/indexing_slicing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ declare_clippy_lint! {
/// **Known problems:** Hopefully none.
///
/// **Example:**
/// ```rust
/// ```rust,no_run
/// // Vector
/// let x = vec![0; 5];
///
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 } => {
Expand Down
2 changes: 2 additions & 0 deletions clippy_lints/src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// # enum Foo { A(usize), B(usize) }
/// # let x = Foo::B(1);
/// match x {
/// A => {},
/// _ => {},
Expand Down
2 changes: 2 additions & 0 deletions clippy_lints/src/mem_forget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// # use std::mem;
/// # use std::rc::Rc;
/// mem::forget(Rc::new(55))
/// ```
pub MEM_FORGET,
Expand Down
36 changes: 30 additions & 6 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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"
/// }
/// }
/// ```
Expand Down Expand Up @@ -467,7 +489,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,
Expand Down
5 changes: 3 additions & 2 deletions clippy_lints/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/missing_inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ declare_clippy_lint! {
///
/// struct Baz;
/// impl Baz {
/// fn priv() {} // ok
/// fn private() {} // ok
/// }
///
/// impl Bar for Baz {
Expand All @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions clippy_lints/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// # let x = 1;
/// let x = &x;
/// ```
pub SHADOW_SAME,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ declare_clippy_lint! {
///
/// ```rust
/// let x = "Hello".to_owned();
/// x + ", World"
/// x + ", World";
/// ```
pub STRING_ADD,
restriction,
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// # let foo = "bar";
/// println!("{:?}", foo);
/// ```
pub USE_DEBUG,
Expand Down