about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-08-15 20:11:35 +0200
committerGitHub <noreply@github.com>2022-08-15 20:11:35 +0200
commite369ec871e7194ea3f97704651f08edd974c1135 (patch)
treeb1f1a4379634ecd230655296809e9038cf9350b7
parent3aa5734a2cf8d401ec7d194c87978f4a1231bb9d (diff)
parent9b0edd099dfe01b7e69140562cca3fe72ed445e9 (diff)
downloadrust-e369ec871e7194ea3f97704651f08edd974c1135.tar.gz
rust-e369ec871e7194ea3f97704651f08edd974c1135.zip
Rollup merge of #100458 - compiler-errors:fn-argument-span, r=estebank
Adjust span of fn argument declaration

Span of a fn argument declaration goes from:

```
fn foo(i : i32 , ...)
       ^^^^^^^^
```

to:

```
fn foo(i : i32 , ...)
       ^^^^^^^
```

That is, we don't include the extra spacing up to the trailing comma, which I think is more correct.

cc https://github.com/rust-lang/rust/pull/99646#discussion_r944568074
r? ``@estebank``

---

The two tests that had dramatic changes in their rendering I think actually are improved, though they are kinda poor spans both before and after the changes. :shrug: Thoughts?
-rw-r--r--compiler/rustc_parse/src/parser/item.rs2
-rw-r--r--src/test/ui/argument-suggestions/complex.stderr2
-rw-r--r--src/test/ui/c-variadic/issue-86053-1.stderr6
-rw-r--r--src/test/ui/suggestions/suggest-ref-macro.stderr10
-rw-r--r--src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr16
5 files changed, 15 insertions, 21 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs
index 81d0e4733d0..f3f070e6eb0 100644
--- a/compiler/rustc_parse/src/parser/item.rs
+++ b/compiler/rustc_parse/src/parser/item.rs
@@ -2338,7 +2338,7 @@ impl<'a> Parser<'a> {
                 }
             };
 
-            let span = lo.until(this.token.span);
+            let span = lo.to(this.prev_token.span);
 
             Ok((
                 Param {
diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr
index fa030a8f49d..bf49e744458 100644
--- a/src/test/ui/argument-suggestions/complex.stderr
+++ b/src/test/ui/argument-suggestions/complex.stderr
@@ -8,7 +8,7 @@ note: function defined here
   --> $DIR/complex.rs:11:4
    |
 LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {}
-   |    ^^^^^^^ -------  --------  -----  -----  -----  -----  -----  ------
+   |    ^^^^^^^ -------  --------  -----  -----  -----  -----  -----  -----
 help: did you mean
    |
 LL |   complex(/* u32 */, &"", /* E */, F::X2, G{}, X {}, Y {}, Z {});
diff --git a/src/test/ui/c-variadic/issue-86053-1.stderr b/src/test/ui/c-variadic/issue-86053-1.stderr
index 5d119bb8557..60b379faf4e 100644
--- a/src/test/ui/c-variadic/issue-86053-1.stderr
+++ b/src/test/ui/c-variadic/issue-86053-1.stderr
@@ -44,19 +44,19 @@ error: `...` must be the last argument of a C-variadic function
   --> $DIR/issue-86053-1.rs:11:12
    |
 LL |     self , ... ,   self ,   self , ... ) where F : FnOnce ( & 'a & 'b usize ) {
-   |            ^^^^
+   |            ^^^
 
 error: only foreign or `unsafe extern "C"` functions may be C-variadic
   --> $DIR/issue-86053-1.rs:11:12
    |
 LL |     self , ... ,   self ,   self , ... ) where F : FnOnce ( & 'a & 'b usize ) {
-   |            ^^^^
+   |            ^^^
 
 error: only foreign or `unsafe extern "C"` functions may be C-variadic
   --> $DIR/issue-86053-1.rs:11:36
    |
 LL |     self , ... ,   self ,   self , ... ) where F : FnOnce ( & 'a & 'b usize ) {
-   |                                    ^^^^
+   |                                    ^^^
 
 error[E0412]: cannot find type `F` in this scope
   --> $DIR/issue-86053-1.rs:11:48
diff --git a/src/test/ui/suggestions/suggest-ref-macro.stderr b/src/test/ui/suggestions/suggest-ref-macro.stderr
index 84cbc93571a..17de49fbd84 100644
--- a/src/test/ui/suggestions/suggest-ref-macro.stderr
+++ b/src/test/ui/suggestions/suggest-ref-macro.stderr
@@ -10,14 +10,8 @@ LL | #[hello]
 note: function defined here
   --> $DIR/suggest-ref-macro.rs:8:1
    |
-LL |   #[hello]
-   |  _-^^^^^^^
-LL | | fn abc() {}
-LL | |
-LL | | fn x(_: &mut i32) {}
-LL | |
-LL | | macro_rules! bla {
-   | |_____________-
+LL | #[hello]
+   | ^^^^^^^^
    = note: this error originates in the attribute macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0308]: mismatched types
diff --git a/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr b/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr
index 615fd2ccb04..847bc517ea3 100644
--- a/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr
+++ b/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr
@@ -1,13 +1,13 @@
 error: function can not have more than 65535 arguments
-  --> $DIR/issue-88577-check-fn-with-more-than-65535-arguments.rs:6:24
+  --> $DIR/issue-88577-check-fn-with-more-than-65535-arguments.rs:6:22
    |
-LL |           fn _f($($t: ()),*) {}
-   |  ________________________^
-LL | |     }
-LL | | }
-LL | |
-LL | | many_args!{[_]########## ######}
-   | |____________^
+LL |         fn _f($($t: ()),*) {}
+   |                      ^
+...
+LL | many_args!{[_]########## ######}
+   | -------------------------------- in this macro invocation
+   |
+   = note: this error originates in the macro `many_args` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error