Skip to content

Commit c5841ec

Browse files
committed
Fix clippy and rustfmt
1 parent 93a39ee commit c5841ec

File tree

2 files changed

+37
-41
lines changed

2 files changed

+37
-41
lines changed

src/tools/clippy/clippy_utils/src/ast_utils/mod.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -355,25 +355,23 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
355355
ident: li,
356356
generics: lg,
357357
ty: lt,
358-
body_id: _,
359-
expr: le,
358+
body: lb,
360359
define_opaque: _,
361360
}),
362361
Const(box ConstItem {
363362
defaultness: rd,
364363
ident: ri,
365364
generics: rg,
366365
ty: rt,
367-
body_id: _,
368-
expr: re,
366+
body: rb,
369367
define_opaque: _,
370368
}),
371369
) => {
372370
eq_defaultness(*ld, *rd)
373371
&& eq_id(*li, *ri)
374372
&& eq_generics(lg, rg)
375373
&& eq_ty(lt, rt)
376-
&& eq_expr_opt(le.as_ref(), re.as_ref())
374+
&& both(lb.as_ref(), rb.as_ref(), |l, r| eq_anon_const(l, r))
377375
},
378376
(
379377
Fn(box ast::Fn {
@@ -597,25 +595,23 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
597595
ident: li,
598596
generics: lg,
599597
ty: lt,
600-
body_id: _,
601-
expr: le,
598+
body: lb,
602599
define_opaque: _,
603600
}),
604601
Const(box ConstItem {
605602
defaultness: rd,
606603
ident: ri,
607604
generics: rg,
608605
ty: rt,
609-
body_id: _,
610-
expr: re,
606+
body: rb,
611607
define_opaque: _,
612608
}),
613609
) => {
614610
eq_defaultness(*ld, *rd)
615611
&& eq_id(*li, *ri)
616612
&& eq_generics(lg, rg)
617613
&& eq_ty(lt, rt)
618-
&& eq_expr_opt(le.as_ref(), re.as_ref())
614+
&& both(lb.as_ref(), rb.as_ref(), |l, r| eq_anon_const(l, r))
619615
},
620616
(
621617
Fn(box ast::Fn {

src/tools/rustfmt/src/items.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,30 +2029,30 @@ pub(crate) struct StaticParts<'a> {
20292029

20302030
impl<'a> StaticParts<'a> {
20312031
pub(crate) fn from_item(item: &'a ast::Item) -> Self {
2032-
let (defaultness, prefix, safety, ident, ty, mutability, expr, generics) = match &item.kind
2033-
{
2034-
ast::ItemKind::Static(s) => (
2035-
None,
2036-
"static",
2037-
s.safety,
2038-
s.ident,
2039-
&s.ty,
2040-
s.mutability,
2041-
&s.expr,
2042-
None,
2043-
),
2044-
ast::ItemKind::Const(c) => (
2045-
Some(c.defaultness),
2046-
"const",
2047-
ast::Safety::Default,
2048-
c.ident,
2049-
&c.ty,
2050-
ast::Mutability::Not,
2051-
&c.expr,
2052-
Some(&c.generics),
2053-
),
2054-
_ => unreachable!(),
2055-
};
2032+
let (defaultness, prefix, safety, ident, ty, mutability, expr_opt, generics) =
2033+
match &item.kind {
2034+
ast::ItemKind::Static(s) => (
2035+
None,
2036+
"static",
2037+
s.safety,
2038+
s.ident,
2039+
&s.ty,
2040+
s.mutability,
2041+
s.expr.as_ref(),
2042+
None,
2043+
),
2044+
ast::ItemKind::Const(c) => (
2045+
Some(c.defaultness),
2046+
"const",
2047+
ast::Safety::Default,
2048+
c.ident,
2049+
&c.ty,
2050+
ast::Mutability::Not,
2051+
c.body.as_ref().map(|ct| &ct.value),
2052+
Some(&c.generics),
2053+
),
2054+
_ => unreachable!(),
2055+
};
20562056
StaticParts {
20572057
prefix,
20582058
safety,
@@ -2061,15 +2061,15 @@ impl<'a> StaticParts<'a> {
20612061
generics,
20622062
ty,
20632063
mutability,
2064-
expr_opt: expr.as_ref(),
2064+
expr_opt,
20652065
defaultness,
20662066
span: item.span,
20672067
}
20682068
}
20692069

20702070
pub(crate) fn from_trait_item(ti: &'a ast::AssocItem, ident: Ident) -> Self {
2071-
let (defaultness, ty, expr_opt, generics) = match &ti.kind {
2072-
ast::AssocItemKind::Const(c) => (c.defaultness, &c.ty, &c.expr, Some(&c.generics)),
2071+
let (defaultness, ty, body_opt, generics) = match &ti.kind {
2072+
ast::AssocItemKind::Const(c) => (c.defaultness, &c.ty, &c.body, Some(&c.generics)),
20732073
_ => unreachable!(),
20742074
};
20752075
StaticParts {
@@ -2080,15 +2080,15 @@ impl<'a> StaticParts<'a> {
20802080
generics,
20812081
ty,
20822082
mutability: ast::Mutability::Not,
2083-
expr_opt: expr_opt.as_ref(),
2083+
expr_opt: body_opt.as_ref().map(|ct| &ct.value),
20842084
defaultness: Some(defaultness),
20852085
span: ti.span,
20862086
}
20872087
}
20882088

20892089
pub(crate) fn from_impl_item(ii: &'a ast::AssocItem, ident: Ident) -> Self {
2090-
let (defaultness, ty, expr, generics) = match &ii.kind {
2091-
ast::AssocItemKind::Const(c) => (c.defaultness, &c.ty, &c.expr, Some(&c.generics)),
2090+
let (defaultness, ty, body, generics) = match &ii.kind {
2091+
ast::AssocItemKind::Const(c) => (c.defaultness, &c.ty, &c.body, Some(&c.generics)),
20922092
_ => unreachable!(),
20932093
};
20942094
StaticParts {
@@ -2099,7 +2099,7 @@ impl<'a> StaticParts<'a> {
20992099
generics,
21002100
ty,
21012101
mutability: ast::Mutability::Not,
2102-
expr_opt: expr.as_ref(),
2102+
expr_opt: body.as_ref().map(|ct| &ct.value),
21032103
defaultness: Some(defaultness),
21042104
span: ii.span,
21052105
}

0 commit comments

Comments
 (0)