Skip to content

Commit afedaf6

Browse files
committed
Update doc comments to avoid lazy continuations
1 parent f3dd31e commit afedaf6

File tree

9 files changed

+24
-9
lines changed

9 files changed

+24
-9
lines changed

clippy_lints/src/casts/cast_sign_loss.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,10 @@ fn expr_add_sign(cx: &LateContext<'_>, expr: &Expr<'_>) -> Sign {
255255

256256
/// Peels binary operators such as [`BinOpKind::Mul`], [`BinOpKind::Div`] or [`BinOpKind::Rem`],
257257
/// where the result depends on:
258+
///
258259
/// - the number of negative values in the entire expression, or
259260
/// - the number of negative values on the left hand side of the expression.
261+
///
260262
/// Ignores overflow.
261263
///
262264
///
@@ -303,8 +305,10 @@ fn exprs_with_muldiv_binop_peeled<'e>(expr: &'e Expr<'_>) -> Vec<&'e Expr<'e>> {
303305
}
304306

305307
/// Peels binary operators such as [`BinOpKind::Add`], where the result depends on:
308+
///
306309
/// - all the expressions being positive, or
307310
/// - all the expressions being negative.
311+
///
308312
/// Ignores overflow.
309313
///
310314
/// Expressions using other operators are preserved, so we can try to evaluate them later.

clippy_lints/src/manual_clamp.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,15 +611,22 @@ impl<'tcx> BinaryOp<'tcx> {
611611

612612
/// The clamp meta pattern is a pattern shared between many (but not all) patterns.
613613
/// In summary, this pattern consists of two if statements that meet many criteria,
614+
///
614615
/// - binary operators that are one of [`>`, `<`, `>=`, `<=`].
616+
///
615617
/// - Both binary statements must have a shared argument
618+
///
616619
/// - Which can appear on the left or right side of either statement
620+
///
617621
/// - The binary operators must define a finite range for the shared argument. To put this in
618622
/// the terms of Rust `std` library, the following ranges are acceptable
623+
///
619624
/// - `Range`
620625
/// - `RangeInclusive`
626+
///
621627
/// And all other range types are not accepted. For the purposes of `clamp` it's irrelevant
622628
/// whether the range is inclusive or not, the output is the same.
629+
///
623630
/// - The result of each if statement must be equal to the argument unique to that if statement. The
624631
/// result can not be the shared argument in either case.
625632
fn is_clamp_meta_pattern<'tcx>(

clippy_lints/src/methods/iter_filter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ enum FilterType {
126126
///
127127
/// How this is done:
128128
/// 1. we know that this is invoked in a method call with `filter` as the method name via `mod.rs`
129-
/// 2. we check that we are in a trait method. Therefore we are in an
130-
/// `(x as Iterator).filter({filter_arg})` method call.
129+
/// 2. we check that we are in a trait method. Therefore we are in an `(x as
130+
/// Iterator).filter({filter_arg})` method call.
131131
/// 3. we check that the parent expression is not a map. This is because we don't want to lint
132132
/// twice, and we already have a specialized lint for that.
133133
/// 4. we check that the span of the filter does not contain a comment.
134134
/// 5. we get the type of the `Item` in the `Iterator`, and compare against the type of Option and
135-
/// Result.
135+
/// Result.
136136
/// 6. we finally check the contents of the filter argument to see if it is a call to `is_some` or
137-
/// `is_ok`.
137+
/// `is_ok`.
138138
/// 7. if all of the above are true, then we return the `FilterType`
139139
fn expression_type(
140140
cx: &LateContext<'_>,

clippy_lints/src/methods/iter_kv_map.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ use rustc_middle::ty;
1212
use rustc_span::{sym, Span};
1313

1414
/// lint use of:
15+
///
1516
/// - `hashmap.iter().map(|(_, v)| v)`
1617
/// - `hashmap.into_iter().map(|(_, v)| v)`
18+
///
1719
/// on `HashMaps` and `BTreeMaps` in std
1820
1921
pub(super) fn check<'tcx>(

clippy_lints/src/methods/utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ fn pat_bindings(pat: &Pat<'_>) -> Vec<HirId> {
120120
/// operations performed on `binding_hir_ids` are:
121121
/// * to take non-mutable references to them
122122
/// * to use them as non-mutable `&self` in method calls
123+
///
123124
/// If any of `binding_hir_ids` is used in any other way, then `clone_or_copy_needed` will be true
124125
/// when `CloneOrCopyVisitor` is done visiting.
125126
struct CloneOrCopyVisitor<'cx, 'tcx> {

clippy_lints/src/needless_continue.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ impl EarlyLintPass for NeedlessContinue {
178178
/// Given an expression, returns true if either of the following is true
179179
///
180180
/// - The expression is a `continue` node.
181-
/// - The expression node is a block with the first statement being a
182-
/// `continue`.
181+
/// - The expression node is a block with the first statement being a `continue`.
183182
fn needless_continue_in_else(else_expr: &ast::Expr, label: Option<&ast::Label>) -> bool {
184183
match else_expr.kind {
185184
ast::ExprKind::Block(ref else_block, _) => is_first_block_stmt_continue(else_block, label),

clippy_utils/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,15 +1513,18 @@ pub fn is_else_clause_in_let_else(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool {
15131513
}
15141514

15151515
/// Checks whether the given `Expr` is a range equivalent to a `RangeFull`.
1516+
///
15161517
/// For the lower bound, this means that:
15171518
/// - either there is none
15181519
/// - or it is the smallest value that can be represented by the range's integer type
1520+
///
15191521
/// For the upper bound, this means that:
15201522
/// - either there is none
15211523
/// - or it is the largest value that can be represented by the range's integer type and is
15221524
/// inclusive
15231525
/// - or it is a call to some container's `len` method and is exclusive, and the range is passed to
15241526
/// a method call on that same container (e.g. `v.drain(..v.len())`)
1527+
///
15251528
/// If the given `Expr` is not some kind of range, the function returns `false`.
15261529
pub fn is_range_full(cx: &LateContext<'_>, expr: &Expr<'_>, container_path: Option<&Path<'_>>) -> bool {
15271530
let ty = cx.typeck_results().expr_ty(expr);

clippy_utils/src/source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub fn snippet<'a, T: LintContext>(cx: &T, span: Span, default: &'a str) -> Cow<
250250
/// - Applicability level `Unspecified` will never be changed.
251251
/// - If the span is inside a macro, change the applicability level to `MaybeIncorrect`.
252252
/// - If the default value is used and the applicability level is `MachineApplicable`, change it to
253-
/// `HasPlaceholders`
253+
/// `HasPlaceholders`
254254
pub fn snippet_with_applicability<'a, T: LintContext>(
255255
cx: &T,
256256
span: Span,

clippy_utils/src/sugg.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ impl<'a> Sugg<'a> {
6868
/// - Applicability level `Unspecified` will never be changed.
6969
/// - If the span is inside a macro, change the applicability level to `MaybeIncorrect`.
7070
/// - If the default value is used and the applicability level is `MachineApplicable`, change it
71-
/// to
72-
/// `HasPlaceholders`
71+
/// to `HasPlaceholders`
7372
pub fn hir_with_applicability(
7473
cx: &LateContext<'_>,
7574
expr: &hir::Expr<'_>,

0 commit comments

Comments
 (0)