Expand description
Contains utility functions to generate suggestions.
Re-exportsΒ§
use crate::source::snippet;πuse crate::source::snippet_opt;πuse crate::source::snippet_with_applicability;πuse crate::source::snippet_with_context;πuse crate::ty::expr_sig;πuse crate::get_parent_expr_for_hir;πuse crate::higher;πuse rustc_ast::util::parser::AssocOp;πuse rustc_ast::UnOp;πuse rustc_ast::ast;πuse rustc_data_structures::fx::FxHashSet;πuse rustc_errors::Applicability;πuse rustc_hir as hir;πuse rustc_hir::Closure;πuse rustc_hir::ExprKind;πuse rustc_hir::HirId;πuse rustc_hir::MatchSource;πuse rustc_hir::Node;πuse rustc_hir::TyKind;πuse rustc_hir_typeck::expr_use_visitor::Delegate;πuse rustc_hir_typeck::expr_use_visitor::ExprUseVisitor;πuse rustc_hir_typeck::expr_use_visitor::PlaceBase;πuse rustc_hir_typeck::expr_use_visitor::PlaceWithHirId;πuse rustc_lint::EarlyContext;πuse rustc_lint::LateContext;πuse rustc_lint::LintContext;πuse rustc_middle::hir::place::ProjectionKind;πuse rustc_middle::mir::FakeReadCause;πuse rustc_middle::mir::Mutability;πuse rustc_middle::ty;πuse rustc_span::BytePos;πuse rustc_span::CharPos;πuse rustc_span::Pos as _;πuse rustc_span::Span;πuse rustc_span::SyntaxContext;πuse std::borrow::Cow;πuse std::fmt;πuse std::fmt::Display;πuse std::fmt::Write as _;πuse std::ops::Add;πuse std::ops::Neg;πuse std::ops::Not;πuse std::ops::Sub;π
MacrosΒ§
- forward_
binop_ πimpls_ to_ ref - Copied from the rust standard library, and then edited
StructsΒ§
- Deref
Closure - 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 either
fooor(foo).
EnumsΒ§
- Associativity π
- Operator associativity.
- Sugg
- A helper type to build suggestion correctly handling parentheses.
ConstantsΒ§
- EMPTY
- a constant represents an empty string, for convenience.
- ONE
- Literal constant
1, for convenience. - ZERO
- Literal constant
0, for convenience.
TraitsΒ§
- DiagExt
- Convenience extension trait for
Diag.
FunctionsΒ§
- associativity π
- Returns the associativity/fixity of an operator. The difference with
AssocOp::fixityis that an operator can be both left and right associative (such as+:a + b + c == (a + b) + c == a + (b + c). - binop_
to_ πstring - Generates a string from the operator and both sides.
- deref_
closure_ args - Build suggestion gradually by handling closure arg specific usages,
such as explicit deref and borrowing cases.
Returns
Noneif no such use cases have been triggered in closure body - has_
enclosing_ paren - Returns
trueifsuggis enclosed in parenthesis. - indentation π
- Returns the indentation before
spanif there are nothing but[ \t]before it on its line. - make_
assoc - Builds the string for
<lhs> <op> <rhs>adding parenthesis when necessary. - make_
binop - Convenience wrapper around
make_assocandAssocOp::Binary. - make_
unop - Builds the string for
<op><expr>adding parenthesis when necessary. - strip_
enclosing_ πparen - Strip enclosing parentheses from a snippet if present.