Skip to content

Commit e593c3b

Browse files
committed
Changed most vec! invocations to use square braces
Most of the Rust community agrees that the vec! macro is clearer when called using square brackets [] instead of regular brackets (). Most of these ocurrences are from before macros allowed using different types of brackets. There is one left unchanged in a pretty-print test, as the pretty printer still wants it to have regular brackets.
1 parent f26eedb commit e593c3b

File tree

189 files changed

+511
-511
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+511
-511
lines changed

src/libcollections/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ impl<T> [T] {
11701170
/// let x = s.into_vec();
11711171
/// // `s` cannot be used anymore because it has been converted into `x`.
11721172
///
1173-
/// assert_eq!(x, vec!(10, 40, 30));
1173+
/// assert_eq!(x, vec![10, 40, 30]);
11741174
/// ```
11751175
#[stable(feature = "rust1", since = "1.0.0")]
11761176
#[inline]

src/libcollections/vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@ use super::range::RangeArgument;
148148
/// [`Index`] trait. An example will be more explicit:
149149
///
150150
/// ```
151-
/// let v = vec!(0, 2, 4, 6);
151+
/// let v = vec![0, 2, 4, 6];
152152
/// println!("{}", v[1]); // it will display '2'
153153
/// ```
154154
///
155155
/// However be careful: if you try to access an index which isn't in the `Vec`,
156156
/// your software will panic! You cannot do this:
157157
///
158158
/// ```ignore
159-
/// let v = vec!(0, 2, 4, 6);
159+
/// let v = vec![0, 2, 4, 6];
160160
/// println!("{}", v[6]); // it will panic!
161161
/// ```
162162
///
@@ -173,7 +173,7 @@ use super::range::RangeArgument;
173173
/// // ...
174174
/// }
175175
///
176-
/// let v = vec!(0, 1);
176+
/// let v = vec![0, 1];
177177
/// read_slice(&v);
178178
///
179179
/// // ... and that's all!

src/libcore/option.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,12 +914,12 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
914914
/// ```
915915
/// use std::u16;
916916
///
917-
/// let v = vec!(1, 2);
917+
/// let v = vec![1, 2];
918918
/// let res: Option<Vec<u16>> = v.iter().map(|&x: &u16|
919919
/// if x == u16::MAX { None }
920920
/// else { Some(x + 1) }
921921
/// ).collect();
922-
/// assert!(res == Some(vec!(2, 3)));
922+
/// assert!(res == Some(vec![2, 3]));
923923
/// ```
924924
#[inline]
925925
fn from_iter<I: IntoIterator<Item=Option<A>>>(iter: I) -> Option<V> {

src/libcore/result.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,12 +977,12 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
977977
/// ```
978978
/// use std::u32;
979979
///
980-
/// let v = vec!(1, 2);
980+
/// let v = vec![1, 2];
981981
/// let res: Result<Vec<u32>, &'static str> = v.iter().map(|&x: &u32|
982982
/// if x == u32::MAX { Err("Overflow!") }
983983
/// else { Ok(x + 1) }
984984
/// ).collect();
985-
/// assert!(res == Ok(vec!(2, 3)));
985+
/// assert!(res == Ok(vec![2, 3]));
986986
/// ```
987987
#[inline]
988988
fn from_iter<I: IntoIterator<Item=Result<A, E>>>(iter: I) -> Result<V, E> {

src/libgetopts/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,8 +1610,8 @@ Options:
16101610

16111611
#[test]
16121612
fn test_args_with_equals() {
1613-
let args = vec!("--one".to_string(), "A=B".to_string(),
1614-
"--two=C=D".to_string());
1613+
let args = vec!["--one".to_string(), "A=B".to_string(),
1614+
"--two=C=D".to_string()];
16151615
let opts = vec![optopt("o", "one", "One", "INFO"),
16161616
optopt("t", "two", "Two", "INFO")];
16171617
let matches = &match getopts(&args, &opts) {

src/libgraphviz/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
//! struct Edges(Vec<Ed>);
5959
//!
6060
//! pub fn render_to<W: Write>(output: &mut W) {
61-
//! let edges = Edges(vec!((0,1), (0,2), (1,3), (2,3), (3,4), (4,4)));
61+
//! let edges = Edges(vec![(0,1), (0,2), (1,3), (2,3), (3,4), (4,4)]);
6262
//! dot::render(&edges, output).unwrap()
6363
//! }
6464
//!
@@ -164,8 +164,8 @@
164164
//! struct Graph { nodes: Vec<&'static str>, edges: Vec<(usize,usize)> }
165165
//!
166166
//! pub fn render_to<W: Write>(output: &mut W) {
167-
//! let nodes = vec!("{x,y}","{x}","{y}","{}");
168-
//! let edges = vec!((0,1), (0,2), (1,3), (2,3));
167+
//! let nodes = vec!["{x,y}","{x}","{y}","{}"];
168+
//! let edges = vec![(0,1), (0,2), (1,3), (2,3)];
169169
//! let graph = Graph { nodes: nodes, edges: edges };
170170
//!
171171
//! dot::render(&graph, output).unwrap()
@@ -226,8 +226,8 @@
226226
//! struct Graph { nodes: Vec<&'static str>, edges: Vec<(usize,usize)> }
227227
//!
228228
//! pub fn render_to<W: Write>(output: &mut W) {
229-
//! let nodes = vec!("{x,y}","{x}","{y}","{}");
230-
//! let edges = vec!((0,1), (0,2), (1,3), (2,3));
229+
//! let nodes = vec!["{x,y}","{x}","{y}","{}"];
230+
//! let edges = vec![(0,1), (0,2), (1,3), (2,3)];
231231
//! let graph = Graph { nodes: nodes, edges: edges };
232232
//!
233233
//! dot::render(&graph, output).unwrap()

src/librand/chacha.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,17 @@ mod tests {
253253

254254
let v = (0..16).map(|_| ra.next_u32()).collect::<Vec<_>>();
255255
assert_eq!(v,
256-
vec!(0xade0b876, 0x903df1a0, 0xe56a5d40, 0x28bd8653,
256+
vec![0xade0b876, 0x903df1a0, 0xe56a5d40, 0x28bd8653,
257257
0xb819d2bd, 0x1aed8da0, 0xccef36a8, 0xc70d778b,
258258
0x7c5941da, 0x8d485751, 0x3fe02477, 0x374ad8b8,
259-
0xf4b8436a, 0x1ca11815, 0x69b687c3, 0x8665eeb2));
259+
0xf4b8436a, 0x1ca11815, 0x69b687c3, 0x8665eeb2]);
260260

261261
let v = (0..16).map(|_| ra.next_u32()).collect::<Vec<_>>();
262262
assert_eq!(v,
263-
vec!(0xbee7079f, 0x7a385155, 0x7c97ba98, 0x0d082d73,
263+
vec![0xbee7079f, 0x7a385155, 0x7c97ba98, 0x0d082d73,
264264
0xa0290fcb, 0x6965e348, 0x3e53c612, 0xed7aee32,
265265
0x7621b729, 0x434ee69c, 0xb03371d5, 0xd539d874,
266-
0x281fed31, 0x45fb0a51, 0x1f0ae1ac, 0x6f4d794b));
266+
0x281fed31, 0x45fb0a51, 0x1f0ae1ac, 0x6f4d794b]);
267267

268268

269269
let seed: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7];
@@ -280,10 +280,10 @@ mod tests {
280280
}
281281

282282
assert_eq!(v,
283-
vec!(0xf225c81a, 0x6ab1be57, 0x04d42951, 0x70858036,
283+
vec![0xf225c81a, 0x6ab1be57, 0x04d42951, 0x70858036,
284284
0x49884684, 0x64efec72, 0x4be2d186, 0x3615b384,
285285
0x11cfa18e, 0xd3c50049, 0x75c775f6, 0x434c6530,
286-
0x2c5bad8f, 0x898881dc, 0x5f1c86d9, 0xc1f8e7f4));
286+
0x2c5bad8f, 0x898881dc, 0x5f1c86d9, 0xc1f8e7f4]);
287287
}
288288

289289
#[test]

src/librand/distributions/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,37 +312,37 @@ mod tests {
312312
}}
313313
}
314314

315-
t!(vec!(Weighted { weight: 1, item: 10 }),
315+
t!(vec![Weighted { weight: 1, item: 10 }],
316316
[10]);
317317

318318
// skip some
319-
t!(vec!(Weighted { weight: 0, item: 20 },
319+
t!(vec![Weighted { weight: 0, item: 20 },
320320
Weighted { weight: 2, item: 21 },
321321
Weighted { weight: 0, item: 22 },
322-
Weighted { weight: 1, item: 23 }),
322+
Weighted { weight: 1, item: 23 }],
323323
[21, 21, 23]);
324324

325325
// different weights
326-
t!(vec!(Weighted { weight: 4, item: 30 },
327-
Weighted { weight: 3, item: 31 }),
326+
t!(vec![Weighted { weight: 4, item: 30 },
327+
Weighted { weight: 3, item: 31 }],
328328
[30, 30, 30, 30, 31, 31, 31]);
329329

330330
// check that we're binary searching
331331
// correctly with some vectors of odd
332332
// length.
333-
t!(vec!(Weighted { weight: 1, item: 40 },
333+
t!(vec![Weighted { weight: 1, item: 40 },
334334
Weighted { weight: 1, item: 41 },
335335
Weighted { weight: 1, item: 42 },
336336
Weighted { weight: 1, item: 43 },
337-
Weighted { weight: 1, item: 44 }),
337+
Weighted { weight: 1, item: 44 }],
338338
[40, 41, 42, 43, 44]);
339-
t!(vec!(Weighted { weight: 1, item: 50 },
339+
t!(vec![Weighted { weight: 1, item: 50 },
340340
Weighted { weight: 1, item: 51 },
341341
Weighted { weight: 1, item: 52 },
342342
Weighted { weight: 1, item: 53 },
343343
Weighted { weight: 1, item: 54 },
344344
Weighted { weight: 1, item: 55 },
345-
Weighted { weight: 1, item: 56 }),
345+
Weighted { weight: 1, item: 56 }],
346346
[50, 51, 52, 53, 54, 55, 56]);
347347
}
348348

src/librand/isaac.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,8 @@ mod tests {
662662
// Regression test that isaac is actually using the above vector
663663
let v = (0..10).map(|_| ra.next_u32()).collect::<Vec<_>>();
664664
assert_eq!(v,
665-
vec!(2558573138, 873787463, 263499565, 2103644246, 3595684709,
666-
4203127393, 264982119, 2765226902, 2737944514, 3900253796));
665+
vec![2558573138, 873787463, 263499565, 2103644246, 3595684709,
666+
4203127393, 264982119, 2765226902, 2737944514, 3900253796]);
667667

668668
let seed: &[_] = &[12345, 67890, 54321, 9876];
669669
let mut rb: IsaacRng = SeedableRng::from_seed(seed);
@@ -674,8 +674,8 @@ mod tests {
674674

675675
let v = (0..10).map(|_| rb.next_u32()).collect::<Vec<_>>();
676676
assert_eq!(v,
677-
vec!(3676831399, 3183332890, 2834741178, 3854698763, 2717568474,
678-
1576568959, 3507990155, 179069555, 141456972, 2478885421));
677+
vec![3676831399, 3183332890, 2834741178, 3854698763, 2717568474,
678+
1576568959, 3507990155, 179069555, 141456972, 2478885421]);
679679
}
680680
#[test]
681681
#[rustfmt_skip]
@@ -685,10 +685,10 @@ mod tests {
685685
// Regression test that isaac is actually using the above vector
686686
let v = (0..10).map(|_| ra.next_u64()).collect::<Vec<_>>();
687687
assert_eq!(v,
688-
vec!(547121783600835980, 14377643087320773276, 17351601304698403469,
688+
vec![547121783600835980, 14377643087320773276, 17351601304698403469,
689689
1238879483818134882, 11952566807690396487, 13970131091560099343,
690690
4469761996653280935, 15552757044682284409, 6860251611068737823,
691-
13722198873481261842));
691+
13722198873481261842]);
692692

693693
let seed: &[_] = &[12345, 67890, 54321, 9876];
694694
let mut rb: Isaac64Rng = SeedableRng::from_seed(seed);
@@ -699,10 +699,10 @@ mod tests {
699699

700700
let v = (0..10).map(|_| rb.next_u64()).collect::<Vec<_>>();
701701
assert_eq!(v,
702-
vec!(18143823860592706164, 8491801882678285927, 2699425367717515619,
702+
vec![18143823860592706164, 8491801882678285927, 2699425367717515619,
703703
17196852593171130876, 2606123525235546165, 15790932315217671084,
704704
596345674630742204, 9947027391921273664, 11788097613744130851,
705-
10391409374914919106));
705+
10391409374914919106]);
706706

707707
}
708708

src/librustc/cfg/construct.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
536536
fn add_contained_edge(&mut self,
537537
source: CFGIndex,
538538
target: CFGIndex) {
539-
let data = CFGEdgeData {exiting_scopes: vec!() };
539+
let data = CFGEdgeData {exiting_scopes: vec![] };
540540
self.graph.add_edge(source, target, data);
541541
}
542542

@@ -545,7 +545,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
545545
from_index: CFGIndex,
546546
to_loop: LoopScope,
547547
to_index: CFGIndex) {
548-
let mut data = CFGEdgeData {exiting_scopes: vec!() };
548+
let mut data = CFGEdgeData {exiting_scopes: vec![] };
549549
let mut scope = self.tcx.region_maps.node_extent(from_expr.id);
550550
let target_scope = self.tcx.region_maps.node_extent(to_loop.loop_id);
551551
while scope != target_scope {
@@ -559,7 +559,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
559559
_from_expr: &hir::Expr,
560560
from_index: CFGIndex) {
561561
let mut data = CFGEdgeData {
562-
exiting_scopes: vec!(),
562+
exiting_scopes: vec![],
563563
};
564564
for &LoopScope { loop_id: id, .. } in self.loop_scopes.iter().rev() {
565565
data.exiting_scopes.push(id);

0 commit comments

Comments
 (0)