Skip to content

Commit 7a55709

Browse files
committed
Fix the span of trait bound modifier [const]
1 parent 7ba34c7 commit 7a55709

9 files changed

+73
-73
lines changed

compiler/rustc_parse/src/parser/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ impl<'a> Parser<'a> {
10711071
&& self.look_ahead(1, |t| t.is_keyword(kw::Const))
10721072
&& self.look_ahead(2, |t| *t == token::CloseBracket)
10731073
{
1074-
let start = self.prev_token.span;
1074+
let start = self.token.span;
10751075
self.bump();
10761076
self.expect_keyword(exp!(Const)).unwrap();
10771077
self.bump();

tests/ui/traits/const-traits/feature-gate.stock.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ LL | impl const T for S {}
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

1111
error[E0658]: const trait impls are experimental
12-
--> $DIR/feature-gate.rs:13:13
12+
--> $DIR/feature-gate.rs:13:15
1313
|
1414
LL | const fn f<A: [const] T>() {}
15-
| ^^^^^^^^^
15+
| ^^^^^^^
1616
|
1717
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
1818
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
@@ -29,10 +29,10 @@ LL | fn g<A: const T>() {}
2929
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
3030

3131
error[E0658]: const trait impls are experimental
32-
--> $DIR/feature-gate.rs:18:12
32+
--> $DIR/feature-gate.rs:18:17
3333
|
3434
LL | discard! { impl [const] T }
35-
| ^^^^^^^^^^^^
35+
| ^^^^^^^
3636
|
3737
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
3838
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable

tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: `[const]` is not allowed here
2-
--> $DIR/super-traits-fail-3.rs:23:10
2+
--> $DIR/super-traits-fail-3.rs:23:12
33
|
44
LL | trait Bar: [const] Foo {}
5-
| ^^^^^^^^^
5+
| ^^^^^^^
66
|
77
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
88
--> $DIR/super-traits-fail-3.rs:23:1
@@ -11,41 +11,41 @@ LL | trait Bar: [const] Foo {}
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error[E0658]: const trait impls are experimental
14-
--> $DIR/super-traits-fail-3.rs:23:10
14+
--> $DIR/super-traits-fail-3.rs:23:12
1515
|
1616
LL | trait Bar: [const] Foo {}
17-
| ^^^^^^^^^
17+
| ^^^^^^^
1818
|
1919
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
2020
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
2121
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2222

2323
error[E0658]: const trait impls are experimental
24-
--> $DIR/super-traits-fail-3.rs:32:15
24+
--> $DIR/super-traits-fail-3.rs:32:17
2525
|
2626
LL | const fn foo<T: [const] Bar>(x: &T) {
27-
| ^^^^^^^^^
27+
| ^^^^^^^
2828
|
2929
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
3030
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
3131
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
3232

3333
error: `[const]` can only be applied to `#[const_trait]` traits
34-
--> $DIR/super-traits-fail-3.rs:23:10
34+
--> $DIR/super-traits-fail-3.rs:23:12
3535
|
3636
LL | trait Bar: [const] Foo {}
37-
| ^^^^^^^^^ can't be applied to `Foo`
37+
| ^^^^^^^ can't be applied to `Foo`
3838
|
3939
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
4040
|
4141
LL | #[const_trait] trait Foo {
4242
| ++++++++++++++
4343

4444
error: `[const]` can only be applied to `#[const_trait]` traits
45-
--> $DIR/super-traits-fail-3.rs:23:10
45+
--> $DIR/super-traits-fail-3.rs:23:12
4646
|
4747
LL | trait Bar: [const] Foo {}
48-
| ^^^^^^^^^ can't be applied to `Foo`
48+
| ^^^^^^^ can't be applied to `Foo`
4949
|
5050
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
5151
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
@@ -54,10 +54,10 @@ LL | #[const_trait] trait Foo {
5454
| ++++++++++++++
5555

5656
error: `[const]` can only be applied to `#[const_trait]` traits
57-
--> $DIR/super-traits-fail-3.rs:23:10
57+
--> $DIR/super-traits-fail-3.rs:23:12
5858
|
5959
LL | trait Bar: [const] Foo {}
60-
| ^^^^^^^^^ can't be applied to `Foo`
60+
| ^^^^^^^ can't be applied to `Foo`
6161
|
6262
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
6363
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
@@ -66,21 +66,21 @@ LL | #[const_trait] trait Foo {
6666
| ++++++++++++++
6767

6868
error: `[const]` can only be applied to `#[const_trait]` traits
69-
--> $DIR/super-traits-fail-3.rs:32:15
69+
--> $DIR/super-traits-fail-3.rs:32:17
7070
|
7171
LL | const fn foo<T: [const] Bar>(x: &T) {
72-
| ^^^^^^^^^ can't be applied to `Bar`
72+
| ^^^^^^^ can't be applied to `Bar`
7373
|
7474
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
7575
|
7676
LL | #[const_trait] trait Bar: [const] Foo {}
7777
| ++++++++++++++
7878

7979
error: `[const]` can only be applied to `#[const_trait]` traits
80-
--> $DIR/super-traits-fail-3.rs:32:15
80+
--> $DIR/super-traits-fail-3.rs:32:17
8181
|
8282
LL | const fn foo<T: [const] Bar>(x: &T) {
83-
| ^^^^^^^^^ can't be applied to `Bar`
83+
| ^^^^^^^ can't be applied to `Bar`
8484
|
8585
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
8686
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations

tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: `[const]` is not allowed here
2-
--> $DIR/super-traits-fail-3.rs:23:10
2+
--> $DIR/super-traits-fail-3.rs:23:12
33
|
44
LL | trait Bar: [const] Foo {}
5-
| ^^^^^^^^^
5+
| ^^^^^^^
66
|
77
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
88
--> $DIR/super-traits-fail-3.rs:23:1
@@ -11,41 +11,41 @@ LL | trait Bar: [const] Foo {}
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error[E0658]: const trait impls are experimental
14-
--> $DIR/super-traits-fail-3.rs:23:10
14+
--> $DIR/super-traits-fail-3.rs:23:12
1515
|
1616
LL | trait Bar: [const] Foo {}
17-
| ^^^^^^^^^
17+
| ^^^^^^^
1818
|
1919
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
2020
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
2121
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2222

2323
error[E0658]: const trait impls are experimental
24-
--> $DIR/super-traits-fail-3.rs:32:15
24+
--> $DIR/super-traits-fail-3.rs:32:17
2525
|
2626
LL | const fn foo<T: [const] Bar>(x: &T) {
27-
| ^^^^^^^^^
27+
| ^^^^^^^
2828
|
2929
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
3030
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
3131
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
3232

3333
error: `[const]` can only be applied to `#[const_trait]` traits
34-
--> $DIR/super-traits-fail-3.rs:23:10
34+
--> $DIR/super-traits-fail-3.rs:23:12
3535
|
3636
LL | trait Bar: [const] Foo {}
37-
| ^^^^^^^^^ can't be applied to `Foo`
37+
| ^^^^^^^ can't be applied to `Foo`
3838
|
3939
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
4040
|
4141
LL | #[const_trait] trait Foo {
4242
| ++++++++++++++
4343

4444
error: `[const]` can only be applied to `#[const_trait]` traits
45-
--> $DIR/super-traits-fail-3.rs:23:10
45+
--> $DIR/super-traits-fail-3.rs:23:12
4646
|
4747
LL | trait Bar: [const] Foo {}
48-
| ^^^^^^^^^ can't be applied to `Foo`
48+
| ^^^^^^^ can't be applied to `Foo`
4949
|
5050
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
5151
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
@@ -54,10 +54,10 @@ LL | #[const_trait] trait Foo {
5454
| ++++++++++++++
5555

5656
error: `[const]` can only be applied to `#[const_trait]` traits
57-
--> $DIR/super-traits-fail-3.rs:23:10
57+
--> $DIR/super-traits-fail-3.rs:23:12
5858
|
5959
LL | trait Bar: [const] Foo {}
60-
| ^^^^^^^^^ can't be applied to `Foo`
60+
| ^^^^^^^ can't be applied to `Foo`
6161
|
6262
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
6363
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
@@ -66,21 +66,21 @@ LL | #[const_trait] trait Foo {
6666
| ++++++++++++++
6767

6868
error: `[const]` can only be applied to `#[const_trait]` traits
69-
--> $DIR/super-traits-fail-3.rs:32:15
69+
--> $DIR/super-traits-fail-3.rs:32:17
7070
|
7171
LL | const fn foo<T: [const] Bar>(x: &T) {
72-
| ^^^^^^^^^ can't be applied to `Bar`
72+
| ^^^^^^^ can't be applied to `Bar`
7373
|
7474
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
7575
|
7676
LL | #[const_trait] trait Bar: [const] Foo {}
7777
| ++++++++++++++
7878

7979
error: `[const]` can only be applied to `#[const_trait]` traits
80-
--> $DIR/super-traits-fail-3.rs:32:15
80+
--> $DIR/super-traits-fail-3.rs:32:17
8181
|
8282
LL | const fn foo<T: [const] Bar>(x: &T) {
83-
| ^^^^^^^^^ can't be applied to `Bar`
83+
| ^^^^^^^ can't be applied to `Bar`
8484
|
8585
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
8686
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations

tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
error[E0658]: const trait impls are experimental
2-
--> $DIR/super-traits-fail-3.rs:23:10
2+
--> $DIR/super-traits-fail-3.rs:23:12
33
|
44
LL | trait Bar: [const] Foo {}
5-
| ^^^^^^^^^
5+
| ^^^^^^^
66
|
77
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
88
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

1111
error[E0658]: const trait impls are experimental
12-
--> $DIR/super-traits-fail-3.rs:32:15
12+
--> $DIR/super-traits-fail-3.rs:32:17
1313
|
1414
LL | const fn foo<T: [const] Bar>(x: &T) {
15-
| ^^^^^^^^^
15+
| ^^^^^^^
1616
|
1717
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
1818
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable

tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
error[E0658]: const trait impls are experimental
2-
--> $DIR/super-traits-fail-3.rs:23:10
2+
--> $DIR/super-traits-fail-3.rs:23:12
33
|
44
LL | trait Bar: [const] Foo {}
5-
| ^^^^^^^^^
5+
| ^^^^^^^
66
|
77
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
88
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

1111
error[E0658]: const trait impls are experimental
12-
--> $DIR/super-traits-fail-3.rs:32:15
12+
--> $DIR/super-traits-fail-3.rs:32:17
1313
|
1414
LL | const fn foo<T: [const] Bar>(x: &T) {
15-
| ^^^^^^^^^
15+
| ^^^^^^^
1616
|
1717
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
1818
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable

tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: `[const]` is not allowed here
2-
--> $DIR/super-traits-fail-3.rs:23:10
2+
--> $DIR/super-traits-fail-3.rs:23:12
33
|
44
LL | trait Bar: [const] Foo {}
5-
| ^^^^^^^^^
5+
| ^^^^^^^
66
|
77
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
88
--> $DIR/super-traits-fail-3.rs:23:1
@@ -11,21 +11,21 @@ LL | trait Bar: [const] Foo {}
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: `[const]` can only be applied to `#[const_trait]` traits
14-
--> $DIR/super-traits-fail-3.rs:23:10
14+
--> $DIR/super-traits-fail-3.rs:23:12
1515
|
1616
LL | trait Bar: [const] Foo {}
17-
| ^^^^^^^^^ can't be applied to `Foo`
17+
| ^^^^^^^ can't be applied to `Foo`
1818
|
1919
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
2020
|
2121
LL | #[const_trait] trait Foo {
2222
| ++++++++++++++
2323

2424
error: `[const]` can only be applied to `#[const_trait]` traits
25-
--> $DIR/super-traits-fail-3.rs:23:10
25+
--> $DIR/super-traits-fail-3.rs:23:12
2626
|
2727
LL | trait Bar: [const] Foo {}
28-
| ^^^^^^^^^ can't be applied to `Foo`
28+
| ^^^^^^^ can't be applied to `Foo`
2929
|
3030
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3131
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
@@ -34,10 +34,10 @@ LL | #[const_trait] trait Foo {
3434
| ++++++++++++++
3535

3636
error: `[const]` can only be applied to `#[const_trait]` traits
37-
--> $DIR/super-traits-fail-3.rs:23:10
37+
--> $DIR/super-traits-fail-3.rs:23:12
3838
|
3939
LL | trait Bar: [const] Foo {}
40-
| ^^^^^^^^^ can't be applied to `Foo`
40+
| ^^^^^^^ can't be applied to `Foo`
4141
|
4242
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
4343
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
@@ -46,21 +46,21 @@ LL | #[const_trait] trait Foo {
4646
| ++++++++++++++
4747

4848
error: `[const]` can only be applied to `#[const_trait]` traits
49-
--> $DIR/super-traits-fail-3.rs:32:15
49+
--> $DIR/super-traits-fail-3.rs:32:17
5050
|
5151
LL | const fn foo<T: [const] Bar>(x: &T) {
52-
| ^^^^^^^^^ can't be applied to `Bar`
52+
| ^^^^^^^ can't be applied to `Bar`
5353
|
5454
help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
5555
|
5656
LL | #[const_trait] trait Bar: [const] Foo {}
5757
| ++++++++++++++
5858

5959
error: `[const]` can only be applied to `#[const_trait]` traits
60-
--> $DIR/super-traits-fail-3.rs:32:15
60+
--> $DIR/super-traits-fail-3.rs:32:17
6161
|
6262
LL | const fn foo<T: [const] Bar>(x: &T) {
63-
| ^^^^^^^^^ can't be applied to `Bar`
63+
| ^^^^^^^ can't be applied to `Bar`
6464
|
6565
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
6666
help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations

0 commit comments

Comments
 (0)