Skip to content

Commit

Permalink
Include const generic type bounds in their spans
Browse files Browse the repository at this point in the history
Closes #4310
  • Loading branch information
ayazhafiz authored and calebcartwright committed Jul 7, 2020
1 parent 37ec56d commit 8e8db1f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/formatting/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2263,11 +2263,10 @@ fn rewrite_fn_base(

// Skip `pub(crate)`.
let lo_after_visibility = get_bytepos_after_visibility(&fn_sig.visibility, span);
// A conservative estimation, to goal is to be over all parens in generics
// A conservative estimation, the goal is to be over all parens in generics
let params_start = fn_sig
.generics
.params
.iter()
.last()
.map_or(lo_after_visibility, |param| param.span().hi());
let params_end = if fd.inputs.is_empty() {
Expand Down
3 changes: 2 additions & 1 deletion src/formatting/spanned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ impl Spanned for ast::GenericParam {
};
let ty_hi = if let ast::GenericParamKind::Type {
default: Some(ref ty),
} = self.kind
}
| ast::GenericParamKind::Const { ref ty, .. } = self.kind
{
ty.span().hi()
} else {
Expand Down
9 changes: 9 additions & 0 deletions tests/target/issue-4310.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![feature(const_generics)]

fn foo<
const N: [u8; {
struct Inner<'a>(&'a ());
3
}],
>() {
}

0 comments on commit 8e8db1f

Please sign in to comment.