Dogfood tests

This commit is contained in:
Oliver Schneider 2017-04-12 10:55:34 +02:00
parent 3534149035
commit 7ee0d4f9c2
2 changed files with 16 additions and 10 deletions

View file

@ -225,6 +225,7 @@ fn with_if_expr<F>(stmt: &ast::Stmt, mut func: F)
}
/// A type to distinguish between the two distinct cases this lint handles.
#[derive(Copy, Clone, Debug)]
enum LintType {
ContinueInsideElseBlock,
ContinueInsideThenBlock,
@ -361,17 +362,18 @@ fn check_and_warn<'a>(ctx: &EarlyContext, expr: &'a ast::Expr) {
/// continues eating till a non-whitespace character is found.
/// e.g., the string
///
/// "
/// ```
/// {
/// let x = 5;
/// }
/// "
/// ```
///
/// is transformed to
///
/// "
/// ```
/// {
/// let x = 5;"
/// ```
///
/// NOTE: when there is no closing brace in `s`, `s` is _not_ preserved, i.e.,
/// an empty string will be returned in that case.
@ -391,19 +393,21 @@ pub fn erode_from_back(s: &str) -> String {
/// any number of opening braces are eaten, followed by any number of newlines.
/// e.g., the string
///
/// "
/// ```
/// {
/// something();
/// inside_a_block();
/// }
/// "
/// ```
///
/// is transformed to
///
/// " something();
/// ```
/// something();
/// inside_a_block();
/// }
/// "
///
/// ```
///
pub fn erode_from_front(s: &str) -> String {
s.chars()

View file

@ -1093,6 +1093,7 @@ pub fn align_two_snippets(s: &str, t: &str) -> String {
///
/// For example, consider
///
/// ```
/// let s1 = "\
/// if (condition()) {
/// do_something()";
@ -1103,18 +1104,19 @@ pub fn align_two_snippets(s: &str, t: &str) -> String {
/// let s3 = "\
/// another_piece_of_code();
/// indented_here();";
///
/// ```
///
///
///
/// Now calling `align_snippets(&[s1, s2, s3])` will yield the following:
///
/// "\
/// ```
/// if (condition()) {
/// do_something();
/// code_from_somewhere_else();
/// another_piece_of_code();
/// indented_here();"
/// indented_here();
/// ```
pub fn align_snippets(xs: &[&str]) -> String {
if xs.is_empty() {
String::from("")