clippy::redudant_borrow

This commit is contained in:
Maan2003 2021-06-13 09:24:16 +05:30
parent d6737e55fb
commit c9b4ac5be4
No known key found for this signature in database
GPG key ID: E9AF024BA63C70ED
114 changed files with 285 additions and 285 deletions

View file

@ -528,7 +528,7 @@ impl SplitWildcard {
smallvec![NonExhaustive]
}
TyKind::Never => SmallVec::new(),
_ if cx.is_uninhabited(&pcx.ty) => SmallVec::new(),
_ if cx.is_uninhabited(pcx.ty) => SmallVec::new(),
TyKind::Adt(..) | TyKind::Tuple(..) | TyKind::Ref(..) => smallvec![Single],
// This type is one for which we cannot list constructors, like `str` or `f64`.
_ => smallvec![NonExhaustive],

View file

@ -645,7 +645,7 @@ impl SubPatSet {
(Seq { subpats: s_set }, Seq { subpats: mut o_set }) => {
s_set.retain(|i, s_sub_set| {
// Missing entries count as full.
let o_sub_set = o_set.remove(&i).unwrap_or(Full);
let o_sub_set = o_set.remove(i).unwrap_or(Full);
s_sub_set.union(o_sub_set);
// We drop full entries.
!s_sub_set.is_full()
@ -656,7 +656,7 @@ impl SubPatSet {
(Alt { subpats: s_set, .. }, Alt { subpats: mut o_set, .. }) => {
s_set.retain(|i, s_sub_set| {
// Missing entries count as empty.
let o_sub_set = o_set.remove(&i).unwrap_or(Empty);
let o_sub_set = o_set.remove(i).unwrap_or(Empty);
s_sub_set.union(o_sub_set);
// We drop empty entries.
!s_sub_set.is_empty()
@ -898,7 +898,7 @@ impl Usefulness {
} else {
witnesses
.into_iter()
.map(|witness| witness.apply_constructor(pcx, &ctor, ctor_wild_subpatterns))
.map(|witness| witness.apply_constructor(pcx, ctor, ctor_wild_subpatterns))
.collect()
};
WithWitnesses(new_witnesses)

View file

@ -782,7 +782,7 @@ impl Expectation {
fn adjust_for_branches(&self, table: &mut unify::InferenceTable) -> Expectation {
match self {
Expectation::HasType(ety) => {
let ety = table.resolve_ty_shallow(&ety);
let ety = table.resolve_ty_shallow(ety);
if !ety.is_ty_var() {
Expectation::HasType(ety)
} else {

View file

@ -109,7 +109,7 @@ impl<'a> InferenceContext<'a> {
}
// Consider coercing the subtype to a DST
if let Ok(ret) = self.try_coerce_unsized(&from_ty, &to_ty) {
if let Ok(ret) = self.try_coerce_unsized(&from_ty, to_ty) {
return Ok(ret);
}

View file

@ -54,7 +54,7 @@ impl<'a> InferenceContext<'a> {
/// Infer type of expression with possibly implicit coerce to the expected type.
/// Return the type after possible coercion.
pub(super) fn infer_expr_coerce(&mut self, expr: ExprId, expected: &Expectation) -> Ty {
let ty = self.infer_expr_inner(expr, &expected);
let ty = self.infer_expr_inner(expr, expected);
let ty = if let Some(target) = expected.only_has_type(&mut self.table) {
if !self.coerce(&ty, &target) {
self.result
@ -135,11 +135,11 @@ impl<'a> InferenceContext<'a> {
let mut both_arms_diverge = Diverges::Always;
let mut result_ty = self.table.new_type_var();
let then_ty = self.infer_expr_inner(*then_branch, &expected);
let then_ty = self.infer_expr_inner(*then_branch, expected);
both_arms_diverge &= mem::replace(&mut self.diverges, Diverges::Maybe);
result_ty = self.coerce_merge_branch(Some(*then_branch), &result_ty, &then_ty);
let else_ty = match else_branch {
Some(else_branch) => self.infer_expr_inner(*else_branch, &expected),
Some(else_branch) => self.infer_expr_inner(*else_branch, expected),
None => TyBuilder::unit(),
};
both_arms_diverge &= self.diverges;
@ -330,8 +330,8 @@ impl<'a> InferenceContext<'a> {
.infer_method_call(
tgt_expr,
*receiver,
&args,
&method_name,
args,
method_name,
generic_args.as_deref(),
),
Expr::Match { expr, arms } => {
@ -993,7 +993,7 @@ impl<'a> InferenceContext<'a> {
}
fn register_obligations_for_call(&mut self, callable_ty: &Ty) {
let callable_ty = self.resolve_ty_shallow(&callable_ty);
let callable_ty = self.resolve_ty_shallow(callable_ty);
if let TyKind::FnDef(fn_def, parameters) = callable_ty.kind(&Interner) {
let def: CallableDefId = from_chalk(self.db, *fn_def);
let generic_predicates = self.db.generic_predicates(def.into());

View file

@ -192,7 +192,7 @@ impl<'a> InferenceContext<'a> {
Pat::Path(path) => {
// FIXME use correct resolver for the surrounding expression
let resolver = self.resolver.clone();
self.infer_path(&resolver, &path, pat.into()).unwrap_or(self.err_ty())
self.infer_path(&resolver, path, pat.into()).unwrap_or(self.err_ty())
}
Pat::Bind { mode, name: _, subpat } => {
let mode = if mode == &BindingAnnotation::Unannotated {

View file

@ -43,11 +43,11 @@ impl<'a> InferenceContext<'a> {
}
let ty = self.make_ty(type_ref);
let remaining_segments_for_ty = path.segments().take(path.segments().len() - 1);
let ctx = crate::lower::TyLoweringContext::new(self.db, &resolver);
let ctx = crate::lower::TyLoweringContext::new(self.db, resolver);
let (ty, _) = ctx.lower_ty_relative_path(ty, None, remaining_segments_for_ty);
self.resolve_ty_assoc_item(
ty,
&path.segments().last().expect("path had at least one segment").name,
path.segments().last().expect("path had at least one segment").name,
id,
)?
} else {
@ -154,7 +154,7 @@ impl<'a> InferenceContext<'a> {
let segment =
remaining_segments.last().expect("there should be at least one segment here");
self.resolve_ty_assoc_item(ty, &segment.name, id)
self.resolve_ty_assoc_item(ty, segment.name, id)
}
}
}

View file

@ -331,7 +331,7 @@ impl chalk_ir::interner::Interner for Interner {
&self,
clauses: &'a Self::InternedProgramClauses,
) -> &'a [chalk_ir::ProgramClause<Self>] {
&clauses
clauses
}
fn intern_quantified_where_clauses<E>(
@ -373,7 +373,7 @@ impl chalk_ir::interner::Interner for Interner {
&self,
canonical_var_kinds: &'a Self::InternedCanonicalVarKinds,
) -> &'a [chalk_ir::CanonicalVarKind<Self>] {
&canonical_var_kinds
canonical_var_kinds
}
fn intern_constraints<E>(
@ -413,7 +413,7 @@ impl chalk_ir::interner::Interner for Interner {
&self,
variances: &'a Self::InternedVariances,
) -> &'a [chalk_ir::Variance] {
&variances
variances
}
}

View file

@ -238,7 +238,7 @@ impl<'a> TyLoweringContext<'a> {
// away instead of two.
let actual_opaque_type_data = self
.with_debruijn(DebruijnIndex::INNERMOST, |ctx| {
ctx.lower_impl_trait(&bounds)
ctx.lower_impl_trait(bounds)
});
self.opaque_type_data.borrow_mut()[idx as usize] = actual_opaque_type_data;
@ -421,7 +421,7 @@ impl<'a> TyLoweringContext<'a> {
let found = self
.db
.trait_data(trait_ref.hir_trait_id())
.associated_type_by_name(&segment.name);
.associated_type_by_name(segment.name);
match found {
Some(associated_ty) => {
// FIXME handle type parameters on the segment
@ -505,7 +505,7 @@ impl<'a> TyLoweringContext<'a> {
pub(crate) fn lower_path(&self, path: &Path) -> (Ty, Option<TypeNs>) {
// Resolve the path (in type namespace)
if let Some(type_ref) = path.type_anchor() {
let (ty, res) = self.lower_ty_ext(&type_ref);
let (ty, res) = self.lower_ty_ext(type_ref);
return self.lower_ty_relative_path(ty, res, path.segments());
}
let (resolution, remaining_index) =

View file

@ -372,7 +372,7 @@ pub(crate) fn lookup_method(
db,
env,
krate,
&traits_in_scope,
traits_in_scope,
visible_from_module,
Some(name),
LookupMode::MethodCall,
@ -484,7 +484,7 @@ fn iterate_method_candidates_impl(
LookupMode::Path => {
// No autoderef for path lookups
iterate_method_candidates_for_self_ty(
&ty,
ty,
db,
env,
krate,
@ -513,7 +513,7 @@ fn iterate_method_candidates_with_autoref(
db,
env.clone(),
krate,
&traits_in_scope,
traits_in_scope,
visible_from_module,
name,
&mut callback,
@ -531,7 +531,7 @@ fn iterate_method_candidates_with_autoref(
db,
env.clone(),
krate,
&traits_in_scope,
traits_in_scope,
visible_from_module,
name,
&mut callback,
@ -549,7 +549,7 @@ fn iterate_method_candidates_with_autoref(
db,
env,
krate,
&traits_in_scope,
traits_in_scope,
visible_from_module,
name,
&mut callback,
@ -593,7 +593,7 @@ fn iterate_method_candidates_by_receiver(
db,
env.clone(),
krate,
&traits_in_scope,
traits_in_scope,
name,
Some(receiver_ty),
&mut callback,
@ -870,7 +870,7 @@ fn transform_receiver_ty(
.fill_with_unknown()
.build(),
AssocContainerId::ImplId(impl_id) => {
let impl_substs = inherent_impl_substs(db, env, impl_id, &self_ty)?;
let impl_substs = inherent_impl_substs(db, env, impl_id, self_ty)?;
TyBuilder::subst_for_def(db, function_id)
.use_parent_substs(&impl_substs)
.fill_with_unknown()