From: Oliver Schneider Date: Wed, 21 Dec 2016 11:14:54 +0000 (+0100) Subject: function definition style simplification X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=47eead5ada97f50af5e00426bc08f1dcbeb5d4d2;p=rust.git function definition style simplification --- diff --git a/clippy_lints/src/array_indexing.rs b/clippy_lints/src/array_indexing.rs index aa9af2e681d..de13c0264e5 100644 --- a/clippy_lints/src/array_indexing.rs +++ b/clippy_lints/src/array_indexing.rs @@ -107,8 +107,12 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) { } /// Returns an option containing a tuple with the start and end (exclusive) of the range. -fn to_const_range(start: Option>, end: Option>, limits: RangeLimits, array_size: ConstInt) - -> Option<(ConstInt, ConstInt)> { +fn to_const_range( + start: Option>, + end: Option>, + limits: RangeLimits, + array_size: ConstInt +) -> Option<(ConstInt, ConstInt)> { let start = match start { Some(Some(ConstVal::Integral(x))) => x, Some(_) => return None, diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 9a9b97d0e81..11b85edba3e 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -248,7 +248,11 @@ fn if_sequence(mut expr: &Expr) -> (SmallVector<&Expr>, SmallVector<&Block>) { /// Return the list of bindings in a pattern. fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap> { - fn bindings_impl<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat, map: &mut HashMap>) { + fn bindings_impl<'a, 'tcx>( + cx: &LateContext<'a, 'tcx>, + pat: &Pat, + map: &mut HashMap> + ) { match pat.node { PatKind::Box(ref pat) | PatKind::Ref(ref pat, _) => bindings_impl(cx, pat, map), diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 8836af28d09..cda82f46434 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -86,8 +86,13 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { } /// Implementation of the `DERIVE_HASH_XOR_EQ` lint. -fn check_hash_peq<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, span: Span, trait_ref: &TraitRef, ty: ty::Ty<'tcx>, - hash_is_automatically_derived: bool) { +fn check_hash_peq<'a, 'tcx>( + cx: &LateContext<'a, 'tcx>, + span: Span, + trait_ref: &TraitRef, + ty: ty::Ty<'tcx>, + hash_is_automatically_derived: bool +) { if_let_chain! {[ match_path_old(&trait_ref.path, &paths::HASH), let Some(peq_trait_def_id) = cx.tcx.lang_items.eq_trait() diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index 2ff31b3a4fe..2fe53d8cacf 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -78,8 +78,10 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { } } -fn check_cond<'a, 'tcx, 'b>(cx: &'a LateContext<'a, 'tcx>, check: &'b Expr) - -> Option<(&'static str, &'b Expr, &'b Expr)> { +fn check_cond<'a, 'tcx, 'b>( + cx: &'a LateContext<'a, 'tcx>, + check: &'b Expr +) -> Option<(&'static str, &'b Expr, &'b Expr)> { if_let_chain! {[ let ExprMethodCall(ref name, _, ref params) = check.node, params.len() >= 2, diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index e3bfca0b2f5..5ae3fcbb2a1 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -114,7 +114,14 @@ fn partial_rmatch(post: &str, name: &str) -> usize { // FIXME: #600 #[allow(while_let_on_iterator)] -fn check_variant(cx: &EarlyContext, threshold: u64, def: &EnumDef, item_name: &str, item_name_chars: usize, span: Span) { +fn check_variant( + cx: &EarlyContext, + threshold: u64, + def: &EnumDef, + item_name: &str, + item_name_chars: usize, + span: Span +) { if (def.variants.len() as u64) < threshold { return; } diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index d66c8757ef2..ee415b36382 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -62,7 +62,12 @@ fn get_lints(&self) -> LintArray { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_fn( - &mut self, cx: &LateContext<'a, 'tcx>, _: visit::FnKind<'tcx>, decl: &'tcx FnDecl, body: &'tcx Expr, _: Span, + &mut self, + cx: &LateContext<'a, 'tcx>, + _: visit::FnKind<'tcx>, + decl: &'tcx FnDecl, + body: &'tcx Expr, + _: Span, id: NodeId ) { let param_env = ty::ParameterEnvironment::for_item(cx.tcx, id); @@ -146,8 +151,15 @@ fn consume_pat(&mut self, consume_pat: &Pat, cmt: cmt<'tcx>, _: ConsumeMode) { } } - fn borrow(&mut self, borrow_id: NodeId, _: Span, cmt: cmt<'tcx>, _: &ty::Region, _: ty::BorrowKind, - loan_cause: LoanCause) { + fn borrow( + &mut self, + borrow_id: NodeId, + _: Span, + cmt: cmt<'tcx>, + _: &ty::Region, + _: ty::BorrowKind, + loan_cause: LoanCause + ) { use rustc::ty::adjustment::Adjust; if let Categorization::Local(lid) = cmt.cat { diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 58425ff2a40..5ad676e57a0 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -70,8 +70,13 @@ fn get_lints(&self) -> LintArray { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions { fn check_fn( - &mut self, cx: &LateContext<'a, 'tcx>, kind: intravisit::FnKind<'tcx>, decl: &'tcx hir::FnDecl, - expr: &'tcx hir::Expr, span: Span, nodeid: ast::NodeId + &mut self, + cx: &LateContext<'a, 'tcx>, + kind: intravisit::FnKind<'tcx>, + decl: &'tcx hir::FnDecl, + expr: &'tcx hir::Expr, + span: Span, + nodeid: ast::NodeId ) { use rustc::hir::map::Node::*; @@ -127,7 +132,11 @@ fn check_arg_number(&self, cx: &LateContext, decl: &hir::FnDecl, span: Span) { } fn check_raw_ptr( - &self, cx: &LateContext<'a, 'tcx>, unsafety: hir::Unsafety, decl: &'tcx hir::FnDecl, expr: &'tcx hir::Expr, + &self, + cx: &LateContext<'a, 'tcx>, + unsafety: hir::Unsafety, + decl: &'tcx hir::FnDecl, + expr: &'tcx hir::Expr, nodeid: ast::NodeId ) { if unsafety == hir::Unsafety::Normal && cx.access_levels.is_exported(nodeid) { diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index c6efc3fd736..88d74b01886 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -149,8 +149,11 @@ fn nested_visit_map<'this>(&'this mut self) -> hir::intravisit::NestedVisitorMap } } -fn check_assign<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: hir::def_id::DefId, block: &'tcx hir::Block) - -> Option<&'tcx hir::Expr> { +fn check_assign<'a, 'tcx>( + cx: &LateContext<'a, 'tcx>, + decl: hir::def_id::DefId, + block: &'tcx hir::Block +) -> Option<&'tcx hir::Expr> { if_let_chain! {[ block.expr.is_none(), let Some(expr) = block.stmts.iter().last(), diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index e9f93d04360..ba705a84089 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -116,8 +116,12 @@ fn check_fn_inner<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, gene report_extra_lifetimes(cx, decl, generics); } -fn could_use_elision<'a, 'tcx: 'a, T: Iterator>(cx: &LateContext<'a, 'tcx>, func: &'tcx FnDecl, named_lts: &'tcx [LifetimeDef], bounds_lts: T) - -> bool { +fn could_use_elision<'a, 'tcx: 'a, T: Iterator>( + cx: &LateContext<'a, 'tcx>, + func: &'tcx FnDecl, + named_lts: &'tcx [LifetimeDef], + bounds_lts: T +) -> bool { // There are two scenarios where elision works: // * no output references, all input references have different LT // * output references, exactly one input reference with same LT diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 3a7012972ba..9a3defec72d 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -402,8 +402,13 @@ fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { } } -fn check_for_loop<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat, arg: &'tcx Expr, body: &'tcx Expr, - expr: &'tcx Expr) { +fn check_for_loop<'a, 'tcx>( + cx: &LateContext<'a, 'tcx>, + pat: &'tcx Pat, + arg: &'tcx Expr, + body: &'tcx Expr, + expr: &'tcx Expr +) { check_for_loop_range(cx, pat, arg, body, expr); check_for_loop_reverse_range(cx, arg, expr); check_for_loop_arg(cx, pat, arg, expr); @@ -413,8 +418,13 @@ fn check_for_loop<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat, arg: &'t /// Check for looping over a range and then indexing a sequence with it. /// The iteratee must be a range literal. -fn check_for_loop_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat, arg: &'tcx Expr, body: &'tcx Expr, - expr: &'tcx Expr) { +fn check_for_loop_range<'a, 'tcx>( + cx: &LateContext<'a, 'tcx>, + pat: &'tcx Pat, + arg: &'tcx Expr, + body: &'tcx Expr, + expr: &'tcx Expr +) { if let Some(higher::Range { start: Some(start), ref end, limits }) = higher::range(arg) { // the var must be a single name if let PatKind::Binding(_, def_id, ref ident, _) = pat.node { @@ -641,8 +651,12 @@ fn check_arg_type(cx: &LateContext, pat: &Pat, arg: &Expr) { } } -fn check_for_loop_explicit_counter<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &'tcx Expr, body: &'tcx Expr, - expr: &'tcx Expr) { +fn check_for_loop_explicit_counter<'a, 'tcx>( + cx: &LateContext<'a, 'tcx>, + arg: &'tcx Expr, + body: &'tcx Expr, + expr: &'tcx Expr +) { // Look for variables that are incremented once per loop iteration. let mut visitor = IncrementVisitor { cx: cx, @@ -687,8 +701,13 @@ fn check_for_loop_explicit_counter<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &' } /// Check for the `FOR_KV_MAP` lint. -fn check_for_loop_over_map_kv<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat, arg: &'tcx Expr, - body: &'tcx Expr, expr: &'tcx Expr) { +fn check_for_loop_over_map_kv<'a, 'tcx>( + cx: &LateContext<'a, 'tcx>, + pat: &'tcx Pat, + arg: &'tcx Expr, + body: &'tcx Expr, + expr: &'tcx Expr +) { let pat_span = pat.span; if let PatKind::Tuple(ref pat, _) = pat.node { diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index b1b52cfb015..978e9f5a029 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -196,7 +196,14 @@ fn check_single_match_single_pattern(cx: &LateContext, ex: &Expr, arms: &[Arm], } } -fn check_single_match_opt_like(cx: &LateContext, ex: &Expr, arms: &[Arm], expr: &Expr, ty: ty::Ty, els: Option<&Expr>) { +fn check_single_match_opt_like( + cx: &LateContext, + ex: &Expr, + arms: &[Arm], + expr: &Expr, + ty: ty::Ty, + els: Option<&Expr> +) { // list of candidate Enums we know will never get any more members let candidates = &[(&paths::COW, "Borrowed"), (&paths::COW, "Cow::Borrowed"), diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index ebb90c9eef0..591b395fe70 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -696,7 +696,12 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, implitem: &'tcx hir::I fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir::Expr]) { /// Check for `unwrap_or(T::new())` or `unwrap_or(T::default())`. fn check_unwrap_or_default( - cx: &LateContext, name: &str, fun: &hir::Expr, self_expr: &hir::Expr, arg: &hir::Expr, or_has_args: bool, + cx: &LateContext, + name: &str, + fun: &hir::Expr, + self_expr: &hir::Expr, + arg: &hir::Expr, + or_has_args: bool, span: Span ) -> bool { if or_has_args { @@ -737,7 +742,12 @@ fn check_unwrap_or_default( /// Check for `*or(foo())`. fn check_general_case( - cx: &LateContext, name: &str, fun: &hir::Expr, self_expr: &hir::Expr, arg: &hir::Expr, or_has_args: bool, + cx: &LateContext, + name: &str, + fun: &hir::Expr, + self_expr: &hir::Expr, + arg: &hir::Expr, + or_has_args: bool, span: Span ) { // don't lint for constant values @@ -1157,8 +1167,13 @@ fn lint_filter_map_flat_map(cx: &LateContext, expr: &hir::Expr, _filter_args: &[ } /// lint searching an Iterator followed by `is_some()` -fn lint_search_is_some(cx: &LateContext, expr: &hir::Expr, search_method: &str, search_args: &[hir::Expr], - is_some_args: &[hir::Expr]) { +fn lint_search_is_some( + cx: &LateContext, + expr: &hir::Expr, + search_method: &str, + search_args: &[hir::Expr], + is_some_args: &[hir::Expr] +) { // lint if caller of search is an Iterator if match_trait_method(cx, &is_some_args[0], &paths::ITERATOR) { let msg = format!("called `is_some()` after searching an `Iterator` with {}. This is more succinctly \ diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index f796207a223..409a7de86f0 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -170,8 +170,15 @@ fn get_lints(&self) -> LintArray { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { - fn check_fn(&mut self, cx: &LateContext<'a, 'tcx>, k: FnKind<'tcx>, decl: &'tcx FnDecl, _: &'tcx Expr, _: Span, - _: NodeId) { + fn check_fn( + &mut self, + cx: &LateContext<'a, 'tcx>, + k: FnKind<'tcx>, + decl: &'tcx FnDecl, + _: &'tcx Expr, + _: Span, + _: NodeId + ) { if let FnKind::Closure(_) = k { // Does not apply to closures return; diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 2a75a19dd28..9c7b132dd3d 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -91,8 +91,13 @@ fn get_lints(&self) -> LintArray { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault { fn check_fn( - &mut self, cx: &LateContext<'a, 'tcx>, kind: FnKind<'tcx>, decl: &'tcx hir::FnDecl, _: &'tcx hir::Expr, - span: Span, id: ast::NodeId + &mut self, + cx: &LateContext<'a, 'tcx>, + kind: FnKind<'tcx>, + decl: &'tcx hir::FnDecl, + _: &'tcx hir::Expr, + span: Span, + id: ast::NodeId ) { if in_external_macro(cx, span) { return; diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index 36fd33b22ce..9c5b032f625 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -80,8 +80,15 @@ fn get_lints(&self) -> LintArray { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { - fn check_fn(&mut self, cx: &LateContext<'a, 'tcx>, _: FnKind<'tcx>, decl: &'tcx FnDecl, expr: &'tcx Expr, - _: Span, _: NodeId) { + fn check_fn( + &mut self, + cx: &LateContext<'a, 'tcx>, + _: FnKind<'tcx>, + decl: &'tcx FnDecl, + expr: &'tcx Expr, + _: Span, + _: NodeId + ) { if in_external_macro(cx, expr.span) { return; } @@ -143,8 +150,13 @@ fn is_binding(cx: &LateContext, pat_id: NodeId) -> bool { } } -fn check_pat<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat, init: Option<&'tcx Expr>, span: Span, - bindings: &mut Vec<(Name, Span)>) { +fn check_pat<'a, 'tcx>( + cx: &LateContext<'a, 'tcx>, + pat: &'tcx Pat, + init: Option<&'tcx Expr>, + span: Span, + bindings: &mut Vec<(Name, Span)> +) { // TODO: match more stuff / destructuring match pat.node { PatKind::Binding(_, _, ref ident, ref inner) => { @@ -222,8 +234,14 @@ fn check_pat<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat, init: Option< } } -fn lint_shadow<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, name: Name, span: Span, pattern_span: Span, - init: Option<&'tcx Expr>, prev_span: Span) { +fn lint_shadow<'a, 'tcx: 'a>( + cx: &LateContext<'a, 'tcx>, + name: Name, + span: Span, + pattern_span: Span, + init: Option<&'tcx Expr>, + prev_span: Span +) { if let Some(expr) = init { if is_self_shadow(name, expr) { span_lint_and_then(cx, diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index e3a9758d2b7..89bc46074fd 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -528,8 +528,15 @@ fn get_lints(&self) -> LintArray { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexityPass { - fn check_fn(&mut self, cx: &LateContext<'a, 'tcx>, _: FnKind<'tcx>, decl: &'tcx FnDecl, _: &'tcx Expr, _: Span, - _: NodeId) { + fn check_fn( + &mut self, + cx: &LateContext<'a, 'tcx>, + _: FnKind<'tcx>, + decl: &'tcx FnDecl, + _: &'tcx Expr, + _: Span, + _: NodeId + ) { self.check_fndecl(cx, decl); } @@ -740,8 +747,12 @@ enum AbsurdComparisonResult { -fn detect_absurd_comparison<'a>(cx: &LateContext, op: BinOp_, lhs: &'a Expr, rhs: &'a Expr) - -> Option<(ExtremeExpr<'a>, AbsurdComparisonResult)> { +fn detect_absurd_comparison<'a>( + cx: &LateContext, + op: BinOp_, + lhs: &'a Expr, + rhs: &'a Expr +) -> Option<(ExtremeExpr<'a>, AbsurdComparisonResult)> { use types::ExtremeType::*; use types::AbsurdComparisonResult::*; use utils::comparisons::*; @@ -1008,8 +1019,13 @@ fn err_upcast_comparison(cx: &LateContext, span: &Span, expr: &Expr, always: boo } fn upcast_comparison_bounds_err( - cx: &LateContext, span: &Span, rel: comparisons::Rel, lhs_bounds: Option<(FullInt, FullInt)>, lhs: &Expr, - rhs: &Expr, invert: bool + cx: &LateContext, + span: &Span, + rel: comparisons::Rel, + lhs_bounds: Option<(FullInt, FullInt)>, + lhs: &Expr, + rhs: &Expr, + invert: bool ) { use utils::comparisons::*; diff --git a/clippy_lints/src/unused_label.rs b/clippy_lints/src/unused_label.rs index ebb7735171e..9017fd6933e 100644 --- a/clippy_lints/src/unused_label.rs +++ b/clippy_lints/src/unused_label.rs @@ -42,8 +42,13 @@ fn get_lints(&self) -> LintArray { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedLabel { fn check_fn( - &mut self, cx: &LateContext<'a, 'tcx>, kind: FnKind<'tcx>, decl: &'tcx hir::FnDecl, body: &'tcx hir::Expr, - span: Span, fn_id: ast::NodeId + &mut self, + cx: &LateContext<'a, 'tcx>, + kind: FnKind<'tcx>, + decl: &'tcx hir::FnDecl, + body: &'tcx hir::Expr, + span: Span, + fn_id: ast::NodeId ) { if in_macro(cx, span) { return; diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index dc25020d3fc..77b33d7b589 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -317,8 +317,12 @@ pub fn get_trait_def_id(cx: &LateContext, path: &[&str]) -> Option { /// Check whether a type implements a trait. /// See also `get_trait_def_id`. -pub fn implements_trait<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>, trait_id: DefId, ty_params: Vec>) - -> bool { +pub fn implements_trait<'a, 'tcx>( + cx: &LateContext<'a, 'tcx>, + ty: ty::Ty<'tcx>, + trait_id: DefId, + ty_params: Vec> +) -> bool { cx.tcx.populate_implementations_for_trait_if_necessary(trait_id); let ty = cx.tcx.erase_regions(&ty); @@ -401,8 +405,12 @@ pub fn snippet_block<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &' /// Like `snippet_block`, but add braces if the expr is not an `ExprBlock`. /// Also takes an `Option` which can be put inside the braces. -pub fn expr_block<'a, 'b, T: LintContext<'b>>(cx: &T, expr: &Expr, option: Option, default: &'a str) - -> Cow<'a, str> { +pub fn expr_block<'a, 'b, T: LintContext<'b>>( + cx: &T, + expr: &Expr, + option: Option, + default: &'a str +) -> Cow<'a, str> { let code = snippet_block(cx, expr.span, default); let string = option.unwrap_or_default(); if let ExprBlock(_) = expr.node { @@ -515,8 +523,13 @@ pub fn span_lint<'a, T: LintContext<'a>>(cx: &T, lint: &'static Lint, sp: Span, } } -pub fn span_help_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(cx: &'a T, lint: &'static Lint, span: Span, msg: &str, - help: &str) { +pub fn span_help_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>( + cx: &'a T, + lint: &'static Lint, + span: Span, + msg: &str, + help: &str +) { let mut db = DiagnosticWrapper(cx.struct_span_lint(lint, span, msg)); if cx.current_level(lint) != Level::Allow { db.0.help(help); @@ -524,8 +537,14 @@ pub fn span_help_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(cx: &'a T, lint: & } } -pub fn span_note_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(cx: &'a T, lint: &'static Lint, span: Span, msg: &str, - note_span: Span, note: &str) { +pub fn span_note_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>( + cx: &'a T, + lint: &'static Lint, + span: Span, + msg: &str, + note_span: Span, + note: &str +) { let mut db = DiagnosticWrapper(cx.struct_span_lint(lint, span, msg)); if cx.current_level(lint) != Level::Allow { if note_span == span { @@ -537,9 +556,13 @@ pub fn span_note_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(cx: &'a T, lint: & } } -pub fn span_lint_and_then<'a, 'tcx: 'a, T: LintContext<'tcx>, F>(cx: &'a T, lint: &'static Lint, sp: Span, msg: &str, - f: F) - where F: for<'b> FnOnce(&mut DiagnosticBuilder<'b>) +pub fn span_lint_and_then<'a, 'tcx: 'a, T: LintContext<'tcx>, F>( + cx: &'a T, + lint: &'static Lint, + sp: Span, + msg: &str, + f: F +) where F: for<'b> FnOnce(&mut DiagnosticBuilder<'b>) { let mut db = DiagnosticWrapper(cx.struct_span_lint(lint, sp, msg)); if cx.current_level(lint) != Level::Allow { @@ -756,8 +779,12 @@ pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> ty::T /// Check if two types are the same. // FIXME: this works correctly for lifetimes bounds (`for <'a> Foo<'a>` == `for <'b> Foo<'b>` but // not for type parameters. -pub fn same_tys<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, a: ty::Ty<'tcx>, b: ty::Ty<'tcx>, parameter_item: NodeId) - -> bool { +pub fn same_tys<'a, 'tcx>( + cx: &LateContext<'a, 'tcx>, + a: ty::Ty<'tcx>, + b: ty::Ty<'tcx>, + parameter_item: NodeId +) -> bool { let parameter_env = ty::ParameterEnvironment::for_item(cx.tcx, parameter_item); cx.tcx.infer_ctxt(None, Some(parameter_env), Reveal::All).enter(|infcx| { let new_a = a.subst(infcx.tcx, infcx.parameter_environment.free_substs); diff --git a/rustfmt.toml b/rustfmt.toml index 0d8362496c1..18d146d4917 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,8 +1,6 @@ max_width = 120 ideal_width = 100 -fn_args_density = "Compressed" fn_call_width = 80 -fn_args_paren_newline = false match_block_trailing_comma = true fn_args_layout = "Block" closure_block_indent_threshold = 0