diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index 83b87dc74b0..85bd419df73 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -2,7 +2,7 @@ //! //! For example, the lint would catch: //! -//! ```rust +//! ```rust,ignore //! if x { //! if y { //! println!("Hello world"); @@ -28,7 +28,7 @@ use utils::sugg::Sugg; /// **Known problems:** None. /// /// **Example:** -/// ```rust +/// ```rust,ignore /// if x { /// if y { /// … @@ -48,7 +48,7 @@ use utils::sugg::Sugg; /// /// Should be written: /// -/// ```rust +/// ```rust.ignore /// if x && y { /// … /// } @@ -140,7 +140,7 @@ fn check_collapsible_no_if_let(cx: &EarlyContext, expr: &ast::Expr, check: &ast: }} } -/// If the block contains only one expression, returns it. +/// If the block contains only one expression, return it. fn expr_block(block: &ast::Block) -> Option<&ast::Expr> { let mut it = block.stmts.iter(); diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index e56574c9ba9..f31ce3706eb 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -35,23 +35,27 @@ pub type MethodArgs = HirVec
>;
/// Produce a nested chain of if-lets and ifs from the patterns:
///
-/// if_let_chain! {[
-/// let Some(y) = x,
-/// y.len() == 2,
-/// let Some(z) = y,
-/// ], {
-/// block
-/// }}
+/// ```rust,ignore
+/// if_let_chain! {[
+/// let Some(y) = x,
+/// y.len() == 2,
+/// let Some(z) = y,
+/// ], {
+/// block
+/// }}
+/// ```
///
/// becomes
///
-/// if let Some(y) = x {
-/// if y.len() == 2 {
-/// if let Some(z) = y {
-/// block
-/// }
+/// ```rust,ignore
+/// if let Some(y) = x {
+/// if y.len() == 2 {
+/// if let Some(z) = y {
+/// block
/// }
/// }
+/// }
+/// ```
#[macro_export]
macro_rules! if_let_chain {
([let $pat:pat = $expr:expr, $($tt:tt)+], $block:block) => {
@@ -135,7 +139,7 @@ pub fn in_external_macro<'a, T: LintContext<'a>>(cx: &T, span: Span) -> bool {
/// Check if a `DefId`'s path matches the given absolute type path usage.
///
/// # Examples
-/// ```
+/// ```rust,ignore
/// match_def_path(cx, id, &["core", "option", "Option"])
/// ```
///
@@ -229,7 +233,7 @@ pub fn single_segment_path(path: &QPath) -> Option<&PathSegment> {
/// Match a `Path` against a slice of segment string literals.
///
/// # Examples
-/// ```
+/// ```rust,ignore
/// match_path(path, &["std", "rt", "begin_unwind"])
/// ```
pub fn match_path(path: &QPath, segments: &[&str]) -> bool {
@@ -254,7 +258,7 @@ pub fn match_path_old(path: &Path, segments: &[&str]) -> bool {
/// Match a `Path` against a slice of segment string literals, e.g.
///
/// # Examples
-/// ```
+/// ```rust,ignore
/// match_path(path, &["std", "rt", "begin_unwind"])
/// ```
pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool {
@@ -371,7 +375,7 @@ pub fn get_item_name(cx: &LateContext, expr: &Expr) -> Option