Rollup merge of #128110 - veera-sivarajan:bugfix-80173, r=cjgillot
Suggest Replacing Comma with Semicolon in Incorrect Repeat Expressions Fixes #80173 This PR detects typos in repeat expressions like `["_", 10]` and `vec![String::new(), 10]` and suggests replacing comma with semicolon. Also, improves code in other place by adding doc comments and making use of a helper function to check if a type implements `Clone`. References: 1. For `vec![T; N]`: https://doc.rust-lang.org/std/macro.vec.html 2. For `[T; N]`: https://doc.rust-lang.org/std/primitive.array.html
This commit is contained in:
commit
e4e2d9ceb8
9 changed files with 324 additions and 11 deletions
|
@ -27,7 +27,7 @@ use crate::infer::canonical::Canonical;
|
|||
use crate::ty::InferTy::*;
|
||||
use crate::ty::{
|
||||
self, AdtDef, BoundRegionKind, Discr, GenericArg, GenericArgs, GenericArgsRef, List, ParamEnv,
|
||||
Region, Ty, TyCtxt, TypeFlags, TypeSuperVisitable, TypeVisitable, TypeVisitor,
|
||||
Region, Ty, TyCtxt, TypeFlags, TypeSuperVisitable, TypeVisitable, TypeVisitor, UintTy,
|
||||
};
|
||||
|
||||
// Re-export and re-parameterize some `I = TyCtxt<'tcx>` types here
|
||||
|
@ -1017,6 +1017,18 @@ impl<'tcx> Ty<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Check if type is an `usize`.
|
||||
#[inline]
|
||||
pub fn is_usize(self) -> bool {
|
||||
matches!(self.kind(), Uint(UintTy::Usize))
|
||||
}
|
||||
|
||||
/// Check if type is an `usize` or an integral type variable.
|
||||
#[inline]
|
||||
pub fn is_usize_like(self) -> bool {
|
||||
matches!(self.kind(), Uint(UintTy::Usize) | Infer(IntVar(_)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_never(self) -> bool {
|
||||
matches!(self.kind(), Never)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue