Skip to content

Commit 6e74155

Browse files
fix tests after s/${length()}/${len()}/
1 parent fa5964f commit 6e74155

11 files changed

+155
-140
lines changed

tests/ui/macros/meta-variable-depth-outside-repeat.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
macro_rules! metavar {
44
( $i:expr ) => {
5-
${length(0)}
6-
//~^ ERROR meta-variable expression `length` with depth parameter must be called inside of a macro repetition
5+
${len(0)}
6+
//~^ ERROR meta-variable expression `len` with depth parameter must be called inside of a macro repetition
77
};
88
}
99

Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: meta-variable expression `length` with depth parameter must be called inside of a macro repetition
1+
error: meta-variable expression `len` with depth parameter must be called inside of a macro repetition
22
--> $DIR/meta-variable-depth-outside-repeat.rs:5:10
33
|
4-
LL | ${length(0)}
5-
| ^^^^^^^^^^^
4+
LL | ${len(0)}
5+
| ^^^^^^^^
66

77
error: aborting due to 1 previous error
88

tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs

+60-48
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,55 @@
33
#![feature(macro_metavar_expr)]
44

55
fn main() {
6-
macro_rules! one_nested_count_and_length {
6+
macro_rules! one_nested_count_and_len {
77
( $( [ $( $l:literal ),* ] ),* ) => {
88
[
99
// outer-most repetition
1010
$(
1111
// inner-most repetition
1212
$(
13-
${ignore($l)} ${index()}, ${length()},
13+
${ignore($l)} ${index()}, ${len()},
1414
)*
15-
${count($l)}, ${index()}, ${length()},
15+
${count($l)}, ${index()}, ${len()},
1616
)*
1717
${count($l)},
1818
]
1919
};
2020
}
2121
assert_eq!(
22-
one_nested_count_and_length!(["foo"], ["bar", "baz"]),
22+
one_nested_count_and_len!(["foo"], ["bar", "baz"]),
2323
[
2424
// # ["foo"]
2525

2626
// ## inner-most repetition (first iteration)
2727
//
2828
// `index` is 0 because this is the first inner-most iteration.
29-
// `length` is 1 because there is only one inner-most repetition, "foo".
29+
// `len` is 1 because there is only one inner-most repetition, "foo".
3030
0, 1,
31-
3231
// ## outer-most repetition (first iteration)
3332
//
3433
// `count` is 1 because of "foo", i,e, `$l` has only one repetition,
3534
// `index` is 0 because this is the first outer-most iteration.
36-
// `length` is 2 because there are 2 outer-most repetitions, ["foo"] and ["bar", "baz"]
35+
// `len` is 2 because there are 2 outer-most repetitions, ["foo"] and ["bar", "baz"]
3736
1, 0, 2,
38-
3937
// # ["bar", "baz"]
4038

4139
// ## inner-most repetition (first iteration)
4240
//
4341
// `index` is 0 because this is the first inner-most iteration
44-
// `length` is 2 because there are repetitions, "bar" and "baz"
42+
// `len` is 2 because there are repetitions, "bar" and "baz"
4543
0, 2,
46-
4744
// ## inner-most repetition (second iteration)
4845
//
4946
// `index` is 1 because this is the second inner-most iteration
50-
// `length` is 2 because there are repetitions, "bar" and "baz"
47+
// `len` is 2 because there are repetitions, "bar" and "baz"
5148
1, 2,
52-
5349
// ## outer-most repetition (second iteration)
5450
//
5551
// `count` is 2 because of "bar" and "baz", i,e, `$l` has two repetitions,
5652
// `index` is 1 because this is the second outer-most iteration
57-
// `length` is 2 because there are 2 outer-most repetitions, ["foo"] and ["bar", "baz"]
53+
// `len` is 2 because there are 2 outer-most repetitions, ["foo"] and ["bar", "baz"]
5854
2, 1, 2,
59-
6055
// # last count
6156

6257
// Because there are a total of 3 repetitions of `$l`, "foo", "bar" and "baz"
@@ -131,7 +126,6 @@ fn main() {
131126
&[2][..],
132127
// t u v w x y z
133128
&[7][..],
134-
135129
// (a b c) (d e f)
136130
&[6, 2][..],
137131
// (g h) (i j k l m)
@@ -142,15 +136,13 @@ fn main() {
142136
&[5, 3][..],
143137
// (t u v w x y z)
144138
&[7, 1][..],
145-
146139
// [ (a b c) (d e f) ]
147140
// [ (g h) (i j k l m) ]
148141
// [ (n) ]
149142
&[14, 5, 3][..],
150143
// [ (o) (p q) (r s) ]
151144
// [ (t u v w x y z) ]
152145
&[12, 4, 2][..],
153-
154146
// {
155147
// [ (a b c) (d e f) ]
156148
// [ (g h) (i j k l m) ]
@@ -165,43 +157,43 @@ fn main() {
165157
);
166158

167159
// Grouped from the outer-most to the inner-most
168-
macro_rules! three_nested_length {
160+
macro_rules! three_nested_len {
169161
( $( { $( [ $( ( $( $i:ident )* ) )* ] )* } )* ) => {
170162
&[
171163
$( $( $( $(
172164
&[
173-
${ignore($i)} ${length(3)},
174-
${ignore($i)} ${length(2)},
175-
${ignore($i)} ${length(1)},
176-
${ignore($i)} ${length(0)},
165+
${ignore($i)} ${len(3)},
166+
${ignore($i)} ${len(2)},
167+
${ignore($i)} ${len(1)},
168+
${ignore($i)} ${len(0)},
177169
][..],
178170
)* )* )* )*
179171

180172
$( $( $(
181173
&[
182-
${ignore($i)} ${length(2)},
183-
${ignore($i)} ${length(1)},
184-
${ignore($i)} ${length(0)},
174+
${ignore($i)} ${len(2)},
175+
${ignore($i)} ${len(1)},
176+
${ignore($i)} ${len(0)},
185177
][..],
186178
)* )* )*
187179

188180
$( $(
189181
&[
190-
${ignore($i)} ${length(1)},
191-
${ignore($i)} ${length(0)},
182+
${ignore($i)} ${len(1)},
183+
${ignore($i)} ${len(0)},
192184
][..],
193185
)* )*
194186

195187
$(
196188
&[
197-
${ignore($i)} ${length(0)},
189+
${ignore($i)} ${len(0)},
198190
][..],
199191
)*
200192
][..]
201193
}
202194
}
203195
assert_eq!(
204-
three_nested_length!(
196+
three_nested_len!(
205197
{
206198
[ (a b c) (d e f) ]
207199
[ (g h) (i j k l m) ]
@@ -214,45 +206,64 @@ fn main() {
214206
),
215207
&[
216208
// a b c
217-
&[2, 3, 2, 3][..], &[2, 3, 2, 3][..], &[2, 3, 2, 3][..],
209+
&[2, 3, 2, 3][..],
210+
&[2, 3, 2, 3][..],
211+
&[2, 3, 2, 3][..],
218212
// d e f
219-
&[2, 3, 2, 3][..], &[2, 3, 2, 3][..], &[2, 3, 2, 3][..],
213+
&[2, 3, 2, 3][..],
214+
&[2, 3, 2, 3][..],
215+
&[2, 3, 2, 3][..],
220216
// g h
221-
&[2, 3, 2, 2][..], &[2, 3, 2, 2][..],
217+
&[2, 3, 2, 2][..],
218+
&[2, 3, 2, 2][..],
222219
// i j k l m
223-
&[2, 3, 2, 5][..], &[2, 3, 2, 5][..], &[2, 3, 2, 5][..], &[2, 3, 2, 5][..],
220+
&[2, 3, 2, 5][..],
221+
&[2, 3, 2, 5][..],
222+
&[2, 3, 2, 5][..],
223+
&[2, 3, 2, 5][..],
224224
&[2, 3, 2, 5][..],
225225
// n
226226
&[2, 3, 1, 1][..],
227227
// o
228228
&[2, 2, 3, 1][..],
229229
// p q
230-
&[2, 2, 3, 2][..], &[2, 2, 3, 2][..],
230+
&[2, 2, 3, 2][..],
231+
&[2, 2, 3, 2][..],
231232
// r s
232-
&[2, 2, 3, 2][..], &[2, 2, 3, 2][..],
233+
&[2, 2, 3, 2][..],
234+
&[2, 2, 3, 2][..],
233235
// t u v w x y z
234-
&[2, 2, 1, 7][..], &[2, 2, 1, 7][..], &[2, 2, 1, 7][..], &[2, 2, 1, 7][..],
235-
&[2, 2, 1, 7][..], &[2, 2, 1, 7][..], &[2, 2, 1, 7][..],
236-
236+
&[2, 2, 1, 7][..],
237+
&[2, 2, 1, 7][..],
238+
&[2, 2, 1, 7][..],
239+
&[2, 2, 1, 7][..],
240+
&[2, 2, 1, 7][..],
241+
&[2, 2, 1, 7][..],
242+
&[2, 2, 1, 7][..],
237243
// (a b c) (d e f)
238-
&[2, 3, 2][..], &[2, 3, 2][..],
244+
&[2, 3, 2][..],
245+
&[2, 3, 2][..],
239246
// (g h) (i j k l m)
240-
&[2, 3, 2][..], &[2, 3, 2][..],
247+
&[2, 3, 2][..],
248+
&[2, 3, 2][..],
241249
// (n)
242250
&[2, 3, 1][..],
243251
// (o) (p q) (r s)
244-
&[2, 2, 3][..], &[2, 2, 3][..], &[2, 2, 3][..],
252+
&[2, 2, 3][..],
253+
&[2, 2, 3][..],
254+
&[2, 2, 3][..],
245255
// (t u v w x y z)
246256
&[2, 2, 1][..],
247-
248257
// [ (a b c) (d e f) ]
249258
// [ (g h) (i j k l m) ]
250259
// [ (n) ]
251-
&[2, 3][..], &[2, 3][..], &[2, 3,][..],
260+
&[2, 3][..],
261+
&[2, 3][..],
262+
&[2, 3,][..],
252263
// [ (o) (p q) (r s) ]
253264
// [ (t u v w x y z) ]
254-
&[2, 2][..], &[2, 2][..],
255-
265+
&[2, 2][..],
266+
&[2, 2][..],
256267
// {
257268
// [ (a b c) (d e f) ]
258269
// [ (g h) (i j k l m) ]
@@ -262,10 +273,11 @@ fn main() {
262273
// [ (o) (p q) (r s) ]
263274
// [ (t u v w x y z) ]
264275
// }
265-
&[2][..], &[2][..]
276+
&[2][..],
277+
&[2][..]
266278
][..]
267279
);
268280

269-
// It is possible to say, to some degree, that count is an "amalgamation" of length (see
270-
// each length line result and compare them with the count results)
281+
// It is possible to say, to some degree, that count is an "amalgamation" of len (see
282+
// each len line result and compare them with the count results)
271283
}

tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ macro_rules! count_depth_limits {
3737
};
3838
}
3939

40-
/// Produce (index, length) pairs for literals in a macro repetition.
40+
/// Produce (index, len) pairs for literals in a macro repetition.
4141
/// The literal is not included in the output, so this macro uses the
4242
/// `ignore` meta-variable expression to create a non-expanding
4343
/// repetition binding.
4444
macro_rules! enumerate_literals {
4545
( $( ($l:stmt) ),* ) => {
46-
[$( ${ignore($l)} (${index()}, ${length()}) ),*]
46+
[$( ${ignore($l)} (${index()}, ${len()}) ),*]
4747
};
4848
}
4949

50-
/// Produce index and length tuples for literals in a 2-dimensional
50+
/// Produce index and len tuples for literals in a 2-dimensional
5151
/// macro repetition.
5252
macro_rules! enumerate_literals_2 {
5353
( $( [ $( ($l:literal) ),* ] ),* ) => {
@@ -56,9 +56,9 @@ macro_rules! enumerate_literals_2 {
5656
$(
5757
(
5858
${index(1)},
59-
${length(1)},
59+
${len(1)},
6060
${index(0)},
61-
${length(0)},
61+
${len(0)},
6262
$l
6363
),
6464
)*
@@ -134,7 +134,6 @@ fn main() {
134134
(0, 2, 0, 3, "foo"),
135135
(0, 2, 1, 3, "bar"),
136136
(0, 2, 2, 3, "baz"),
137-
138137
(1, 2, 0, 4, "qux"),
139138
(1, 2, 1, 4, "quux"),
140139
(1, 2, 2, 4, "quuz"),

tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ macro_rules! example {
1717
_nested: vec![
1818
$(
1919
Example {
20-
_indexes: &[(${index()}, ${length()})],
20+
_indexes: &[(${index()}, ${len()})],
2121
_counts: &[${count($x, 0)}, ${count($x, 1)}],
2222
_nested: vec![
2323
$(
2424
Example {
25-
_indexes: &[(${index(1)}, ${length(1)}), (${index()}, ${length()})],
25+
_indexes: &[(${index(1)}, ${len(1)}), (${index()}, ${len()})],
2626
_counts: &[${count($x)}],
2727
_nested: vec![
2828
$(
2929
Example {
3030
_indexes: &[
31-
(${index(2)}, ${length(2)}),
32-
(${index(1)}, ${length(1)}),
33-
(${index()}, ${length()})
31+
(${index(2)}, ${len(2)}),
32+
(${index(1)}, ${len(1)}),
33+
(${index()}, ${len()})
3434
],
3535
_counts: &[],
3636
_nested: vec![],

tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ macro_rules! c {
2828
(
2929
$( $(
3030
${ignore($foo)}
31-
${length(0)}
32-
${length(10)}
33-
//~^ ERROR depth parameter of meta-variable expression `length` must be less than 2
31+
${len(0)}
32+
${len(10)}
33+
//~^ ERROR depth parameter of meta-variable expression `len` must be less than 2
3434
)* )*
3535
)
3636
};

tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ error: depth parameter of meta-variable expression `index` must be less than 3
1010
LL | ${index(10)},
1111
| ^^^^^^^^^^^
1212

13-
error: depth parameter of meta-variable expression `length` must be less than 2
13+
error: depth parameter of meta-variable expression `len` must be less than 2
1414
--> $DIR/out-of-bounds-arguments.rs:32:18
1515
|
16-
LL | ${length(10)}
17-
| ^^^^^^^^^^^^
16+
LL | ${len(10)}
17+
| ^^^^^^^^^
1818

1919
error: aborting due to 3 previous errors
2020

tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ macro_rules! ignore {
3232
}};
3333
}
3434

35-
macro_rules! length {
35+
macro_rules! len {
3636
( $( $e:stmt ),* ) => {
37-
$( ${ignore($e)} ${length()} )*
37+
$( ${ignore($e)} ${len()} )*
3838
//~^ ERROR meta-variable expressions are unstable
3939
//~| ERROR meta-variable expressions are unstable
4040
};
4141
}
4242

43-
fn main() {
44-
}
43+
fn main() {}

0 commit comments

Comments
 (0)