Skip to content

Commit e369ec8

Browse files
authored
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 #99646 (comment) 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. 🤷 Thoughts?
2 parents 3aa5734 + 9b0edd0 commit e369ec8

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

compiler/rustc_parse/src/parser/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2338,7 +2338,7 @@ impl<'a> Parser<'a> {
23382338
}
23392339
};
23402340

2341-
let span = lo.until(this.token.span);
2341+
let span = lo.to(this.prev_token.span);
23422342

23432343
Ok((
23442344
Param {

src/test/ui/argument-suggestions/complex.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ note: function defined here
88
--> $DIR/complex.rs:11:4
99
|
1010
LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {}
11-
| ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ------
11+
| ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- -----
1212
help: did you mean
1313
|
1414
LL | complex(/* u32 */, &"", /* E */, F::X2, G{}, X {}, Y {}, Z {});

src/test/ui/c-variadic/issue-86053-1.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ error: `...` must be the last argument of a C-variadic function
4444
--> $DIR/issue-86053-1.rs:11:12
4545
|
4646
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) {
47-
| ^^^^
47+
| ^^^
4848

4949
error: only foreign or `unsafe extern "C"` functions may be C-variadic
5050
--> $DIR/issue-86053-1.rs:11:12
5151
|
5252
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) {
53-
| ^^^^
53+
| ^^^
5454

5555
error: only foreign or `unsafe extern "C"` functions may be C-variadic
5656
--> $DIR/issue-86053-1.rs:11:36
5757
|
5858
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) {
59-
| ^^^^
59+
| ^^^
6060

6161
error[E0412]: cannot find type `F` in this scope
6262
--> $DIR/issue-86053-1.rs:11:48

src/test/ui/suggestions/suggest-ref-macro.stderr

+2-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,8 @@ LL | #[hello]
1010
note: function defined here
1111
--> $DIR/suggest-ref-macro.rs:8:1
1212
|
13-
LL | #[hello]
14-
| _-^^^^^^^
15-
LL | | fn abc() {}
16-
LL | |
17-
LL | | fn x(_: &mut i32) {}
18-
LL | |
19-
LL | | macro_rules! bla {
20-
| |_____________-
13+
LL | #[hello]
14+
| ^^^^^^^^
2115
= note: this error originates in the attribute macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
2216

2317
error[E0308]: mismatched types
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: function can not have more than 65535 arguments
2-
--> $DIR/issue-88577-check-fn-with-more-than-65535-arguments.rs:6:24
2+
--> $DIR/issue-88577-check-fn-with-more-than-65535-arguments.rs:6:22
33
|
4-
LL | fn _f($($t: ()),*) {}
5-
| ________________________^
6-
LL | | }
7-
LL | | }
8-
LL | |
9-
LL | | many_args!{[_]########## ######}
10-
| |____________^
4+
LL | fn _f($($t: ()),*) {}
5+
| ^
6+
...
7+
LL | many_args!{[_]########## ######}
8+
| -------------------------------- in this macro invocation
9+
|
10+
= note: this error originates in the macro `many_args` (in Nightly builds, run with -Z macro-backtrace for more info)
1111

1212
error: aborting due to previous error
1313

0 commit comments

Comments
 (0)