Skip to content

Commit 8a10e6f

Browse files
Rustfmt, clippy
1 parent 4213228 commit 8a10e6f

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,8 @@ pub fn eq_ty(l: &Ty, r: &Ty) -> bool {
709709
(Tup(l), Tup(r)) => over(l, r, |l, r| eq_ty(l, r)),
710710
(Path(lq, lp), Path(rq, rp)) => both(lq, rq, eq_qself) && eq_path(lp, rp),
711711
(TraitObject(lg, ls), TraitObject(rg, rs)) => ls == rs && over(lg, rg, eq_generic_bound),
712-
(ImplTrait(_, lg), ImplTrait(_, rg)) => over(lg, rg, eq_generic_bound),
712+
(ImplTrait(_, lg, lc), ImplTrait(_, rg, rc)) =>
713+
over(lg, rg, eq_generic_bound) && both(lc, rc, |lc, rc| over(lc.0.as_slice(), rc.0.as_slice(), eq_precise_capture)),
713714
(Typeof(l), Typeof(r)) => eq_expr(&l.value, &r.value),
714715
(MacCall(l), MacCall(r)) => eq_mac_call(l, r),
715716
_ => false,
@@ -770,6 +771,14 @@ pub fn eq_generic_bound(l: &GenericBound, r: &GenericBound) -> bool {
770771
}
771772
}
772773

774+
pub fn eq_precise_capture(l: &PreciseCapturingArg, r: &PreciseCapturingArg) -> bool {
775+
match (l, r) {
776+
(PreciseCapturingArg::Lifetime(l), PreciseCapturingArg::Lifetime(r)) => l.ident == r.ident,
777+
(PreciseCapturingArg::Arg(l, _), PreciseCapturingArg::Arg(r, _)) => l.segments[0].ident == r.segments[0].ident,
778+
_ => false,
779+
}
780+
}
781+
773782
fn eq_term(l: &Term, r: &Term) -> bool {
774783
match (l, r) {
775784
(Term::Ty(l), Term::Ty(r)) => eq_ty(l, r),

src/tools/rustfmt/src/types.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,11 @@ impl Rewrite for ast::Ty {
843843
rewrite_macro(mac, None, context, shape, MacroPosition::Expression)
844844
}
845845
ast::TyKind::ImplicitSelf => Some(String::from("")),
846-
ast::TyKind::ImplTrait(_, ref it) => {
846+
ast::TyKind::ImplTrait(_, ref it, ref captures) => {
847+
// FIXME(precise_capturing): Implement formatting.
848+
if captures.is_some() {
849+
return None;
850+
}
847851
// Empty trait is not a parser error.
848852
if it.is_empty() {
849853
return Some("impl".to_owned());
@@ -1101,7 +1105,8 @@ fn join_bounds_inner(
11011105

11021106
pub(crate) fn opaque_ty(ty: &Option<ptr::P<ast::Ty>>) -> Option<&ast::GenericBounds> {
11031107
ty.as_ref().and_then(|t| match &t.kind {
1104-
ast::TyKind::ImplTrait(_, bounds) => Some(bounds),
1108+
// FIXME(precise_capturing): Implement support here
1109+
ast::TyKind::ImplTrait(_, bounds, _) => Some(bounds),
11051110
_ => None,
11061111
})
11071112
}

0 commit comments

Comments
 (0)