Skip to content

Commit decd13a

Browse files
committed
Include const generic type bounds in their spans
Closes rust-lang#4310
1 parent 37ec56d commit decd13a

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

Diff for: src/formatting/items.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2263,11 +2263,10 @@ fn rewrite_fn_base(
22632263

22642264
// Skip `pub(crate)`.
22652265
let lo_after_visibility = get_bytepos_after_visibility(&fn_sig.visibility, span);
2266-
// A conservative estimation, to goal is to be over all parens in generics
2266+
// A conservative estimation, the goal is to be over all parens in generics
22672267
let params_start = fn_sig
22682268
.generics
22692269
.params
2270-
.iter()
22712270
.last()
22722271
.map_or(lo_after_visibility, |param| param.span().hi());
22732272
let params_end = if fd.inputs.is_empty() {

Diff for: src/formatting/spanned.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ impl Spanned for ast::GenericParam {
131131
};
132132
let ty_hi = if let ast::GenericParamKind::Type {
133133
default: Some(ref ty),
134-
} = self.kind
134+
}
135+
| ast::GenericParamKind::Const { ref ty, .. } = self.kind
135136
{
136137
ty.span().hi()
137138
} else {

Diff for: tests/target/issue-4310.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(const_generics)]
2+
3+
fn foo<
4+
const N: [u8; {
5+
struct Inner<'a>(&'a ());
6+
3
7+
}],
8+
>() {
9+
}

0 commit comments

Comments
 (0)