about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAyaz Hafiz <ayaz.hafiz.1@gmail.com>2020-07-07 07:31:09 -0700
committerCaleb Cartwright <calebcartwright@users.noreply.github.com>2021-01-27 18:50:03 -0600
commitf8deed3a3a1431bc40e7f9165c30de11ca9d2532 (patch)
tree9cf36ef2e6dd3f8d725e8ea5439d4974c1e4f851
parent152ccb505958ec0e7f60204d786cc126bc571121 (diff)
downloadrust-f8deed3a3a1431bc40e7f9165c30de11ca9d2532.tar.gz
rust-f8deed3a3a1431bc40e7f9165c30de11ca9d2532.zip
Include const generic type bounds in their spans
Closes #4310
-rw-r--r--src/items.rs3
-rw-r--r--src/spanned.rs3
-rw-r--r--tests/target/issue-4310.rs9
3 files changed, 12 insertions, 3 deletions
diff --git a/src/items.rs b/src/items.rs
index 70cd7faad8b..f1d191783c9 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -2217,11 +2217,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() {
diff --git a/src/spanned.rs b/src/spanned.rs
index 9e3658dd22f..1f6d0023e68 100644
--- a/src/spanned.rs
+++ b/src/spanned.rs
@@ -132,7 +132,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 {
diff --git a/tests/target/issue-4310.rs b/tests/target/issue-4310.rs
new file mode 100644
index 00000000000..6cf494fc5b8
--- /dev/null
+++ b/tests/target/issue-4310.rs
@@ -0,0 +1,9 @@
+#![feature(const_generics)]
+
+fn foo<
+    const N: [u8; {
+        struct Inner<'a>(&'a ());
+        3
+    }],
+>() {
+}