Skip to content

Commit 94d7374

Browse files
author
Ype Kingma
committed
Cargo dev dogfood suggestions
1 parent 441f2bf commit 94d7374

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

clippy_lints/src/lifetimes_bound_nested_ref.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ struct BoundLftPair {
162162
}
163163

164164
impl BoundLftPair {
165-
fn new(long_lft_sym: &Symbol, outlived_lft_sym: &Symbol) -> Self {
165+
fn new(long_lft_sym: Symbol, outlived_lft_sym: Symbol) -> Self {
166166
BoundLftPair {
167167
long_lft: long_lft_sym.to_ident_string(),
168168
outlived_lft: outlived_lft_sym.to_ident_string(),
@@ -178,19 +178,13 @@ impl PartialEq for BoundLftPair {
178178
fn eq(&self, other: &Self) -> bool {
179179
self.long_lft.eq(&other.long_lft) && self.outlived_lft.eq(&other.outlived_lft)
180180
}
181-
182-
fn ne(&self, other: &Self) -> bool {
183-
!self.eq(other)
184-
}
185181
}
186182

187183
impl Eq for BoundLftPair {}
188184

189185
impl PartialOrd for BoundLftPair {
190186
fn partial_cmp(&self, other: &BoundLftPair) -> Option<Ordering> {
191-
self.long_lft
192-
.partial_cmp(&other.long_lft)
193-
.or(self.outlived_lft.partial_cmp(&other.outlived_lft))
187+
Some(self.cmp(other))
194188
}
195189
}
196190

@@ -215,7 +209,7 @@ fn get_declared_bounds(generics: &Generics<'_>) -> BTreeSet<BoundLftPair> {
215209
let GenericBound::Outlives(outlived_lft) = *generic_bound else {
216210
continue;
217211
};
218-
let declared_bound = BoundLftPair::new(&long_lft_sym, &outlived_lft.ident.name);
212+
let declared_bound = BoundLftPair::new(long_lft_sym, outlived_lft.ident.name);
219213
declared_bounds.insert(declared_bound);
220214
}
221215
},
@@ -249,7 +243,7 @@ fn collect_nested_ref_implied_bounds(
249243
if let Some(ref_lft_sym) = ref_lft_sym_opt {
250244
if let Some(outlived_lft_sym) = outlived_lft_sym_opt {
251245
// ref_lft_sym outlives outlived_lft_sym
252-
let bound_lft_pair = BoundLftPair::new(&ref_lft_sym, &outlived_lft_sym);
246+
let bound_lft_pair = BoundLftPair::new(ref_lft_sym, outlived_lft_sym);
253247
implied_bounds.insert(bound_lft_pair);
254248
}
255249
// ref_lft_sym may be outlived by deeper refs

0 commit comments

Comments
 (0)