Module clippy_utils::sugg
source Β· Expand description
Contains utility functions to generate suggestions.
Macros§
- Copied from the rust standard library, and then edited
Structs§
- Suggestion results for handling closure args dereferencing and borrowing
- Deref
Delegate πVisitor struct used for tracking down dereferencing and borrowing of closureβs args - Paren
Helper πHelper type to display eitherfoo
or(foo)
.
Enums§
- Associativity πOperator associativity.
- A helper type to build suggestion correctly handling parentheses.
Constants§
- a constant represents an empty string, for convenience.
- Literal constant
1
, for convenience. - Literal constant
0
, for convenience.
Traits§
- Convenience extension trait for
Diag
.
Functions§
- associativity πReturns the associativity/fixity of an operator. The difference with
AssocOp::fixity
is that an operator can be both left and right associative (such as+
:a + b + c == (a + b) + c == a + (b + c)
. - astbinop2assignop πConverts an
ast::BinOp
to the corresponding assigning binary operator. - binop_
to_ πstring Generates a string from the operator and both sides. - Build suggestion gradually by handling closure arg specific usages, such as explicit deref and borrowing cases. Returns
None
if no such use cases have been triggered in closure body - Returns
true
ifsugg
is enclosed in parenthesis. - hirbinop2assignop πConverts a
hir::BinOp
to the corresponding assigning binary operator. - indentation πReturns the indentation before
span
if there are nothing but[ \t]
before it on its line. - Builds the string for
<lhs> <op> <rhs>
adding parenthesis when necessary. - Convenience wrapper around
make_assoc
andAssocOp::from_ast_binop
. - Builds the string for
<op><expr>
adding parenthesis when necessary.