rustfmt fallout in doc comments

This commit is contained in:
Oliver Schneider 2016-12-21 10:00:13 +01:00
parent 44533f09aa
commit 299d7be132
No known key found for this signature in database
GPG Key ID: 56D6EEA0FC67AC46
3 changed files with 27 additions and 23 deletions

View File

@ -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();

View File

@ -35,23 +35,27 @@ pub type MethodArgs = HirVec<P<Expr>>;
/// 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<Name> {
/// Convert a span to a code snippet if available, otherwise use default.
///
/// # Example
/// ```
/// ```rust,ignore
/// snippet(cx, expr.span, "..")
/// ```
pub fn snippet<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
@ -388,7 +392,7 @@ pub fn snippet_opt<'a, T: LintContext<'a>>(cx: &T, span: Span) -> Option<String>
/// things which need to be printed as such.
///
/// # Example
/// ```
/// ```rust,ignore
/// snippet(cx, expr.span, "..")
/// ```
pub fn snippet_block<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {

View File

@ -398,7 +398,7 @@ pub trait DiagnosticBuilderExt<'a, T: LintContext<'a>> {
///
/// # Example
///
/// ```rust
/// ```rust,ignore
/// db.suggest_item_with_attr(cx, item, "#[derive(Default)]");
/// ```
fn suggest_item_with_attr<D: Display + ?Sized>(&mut self, cx: &T, item: Span, msg: &str, attr: &D);
@ -409,7 +409,7 @@ pub trait DiagnosticBuilderExt<'a, T: LintContext<'a>> {
///
/// # Example
///
/// ```rust
/// ```rust,ignore
/// db.suggest_prepend_item(cx, item,
/// "fn foo() {
/// bar();