Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed most instances of vec!(..) and replaced them with vec![..]s #37476

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a920e35
Shrink Expr_::ExprInlineAsm.
nnethercote Oct 28, 2016
c751c08
save-analysis: change imports to carry a ref id rather than their own…
nrc Oct 28, 2016
4e46d31
Changed all empty vec!()s to use square brackets
iirelu Oct 29, 2016
2de033b
Removed every last vec!(..) from Rust. Yay.
iirelu Oct 29, 2016
47f8539
Reverted vec![] change in pretty print test
iirelu Oct 30, 2016
bdb399d
Fix ICE when attempting to get closure generics.
Mark-Simulacrum Oct 28, 2016
f5a702d
Auto merge of #37445 - nnethercote:shrink-Expr_, r=eddyb
bors Oct 30, 2016
abe7c18
Merge branch 'master' of github.com:rust-lang/rust into proper-vec-br…
iirelu Oct 30, 2016
ea20ab1
Auto merge of #37459 - Mark-Simulacrum:closure-ice, r=eddyb
bors Oct 30, 2016
a2a2763
Replace all uses of SHA-256 with BLAKE2b.
michaelwoerister Oct 27, 2016
bd1ce91
Add rustc_data_structures to rustc_driver dependencies.
michaelwoerister Oct 29, 2016
9ef9194
Make the crate disambiguator 128 bits instead of 256 bits.
michaelwoerister Oct 30, 2016
bfc9b29
Auto merge of #37460 - nrc:save-imports, r=eddyb
bors Oct 31, 2016
8ec0b3a
Do not clone Mir unnecessarily
nagisa Oct 31, 2016
8f1fc86
Auto merge of #37489 - nagisa:unnecessary-clone, r=eddyb
bors Oct 31, 2016
4497196
Auto merge of #37439 - michaelwoerister:remove-sha256, r=alexcrichton
bors Oct 31, 2016
25aa44c
Changed all empty vec!()s to use square brackets
iirelu Oct 29, 2016
62b29e9
Resolved merge conflict
iirelu Oct 31, 2016
e3edd73
Merge branch 'proper-vec-brackets' of github.com:iirelu/rust into pro…
iirelu Oct 31, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_bo
rustc_trans rustc_privacy rustc_lint rustc_plugin \
rustc_metadata syntax_ext proc_macro_plugin \
rustc_passes rustc_save_analysis rustc_const_eval \
rustc_incremental syntax_pos rustc_errors proc_macro
rustc_incremental syntax_pos rustc_errors proc_macro rustc_data_structures
DEPS_rustc_errors := log libc serialize syntax_pos
DEPS_rustc_lint := rustc log syntax syntax_pos rustc_const_eval
DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
Expand Down
1 change: 1 addition & 0 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ impl<T> [T] {
/// let x = s.into_vec();
/// // `s` cannot be used anymore because it has been converted into `x`.
///
/// assert_eq!(x, vec!(10, 40, 30));
/// assert_eq!(x, vec![10, 40, 30]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down
6 changes: 3 additions & 3 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ use super::range::RangeArgument;
/// [`Index`] trait. An example will be more explicit:
///
/// ```
/// let v = vec!(0, 2, 4, 6);
/// let v = vec![0, 2, 4, 6];
/// println!("{}", v[1]); // it will display '2'
/// ```
///
/// However be careful: if you try to access an index which isn't in the `Vec`,
/// your software will panic! You cannot do this:
///
/// ```ignore
/// let v = vec!(0, 2, 4, 6);
/// let v = vec![0, 2, 4, 6];
/// println!("{}", v[6]); // it will panic!
/// ```
///
Expand All @@ -173,7 +173,7 @@ use super::range::RangeArgument;
/// // ...
/// }
///
/// let v = vec!(0, 1);
/// let v = vec![0, 1];
/// read_slice(&v);
///
/// // ... and that's all!
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,12 +914,12 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
/// ```
/// use std::u16;
///
/// let v = vec!(1, 2);
/// let v = vec![1, 2];
/// let res: Option<Vec<u16>> = v.iter().map(|&x: &u16|
/// if x == u16::MAX { None }
/// else { Some(x + 1) }
/// ).collect();
/// assert!(res == Some(vec!(2, 3)));
/// assert!(res == Some(vec![2, 3]));
/// ```
#[inline]
fn from_iter<I: IntoIterator<Item=Option<A>>>(iter: I) -> Option<V> {
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,12 +977,12 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
/// ```
/// use std::u32;
///
/// let v = vec!(1, 2);
/// let v = vec![1, 2];
/// let res: Result<Vec<u32>, &'static str> = v.iter().map(|&x: &u32|
/// if x == u32::MAX { Err("Overflow!") }
/// else { Ok(x + 1) }
/// ).collect();
/// assert!(res == Ok(vec!(2, 3)));
/// assert!(res == Ok(vec![2, 3]));
/// ```
#[inline]
fn from_iter<I: IntoIterator<Item=Result<A, E>>>(iter: I) -> Result<V, E> {
Expand Down
4 changes: 2 additions & 2 deletions src/libgetopts/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1610,8 +1610,8 @@ Options:

#[test]
fn test_args_with_equals() {
let args = vec!("--one".to_string(), "A=B".to_string(),
"--two=C=D".to_string());
let args = vec!["--one".to_string(), "A=B".to_string(),
"--two=C=D".to_string()];
let opts = vec![optopt("o", "one", "One", "INFO"),
optopt("t", "two", "Two", "INFO")];
let matches = &match getopts(&args, &opts) {
Expand Down
10 changes: 5 additions & 5 deletions src/libgraphviz/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
//! struct Edges(Vec<Ed>);
//!
//! pub fn render_to<W: Write>(output: &mut W) {
//! let edges = Edges(vec!((0,1), (0,2), (1,3), (2,3), (3,4), (4,4)));
//! let edges = Edges(vec![(0,1), (0,2), (1,3), (2,3), (3,4), (4,4)]);
//! dot::render(&edges, output).unwrap()
//! }
//!
Expand Down Expand Up @@ -164,8 +164,8 @@
//! struct Graph { nodes: Vec<&'static str>, edges: Vec<(usize,usize)> }
//!
//! pub fn render_to<W: Write>(output: &mut W) {
//! let nodes = vec!("{x,y}","{x}","{y}","{}");
//! let edges = vec!((0,1), (0,2), (1,3), (2,3));
//! let nodes = vec!["{x,y}","{x}","{y}","{}"];
//! let edges = vec![(0,1), (0,2), (1,3), (2,3)];
//! let graph = Graph { nodes: nodes, edges: edges };
//!
//! dot::render(&graph, output).unwrap()
Expand Down Expand Up @@ -226,8 +226,8 @@
//! struct Graph { nodes: Vec<&'static str>, edges: Vec<(usize,usize)> }
//!
//! pub fn render_to<W: Write>(output: &mut W) {
//! let nodes = vec!("{x,y}","{x}","{y}","{}");
//! let edges = vec!((0,1), (0,2), (1,3), (2,3));
//! let nodes = vec!["{x,y}","{x}","{y}","{}"];
//! let edges = vec![(0,1), (0,2), (1,3), (2,3)];
//! let graph = Graph { nodes: nodes, edges: edges };
//!
//! dot::render(&graph, output).unwrap()
Expand Down
12 changes: 6 additions & 6 deletions src/librand/chacha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,17 @@ mod tests {

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

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


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

assert_eq!(v,
vec!(0xf225c81a, 0x6ab1be57, 0x04d42951, 0x70858036,
vec![0xf225c81a, 0x6ab1be57, 0x04d42951, 0x70858036,
0x49884684, 0x64efec72, 0x4be2d186, 0x3615b384,
0x11cfa18e, 0xd3c50049, 0x75c775f6, 0x434c6530,
0x2c5bad8f, 0x898881dc, 0x5f1c86d9, 0xc1f8e7f4));
0x2c5bad8f, 0x898881dc, 0x5f1c86d9, 0xc1f8e7f4]);
}

#[test]
Expand Down
18 changes: 9 additions & 9 deletions src/librand/distributions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,37 +312,37 @@ mod tests {
}}
}

t!(vec!(Weighted { weight: 1, item: 10 }),
t!(vec![Weighted { weight: 1, item: 10 }],
[10]);

// skip some
t!(vec!(Weighted { weight: 0, item: 20 },
t!(vec![Weighted { weight: 0, item: 20 },
Weighted { weight: 2, item: 21 },
Weighted { weight: 0, item: 22 },
Weighted { weight: 1, item: 23 }),
Weighted { weight: 1, item: 23 }],
[21, 21, 23]);

// different weights
t!(vec!(Weighted { weight: 4, item: 30 },
Weighted { weight: 3, item: 31 }),
t!(vec![Weighted { weight: 4, item: 30 },
Weighted { weight: 3, item: 31 }],
[30, 30, 30, 30, 31, 31, 31]);

// check that we're binary searching
// correctly with some vectors of odd
// length.
t!(vec!(Weighted { weight: 1, item: 40 },
t!(vec![Weighted { weight: 1, item: 40 },
Weighted { weight: 1, item: 41 },
Weighted { weight: 1, item: 42 },
Weighted { weight: 1, item: 43 },
Weighted { weight: 1, item: 44 }),
Weighted { weight: 1, item: 44 }],
[40, 41, 42, 43, 44]);
t!(vec!(Weighted { weight: 1, item: 50 },
t!(vec![Weighted { weight: 1, item: 50 },
Weighted { weight: 1, item: 51 },
Weighted { weight: 1, item: 52 },
Weighted { weight: 1, item: 53 },
Weighted { weight: 1, item: 54 },
Weighted { weight: 1, item: 55 },
Weighted { weight: 1, item: 56 }),
Weighted { weight: 1, item: 56 }],
[50, 51, 52, 53, 54, 55, 56]);
}

Expand Down
16 changes: 8 additions & 8 deletions src/librand/isaac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,8 @@ mod tests {
// Regression test that isaac is actually using the above vector
let v = (0..10).map(|_| ra.next_u32()).collect::<Vec<_>>();
assert_eq!(v,
vec!(2558573138, 873787463, 263499565, 2103644246, 3595684709,
4203127393, 264982119, 2765226902, 2737944514, 3900253796));
vec![2558573138, 873787463, 263499565, 2103644246, 3595684709,
4203127393, 264982119, 2765226902, 2737944514, 3900253796]);

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

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

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

let v = (0..10).map(|_| rb.next_u64()).collect::<Vec<_>>();
assert_eq!(v,
vec!(18143823860592706164, 8491801882678285927, 2699425367717515619,
vec![18143823860592706164, 8491801882678285927, 2699425367717515619,
17196852593171130876, 2606123525235546165, 15790932315217671084,
596345674630742204, 9947027391921273664, 11788097613744130851,
10391409374914919106));
10391409374914919106]);

}

Expand Down
6 changes: 3 additions & 3 deletions src/librustc/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
fn add_contained_edge(&mut self,
source: CFGIndex,
target: CFGIndex) {
let data = CFGEdgeData {exiting_scopes: vec!() };
let data = CFGEdgeData {exiting_scopes: vec![] };
self.graph.add_edge(source, target, data);
}

Expand All @@ -545,7 +545,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
from_index: CFGIndex,
to_loop: LoopScope,
to_index: CFGIndex) {
let mut data = CFGEdgeData {exiting_scopes: vec!() };
let mut data = CFGEdgeData {exiting_scopes: vec![] };
let mut scope = self.tcx.region_maps.node_extent(from_expr.id);
let target_scope = self.tcx.region_maps.node_extent(to_loop.loop_id);
while scope != target_scope {
Expand All @@ -559,7 +559,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
_from_expr: &hir::Expr,
from_index: CFGIndex) {
let mut data = CFGEdgeData {
exiting_scopes: vec!(),
exiting_scopes: vec![],
};
for &LoopScope { loop_id: id, .. } in self.loop_scopes.iter().rev() {
data.exiting_scopes.push(id);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ impl<'a> LoweringContext<'a> {
alignstack,
dialect,
expn_id,
}) => hir::ExprInlineAsm(hir::InlineAsm {
}) => hir::ExprInlineAsm(P(hir::InlineAsm {
inputs: inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
outputs: outputs.iter()
.map(|out| {
Expand All @@ -1236,7 +1236,7 @@ impl<'a> LoweringContext<'a> {
alignstack: alignstack,
dialect: dialect,
expn_id: expn_id,
}, outputs.iter().map(|out| self.lower_expr(&out.expr)).collect(),
}), outputs.iter().map(|out| self.lower_expr(&out.expr)).collect(),
inputs.iter().map(|&(_, ref input)| self.lower_expr(input)).collect()),
ExprKind::Struct(ref path, ref fields, ref maybe_expr) => {
hir::ExprStruct(self.lower_path(path),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ pub enum Expr_ {
ExprRet(Option<P<Expr>>),

/// Inline assembly (from `asm!`), with its outputs and inputs.
ExprInlineAsm(InlineAsm, Vec<P<Expr>>, Vec<P<Expr>>),
ExprInlineAsm(P<InlineAsm>, HirVec<P<Expr>>, HirVec<P<Expr>>),

/// A struct or struct-like variant literal expression.
///
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
}
same_regions.push(SameRegions {
scope_id: scope_id,
regions: vec!(sub_fr.bound_region, sup_fr.bound_region)
regions: vec![sub_fr.bound_region, sup_fr.bound_region]
})
}
}
Expand Down Expand Up @@ -1359,7 +1359,7 @@ impl<'a, 'gcx, 'tcx> Rebuilder<'a, 'gcx, 'tcx> {
region_names: &HashSet<ast::Name>)
-> P<hir::Ty> {
let mut new_ty = P(ty.clone());
let mut ty_queue = vec!(ty);
let mut ty_queue = vec![ty];
while !ty_queue.is_empty() {
let cur_ty = ty_queue.remove(0);
match cur_ty.node {
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ pub mod traits;
pub mod ty;

pub mod util {
pub use rustc_back::sha2;

pub mod common;
pub mod ppaux;
pub mod nodemap;
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ impl LintStore {

pub fn new() -> LintStore {
LintStore {
lints: vec!(),
early_passes: Some(vec!()),
late_passes: Some(vec!()),
lints: vec![],
early_passes: Some(vec![]),
late_passes: Some(vec![]),
by_name: FnvHashMap(),
levels: FnvHashMap(),
future_incompatible: FnvHashMap(),
Expand Down Expand Up @@ -345,7 +345,7 @@ macro_rules! run_lints { ($cx:expr, $f:ident, $ps:ident, $($args:expr),*) => ({
// See also the hir version just below.
pub fn gather_attrs(attrs: &[ast::Attribute])
-> Vec<Result<(InternedString, Level, Span), Span>> {
let mut out = vec!();
let mut out = vec![];
for attr in attrs {
let r = gather_attr(attr);
out.extend(r.into_iter());
Expand All @@ -355,7 +355,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])

pub fn gather_attr(attr: &ast::Attribute)
-> Vec<Result<(InternedString, Level, Span), Span>> {
let mut out = vec!();
let mut out = vec![];

let level = match Level::from_str(&attr.name()) {
None => return out,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl LanguageItems {
fn foo(_: LangItem) -> Option<DefId> { None }

LanguageItems {
items: vec!($(foo($variant)),*),
items: vec![$(foo($variant)),*],
missing: Vec::new(),
}
}
Expand Down
Loading