Open
Description
Here's some example code:
impl<'tcx> LateLintPass<'tcx> for UnqualifiedLocalImports {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
let hir::ItemKind::Use(path, _kind) = item.kind else { return };
let is_local_import = |res: &Res| {
matches!(res, hir::def::Res::Def(def_kind, def_id) if def_id.is_local() && !matches!(def_kind, DefKind::Macro(_)))
};
}
}
It's not the best code, that line is too long. So let's format it. Now we have:
impl<'tcx> LateLintPass<'tcx> for UnqualifiedLocalImports {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
let hir::ItemKind::Use(path, _kind) = item.kind else {
return;
};
let is_local_import = |res: &Res| matches!(res, hir::def::Res::Def(def_kind, def_id) if def_id.is_local() && !matches!(def_kind, DefKind::Macro(_)));
}
}
Now the line is even longer! It's way past the 100 character limit.
I guess rustfmt is reluctant to introduce linebreaks inside a macro, but then it should just avoid touching this code -- but instead it makes things worse by putting the entire closure on a single line.