Merge pull request #2083 from topecongiro/issue-2082

Use a correct span for fn with pub(crate) syntax
This commit is contained in:
Nick Cameron 2017-10-27 02:14:29 +05:30 committed by GitHub
commit 038f711c6e
3 changed files with 13 additions and 1 deletions

View File

@ -1771,12 +1771,18 @@ fn rewrite_fn_base(
result.push(' ')
}
// Skip `pub(crate)`.
let lo_after_visibility = if let ast::Visibility::Crate(s) = fn_sig.visibility {
context.codemap.span_after(mk_sp(s.hi(), span.hi()), ")")
} else {
span.lo()
};
// A conservative estimation, to goal is to be over all parens in generics
let args_start = fn_sig
.generics
.ty_params
.last()
.map_or(span.lo(), |tp| end_typaram(tp));
.map_or(lo_after_visibility, |tp| end_typaram(tp));
let args_end = if fd.inputs.is_empty() {
context
.codemap

View File

@ -59,3 +59,6 @@ mod foo {
foo();
}
}
// #2082
pub(crate) fn init() {}

View File

@ -101,3 +101,6 @@ mod foo {
foo();
}
}
// #2082
pub(crate) fn init() {}