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
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -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 } => {
@@ -205,6 +205,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"
/// }
/// }
/// ```
@@ -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,
@@ -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,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.