Skip to content

Commit 8320183

Browse files
committed
Fix clippy::needless_borrow
1 parent 9af1cb1 commit 8320183

File tree

23 files changed

+59
-60
lines changed

23 files changed

+59
-60
lines changed

chalk-derive/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn find_interner(s: &mut synstructure::Structure) -> (TokenStream, DeriveKind) {
8484

8585
let generic_param0 = get_generic_param(input);
8686

87-
if let Some(param) = has_interner(&generic_param0) {
87+
if let Some(param) = has_interner(generic_param0) {
8888
// HasInterner bound:
8989
//
9090
// Example:
@@ -98,7 +98,7 @@ fn find_interner(s: &mut synstructure::Structure) -> (TokenStream, DeriveKind) {
9898
);
9999

100100
(quote! { _I }, DeriveKind::FromHasInterner)
101-
} else if let Some(i) = is_interner(&generic_param0) {
101+
} else if let Some(i) = is_interner(generic_param0) {
102102
// Interner bound:
103103
//
104104
// Example:

chalk-engine/src/logic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ impl<'forest, I: Interner> SolveState<'forest, I> {
951951
Ok(_) => {
952952
debug!(?strand, "merged answer into current strand");
953953
canonical_strand =
954-
Forest::canonicalize_strand_from(&self.context, &mut infer, &strand);
954+
Forest::canonicalize_strand_from(self.context, &mut infer, &strand);
955955
self.stack.top().active_strand = Some(canonical_strand);
956956
return Ok(());
957957
}

chalk-engine/src/slg/resolvent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl<I: Interner> AnswerSubstitutor<'_, I> {
329329
let result = self.table.relate(
330330
interner,
331331
db,
332-
&self.environment,
332+
self.environment,
333333
variance,
334334
answer_param,
335335
&GenericArg::new(interner, pending_shifted),

chalk-integration/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl ChalkDatabase {
4040

4141
pub fn with_program<R>(&self, op: impl FnOnce(&Program) -> R) -> R {
4242
let program = &self.checked_program().unwrap();
43-
tls::set_current_program(&program, || op(&program))
43+
tls::set_current_program(program, || op(program))
4444
}
4545

4646
pub fn parse_and_lower_goal(&self, text: &str) -> Result<Goal<ChalkIr>, ChalkError> {

chalk-integration/src/lowering.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ impl LowerWithEnv for InlineBound {
526526

527527
fn lower(&self, env: &Env) -> LowerResult<Self::Lowered> {
528528
Ok(match self {
529-
InlineBound::TraitBound(b) => rust_ir::InlineBound::TraitBound(b.lower(&env)?),
530-
InlineBound::AliasEqBound(b) => rust_ir::InlineBound::AliasEqBound(b.lower(&env)?),
529+
InlineBound::TraitBound(b) => rust_ir::InlineBound::TraitBound(b.lower(env)?),
530+
InlineBound::AliasEqBound(b) => rust_ir::InlineBound::AliasEqBound(b.lower(env)?),
531531
})
532532
}
533533
}
@@ -664,7 +664,7 @@ impl LowerWithEnv for Ty {
664664
let interner = env.interner();
665665
Ok(match self {
666666
Ty::Id { name } => {
667-
let parameter = env.lookup_generic_arg(&name)?;
667+
let parameter = env.lookup_generic_arg(name)?;
668668
parameter.ty(interner).map(|ty| ty.clone()).ok_or_else(|| {
669669
RustIrError::IncorrectParameterKind {
670670
identifier: name.clone(),
@@ -736,7 +736,7 @@ impl LowerWithEnv for Ty {
736736
chalk_ir::TyKind::$tykind($id, substitution).intern(interner)
737737
}};
738738
}
739-
match env.lookup_type(&name)? {
739+
match env.lookup_type(name)? {
740740
TypeLookup::Parameter(_) => {
741741
return Err(RustIrError::CannotApplyTypeParameter(name.clone()))
742742
}
@@ -846,7 +846,7 @@ impl LowerWithEnv for GenericArg {
846846
match self {
847847
GenericArg::Ty(ref t) => Ok(t.lower(env)?.cast(interner)),
848848
GenericArg::Lifetime(ref l) => Ok(l.lower(env)?.cast(interner)),
849-
GenericArg::Id(name) => env.lookup_generic_arg(&name),
849+
GenericArg::Id(name) => env.lookup_generic_arg(name),
850850
GenericArg::Const(c) => Ok(c.lower(env)?.cast(interner)),
851851
}
852852
}
@@ -859,7 +859,7 @@ impl LowerWithEnv for Lifetime {
859859
let interner = env.interner();
860860
match self {
861861
Lifetime::Id { name } => {
862-
let parameter = env.lookup_generic_arg(&name)?;
862+
let parameter = env.lookup_generic_arg(name)?;
863863
parameter.lifetime(interner).copied().ok_or_else(|| {
864864
RustIrError::IncorrectParameterKind {
865865
identifier: name.clone(),
@@ -901,7 +901,7 @@ impl LowerWithEnv for (&Impl, ImplId<ChalkIr>, &AssociatedTyValueIds) {
901901
))?;
902902
}
903903

904-
let where_clauses = impl_.where_clauses.lower(&env)?;
904+
let where_clauses = impl_.where_clauses.lower(env)?;
905905
debug!(where_clauses = ?trait_ref);
906906
Ok(rust_ir::ImplDatumBound {
907907
trait_ref,
@@ -1065,8 +1065,8 @@ impl LowerWithEnv for Goal {
10651065
fn lower(&self, env: &Env) -> LowerResult<Self::Lowered> {
10661066
let interner = env.interner();
10671067
match self {
1068-
Goal::ForAll(ids, g) => (&**g, chalk_ir::QuantifierKind::ForAll, ids).lower(&env),
1069-
Goal::Exists(ids, g) => (&**g, chalk_ir::QuantifierKind::Exists, ids).lower(&env),
1068+
Goal::ForAll(ids, g) => (&**g, chalk_ir::QuantifierKind::ForAll, ids).lower(env),
1069+
Goal::Exists(ids, g) => (&**g, chalk_ir::QuantifierKind::Exists, ids).lower(env),
10701070
Goal::Implies(hyp, g) => {
10711071
// We "elaborate" implied bounds by lowering goals like `T: Trait` and
10721072
// `T: Trait<Assoc = U>` to `FromEnv(T: Trait)` and `FromEnv(T: Trait<Assoc = U>)`

chalk-integration/src/lowering/program_lowerer.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl ProgramLowerer {
246246
let upvars =
247247
empty_env.in_binders(defn.all_parameters(), |env| {
248248
let upvar_tys: LowerResult<Vec<chalk_ir::Ty<ChalkIr>>> =
249-
defn.upvars.iter().map(|ty| ty.lower(&env)).collect();
249+
defn.upvars.iter().map(|ty| ty.lower(env)).collect();
250250
let substitution = chalk_ir::Substitution::from_iter(
251251
ChalkIr,
252252
upvar_tys?.into_iter().map(|ty| ty.cast(ChalkIr)),
@@ -295,8 +295,8 @@ impl ProgramLowerer {
295295

296296
let binders = empty_env.in_binders(variable_kinds, |env| {
297297
Ok(rust_ir::AssociatedTyDatumBound {
298-
bounds: assoc_ty_defn.bounds.lower(&env)?,
299-
where_clauses: assoc_ty_defn.where_clauses.lower(&env)?,
298+
bounds: assoc_ty_defn.bounds.lower(env)?,
299+
where_clauses: assoc_ty_defn.where_clauses.lower(env)?,
300300
})
301301
})?;
302302

@@ -361,7 +361,7 @@ impl ProgramLowerer {
361361
// Introduce the parameters declared on the opaque type definition.
362362
// So if we have `type Foo<P1..Pn> = impl Trait<T1..Tn>`, this would introduce `P1..Pn`
363363
let binders = empty_env.in_binders(variable_kinds, |env| {
364-
let hidden_ty = opaque_ty.ty.lower(&env)?;
364+
let hidden_ty = opaque_ty.ty.lower(env)?;
365365
hidden_opaque_types.insert(opaque_ty_id, Arc::new(hidden_ty));
366366

367367
// Introduce a variable to represent the hidden "self type". This will be used in the bounds.
@@ -376,7 +376,7 @@ impl ProgramLowerer {
376376
let interner = env.interner();
377377
Ok(opaque_ty
378378
.bounds
379-
.lower(&env)?
379+
.lower(env)?
380380
.iter()
381381
.flat_map(|qil| {
382382
// Instantiate the bounds with the innermost bound variable, which represents Self, as the self type.
@@ -430,11 +430,11 @@ impl ProgramLowerer {
430430
.collect::<Vec<_>>();
431431

432432
let input_output = empty_env.in_binders(variable_kinds.clone(), |env| {
433-
let yield_type = defn.yield_ty.lower(&env)?;
434-
let resume_type = defn.resume_ty.lower(&env)?;
435-
let return_type = defn.return_ty.lower(&env)?;
433+
let yield_type = defn.yield_ty.lower(env)?;
434+
let resume_type = defn.resume_ty.lower(env)?;
435+
let return_type = defn.return_ty.lower(env)?;
436436
let upvars: Result<Vec<_>, _> =
437-
defn.upvars.iter().map(|ty| ty.lower(&env)).collect();
437+
defn.upvars.iter().map(|ty| ty.lower(env)).collect();
438438

439439
Ok(GeneratorInputOutputDatum {
440440
resume_type,
@@ -447,7 +447,7 @@ impl ProgramLowerer {
447447
let inner_types = empty_env.in_binders(variable_kinds, |env| {
448448
let witnesses = env.in_binders(witness_lifetimes, |env| {
449449
let witnesses: Result<Vec<_>, _> =
450-
defn.witness_types.iter().map(|ty| ty.lower(&env)).collect();
450+
defn.witness_types.iter().map(|ty| ty.lower(env)).collect();
451451
witnesses
452452
})?;
453453

chalk-integration/src/program.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl tls::DebugContext for Program {
213213
associated_ty_data.trait_id,
214214
Angle(&trait_params[1..]),
215215
associated_ty_data.name,
216-
Angle(&other_params)
216+
Angle(other_params)
217217
)
218218
}
219219

@@ -448,10 +448,10 @@ impl RustIrDatabase<ChalkIr> for Program {
448448
trait_id == trait_ref.trait_id && {
449449
assert_eq!(trait_ref.substitution.len(interner), parameters.len());
450450
<[_] as CouldMatch<[_]>>::could_match(
451-
&parameters,
451+
parameters,
452452
interner,
453453
self.unification_database(),
454-
&trait_ref.substitution.as_slice(interner),
454+
trait_ref.substitution.as_slice(interner),
455455
)
456456
}
457457
})

chalk-ir/src/could_match.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ where
4141
let matches = |a: &Substitution<I>, b: &Substitution<I>| {
4242
a.iter(interner)
4343
.zip(b.iter(interner))
44-
.all(|(p_a, p_b)| p_a.could_match(interner, self.db, &p_b))
44+
.all(|(p_a, p_b)| p_a.could_match(interner, self.db, p_b))
4545
};
4646
let could_match = match (a.kind(interner), b.kind(interner)) {
4747
(TyKind::Adt(id_a, substitution_a), TyKind::Adt(id_b, substitution_b)) => {
@@ -91,11 +91,11 @@ where
9191
TyKind::Ref(mutability_b, lifetime_b, ty_b),
9292
) => {
9393
mutability_a == mutability_b
94-
&& lifetime_a.could_match(interner, self.db, &lifetime_b)
95-
&& ty_a.could_match(interner, self.db, &ty_b)
94+
&& lifetime_a.could_match(interner, self.db, lifetime_b)
95+
&& ty_a.could_match(interner, self.db, ty_b)
9696
}
9797
(TyKind::Raw(mutability_a, ty_a), TyKind::Raw(mutability_b, ty_b)) => {
98-
mutability_a == mutability_b && ty_a.could_match(interner, self.db, &ty_b)
98+
mutability_a == mutability_b && ty_a.could_match(interner, self.db, ty_b)
9999
}
100100
(TyKind::Never, TyKind::Never) => true,
101101
(TyKind::Array(ty_a, const_a), TyKind::Array(ty_b, const_b)) => {

chalk-recursive/src/fixed_point.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ where
123123
) -> V {
124124
// First check the cache.
125125
if let Some(cache) = &self.cache {
126-
if let Some(value) = cache.get(&goal) {
126+
if let Some(value) = cache.get(goal) {
127127
debug!("solve_reduced_goal: cache hit, value={:?}", value);
128128
return value.clone();
129129
}
130130
}
131131

132132
// Next, check if the goal is in the search tree already.
133-
if let Some(dfn) = self.search_graph.lookup(&goal) {
133+
if let Some(dfn) = self.search_graph.lookup(goal) {
134134
// Check if this table is still on the stack.
135135
if let Some(depth) = self.search_graph[dfn].stack_depth {
136136
self.stack[depth].flag_cycle();
@@ -157,9 +157,9 @@ where
157157
let coinductive_goal = solver_stuff.is_coinductive_goal(goal);
158158
let initial_solution = solver_stuff.initial_value(goal, coinductive_goal);
159159
let depth = self.stack.push(coinductive_goal);
160-
let dfn = self.search_graph.insert(&goal, depth, initial_solution);
160+
let dfn = self.search_graph.insert(goal, depth, initial_solution);
161161

162-
let subgoal_minimums = self.solve_new_subgoal(&goal, depth, dfn, solver_stuff);
162+
let subgoal_minimums = self.solve_new_subgoal(goal, depth, dfn, solver_stuff);
163163

164164
self.search_graph[dfn].links = subgoal_minimums;
165165
self.search_graph[dfn].stack_depth = None;
@@ -209,7 +209,7 @@ where
209209
// so this function will eventually be constant and the loop terminates.
210210
loop {
211211
let minimums = &mut Minimums::new();
212-
let current_answer = solver_stuff.solve_iteration(self, &canonical_goal, minimums);
212+
let current_answer = solver_stuff.solve_iteration(self, canonical_goal, minimums);
213213

214214
debug!(
215215
"solve_new_subgoal: loop iteration result = {:?} with minimums {:?}",

chalk-recursive/src/fixed_point/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ where
4141
/// Record a cache result.
4242
pub fn get(&self, goal: &K) -> Option<V> {
4343
let data = self.data.lock().unwrap();
44-
if let Some(result) = data.cache.get(&goal) {
44+
if let Some(result) = data.cache.get(goal) {
4545
debug!(?goal, ?result, "Cache hit");
4646
Some(result.clone())
4747
} else {

0 commit comments

Comments
 (0)