Allow use of [_ ; n]
syntax for fixed length and repeating arrays.
This does NOT break any existing programs because the `[_, ..n]` syntax is also supported.
This commit is contained in:
parent
cbe9fb45bc
commit
2e86929a4a
122 changed files with 260 additions and 266 deletions
|
@ -452,7 +452,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
ty_vec(t, sz) => {
|
||||
let inner_str = ty_to_string(cx, t);
|
||||
match sz {
|
||||
Some(n) => format!("[{}, ..{}]", inner_str, n),
|
||||
Some(n) => format!("[{}; {}]", inner_str, n),
|
||||
None => format!("[{}]", inner_str),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -334,7 +334,7 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
// mut ptr (*mut) -> {*mut :pointee-uid:}
|
||||
// unique ptr (~) -> {~ :pointee-uid:}
|
||||
// @-ptr (@) -> {@ :pointee-uid:}
|
||||
// sized vec ([T, ..x]) -> {[:size:] :element-uid:}
|
||||
// sized vec ([T; x]) -> {[:size:] :element-uid:}
|
||||
// unsized vec ([T]) -> {[] :element-uid:}
|
||||
// trait (T) -> {trait_:svh: / :node-id:_<(:param-uid:),*> }
|
||||
// closure -> {<unsafe_> <once_> :store-sigil: |(:param-uid:),* <,_...>| -> \
|
||||
|
@ -3752,7 +3752,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
match optional_length {
|
||||
Some(len) => {
|
||||
output.push_str(format!(", ..{}", len).as_slice());
|
||||
output.push_str(format!("; {}", len).as_slice());
|
||||
}
|
||||
None => { /* nothing to do */ }
|
||||
};
|
||||
|
|
|
@ -1548,7 +1548,7 @@ impl<'a> Parser<'a> {
|
|||
self.expect(&token::OpenDelim(token::Bracket));
|
||||
let t = self.parse_ty_sum();
|
||||
|
||||
// Parse the `, ..e` in `[ int, ..e ]`
|
||||
// Parse the `; e` in `[ int; e ]`
|
||||
// where `e` is a const expression
|
||||
let t = match self.maybe_parse_fixed_vstore() {
|
||||
None => TyVec(t),
|
||||
|
@ -1716,6 +1716,9 @@ impl<'a> Parser<'a> {
|
|||
self.bump();
|
||||
self.bump();
|
||||
Some(self.parse_expr())
|
||||
} else if self.check(&token::Semi) {
|
||||
self.bump();
|
||||
Some(self.parse_expr())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -2262,6 +2265,12 @@ impl<'a> Parser<'a> {
|
|||
let count = self.parse_expr();
|
||||
self.expect(&token::CloseDelim(token::Bracket));
|
||||
ex = ExprRepeat(first_expr, count);
|
||||
} else if self.check(&token::Semi) {
|
||||
// Repeating vector syntax: [ 0; 512 ]
|
||||
self.bump();
|
||||
let count = self.parse_expr();
|
||||
self.expect(&token::CloseDelim(token::Bracket));
|
||||
ex = ExprRepeat(first_expr, count);
|
||||
} else if self.check(&token::Comma) {
|
||||
// Vector with two or more elements.
|
||||
self.bump();
|
||||
|
|
|
@ -755,7 +755,7 @@ impl<'a> State<'a> {
|
|||
ast::TyFixedLengthVec(ref ty, ref v) => {
|
||||
try!(word(&mut self.s, "["));
|
||||
try!(self.print_type(&**ty));
|
||||
try!(word(&mut self.s, ", .."));
|
||||
try!(word(&mut self.s, "; "));
|
||||
try!(self.print_expr(&**v));
|
||||
try!(word(&mut self.s, "]"));
|
||||
}
|
||||
|
@ -1531,8 +1531,7 @@ impl<'a> State<'a> {
|
|||
try!(self.ibox(indent_unit));
|
||||
try!(word(&mut self.s, "["));
|
||||
try!(self.print_expr(&**element));
|
||||
try!(word(&mut self.s, ","));
|
||||
try!(word(&mut self.s, ".."));
|
||||
try!(self.word_space(";"));
|
||||
try!(self.print_expr(&**count));
|
||||
try!(word(&mut self.s, "]"));
|
||||
try!(self.end());
|
||||
|
|
|
@ -28,7 +28,7 @@ impl<T> Foo {
|
|||
pub struct Parser<T>;
|
||||
impl<T: std::iter::Iterator<char>> Parser<T> {
|
||||
fn in_doctype(&mut self) {
|
||||
static DOCTYPEPattern: [char, ..6] = ['O', 'C', 'T', 'Y', 'P', 'E'];
|
||||
static DOCTYPEPattern: [char; 6] = ['O', 'C', 'T', 'Y', 'P', 'E'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,20 +37,20 @@ fn gradient(orig: Vec2, grad: Vec2, p: Vec2) -> f32 {
|
|||
}
|
||||
|
||||
struct Noise2DContext {
|
||||
rgradients: [Vec2, ..256],
|
||||
permutations: [i32, ..256],
|
||||
rgradients: [Vec2; 256],
|
||||
permutations: [i32; 256],
|
||||
}
|
||||
|
||||
impl Noise2DContext {
|
||||
fn new() -> Noise2DContext {
|
||||
let mut rng = StdRng::new().unwrap();
|
||||
|
||||
let mut rgradients = [Vec2 { x: 0.0, y: 0.0 }, ..256];
|
||||
let mut rgradients = [Vec2 { x: 0.0, y: 0.0 }; 256];
|
||||
for x in rgradients.iter_mut() {
|
||||
*x = random_gradient(&mut rng);
|
||||
}
|
||||
|
||||
let mut permutations = [0i32, ..256];
|
||||
let mut permutations = [0i32; 256];
|
||||
for (i, x) in permutations.iter_mut().enumerate() {
|
||||
*x = i as i32;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ impl Noise2DContext {
|
|||
self.rgradients[(idx & 255) as uint]
|
||||
}
|
||||
|
||||
fn get_gradients(&self, x: f32, y: f32) -> ([Vec2, ..4], [Vec2, ..4]) {
|
||||
fn get_gradients(&self, x: f32, y: f32) -> ([Vec2; 4], [Vec2; 4]) {
|
||||
let x0f = x.floor();
|
||||
let y0f = y.floor();
|
||||
let x1f = x0f + 1.0;
|
||||
|
@ -102,7 +102,7 @@ impl Noise2DContext {
|
|||
|
||||
fn main() {
|
||||
let symbols = [' ', '░', '▒', '▓', '█', '█'];
|
||||
let mut pixels = [0f32, ..256*256];
|
||||
let mut pixels = [0f32; 256*256];
|
||||
let n2d = Noise2DContext::new();
|
||||
|
||||
for _ in range(0u, 100) {
|
||||
|
|
|
@ -64,14 +64,14 @@ fn next_permutation(perm: &mut [i32], count: &mut [i32]) {
|
|||
}
|
||||
|
||||
struct P {
|
||||
p: [i32, .. 16],
|
||||
p: [i32; 16],
|
||||
}
|
||||
|
||||
impl Copy for P {}
|
||||
|
||||
struct Perm {
|
||||
cnt: [i32, .. 16],
|
||||
fact: [u32, .. 16],
|
||||
cnt: [i32; 16],
|
||||
fact: [u32; 16],
|
||||
n: u32,
|
||||
permcount: u32,
|
||||
perm: P,
|
||||
|
@ -81,21 +81,21 @@ impl Copy for Perm {}
|
|||
|
||||
impl Perm {
|
||||
fn new(n: u32) -> Perm {
|
||||
let mut fact = [1, .. 16];
|
||||
let mut fact = [1; 16];
|
||||
for i in range(1, n as uint + 1) {
|
||||
fact[i] = fact[i - 1] * i as u32;
|
||||
}
|
||||
Perm {
|
||||
cnt: [0, .. 16],
|
||||
cnt: [0; 16],
|
||||
fact: fact,
|
||||
n: n,
|
||||
permcount: 0,
|
||||
perm: P { p: [0, .. 16 ] }
|
||||
perm: P { p: [0; 16 ] }
|
||||
}
|
||||
}
|
||||
|
||||
fn get(&mut self, mut idx: i32) -> P {
|
||||
let mut pp = [0u8, .. 16];
|
||||
let mut pp = [0u8; 16];
|
||||
self.permcount = idx as u32;
|
||||
for (i, place) in self.perm.p.iter_mut().enumerate() {
|
||||
*place = i as i32 + 1;
|
||||
|
|
|
@ -64,7 +64,7 @@ const ALU: &'static str = "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTG\
|
|||
|
||||
const NULL_AMINO_ACID: AminoAcid = AminoAcid { c: ' ' as u8, p: 0.0 };
|
||||
|
||||
static IUB: [AminoAcid, ..15] = [
|
||||
static IUB: [AminoAcid;15] = [
|
||||
AminoAcid { c: 'a' as u8, p: 0.27 },
|
||||
AminoAcid { c: 'c' as u8, p: 0.12 },
|
||||
AminoAcid { c: 'g' as u8, p: 0.12 },
|
||||
|
@ -82,7 +82,7 @@ static IUB: [AminoAcid, ..15] = [
|
|||
AminoAcid { c: 'Y' as u8, p: 0.02 },
|
||||
];
|
||||
|
||||
static HOMO_SAPIENS: [AminoAcid, ..4] = [
|
||||
static HOMO_SAPIENS: [AminoAcid;4] = [
|
||||
AminoAcid { c: 'a' as u8, p: 0.3029549426680 },
|
||||
AminoAcid { c: 'c' as u8, p: 0.1979883004921 },
|
||||
AminoAcid { c: 'g' as u8, p: 0.1975473066391 },
|
||||
|
@ -148,8 +148,8 @@ impl<'a, W: Writer> RepeatFasta<'a, W> {
|
|||
}
|
||||
}
|
||||
|
||||
fn make_lookup(a: &[AminoAcid]) -> [AminoAcid, ..LOOKUP_SIZE] {
|
||||
let mut lookup = [ NULL_AMINO_ACID, ..LOOKUP_SIZE ];
|
||||
fn make_lookup(a: &[AminoAcid]) -> [AminoAcid;LOOKUP_SIZE] {
|
||||
let mut lookup = [ NULL_AMINO_ACID;LOOKUP_SIZE ];
|
||||
let mut j = 0;
|
||||
for (i, slot) in lookup.iter_mut().enumerate() {
|
||||
while a[j].p < (i as f32) {
|
||||
|
@ -162,7 +162,7 @@ fn make_lookup(a: &[AminoAcid]) -> [AminoAcid, ..LOOKUP_SIZE] {
|
|||
|
||||
struct RandomFasta<'a, W:'a> {
|
||||
seed: u32,
|
||||
lookup: [AminoAcid, ..LOOKUP_SIZE],
|
||||
lookup: [AminoAcid;LOOKUP_SIZE],
|
||||
out: &'a mut W,
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ impl<'a, W: Writer> RandomFasta<'a, W> {
|
|||
fn make(&mut self, n: uint) -> IoResult<()> {
|
||||
let lines = n / LINE_LEN;
|
||||
let chars_left = n % LINE_LEN;
|
||||
let mut buf = [0, ..LINE_LEN + 1];
|
||||
let mut buf = [0;LINE_LEN + 1];
|
||||
|
||||
for _ in range(0, lines) {
|
||||
for i in range(0u, LINE_LEN) {
|
||||
|
|
|
@ -89,7 +89,7 @@ fn make_fasta<W: Writer, I: Iterator<u8>>(
|
|||
-> std::io::IoResult<()>
|
||||
{
|
||||
try!(wr.write(header.as_bytes()));
|
||||
let mut line = [0u8, .. LINE_LENGTH + 1];
|
||||
let mut line = [0u8; LINE_LENGTH + 1];
|
||||
while n > 0 {
|
||||
let nb = min(LINE_LENGTH, n);
|
||||
for i in range(0, nb) {
|
||||
|
|
|
@ -46,10 +46,10 @@ use std::string::String;
|
|||
use std::slice;
|
||||
use std::sync::{Arc, Future};
|
||||
|
||||
static TABLE: [u8, ..4] = [ 'A' as u8, 'C' as u8, 'G' as u8, 'T' as u8 ];
|
||||
static TABLE: [u8;4] = [ 'A' as u8, 'C' as u8, 'G' as u8, 'T' as u8 ];
|
||||
static TABLE_SIZE: uint = 2 << 16;
|
||||
|
||||
static OCCURRENCES: [&'static str, ..5] = [
|
||||
static OCCURRENCES: [&'static str;5] = [
|
||||
"GGT",
|
||||
"GGTA",
|
||||
"GGTATT",
|
||||
|
|
|
@ -45,7 +45,7 @@ const SOLAR_MASS: f64 = 4.0 * PI * PI;
|
|||
const YEAR: f64 = 365.24;
|
||||
const N_BODIES: uint = 5;
|
||||
|
||||
static BODIES: [Planet, ..N_BODIES] = [
|
||||
static BODIES: [Planet;N_BODIES] = [
|
||||
// Sun
|
||||
Planet {
|
||||
x: 0.0, y: 0.0, z: 0.0,
|
||||
|
@ -102,7 +102,7 @@ struct Planet {
|
|||
|
||||
impl Copy for Planet {}
|
||||
|
||||
fn advance(bodies: &mut [Planet, ..N_BODIES], dt: f64, steps: int) {
|
||||
fn advance(bodies: &mut [Planet;N_BODIES], dt: f64, steps: int) {
|
||||
for _ in range(0, steps) {
|
||||
let mut b_slice = bodies.as_mut_slice();
|
||||
loop {
|
||||
|
@ -135,7 +135,7 @@ fn advance(bodies: &mut [Planet, ..N_BODIES], dt: f64, steps: int) {
|
|||
}
|
||||
}
|
||||
|
||||
fn energy(bodies: &[Planet, ..N_BODIES]) -> f64 {
|
||||
fn energy(bodies: &[Planet;N_BODIES]) -> f64 {
|
||||
let mut e = 0.0;
|
||||
let mut bodies = bodies.iter();
|
||||
loop {
|
||||
|
@ -155,7 +155,7 @@ fn energy(bodies: &[Planet, ..N_BODIES]) -> f64 {
|
|||
e
|
||||
}
|
||||
|
||||
fn offset_momentum(bodies: &mut [Planet, ..N_BODIES]) {
|
||||
fn offset_momentum(bodies: &mut [Planet;N_BODIES]) {
|
||||
let mut px = 0.0;
|
||||
let mut py = 0.0;
|
||||
let mut pz = 0.0;
|
||||
|
|
|
@ -50,17 +50,17 @@ use std::ptr::{copy_memory};
|
|||
use std::io::{IoResult, EndOfFile};
|
||||
|
||||
struct Tables {
|
||||
table8: [u8, ..1 << 8],
|
||||
table16: [u16, ..1 << 16]
|
||||
table8: [u8;1 << 8],
|
||||
table16: [u16;1 << 16]
|
||||
}
|
||||
|
||||
impl Tables {
|
||||
fn new() -> Tables {
|
||||
let mut table8 = [0, ..1 << 8];
|
||||
let mut table8 = [0;1 << 8];
|
||||
for (i, v) in table8.iter_mut().enumerate() {
|
||||
*v = Tables::computed_cpl8(i as u8);
|
||||
}
|
||||
let mut table16 = [0, ..1 << 16];
|
||||
let mut table16 = [0;1 << 16];
|
||||
for (i, v) in table16.iter_mut().enumerate() {
|
||||
*v = table8[i & 255] as u16 << 8 |
|
||||
table8[i >> 8] as u16;
|
||||
|
|
|
@ -46,7 +46,7 @@ impl Sudoku {
|
|||
return Sudoku { grid: g }
|
||||
}
|
||||
|
||||
pub fn from_vec(vec: &[[u8, ..9], ..9]) -> Sudoku {
|
||||
pub fn from_vec(vec: &[[u8;9];9]) -> Sudoku {
|
||||
let g = Vec::from_fn(9u, |i| {
|
||||
Vec::from_fn(9u, |j| { vec[i][j] })
|
||||
});
|
||||
|
@ -198,7 +198,7 @@ impl Colors {
|
|||
}
|
||||
}
|
||||
|
||||
static DEFAULT_SUDOKU: [[u8, ..9], ..9] = [
|
||||
static DEFAULT_SUDOKU: [[u8;9];9] = [
|
||||
/* 0 1 2 3 4 5 6 7 8 */
|
||||
/* 0 */ [0u8, 4u8, 0u8, 6u8, 0u8, 0u8, 0u8, 3u8, 2u8],
|
||||
/* 1 */ [0u8, 0u8, 8u8, 0u8, 2u8, 0u8, 0u8, 0u8, 0u8],
|
||||
|
@ -212,7 +212,7 @@ static DEFAULT_SUDOKU: [[u8, ..9], ..9] = [
|
|||
];
|
||||
|
||||
#[cfg(test)]
|
||||
static DEFAULT_SOLUTION: [[u8, ..9], ..9] = [
|
||||
static DEFAULT_SOLUTION: [[u8;9];9] = [
|
||||
/* 0 1 2 3 4 5 6 7 8 */
|
||||
/* 0 */ [1u8, 4u8, 9u8, 6u8, 7u8, 5u8, 8u8, 3u8, 2u8],
|
||||
/* 1 */ [5u8, 3u8, 8u8, 1u8, 2u8, 9u8, 7u8, 4u8, 6u8],
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let x: [int ..3]; //~ ERROR expected one of `(`, `+`, `,`, `::`, or `]`, found `..`
|
||||
let x: [int 3]; //~ ERROR expected one of `(`, `+`, `,`, `::`, `;`, or `]`, found `3`
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// Issue #16205.
|
||||
|
||||
struct Foo {
|
||||
a: [Box<int>, ..3],
|
||||
a: [Box<int>; 3],
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Tests that we forbid coercion from `[T, ..n]` to `&[T]`
|
||||
// Tests that we forbid coercion from `[T; n]` to `&[T]`
|
||||
|
||||
fn main() {
|
||||
let _: &[int] = [0i]; //~ERROR: mismatched types: expected `&[int]`, found `[int, ..1]`
|
||||
let _: &[int] = [0i]; //~ERROR: mismatched types: expected `&[int]`, found `[int; 1]`
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
static a: [u8, ..3] = ['h' as u8, 'i' as u8, 0 as u8];
|
||||
static a: [u8; 3] = ['h' as u8, 'i' as u8, 0 as u8];
|
||||
static b: *const i8 = &a as *const i8; //~ ERROR mismatched types
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -20,9 +20,9 @@ trait Bar {}
|
|||
pub fn main() {
|
||||
// With a vec of ints.
|
||||
let f1 = Fat { ptr: [1, 2, 3] };
|
||||
let f2: &Fat<[int, ..3]> = &f1;
|
||||
let f2: &Fat<[int; 3]> = &f1;
|
||||
let f3: &Fat<[uint]> = f2;
|
||||
//~^ ERROR mismatched types: expected `&Fat<[uint]>`, found `&Fat<[int, ..3]>`
|
||||
//~^ ERROR mismatched types: expected `&Fat<[uint]>`, found `&Fat<[int; 3]>`
|
||||
|
||||
// With a trait.
|
||||
let f1 = Fat { ptr: Foo };
|
||||
|
|
|
@ -21,7 +21,7 @@ impl Bar for Foo {}
|
|||
pub fn main() {
|
||||
// With a vec of ints.
|
||||
let f1 = Fat { ptr: [1, 2, 3] };
|
||||
let f2: &Fat<[int, ..3]> = &f1;
|
||||
let f2: &Fat<[int; 3]> = &f1;
|
||||
let f3: &mut Fat<[int]> = f2; //~ ERROR mismatched types
|
||||
|
||||
// With a trait.
|
||||
|
|
|
@ -21,7 +21,7 @@ impl Bar for Foo {}
|
|||
fn baz<'a>() {
|
||||
// With a vec of ints.
|
||||
let f1 = Fat { ptr: [1, 2, 3] };
|
||||
let f2: &Fat<[int, ..3]> = &f1; //~ ERROR `f1` does not live long enough
|
||||
let f2: &Fat<[int; 3]> = &f1; //~ ERROR `f1` does not live long enough
|
||||
let f3: &'a Fat<[int]> = f2;
|
||||
|
||||
// With a trait.
|
||||
|
|
|
@ -17,6 +17,6 @@ struct Fat<Sized? T> {
|
|||
pub fn main() {
|
||||
// With a vec of ints.
|
||||
let f1: &Fat<[int]> = &Fat { ptr: [1, 2, 3] };
|
||||
let f2: &Fat<[int, ..3]> = f1;
|
||||
//~^ ERROR mismatched types: expected `&Fat<[int, ..3]>`, found `&Fat<[int]>`
|
||||
let f2: &Fat<[int; 3]> = f1;
|
||||
//~^ ERROR mismatched types: expected `&Fat<[int; 3]>`, found `&Fat<[int]>`
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ struct Fat<Sized? T> {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let f: Fat<[int, ..3]> = Fat { ptr: [5i, 6, 7] };
|
||||
let f: Fat<[int; 3]> = Fat { ptr: [5i, 6, 7] };
|
||||
let g: &Fat<[int]> = &f;
|
||||
let h: &Fat<Fat<[int]>> = &Fat { ptr: *g };
|
||||
//~^ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
// error-pattern: too big for the current
|
||||
|
||||
fn main() {
|
||||
let fat : [u8, ..(1<<61)+(1<<31)] = [0, ..(1u64<<61) as uint +(1u64<<31) as uint];
|
||||
let fat : [u8; (1<<61)+(1<<31)] = [0; (1u64<<61) as uint +(1u64<<31) as uint];
|
||||
}
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: ..1518599999
|
||||
// error-pattern:; 1518599999
|
||||
|
||||
fn generic<T: Copy>(t: T) {
|
||||
let s: [T, ..1518600000] = [t, ..1518600000];
|
||||
let s: [T; 1518600000] = [t; 1518600000];
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: [u8, ..1518599999] = [0, ..1518599999];
|
||||
generic::<[u8, ..1518599999]>(x);
|
||||
let x: [u8; 1518599999] = [0; 1518599999];
|
||||
generic::<[u8; 1518599999]>(x);
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
#[cfg(target_word_size = "32")]
|
||||
fn main() {
|
||||
let big: Option<[u32, ..(1<<29)-1]> = None;
|
||||
let big: Option<[u32; (1<<29)-1]> = None;
|
||||
}
|
||||
|
||||
#[cfg(target_word_size = "64")]
|
||||
fn main() {
|
||||
let big: Option<[u32, ..(1<<45)-1]> = None;
|
||||
let big: Option<[u32; (1<<45)-1]> = None;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
// error-pattern: mismatched types
|
||||
|
||||
static VEC: [u32, ..256] = vec!();
|
||||
static VEC: [u32; 256] = vec!();
|
||||
|
||||
fn main() {}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ fn main() {
|
|||
let x = [1,2];
|
||||
let y = match x {
|
||||
[] => None,
|
||||
//~^ ERROR types: expected `[_#0i, ..2]`, found `[_#7t, ..0]`
|
||||
//~^ ERROR types: expected `[_#0i; 2]`, found `[_#7t; 0]`
|
||||
// (expected array of 2 elements, found array of 0 elements)
|
||||
[a,_] => Some(a)
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ fn main() {
|
|||
let x = [1,2];
|
||||
let y = match x {
|
||||
[] => None,
|
||||
//~^ ERROR types: expected `[_, ..2]`, found `[_, ..0]`
|
||||
//~^ ERROR types: expected `[_; 2]`, found `[_; 0]`
|
||||
// (expected array of 2 elements, found array of 0 elements)
|
||||
[a,_] => Some(a)
|
||||
};
|
||||
|
|
|
@ -10,15 +10,15 @@
|
|||
|
||||
|
||||
struct X {
|
||||
a: [u8, ..1]
|
||||
a: [u8; 1]
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = X { a: [0] };
|
||||
let _f = &x.a as *mut u8;
|
||||
//~^ ERROR mismatched types: expected `*mut u8`, found `&[u8, ..1]`
|
||||
//~^ ERROR mismatched types: expected `*mut u8`, found `&[u8; 1]`
|
||||
|
||||
let local = [0u8];
|
||||
let _v = &local as *mut u8;
|
||||
//~^ ERROR mismatched types: expected `*mut u8`, found `&[u8, ..1]`
|
||||
//~^ ERROR mismatched types: expected `*mut u8`, found `&[u8; 1]`
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
static FOO: uint = FOO; //~ ERROR recursive constant
|
||||
|
||||
fn main() {
|
||||
let _x: [u8, ..FOO]; // caused stack overflow prior to fix
|
||||
let _x: [u8; FOO]; // caused stack overflow prior to fix
|
||||
let _y: uint = 1 + {
|
||||
static BAR: uint = BAR; //~ ERROR recursive constant
|
||||
let _z: [u8, ..BAR]; // caused stack overflow prior to fix
|
||||
let _z: [u8; BAR]; // caused stack overflow prior to fix
|
||||
1
|
||||
};
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
fn main() {
|
||||
let _foo = &[1u, 2] as [uint];
|
||||
//~^ ERROR cast to unsized type: `&[uint, ..2]` as `[uint]`
|
||||
//~^ ERROR cast to unsized type: `&[uint; 2]` as `[uint]`
|
||||
//~^^ HELP consider using an implicit coercion to `&[uint]` instead
|
||||
let _bar = box 1u as std::fmt::Show;
|
||||
//~^ ERROR cast to unsized type: `Box<uint>` as `core::fmt::Show`
|
||||
|
@ -19,6 +19,6 @@ fn main() {
|
|||
//~^ ERROR cast to unsized type: `uint` as `core::fmt::Show`
|
||||
//~^^ HELP consider using a box or reference as appropriate
|
||||
let _quux = [1u, 2] as [uint];
|
||||
//~^ ERROR cast to unsized type: `[uint, ..2]` as `[uint]`
|
||||
//~^ ERROR cast to unsized type: `[uint; 2]` as `[uint]`
|
||||
//~^^ HELP consider using a box or reference as appropriate
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ static B: &'static uint = &A.a;
|
|||
static C: &'static uint = &(A.a);
|
||||
//~^ ERROR: cannot refer to the interior of another static
|
||||
|
||||
static D: [uint, ..1] = [1];
|
||||
static D: [uint; 1] = [1];
|
||||
static E: uint = D[0];
|
||||
//~^ ERROR: cannot refer to other statics by value
|
||||
static F: &'static uint = &D[0];
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
const TUP: (uint,) = (42,);
|
||||
|
||||
fn main() {
|
||||
let a: [int, ..TUP.1];
|
||||
let a: [int; TUP.1];
|
||||
//~^ ERROR expected constant expr for array length: tuple index out of bounds
|
||||
}
|
||||
|
|
|
@ -12,6 +12,6 @@ struct MyStruct { field: uint }
|
|||
const STRUCT: MyStruct = MyStruct { field: 42 };
|
||||
|
||||
fn main() {
|
||||
let a: [int, ..STRUCT.nonexistent_field];
|
||||
let a: [int; STRUCT.nonexistent_field];
|
||||
//~^ ERROR expected constant expr for array length: nonexistent struct field
|
||||
}
|
||||
|
|
|
@ -22,5 +22,5 @@ impl<A> vec_monad<A> for Vec<A> {
|
|||
}
|
||||
fn main() {
|
||||
["hi"].bind(|x| [x] );
|
||||
//~^ ERROR type `[&str, ..1]` does not implement any method in scope named `bind`
|
||||
//~^ ERROR type `[&str; 1]` does not implement any method in scope named `bind`
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
fn bar(int_param: int) {}
|
||||
|
||||
fn main() {
|
||||
let foo: [u8, ..4] = [1u8, ..4u];
|
||||
let foo: [u8; 4] = [1u8; 4u];
|
||||
bar(foo);
|
||||
//~^ ERROR mismatched types: expected `int`, found `[u8, ..4]`
|
||||
//~^ ERROR mismatched types: expected `int`, found `[u8; 4]`
|
||||
// (expected int, found vector)
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ fn main() {
|
|||
println!("{}", Test);
|
||||
|
||||
let mut f = File::open(&Path::new("something.txt"));
|
||||
let mut buff = [0u8, ..16];
|
||||
let mut buff = [0u8; 16];
|
||||
match f.read(&mut buff) {
|
||||
Ok(cnt) => println!("read this many bytes: {}", cnt),
|
||||
Err(IoError{ kind: EndOfFile, .. }) => println!("Got end of file: {}", EndOfFile.to_string()),
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Test moving array structures, e.g. `[T, ..3]` as well as moving
|
||||
// Test moving array structures, e.g. `[T; 3]` as well as moving
|
||||
// elements in and out of such arrays.
|
||||
//
|
||||
// Note also that the `test_move_array_then_overwrite` tests represent
|
||||
|
@ -18,14 +18,14 @@ pub struct D { d: int }
|
|||
impl Drop for D { fn drop(&mut self) { } }
|
||||
|
||||
#[rustc_move_fragments]
|
||||
pub fn test_move_array_via_return(a: [D, ..3]) -> [D, ..3] {
|
||||
pub fn test_move_array_via_return(a: [D; 3]) -> [D; 3] {
|
||||
//~^ ERROR assigned_leaf_path: `$(local a)`
|
||||
//~| ERROR moved_leaf_path: `$(local a)`
|
||||
return a;
|
||||
}
|
||||
|
||||
#[rustc_move_fragments]
|
||||
pub fn test_move_array_into_recv(a: [D, ..3], recv: &mut [D, ..3]) {
|
||||
pub fn test_move_array_into_recv(a: [D; 3], recv: &mut [D; 3]) {
|
||||
//~^ ERROR parent_of_fragments: `$(local recv)`
|
||||
//~| ERROR assigned_leaf_path: `$(local a)`
|
||||
//~| ERROR moved_leaf_path: `$(local a)`
|
||||
|
@ -34,7 +34,7 @@ pub fn test_move_array_into_recv(a: [D, ..3], recv: &mut [D, ..3]) {
|
|||
}
|
||||
|
||||
#[rustc_move_fragments]
|
||||
pub fn test_extract_array_elem(a: [D, ..3], i: uint) -> D {
|
||||
pub fn test_extract_array_elem(a: [D; 3], i: uint) -> D {
|
||||
//~^ ERROR parent_of_fragments: `$(local a)`
|
||||
//~| ERROR assigned_leaf_path: `$(local i)`
|
||||
//~| ERROR moved_leaf_path: `$(local a).[]`
|
||||
|
@ -43,7 +43,7 @@ pub fn test_extract_array_elem(a: [D, ..3], i: uint) -> D {
|
|||
}
|
||||
|
||||
#[rustc_move_fragments]
|
||||
pub fn test_overwrite_array_elem(mut a: [D, ..3], i: uint, d: D) {
|
||||
pub fn test_overwrite_array_elem(mut a: [D; 3], i: uint, d: D) {
|
||||
//~^ ERROR parent_of_fragments: `$(local mut a)`
|
||||
//~| ERROR assigned_leaf_path: `$(local i)`
|
||||
//~| ERROR assigned_leaf_path: `$(local d)`
|
||||
|
@ -59,7 +59,7 @@ pub fn test_overwrite_array_elem(mut a: [D, ..3], i: uint, d: D) {
|
|||
// See RFC PR 320 for more discussion.
|
||||
|
||||
#[rustc_move_fragments]
|
||||
pub fn test_move_array_then_overwrite_elem1(mut a: [D, ..3], i: uint, recv: &mut [D, ..3], d: D) {
|
||||
pub fn test_move_array_then_overwrite_elem1(mut a: [D; 3], i: uint, recv: &mut [D; 3], d: D) {
|
||||
//~^ ERROR parent_of_fragments: `$(local mut a)`
|
||||
//~| ERROR parent_of_fragments: `$(local recv)`
|
||||
//~| ERROR assigned_leaf_path: `$(local recv).*`
|
||||
|
@ -76,8 +76,8 @@ pub fn test_move_array_then_overwrite_elem1(mut a: [D, ..3], i: uint, recv: &mut
|
|||
}
|
||||
|
||||
#[rustc_move_fragments]
|
||||
pub fn test_move_array_then_overwrite_elem2(mut a: [D, ..3], i: uint, j: uint,
|
||||
recv: &mut [D, ..3], d1: D, d2: D) {
|
||||
pub fn test_move_array_then_overwrite_elem2(mut a: [D; 3], i: uint, j: uint,
|
||||
recv: &mut [D; 3], d1: D, d2: D) {
|
||||
//~^^ ERROR parent_of_fragments: `$(local mut a)`
|
||||
//~| ERROR parent_of_fragments: `$(local recv)`
|
||||
//~| ERROR assigned_leaf_path: `$(local recv).*`
|
||||
|
|
|
@ -89,7 +89,7 @@ fn f100() {
|
|||
|
||||
fn f110() {
|
||||
let x = vec!("hi".to_string());
|
||||
let _y = [x.into_iter().next().unwrap(), ..1];
|
||||
let _y = [x.into_iter().next().unwrap(); 1];
|
||||
touch(&x); //~ ERROR use of moved value: `x`
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
enum State { ST_NULL, ST_WHITESPACE }
|
||||
|
||||
fn main() {
|
||||
[State::ST_NULL, ..(State::ST_WHITESPACE as uint)];
|
||||
[State::ST_NULL; (State::ST_WHITESPACE as uint)];
|
||||
//~^ ERROR expected constant integer for repeat count, found non-constant expression
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
fn main() {
|
||||
fn bar(n: int) {
|
||||
let _x: [int, ..n];
|
||||
let _x: [int; n];
|
||||
//~^ ERROR expected constant expr for array length: non-constant path in constant expr
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
|
||||
fn main() {
|
||||
fn bar(n: uint) {
|
||||
let _x = [0, ..n]; //~ ERROR expected constant integer for repeat count, found variable
|
||||
let _x = [0; n]; //~ ERROR expected constant integer for repeat count, found variable
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
struct Foo {
|
||||
first: bool,
|
||||
second: Option<[uint, ..4]>
|
||||
second: Option<[uint; 4]>
|
||||
}
|
||||
|
||||
enum Color {
|
||||
|
|
|
@ -33,7 +33,7 @@ struct Oof<T, S> {
|
|||
fn main() {
|
||||
let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
|
||||
unsafe {
|
||||
let oof: Oof<[u8, .. 5], i32> = mem::transmute(foo);
|
||||
let oof: Oof<[u8; 5], i32> = mem::transmute(foo);
|
||||
println!("{} {}", oof.rab[], oof.zab);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,4 +8,4 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
type v = [int * 3]; //~ ERROR expected one of `(`, `+`, `,`, `::`, or `]`, found `*`
|
||||
type v = [int * 3]; //~ ERROR expected one of `(`, `+`, `,`, `::`, `;`, or `]`, found `*`
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
fn f() {
|
||||
let v = [mut 1, 2, 3, 4];
|
||||
//~^ ERROR expected identifier, found keyword `mut`
|
||||
//~^^ ERROR expected one of `!`, `,`, `.`, `::`, `]`, `{`, or an operator, found `1`
|
||||
//~^^ ERROR expected one of `!`, `,`, `.`, `::`, `;`, `]`, `{`, or an operator, found `1`
|
||||
}
|
||||
|
|
|
@ -10,4 +10,4 @@
|
|||
|
||||
type v = [mut int];
|
||||
//~^ ERROR expected identifier, found keyword `mut`
|
||||
//~^^ ERROR expected one of `(`, `+`, `,`, `::`, or `]`, found `int`
|
||||
//~^^ ERROR expected one of `(`, `+`, `,`, `::`, `;`, or `]`, found `int`
|
||||
|
|
|
@ -24,6 +24,6 @@ impl Drop for Foo {
|
|||
|
||||
fn main() {
|
||||
let a = Foo { x: 3 };
|
||||
let _ = [ a, ..5 ];
|
||||
let _ = [ a; 5 ];
|
||||
//~^ ERROR the trait `core::kinds::Copy` is not implemented for the type `Foo`
|
||||
}
|
||||
|
|
|
@ -12,18 +12,18 @@
|
|||
|
||||
fn main() {
|
||||
let n = 1;
|
||||
let a = [0, ..n]; //~ ERROR expected constant integer for repeat count, found variable
|
||||
let b = [0, ..()];
|
||||
let a = [0; n]; //~ ERROR expected constant integer for repeat count, found variable
|
||||
let b = [0; ()];
|
||||
//~^ ERROR expected constant integer for repeat count, found non-constant expression
|
||||
//~^^ ERROR: expected `uint`, found `()`
|
||||
let c = [0, ..true]; //~ ERROR expected positive integer for repeat count, found boolean
|
||||
let c = [0; true]; //~ ERROR expected positive integer for repeat count, found boolean
|
||||
//~^ ERROR: expected `uint`, found `bool`
|
||||
let d = [0, ..0.5]; //~ ERROR expected positive integer for repeat count, found float
|
||||
let d = [0; 0.5]; //~ ERROR expected positive integer for repeat count, found float
|
||||
//~^ ERROR: expected `uint`, found `_`
|
||||
let e = [0, .."foo"]; //~ ERROR expected positive integer for repeat count, found string
|
||||
let e = [0; "foo"]; //~ ERROR expected positive integer for repeat count, found string
|
||||
//~^ ERROR: expected `uint`, found `&'static str`
|
||||
let f = [0, ..-4];
|
||||
let f = [0; -4];
|
||||
//~^ ERROR expected positive integer for repeat count, found negative integer
|
||||
let f = [0u, ..-1];
|
||||
let f = [0u; -1];
|
||||
//~^ ERROR expected positive integer for repeat count, found negative integer
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
fn foo() -> int { 23 }
|
||||
|
||||
static a: [int, ..2] = [foo(), ..2];
|
||||
static a: [int; 2] = [foo(); 2];
|
||||
//~^ ERROR: function calls in constants are limited to struct and enum constructors
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let [_, ..,] = [(), ()]; //~ ERROR unexpected token: `]`
|
||||
}
|
|
@ -20,7 +20,7 @@ unsafe fn g<T>(x: (T, int)) {
|
|||
let _: int = transmute(x); //~ ERROR cannot transmute
|
||||
}
|
||||
|
||||
unsafe fn h<T>(x: [T, ..10]) {
|
||||
unsafe fn h<T>(x: [T; 10]) {
|
||||
let _: int = transmute(x); //~ ERROR cannot transmute
|
||||
}
|
||||
|
||||
|
|
|
@ -12,20 +12,20 @@
|
|||
// presence of the `_` type shorthand notation.
|
||||
|
||||
struct X {
|
||||
y: [u8, ..2],
|
||||
y: [u8; 2],
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x1 = X { y: [0, 0] };
|
||||
|
||||
let p1: *const u8 = &x1.y as *const _; //~ ERROR mismatched types
|
||||
let t1: *const [u8, ..2] = &x1.y as *const _;
|
||||
let h1: *const [u8, ..2] = &x1.y as *const [u8, ..2];
|
||||
let t1: *const [u8; 2] = &x1.y as *const _;
|
||||
let h1: *const [u8; 2] = &x1.y as *const [u8; 2];
|
||||
|
||||
let mut x1 = X { y: [0, 0] };
|
||||
|
||||
let p1: *mut u8 = &mut x1.y as *mut _; //~ ERROR mismatched types
|
||||
let t1: *mut [u8, ..2] = &mut x1.y as *mut _;
|
||||
let h1: *mut [u8, ..2] = &mut x1.y as *mut [u8, ..2];
|
||||
let t1: *mut [u8; 2] = &mut x1.y as *mut _;
|
||||
let h1: *mut [u8; 2] = &mut x1.y as *mut [u8; 2];
|
||||
}
|
||||
|
||||
|
|
|
@ -53,28 +53,28 @@
|
|||
#![allow(unused_variables)]
|
||||
|
||||
struct NoPadding1 {
|
||||
x: [u32, ..3],
|
||||
x: [u32; 3],
|
||||
y: i32,
|
||||
z: [f32, ..2]
|
||||
z: [f32; 2]
|
||||
}
|
||||
|
||||
struct NoPadding2 {
|
||||
x: [u32, ..3],
|
||||
y: [[u32, ..2], ..2]
|
||||
x: [u32; 3],
|
||||
y: [[u32; 2]; 2]
|
||||
}
|
||||
|
||||
struct StructInternalPadding {
|
||||
x: [i16, ..2],
|
||||
y: [i64, ..2]
|
||||
x: [i16; 2],
|
||||
y: [i64; 2]
|
||||
}
|
||||
|
||||
struct SingleVec {
|
||||
x: [i16, ..5]
|
||||
x: [i16; 5]
|
||||
}
|
||||
|
||||
struct StructPaddedAtEnd {
|
||||
x: [i64, ..2],
|
||||
y: [i16, ..2]
|
||||
x: [i64; 2],
|
||||
y: [i16; 2]
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -450,7 +450,7 @@ fn main() {
|
|||
sentinel();
|
||||
|
||||
val
|
||||
}, ..10];
|
||||
}; 10];
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
@ -491,7 +491,7 @@ fn main() {
|
|||
sentinel();
|
||||
|
||||
// index expression
|
||||
let a_vector = [10i, ..20];
|
||||
let a_vector = [10i; 20];
|
||||
let _ = a_vector[{
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
|
|
@ -143,7 +143,7 @@ fn main() {
|
|||
value: 2,
|
||||
};
|
||||
|
||||
let vec_unique: [UniqueNode<f32>, ..1] = [UniqueNode {
|
||||
let vec_unique: [UniqueNode<f32>; 1] = [UniqueNode {
|
||||
next: Val {
|
||||
val: box UniqueNode {
|
||||
next: Empty,
|
||||
|
|
|
@ -99,10 +99,10 @@
|
|||
|
||||
// VECTORS
|
||||
// gdb-command:whatis fixed_size_vec1
|
||||
// gdb-check:type = struct ([type-names::Struct1, ..3], i16)
|
||||
// gdb-check:type = struct ([type-names::Struct1; 3], i16)
|
||||
|
||||
// gdb-command:whatis fixed_size_vec2
|
||||
// gdb-check:type = struct ([uint, ..3], i16)
|
||||
// gdb-check:type = struct ([uint; 3], i16)
|
||||
|
||||
// gdb-command:whatis slice1
|
||||
// gdb-check:type = struct &[uint]
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#![allow(unused_variables)]
|
||||
|
||||
static mut VECT: [i32, ..3] = [1, 2, 3];
|
||||
static mut VECT: [i32; 3] = [1, 2, 3];
|
||||
|
||||
fn main() {
|
||||
let a = [1i, 2, 3];
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
// pp-exact
|
||||
fn f() -> [int, ..3] {
|
||||
fn f() -> [int; 3] {
|
||||
let picard = 0;
|
||||
|
||||
let data = 1;
|
||||
|
|
|
@ -21,26 +21,26 @@ use std::prelude::*;
|
|||
|
||||
// #4264 fixed-length vector types
|
||||
|
||||
pub fn foo(_: [int, ..(3 as uint)]) { }
|
||||
pub fn foo(_: [int; (3 as uint)]) { }
|
||||
|
||||
pub fn bar() {
|
||||
const FOO: uint = ((5u as uint) - (4u as uint) as uint);
|
||||
let _: [(), ..(FOO as uint)] = ([(() as ())] as [(), ..1]);
|
||||
let _: [(); (FOO as uint)] = ([(() as ())] as [(); 1]);
|
||||
|
||||
let _: [(), ..(1u as uint)] = ([(() as ())] as [(), ..1]);
|
||||
let _: [(); (1u as uint)] = ([(() as ())] as [(); 1]);
|
||||
|
||||
let _ =
|
||||
(((&((([(1i as int), (2 as int), (3 as int)] as [int, ..3])) as
|
||||
[int, ..3]) as &[int, ..3]) as *const _ as *const [int, ..3])
|
||||
as *const [int, ..(3u as uint)] as *const [int, ..3]);
|
||||
(((&((([(1i as int), (2 as int), (3 as int)] as [int; 3])) as
|
||||
[int; 3]) as &[int; 3]) as *const _ as *const [int; 3]) as
|
||||
*const [int; (3u as uint)] as *const [int; 3]);
|
||||
|
||||
(match (() as ()) {
|
||||
() => {
|
||||
#[inline]
|
||||
#[allow(dead_code)]
|
||||
static __STATIC_FMTSTR: &'static [&'static str] =
|
||||
(&([("test" as &'static str)] as [&'static str, ..1]) as
|
||||
&'static [&'static str, ..1]);
|
||||
(&([("test" as &'static str)] as [&'static str; 1]) as
|
||||
&'static [&'static str; 1]);
|
||||
|
||||
|
||||
|
||||
|
@ -57,9 +57,9 @@ pub fn bar() {
|
|||
&'static [&'static str]),
|
||||
(&([]
|
||||
as
|
||||
[core::fmt::Argument<'_>, ..0])
|
||||
[core::fmt::Argument<'_>; 0])
|
||||
as
|
||||
&[core::fmt::Argument<'_>, ..0]))
|
||||
&[core::fmt::Argument<'_>; 0]))
|
||||
as
|
||||
core::fmt::Arguments<'_>)
|
||||
as
|
||||
|
@ -68,18 +68,17 @@ pub fn bar() {
|
|||
}
|
||||
} as collections::string::String);
|
||||
}
|
||||
pub type Foo = [int, ..(3u as uint)];
|
||||
pub type Foo = [int; (3u as uint)];
|
||||
pub struct Bar {
|
||||
pub x: [int, ..(3u as uint)],
|
||||
pub x: [int; (3u as uint)],
|
||||
}
|
||||
pub struct TupleBar([int, ..(4u as uint)]);
|
||||
pub enum Baz { BazVariant([int, ..(5u as uint)]), }
|
||||
pub struct TupleBar([int; (4u as uint)]);
|
||||
pub enum Baz { BazVariant([int; (5u as uint)]), }
|
||||
pub fn id<T>(x: T) -> T { (x as T) }
|
||||
pub fn use_id() {
|
||||
let _ =
|
||||
((id::<[int, ..(3u as uint)]> as
|
||||
fn([int, ..3]) -> [int, ..3])(([(1 as int), (2 as int),
|
||||
(3 as int)] as [int, ..3])) as
|
||||
[int, ..3]);
|
||||
((id::<[int; (3u as uint)]> as
|
||||
fn([int; 3]) -> [int; 3])(([(1 as int), (2 as int), (3 as int)]
|
||||
as [int; 3])) as [int; 3]);
|
||||
}
|
||||
fn main() { }
|
||||
|
|
|
@ -20,6 +20,6 @@ extern {
|
|||
#[no_stack_check]
|
||||
pub unsafe fn foo() {
|
||||
// Make sure we use the stack
|
||||
let x: [u8, ..50] = [0, ..50];
|
||||
let x: [u8; 50] = [0; 50];
|
||||
black_box(x.as_ptr());
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@ extern {
|
|||
|
||||
pub unsafe fn foo() {
|
||||
// Make sure we use the stack
|
||||
let x: [u8, ..50] = [0, ..50];
|
||||
let x: [u8; 50] = [0; 50];
|
||||
black_box(x.as_ptr());
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ trait Sized { }
|
|||
fn start(_main: *const u8, _argc: int, _argv: *const *const u8) -> int { 0 }
|
||||
|
||||
extern {
|
||||
fn _foo() -> [u8, ..16];
|
||||
fn _foo() -> [u8; 16];
|
||||
}
|
||||
|
||||
fn _main() {
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
const SIZE: int = 25;
|
||||
|
||||
fn main() {
|
||||
let _a: [bool, ..1 as uint];
|
||||
let _b: [int, ..SIZE as uint] = [1, ..SIZE as uint];
|
||||
let _c: [bool, ..'\n' as uint] = [true, ..'\n' as uint];
|
||||
let _d: [bool, ..true as uint] = [true, ..true as uint];
|
||||
let _a: [bool; 1 as uint];
|
||||
let _b: [int; SIZE as uint] = [1; SIZE as uint];
|
||||
let _c: [bool; '\n' as uint] = [true; '\n' as uint];
|
||||
let _d: [bool; true as uint] = [true; true as uint];
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
// Check that the various ways of getting to a reference to a vec (both sized
|
||||
// and unsized) work properly.
|
||||
|
||||
const aa: [int, ..3] = [1, 2, 3];
|
||||
const ab: &'static [int, ..3] = &aa;
|
||||
const aa: [int; 3] = [1, 2, 3];
|
||||
const ab: &'static [int; 3] = &aa;
|
||||
const ac: &'static [int] = ab;
|
||||
const ad: &'static [int] = &aa;
|
||||
const ae: &'static [int, ..3] = &[1, 2, 3];
|
||||
const ae: &'static [int; 3] = &[1, 2, 3];
|
||||
const af: &'static [int] = &[1, 2, 3];
|
||||
|
||||
static ca: int = aa[0];
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
static A: [u8, ..1] = ['h' as u8];
|
||||
static A: [u8; 1] = ['h' as u8];
|
||||
static B: u8 = (&A)[0];
|
||||
static C: &'static &'static &'static &'static [u8, ..1] = & & & &A;
|
||||
static C: &'static &'static &'static &'static [u8; 1] = & & & &A;
|
||||
static D: u8 = (&C)[0];
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
@ -12,7 +12,7 @@ enum E { V1(int), V0 }
|
|||
const C: &'static [E] = &[E::V0, E::V1(0xDEADBEE)];
|
||||
static C0: E = C[0];
|
||||
static C1: E = C[1];
|
||||
const D: &'static [E, ..2] = &[E::V0, E::V1(0xDEADBEE)];
|
||||
const D: &'static [E; 2] = &[E::V0, E::V1(0xDEADBEE)];
|
||||
static D0: E = C[0];
|
||||
static D1: E = C[1];
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
enum E { V1(int), V0 }
|
||||
static C: [E, ..3] = [E::V0, E::V1(0xDEADBEE), E::V0];
|
||||
static C: [E; 3] = [E::V0, E::V1(0xDEADBEE), E::V0];
|
||||
|
||||
pub fn main() {
|
||||
match C[1] {
|
||||
|
|
|
@ -14,6 +14,6 @@
|
|||
pub fn main() {
|
||||
|
||||
const FOO: uint = 2;
|
||||
let _v: [int, ..FOO*3];
|
||||
let _v: [int; FOO*3];
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@
|
|||
pub fn main() {
|
||||
|
||||
const FOO: uint = 2;
|
||||
let _v = [0i, ..FOO*3*2/2];
|
||||
let _v = [0i; FOO*3*2/2];
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const x : [int, ..4] = [1,2,3,4];
|
||||
const x : [int; 4] = [1,2,3,4];
|
||||
static p : int = x[2];
|
||||
const y : &'static [int] = &[1,2,3,4];
|
||||
static q : int = y[2];
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
type Big = [u64, ..8];
|
||||
type Big = [u64; 8];
|
||||
struct Pair<'a> { a: int, b: &'a Big }
|
||||
const x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]);
|
||||
const y: &'static Pair<'static> = &Pair {a: 15, b: x};
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
use std::{str, string};
|
||||
|
||||
const A: [u8, ..2] = ['h' as u8, 'i' as u8];
|
||||
const B: &'static [u8, ..2] = &A;
|
||||
const A: [u8; 2] = ['h' as u8, 'i' as u8];
|
||||
const B: &'static [u8; 2] = &A;
|
||||
const C: *const u8 = B as *const u8;
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
static x : [int, ..4] = [1,2,3,4];
|
||||
static x : [int; 4] = [1,2,3,4];
|
||||
static y : &'static [int] = &[1,2,3,4];
|
||||
static z : &'static [int, ..4] = &[1,2,3,4];
|
||||
static z : &'static [int; 4] = &[1,2,3,4];
|
||||
static zz : &'static [int] = &[1,2,3,4];
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
@ -120,7 +120,7 @@ pub fn main() {
|
|||
assert!((*f2)[1] == 2);
|
||||
|
||||
// Nested Box.
|
||||
let f1 : Box<Fat<[int, ..3]>> = box Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] };
|
||||
let f1 : Box<Fat<[int; 3]>> = box Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] };
|
||||
foo(&*f1);
|
||||
let f2 : Box<Fat<[int]>> = f1;
|
||||
foo(&*f2);
|
||||
|
|
|
@ -16,9 +16,9 @@ const BAR:uint = Flopsy::Bunny as uint;
|
|||
const BAR2:uint = BAR;
|
||||
|
||||
pub fn main() {
|
||||
let _v = [0i, .. Flopsy::Bunny as uint];
|
||||
let _v = [0i, .. BAR];
|
||||
let _v = [0i, .. BAR2];
|
||||
let _v = [0i; Flopsy::Bunny as uint];
|
||||
let _v = [0i; BAR];
|
||||
let _v = [0i; BAR2];
|
||||
const BAR3:uint = BAR2;
|
||||
let _v = [0i, .. BAR3];
|
||||
let _v = [0i; BAR3];
|
||||
}
|
||||
|
|
|
@ -13,16 +13,16 @@
|
|||
// Doesn't work; needs a design decision.
|
||||
|
||||
pub fn main() {
|
||||
let x : [int, ..5] = [1,2,3,4,5];
|
||||
let _y : [int, ..5] = [1,2,3,4,5];
|
||||
let x : [int; 5] = [1,2,3,4,5];
|
||||
let _y : [int; 5] = [1,2,3,4,5];
|
||||
let mut z = [1,2,3,4,5];
|
||||
z = x;
|
||||
assert_eq!(z[0], 1);
|
||||
assert_eq!(z[4], 5);
|
||||
|
||||
let a : [int, ..5] = [1,1,1,1,1];
|
||||
let b : [int, ..5] = [2,2,2,2,2];
|
||||
let c : [int, ..5] = [2,2,2,2,3];
|
||||
let a : [int; 5] = [1,1,1,1,1];
|
||||
let b : [int; 5] = [2,2,2,2,2];
|
||||
let c : [int; 5] = [2,2,2,2,3];
|
||||
|
||||
log(debug, a);
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ use std::mem::size_of;
|
|||
|
||||
#[cfg(target_word_size = "32")]
|
||||
pub fn main() {
|
||||
assert_eq!(size_of::<[u8, ..(1 << 31) - 1]>(), (1 << 31) - 1);
|
||||
assert_eq!(size_of::<[u8; (1 << 31) - 1]>(), (1 << 31) - 1);
|
||||
}
|
||||
|
||||
#[cfg(target_word_size = "64")]
|
||||
pub fn main() {
|
||||
assert_eq!(size_of::<[u8, ..(1 << 47) - 1]>(), (1 << 47) - 1);
|
||||
assert_eq!(size_of::<[u8; (1 << 47) - 1]>(), (1 << 47) - 1);
|
||||
}
|
||||
|
|
|
@ -12,22 +12,22 @@
|
|||
|
||||
trait Foo {}
|
||||
impl Foo for int {}
|
||||
fn foo(_: [&Foo, ..2]) {}
|
||||
fn foo(_: [&Foo; 2]) {}
|
||||
fn foos(_: &[&Foo]) {}
|
||||
fn foog<T>(_: &[T], _: &[T]) {}
|
||||
|
||||
fn bar(_: [Box<Foo>, ..2]) {}
|
||||
fn bar(_: [Box<Foo>; 2]) {}
|
||||
fn bars(_: &[Box<Foo>]) {}
|
||||
|
||||
fn main() {
|
||||
let x: [&Foo, ..2] = [&1i, &2i];
|
||||
let x: [&Foo; 2] = [&1i, &2i];
|
||||
foo(x);
|
||||
foo([&1i, &2i]);
|
||||
|
||||
let r = &1i;
|
||||
let x: [&Foo, ..2] = [r, ..2];
|
||||
let x: [&Foo; 2] = [r; 2];
|
||||
foo(x);
|
||||
foo([&1i, ..2]);
|
||||
foo([&1i; 2]);
|
||||
|
||||
let x: &[&Foo] = &[&1i, &2i];
|
||||
foos(x);
|
||||
|
@ -37,7 +37,7 @@ fn main() {
|
|||
let r = &1i;
|
||||
foog(x, &[r]);
|
||||
|
||||
let x: [Box<Foo>, ..2] = [box 1i, box 2i];
|
||||
let x: [Box<Foo>; 2] = [box 1i, box 2i];
|
||||
bar(x);
|
||||
bar([box 1i, box 2i]);
|
||||
|
||||
|
@ -49,16 +49,16 @@ fn main() {
|
|||
foog(x, &[box 1i]);
|
||||
|
||||
struct T<'a> {
|
||||
t: [&'a (Foo+'a), ..2]
|
||||
t: [&'a (Foo+'a); 2]
|
||||
}
|
||||
let _n = T {
|
||||
t: [&1i, &2i]
|
||||
};
|
||||
let r = &1i;
|
||||
let _n = T {
|
||||
t: [r, ..2]
|
||||
t: [r; 2]
|
||||
};
|
||||
let x: [&Foo, ..2] = [&1i, &2i];
|
||||
let x: [&Foo; 2] = [&1i, &2i];
|
||||
let _n = T {
|
||||
t: x
|
||||
};
|
||||
|
@ -70,11 +70,11 @@ fn main() {
|
|||
t: &[&1i, &2i]
|
||||
};
|
||||
let r = &1i;
|
||||
let r: [&Foo, ..2] = [r, ..2];
|
||||
let r: [&Foo; 2] = [r; 2];
|
||||
let _n = F {
|
||||
t: &r
|
||||
};
|
||||
let x: [&Foo, ..2] = [&1i, &2i];
|
||||
let x: [&Foo; 2] = [&1i, &2i];
|
||||
let _n = F {
|
||||
t: &x
|
||||
};
|
||||
|
@ -85,7 +85,7 @@ fn main() {
|
|||
let _n = M {
|
||||
t: &[box 1i, box 2i]
|
||||
};
|
||||
let x: [Box<Foo>, ..2] = [box 1i, box 2i];
|
||||
let x: [Box<Foo>; 2] = [box 1i, box 2i];
|
||||
let _n = M {
|
||||
t: &x
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@ mod imp {
|
|||
}
|
||||
|
||||
pub fn test() {
|
||||
let mut buf: [u16, ..50] = [0, ..50];
|
||||
let mut buf: [u16; 50] = [0; 50];
|
||||
let ret = unsafe {
|
||||
FormatMessageW(0x1000, 0 as *mut c_void, 1, 0x400,
|
||||
buf.as_mut_ptr(), buf.len() as u32, 0 as *const c_void)
|
||||
|
|
|
@ -12,9 +12,9 @@ use std::u8;
|
|||
|
||||
const NUM: uint = u8::BITS as uint;
|
||||
|
||||
struct MyStruct { nums: [uint, ..8] }
|
||||
struct MyStruct { nums: [uint; 8] }
|
||||
|
||||
|
||||
fn main() {
|
||||
let _s = MyStruct { nums: [0, ..NUM] };
|
||||
let _s = MyStruct { nums: [0; NUM] };
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
static TEST_VALUE : *const [int, ..2] = 0x1234 as *const [int, ..2];
|
||||
static TEST_VALUE : *const [int; 2] = 0x1234 as *const [int; 2];
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -15,7 +15,7 @@ fn main() {
|
|||
let args = os::args();
|
||||
if args.len() > 1 {
|
||||
let mut out = stdio::stdout();
|
||||
out.write(&['a' as u8, ..128 * 1024]).unwrap();
|
||||
out.write(&['a' as u8; 128 * 1024]).unwrap();
|
||||
} else {
|
||||
let out = Command::new(args[0].as_slice()).arg("child").output();
|
||||
let out = out.unwrap();
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
use std::iter::AdditiveIterator;
|
||||
fn main() {
|
||||
let x: [u64, ..3] = [1, 2, 3];
|
||||
let x: [u64; 3] = [1, 2, 3];
|
||||
assert_eq!(6, range(0, 3).map(|i| x[i]).sum());
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
static mut DROPPED: [bool, ..2] = [false, false];
|
||||
static mut DROPPED: [bool; 2] = [false, false];
|
||||
|
||||
struct A(uint);
|
||||
struct Foo { _a: A, _b: int }
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
assert_eq!(match [0u8, ..1024] {
|
||||
assert_eq!(match [0u8; 1024] {
|
||||
_ => 42u,
|
||||
}, 42u);
|
||||
|
||||
assert_eq!(match [0u8, ..1024] {
|
||||
assert_eq!(match [0u8; 1024] {
|
||||
[1, _..] => 0u,
|
||||
[0, _..] => 1u,
|
||||
_ => 2u
|
||||
|
|
|
@ -12,5 +12,5 @@
|
|||
// expression with a count of 1 and a non-Copy element type.
|
||||
|
||||
fn main() {
|
||||
let _ = [box 1u, ..1];
|
||||
let _ = [box 1u; 1];
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ const STRUCT: MyStruct = MyStruct { field: 42 };
|
|||
const TUP: (uint,) = (43,);
|
||||
|
||||
fn main() {
|
||||
let a = [0i, ..STRUCT.field];
|
||||
let b = [0i, ..TUP.0];
|
||||
let a = [0i; STRUCT.field];
|
||||
let b = [0i; TUP.0];
|
||||
|
||||
assert!(a.len() == 42);
|
||||
assert!(b.len() == 43);
|
||||
|
|
|
@ -63,7 +63,7 @@ fn read_board_grid<rdr:'static + io::Reader>(mut input: rdr)
|
|||
-> Vec<Vec<square>> {
|
||||
let mut input: &mut io::Reader = &mut input;
|
||||
let mut grid = Vec::new();
|
||||
let mut line = [0, ..10];
|
||||
let mut line = [0; 10];
|
||||
input.read(&mut line);
|
||||
let mut row = Vec::new();
|
||||
for c in line.iter() {
|
||||
|
|
|
@ -16,7 +16,7 @@ extern crate libc;
|
|||
use libc::{c_uint, uint32_t, c_void};
|
||||
|
||||
pub struct KEYGEN {
|
||||
hash_algorithm: [c_uint, ..2],
|
||||
hash_algorithm: [c_uint; 2],
|
||||
count: uint32_t,
|
||||
salt: *const c_void,
|
||||
salt_size: uint32_t,
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
pub fn main() {
|
||||
let _foo = [0i, ..2*4];
|
||||
let _foo = [0i; 2*4];
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
...should print &[1, 2, 3] but instead prints something like
|
||||
&[4492532864, 24]. It is pretty evident that the compiler messed up
|
||||
with the representation of [int, ..n] and [int] somehow, or at least
|
||||
with the representation of [int; n] and [int] somehow, or at least
|
||||
failed to typecheck correctly.
|
||||
*/
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
|
||||
#![feature(advanced_slice_patterns)]
|
||||
|
||||
fn foo<T: Add<T, T> + Clone>([x, y, z]: [T, ..3]) -> (T, T, T) {
|
||||
fn foo<T: Add<T, T> + Clone>([x, y, z]: [T; 3]) -> (T, T, T) {
|
||||
(x.clone(), x.clone() + y.clone(), x + y + z)
|
||||
}
|
||||
fn bar(a: &'static str, b: &'static str) -> [&'static str, ..4] {
|
||||
fn bar(a: &'static str, b: &'static str) -> [&'static str; 4] {
|
||||
[a, b, b, a]
|
||||
}
|
||||
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
pub fn main() {
|
||||
const S: uint = 23 as uint; [0i, ..S]; ()
|
||||
const S: uint = 23 as uint; [0i; S]; ()
|
||||
}
|
||||
|
|
|
@ -15,5 +15,5 @@ macro_rules! four (
|
|||
);
|
||||
|
||||
fn main() {
|
||||
let _x: [u16, ..four!()];
|
||||
let _x: [u16; four!()];
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ fn issue_6533() {
|
|||
}
|
||||
|
||||
fn issue_13626() {
|
||||
const VAL: [u8, ..1] = [0];
|
||||
const VAL: [u8; 1] = [0];
|
||||
match [1] {
|
||||
VAL => unreachable!(),
|
||||
_ => ()
|
||||
|
|
|
@ -38,7 +38,7 @@ impl<'a> MyWriter for &'a mut [u8] {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let mut buf = [0_u8, .. 6];
|
||||
let mut buf = [0_u8; 6];
|
||||
|
||||
{
|
||||
let mut writer = buf.as_mut_slice();
|
||||
|
|
|
@ -28,7 +28,7 @@ impl<T> B for *const [T] {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let x: [int, ..4] = [1,2,3,4];
|
||||
let x: [int; 4] = [1,2,3,4];
|
||||
let xptr = x.as_slice() as *const _;
|
||||
xptr.foo();
|
||||
}
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn test1() {
|
||||
let mut ints = [0i, ..32];
|
||||
let mut ints = [0i; 32];
|
||||
ints[0] += 1;
|
||||
assert_eq!(ints[0], 1);
|
||||
}
|
||||
|
||||
fn test2() {
|
||||
let mut ints = [0i, ..32];
|
||||
let mut ints = [0i; 32];
|
||||
for i in ints.iter_mut() { *i += 22; }
|
||||
for i in ints.iter() { assert!(*i == 22); }
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
static FOO: [int, ..3] = [1, 2, 3];
|
||||
static FOO: [int; 3] = [1, 2, 3];
|
||||
|
||||
pub fn main() {
|
||||
println!("{} {} {}", FOO[0], FOO[1], FOO[2]);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue