Skip to content

Commit efd2c20

Browse files
committed
remove useless conversions
1 parent cc80c5b commit efd2c20

File tree

17 files changed

+26
-38
lines changed

17 files changed

+26
-38
lines changed

crates/hir-def/src/nameres/collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub(super) fn collect_defs(db: &dyn DefDatabase, mut def_map: DefMap, tree_id: T
6767
let dep_def_map = db.crate_def_map(dep.crate_id);
6868
let dep_root = dep_def_map.module_id(dep_def_map.root);
6969

70-
deps.insert(dep.as_name(), dep_root.into());
70+
deps.insert(dep.as_name(), dep_root);
7171

7272
if dep.is_prelude() && !tree_id.is_block() {
7373
def_map.extern_prelude.insert(dep.as_name(), dep_root);
@@ -2085,7 +2085,7 @@ impl ModCollector<'_, '_> {
20852085
.scope
20862086
.get_legacy_macro(name)
20872087
.and_then(|it| it.last())
2088-
.map(|&it| macro_id_to_def_id(self.def_collector.db, it.into()))
2088+
.map(|&it| macro_id_to_def_id(self.def_collector.db, it))
20892089
},
20902090
)
20912091
})

crates/hir-def/src/nameres/path_resolution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl DefMap {
390390
.get_legacy_macro(name)
391391
// FIXME: shadowing
392392
.and_then(|it| it.last())
393-
.map_or_else(PerNs::none, |&m| PerNs::macros(m.into(), Visibility::Public));
393+
.map_or_else(PerNs::none, |&m| PerNs::macros(m, Visibility::Public));
394394
let from_scope = self[module].scope.get(name);
395395
let from_builtin = match self.block {
396396
Some(_) => {

crates/hir-def/src/resolver.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl Resolver {
381381
});
382382
def_map[module_id].scope.legacy_macros().for_each(|(name, macs)| {
383383
macs.iter().for_each(|&mac| {
384-
res.add(name, ScopeDef::ModuleDef(ModuleDefId::MacroId(MacroId::from(mac))));
384+
res.add(name, ScopeDef::ModuleDef(ModuleDefId::MacroId(mac)));
385385
})
386386
});
387387
def_map.extern_prelude().for_each(|(name, &def)| {
@@ -517,10 +517,7 @@ impl Scope {
517517
});
518518
m.def_map[m.module_id].scope.legacy_macros().for_each(|(name, macs)| {
519519
macs.iter().for_each(|&mac| {
520-
acc.add(
521-
name,
522-
ScopeDef::ModuleDef(ModuleDefId::MacroId(MacroId::from(mac))),
523-
);
520+
acc.add(name, ScopeDef::ModuleDef(ModuleDefId::MacroId(mac)));
524521
})
525522
});
526523
}

crates/hir-ty/src/consteval/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ fn eval_goal(ra_fixture: &str) -> Result<ComputedExpr, ConstEvalError> {
2525
let scope = &def_map[module_id.local_id].scope;
2626
let const_id = scope
2727
.declarations()
28-
.into_iter()
2928
.find_map(|x| match x {
3029
hir_def::ModuleDefId::ConstId(x) => {
3130
if db.const_data(x).name.as_ref()?.to_string() == "GOAL" {

crates/hir-ty/src/infer/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ impl<'a> InferenceContext<'a> {
960960
Expr::RecordLit { path, fields, .. } => {
961961
let subs = fields.iter().map(|f| (f.name.clone(), f.expr));
962962

963-
self.infer_record_pat_like(path.as_deref(), &rhs_ty, (), lhs.into(), subs)
963+
self.infer_record_pat_like(path.as_deref(), &rhs_ty, (), lhs, subs)
964964
}
965965
Expr::Underscore => rhs_ty.clone(),
966966
_ => {

crates/hir-ty/src/infer/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl<'a> InferenceContext<'a> {
220220
),
221221
Pat::Record { path: p, args: fields, ellipsis: _ } => {
222222
let subs = fields.iter().map(|f| (f.name.clone(), f.pat));
223-
self.infer_record_pat_like(p.as_deref(), &expected, default_bm, pat.into(), subs)
223+
self.infer_record_pat_like(p.as_deref(), &expected, default_bm, pat, subs)
224224
}
225225
Pat::Path(path) => {
226226
// FIXME use correct resolver for the surrounding expression

crates/hir-ty/src/layout/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ fn eval_goal(ra_fixture: &str, minicore: &str) -> Result<Layout, LayoutError> {
2929
let scope = &def_map[module_id.local_id].scope;
3030
let adt_id = scope
3131
.declarations()
32-
.into_iter()
3332
.find_map(|x| match x {
3433
hir_def::ModuleDefId::AdtId(x) => {
3534
let name = match x {

crates/hir/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ impl Module {
608608
pub fn legacy_macros(self, db: &dyn HirDatabase) -> Vec<Macro> {
609609
let def_map = self.id.def_map(db.upcast());
610610
let scope = &def_map[self.id.local_id].scope;
611-
scope.legacy_macros().flat_map(|(_, it)| it).map(|&it| MacroId::from(it).into()).collect()
611+
scope.legacy_macros().flat_map(|(_, it)| it).map(|&it| it.into()).collect()
612612
}
613613

614614
pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec<Impl> {
@@ -2411,7 +2411,7 @@ pub struct DeriveHelper {
24112411

24122412
impl DeriveHelper {
24132413
pub fn derive(&self) -> Macro {
2414-
Macro { id: self.derive.into() }
2414+
Macro { id: self.derive }
24152415
}
24162416

24172417
pub fn name(&self, db: &dyn HirDatabase) -> Name {
@@ -2781,7 +2781,7 @@ impl Impl {
27812781
pub fn all_for_trait(db: &dyn HirDatabase, trait_: Trait) -> Vec<Impl> {
27822782
let krate = trait_.module(db).krate();
27832783
let mut all = Vec::new();
2784-
for Crate { id } in krate.transitive_reverse_dependencies(db).into_iter() {
2784+
for Crate { id } in krate.transitive_reverse_dependencies(db) {
27852785
let impls = db.trait_impls_in_crate(id);
27862786
all.extend(impls.for_trait(trait_.id).map(Self::from))
27872787
}

crates/hir/src/source_analyzer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl SourceAnalyzer {
270270
db: &dyn HirDatabase,
271271
await_expr: &ast::AwaitExpr,
272272
) -> Option<FunctionId> {
273-
let mut ty = self.ty_of_expr(db, &await_expr.expr()?.into())?.clone();
273+
let mut ty = self.ty_of_expr(db, &await_expr.expr()?)?.clone();
274274

275275
let into_future_trait = self
276276
.resolver
@@ -316,7 +316,7 @@ impl SourceAnalyzer {
316316
ast::UnaryOp::Not => name![not],
317317
ast::UnaryOp::Neg => name![neg],
318318
};
319-
let ty = self.ty_of_expr(db, &prefix_expr.expr()?.into())?;
319+
let ty = self.ty_of_expr(db, &prefix_expr.expr()?)?;
320320

321321
let (op_trait, op_fn) = self.lang_trait_fn(db, &lang_item_name, &lang_item_name)?;
322322
// HACK: subst for all methods coincides with that for their trait because the methods
@@ -331,8 +331,8 @@ impl SourceAnalyzer {
331331
db: &dyn HirDatabase,
332332
index_expr: &ast::IndexExpr,
333333
) -> Option<FunctionId> {
334-
let base_ty = self.ty_of_expr(db, &index_expr.base()?.into())?;
335-
let index_ty = self.ty_of_expr(db, &index_expr.index()?.into())?;
334+
let base_ty = self.ty_of_expr(db, &index_expr.base()?)?;
335+
let index_ty = self.ty_of_expr(db, &index_expr.index()?)?;
336336

337337
let lang_item_name = name![index];
338338

@@ -352,8 +352,8 @@ impl SourceAnalyzer {
352352
binop_expr: &ast::BinExpr,
353353
) -> Option<FunctionId> {
354354
let op = binop_expr.op_kind()?;
355-
let lhs = self.ty_of_expr(db, &binop_expr.lhs()?.into())?;
356-
let rhs = self.ty_of_expr(db, &binop_expr.rhs()?.into())?;
355+
let lhs = self.ty_of_expr(db, &binop_expr.lhs()?)?;
356+
let rhs = self.ty_of_expr(db, &binop_expr.rhs()?)?;
357357

358358
let (op_trait, op_fn) = lang_names_for_bin_op(op)
359359
.and_then(|(name, lang_item)| self.lang_trait_fn(db, &lang_item, &name))?;
@@ -372,7 +372,7 @@ impl SourceAnalyzer {
372372
db: &dyn HirDatabase,
373373
try_expr: &ast::TryExpr,
374374
) -> Option<FunctionId> {
375-
let ty = self.ty_of_expr(db, &try_expr.expr()?.into())?;
375+
let ty = self.ty_of_expr(db, &try_expr.expr()?)?;
376376

377377
let op_fn =
378378
db.lang_item(self.resolver.krate(), name![branch].to_smol_str())?.as_function()?;

crates/ide-assists/src/handlers/generate_default_from_new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub(crate) fn generate_default_from_new(acc: &mut Assists, ctx: &AssistContext<'
5353
return None;
5454
}
5555

56-
let impl_ = fn_node.syntax().ancestors().into_iter().find_map(ast::Impl::cast)?;
56+
let impl_ = fn_node.syntax().ancestors().find_map(ast::Impl::cast)?;
5757
if is_default_implemented(ctx, &impl_) {
5858
cov_mark::hit!(default_block_is_already_present);
5959
cov_mark::hit!(struct_in_module_with_default);

0 commit comments

Comments
 (0)