Skip to content

Commit

Permalink
Merge pull request rust-lang#5121 from calebcartwright/subtree-sync-2…
Browse files Browse the repository at this point in the history
…021-12-02

subtree sync
  • Loading branch information
calebcartwright authored Dec 3, 2021
2 parents ec46ffd + e305322 commit 8da8371
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2219,26 +2219,18 @@ fn rewrite_fn_base(
result.push_str(&param_indent.to_string_with_newline(context.config));
}

// Skip `pub(crate)`.
let lo_after_visibility = get_bytepos_after_visibility(fn_sig.visibility, span);
// A conservative estimation, the goal is to be over all parens in generics
let params_start = fn_sig
.generics
.params
.last()
.map_or(lo_after_visibility, |param| param.span().hi());
let params_end = if fd.inputs.is_empty() {
context
.snippet_provider
.span_after(mk_sp(params_start, span.hi()), ")")
.span_after(mk_sp(fn_sig.generics.span.hi(), span.hi()), ")")
} else {
let last_span = mk_sp(fd.inputs[fd.inputs.len() - 1].span().hi(), span.hi());
context.snippet_provider.span_after(last_span, ")")
};
let params_span = mk_sp(
context
.snippet_provider
.span_after(mk_sp(params_start, span.hi()), "("),
.span_after(mk_sp(fn_sig.generics.span.hi(), span.hi()), "("),
params_end,
);
let param_str = rewrite_params(
Expand Down

0 comments on commit 8da8371

Please sign in to comment.