mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
avoid converting types into themselves via .into() (clippy::useless-conversion)
example: let x: String = String::from("hello world").into();
This commit is contained in:
parent
83e6940efb
commit
966c23f529
24 changed files with 56 additions and 61 deletions
|
@ -203,7 +203,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
|
|||
let diagnostic = IncorrectCase {
|
||||
file: fn_src.file_id,
|
||||
ident_type: IdentType::Function,
|
||||
ident: AstPtr::new(&ast_ptr).into(),
|
||||
ident: AstPtr::new(&ast_ptr),
|
||||
expected_case: replacement.expected_case,
|
||||
ident_text: replacement.current_name.to_string(),
|
||||
suggested_text: replacement.suggested_text,
|
||||
|
@ -261,7 +261,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
|
|||
let diagnostic = IncorrectCase {
|
||||
file: fn_src.file_id,
|
||||
ident_type: IdentType::Argument,
|
||||
ident: AstPtr::new(&ast_ptr).into(),
|
||||
ident: AstPtr::new(&ast_ptr),
|
||||
expected_case: param_to_rename.expected_case,
|
||||
ident_text: param_to_rename.current_name.to_string(),
|
||||
suggested_text: param_to_rename.suggested_text,
|
||||
|
@ -313,7 +313,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
|
|||
let diagnostic = IncorrectCase {
|
||||
file: source_ptr.file_id,
|
||||
ident_type: IdentType::Variable,
|
||||
ident: AstPtr::new(&name_ast).into(),
|
||||
ident: AstPtr::new(&name_ast),
|
||||
expected_case: replacement.expected_case,
|
||||
ident_text: replacement.current_name.to_string(),
|
||||
suggested_text: replacement.suggested_text,
|
||||
|
@ -403,7 +403,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
|
|||
let diagnostic = IncorrectCase {
|
||||
file: struct_src.file_id,
|
||||
ident_type: IdentType::Structure,
|
||||
ident: AstPtr::new(&ast_ptr).into(),
|
||||
ident: AstPtr::new(&ast_ptr),
|
||||
expected_case: replacement.expected_case,
|
||||
ident_text: replacement.current_name.to_string(),
|
||||
suggested_text: replacement.suggested_text,
|
||||
|
@ -448,7 +448,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
|
|||
let diagnostic = IncorrectCase {
|
||||
file: struct_src.file_id,
|
||||
ident_type: IdentType::Field,
|
||||
ident: AstPtr::new(&ast_ptr).into(),
|
||||
ident: AstPtr::new(&ast_ptr),
|
||||
expected_case: field_to_rename.expected_case,
|
||||
ident_text: field_to_rename.current_name.to_string(),
|
||||
suggested_text: field_to_rename.suggested_text,
|
||||
|
@ -527,7 +527,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
|
|||
let diagnostic = IncorrectCase {
|
||||
file: enum_src.file_id,
|
||||
ident_type: IdentType::Enum,
|
||||
ident: AstPtr::new(&ast_ptr).into(),
|
||||
ident: AstPtr::new(&ast_ptr),
|
||||
expected_case: replacement.expected_case,
|
||||
ident_text: replacement.current_name.to_string(),
|
||||
suggested_text: replacement.suggested_text,
|
||||
|
@ -572,7 +572,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
|
|||
let diagnostic = IncorrectCase {
|
||||
file: enum_src.file_id,
|
||||
ident_type: IdentType::Variant,
|
||||
ident: AstPtr::new(&ast_ptr).into(),
|
||||
ident: AstPtr::new(&ast_ptr),
|
||||
expected_case: variant_to_rename.expected_case,
|
||||
ident_text: variant_to_rename.current_name.to_string(),
|
||||
suggested_text: variant_to_rename.suggested_text,
|
||||
|
@ -617,7 +617,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
|
|||
let diagnostic = IncorrectCase {
|
||||
file: const_src.file_id,
|
||||
ident_type: IdentType::Constant,
|
||||
ident: AstPtr::new(&ast_ptr).into(),
|
||||
ident: AstPtr::new(&ast_ptr),
|
||||
expected_case: replacement.expected_case,
|
||||
ident_text: replacement.current_name.to_string(),
|
||||
suggested_text: replacement.suggested_text,
|
||||
|
@ -665,7 +665,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
|
|||
let diagnostic = IncorrectCase {
|
||||
file: static_src.file_id,
|
||||
ident_type: IdentType::StaticVariable,
|
||||
ident: AstPtr::new(&ast_ptr).into(),
|
||||
ident: AstPtr::new(&ast_ptr),
|
||||
expected_case: replacement.expected_case,
|
||||
ident_text: replacement.current_name.to_string(),
|
||||
suggested_text: replacement.suggested_text,
|
||||
|
|
|
@ -44,7 +44,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) {
|
||||
self.check_for_filter_map_next(db);
|
||||
|
||||
let body = db.body(self.owner.into());
|
||||
let body = db.body(self.owner);
|
||||
|
||||
for (id, expr) in body.exprs.iter() {
|
||||
if let Some((variant_def, missed_fields, true)) =
|
||||
|
@ -98,7 +98,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
missed_fields: Vec<LocalFieldId>,
|
||||
) {
|
||||
// XXX: only look at source_map if we do have missing fields
|
||||
let (_, source_map) = db.body_with_source_map(self.owner.into());
|
||||
let (_, source_map) = db.body_with_source_map(self.owner);
|
||||
|
||||
if let Ok(source_ptr) = source_map.expr_syntax(id) {
|
||||
let root = source_ptr.file_syntax(db.upcast());
|
||||
|
@ -128,7 +128,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
missed_fields: Vec<LocalFieldId>,
|
||||
) {
|
||||
// XXX: only look at source_map if we do have missing fields
|
||||
let (_, source_map) = db.body_with_source_map(self.owner.into());
|
||||
let (_, source_map) = db.body_with_source_map(self.owner);
|
||||
|
||||
if let Ok(source_ptr) = source_map.pat_syntax(id) {
|
||||
if let Some(expr) = source_ptr.value.as_ref().left() {
|
||||
|
@ -175,7 +175,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
};
|
||||
|
||||
// Search function body for instances of .filter_map(..).next()
|
||||
let body = db.body(self.owner.into());
|
||||
let body = db.body(self.owner);
|
||||
let mut prev = None;
|
||||
for (id, expr) in body.exprs.iter() {
|
||||
if let Expr::MethodCall { receiver, .. } = expr {
|
||||
|
@ -192,7 +192,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
if function_id == *next_function_id {
|
||||
if let Some(filter_map_id) = prev {
|
||||
if *receiver == filter_map_id {
|
||||
let (_, source_map) = db.body_with_source_map(self.owner.into());
|
||||
let (_, source_map) = db.body_with_source_map(self.owner);
|
||||
if let Ok(next_source_ptr) = source_map.expr_syntax(id) {
|
||||
self.sink.push(ReplaceFilterMapNextWithFindMap {
|
||||
file: next_source_ptr.file_id,
|
||||
|
@ -262,7 +262,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
let mut arg_count = args.len();
|
||||
|
||||
if arg_count != param_count {
|
||||
let (_, source_map) = db.body_with_source_map(self.owner.into());
|
||||
let (_, source_map) = db.body_with_source_map(self.owner);
|
||||
if let Ok(source_ptr) = source_map.expr_syntax(call_id) {
|
||||
if is_method_call {
|
||||
param_count -= 1;
|
||||
|
@ -287,7 +287,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
infer: Arc<InferenceResult>,
|
||||
) {
|
||||
let (body, source_map): (Arc<Body>, Arc<BodySourceMap>) =
|
||||
db.body_with_source_map(self.owner.into());
|
||||
db.body_with_source_map(self.owner);
|
||||
|
||||
let match_expr_ty = if infer.type_of_expr[match_expr].is_unknown() {
|
||||
return;
|
||||
|
@ -393,7 +393,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
};
|
||||
|
||||
if params.len() > 0 && params[0] == mismatch.actual {
|
||||
let (_, source_map) = db.body_with_source_map(self.owner.into());
|
||||
let (_, source_map) = db.body_with_source_map(self.owner);
|
||||
|
||||
if let Ok(source_ptr) = source_map.expr_syntax(id) {
|
||||
self.sink.push(MissingOkOrSomeInTailExpr {
|
||||
|
@ -425,7 +425,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
return;
|
||||
}
|
||||
|
||||
let (_, source_map) = db.body_with_source_map(self.owner.into());
|
||||
let (_, source_map) = db.body_with_source_map(self.owner);
|
||||
|
||||
if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) {
|
||||
self.sink
|
||||
|
|
|
@ -29,7 +29,7 @@ impl<'a, 'b> UnsafeValidator<'a, 'b> {
|
|||
}
|
||||
|
||||
pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) {
|
||||
let def = self.owner.into();
|
||||
let def = self.owner;
|
||||
let unsafe_expressions = unsafe_expressions(db, self.infer.as_ref(), def);
|
||||
let is_unsafe = match self.owner {
|
||||
DefWithBodyId::FunctionId(it) => db.function_data(it).qualifier.is_unsafe,
|
||||
|
|
|
@ -52,7 +52,7 @@ impl ToChalk for Ty {
|
|||
|
||||
TyKind::Tuple(cardinality, substs) => {
|
||||
let substitution = substs.to_chalk(db);
|
||||
chalk_ir::TyKind::Tuple(cardinality.into(), substitution).intern(&Interner)
|
||||
chalk_ir::TyKind::Tuple(cardinality, substitution).intern(&Interner)
|
||||
}
|
||||
TyKind::Raw(mutability, ty) => {
|
||||
let ty = ty.to_chalk(db);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue