mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-21 04:03:11 +00:00
Fix typos
This commit is contained in:
parent
c7bf05c1a4
commit
885a18207f
@ -174,7 +174,7 @@ The maximum amount of nesting a block can reside in
|
|||||||
|
|
||||||
## `disallowed-names`
|
## `disallowed-names`
|
||||||
The list of disallowed names to lint about. NB: `bar` is not here since it has legitimate uses. The value
|
The list of disallowed names to lint about. NB: `bar` is not here since it has legitimate uses. The value
|
||||||
`".."` can be used as part of the list to indicate, that the configured values should be appended to the
|
`".."` can be used as part of the list to indicate that the configured values should be appended to the
|
||||||
default configuration of Clippy. By default, any configuration will replace the default value.
|
default configuration of Clippy. By default, any configuration will replace the default value.
|
||||||
|
|
||||||
**Default Value:** `["foo", "baz", "quux"]` (`Vec<String>`)
|
**Default Value:** `["foo", "baz", "quux"]` (`Vec<String>`)
|
||||||
|
@ -11,7 +11,8 @@ use rustc_span::symbol::sym;
|
|||||||
use super::MAP_UNWRAP_OR;
|
use super::MAP_UNWRAP_OR;
|
||||||
|
|
||||||
/// lint use of `map().unwrap_or_else()` for `Option`s and `Result`s
|
/// lint use of `map().unwrap_or_else()` for `Option`s and `Result`s
|
||||||
/// Return true if lint triggered
|
///
|
||||||
|
/// Returns true if the lint was emitted
|
||||||
pub(super) fn check<'tcx>(
|
pub(super) fn check<'tcx>(
|
||||||
cx: &LateContext<'tcx>,
|
cx: &LateContext<'tcx>,
|
||||||
expr: &'tcx hir::Expr<'_>,
|
expr: &'tcx hir::Expr<'_>,
|
||||||
|
@ -25,7 +25,7 @@ declare_clippy_lint! {
|
|||||||
/// ### Example
|
/// ### Example
|
||||||
/// ```rust,ignore
|
/// ```rust,ignore
|
||||||
/// for m in movies {
|
/// for m in movies {
|
||||||
/// let title = m.t;
|
/// let title = m.t;
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
/// Use instead:
|
/// Use instead:
|
||||||
|
@ -51,7 +51,7 @@ impl EarlyLintPass for NeedlessElse {
|
|||||||
cx,
|
cx,
|
||||||
NEEDLESS_ELSE,
|
NEEDLESS_ELSE,
|
||||||
span,
|
span,
|
||||||
"this else branch is empty",
|
"this `else` branch is empty",
|
||||||
"you can remove it",
|
"you can remove it",
|
||||||
String::new(),
|
String::new(),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
|
@ -319,7 +319,7 @@ define_Conf! {
|
|||||||
/// Lint: DISALLOWED_NAMES.
|
/// Lint: DISALLOWED_NAMES.
|
||||||
///
|
///
|
||||||
/// The list of disallowed names to lint about. NB: `bar` is not here since it has legitimate uses. The value
|
/// The list of disallowed names to lint about. NB: `bar` is not here since it has legitimate uses. The value
|
||||||
/// `".."` can be used as part of the list to indicate, that the configured values should be appended to the
|
/// `".."` can be used as part of the list to indicate that the configured values should be appended to the
|
||||||
/// default configuration of Clippy. By default, any configuration will replace the default value.
|
/// default configuration of Clippy. By default, any configuration will replace the default value.
|
||||||
(disallowed_names: Vec<String> = super::DEFAULT_DISALLOWED_NAMES.iter().map(ToString::to_string).collect()),
|
(disallowed_names: Vec<String> = super::DEFAULT_DISALLOWED_NAMES.iter().map(ToString::to_string).collect()),
|
||||||
/// Lint: SEMICOLON_INSIDE_BLOCK.
|
/// Lint: SEMICOLON_INSIDE_BLOCK.
|
||||||
|
@ -143,13 +143,13 @@ pub fn get_unique_attr<'a>(
|
|||||||
unique_attr
|
unique_attr
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if the attributes contain any of `proc_macro`,
|
/// Returns true if the attributes contain any of `proc_macro`,
|
||||||
/// `proc_macro_derive` or `proc_macro_attribute`, false otherwise
|
/// `proc_macro_derive` or `proc_macro_attribute`, false otherwise
|
||||||
pub fn is_proc_macro(attrs: &[ast::Attribute]) -> bool {
|
pub fn is_proc_macro(attrs: &[ast::Attribute]) -> bool {
|
||||||
attrs.iter().any(rustc_ast::Attribute::is_proc_macro_attr)
|
attrs.iter().any(rustc_ast::Attribute::is_proc_macro_attr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if the attributes contain `#[doc(hidden)]`
|
/// Returns true if the attributes contain `#[doc(hidden)]`
|
||||||
pub fn is_doc_hidden(attrs: &[ast::Attribute]) -> bool {
|
pub fn is_doc_hidden(attrs: &[ast::Attribute]) -> bool {
|
||||||
attrs
|
attrs
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -339,7 +339,7 @@ fn ty_search_pat(ty: &Ty<'_>) -> (Pat, Pat) {
|
|||||||
TyKind::Tup(..) => (Pat::Str("("), Pat::Str(")")),
|
TyKind::Tup(..) => (Pat::Str("("), Pat::Str(")")),
|
||||||
TyKind::OpaqueDef(..) => (Pat::Str("impl"), Pat::Str("")),
|
TyKind::OpaqueDef(..) => (Pat::Str("impl"), Pat::Str("")),
|
||||||
TyKind::Path(qpath) => qpath_search_pat(&qpath),
|
TyKind::Path(qpath) => qpath_search_pat(&qpath),
|
||||||
// NOTE: This is missing `TraitObject`. It always return true then.
|
// NOTE: This is missing `TraitObject`. It will always return true then.
|
||||||
_ => (Pat::Str(""), Pat::Str("")),
|
_ => (Pat::Str(""), Pat::Str("")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
//! Utility functions about comparison operators.
|
//! Utility functions for comparison operators.
|
||||||
|
|
||||||
#![deny(clippy::missing_docs_in_private_items)]
|
#![deny(clippy::missing_docs_in_private_items)]
|
||||||
|
|
||||||
use rustc_hir::{BinOpKind, Expr};
|
use rustc_hir::{BinOpKind, Expr};
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
|
||||||
/// Represent a normalized comparison operator.
|
/// Represents a normalized comparison operator.
|
||||||
pub enum Rel {
|
pub enum Rel {
|
||||||
/// `<`
|
/// `<`
|
||||||
Lt,
|
Lt,
|
||||||
|
@ -267,7 +267,7 @@ pub fn constant_with_source<'tcx>(
|
|||||||
res.map(|x| (x, ctxt.source))
|
res.map(|x| (x, ctxt.source))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to evaluate an expression only if it's value is not dependent on other items.
|
/// Attempts to evaluate an expression only if its value is not dependent on other items.
|
||||||
pub fn constant_simple<'tcx>(
|
pub fn constant_simple<'tcx>(
|
||||||
lcx: &LateContext<'tcx>,
|
lcx: &LateContext<'tcx>,
|
||||||
typeck_results: &ty::TypeckResults<'tcx>,
|
typeck_results: &ty::TypeckResults<'tcx>,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! Utilities for evaluating whether eagerly evaluated expressions can be made lazy and vice versa.
|
//! Utilities for evaluating whether eagerly evaluated expressions can be made lazy and vice versa.
|
||||||
//!
|
//!
|
||||||
//! Things to consider:
|
//! Things to consider:
|
||||||
//! - has the expression side-effects?
|
//! - does the expression have side-effects?
|
||||||
//! - is the expression computationally expensive?
|
//! - is the expression computationally expensive?
|
||||||
//!
|
//!
|
||||||
//! See lints:
|
//! See lints:
|
||||||
|
@ -13,7 +13,7 @@ use rustc_lint::LateContext;
|
|||||||
use rustc_span::{sym, symbol, Span};
|
use rustc_span::{sym, symbol, Span};
|
||||||
|
|
||||||
/// The essential nodes of a desugared for loop as well as the entire span:
|
/// The essential nodes of a desugared for loop as well as the entire span:
|
||||||
/// `for pat in arg { body }` becomes `(pat, arg, body)`. Return `(pat, arg, body, span)`.
|
/// `for pat in arg { body }` becomes `(pat, arg, body)`. Returns `(pat, arg, body, span)`.
|
||||||
pub struct ForLoop<'tcx> {
|
pub struct ForLoop<'tcx> {
|
||||||
/// `for` loop item
|
/// `for` loop item
|
||||||
pub pat: &'tcx hir::Pat<'tcx>,
|
pub pat: &'tcx hir::Pat<'tcx>,
|
||||||
@ -264,7 +264,7 @@ impl<'a> Range<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represent the pre-expansion arguments of a `vec!` invocation.
|
/// Represents the pre-expansion arguments of a `vec!` invocation.
|
||||||
pub enum VecArgs<'a> {
|
pub enum VecArgs<'a> {
|
||||||
/// `vec![elem; len]`
|
/// `vec![elem; len]`
|
||||||
Repeat(&'a hir::Expr<'a>, &'a hir::Expr<'a>),
|
Repeat(&'a hir::Expr<'a>, &'a hir::Expr<'a>),
|
||||||
@ -398,7 +398,7 @@ impl<'hir> WhileLet<'hir> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a hir binary operator to the corresponding `ast` type.
|
/// Converts a `hir` binary operator to the corresponding `ast` type.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn binop(op: hir::BinOpKind) -> ast::BinOpKind {
|
pub fn binop(op: hir::BinOpKind) -> ast::BinOpKind {
|
||||||
match op {
|
match op {
|
||||||
@ -436,7 +436,7 @@ pub enum VecInitKind {
|
|||||||
WithExprCapacity(HirId),
|
WithExprCapacity(HirId),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if given expression is an initialization of `Vec` and returns its kind.
|
/// Checks if the given expression is an initialization of `Vec` and returns its kind.
|
||||||
pub fn get_vec_init_kind<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<VecInitKind> {
|
pub fn get_vec_init_kind<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<VecInitKind> {
|
||||||
if let ExprKind::Call(func, args) = expr.kind {
|
if let ExprKind::Call(func, args) = expr.kind {
|
||||||
match func.kind {
|
match func.kind {
|
||||||
|
@ -823,7 +823,7 @@ fn is_default_equivalent_ctor(cx: &LateContext<'_>, def_id: DefId, path: &QPath<
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if the expr is equal to `Default::default` when evaluated.
|
/// Returns true if the expr is equal to `Default::default` when evaluated.
|
||||||
pub fn is_default_equivalent_call(cx: &LateContext<'_>, repl_func: &Expr<'_>) -> bool {
|
pub fn is_default_equivalent_call(cx: &LateContext<'_>, repl_func: &Expr<'_>) -> bool {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if let hir::ExprKind::Path(ref repl_func_qpath) = repl_func.kind;
|
if let hir::ExprKind::Path(ref repl_func_qpath) = repl_func.kind;
|
||||||
@ -2527,7 +2527,8 @@ pub fn span_contains_comment(sm: &SourceMap, span: Span) -> bool {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return all the comments a given span contains
|
/// Returns all the comments a given span contains
|
||||||
|
///
|
||||||
/// Comments are returned wrapped with their relevant delimiters
|
/// Comments are returned wrapped with their relevant delimiters
|
||||||
pub fn span_extract_comment(sm: &SourceMap, span: Span) -> String {
|
pub fn span_extract_comment(sm: &SourceMap, span: Span) -> String {
|
||||||
let snippet = sm.span_to_snippet(span).unwrap_or_default();
|
let snippet = sm.span_to_snippet(span).unwrap_or_default();
|
||||||
|
@ -395,7 +395,7 @@ fn binop_to_string(op: AssocOp, lhs: &str, rhs: &str) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return `true` if `sugg` is enclosed in parenthesis.
|
/// Returns `true` if `sugg` is enclosed in parenthesis.
|
||||||
pub fn has_enclosing_paren(sugg: impl AsRef<str>) -> bool {
|
pub fn has_enclosing_paren(sugg: impl AsRef<str>) -> bool {
|
||||||
let mut chars = sugg.as_ref().chars();
|
let mut chars = sugg.as_ref().chars();
|
||||||
if chars.next() == Some('(') {
|
if chars.next() == Some('(') {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
error: this else branch is empty
|
error: this `else` branch is empty
|
||||||
--> $DIR/needless_else.rs:24:7
|
--> $DIR/needless_else.rs:24:7
|
||||||
|
|
|
|
||||||
LL | } else {
|
LL | } else {
|
||||||
|
Loading…
Reference in New Issue
Block a user