Skip to content

Commit 8eb1a9e

Browse files
author
Alexander Regueiro
committed
Added regression test for using generic parameters on modules.
1 parent 5a36f9e commit 8eb1a9e

35 files changed

+306
-279
lines changed

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ pub struct GenericArgs {
420420
/// The generic arguments for this path segment.
421421
pub args: HirVec<GenericArg>,
422422
/// Bindings (equality constraints) on associated types, if present.
423-
/// E.g., `Foo<A=Bar>`.
423+
/// E.g., `Foo<A = Bar>`.
424424
pub bindings: HirVec<TypeBinding>,
425425
/// Were arguments written in parenthesized form `Fn(T) -> U`?
426426
/// This is required mostly for pretty-printing and diagnostics,

src/librustc_typeck/astconv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,20 +1437,20 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
14371437
if err_for_lt { continue }
14381438
err_for_lt = true;
14391439
(struct_span_err!(self.tcx().sess, lt.span, E0110,
1440-
"lifetime parameters are not allowed on this type"),
1440+
"lifetime arguments are not allowed on this entity"),
14411441
lt.span,
14421442
"lifetime")
14431443
}
14441444
hir::GenericArg::Type(ty) => {
14451445
if err_for_ty { continue }
14461446
err_for_ty = true;
14471447
(struct_span_err!(self.tcx().sess, ty.span, E0109,
1448-
"type parameters are not allowed on this type"),
1448+
"type arguments are not allowed on this entity"),
14491449
ty.span,
14501450
"type")
14511451
}
14521452
};
1453-
span_err.span_label(span, format!("{} parameter not allowed", kind))
1453+
span_err.span_label(span, format!("{} argument not allowed", kind))
14541454
.emit();
14551455
if err_for_lt && err_for_ty {
14561456
break;

src/librustc_typeck/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ You tried to give a type parameter to a type which doesn't need it. Erroneous
12911291
code example:
12921292
12931293
```compile_fail,E0109
1294-
type X = u32<i32>; // error: type parameters are not allowed on this type
1294+
type X = u32<i32>; // error: type arguments are not allowed on this entity
12951295
```
12961296
12971297
Please check that you used the correct type and recheck its definition. Perhaps

src/test/ui/enum-variant-generic-args.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,59 +7,59 @@ type AliasFixed = Enum<()>;
77
impl<T> Enum<T> {
88
fn ts_variant() {
99
Self::TSVariant::<()>(());
10-
//~^ ERROR type parameters are not allowed on this type [E0109]
10+
//~^ ERROR type arguments are not allowed on this entity [E0109]
1111
Self::<()>::TSVariant(());
12-
//~^ ERROR type parameters are not allowed on this type [E0109]
12+
//~^ ERROR type arguments are not allowed on this entity [E0109]
1313
Self::<()>::TSVariant::<()>(());
14-
//~^ ERROR type parameters are not allowed on this type [E0109]
15-
//~^^ ERROR type parameters are not allowed on this type [E0109]
14+
//~^ ERROR type arguments are not allowed on this entity [E0109]
15+
//~^^ ERROR type arguments are not allowed on this entity [E0109]
1616
}
1717

1818
fn s_variant() {
1919
Self::SVariant::<()>(());
20-
//~^ ERROR type parameters are not allowed on this type [E0109]
20+
//~^ ERROR type arguments are not allowed on this entity [E0109]
2121
Self::<()>::SVariant(());
22-
//~^ ERROR type parameters are not allowed on this type [E0109]
22+
//~^ ERROR type arguments are not allowed on this entity [E0109]
2323
Self::<()>::SVariant::<()>(());
24-
//~^ ERROR type parameters are not allowed on this type [E0109]
25-
//~^^ ERROR type parameters are not allowed on this type [E0109]
24+
//~^ ERROR type arguments are not allowed on this entity [E0109]
25+
//~^^ ERROR type arguments are not allowed on this entity [E0109]
2626
}
2727
}
2828

2929
fn main() {
3030
// Tuple struct variant
3131

3232
Enum::<()>::TSVariant::<()>(());
33-
//~^ ERROR type parameters are not allowed on this type [E0109]
33+
//~^ ERROR type arguments are not allowed on this entity [E0109]
3434

3535
Alias::TSVariant::<()>(());
36-
//~^ ERROR type parameters are not allowed on this type [E0109]
36+
//~^ ERROR type arguments are not allowed on this entity [E0109]
3737
Alias::<()>::TSVariant::<()>(());
38-
//~^ ERROR type parameters are not allowed on this type [E0109]
38+
//~^ ERROR type arguments are not allowed on this entity [E0109]
3939

4040
AliasFixed::TSVariant::<()>(());
41-
//~^ ERROR type parameters are not allowed on this type [E0109]
41+
//~^ ERROR type arguments are not allowed on this entity [E0109]
4242
AliasFixed::<()>::TSVariant(());
4343
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
4444
AliasFixed::<()>::TSVariant::<()>(());
45-
//~^ ERROR type parameters are not allowed on this type [E0109]
45+
//~^ ERROR type arguments are not allowed on this entity [E0109]
4646
//~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
4747

4848
// Struct variant
4949

5050
Enum::<()>::SVariant::<()>(());
51-
//~^ ERROR type parameters are not allowed on this type [E0109]
51+
//~^ ERROR type arguments are not allowed on this entity [E0109]
5252

5353
Alias::SVariant::<()>(());
54-
//~^ ERROR type parameters are not allowed on this type [E0109]
54+
//~^ ERROR type arguments are not allowed on this entity [E0109]
5555
Alias::<()>::SVariant::<()>(());
56-
//~^ ERROR type parameters are not allowed on this type [E0109]
56+
//~^ ERROR type arguments are not allowed on this entity [E0109]
5757

5858
AliasFixed::SVariant::<()>(());
59-
//~^ ERROR type parameters are not allowed on this type [E0109]
59+
//~^ ERROR type arguments are not allowed on this entity [E0109]
6060
AliasFixed::<()>::SVariant(());
6161
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
6262
AliasFixed::<()>::SVariant::<()>(());
63-
//~^ ERROR type parameters are not allowed on this type [E0109]
63+
//~^ ERROR type arguments are not allowed on this entity [E0109]
6464
//~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
6565
}

src/test/ui/enum-variant-generic-args.stderr

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@ LL | Enum::<()>::SVariant::<()>(());
77
| | did you mean `TSVariant`?
88
| did you mean `Enum::SVariant { /* fields */ }`?
99

10-
error[E0109]: type parameters are not allowed on this type
10+
error[E0109]: type arguments are not allowed on this entity
1111
--> $DIR/enum-variant-generic-args.rs:9:27
1212
|
1313
LL | Self::TSVariant::<()>(());
14-
| ^^ type parameter not allowed
14+
| ^^ type argument not allowed
1515

16-
error[E0109]: type parameters are not allowed on this type
16+
error[E0109]: type arguments are not allowed on this entity
1717
--> $DIR/enum-variant-generic-args.rs:11:16
1818
|
1919
LL | Self::<()>::TSVariant(());
20-
| ^^ type parameter not allowed
20+
| ^^ type argument not allowed
2121

22-
error[E0109]: type parameters are not allowed on this type
22+
error[E0109]: type arguments are not allowed on this entity
2323
--> $DIR/enum-variant-generic-args.rs:13:16
2424
|
2525
LL | Self::<()>::TSVariant::<()>(());
26-
| ^^ type parameter not allowed
26+
| ^^ type argument not allowed
2727

28-
error[E0109]: type parameters are not allowed on this type
28+
error[E0109]: type arguments are not allowed on this entity
2929
--> $DIR/enum-variant-generic-args.rs:13:33
3030
|
3131
LL | Self::<()>::TSVariant::<()>(());
32-
| ^^ type parameter not allowed
32+
| ^^ type argument not allowed
3333

34-
error[E0109]: type parameters are not allowed on this type
34+
error[E0109]: type arguments are not allowed on this entity
3535
--> $DIR/enum-variant-generic-args.rs:19:26
3636
|
3737
LL | Self::SVariant::<()>(());
38-
| ^^ type parameter not allowed
38+
| ^^ type argument not allowed
3939

4040
error[E0618]: expected function, found enum variant `<Self>::SVariant::<()>`
4141
--> $DIR/enum-variant-generic-args.rs:19:9
@@ -52,11 +52,11 @@ help: `<Self>::SVariant::<()>` is a unit variant, you need to write it without t
5252
LL | <Self>::SVariant::<()>;
5353
| ^^^^^^^^^^^^^^^^^^^^^^
5454

55-
error[E0109]: type parameters are not allowed on this type
55+
error[E0109]: type arguments are not allowed on this entity
5656
--> $DIR/enum-variant-generic-args.rs:21:16
5757
|
5858
LL | Self::<()>::SVariant(());
59-
| ^^ type parameter not allowed
59+
| ^^ type argument not allowed
6060

6161
error[E0618]: expected function, found enum variant `<Self<()>>::SVariant`
6262
--> $DIR/enum-variant-generic-args.rs:21:9
@@ -73,17 +73,17 @@ help: `<Self<()>>::SVariant` is a unit variant, you need to write it without the
7373
LL | <Self<()>>::SVariant;
7474
| ^^^^^^^^^^^^^^^^^^^^
7575

76-
error[E0109]: type parameters are not allowed on this type
76+
error[E0109]: type arguments are not allowed on this entity
7777
--> $DIR/enum-variant-generic-args.rs:23:16
7878
|
7979
LL | Self::<()>::SVariant::<()>(());
80-
| ^^ type parameter not allowed
80+
| ^^ type argument not allowed
8181

82-
error[E0109]: type parameters are not allowed on this type
82+
error[E0109]: type arguments are not allowed on this entity
8383
--> $DIR/enum-variant-generic-args.rs:23:32
8484
|
8585
LL | Self::<()>::SVariant::<()>(());
86-
| ^^ type parameter not allowed
86+
| ^^ type argument not allowed
8787

8888
error[E0618]: expected function, found enum variant `<Self<()>>::SVariant::<()>`
8989
--> $DIR/enum-variant-generic-args.rs:23:9
@@ -100,29 +100,29 @@ help: `<Self<()>>::SVariant::<()>` is a unit variant, you need to write it witho
100100
LL | <Self<()>>::SVariant::<()>;
101101
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
102102

103-
error[E0109]: type parameters are not allowed on this type
103+
error[E0109]: type arguments are not allowed on this entity
104104
--> $DIR/enum-variant-generic-args.rs:32:29
105105
|
106106
LL | Enum::<()>::TSVariant::<()>(());
107-
| ^^ type parameter not allowed
107+
| ^^ type argument not allowed
108108

109-
error[E0109]: type parameters are not allowed on this type
109+
error[E0109]: type arguments are not allowed on this entity
110110
--> $DIR/enum-variant-generic-args.rs:35:24
111111
|
112112
LL | Alias::TSVariant::<()>(());
113-
| ^^ type parameter not allowed
113+
| ^^ type argument not allowed
114114

115-
error[E0109]: type parameters are not allowed on this type
115+
error[E0109]: type arguments are not allowed on this entity
116116
--> $DIR/enum-variant-generic-args.rs:37:30
117117
|
118118
LL | Alias::<()>::TSVariant::<()>(());
119-
| ^^ type parameter not allowed
119+
| ^^ type argument not allowed
120120

121-
error[E0109]: type parameters are not allowed on this type
121+
error[E0109]: type arguments are not allowed on this entity
122122
--> $DIR/enum-variant-generic-args.rs:40:29
123123
|
124124
LL | AliasFixed::TSVariant::<()>(());
125-
| ^^ type parameter not allowed
125+
| ^^ type argument not allowed
126126

127127
error[E0107]: wrong number of type arguments: expected 0, found 1
128128
--> $DIR/enum-variant-generic-args.rs:42:18
@@ -136,17 +136,17 @@ error[E0107]: wrong number of type arguments: expected 0, found 1
136136
LL | AliasFixed::<()>::TSVariant::<()>(());
137137
| ^^ unexpected type argument
138138

139-
error[E0109]: type parameters are not allowed on this type
139+
error[E0109]: type arguments are not allowed on this entity
140140
--> $DIR/enum-variant-generic-args.rs:44:35
141141
|
142142
LL | AliasFixed::<()>::TSVariant::<()>(());
143-
| ^^ type parameter not allowed
143+
| ^^ type argument not allowed
144144

145-
error[E0109]: type parameters are not allowed on this type
145+
error[E0109]: type arguments are not allowed on this entity
146146
--> $DIR/enum-variant-generic-args.rs:53:23
147147
|
148148
LL | Alias::SVariant::<()>(());
149-
| ^^ type parameter not allowed
149+
| ^^ type argument not allowed
150150

151151
error[E0618]: expected function, found enum variant `<Alias>::SVariant::<()>`
152152
--> $DIR/enum-variant-generic-args.rs:53:5
@@ -163,11 +163,11 @@ help: `<Alias>::SVariant::<()>` is a unit variant, you need to write it without
163163
LL | <Alias>::SVariant::<()>;
164164
| ^^^^^^^^^^^^^^^^^^^^^^^
165165

166-
error[E0109]: type parameters are not allowed on this type
166+
error[E0109]: type arguments are not allowed on this entity
167167
--> $DIR/enum-variant-generic-args.rs:55:29
168168
|
169169
LL | Alias::<()>::SVariant::<()>(());
170-
| ^^ type parameter not allowed
170+
| ^^ type argument not allowed
171171

172172
error[E0618]: expected function, found enum variant `<Alias<()>>::SVariant::<()>`
173173
--> $DIR/enum-variant-generic-args.rs:55:5
@@ -184,11 +184,11 @@ help: `<Alias<()>>::SVariant::<()>` is a unit variant, you need to write it with
184184
LL | <Alias<()>>::SVariant::<()>;
185185
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
186186

187-
error[E0109]: type parameters are not allowed on this type
187+
error[E0109]: type arguments are not allowed on this entity
188188
--> $DIR/enum-variant-generic-args.rs:58:28
189189
|
190190
LL | AliasFixed::SVariant::<()>(());
191-
| ^^ type parameter not allowed
191+
| ^^ type argument not allowed
192192

193193
error[E0618]: expected function, found enum variant `<AliasFixed>::SVariant::<()>`
194194
--> $DIR/enum-variant-generic-args.rs:58:5
@@ -232,11 +232,11 @@ error[E0107]: wrong number of type arguments: expected 0, found 1
232232
LL | AliasFixed::<()>::SVariant::<()>(());
233233
| ^^ unexpected type argument
234234

235-
error[E0109]: type parameters are not allowed on this type
235+
error[E0109]: type arguments are not allowed on this entity
236236
--> $DIR/enum-variant-generic-args.rs:62:34
237237
|
238238
LL | AliasFixed::<()>::SVariant::<()>(());
239-
| ^^ type parameter not allowed
239+
| ^^ type argument not allowed
240240

241241
error[E0618]: expected function, found enum variant `<AliasFixed<()>>::SVariant::<()>`
242242
--> $DIR/enum-variant-generic-args.rs:62:5

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0109]: type parameters are not allowed on this type
1+
error[E0109]: type arguments are not allowed on this entity
22
--> $DIR/E0109.rs:1:14
33
|
44
LL | type X = u32<i32>; //~ ERROR E0109
5-
| ^^^ type parameter not allowed
5+
| ^^^ type argument not allowed
66

77
error: aborting due to previous error
88

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
error[E0110]: lifetime parameters are not allowed on this type
1+
<<<<<<< HEAD
2+
error[E0110]: lifetime arguments are not allowed on this entity
23
--> $DIR/E0110.rs:1:14
4+
||||||| merged common ancestors
5+
error[E0110]: lifetime parameters are not allowed on this type
6+
--> $DIR/E0110.rs:11:14
7+
=======
8+
error[E0110]: lifetime arguments are not allowed on this entity
9+
--> $DIR/E0110.rs:11:14
10+
>>>>>>> Added regression test for using generic parameters on modules.
311
|
412
LL | type X = u32<'static>; //~ ERROR E0110
5-
| ^^^^^^^ lifetime parameter not allowed
13+
| ^^^^^^^ lifetime argument not allowed
614

715
error: aborting due to previous error
816

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fn is_copy<T: ::std::marker<i32>::Copy>() {}
2-
//~^ ERROR type parameters are not allowed on this type [E0109]
2+
//~^ ERROR type arguments are not allowed on this entity [E0109]
33
fn main() {}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0109]: type parameters are not allowed on this type
1+
error[E0109]: type arguments are not allowed on this entity
22
--> $DIR/issue-22706.rs:1:29
33
|
44
LL | fn is_copy<T: ::std::marker<i32>::Copy>() {}
5-
| ^^^ type parameter not allowed
5+
| ^^^ type argument not allowed
66

77
error: aborting due to previous error
88

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
mod Mod {
3+
pub struct FakeVariant<T>(pub T);
4+
}
5+
6+
fn main() {
7+
Mod::FakeVariant::<i32>(0);
8+
Mod::<i32>::FakeVariant(0);
9+
//~^ ERROR type arguments are not allowed on this entity [E0109]
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0109]: type arguments are not allowed on this entity
2+
--> $DIR/mod-subitem-as-enum-variant.rs:8:11
3+
|
4+
LL | Mod::<i32>::FakeVariant(0);
5+
| ^^^ type argument not allowed
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0109`.

0 commit comments

Comments
 (0)