mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Spelling
* applying * binding * complex * constituent * demonstrate * desugaring * exact * expression * for * functionalities * github * implementation * infers * multiple conflicting traits * mutable * necessarily * nightly * nonexistent * optional * parameter * reassignments * resources * substitution * suggestion * that * that array is * using the Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
This commit is contained in:
parent
d9c2957221
commit
d2061faf9e
@ -139,7 +139,7 @@ whether the pattern matched.
|
||||
|
||||
## Pattern syntax
|
||||
|
||||
The following examples demonstate the pattern syntax:
|
||||
The following examples demonstrate the pattern syntax:
|
||||
|
||||
|
||||
#### Any (`_`)
|
||||
|
@ -638,7 +638,7 @@ declare_clippy_lint! {
|
||||
#[clippy::version = "1.66.0"]
|
||||
pub AS_PTR_CAST_MUT,
|
||||
nursery,
|
||||
"casting the result of the `&self`-taking `as_ptr` to a mutabe pointer"
|
||||
"casting the result of the `&self`-taking `as_ptr` to a mutable pointer"
|
||||
}
|
||||
|
||||
declare_clippy_lint! {
|
||||
|
@ -591,7 +591,7 @@ fn lint_same_cond(cx: &LateContext<'_>, conds: &[&Expr<'_>], ignored_ty_ids: &De
|
||||
conds,
|
||||
|e| hash_expr(cx, e),
|
||||
|lhs, rhs| {
|
||||
// Ignore eq_expr side effects iff one of the expressin kind is a method call
|
||||
// Ignore eq_expr side effects iff one of the expression kind is a method call
|
||||
// and the caller is not a mutable, including inner mutable type.
|
||||
if let ExprKind::MethodCall(_, caller, _, _) = lhs.kind {
|
||||
if method_caller_is_mutable(cx, caller, ignored_ty_ids) {
|
||||
|
@ -10,7 +10,7 @@ use rustc_span::source_map::Span;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
/// Checks for usage of the non-existent `=*`, `=!` and `=-`
|
||||
/// Checks for usage of the nonexistent `=*`, `=!` and `=-`
|
||||
/// operators.
|
||||
///
|
||||
/// ### Why is this bad?
|
||||
|
@ -94,7 +94,7 @@ impl<'tcx> LateLintPass<'tcx> for FromOverInto {
|
||||
);
|
||||
}
|
||||
|
||||
let message = format!("replace the `Into` implentation with `From<{}>`", middle_trait_ref.self_ty());
|
||||
let message = format!("replace the `Into` implementation with `From<{}>`", middle_trait_ref.self_ty());
|
||||
if let Some(suggestions) = convert_to_from(cx, into_trait_seg, target_ty, self_ty, impl_item_ref) {
|
||||
diag.multipart_suggestion(message, suggestions, Applicability::MachineApplicable);
|
||||
} else {
|
||||
|
@ -40,7 +40,7 @@ pub fn check_fn(cx: &LateContext<'_>, kind: FnKind<'_>, decl: &FnDecl<'_>, body:
|
||||
};
|
||||
|
||||
// Body must be &(mut) <self_data>.name
|
||||
// self_data is not neccessarilly self, to also lint sub-getters, etc…
|
||||
// self_data is not necessarily self, to also lint sub-getters, etc…
|
||||
|
||||
let block_expr = if_chain! {
|
||||
if let ExprKind::Block(block,_) = body.value.kind;
|
||||
|
@ -330,7 +330,7 @@ declare_clippy_lint! {
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
/// Lints when `impl Trait` is being used in a function's paremeters.
|
||||
/// Lints when `impl Trait` is being used in a function's parameters.
|
||||
/// ### Why is this bad?
|
||||
/// Turbofish syntax (`::<>`) cannot be used when `impl Trait` is being used, making `impl Trait` less powerful. Readability may also be a factor.
|
||||
///
|
||||
|
@ -11,7 +11,7 @@ declare_clippy_lint! {
|
||||
/// It checks for the size of a `Future` created by `async fn` or `async {}`.
|
||||
///
|
||||
/// ### Why is this bad?
|
||||
/// Due to the current [unideal implemention](https://github.com/rust-lang/rust/issues/69826) of `Generator`,
|
||||
/// Due to the current [unideal implementation](https://github.com/rust-lang/rust/issues/69826) of `Generator`,
|
||||
/// large size of a `Future` may cause stack overflows.
|
||||
///
|
||||
/// ### Example
|
||||
|
@ -15,7 +15,7 @@ use rustc_span::symbol::sym;
|
||||
use std::fmt::Display;
|
||||
use std::iter::Iterator;
|
||||
|
||||
/// Checks for for loops that sequentially copy items from one slice-like
|
||||
/// Checks for `for` loops that sequentially copy items from one slice-like
|
||||
/// object to another.
|
||||
pub(super) fn check<'tcx>(
|
||||
cx: &LateContext<'tcx>,
|
||||
|
@ -64,7 +64,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualAssert {
|
||||
};
|
||||
let cond_sugg = sugg::Sugg::hir_with_applicability(cx, cond, "..", &mut applicability).maybe_par();
|
||||
let sugg = format!("assert!({not}{cond_sugg}, {format_args_snip});");
|
||||
// we show to the user the suggestion without the comments, but when applicating the fix, include the comments in the block
|
||||
// we show to the user the suggestion without the comments, but when applying the fix, include the comments in the block
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
MANUAL_ASSERT,
|
||||
|
@ -101,7 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualLetElse {
|
||||
if source != MatchSource::Normal {
|
||||
return;
|
||||
}
|
||||
// Any other number than two arms doesn't (neccessarily)
|
||||
// Any other number than two arms doesn't (necessarily)
|
||||
// have a trivial mapping to let else.
|
||||
if arms.len() != 2 {
|
||||
return;
|
||||
|
@ -46,7 +46,7 @@ declare_clippy_lint! {
|
||||
#[clippy::version = "1.64.0"]
|
||||
pub MANUAL_RETAIN,
|
||||
perf,
|
||||
"`retain()` is simpler and the same functionalitys"
|
||||
"`retain()` is simpler and the same functionalities"
|
||||
}
|
||||
|
||||
pub struct ManualRetain {
|
||||
|
@ -12,7 +12,7 @@ declare_clippy_lint! {
|
||||
/// Checks if a provided method is used implicitly by a trait
|
||||
/// implementation. A usage example would be a wrapper where every method
|
||||
/// should perform some operation before delegating to the inner type's
|
||||
/// implemenation.
|
||||
/// implementation.
|
||||
///
|
||||
/// This lint should typically be enabled on a specific trait `impl` item
|
||||
/// rather than globally.
|
||||
|
@ -74,7 +74,7 @@ enum InitializationType<'tcx> {
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for SlowVectorInit {
|
||||
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
// Matches initialization on reassignements. For example: `vec = Vec::with_capacity(100)`
|
||||
// Matches initialization on reassignments. For example: `vec = Vec::with_capacity(100)`
|
||||
if_chain! {
|
||||
if let ExprKind::Assign(left, right, _) = expr.kind;
|
||||
|
||||
|
@ -60,7 +60,7 @@ fn is_struct_with_trailing_zero_sized_array(cx: &LateContext<'_>, item: &Item<'_
|
||||
if let Some(last_field) = data.fields().last();
|
||||
if let rustc_hir::TyKind::Array(_, rustc_hir::ArrayLen::Body(length)) = last_field.ty.kind;
|
||||
|
||||
// Then check if that that array zero-sized
|
||||
// Then check if that array is zero-sized
|
||||
let length = Const::from_anon_const(cx.tcx, length.def_id);
|
||||
let length = length.try_eval_target_usize(cx.tcx, cx.param_env);
|
||||
if let Some(length) = length;
|
||||
|
@ -90,8 +90,8 @@ declare_clippy_lint! {
|
||||
///
|
||||
/// ### Why is this bad?
|
||||
/// `Option<_>` represents an optional value. `Option<Option<_>>`
|
||||
/// represents an optional optional value which is logically the same thing as an optional
|
||||
/// value but has an unneeded extra level of wrapping.
|
||||
/// represents an optional value which itself wraps an optional. This is logically the
|
||||
/// same thing as an optional value but has an unneeded extra level of wrapping.
|
||||
///
|
||||
/// If you have a case where `Some(Some(_))`, `Some(None)` and `None` are distinct cases,
|
||||
/// consider a custom `enum` instead, with clear names for each case.
|
||||
|
@ -102,7 +102,7 @@ impl LateLintPass<'_> for UnnecessaryBoxReturns {
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'_>, item: &rustc_hir::ImplItem<'_>) {
|
||||
// Ignore implementations of traits, because the lint should be on the
|
||||
// trait, not on the implmentation of it.
|
||||
// trait, not on the implementation of it.
|
||||
let Node::Item(parent) = cx.tcx.hir().get_parent(item.hir_id()) else { return };
|
||||
let ItemKind::Impl(parent) = parent.kind else { return };
|
||||
if parent.of_trait.is_some() {
|
||||
|
@ -93,7 +93,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
|
||||
for &(predicate, _span) in cx.tcx.explicit_item_bounds(def_id) {
|
||||
match predicate.kind().skip_binder() {
|
||||
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
|
||||
// and check substituions to find `U`.
|
||||
// and check substitutions to find `U`.
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) => {
|
||||
if trait_predicate
|
||||
.trait_ref
|
||||
@ -1101,7 +1101,7 @@ pub fn make_projection<'tcx>(
|
||||
///
|
||||
/// This function is for associated types which are "known" to be valid with the given
|
||||
/// substitutions, and as such, will only return `None` when debug assertions are disabled in order
|
||||
/// to prevent ICE's. With debug assertions enabled this will check that that type normalization
|
||||
/// to prevent ICE's. With debug assertions enabled this will check that type normalization
|
||||
/// succeeds as well as everything checked by `make_projection`.
|
||||
pub fn make_normalized_projection<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -421,7 +421,7 @@ impl Crate {
|
||||
{
|
||||
let subcrate = &stderr[63..];
|
||||
println!(
|
||||
"ERROR: failed to apply some suggetion to {} / to (sub)crate {subcrate}",
|
||||
"ERROR: failed to apply some suggestion to {} / to (sub)crate {subcrate}",
|
||||
self.name
|
||||
);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ pub fn rename_my_lifetimes(_args: TokenStream, input: TokenStream) -> TokenStrea
|
||||
elided += 1;
|
||||
|
||||
// HACK: Syn uses `Span` from the proc_macro2 crate, and does not seem to reexport it.
|
||||
// In order to avoid adding the dependency, get a default span from a non-existent token.
|
||||
// In order to avoid adding the dependency, get a default span from a nonexistent token.
|
||||
// A default span is needed to mark the code as coming from expansion.
|
||||
let span = Star::default().span();
|
||||
|
||||
|
@ -23,7 +23,7 @@ fn main() {
|
||||
r_x as *const [i32]
|
||||
} as *const [u8];
|
||||
|
||||
// Check that resores of the same size are detected through blocks
|
||||
// Check that resources of the same size are detected through blocks
|
||||
let restore_block_1 = { r_x as *const [i32] } as *const [u8] as *const [u32];
|
||||
let restore_block_2 = { ({ r_x as *const [i32] }) as *const [u8] } as *const [u32];
|
||||
let restore_block_3 = {
|
||||
|
@ -5,7 +5,7 @@ LL | impl Into<StringWrapper> for String {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::from-over-into` implied by `-D warnings`
|
||||
help: replace the `Into` implentation with `From<std::string::String>`
|
||||
help: replace the `Into` implementation with `From<std::string::String>`
|
||||
|
|
||||
LL ~ impl From<String> for StringWrapper {
|
||||
LL ~ fn from(val: String) -> Self {
|
||||
@ -18,7 +18,7 @@ error: an implementation of `From` is preferred since it gives you `Into<_>` for
|
||||
LL | impl Into<SelfType> for String {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: replace the `Into` implentation with `From<std::string::String>`
|
||||
help: replace the `Into` implementation with `From<std::string::String>`
|
||||
|
|
||||
LL ~ impl From<String> for SelfType {
|
||||
LL ~ fn from(val: String) -> Self {
|
||||
@ -31,7 +31,7 @@ error: an implementation of `From` is preferred since it gives you `Into<_>` for
|
||||
LL | impl Into<SelfKeywords> for X {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: replace the `Into` implentation with `From<X>`
|
||||
help: replace the `Into` implementation with `From<X>`
|
||||
|
|
||||
LL ~ impl From<X> for SelfKeywords {
|
||||
LL ~ fn from(val: X) -> Self {
|
||||
@ -48,7 +48,7 @@ LL | impl core::convert::Into<bool> for crate::ExplicitPaths {
|
||||
|
|
||||
= help: `impl From<Local> for Foreign` is allowed by the orphan rules, for more information see
|
||||
https://doc.rust-lang.org/reference/items/implementations.html#trait-implementation-coherence
|
||||
help: replace the `Into` implentation with `From<ExplicitPaths>`
|
||||
help: replace the `Into` implementation with `From<ExplicitPaths>`
|
||||
|
|
||||
LL ~ impl core::convert::From<crate::ExplicitPaths> for bool {
|
||||
LL ~ fn from(mut val: crate::ExplicitPaths) -> Self {
|
||||
@ -64,7 +64,7 @@ error: an implementation of `From` is preferred since it gives you `Into<_>` for
|
||||
LL | impl<T> Into<FromOverInto<T>> for Vec<T> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: replace the `Into` implentation with `From<std::vec::Vec<T>>`
|
||||
help: replace the `Into` implementation with `From<std::vec::Vec<T>>`
|
||||
|
|
||||
LL ~ impl<T> From<Vec<T>> for FromOverInto<T> {
|
||||
LL ~ fn from(val: Vec<T>) -> Self {
|
||||
|
@ -4,7 +4,7 @@ error: an implementation of `From` is preferred since it gives you `Into<_>` for
|
||||
LL | impl Into<InMacro> for String {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: replace the `Into` implentation with `From<std::string::String>`
|
||||
= help: replace the `Into` implementation with `From<std::string::String>`
|
||||
= note: `-D clippy::from-over-into` implied by `-D warnings`
|
||||
|
||||
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
|
||||
@ -13,7 +13,7 @@ error: an implementation of `From` is preferred since it gives you `Into<_>` for
|
||||
LL | impl Into<WeirdUpperSelf> for &'static [u8] {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: replace the `Into` implentation with `From<&'static [u8]>`
|
||||
= help: replace the `Into` implementation with `From<&'static [u8]>`
|
||||
|
||||
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
|
||||
--> $DIR/from_over_into_unfixable.rs:28:1
|
||||
@ -23,7 +23,7 @@ LL | impl Into<u8> for ContainsVal {
|
||||
|
|
||||
= help: `impl From<Local> for Foreign` is allowed by the orphan rules, for more information see
|
||||
https://doc.rust-lang.org/reference/items/implementations.html#trait-implementation-coherence
|
||||
= help: replace the `Into` implentation with `From<ContainsVal>`
|
||||
= help: replace the `Into` implementation with `From<ContainsVal>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
@ -12,7 +12,7 @@ fn main() {
|
||||
let _: _ = 2;
|
||||
let x: _ = func();
|
||||
|
||||
let x = 1; // Will not lint, Rust inferres this to an integer before Clippy
|
||||
let x = 1; // Will not lint, Rust infers this to an integer before Clippy
|
||||
let x = func();
|
||||
let x: Vec<_> = Vec::<u32>::new();
|
||||
let x: [_; 1] = [1];
|
||||
|
@ -23,8 +23,8 @@ fn main() {
|
||||
}
|
||||
|
||||
fn binary_heap_retain() {
|
||||
// NOTE: Do not lint now, because binary_heap_retain is nighyly API.
|
||||
// And we need to add a test case for msrv if we update this implmention.
|
||||
// NOTE: Do not lint now, because binary_heap_retain is nightly API.
|
||||
// And we need to add a test case for msrv if we update this implementation.
|
||||
// https://github.com/rust-lang/rust/issues/71503
|
||||
let mut heap = BinaryHeap::from([1, 2, 3]);
|
||||
heap = heap.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
|
@ -23,8 +23,8 @@ fn main() {
|
||||
}
|
||||
|
||||
fn binary_heap_retain() {
|
||||
// NOTE: Do not lint now, because binary_heap_retain is nighyly API.
|
||||
// And we need to add a test case for msrv if we update this implmention.
|
||||
// NOTE: Do not lint now, because binary_heap_retain is nightly API.
|
||||
// And we need to add a test case for msrv if we update this implementation.
|
||||
// https://github.com/rust-lang/rust/issues/71503
|
||||
let mut heap = BinaryHeap::from([1, 2, 3]);
|
||||
heap = heap.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
|
@ -110,7 +110,7 @@ fn should_not_lint() {
|
||||
}),
|
||||
}
|
||||
|
||||
// `for_each` is in a let bingind.
|
||||
// `for_each` is in a let binding.
|
||||
let _ = v.iter().for_each(|elem| {
|
||||
acc += elem;
|
||||
});
|
||||
|
@ -110,7 +110,7 @@ fn should_not_lint() {
|
||||
}),
|
||||
}
|
||||
|
||||
// `for_each` is in a let bingind.
|
||||
// `for_each` is in a let binding.
|
||||
let _ = v.iter().for_each(|elem| {
|
||||
acc += elem;
|
||||
});
|
||||
|
@ -25,7 +25,7 @@ fn rust_abi_multiline_function_really_long_name_to_overflow_args_to_multiple_lin
|
||||
0
|
||||
}
|
||||
|
||||
// Must not run on functions that explicitly opt in to Rust ABI with `extern "Rust"`
|
||||
// Must not run on functions that explicitly opt in to using the Rust ABI with `extern "Rust"`
|
||||
#[no_mangle]
|
||||
#[rustfmt::skip]
|
||||
extern "Rust" fn rust_abi_fn_explicit_opt_in(arg_one: u32, arg_two: usize) {}
|
||||
|
@ -97,7 +97,7 @@ enum DummyEnum {
|
||||
Two,
|
||||
}
|
||||
|
||||
// should not warn since there is a compled complex subpat
|
||||
// should not warn since there is a complex subpat
|
||||
// see #7991
|
||||
fn complex_subpat() -> DummyEnum {
|
||||
let x = Some(DummyEnum::One(1));
|
||||
|
@ -120,7 +120,7 @@ enum DummyEnum {
|
||||
Two,
|
||||
}
|
||||
|
||||
// should not warn since there is a compled complex subpat
|
||||
// should not warn since there is a complex subpat
|
||||
// see #7991
|
||||
fn complex_subpat() -> DummyEnum {
|
||||
let x = Some(DummyEnum::One(1));
|
||||
|
@ -62,7 +62,7 @@ mod should_lint {
|
||||
impl T1 for S {}
|
||||
}
|
||||
|
||||
mod multiply_conflicit_trait {
|
||||
mod multiple_conflicting_traits {
|
||||
use crate::{T1, T2};
|
||||
|
||||
struct S;
|
||||
|
@ -144,7 +144,7 @@ struct ReprCAlign {
|
||||
|
||||
// NOTE: because of https://doc.rust-lang.org/stable/reference/type-layout.html#primitive-representation-of-enums-with-fields and I'm not sure when in the compilation pipeline that would happen
|
||||
#[repr(C)]
|
||||
enum DontLintAnonymousStructsFromDesuraging {
|
||||
enum DontLintAnonymousStructsFromDesugaring {
|
||||
A(u32),
|
||||
B(f32, [u64; 0]),
|
||||
C { x: u32, y: [u64; 0] },
|
||||
|
@ -17,10 +17,10 @@ fn main() {
|
||||
// This is OK, because `MaybeUninit` allows uninitialized data.
|
||||
let _: MaybeUninit<usize> = unsafe { MaybeUninit::uninit().assume_init() };
|
||||
|
||||
// This is OK, because all constitutent types are uninit-compatible.
|
||||
// This is OK, because all constituent types are uninit-compatible.
|
||||
let _: (MaybeUninit<usize>, MaybeUninit<bool>) = unsafe { MaybeUninit::uninit().assume_init() };
|
||||
|
||||
// This is OK, because all constitutent types are uninit-compatible.
|
||||
// This is OK, because all constituent types are uninit-compatible.
|
||||
let _: (MaybeUninit<usize>, [MaybeUninit<bool>; 2]) = unsafe { MaybeUninit::uninit().assume_init() };
|
||||
|
||||
// This is OK, because our own MaybeUninit is just as fine as the one from core.
|
||||
|
@ -564,7 +564,7 @@ Otherwise, have a great day =^.^=
|
||||
</div>
|
||||
|
||||
<a href="https://github.com/rust-lang/rust-clippy">
|
||||
<img style="position: absolute; top: 0; right: 0; border: 0; clip-path: polygon(0% 0%, 100% 0%, 100% 100%);" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on Github"/>
|
||||
<img style="position: absolute; top: 0; right: 0; border: 0; clip-path: polygon(0% 0%, 100% 0%, 100% 100%);" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"/>
|
||||
</a>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/12.3.2/markdown-it.min.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user