Skip to content

Commit e635704

Browse files
authored
Rollup merge of rust-lang#98268 - compiler-errors:disallowed-generics-better, r=lcnr
Improve `lifetime arguments are not allowed on` error message Actually mention what thing we're improperly trying to add lifetime generics to.
2 parents b6fb582 + 2762d62 commit e635704

15 files changed

+67
-67
lines changed

compiler/rustc_typeck/src/astconv/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,8 +2195,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
21952195
"{kind} arguments are not allowed on {this_type}",
21962196
);
21972197
err.span_label(last_span, format!("{kind} argument{s} not allowed"));
2198-
for (_, span) in types_and_spans {
2199-
err.span_label(span, "not allowed on this");
2198+
for (what, span) in types_and_spans {
2199+
err.span_label(span, format!("not allowed on {what}"));
22002200
}
22012201
extend(&mut err);
22022202
err.emit();

src/test/ui/derives/issue-97343.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on type parameter `Irrelevant`
44
LL | #[derive(Debug)]
55
| -----
66
| |
7-
| not allowed on this
7+
| not allowed on type parameter `Irrelevant`
88
| in this derive macro expansion
99
LL | pub struct Irrelevant<Irrelevant> {
1010
| ^^^^^^^^^^ type argument not allowed

src/test/ui/error-codes/E0109.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on this type
44
LL | type X = u32<i32>;
55
| --- ^^^ type argument not allowed
66
| |
7-
| not allowed on this
7+
| not allowed on this type
88
|
99
help: primitive type `u32` doesn't have generic parameters
1010
|

src/test/ui/error-codes/E0110.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0109]: lifetime arguments are not allowed on this type
44
LL | type X = u32<'static>;
55
| --- ^^^^^^^ lifetime argument not allowed
66
| |
7-
| not allowed on this
7+
| not allowed on this type
88
|
99
help: primitive type `u32` doesn't have generic parameters
1010
|

src/test/ui/issues/issue-22706.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on module `marker`
44
LL | fn is_copy<T: ::std::marker<i32>::Copy>() {}
55
| ------ ^^^ type argument not allowed
66
| |
7-
| not allowed on this
7+
| not allowed on module `marker`
88

99
error: aborting due to previous error
1010

src/test/ui/issues/issue-57924.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on self constructor
44
LL | Self::<E>(e)
55
| ---- ^ type argument not allowed
66
| |
7-
| not allowed on this
7+
| not allowed on self constructor
88

99
error: aborting due to previous error
1010

src/test/ui/issues/issue-60989.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ error[E0109]: type arguments are not allowed on local variable
44
LL | c1::<()>;
55
| -- ^^ type argument not allowed
66
| |
7-
| not allowed on this
7+
| not allowed on local variable
88

99
error[E0109]: type arguments are not allowed on local variable
1010
--> $DIR/issue-60989.rs:16:10
1111
|
1212
LL | c1::<dyn Into<B>>;
1313
| -- ^^^^^^^^^^^ type argument not allowed
1414
| |
15-
| not allowed on this
15+
| not allowed on local variable
1616

1717
error: aborting due to 2 previous errors
1818

src/test/ui/mod-subitem-as-enum-variant.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on module `Mod`
44
LL | Mod::<i32>::FakeVariant(0);
55
| --- ^^^ type argument not allowed
66
| |
7-
| not allowed on this
7+
| not allowed on module `Mod`
88

99
error: aborting due to previous error
1010

src/test/ui/structs/struct-path-associated-type.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error[E0109]: type arguments are not allowed on this type
1010
LL | let z = T::A::<u8> {};
1111
| - ^^ type argument not allowed
1212
| |
13-
| not allowed on this
13+
| not allowed on this type
1414

1515
error[E0071]: expected struct, variant or union type, found associated type
1616
--> $DIR/struct-path-associated-type.rs:14:13
@@ -30,7 +30,7 @@ error[E0109]: type arguments are not allowed on this type
3030
LL | let z = T::A::<u8> {};
3131
| - ^^ type argument not allowed
3232
| |
33-
| not allowed on this
33+
| not allowed on this type
3434

3535
error[E0223]: ambiguous associated type
3636
--> $DIR/struct-path-associated-type.rs:32:13

src/test/ui/structs/struct-path-self.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error[E0109]: type arguments are not allowed on self type
1010
LL | let z = Self::<u8> {};
1111
| ---- ^^ type argument not allowed
1212
| |
13-
| not allowed on this
13+
| not allowed on self type
1414
|
1515
help: the `Self` type doesn't accept type parameters
1616
|
@@ -36,7 +36,7 @@ error[E0109]: type arguments are not allowed on self type
3636
LL | let z = Self::<u8> {};
3737
| ---- ^^ type argument not allowed
3838
| |
39-
| not allowed on this
39+
| not allowed on self type
4040
|
4141
note: `Self` is of type `S`
4242
--> $DIR/struct-path-self.rs:1:8
@@ -58,7 +58,7 @@ error[E0109]: type arguments are not allowed on self type
5858
LL | let z = Self::<u8> {};
5959
| ---- ^^ type argument not allowed
6060
| |
61-
| not allowed on this
61+
| not allowed on self type
6262
|
6363
note: `Self` is of type `S`
6464
--> $DIR/struct-path-self.rs:1:8

0 commit comments

Comments
 (0)