Skip to content

Commit da7dcea

Browse files
authored
Make some clippy checks stricter (#129)
* fix some issues * fix some issues * Fix clippy match_same_arms warnings by merging identical match arms Merged match arms with identical bodies across multiple files: - src/loop/mod.rs: Merged PlaceUsageType equality checks and PlaceContext arms - src/owned_pcg/impl/local/join.rs: Merged JoinExpandedPlaceResult actions - src/pcg/engine.rs: Merged Assert and Drop terminator edge handling - src/pcg/capabilities.rs: Consolidated partial ordering comparisons and minimum function - src/pcg/obtain/mod.rs: Merged ObtainType variants returning true - src/pcg/place_capabilities.rs: Consolidated BlockType capability returns - src/pcg/triple.rs: Merged SetDiscriminant and Retag, removed redundant PlaceMention - src/pcg/visitor/function_call.rs: Removed redundant FnPtr arm - src/utils/display.rs: Merged ConstantIndex and Subslice projections - src/utils/html.rs: Merged Text and Subscript variants - src/utils/initialized.rs: Merged LookupResult variants - src/utils/liveness.rs: Merged NonUse and Drop contexts - src/utils/place/mod.rs: Consolidated TyKind arms - src/utils/place_snapshot.rs: Merged SnapshotLocation variants - src/utils/visitor.rs: Consolidated statement and rvalue handling - src/visualization/mir_graph.rs: Merged binary ops and terminator kinds - src/visualization/mod.rs: Consolidated GraphEdge validity_conditions * rustfmt * rustfmt * more clippy checks * more clippy checks
1 parent b1a3340 commit da7dcea

60 files changed

Lines changed: 302 additions & 370 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/action.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'a, 'tcx: 'a, Ctxt: HasBorrowCheckerCtxt<'a, 'tcx>> DebugRepr<Ctxt> for App
5858

5959
pub(crate) type AppliedActions<'tcx> = PcgActions<'tcx, AppliedAction<'tcx>>;
6060

61-
impl<'tcx> Default for AppliedActions<'tcx> {
61+
impl Default for AppliedActions<'_> {
6262
fn default() -> Self {
6363
Self {
6464
actions: vec![],

src/borrow_pcg/action/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub struct LabelPlaceAction<'tcx, P = Place<'tcx>> {
225225
_marker: PhantomData<&'tcx ()>,
226226
}
227227

228-
impl<'tcx, P> LabelPlaceAction<'tcx, P> {
228+
impl<P> LabelPlaceAction<'_, P> {
229229
pub(crate) fn new(place: P, location: SnapshotLocation, reason: LabelPlaceReason) -> Self {
230230
Self {
231231
place,
@@ -398,11 +398,11 @@ impl<'a, 'tcx: 'a, Ctxt: HasBorrowCheckerCtxt<'a, 'tcx>, EdgeKind: DisplayWithCt
398398
BorrowPcgActionKind::LabelPlace(action) => action.display_output(ctxt, mode),
399399
BorrowPcgActionKind::RemoveEdge(edge) => DisplayOutput::join(
400400
vec!["Remove Edge".into(), edge.display_output(ctxt, mode)],
401-
DisplayOutput::SPACE,
401+
&DisplayOutput::SPACE,
402402
),
403403
BorrowPcgActionKind::AddEdge { edge } => DisplayOutput::join(
404404
vec!["Add Edge".into(), edge.display_output(ctxt, mode)],
405-
DisplayOutput::SPACE,
405+
&DisplayOutput::SPACE,
406406
),
407407
}
408408
}

src/borrow_pcg/borrow_pcg_edge.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ pub struct BorrowPcgEdgeRef<
4747
_marker: PhantomData<&'tcx ()>,
4848
}
4949

50-
impl<'a, 'tcx: 'a, 'graph, Ctxt: HasCompilerCtxt<'a, 'tcx>, EdgeKind: DisplayWithCtxt<Ctxt>>
51-
DisplayWithCtxt<Ctxt> for BorrowPcgEdgeRef<'tcx, 'graph, EdgeKind>
50+
impl<'a, 'tcx: 'a, Ctxt: HasCompilerCtxt<'a, 'tcx>, EdgeKind: DisplayWithCtxt<Ctxt>>
51+
DisplayWithCtxt<Ctxt> for BorrowPcgEdgeRef<'tcx, '_, EdgeKind>
5252
{
5353
fn display_output(&self, ctxt: Ctxt, mode: OutputMode) -> DisplayOutput {
5454
let kind = self.kind.display_output(ctxt, mode);
5555
self.conditions.conditional_string(kind, ctxt)
5656
}
5757
}
5858

59-
impl<'tcx, 'graph, EdgeKind, VC> BorrowPcgEdgeRef<'tcx, 'graph, EdgeKind, VC> {
59+
impl<'graph, EdgeKind, VC> BorrowPcgEdgeRef<'_, 'graph, EdgeKind, VC> {
6060
pub(crate) fn new(kind: &'graph EdgeKind, conditions: &'graph VC) -> Self {
6161
Self {
6262
kind,
@@ -66,15 +66,15 @@ impl<'tcx, 'graph, EdgeKind, VC> BorrowPcgEdgeRef<'tcx, 'graph, EdgeKind, VC> {
6666
}
6767
}
6868

69-
impl<'tcx, 'graph, EdgeKind, VC> BorrowPcgEdgeRef<'tcx, 'graph, EdgeKind, VC> {
69+
impl<EdgeKind, VC> BorrowPcgEdgeRef<'_, '_, EdgeKind, VC> {
7070
pub fn kind(&self) -> &EdgeKind {
7171
self.kind
7272
}
7373
}
7474

75-
impl<'tcx, 'graph, EdgeKind> Copy for BorrowPcgEdgeRef<'tcx, 'graph, EdgeKind> {}
75+
impl<EdgeKind> Copy for BorrowPcgEdgeRef<'_, '_, EdgeKind> {}
7676

77-
impl<'tcx, 'graph, EdgeKind> Clone for BorrowPcgEdgeRef<'tcx, 'graph, EdgeKind> {
77+
impl<EdgeKind> Clone for BorrowPcgEdgeRef<'_, '_, EdgeKind> {
7878
fn clone(&self) -> Self {
7979
*self
8080
}
@@ -287,7 +287,7 @@ impl<'tcx> From<LifetimeProjection<'tcx, Place<'tcx>>> for LocalNode<'tcx> {
287287
/// by definition)
288288
pub type BlockingNode<'tcx> = LocalNode<'tcx>;
289289

290-
impl<'a, 'tcx> HasValidityCheck<CompilerCtxt<'a, 'tcx>> for MaybeRemotePlace<'tcx> {
290+
impl<'tcx> HasValidityCheck<CompilerCtxt<'_, 'tcx>> for MaybeRemotePlace<'tcx> {
291291
fn check_validity(&self, _ctxt: CompilerCtxt<'_, 'tcx>) -> Result<(), String> {
292292
Ok(())
293293
}
@@ -302,7 +302,7 @@ impl<T: std::fmt::Display> std::fmt::Display for PcgNode<'_, T> {
302302
}
303303
}
304304

305-
impl<'tcx, P: PcgNodeComponent> LocalNode<'tcx, P> {
305+
impl<P: PcgNodeComponent> LocalNode<'_, P> {
306306
pub fn as_current_place(self) -> Option<P> {
307307
match self {
308308
LocalNode::Place(MaybeLabelledPlace::Current(place)) => Some(place),
@@ -339,7 +339,7 @@ impl<'tcx, P: Copy> PcgNodeWithPlace<'tcx, P> {
339339
}
340340
}
341341

342-
impl<'tcx, T: Copy, U> PcgNode<'tcx, T, U> {
342+
impl<T: Copy, U> PcgNode<'_, T, U> {
343343
pub(crate) fn as_place(&self) -> Option<T> {
344344
match self {
345345
PcgNode::Place(p) => Some(*p),

src/borrow_pcg/borrow_pcg_expansion.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'tcx, P: PcgNodeComponent> BorrowPcgExpansion<'tcx, P> {
250250
impl<'tcx> BorrowPcgExpansion<'tcx> {
251251
pub(crate) fn new_lifetime_projection_expansion<'a>(
252252
base: LifetimeProjection<'tcx, Place<'tcx>>,
253-
expansion: PlaceExpansion<'tcx>,
253+
expansion: &PlaceExpansion<'tcx>,
254254
ctxt: impl HasBorrowCheckerCtxt<'a, 'tcx>,
255255
) -> Result<Self, PcgError>
256256
where
@@ -266,7 +266,7 @@ impl<'tcx> BorrowPcgExpansion<'tcx> {
266266
}
267267
pub(crate) fn new_place_expansion<'a>(
268268
base: Place<'tcx>,
269-
expansion: PlaceExpansion<'tcx>,
269+
expansion: &PlaceExpansion<'tcx>,
270270
ctxt: impl HasBorrowCheckerCtxt<'a, 'tcx>,
271271
) -> Result<Self, PcgError>
272272
where
@@ -513,7 +513,7 @@ impl<'tcx, Node: PcgNodeComponent> BorrowPcgExpansionData<Node> {
513513

514514
pub(crate) fn new<Ctxt: DebugCtxt + Copy, P: PlaceLike<'tcx, Ctxt> + DisplayWithCtxt<Ctxt>>(
515515
base: Node,
516-
expansion: PlaceExpansion<'tcx>,
516+
expansion: &PlaceExpansion<'tcx>,
517517
ctxt: Ctxt,
518518
) -> Result<Self, PcgError>
519519
where
@@ -524,7 +524,7 @@ impl<'tcx, Node: PcgNodeComponent> BorrowPcgExpansionData<Node> {
524524
return Err(PcgUnsupportedError::DerefUnsafePtr.into());
525525
}
526526
pcg_validity_assert!(
527-
!(base.is_place() && base.place().is_ref(ctxt) && expansion == PlaceExpansion::Deref),
527+
!(base.is_place() && base.place().is_ref(ctxt) && expansion == &PlaceExpansion::Deref),
528528
[ctxt],
529529
"Deref expansion of {} should be a Deref edge, not an expansion",
530530
base.place().display_string(ctxt)

src/borrow_pcg/edge/abstraction/function.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'tcx> FunctionDataShapeDataSource<'tcx> {
8787
}
8888

8989
impl<'tcx> FunctionData<'tcx> {
90-
pub(crate) fn identity_fn_sig(&self, tcx: ty::TyCtxt<'tcx>) -> ty::FnSig<'tcx> {
90+
pub(crate) fn identity_fn_sig(self, tcx: ty::TyCtxt<'tcx>) -> ty::FnSig<'tcx> {
9191
let fn_sig = tcx.fn_sig(self.def_id).instantiate_identity();
9292
tcx.liberate_late_bound_regions(self.def_id, fn_sig)
9393
}
@@ -207,8 +207,8 @@ pub struct AbstractionBlockEdgeWithMetadata<Metadata, Edge> {
207207
pub(crate) edge: Edge,
208208
}
209209

210-
impl<'tcx, Metadata, Input: Copy, Output: Copy>
211-
AbstractionBlockEdgeWithMetadata<Metadata, AbstractionBlockEdge<'tcx, Input, Output>>
210+
impl<Metadata, Input: Copy, Output: Copy>
211+
AbstractionBlockEdgeWithMetadata<Metadata, AbstractionBlockEdge<'_, Input, Output>>
212212
{
213213
pub(crate) fn into_singleton_coupled_edge(self) -> CoupledEdgeKind<Metadata, Input, Output> {
214214
CoupledEdgeKind::new(self.metadata, self.edge.to_singleton_hyper_edge())

src/borrow_pcg/edge/abstraction/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ impl<'tcx> AbstractionEdge<'tcx> {
9191
}
9292
}
9393

94-
impl<'tcx, Input: std::fmt::Display, Output: std::fmt::Display> std::fmt::Display
95-
for AbstractionBlockEdge<'tcx, Input, Output>
94+
impl<Input: std::fmt::Display, Output: std::fmt::Display> std::fmt::Display
95+
for AbstractionBlockEdge<'_, Input, Output>
9696
{
9797
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9898
write!(f, "{} -> {}", self.input, self.output)
@@ -107,7 +107,7 @@ pub struct AbstractionBlockEdge<'tcx, Input, Output> {
107107
pub(crate) output: Output,
108108
}
109109

110-
impl<'tcx, Input: Copy, Output: Copy> AbstractionBlockEdge<'tcx, Input, Output> {
110+
impl<Input: Copy, Output: Copy> AbstractionBlockEdge<'_, Input, Output> {
111111
pub(crate) fn new(input: Input, output: Output) -> Self {
112112
Self {
113113
_phantom: PhantomData,
@@ -271,8 +271,8 @@ impl<
271271
}
272272
}
273273

274-
impl<'tcx, Ctxt: Copy, Input: DisplayWithCtxt<Ctxt>, Output: DisplayWithCtxt<Ctxt>>
275-
DisplayWithCtxt<Ctxt> for AbstractionBlockEdge<'tcx, Input, Output>
274+
impl<Ctxt: Copy, Input: DisplayWithCtxt<Ctxt>, Output: DisplayWithCtxt<Ctxt>> DisplayWithCtxt<Ctxt>
275+
for AbstractionBlockEdge<'_, Input, Output>
276276
{
277277
fn display_output(&self, ctxt: Ctxt, _mode: OutputMode) -> DisplayOutput {
278278
DisplayOutput::Text(
@@ -287,11 +287,10 @@ impl<'tcx, Ctxt: Copy, Input: DisplayWithCtxt<Ctxt>, Output: DisplayWithCtxt<Ctx
287287
}
288288

289289
impl<
290-
'tcx,
291290
Ctxt: DebugCtxt + Copy,
292291
Input: HasValidityCheck<Ctxt> + DisplayWithCtxt<Ctxt>,
293292
Output: HasValidityCheck<Ctxt> + DisplayWithCtxt<Ctxt>,
294-
> HasValidityCheck<Ctxt> for AbstractionBlockEdge<'tcx, Input, Output>
293+
> HasValidityCheck<Ctxt> for AbstractionBlockEdge<'_, Input, Output>
295294
{
296295
fn check_validity(&self, ctxt: Ctxt) -> Result<(), String> {
297296
self.input.check_validity(ctxt)?;
@@ -306,7 +305,7 @@ impl<
306305
}
307306
}
308307

309-
impl<'tcx, Input, Output> AbstractionBlockEdge<'tcx, Input, Output> {
308+
impl<Input, Output> AbstractionBlockEdge<'_, Input, Output> {
310309
pub(crate) fn new_checked<Ctxt: DebugCtxt + Copy>(
311310
input: Input,
312311
output: Output,

src/borrow_pcg/edge/borrow_flow.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct BorrowFlowEdge<'tcx, P = Place<'tcx>> {
3737
pub(crate) kind: BorrowFlowEdgeKind<'tcx>,
3838
}
3939

40-
impl<'tcx, P> BorrowFlowEdge<'tcx, P> {
40+
impl<P> BorrowFlowEdge<'_, P> {
4141
pub(crate) fn future_edge_kind(self) -> Option<private::FutureEdgeKind> {
4242
if let BorrowFlowEdgeKind::Future(future_edge_kind) = self.kind {
4343
Some(future_edge_kind)
@@ -239,7 +239,7 @@ impl<'tcx, P: Copy> BorrowFlowEdge<'tcx, P> {
239239
}
240240
}
241241

242-
impl<'tcx, Ty: serde::Serialize> serde::Serialize for CastData<'tcx, Ty> {
242+
impl<Ty: serde::Serialize> serde::Serialize for CastData<'_, Ty> {
243243
fn serialize<S>(&self, _serializer: S) -> Result<S::Ok, S::Error>
244244
where
245245
S: serde::Serializer,
@@ -255,7 +255,7 @@ pub struct CastData<'tcx, Ty = ty::Ty<'tcx>> {
255255
_phantom: PhantomData<&'tcx Ty>,
256256
}
257257

258-
impl<'tcx, Ty> CastData<'tcx, Ty> {
258+
impl<Ty> CastData<'_, Ty> {
259259
pub(crate) fn new(kind: mir::CastKind, ty: Ty) -> Self {
260260
Self {
261261
kind,
@@ -383,7 +383,7 @@ impl<'tcx, Ctxt> DebugRepr<Ctxt> for BorrowFlowEdgeKind<'tcx> {
383383
}
384384
}
385385

386-
impl<'tcx, Ty: std::fmt::Debug> std::fmt::Display for BorrowFlowEdgeKind<'tcx, Ty> {
386+
impl<Ty: std::fmt::Debug> std::fmt::Display for BorrowFlowEdgeKind<'_, Ty> {
387387
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
388388
match self {
389389
BorrowFlowEdgeKind::Aggregate {

src/borrow_pcg/edge_data.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ where
144144
}
145145
}
146146

147-
impl<'graph, 'tcx, Ctxt: Copy> EdgeData<'tcx, Ctxt> for BorrowPcgEdgeRef<'tcx, 'graph>
147+
impl<'tcx, Ctxt: Copy> EdgeData<'tcx, Ctxt> for BorrowPcgEdgeRef<'tcx, '_>
148148
where
149149
BorrowPcgEdgeKind<'tcx>: EdgeData<'tcx, Ctxt>,
150150
{
@@ -196,7 +196,7 @@ pub enum LabelNodePredicate<'tcx, P = Place<'tcx>> {
196196
InTargetNodes,
197197
}
198198

199-
impl<'tcx, P: Copy> LabelNodePredicate<'tcx, P> {
199+
impl<P: Copy> LabelNodePredicate<'_, P> {
200200
/// Creates a predicate that matches all future lifetime projections whose base
201201
/// is a postfix of the given place (and the base is current, not labelled).
202202
pub(crate) fn all_future_postfixes(place: P) -> Self {
@@ -272,15 +272,15 @@ impl<'a, 'tcx: 'a, Ctxt: HasBorrowCheckerCtxt<'a, 'tcx> + OverrideRegionDebugStr
272272
"(".into(),
273273
DisplayOutput::join(
274274
predicates.iter().map(|p| p.display_output(ctxt, mode)),
275-
" && ".into(),
275+
&" && ".into(),
276276
),
277277
")".into(),
278278
]),
279279
LabelNodePredicate::Or(predicates) => DisplayOutput::Seq(vec![
280280
"(".into(),
281281
DisplayOutput::join(
282282
predicates.iter().map(|p| p.display_output(ctxt, mode)),
283-
" || ".into(),
283+
&" || ".into(),
284284
),
285285
")".into(),
286286
]),
@@ -402,7 +402,7 @@ where
402402
.collect();
403403
DisplayOutput::Seq(vec![
404404
"Labelled nodes: [".into(),
405-
DisplayOutput::join(items, ", ".into()),
405+
DisplayOutput::join(items, &", ".into()),
406406
"]".into(),
407407
])
408408
}

src/borrow_pcg/graph/aliases.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,10 @@ impl<'tcx> BorrowsGraph<'tcx> {
7676
if !alias.exact_alias {
7777
continue;
7878
}
79-
let local_node = if let Some(local_node) = alias.node.try_to_local_node(ctxt) {
80-
local_node
81-
} else {
79+
let Some(local_node) = alias.node.try_to_local_node(ctxt) else {
8280
continue;
8381
};
84-
let local_node = if let Ok(n) = local_node.project_deeper(proj, ctxt) {
85-
n
86-
} else {
82+
let Ok(local_node) = local_node.project_deeper(proj, ctxt) else {
8783
continue;
8884
};
8985
results.extend(self.direct_aliases(

src/borrow_pcg/graph/frozen.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ pub struct FrozenGraphRef<
4949
roots_cache: RefCell<Option<FxHashSet<PcgNode<'tcx>>>>,
5050
}
5151

52-
impl<'graph, 'tcx, P: PcgNodeComponent, VC>
53-
FrozenGraphRef<'graph, 'tcx, P, BorrowPcgEdgeKind<'tcx, P>, VC>
54-
{
52+
impl<'tcx, P: PcgNodeComponent, VC> FrozenGraphRef<'_, 'tcx, P, BorrowPcgEdgeKind<'tcx, P>, VC> {
5553
pub(crate) fn is_leaf<'slf, Ctxt: Copy + DebugCtxt>(
5654
&'slf self,
5755
node: LocalNode<'tcx, P>,

0 commit comments

Comments
 (0)