mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
remove useless conversions
This commit is contained in:
parent
cc80c5bd07
commit
efd2c20e96
17 changed files with 26 additions and 38 deletions
|
@ -608,7 +608,7 @@ impl Module {
|
|||
pub fn legacy_macros(self, db: &dyn HirDatabase) -> Vec<Macro> {
|
||||
let def_map = self.id.def_map(db.upcast());
|
||||
let scope = &def_map[self.id.local_id].scope;
|
||||
scope.legacy_macros().flat_map(|(_, it)| it).map(|&it| MacroId::from(it).into()).collect()
|
||||
scope.legacy_macros().flat_map(|(_, it)| it).map(|&it| it.into()).collect()
|
||||
}
|
||||
|
||||
pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec<Impl> {
|
||||
|
@ -2411,7 +2411,7 @@ pub struct DeriveHelper {
|
|||
|
||||
impl DeriveHelper {
|
||||
pub fn derive(&self) -> Macro {
|
||||
Macro { id: self.derive.into() }
|
||||
Macro { id: self.derive }
|
||||
}
|
||||
|
||||
pub fn name(&self, db: &dyn HirDatabase) -> Name {
|
||||
|
@ -2781,7 +2781,7 @@ impl Impl {
|
|||
pub fn all_for_trait(db: &dyn HirDatabase, trait_: Trait) -> Vec<Impl> {
|
||||
let krate = trait_.module(db).krate();
|
||||
let mut all = Vec::new();
|
||||
for Crate { id } in krate.transitive_reverse_dependencies(db).into_iter() {
|
||||
for Crate { id } in krate.transitive_reverse_dependencies(db) {
|
||||
let impls = db.trait_impls_in_crate(id);
|
||||
all.extend(impls.for_trait(trait_.id).map(Self::from))
|
||||
}
|
||||
|
|
|
@ -270,7 +270,7 @@ impl SourceAnalyzer {
|
|||
db: &dyn HirDatabase,
|
||||
await_expr: &ast::AwaitExpr,
|
||||
) -> Option<FunctionId> {
|
||||
let mut ty = self.ty_of_expr(db, &await_expr.expr()?.into())?.clone();
|
||||
let mut ty = self.ty_of_expr(db, &await_expr.expr()?)?.clone();
|
||||
|
||||
let into_future_trait = self
|
||||
.resolver
|
||||
|
@ -316,7 +316,7 @@ impl SourceAnalyzer {
|
|||
ast::UnaryOp::Not => name![not],
|
||||
ast::UnaryOp::Neg => name![neg],
|
||||
};
|
||||
let ty = self.ty_of_expr(db, &prefix_expr.expr()?.into())?;
|
||||
let ty = self.ty_of_expr(db, &prefix_expr.expr()?)?;
|
||||
|
||||
let (op_trait, op_fn) = self.lang_trait_fn(db, &lang_item_name, &lang_item_name)?;
|
||||
// HACK: subst for all methods coincides with that for their trait because the methods
|
||||
|
@ -331,8 +331,8 @@ impl SourceAnalyzer {
|
|||
db: &dyn HirDatabase,
|
||||
index_expr: &ast::IndexExpr,
|
||||
) -> Option<FunctionId> {
|
||||
let base_ty = self.ty_of_expr(db, &index_expr.base()?.into())?;
|
||||
let index_ty = self.ty_of_expr(db, &index_expr.index()?.into())?;
|
||||
let base_ty = self.ty_of_expr(db, &index_expr.base()?)?;
|
||||
let index_ty = self.ty_of_expr(db, &index_expr.index()?)?;
|
||||
|
||||
let lang_item_name = name![index];
|
||||
|
||||
|
@ -352,8 +352,8 @@ impl SourceAnalyzer {
|
|||
binop_expr: &ast::BinExpr,
|
||||
) -> Option<FunctionId> {
|
||||
let op = binop_expr.op_kind()?;
|
||||
let lhs = self.ty_of_expr(db, &binop_expr.lhs()?.into())?;
|
||||
let rhs = self.ty_of_expr(db, &binop_expr.rhs()?.into())?;
|
||||
let lhs = self.ty_of_expr(db, &binop_expr.lhs()?)?;
|
||||
let rhs = self.ty_of_expr(db, &binop_expr.rhs()?)?;
|
||||
|
||||
let (op_trait, op_fn) = lang_names_for_bin_op(op)
|
||||
.and_then(|(name, lang_item)| self.lang_trait_fn(db, &lang_item, &name))?;
|
||||
|
@ -372,7 +372,7 @@ impl SourceAnalyzer {
|
|||
db: &dyn HirDatabase,
|
||||
try_expr: &ast::TryExpr,
|
||||
) -> Option<FunctionId> {
|
||||
let ty = self.ty_of_expr(db, &try_expr.expr()?.into())?;
|
||||
let ty = self.ty_of_expr(db, &try_expr.expr()?)?;
|
||||
|
||||
let op_fn =
|
||||
db.lang_item(self.resolver.krate(), name![branch].to_smol_str())?.as_function()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue