diff options
Diffstat (limited to 'src/test')
370 files changed, 2451 insertions, 1060 deletions
diff --git a/src/test/auxiliary/cci_class_3.rs b/src/test/auxiliary/cci_class_3.rs index 98881eb09bf..44d3a69fde4 100644 --- a/src/test/auxiliary/cci_class_3.rs +++ b/src/test/auxiliary/cci_class_3.rs @@ -16,7 +16,7 @@ pub mod kitties { } impl cat { - pub fn speak(&mut self) { self.meows += 1_usize; } + pub fn speak(&mut self) { self.meows += 1; } pub fn meow_count(&mut self) -> uint { self.meows } } diff --git a/src/test/auxiliary/cci_class_4.rs b/src/test/auxiliary/cci_class_4.rs index 9d7905cdebd..c10ef805a65 100644 --- a/src/test/auxiliary/cci_class_4.rs +++ b/src/test/auxiliary/cci_class_4.rs @@ -34,8 +34,8 @@ pub mod kitties { impl cat { pub fn meow(&mut self) { println!("Meow"); - self.meows += 1_usize; - if self.meows % 5_usize == 0_usize { + self.meows += 1; + if self.meows % 5 == 0 { self.how_hungry += 1; } } diff --git a/src/test/auxiliary/cci_class_cast.rs b/src/test/auxiliary/cci_class_cast.rs index 96a06968c5f..28fa354fef3 100644 --- a/src/test/auxiliary/cci_class_cast.rs +++ b/src/test/auxiliary/cci_class_cast.rs @@ -26,8 +26,8 @@ pub mod kitty { impl cat { fn meow(&mut self) { println!("Meow"); - self.meows += 1_usize; - if self.meows % 5_usize == 0_usize { + self.meows += 1; + if self.meows % 5 == 0 { self.how_hungry += 1; } } diff --git a/src/test/auxiliary/cci_impl_lib.rs b/src/test/auxiliary/cci_impl_lib.rs index 6ee497370e8..a650b30e593 100644 --- a/src/test/auxiliary/cci_impl_lib.rs +++ b/src/test/auxiliary/cci_impl_lib.rs @@ -20,7 +20,7 @@ impl uint_helpers for uint { let mut i = *self; while i < v { f(i); - i += 1_usize; + i += 1; } } } diff --git a/src/test/auxiliary/cci_iter_lib.rs b/src/test/auxiliary/cci_iter_lib.rs index 8e00b0dc7be..07d03b4c759 100644 --- a/src/test/auxiliary/cci_iter_lib.rs +++ b/src/test/auxiliary/cci_iter_lib.rs @@ -12,10 +12,10 @@ #[inline] pub fn iter<T, F>(v: &[T], mut f: F) where F: FnMut(&T) { - let mut i = 0_usize; + let mut i = 0; let n = v.len(); while i < n { f(&v[i]); - i += 1_usize; + i += 1; } } diff --git a/src/test/auxiliary/cci_no_inline_lib.rs b/src/test/auxiliary/cci_no_inline_lib.rs index ce041118906..f3ad2a3aeb9 100644 --- a/src/test/auxiliary/cci_no_inline_lib.rs +++ b/src/test/auxiliary/cci_no_inline_lib.rs @@ -13,10 +13,10 @@ // same as cci_iter_lib, more-or-less, but not marked inline pub fn iter<F>(v: Vec<uint> , mut f: F) where F: FnMut(uint) { - let mut i = 0_usize; + let mut i = 0; let n = v.len(); while i < n { f(v[i]); - i += 1_usize; + i += 1; } } diff --git a/src/test/auxiliary/cross_crate_spans.rs b/src/test/auxiliary/cross_crate_spans.rs new file mode 100644 index 00000000000..22c206836ee --- /dev/null +++ b/src/test/auxiliary/cross_crate_spans.rs @@ -0,0 +1,26 @@ +// Copyright 2013-2015 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. + +#![crate_type = "rlib"] +#![omit_gdb_pretty_printer_section] + +// no-prefer-dynamic +// compile-flags:-g + +pub fn generic_function<T: Clone>(val: T) -> (T, T) { + let result = (val.clone(), val.clone()); + let a_variable: u32 = 123456789; + let another_variable: f64 = 123456789.5; + zzz(); + result +} + +#[inline(never)] +fn zzz() {()} \ No newline at end of file diff --git a/src/test/auxiliary/custom_derive_plugin.rs b/src/test/auxiliary/custom_derive_plugin.rs new file mode 100644 index 00000000000..e2688964804 --- /dev/null +++ b/src/test/auxiliary/custom_derive_plugin.rs @@ -0,0 +1,74 @@ +// Copyright 2015 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. + +// force-host + +#![feature(plugin_registrar)] +#![feature(box_syntax)] +#![feature(rustc_private)] + +extern crate syntax; +extern crate rustc; + +use syntax::ast; +use syntax::codemap::Span; +use syntax::ext::base::{Decorator, ExtCtxt}; +use syntax::ext::build::AstBuilder; +use syntax::ext::deriving::generic::{cs_fold, TraitDef, MethodDef, combine_substructure}; +use syntax::ext::deriving::generic::ty::{Literal, LifetimeBounds, Path, borrowed_explicit_self}; +use syntax::parse::token; +use syntax::ptr::P; +use rustc::plugin::Registry; + +#[plugin_registrar] +pub fn plugin_registrar(reg: &mut Registry) { + reg.register_syntax_extension( + token::intern("derive_TotalSum"), + Decorator(box expand)); +} + +fn expand(cx: &mut ExtCtxt, + span: Span, + mitem: &ast::MetaItem, + item: &ast::Item, + push: &mut FnMut(P<ast::Item>)) { + let trait_def = TraitDef { + span: span, + attributes: vec![], + path: Path::new(vec!["TotalSum"]), + additional_bounds: vec![], + generics: LifetimeBounds::empty(), + associated_types: vec![], + methods: vec![ + MethodDef { + name: "total_sum", + generics: LifetimeBounds::empty(), + explicit_self: borrowed_explicit_self(), + args: vec![], + ret_ty: Literal(Path::new_local("isize")), + attributes: vec![], + combine_substructure: combine_substructure(box |cx, span, substr| { + let zero = cx.expr_int(span, 0); + cs_fold(false, + |cx, span, subexpr, field, _| { + cx.expr_binary(span, ast::BiAdd, subexpr, + cx.expr_method_call(span, field, + token::str_to_ident("total_sum"), vec![])) + }, + zero, + box |cx, span, _, _| { cx.span_bug(span, "wtf??"); }, + cx, span, substr) + }), + }, + ], + }; + + trait_def.expand(cx, mitem, item, |i| push(i)) +} diff --git a/src/test/auxiliary/internal_unstable.rs b/src/test/auxiliary/internal_unstable.rs new file mode 100644 index 00000000000..3d59b8e9009 --- /dev/null +++ b/src/test/auxiliary/internal_unstable.rs @@ -0,0 +1,60 @@ +// Copyright 2015 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. + +#![feature(staged_api, allow_internal_unstable)] +#![staged_api] +#![stable(feature = "stable", since = "1.0.0")] + +#[unstable(feature = "function")] +pub fn unstable() {} + + +#[stable(feature = "stable", since = "1.0.0")] +pub struct Foo { + #[unstable(feature = "struct_field")] + pub x: u8 +} + +#[allow_internal_unstable] +#[macro_export] +macro_rules! call_unstable_allow { + () => { $crate::unstable() } +} + +#[allow_internal_unstable] +#[macro_export] +macro_rules! construct_unstable_allow { + ($e: expr) => { + $crate::Foo { x: $e } + } +} + +#[allow_internal_unstable] +#[macro_export] +macro_rules! pass_through_allow { + ($e: expr) => { $e } +} + +#[macro_export] +macro_rules! call_unstable_noallow { + () => { $crate::unstable() } +} + +#[macro_export] +macro_rules! construct_unstable_noallow { + ($e: expr) => { + $crate::Foo { x: $e } + } +} + +#[macro_export] +macro_rules! pass_through_noallow { + ($e: expr) => { $e } +} diff --git a/src/test/auxiliary/lint_output_format.rs b/src/test/auxiliary/lint_output_format.rs index 1977e2aad28..1977e2aad28 100755..100644 --- a/src/test/auxiliary/lint_output_format.rs +++ b/src/test/auxiliary/lint_output_format.rs diff --git a/src/test/auxiliary/macro_reexport_1.rs b/src/test/auxiliary/macro_reexport_1.rs index 9c72cb1a680..aaeccc6e898 100644 --- a/src/test/auxiliary/macro_reexport_1.rs +++ b/src/test/auxiliary/macro_reexport_1.rs @@ -11,5 +11,5 @@ #![crate_type = "dylib"] #[macro_export] macro_rules! reexported { - () => ( 3_usize ) + () => ( 3 ) } diff --git a/src/test/auxiliary/plugin_args.rs b/src/test/auxiliary/plugin_args.rs index 20c84c4ba5b..30b18a3618f 100644 --- a/src/test/auxiliary/plugin_args.rs +++ b/src/test/auxiliary/plugin_args.rs @@ -47,5 +47,5 @@ pub fn plugin_registrar(reg: &mut Registry) { let args = reg.args().clone(); reg.register_syntax_extension(token::intern("plugin_args"), // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - NormalTT(Box::new(Expander { args: args, }), None)); + NormalTT(Box::new(Expander { args: args, }), None, false)); } diff --git a/src/test/auxiliary/procedural_mbe_matching.rs b/src/test/auxiliary/procedural_mbe_matching.rs new file mode 100644 index 00000000000..d9a2b06e039 --- /dev/null +++ b/src/test/auxiliary/procedural_mbe_matching.rs @@ -0,0 +1,69 @@ +// Copyright 2015 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. + +// force-host + +#![crate_type="dylib"] +#![feature(plugin_registrar, quote)] + +extern crate syntax; +extern crate rustc; + +use syntax::codemap::Span; +use syntax::parse::token::{self, str_to_ident, NtExpr, NtPat}; +use syntax::ast::{TokenTree, TtToken, Pat}; +use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager}; +use syntax::ext::build::AstBuilder; +use syntax::ext::tt::macro_parser::{MatchedSeq, MatchedNonterminal}; +use syntax::ext::tt::macro_parser::{Success, Failure, Error}; +use syntax::ptr::P; +use rustc::plugin::Registry; + +fn expand_mbe_matches(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) + -> Box<MacResult + 'static> { + + let mbe_matcher = quote_matcher!(cx, $matched:expr, $($pat:pat)|+); + + let mac_expr = match TokenTree::parse(cx, &mbe_matcher[..], args) { + Success(map) => { + match (&*map[str_to_ident("matched")], &*map[str_to_ident("pat")]) { + (&MatchedNonterminal(NtExpr(ref matched_expr)), + &MatchedSeq(ref pats, seq_sp)) => { + let pats: Vec<P<Pat>> = pats.iter().map(|pat_nt| + if let &MatchedNonterminal(NtPat(ref pat)) = &**pat_nt { + pat.clone() + } else { + unreachable!() + } + ).collect(); + let arm = cx.arm(seq_sp, pats, cx.expr_bool(seq_sp, true)); + + quote_expr!(cx, + match $matched_expr { + $arm + _ => false + } + ) + } + _ => unreachable!() + } + } + Failure(_, s) | Error(_, s) => { + panic!("expected Success, but got Error/Failure: {}", s); + } + }; + + MacEager::expr(mac_expr) +} + +#[plugin_registrar] +pub fn plugin_registrar(reg: &mut Registry) { + reg.register_macro("matches", expand_mbe_matches); +} diff --git a/src/test/auxiliary/roman_numerals.rs b/src/test/auxiliary/roman_numerals.rs index e5c42111105..0ea7c000570 100644 --- a/src/test/auxiliary/roman_numerals.rs +++ b/src/test/auxiliary/roman_numerals.rs @@ -47,7 +47,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) }; let mut text = &*text; - let mut total = 0_usize; + let mut total = 0; while !text.is_empty() { match NUMERALS.iter().find(|&&(rn, _)| text.starts_with(rn)) { Some(&(rn, val)) => { diff --git a/src/test/auxiliary/typeck-default-trait-impl-cross-crate-coherence-lib.rs b/src/test/auxiliary/typeck-default-trait-impl-cross-crate-coherence-lib.rs new file mode 100644 index 00000000000..506e7a00c75 --- /dev/null +++ b/src/test/auxiliary/typeck-default-trait-impl-cross-crate-coherence-lib.rs @@ -0,0 +1,19 @@ +// Copyright 2015 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. + +#![feature(optin_builtin_traits)] +#![crate_type = "rlib"] + +use std::marker::MarkerTrait; + +pub trait DefaultedTrait : MarkerTrait { } +impl DefaultedTrait for .. { } + +pub struct Something<T> { t: T } diff --git a/src/test/auxiliary/unboxed-closures-cross-crate.rs b/src/test/auxiliary/unboxed-closures-cross-crate.rs index a5178c03443..26925a35067 100644 --- a/src/test/auxiliary/unboxed-closures-cross-crate.rs +++ b/src/test/auxiliary/unboxed-closures-cross-crate.rs @@ -14,9 +14,9 @@ use std::ops::Add; #[inline] pub fn has_closures() -> uint { - let x = 1_usize; + let x = 1; let mut f = move || x; - let y = 1_usize; + let y = 1; let g = || y; f() + g() } diff --git a/src/test/bench/noise.rs b/src/test/bench/noise.rs index 53c52ae3019..de88c7733b3 100644 --- a/src/test/bench/noise.rs +++ b/src/test/bench/noise.rs @@ -49,7 +49,7 @@ impl Noise2DContext { *x = random_gradient(&mut rng); } - let mut permutations = [0i32; 256]; + let mut permutations = [0; 256]; for (i, x) in permutations.iter_mut().enumerate() { *x = i as i32; } diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 73e7c8eb073..4a8bb24270d 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -145,7 +145,7 @@ fn creature( to_rendezvous: Sender<CreatureInfo>, to_rendezvous_log: Sender<String> ) { - let mut creatures_met = 0i32; + let mut creatures_met = 0; let mut evil_clones_met = 0; let mut rendezvous = from_rendezvous.iter(); diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index f7de935d08f..3688c224a7d 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -91,7 +91,7 @@ impl Perm { } fn get(&mut self, mut idx: i32) -> P { - let mut pp = [0u8; 16]; + let mut pp = [0; 16]; self.permcount = idx as u32; for (i, place) in self.perm.p.iter_mut().enumerate() { *place = i as i32 + 1; @@ -183,7 +183,7 @@ fn main() { let n = std::env::args() .nth(1) .and_then(|arg| arg.parse().ok()) - .unwrap_or(2i32); + .unwrap_or(2); let (checksum, maxflips) = fannkuch(n); println!("{}\nPfannkuchen({}) = {}", checksum, n, maxflips); diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index 277c3ee73df..9cee75757aa 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -121,7 +121,7 @@ impl<'a, W: Writer> RepeatFasta<'a, W> { fn make(&mut self, n: usize) -> IoResult<()> { let alu_len = self.alu.len(); - let mut buf = repeat(0u8).take(alu_len + LINE_LEN).collect::<Vec<_>>(); + let mut buf = repeat(0).take(alu_len + LINE_LEN).collect::<Vec<_>>(); let alu: &[u8] = self.alu.as_bytes(); copy_memory(&mut buf, alu); diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index 2c640c4b092..e15f9d99ff6 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -89,7 +89,7 @@ fn make_fasta<W: Writer, I: Iterator<Item=u8>>( -> std::old_io::IoResult<()> { try!(wr.write(header.as_bytes())); - let mut line = [0u8; LINE_LENGTH + 1]; + let mut line = [0; LINE_LENGTH + 1]; while n > 0 { let nb = min(LINE_LENGTH, n); for i in 0..nb { diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 5cfe62d967c..9e5885041b6 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -78,11 +78,11 @@ impl Code { } fn rotate(&self, c: u8, frame: usize) -> Code { - Code(self.push_char(c).hash() & ((1u64 << (2 * frame)) - 1)) + Code(self.push_char(c).hash() & ((1 << (2 * frame)) - 1)) } fn pack(string: &str) -> Code { - string.bytes().fold(Code(0u64), |a, b| a.push_char(b)) + string.bytes().fold(Code(0), |a, b| a.push_char(b)) } fn unpack(&self, frame: usize) -> String { diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index a94fe0ccd95..79a5245a408 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -169,7 +169,7 @@ fn make_masks() -> Vec<Vec<Vec<u64> > > { .map(|(id, p)| transform(p, id != 3)) .collect(); - (0i32..50).map(|yx| { + (0..50).map(|yx| { transforms.iter().enumerate().map(|(id, t)| { t.iter().filter_map(|p| mask(yx / 5, yx % 5, id, p)).collect() }).collect() @@ -211,7 +211,7 @@ fn filter_masks(masks: &mut Vec<Vec<Vec<u64>>>) { // Gets the identifier of a mask. fn get_id(m: u64) -> u8 { - for id in 0u8..10 { + for id in 0..10 { if m & (1 << (id + 50) as usize) != 0 {return id;} } panic!("{:016x} does not have a valid identifier", m); diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index f308743ad13..9a82614510e 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -60,7 +60,7 @@ impl Sudoku { reader.read_line(&mut s).unwrap(); assert_eq!(s, "9,9\n"); - let mut g = repeat(vec![0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8]) + let mut g = repeat(vec![0, 0, 0, 0, 0, 0, 0, 0, 0]) .take(10).collect::<Vec<_>>(); for line in reader.lines() { let line = line.unwrap(); @@ -94,10 +94,10 @@ impl Sudoku { // solve sudoku grid pub fn solve(&mut self) { let mut work: Vec<(u8, u8)> = Vec::new(); /* queue of uncolored fields */ - for row in 0u8..9u8 { - for col in 0u8..9u8 { + for row in 0..9 { + for col in 0..9 { let color = self.grid[row as usize][col as usize]; - if color == 0u8 { + if color == 0 { work.push((row, col)); } } @@ -122,7 +122,7 @@ impl Sudoku { } fn next_color(&mut self, row: u8, col: u8, start_color: u8) -> bool { - if start_color < 10u8 { + if start_color < 10 { // colors not yet used let mut avail: Box<_> = box Colors::new(start_color); @@ -132,15 +132,15 @@ impl Sudoku { // find first remaining color that is available let next = avail.next(); self.grid[row as usize][col as usize] = next; - return 0u8 != next; + return 0 != next; } - self.grid[row as usize][col as usize] = 0u8; + self.grid[row as usize][col as usize] = 0; return false; } // find colors available in neighbourhood of (row, col) fn drop_colors(&mut self, avail: &mut Colors, row: u8, col: u8) { - for idx in 0u8..9u8 { + for idx in 0..9 { /* check same column fields */ avail.remove(self.grid[idx as usize][col as usize]); /* check same row fields */ @@ -148,10 +148,10 @@ impl Sudoku { } // check same block fields - let row0 = (row / 3u8) * 3u8; - let col0 = (col / 3u8) * 3u8; - for alt_row in row0..row0 + 3u8 { - for alt_col in col0..col0 + 3u8 { + let row0 = (row / 3) * 3; + let col0 = (col / 3) * 3; + for alt_row in row0..row0 + 3 { + for alt_col in col0..col0 + 3 { avail.remove(self.grid[alt_row as usize][alt_col as usize]); } } @@ -161,29 +161,29 @@ impl Sudoku { // Stores available colors as simple bitfield, bit 0 is always unset struct Colors(u16); -static HEADS: u16 = (1u16 << 10) - 1; /* bits 9..0 */ +static HEADS: u16 = (1 << 10) - 1; /* bits 9..0 */ impl Colors { fn new(start_color: u8) -> Colors { // Sets bits 9..start_color - let tails = !0u16 << start_color as usize; + let tails = !0 << start_color as usize; return Colors(HEADS & tails); } fn next(&self) -> u8 { let Colors(c) = *self; let val = c & HEADS; - if 0u16 == val { - return 0u8; + if 0 == val { + return 0; } else { return val.trailing_zeros() as u8 } } fn remove(&mut self, color: u8) { - if color != 0u8 { + if color != 0 { let Colors(val) = *self; - let mask = !(1u16 << color as usize); + let mask = !(1 << color as usize); *self = Colors(val & mask); } } @@ -191,57 +191,57 @@ impl Colors { 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], - /* 2 */ [7u8, 0u8, 0u8, 8u8, 0u8, 0u8, 0u8, 0u8, 0u8], - /* 3 */ [0u8, 0u8, 0u8, 5u8, 0u8, 0u8, 0u8, 0u8, 0u8], - /* 4 */ [0u8, 5u8, 0u8, 0u8, 0u8, 3u8, 6u8, 0u8, 0u8], - /* 5 */ [6u8, 8u8, 0u8, 0u8, 0u8, 0u8, 0u8, 9u8, 0u8], - /* 6 */ [0u8, 9u8, 5u8, 0u8, 0u8, 6u8, 0u8, 7u8, 0u8], - /* 7 */ [0u8, 0u8, 0u8, 0u8, 4u8, 0u8, 0u8, 6u8, 0u8], - /* 8 */ [4u8, 0u8, 0u8, 0u8, 0u8, 7u8, 2u8, 0u8, 3u8] + /* 0 */ [0, 4, 0, 6, 0, 0, 0, 3, 2], + /* 1 */ [0, 0, 8, 0, 2, 0, 0, 0, 0], + /* 2 */ [7, 0, 0, 8, 0, 0, 0, 0, 0], + /* 3 */ [0, 0, 0, 5, 0, 0, 0, 0, 0], + /* 4 */ [0, 5, 0, 0, 0, 3, 6, 0, 0], + /* 5 */ [6, 8, 0, 0, 0, 0, 0, 9, 0], + /* 6 */ [0, 9, 5, 0, 0, 6, 0, 7, 0], + /* 7 */ [0, 0, 0, 0, 4, 0, 0, 6, 0], + /* 8 */ [4, 0, 0, 0, 0, 7, 2, 0, 3] ]; #[cfg(test)] 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], - /* 2 */ [7u8, 2u8, 6u8, 8u8, 3u8, 4u8, 1u8, 5u8, 9u8], - /* 3 */ [9u8, 1u8, 4u8, 5u8, 6u8, 8u8, 3u8, 2u8, 7u8], - /* 4 */ [2u8, 5u8, 7u8, 4u8, 9u8, 3u8, 6u8, 1u8, 8u8], - /* 5 */ [6u8, 8u8, 3u8, 7u8, 1u8, 2u8, 5u8, 9u8, 4u8], - /* 6 */ [3u8, 9u8, 5u8, 2u8, 8u8, 6u8, 4u8, 7u8, 1u8], - /* 7 */ [8u8, 7u8, 2u8, 3u8, 4u8, 1u8, 9u8, 6u8, 5u8], - /* 8 */ [4u8, 6u8, 1u8, 9u8, 5u8, 7u8, 2u8, 8u8, 3u8] + /* 0 */ [1, 4, 9, 6, 7, 5, 8, 3, 2], + /* 1 */ [5, 3, 8, 1, 2, 9, 7, 4, 6], + /* 2 */ [7, 2, 6, 8, 3, 4, 1, 5, 9], + /* 3 */ [9, 1, 4, 5, 6, 8, 3, 2, 7], + /* 4 */ [2, 5, 7, 4, 9, 3, 6, 1, 8], + /* 5 */ [6, 8, 3, 7, 1, 2, 5, 9, 4], + /* 6 */ [3, 9, 5, 2, 8, 6, 4, 7, 1], + /* 7 */ [8, 7, 2, 3, 4, 1, 9, 6, 5], + /* 8 */ [4, 6, 1, 9, 5, 7, 2, 8, 3] ]; #[test] fn colors_new_works() { - assert_eq!(*Colors::new(1), 1022u16); - assert_eq!(*Colors::new(2), 1020u16); - assert_eq!(*Colors::new(3), 1016u16); - assert_eq!(*Colors::new(4), 1008u16); - assert_eq!(*Colors::new(5), 992u16); - assert_eq!(*Colors::new(6), 960u16); - assert_eq!(*Colors::new(7), 896u16); - assert_eq!(*Colors::new(8), 768u16); - assert_eq!(*Colors::new(9), 512u16); + assert_eq!(*Colors::new(1), 1022); + assert_eq!(*Colors::new(2), 1020); + assert_eq!(*Colors::new(3), 1016); + assert_eq!(*Colors::new(4), 1008); + assert_eq!(*Colors::new(5), 992); + assert_eq!(*Colors::new(6), 960); + assert_eq!(*Colors::new(7), 896); + assert_eq!(*Colors::new(8), 768); + assert_eq!(*Colors::new(9), 512); } #[test] fn colors_next_works() { - assert_eq!(Colors(0).next(), 0u8); - assert_eq!(Colors(2).next(), 1u8); - assert_eq!(Colors(4).next(), 2u8); - assert_eq!(Colors(8).next(), 3u8); - assert_eq!(Colors(16).next(), 4u8); - assert_eq!(Colors(32).next(), 5u8); - assert_eq!(Colors(64).next(), 6u8); - assert_eq!(Colors(128).next(), 7u8); - assert_eq!(Colors(256).next(), 8u8); - assert_eq!(Colors(512).next(), 9u8); - assert_eq!(Colors(1024).next(), 0u8); + assert_eq!(Colors(0).next(), 0); + assert_eq!(Colors(2).next(), 1); + assert_eq!(Colors(4).next(), 2); + assert_eq!(Colors(8).next(), 3); + assert_eq!(Colors(16).next(), 4); + assert_eq!(Colors(32).next(), 5); + assert_eq!(Colors(64).next(), 6); + assert_eq!(Colors(128).next(), 7); + assert_eq!(Colors(256).next(), 8); + assert_eq!(Colors(512).next(), 9); + assert_eq!(Colors(1024).next(), 0); } #[test] @@ -253,7 +253,7 @@ fn colors_remove_works() { colors.remove(1); // THEN - assert_eq!(colors.next(), 2u8); + assert_eq!(colors.next(), 2); } #[test] diff --git a/src/test/compile-fail-fulldeps/gated-quote.rs b/src/test/compile-fail-fulldeps/gated-quote.rs new file mode 100644 index 00000000000..6a5cd88a591 --- /dev/null +++ b/src/test/compile-fail-fulldeps/gated-quote.rs @@ -0,0 +1,50 @@ +// Copyright 2015 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. + +// Test that `quote`-related macro are gated by `quote` feature gate. + +// (To sanity-check the code, uncomment this.) +// #![feature(quote)] + +// FIXME the error message that is current emitted seems pretty bad. + +#![feature(rustc_private)] +#![allow(dead_code, unused_imports, unused_variables)] + +#[macro_use] +extern crate syntax; + +use syntax::ast; +use syntax::codemap::Span; +use syntax::parse; + +struct ParseSess; + +impl ParseSess { + fn cfg(&self) -> ast::CrateConfig { loop { } } + fn parse_sess<'a>(&'a self) -> &'a parse::ParseSess { loop { } } + fn call_site(&self) -> Span { loop { } } + fn ident_of(&self, st: &str) -> ast::Ident { loop { } } + fn name_of(&self, st: &str) -> ast::Name { loop { } } +} + +pub fn main() { + let ecx = &ParseSess; + let x = quote_tokens!(ecx, 3); //~ ERROR macro undefined: 'quote_tokens!' + let x = quote_expr!(ecx, 3); //~ ERROR macro undefined: 'quote_expr!' + let x = quote_ty!(ecx, 3); //~ ERROR macro undefined: 'quote_ty!' + let x = quote_method!(ecx, 3); //~ ERROR macro undefined: 'quote_method!' + let x = quote_item!(ecx, 3); //~ ERROR macro undefined: 'quote_item!' + let x = quote_pat!(ecx, 3); //~ ERROR macro undefined: 'quote_pat!' + let x = quote_arm!(ecx, 3); //~ ERROR macro undefined: 'quote_arm!' + let x = quote_stmt!(ecx, 3); //~ ERROR macro undefined: 'quote_stmt!' + let x = quote_matcher!(ecx, 3); //~ ERROR macro undefined: 'quote_matcher!' + let x = quote_attr!(ecx, 3); //~ ERROR macro undefined: 'quote_attr!' +} diff --git a/src/test/compile-fail-fulldeps/issue-18986.rs b/src/test/compile-fail-fulldeps/issue-18986.rs index 9b696e05c50..06fc3db58c1 100644 --- a/src/test/compile-fail-fulldeps/issue-18986.rs +++ b/src/test/compile-fail-fulldeps/issue-18986.rs @@ -15,6 +15,6 @@ pub use use_from_trait_xc::Trait; fn main() { match () { - Trait { x: 42_usize } => () //~ ERROR use of trait `Trait` in a struct pattern + Trait { x: 42 } => () //~ ERROR use of trait `Trait` in a struct pattern } } diff --git a/src/test/compile-fail/array-not-vector.rs b/src/test/compile-fail/array-not-vector.rs index 7111c00d124..6c9b8f81b2f 100644 --- a/src/test/compile-fail/array-not-vector.rs +++ b/src/test/compile-fail/array-not-vector.rs @@ -9,14 +9,14 @@ // except according to those terms. fn main() { - let _x: i32 = [1i32, 2, 3]; + let _x: i32 = [1, 2, 3]; //~^ ERROR mismatched types //~| expected `i32` - //~| found `[i32; 3]` + //~| found `[_; 3]` //~| expected i32 //~| found array of 3 elements - let x: &[i32] = &[1i32, 2, 3]; + let x: &[i32] = &[1, 2, 3]; let _y: &i32 = x; //~^ ERROR mismatched types //~| expected `&i32` diff --git a/src/test/compile-fail/asm-in-bad-modifier.rs b/src/test/compile-fail/asm-in-bad-modifier.rs index 01481af817b..3cb608a9c5e 100644 --- a/src/test/compile-fail/asm-in-bad-modifier.rs +++ b/src/test/compile-fail/asm-in-bad-modifier.rs @@ -20,8 +20,8 @@ pub fn main() { let x: isize; let y: isize; unsafe { - asm!("mov $1, $0" : "=r"(x) : "=r"(5_usize)); //~ ERROR operand constraint contains '=' - asm!("mov $1, $0" : "=r"(y) : "+r"(5_usize)); //~ ERROR operand constraint contains '+' + asm!("mov $1, $0" : "=r"(x) : "=r"(5)); //~ ERROR operand constraint contains '=' + asm!("mov $1, $0" : "=r"(y) : "+r"(5)); //~ ERROR operand constraint contains '+' } foo(x); foo(y); diff --git a/src/test/compile-fail/asm-out-assign-imm.rs b/src/test/compile-fail/asm-out-assign-imm.rs index ff56fb14f7d..8c8451623d5 100644 --- a/src/test/compile-fail/asm-out-assign-imm.rs +++ b/src/test/compile-fail/asm-out-assign-imm.rs @@ -21,7 +21,7 @@ pub fn main() { x = 1; //~ NOTE prior assignment occurs here foo(x); unsafe { - asm!("mov $1, $0" : "=r"(x) : "r"(5_usize)); + asm!("mov $1, $0" : "=r"(x) : "r"(5)); //~^ ERROR re-assignment of immutable variable `x` } foo(x); diff --git a/src/test/compile-fail/asm-out-no-modifier.rs b/src/test/compile-fail/asm-out-no-modifier.rs index 17c19c77ab9..9cf43bebe65 100644 --- a/src/test/compile-fail/asm-out-no-modifier.rs +++ b/src/test/compile-fail/asm-out-no-modifier.rs @@ -19,7 +19,7 @@ fn foo(x: isize) { println!("{}", x); } pub fn main() { let x: isize; unsafe { - asm!("mov $1, $0" : "r"(x) : "r"(5_usize)); //~ ERROR output operand constraint lacks '=' + asm!("mov $1, $0" : "r"(x) : "r"(5)); //~ ERROR output operand constraint lacks '=' } foo(x); } diff --git a/src/test/compile-fail/assign-to-method.rs b/src/test/compile-fail/assign-to-method.rs index d32ea327d0a..4518ce36b6d 100644 --- a/src/test/compile-fail/assign-to-method.rs +++ b/src/test/compile-fail/assign-to-method.rs @@ -15,7 +15,7 @@ struct cat { } impl cat { - pub fn speak(&self) { self.meows += 1_usize; } + pub fn speak(&self) { self.meows += 1; } } fn cat(in_x : usize, in_y : isize) -> cat { @@ -26,6 +26,6 @@ fn cat(in_x : usize, in_y : isize) -> cat { } fn main() { - let nyan : cat = cat(52_usize, 99); + let nyan : cat = cat(52, 99); nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method } diff --git a/src/test/compile-fail/bad-bang-ann-3.rs b/src/test/compile-fail/bad-bang-ann-3.rs index 58a8314af21..de315a41361 100644 --- a/src/test/compile-fail/bad-bang-ann-3.rs +++ b/src/test/compile-fail/bad-bang-ann-3.rs @@ -11,7 +11,7 @@ // Tests that a function with a ! annotation always actually fails fn bad_bang(i: usize) -> ! { - return 7_usize; //~ ERROR `return` in a function declared as diverging [E0166] + return 7; //~ ERROR `return` in a function declared as diverging [E0166] } fn main() { bad_bang(5); } diff --git a/src/test/compile-fail/bad-bang-ann.rs b/src/test/compile-fail/bad-bang-ann.rs index 03c24c2fa3d..f0ecf31fd10 100644 --- a/src/test/compile-fail/bad-bang-ann.rs +++ b/src/test/compile-fail/bad-bang-ann.rs @@ -11,7 +11,7 @@ // Tests that a function with a ! annotation always actually fails fn bad_bang(i: usize) -> ! { //~ ERROR computation may converge in a function marked as diverging - if i < 0_usize { } else { panic!(); } + if i < 0 { } else { panic!(); } } fn main() { bad_bang(5); } diff --git a/src/test/compile-fail/bad-const-type.rs b/src/test/compile-fail/bad-const-type.rs index 7e3c356b870..a9e5c957b89 100644 --- a/src/test/compile-fail/bad-const-type.rs +++ b/src/test/compile-fail/bad-const-type.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -static i: String = 10i32; +static i: String = 10; //~^ ERROR mismatched types //~| expected `collections::string::String` -//~| found `i32` +//~| found `_` //~| expected struct `collections::string::String` -//~| found i32 +//~| found integral variable fn main() { println!("{}", i); } diff --git a/src/test/compile-fail/bad-method-typaram-kind.rs b/src/test/compile-fail/bad-method-typaram-kind.rs index a97cf5d41e8..2129d4fbd50 100644 --- a/src/test/compile-fail/bad-method-typaram-kind.rs +++ b/src/test/compile-fail/bad-method-typaram-kind.rs @@ -9,7 +9,7 @@ // except according to those terms. fn foo<T:'static>() { - 1_usize.bar::<T>(); //~ ERROR `core::marker::Send` is not implemented + 1.bar::<T>(); //~ ERROR `core::marker::Send` is not implemented } trait bar { diff --git a/src/test/compile-fail/binop-logic-int.rs b/src/test/compile-fail/binop-logic-int.rs index 2217cf5e4da..d5dd9e00902 100644 --- a/src/test/compile-fail/binop-logic-int.rs +++ b/src/test/compile-fail/binop-logic-int.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:`&&` cannot be applied to type `i32` +// error-pattern:`&&` cannot be applied to type `_` -fn main() { let x = 1i32 && 2i32; } +fn main() { let x = 1 && 2; } diff --git a/src/test/compile-fail/borrow-immutable-upvar-mutation.rs b/src/test/compile-fail/borrow-immutable-upvar-mutation.rs index a82aa12dc80..00f51973a41 100644 --- a/src/test/compile-fail/borrow-immutable-upvar-mutation.rs +++ b/src/test/compile-fail/borrow-immutable-upvar-mutation.rs @@ -21,25 +21,25 @@ fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f } fn main() { // By-ref captures { - let mut x = 0_usize; + let mut x = 0; let _f = to_fn(|| x = 42); //~ ERROR cannot assign - let mut y = 0_usize; + let mut y = 0; let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow - let mut z = 0_usize; + let mut z = 0; let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign } // By-value captures { - let mut x = 0_usize; + let mut x = 0; let _f = to_fn(move || x = 42); //~ ERROR cannot assign - let mut y = 0_usize; + let mut y = 0; let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow - let mut z = 0_usize; + let mut z = 0; let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign } } diff --git a/src/test/compile-fail/borrowck-move-error-with-note.rs b/src/test/compile-fail/borrowck-move-error-with-note.rs index 2d82c8be519..e4b9fb26711 100644 --- a/src/test/compile-fail/borrowck-move-error-with-note.rs +++ b/src/test/compile-fail/borrowck-move-error-with-note.rs @@ -17,7 +17,7 @@ enum Foo { } fn blah() { - let f = &Foo::Foo1(box 1u32, box 2u32); + let f = &Foo::Foo1(box 1, box 2); match *f { //~ ERROR cannot move out of Foo::Foo1(num1, //~ NOTE attempting to move value to here num2) => (), //~ NOTE and here diff --git a/src/test/compile-fail/borrowck-report-with-custom-diagnostic.rs b/src/test/compile-fail/borrowck-report-with-custom-diagnostic.rs index 21637370724..61bf2c11a1f 100644 --- a/src/test/compile-fail/borrowck-report-with-custom-diagnostic.rs +++ b/src/test/compile-fail/borrowck-report-with-custom-diagnostic.rs @@ -11,7 +11,7 @@ #![allow(dead_code)] fn main() { // Original borrow ends at end of function - let mut x = 1_usize; + let mut x = 1; let y = &mut x; let z = &x; //~ ERROR cannot borrow } @@ -21,7 +21,7 @@ fn foo() { match true { true => { // Original borrow ends at end of match arm - let mut x = 1_usize; + let mut x = 1; let y = &x; let z = &mut x; //~ ERROR cannot borrow } @@ -33,7 +33,7 @@ fn foo() { fn bar() { // Original borrow ends at end of closure || { - let mut x = 1_usize; + let mut x = 1; let y = &mut x; let z = &mut x; //~ ERROR cannot borrow }; diff --git a/src/test/run-pass/lint-cstack.rs b/src/test/compile-fail/cfg-attr-unknown-attribute-macro-expansion.rs index f180ffcd4e8..afcb896b43c 100644 --- a/src/test/run-pass/lint-cstack.rs +++ b/src/test/compile-fail/cfg-attr-unknown-attribute-macro-expansion.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,19 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate libc; - -extern { - fn rust_get_test_int() -> libc::intptr_t; -} - -trait A { - fn foo(&self) { - unsafe { - rust_get_test_int(); - } +macro_rules! foo { + () => { + #[cfg_attr(all(), unknown)] //~ ERROR `unknown` is currently unknown + fn foo() {} } } -pub fn main() { -} +foo!(); + +fn main() {} diff --git a/src/test/compile-fail/class-method-missing.rs b/src/test/compile-fail/class-method-missing.rs index ada45e8c1fc..46b100a4d39 100644 --- a/src/test/compile-fail/class-method-missing.rs +++ b/src/test/compile-fail/class-method-missing.rs @@ -27,5 +27,5 @@ fn cat(in_x : usize) -> cat { } fn main() { - let nyan = cat(0_usize); + let nyan = cat(0); } diff --git a/src/test/compile-fail/class-missing-self.rs b/src/test/compile-fail/class-missing-self.rs index f25b2e65388..ab76af1cbe6 100644 --- a/src/test/compile-fail/class-missing-self.rs +++ b/src/test/compile-fail/class-missing-self.rs @@ -16,7 +16,7 @@ impl cat { fn sleep(&self) { loop{} } fn meow(&self) { println!("Meow"); - meows += 1_usize; //~ ERROR unresolved name + meows += 1; //~ ERROR unresolved name sleep(); //~ ERROR unresolved name } diff --git a/src/test/compile-fail/coercion-slice.rs b/src/test/compile-fail/coercion-slice.rs index aac180f9ad7..bb4d1693af7 100644 --- a/src/test/compile-fail/coercion-slice.rs +++ b/src/test/compile-fail/coercion-slice.rs @@ -11,10 +11,10 @@ // Tests that we forbid coercion from `[T; n]` to `&[T]` fn main() { - let _: &[i32] = [0i32]; + let _: &[i32] = [0]; //~^ ERROR mismatched types //~| expected `&[i32]` - //~| found `[i32; 1]` + //~| found `[_; 1]` //~| expected &-ptr //~| found array of 1 elements } diff --git a/src/test/compile-fail/coherence-impls-copy.rs b/src/test/compile-fail/coherence-impls-copy.rs new file mode 100644 index 00000000000..3034be177ca --- /dev/null +++ b/src/test/compile-fail/coherence-impls-copy.rs @@ -0,0 +1,39 @@ +// Copyright 2015 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. + +#![feature(optin_builtin_traits)] + +use std::marker::Copy; + +enum TestE { + A +} + +struct MyType; + +struct NotSync; +impl !Sync for NotSync {} + +impl Copy for TestE {} +impl Copy for MyType {} +impl Copy for (MyType, MyType) {} +//~^ ERROR E0206 + +impl Copy for &'static NotSync {} +//~^ ERROR E0206 + +impl Copy for [MyType] {} +//~^ ERROR E0206 + +impl Copy for &'static [NotSync] {} +//~^ ERROR E0206 + +fn main() { +} diff --git a/src/test/compile-fail/coherence-impls-builtin.rs b/src/test/compile-fail/coherence-impls-send.rs index 3e132dcb11f..b05c1ff0f0b 100644 --- a/src/test/compile-fail/coherence-impls-builtin.rs +++ b/src/test/compile-fail/coherence-impls-send.rs @@ -10,7 +10,7 @@ #![feature(optin_builtin_traits)] -use std::marker::Send; +use std::marker::Copy; enum TestE { A @@ -24,20 +24,17 @@ impl !Sync for NotSync {} unsafe impl Send for TestE {} unsafe impl Send for MyType {} unsafe impl Send for (MyType, MyType) {} -//~^ ERROR builtin traits can only be implemented on structs or enums +//~^ ERROR E0321 unsafe impl Send for &'static NotSync {} -//~^ ERROR builtin traits can only be implemented on structs or enums +//~^ ERROR E0321 unsafe impl Send for [MyType] {} -//~^ ERROR builtin traits can only be implemented on structs or enums +//~^ ERROR E0321 unsafe impl Send for &'static [NotSync] {} -//~^ ERROR builtin traits can only be implemented on structs or enums -//~^^ ERROR conflicting implementations for trait `core::marker::Send` - -fn is_send<T: Send>() {} +//~^ ERROR E0321 +//~| ERROR conflicting implementations fn main() { - is_send::<(MyType, TestE)>(); } diff --git a/src/test/compile-fail/coherence-impls-sized.rs b/src/test/compile-fail/coherence-impls-sized.rs new file mode 100644 index 00000000000..a9a3ebaffb7 --- /dev/null +++ b/src/test/compile-fail/coherence-impls-sized.rs @@ -0,0 +1,33 @@ +// Copyright 2015 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. + +#![feature(optin_builtin_traits)] + +use std::marker::Copy; + +enum TestE { + A +} + +struct MyType; + +struct NotSync; +impl !Sync for NotSync {} + +impl Sized for TestE {} //~ ERROR E0322 +impl Sized for MyType {} //~ ERROR E0322 +impl Sized for (MyType, MyType) {} //~ ERROR E0322 +impl Sized for &'static NotSync {} //~ ERROR E0322 +impl Sized for [MyType] {} //~ ERROR E0322 +//~^ ERROR E0277 +impl Sized for &'static [NotSync] {} //~ ERROR E0322 + +fn main() { +} diff --git a/src/test/compile-fail/coherence-orphan.rs b/src/test/compile-fail/coherence-orphan.rs index d7cd68e73c3..97dffec2dd9 100644 --- a/src/test/compile-fail/coherence-orphan.rs +++ b/src/test/compile-fail/coherence-orphan.rs @@ -19,13 +19,15 @@ use lib::TheTrait; struct TheType; -impl TheTrait<usize> for isize { } //~ ERROR E0117 +impl TheTrait<usize> for isize { } +//~^ ERROR E0117 impl TheTrait<TheType> for isize { } impl TheTrait<isize> for TheType { } -impl !Send for Vec<isize> { } //~ ERROR E0117 -//~^ ERROR conflicting +impl !Send for Vec<isize> { } +//~^ ERROR E0117 +//~| ERROR E0119 fn main() { } diff --git a/src/test/compile-fail/const-block-non-item-statement.rs b/src/test/compile-fail/const-block-non-item-statement.rs index fa63b16afa6..5ccfb1ddec7 100644 --- a/src/test/compile-fail/const-block-non-item-statement.rs +++ b/src/test/compile-fail/const-block-non-item-statement.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const A: usize = { 1_usize; 2 }; +const A: usize = { 1; 2 }; //~^ ERROR: blocks in constants are limited to items and tail expressions const B: usize = { { } 2 }; @@ -19,7 +19,7 @@ macro_rules! foo { } const C: usize = { foo!(); 2 }; -const D: usize = { let x = 4_usize; 2 }; +const D: usize = { let x = 4; 2 }; //~^ ERROR: blocks in constants are limited to items and tail expressions pub fn main() { diff --git a/src/test/compile-fail/cycle-projection-based-on-where-clause.rs b/src/test/compile-fail/cycle-projection-based-on-where-clause.rs index abcbf567d44..5ca0700ce6e 100644 --- a/src/test/compile-fail/cycle-projection-based-on-where-clause.rs +++ b/src/test/compile-fail/cycle-projection-based-on-where-clause.rs @@ -25,7 +25,7 @@ trait Trait { type Item; } struct A<T> where T : Trait, T : Add<T::Item> - //~^ ERROR illegal recursive type + //~^ ERROR unsupported cyclic reference between types/traits detected { data: T } diff --git a/src/test/compile-fail/cycle-trait-default-type-trait.rs b/src/test/compile-fail/cycle-trait-default-type-trait.rs new file mode 100644 index 00000000000..e6caeb34a8c --- /dev/null +++ b/src/test/compile-fail/cycle-trait-default-type-trait.rs @@ -0,0 +1,18 @@ +// Copyright 2015 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. + +// Test a cycle where a type parameter on a trait has a default that +// again references the trait. + +trait Foo<X = Box<Foo>> { + //~^ ERROR unsupported cyclic reference +} + +fn main() { } diff --git a/src/test/compile-fail/cycle-trait-supertrait-indirect.rs b/src/test/compile-fail/cycle-trait-supertrait-indirect.rs index 6ebd9a1bcb6..c9bfde3f4ed 100644 --- a/src/test/compile-fail/cycle-trait-supertrait-indirect.rs +++ b/src/test/compile-fail/cycle-trait-supertrait-indirect.rs @@ -12,9 +12,12 @@ // a direct participant in the cycle. trait A: B { + //~^ ERROR unsupported cyclic reference } -trait B: C { } +trait B: C { + //~^ ERROR unsupported cyclic reference +} trait C: B { } //~^ ERROR unsupported cyclic reference diff --git a/src/test/compile-fail/deprecated-phase.rs b/src/test/compile-fail/deprecated-phase.rs index 1401494d987..22fc4a94cd2 100644 --- a/src/test/compile-fail/deprecated-phase.rs +++ b/src/test/compile-fail/deprecated-phase.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(custom_attribute)] + #[phase(blah)] //~^ ERROR #[phase] is deprecated extern crate foo; diff --git a/src/test/compile-fail/deriving-bounds.rs b/src/test/compile-fail/deriving-bounds.rs index c0bcbb284a1..72d06274de4 100644 --- a/src/test/compile-fail/deriving-bounds.rs +++ b/src/test/compile-fail/deriving-bounds.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[derive(Copy(Bad))] -//~^ ERROR unexpected value in deriving, expected a trait +#[derive(Send)] +//~^ ERROR this unsafe trait should be implemented explicitly struct Test; #[derive(Sync)] -//~^ ERROR Sync is an unsafe trait and it should be implemented explicitly +//~^ ERROR this unsafe trait should be implemented explicitly struct Test1; pub fn main() {} diff --git a/src/test/compile-fail/deriving-meta-unknown-trait.rs b/src/test/compile-fail/deriving-meta-unknown-trait.rs index 6b85656bdd9..e2234994693 100644 --- a/src/test/compile-fail/deriving-meta-unknown-trait.rs +++ b/src/test/compile-fail/deriving-meta-unknown-trait.rs @@ -8,7 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[derive(Eqr)] //~ ERROR unknown `derive` trait: `Eqr` +#[derive(Eqr)] +//~^ ERROR `#[derive]` for custom traits is not stable enough for use and is subject to change struct Foo; pub fn main() {} diff --git a/src/test/compile-fail/deriving-non-type.rs b/src/test/compile-fail/deriving-non-type.rs index 966e28a789c..5b215f3ccd9 100644 --- a/src/test/compile-fail/deriving-non-type.rs +++ b/src/test/compile-fail/deriving-non-type.rs @@ -22,10 +22,10 @@ impl S { } impl T for S { } #[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums -static s: usize = 0_usize; +static s: usize = 0; #[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums -const c: usize = 0_usize; +const c: usize = 0; #[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums mod m { } diff --git a/src/test/compile-fail/destructor-restrictions.rs b/src/test/compile-fail/destructor-restrictions.rs index 0836cd1695d..22f615cafd7 100644 --- a/src/test/compile-fail/destructor-restrictions.rs +++ b/src/test/compile-fail/destructor-restrictions.rs @@ -14,8 +14,8 @@ use std::cell::RefCell; fn main() { let b = { - let a = Box::new(RefCell::new(4i8)); - *a.borrow() + 1i8 //~ ERROR `*a` does not live long enough + let a = Box::new(RefCell::new(4)); + *a.borrow() + 1 //~ ERROR `*a` does not live long enough }; println!("{}", b); } diff --git a/src/test/compile-fail/empty-extern-arg.rs b/src/test/compile-fail/empty-extern-arg.rs index 9b7df81a5dc..8791481d9e7 100644 --- a/src/test/compile-fail/empty-extern-arg.rs +++ b/src/test/compile-fail/empty-extern-arg.rs @@ -9,6 +9,6 @@ // except according to those terms. // compile-flags: --extern std= -// error-pattern: is not a file +// error-pattern: can't find crate for `std` fn main() {} diff --git a/src/test/compile-fail/feature-gate-allow-internal-unstable-nested-macro.rs b/src/test/compile-fail/feature-gate-allow-internal-unstable-nested-macro.rs new file mode 100644 index 00000000000..c9251c925cc --- /dev/null +++ b/src/test/compile-fail/feature-gate-allow-internal-unstable-nested-macro.rs @@ -0,0 +1,23 @@ +// Copyright 2015 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. + +macro_rules! bar { + () => { + // more layers don't help: + #[allow_internal_unstable] + macro_rules! baz { //~ ERROR allow_internal_unstable side-steps + () => {} + } + } +} + +bar!(); + +fn main() {} diff --git a/src/test/compile-fail/feature-gate-allow-internal-unstable.rs b/src/test/compile-fail/feature-gate-allow-internal-unstable.rs new file mode 100644 index 00000000000..8a2d8dddac0 --- /dev/null +++ b/src/test/compile-fail/feature-gate-allow-internal-unstable.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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. + +#[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps +macro_rules! foo { + () => {} +} + +fn main() {} diff --git a/src/test/compile-fail/feature-gate-intrinsics-and-lang-items.rs b/src/test/compile-fail/feature-gate-intrinsics.rs index 986d52b1787..a4c09b21c90 100644 --- a/src/test/compile-fail/feature-gate-intrinsics-and-lang-items.rs +++ b/src/test/compile-fail/feature-gate-intrinsics.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[lang="foo"] //~ ERROR language items are subject to change -trait Foo {} - extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change fn bar(); } @@ -20,4 +17,3 @@ extern "rust-intrinsic" fn baz() { //~ ERROR intrinsics are subject to change fn main() { } - diff --git a/src/test/compile-fail/duplicate-trait-bounds.rs b/src/test/compile-fail/feature-gate-lang-items.rs index d9aa9d9dfcc..0435ff4c332 100644 --- a/src/test/compile-fail/duplicate-trait-bounds.rs +++ b/src/test/compile-fail/feature-gate-lang-items.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[lang="foo"] //~ ERROR language items are subject to change trait Foo {} -fn foo<T: Foo + Foo>() {} //~ ERROR `Foo` already appears in the list of bounds - -fn main() {} +fn main() { +} diff --git a/src/test/compile-fail/feature-gated-feature-in-macro-arg.rs b/src/test/compile-fail/feature-gated-feature-in-macro-arg.rs index 1e15e67876e..54bdaf011c8 100644 --- a/src/test/compile-fail/feature-gated-feature-in-macro-arg.rs +++ b/src/test/compile-fail/feature-gated-feature-in-macro-arg.rs @@ -21,7 +21,7 @@ // test. Not ideal, but oh well :( fn main() { - let a = &[1i32, 2, 3]; + let a = &[1, 2, 3]; println!("{}", { extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change fn atomic_fence(); diff --git a/src/test/compile-fail/gated-link-args.rs b/src/test/compile-fail/gated-link-args.rs new file mode 100644 index 00000000000..c8845ced2fc --- /dev/null +++ b/src/test/compile-fail/gated-link-args.rs @@ -0,0 +1,19 @@ +// Copyright 2015 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. + +// Test that `#[link_args]` attribute is gated by `link_args` +// feature gate. + +#[link_args = "aFdEfSeVEEE"] +extern {} +//~^ ERROR the `link_args` attribute is not portable across platforms +//~| HELP add #![feature(link_args)] to the crate attributes to enable + +fn main() { } diff --git a/src/test/compile-fail/gated-link-llvm-intrinsics.rs b/src/test/compile-fail/gated-link-llvm-intrinsics.rs new file mode 100644 index 00000000000..716ea9f8dba --- /dev/null +++ b/src/test/compile-fail/gated-link-llvm-intrinsics.rs @@ -0,0 +1,19 @@ +// Copyright 2015 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. + +extern { + #[link_name = "llvm.sqrt.f32"] + fn sqrt(x: f32) -> f32; + //~^ ERROR linking to LLVM intrinsics is experimental + //~| HELP add #![feature(link_llvm_intrinsics)] to the crate attributes +} + +fn main(){ +} diff --git a/src/test/compile-fail/gated-plugin_registrar.rs b/src/test/compile-fail/gated-plugin_registrar.rs index f6e11ffd9e5..d716c53e1d1 100644 --- a/src/test/compile-fail/gated-plugin_registrar.rs +++ b/src/test/compile-fail/gated-plugin_registrar.rs @@ -8,8 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Test that `#[plugin_registrar]` attribute is gated by `plugin_registrar` +// feature gate. + // the registration function isn't typechecked yet #[plugin_registrar] -pub fn registrar() {} //~ ERROR compiler plugins are experimental - +pub fn registrar() {} +//~^ ERROR compiler plugins are experimental +//~| HELP add #![feature(plugin_registrar)] to the crate attributes to enable fn main() {} diff --git a/src/test/compile-fail/gated-thread-local.rs b/src/test/compile-fail/gated-thread-local.rs new file mode 100644 index 00000000000..f355c6562c8 --- /dev/null +++ b/src/test/compile-fail/gated-thread-local.rs @@ -0,0 +1,25 @@ +// Copyright 2015 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. + +// Test that `#[thread_local]` attribute is gated by `thread_local` +// feature gate. +// +// (Note that the `thread_local!` macro is explicitly *not* gated; it +// is given permission to expand into this unstable attribute even +// when the surrounding context does not have permission to use it.) + +#[thread_local] //~ ERROR `#[thread_local]` is an experimental feature +static FOO: i32 = 3; + +pub fn main() { + FOO.with(|x| { + println!("x: {}", x); + }); +} diff --git a/src/test/compile-fail/gated-unsafe-destructor.rs b/src/test/compile-fail/gated-unsafe-destructor.rs new file mode 100644 index 00000000000..6024fef9fb8 --- /dev/null +++ b/src/test/compile-fail/gated-unsafe-destructor.rs @@ -0,0 +1,23 @@ +// Copyright 2015 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. + +// Test that `#[unsafe_destructor]` attribute is gated by `unsafe_destructor` +// feature gate. + +struct D<'a>(&'a u32); + +#[unsafe_destructor] +impl<'a> Drop for D<'a> { + //~^ ERROR `#[unsafe_destructor]` allows too many unsafe patterns + fn drop(&mut self) { } +} +//~^ HELP: add #![feature(unsafe_destructor)] to the crate attributes to enable + +pub fn main() { } diff --git a/src/test/compile-fail/import-glob-circular.rs b/src/test/compile-fail/import-glob-circular.rs index f38172db444..67834a99969 100644 --- a/src/test/compile-fail/import-glob-circular.rs +++ b/src/test/compile-fail/import-glob-circular.rs @@ -13,13 +13,13 @@ mod circ1 { pub use circ2::f2; pub fn f1() { println!("f1"); } - pub fn common() -> usize { return 0_usize; } + pub fn common() -> usize { return 0; } } mod circ2 { pub use circ1::f1; pub fn f2() { println!("f2"); } - pub fn common() -> usize { return 1_usize; } + pub fn common() -> usize { return 1; } } mod test { diff --git a/src/test/compile-fail/index-bot.rs b/src/test/compile-fail/index-bot.rs index b28f2a746fd..70c362303ae 100644 --- a/src/test/compile-fail/index-bot.rs +++ b/src/test/compile-fail/index-bot.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - (return)[0_usize]; //~ ERROR the type of this value must be known in this context + (return)[0]; //~ ERROR the type of this value must be known in this context } diff --git a/src/test/compile-fail/infinite-instantiation.rs b/src/test/compile-fail/infinite-instantiation.rs index d39efa3c2ab..559e0e9a292 100644 --- a/src/test/compile-fail/infinite-instantiation.rs +++ b/src/test/compile-fail/infinite-instantiation.rs @@ -32,13 +32,13 @@ impl<T:Clone> ToOpt for Option<T> { } fn function<T:ToOpt + Clone>(counter: usize, t: T) { - if counter > 0_usize { - function(counter - 1_usize, t.to_option()); + if counter > 0 { + function(counter - 1, t.to_option()); // FIXME(#4287) Error message should be here. It should be // a type error to instantiate `test` at a type other than T. } } fn main() { - function(22_usize, 22_usize); + function(22, 22); } diff --git a/src/test/compile-fail/infinite-vec-type-recursion.rs b/src/test/compile-fail/infinite-vec-type-recursion.rs index 5bcba350b2e..e5120840f76 100644 --- a/src/test/compile-fail/infinite-vec-type-recursion.rs +++ b/src/test/compile-fail/infinite-vec-type-recursion.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: illegal recursive type - - type x = Vec<x>; +//~^ ERROR unsupported cyclic reference fn main() { let b: x = Vec::new(); } diff --git a/src/test/compile-fail/internal-unstable-noallow.rs b/src/test/compile-fail/internal-unstable-noallow.rs new file mode 100644 index 00000000000..4e296198be8 --- /dev/null +++ b/src/test/compile-fail/internal-unstable-noallow.rs @@ -0,0 +1,30 @@ +// Copyright 2015 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. + +// this has to be separate to internal-unstable.rs because these tests +// have error messages pointing deep into the internals of the +// cross-crate macros, and hence need to use error-pattern instead of +// the // ~ form. + +// aux-build:internal_unstable.rs +// error-pattern:use of unstable library feature 'function' +// error-pattern:use of unstable library feature 'struct_field' +// error-pattern:compilation successful +#![feature(rustc_attrs)] + +#[macro_use] +extern crate internal_unstable; + +#[rustc_error] +fn main() { + call_unstable_noallow!(); + + construct_unstable_noallow!(0); +} diff --git a/src/test/compile-fail/internal-unstable-thread-local.rs b/src/test/compile-fail/internal-unstable-thread-local.rs new file mode 100644 index 00000000000..ff158497546 --- /dev/null +++ b/src/test/compile-fail/internal-unstable-thread-local.rs @@ -0,0 +1,23 @@ +// Copyright 2015 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. + +// aux-build:internal_unstable.rs + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +extern crate internal_unstable; + + +thread_local!(static FOO: () = ()); +thread_local!(static BAR: () = internal_unstable::unstable()); //~ WARN use of unstable + +#[rustc_error] +fn main() {} //~ ERROR diff --git a/src/test/compile-fail/internal-unstable.rs b/src/test/compile-fail/internal-unstable.rs new file mode 100755 index 00000000000..8674e8ab5b2 --- /dev/null +++ b/src/test/compile-fail/internal-unstable.rs @@ -0,0 +1,51 @@ +// Copyright 2015 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. + +// aux-build:internal_unstable.rs + +#![feature(rustc_attrs, allow_internal_unstable)] + +#[macro_use] +extern crate internal_unstable; + +macro_rules! foo { + ($e: expr, $f: expr) => {{ + $e; + $f; + internal_unstable::unstable(); //~ WARN use of unstable + }} +} + +#[allow_internal_unstable] +macro_rules! bar { + ($e: expr) => {{ + foo!($e, + internal_unstable::unstable()); + internal_unstable::unstable(); + }} +} + +#[rustc_error] +fn main() { //~ ERROR + // ok, the instability is contained. + call_unstable_allow!(); + construct_unstable_allow!(0); + + // bad. + pass_through_allow!(internal_unstable::unstable()); //~ WARN use of unstable + + pass_through_noallow!(internal_unstable::unstable()); //~ WARN use of unstable + + + + println!("{:?}", internal_unstable::unstable()); //~ WARN use of unstable + + bar!(internal_unstable::unstable()); //~ WARN use of unstable +} diff --git a/src/test/compile-fail/issue-11714.rs b/src/test/compile-fail/issue-11714.rs index d307352517f..998576097a0 100644 --- a/src/test/compile-fail/issue-11714.rs +++ b/src/test/compile-fail/issue-11714.rs @@ -9,7 +9,7 @@ // except according to those terms. fn blah() -> i32 { //~ ERROR not all control paths return a value - 1i32 + 1 ; //~ HELP consider removing this semicolon: } diff --git a/src/test/compile-fail/issue-13058.rs b/src/test/compile-fail/issue-13058.rs index 06f14158b91..50c4ac94d90 100644 --- a/src/test/compile-fail/issue-13058.rs +++ b/src/test/compile-fail/issue-13058.rs @@ -24,7 +24,7 @@ fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool { let cont_iter = cont.iter(); //~^ ERROR cannot infer an appropriate lifetime for autoref due to conflicting requirements - let result = cont_iter.fold(Some(0u16), |state, val| { + let result = cont_iter.fold(Some(0), |state, val| { state.map_or(None, |mask| { let bit = 1 << val; if mask & bit == 0 {Some(mask|bit)} else {None} @@ -34,10 +34,10 @@ fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool } fn main() { - check((3_usize, 5_usize)); + check((3, 5)); //~^ ERROR mismatched types //~| expected `&_` -//~| found `(usize, usize)` +//~| found `(_, _)` //~| expected &-ptr //~| found tuple } diff --git a/src/test/compile-fail/issue-13466.rs b/src/test/compile-fail/issue-13466.rs index 16128e52d64..a29a83c4306 100644 --- a/src/test/compile-fail/issue-13466.rs +++ b/src/test/compile-fail/issue-13466.rs @@ -14,17 +14,17 @@ pub fn main() { // The expected arm type `Option<T>` has one type parameter, while // the actual arm `Result<T, E>` has two. typeck should not be // tricked into looking up a non-existing second type parameter. - let _x: usize = match Some(1_usize) { + let _x: usize = match Some(1) { Ok(u) => u, //~^ ERROR mismatched types - //~| expected `core::option::Option<usize>` + //~| expected `core::option::Option<_>` //~| found `core::result::Result<_, _>` //~| expected enum `core::option::Option` //~| found enum `core::result::Result` Err(e) => panic!(e) //~^ ERROR mismatched types - //~| expected `core::option::Option<usize>` + //~| expected `core::option::Option<_>` //~| found `core::result::Result<_, _>` //~| expected enum `core::option::Option` //~| found enum `core::result::Result` diff --git a/src/test/compile-fail/issue-14845.rs b/src/test/compile-fail/issue-14845.rs index d7ff6f2fe63..d7bb806999c 100644 --- a/src/test/compile-fail/issue-14845.rs +++ b/src/test/compile-fail/issue-14845.rs @@ -22,11 +22,11 @@ fn main() { //~| expected u8 //~| found array of 1 elements - let local = [0u8]; + let local = [0]; let _v = &local as *mut u8; //~^ ERROR mismatched types //~| expected `*mut u8` - //~| found `&[u8; 1]` + //~| found `&[_; 1]` //~| expected u8, //~| found array of 1 elements } diff --git a/src/test/compile-fail/issue-16747.rs b/src/test/compile-fail/issue-16747.rs index a213234b89b..64334fe4392 100644 --- a/src/test/compile-fail/issue-16747.rs +++ b/src/test/compile-fail/issue-16747.rs @@ -18,11 +18,10 @@ trait Collection { fn len(&self) -> usize; } struct List<'a, T: ListItem<'a>> { //~^ ERROR the parameter type `T` may not live long enough -//~^^ HELP consider adding an explicit lifetime bound -//~^^^ NOTE ...so that the reference type `&'a [T]` does not outlive the data it points at +//~^^ NOTE ...so that the reference type `&'a [T]` does not outlive the data it points at slice: &'a [T] } - +//~^ HELP consider adding an explicit lifetime bound impl<'a, T: ListItem<'a>> Collection for List<'a, T> { fn len(&self) -> usize { 0 diff --git a/src/test/compile-fail/issue-17283.rs b/src/test/compile-fail/issue-17283.rs index 65731379094..a481fec6bf9 100644 --- a/src/test/compile-fail/issue-17283.rs +++ b/src/test/compile-fail/issue-17283.rs @@ -16,7 +16,7 @@ struct Foo { } fn main() { - let x = 1_usize; + let x = 1; let y: Foo; // `x { ... }` should not be interpreted as a struct literal here diff --git a/src/test/compile-fail/issue-17651.rs b/src/test/compile-fail/issue-17651.rs index d6471ca018d..8ebf80a8db0 100644 --- a/src/test/compile-fail/issue-17651.rs +++ b/src/test/compile-fail/issue-17651.rs @@ -13,6 +13,6 @@ fn main() { // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - (|| Box::new(*[0_usize].as_slice()))(); - //~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[usize]` + (|| Box::new(*[0].as_slice()))(); + //~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[_]` } diff --git a/src/test/compile-fail/issue-17718-patterns.rs b/src/test/compile-fail/issue-17718-patterns.rs index b7f58791bfc..4e63f667d26 100644 --- a/src/test/compile-fail/issue-17718-patterns.rs +++ b/src/test/compile-fail/issue-17718-patterns.rs @@ -13,7 +13,7 @@ static mut A2: usize = 1; const A3: usize = 1; fn main() { - match 1_usize { + match 1 { A1 => {} //~ ERROR: static variables cannot be referenced in a pattern A2 => {} //~ ERROR: static variables cannot be referenced in a pattern A3 => {} diff --git a/src/test/compile-fail/issue-17933.rs b/src/test/compile-fail/issue-17933.rs index bd047408498..657b31fa83c 100644 --- a/src/test/compile-fail/issue-17933.rs +++ b/src/test/compile-fail/issue-17933.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub static X: usize = 1_usize; +pub static X: usize = 1; fn main() { - match 1_usize { + match 1 { self::X => { }, //~^ ERROR static variables cannot be referenced in a pattern, use a `const` instead _ => { }, diff --git a/src/test/compile-fail/issue-18107.rs b/src/test/compile-fail/issue-18107.rs index d5fb22bdebd..60ab616d598 100644 --- a/src/test/compile-fail/issue-18107.rs +++ b/src/test/compile-fail/issue-18107.rs @@ -16,7 +16,7 @@ fn _create_render(_: &()) -> AbstractRenderer //~^ ERROR: the trait `core::marker::Sized` is not implemented { - match 0_usize { + match 0 { _ => unimplemented!() } } diff --git a/src/test/compile-fail/issue-18252.rs b/src/test/compile-fail/issue-18252.rs index 54c51405bd7..e3e56c7f97a 100644 --- a/src/test/compile-fail/issue-18252.rs +++ b/src/test/compile-fail/issue-18252.rs @@ -13,5 +13,5 @@ enum Foo { } fn main() { - let f = Foo::Variant(42_usize); //~ ERROR uses it like a function + let f = Foo::Variant(42); //~ ERROR uses it like a function } diff --git a/src/test/compile-fail/issue-18389.rs b/src/test/compile-fail/issue-18389.rs index 9065a5b9605..271c31bd375 100644 --- a/src/test/compile-fail/issue-18389.rs +++ b/src/test/compile-fail/issue-18389.rs @@ -12,18 +12,17 @@ use std::any::Any; use std::any::TypeId; +use std::marker::MarkerTrait; -pub trait Pt {} -pub trait Rt {} +pub trait Pt : MarkerTrait {} +pub trait Rt : MarkerTrait {} trait Private<P: Pt, R: Rt> { fn call(&self, p: P, r: R); } -pub trait Public: Private< +pub trait Public: Private< //~ ERROR private trait in exported type parameter bound <Self as Public>::P, -//~^ ERROR illegal recursive type; insert an enum or struct in the cycle, if this is desired <Self as Public>::R -//~^ ERROR unsupported cyclic reference between types/traits detected > { type P; type R; diff --git a/src/test/compile-fail/issue-18566.rs b/src/test/compile-fail/issue-18566.rs index dd3844b1a0e..41e82d0cd89 100644 --- a/src/test/compile-fail/issue-18566.rs +++ b/src/test/compile-fail/issue-18566.rs @@ -28,7 +28,7 @@ impl Tr for usize { } fn main() { - let s = &mut 1_usize; + let s = &mut 1; MyPtr(s).poke(s); //~^ ERROR cannot borrow `*s` as mutable more than once at a time diff --git a/src/test/compile-fail/issue-18783.rs b/src/test/compile-fail/issue-18783.rs index f6a3da81857..5eb3c439df2 100644 --- a/src/test/compile-fail/issue-18783.rs +++ b/src/test/compile-fail/issue-18783.rs @@ -13,7 +13,7 @@ use std::cell::RefCell; // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. fn main() { - let mut y = 1_usize; + let mut y = 1; let c = RefCell::new(vec![]); c.push(Box::new(|| y = 0)); c.push(Box::new(|| y = 0)); @@ -21,7 +21,7 @@ fn main() { } fn ufcs() { - let mut y = 1_usize; + let mut y = 1; let c = RefCell::new(vec![]); Push::push(&c, Box::new(|| y = 0)); diff --git a/src/test/compile-fail/issue-18959.rs b/src/test/compile-fail/issue-18959.rs index 8fb543fb967..ebda2481803 100644 --- a/src/test/compile-fail/issue-18959.rs +++ b/src/test/compile-fail/issue-18959.rs @@ -19,7 +19,7 @@ impl Foo for Thing { #[inline(never)] fn foo(b: &Bar) { - b.foo(&0usize) + b.foo(&0) //~^ ERROR the trait `Foo` is not implemented for the type `Bar` } diff --git a/src/test/compile-fail/issue-19991.rs b/src/test/compile-fail/issue-19991.rs index 2d73b98ec1e..6c9b0004f77 100644 --- a/src/test/compile-fail/issue-19991.rs +++ b/src/test/compile-fail/issue-19991.rs @@ -14,9 +14,9 @@ fn main() { if let Some(homura) = Some("madoka") { //~ ERROR missing an else clause //~| expected `()` - //~| found `i32` + //~| found `_` //~| expected () - //~| found i32 - 765i32 + //~| found integral variable + 765 }; } diff --git a/src/test/compile-fail/issue-20801.rs b/src/test/compile-fail/issue-20801.rs index 929c8ec0fd6..fe7807042e5 100644 --- a/src/test/compile-fail/issue-20801.rs +++ b/src/test/compile-fail/issue-20801.rs @@ -25,11 +25,11 @@ fn mut_ref() -> &'static mut T { } fn mut_ptr() -> *mut T { - unsafe { 0u8 as *mut T } + unsafe { 0 as *mut T } } fn const_ptr() -> *const T { - unsafe { 0u8 as *const T } + unsafe { 0 as *const T } } pub fn main() { diff --git a/src/test/compile-fail/issue-2150.rs b/src/test/compile-fail/issue-2150.rs index 505885e6c41..8b109b0a5c0 100644 --- a/src/test/compile-fail/issue-2150.rs +++ b/src/test/compile-fail/issue-2150.rs @@ -15,7 +15,7 @@ fn fail_len(v: Vec<isize> ) -> usize { let mut i = 3; panic!(); - for x in &v { i += 1_usize; } + for x in &v { i += 1; } //~^ ERROR: unreachable statement return i; } diff --git a/src/test/compile-fail/issue-23080-2.rs b/src/test/compile-fail/issue-23080-2.rs new file mode 100644 index 00000000000..ff5ac9de8d9 --- /dev/null +++ b/src/test/compile-fail/issue-23080-2.rs @@ -0,0 +1,29 @@ +// Copyright 2015 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. + +// ignore-tidy-linelength + +#![feature(optin_builtin_traits)] + +use std::marker::MarkerTrait; + +unsafe trait Trait: MarkerTrait { +//~^ error: traits with default impls (`e.g. unsafe impl Trait for ..`) must have no methods or associated items + type Output; +} + +unsafe impl Trait for .. {} + +fn call_method<T: Trait>(x: T) {} + +fn main() { + // ICE + call_method(()); +} diff --git a/src/test/compile-fail/issue-23080.rs b/src/test/compile-fail/issue-23080.rs new file mode 100644 index 00000000000..99373a69697 --- /dev/null +++ b/src/test/compile-fail/issue-23080.rs @@ -0,0 +1,31 @@ +// Copyright 2015 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. + +// ignore-tidy-linelength + +#![feature(optin_builtin_traits)] + +unsafe trait Trait { +//~^ error: traits with default impls (`e.g. unsafe impl Trait for ..`) must have no methods or associated items + fn method(&self) { + println!("Hello"); + } +} + +unsafe impl Trait for .. {} + +fn call_method<T: Trait>(x: T) { + x.method(); +} + +fn main() { + // ICE + call_method(()); +} diff --git a/src/test/compile-fail/issue-3953.rs b/src/test/compile-fail/issue-3953.rs deleted file mode 100644 index 0f1dd2d7fd6..00000000000 --- a/src/test/compile-fail/issue-3953.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2012 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. - -// ignore-tidy-linelength - -use std::cmp::PartialEq; - -trait Hahaha: PartialEq + PartialEq { - //~^ ERROR trait `PartialEq` already appears in the list of bounds -} - -struct Lol(isize); - -impl Hahaha for Lol { } - -impl PartialEq for Lol { - fn eq(&self, other: &Lol) -> bool { **self != **other } - fn ne(&self, other: &Lol) -> bool { **self == **other } -} - -fn main() { - if Lol(2) == Lol(4) { - println!("2 == 4"); - } else { - println!("2 != 4"); - } -} diff --git a/src/test/compile-fail/issue-4517.rs b/src/test/compile-fail/issue-4517.rs index 6d4777be40b..a1804b5a268 100644 --- a/src/test/compile-fail/issue-4517.rs +++ b/src/test/compile-fail/issue-4517.rs @@ -11,7 +11,7 @@ fn bar(int_param: usize) {} fn main() { - let foo: [u8; 4] = [1u8; 4_usize]; + let foo: [u8; 4] = [1; 4]; bar(foo); //~^ ERROR mismatched types //~| expected `usize` diff --git a/src/test/compile-fail/issue-7575.rs b/src/test/compile-fail/issue-7575.rs index b6643f43952..9c019f6ec47 100644 --- a/src/test/compile-fail/issue-7575.rs +++ b/src/test/compile-fail/issue-7575.rs @@ -32,17 +32,17 @@ trait UnusedTrait : MarkerTrait { impl CtxtFn for usize { fn f8(self, i: usize) -> usize { - i * 4_usize + i * 4 } fn f9(i: usize) -> usize { - i * 4_usize + i * 4 } } impl OtherTrait for usize { fn f9(i: usize) -> usize { - i * 8_usize + i * 8 } } diff --git a/src/test/compile-fail/issue-7867.rs b/src/test/compile-fail/issue-7867.rs index 7bb4aac23d6..400806c3a5f 100644 --- a/src/test/compile-fail/issue-7867.rs +++ b/src/test/compile-fail/issue-7867.rs @@ -23,16 +23,16 @@ fn main() { _ => () } - match &Some(42i32) { + match &Some(42) { Some(x) => (), //~^ ERROR mismatched types - //~| expected `&core::option::Option<i32>` + //~| expected `&core::option::Option<_>` //~| found `core::option::Option<_>` //~| expected &-ptr //~| found enum `core::option::Option` None => () //~^ ERROR mismatched types - //~| expected `&core::option::Option<i32>` + //~| expected `&core::option::Option<_>` //~| found `core::option::Option<_>` //~| expected &-ptr //~| found enum `core::option::Option` diff --git a/src/test/compile-fail/kindck-nonsendable-1.rs b/src/test/compile-fail/kindck-nonsendable-1.rs index e6041cddead..c370aa4b8fb 100644 --- a/src/test/compile-fail/kindck-nonsendable-1.rs +++ b/src/test/compile-fail/kindck-nonsendable-1.rs @@ -16,7 +16,7 @@ fn foo(_x: Rc<usize>) {} fn bar<F:FnOnce() + Send>(_: F) { } fn main() { - let x = Rc::new(3_usize); + let x = Rc::new(3); bar(move|| foo(x)); //~^ ERROR `core::marker::Send` is not implemented } diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-2.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-2.rs index fac518c7635..0a8e4514b43 100644 --- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-2.rs +++ b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-2.rs @@ -24,7 +24,7 @@ impl<'r> Itble<'r, usize, Range<usize>> for (usize, usize) { fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool { //~^ HELP: consider using an explicit lifetime parameter as shown: fn check<'r, I: Iterator<Item = usize>, T: Itble<'r, usize, I>>(cont: &'r T) let cont_iter = cont.iter(); //~ ERROR: cannot infer - let result = cont_iter.fold(Some(0u16), |state, val| { + let result = cont_iter.fold(Some(0), |state, val| { state.map_or(None, |mask| { let bit = 1 << val; if mask & bit == 0 {Some(mask|bit)} else {None} diff --git a/src/test/compile-fail/linkage1.rs b/src/test/compile-fail/linkage1.rs index 35f93c13fb5..555cc2b9a7a 100644 --- a/src/test/compile-fail/linkage1.rs +++ b/src/test/compile-fail/linkage1.rs @@ -11,5 +11,4 @@ extern { #[linkage = "extern_weak"] static foo: isize; //~^ ERROR: the `linkage` attribute is experimental and not portable - //~^^ ERROR: the `linkage` attribute is experimental and not portable } diff --git a/src/test/compile-fail/lint-dead-code-4.rs b/src/test/compile-fail/lint-dead-code-4.rs index f304c26efb5..8441fb3ade9 100644 --- a/src/test/compile-fail/lint-dead-code-4.rs +++ b/src/test/compile-fail/lint-dead-code-4.rs @@ -63,6 +63,6 @@ fn field_match_in_let(f: Bar) -> bool { fn main() { field_read(Foo { x: 1, b: false, marker: std::marker::NoCopy }); field_match_in_patterns(XYZ::Z); - field_match_in_let(Bar { x: 42_usize, b: true, _guard: () }); + field_match_in_let(Bar { x: 42, b: true, _guard: () }); let _ = Baz { x: 0 }; } diff --git a/src/test/compile-fail/liveness-return-last-stmt-semi.rs b/src/test/compile-fail/liveness-return-last-stmt-semi.rs index 57252dd58d7..a4eb1630afe 100644 --- a/src/test/compile-fail/liveness-return-last-stmt-semi.rs +++ b/src/test/compile-fail/liveness-return-last-stmt-semi.rs @@ -10,7 +10,7 @@ // // regression test for #8005 -macro_rules! test { () => { fn foo() -> i32 { 1i32; } } } +macro_rules! test { () => { fn foo() -> i32 { 1; } } } //~^ ERROR not all control paths return a value //~^^ HELP consider removing this semicolon diff --git a/src/test/compile-fail/macro-no-implicit-reexport.rs b/src/test/compile-fail/macro-no-implicit-reexport.rs index 13dbab12b77..e8d9f444cef 100644 --- a/src/test/compile-fail/macro-no-implicit-reexport.rs +++ b/src/test/compile-fail/macro-no-implicit-reexport.rs @@ -16,5 +16,5 @@ extern crate macro_non_reexport_2; fn main() { - assert_eq!(reexported!(), 3_usize); //~ ERROR macro undefined + assert_eq!(reexported!(), 3); //~ ERROR macro undefined } diff --git a/src/test/compile-fail/macro-reexport-not-locally-visible.rs b/src/test/compile-fail/macro-reexport-not-locally-visible.rs index dc8f4fadc76..26de51a7cf8 100644 --- a/src/test/compile-fail/macro-reexport-not-locally-visible.rs +++ b/src/test/compile-fail/macro-reexport-not-locally-visible.rs @@ -18,5 +18,5 @@ extern crate macro_reexport_1; fn main() { - assert_eq!(reexported!(), 3_usize); //~ ERROR macro undefined + assert_eq!(reexported!(), 3); //~ ERROR macro undefined } diff --git a/src/test/compile-fail/malformed-derive-entry.rs b/src/test/compile-fail/malformed-derive-entry.rs new file mode 100644 index 00000000000..62dbc21495a --- /dev/null +++ b/src/test/compile-fail/malformed-derive-entry.rs @@ -0,0 +1,25 @@ +// Copyright 2015 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. + +#[derive(Copy(Bad))] +//~^ ERROR malformed `derive` entry +struct Test1; + +#[derive(Copy="bad")] +//~^ ERROR malformed `derive` entry +struct Test2; + +#[derive()] +//~^ WARNING empty trait list +struct Test3; + +#[derive] +//~^ WARNING empty trait list +struct Test4; diff --git a/src/test/compile-fail/malformed-plugin-1.rs b/src/test/compile-fail/malformed-plugin-1.rs index 254a797ef1c..214a5e5e3eb 100644 --- a/src/test/compile-fail/malformed-plugin-1.rs +++ b/src/test/compile-fail/malformed-plugin-1.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(plugin)] #![plugin] //~ ERROR malformed plugin attribute fn main() {} diff --git a/src/test/compile-fail/malformed-plugin-2.rs b/src/test/compile-fail/malformed-plugin-2.rs index 884087b7bc5..1b112608bee 100644 --- a/src/test/compile-fail/malformed-plugin-2.rs +++ b/src/test/compile-fail/malformed-plugin-2.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(plugin)] #![plugin="bleh"] //~ ERROR malformed plugin attribute fn main() {} diff --git a/src/test/compile-fail/malformed-plugin-3.rs b/src/test/compile-fail/malformed-plugin-3.rs index 4885bb901df..0c948831de2 100644 --- a/src/test/compile-fail/malformed-plugin-3.rs +++ b/src/test/compile-fail/malformed-plugin-3.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(plugin)] #![plugin(foo="bleh")] //~ ERROR malformed plugin attribute fn main() {} diff --git a/src/test/compile-fail/method-self-arg-1.rs b/src/test/compile-fail/method-self-arg-1.rs index 7b6868af805..57a96bb9a26 100644 --- a/src/test/compile-fail/method-self-arg-1.rs +++ b/src/test/compile-fail/method-self-arg-1.rs @@ -23,9 +23,9 @@ fn main() { //~| found `Foo` //~| expected &-ptr //~| found struct `Foo` - Foo::bar(&42i32); //~ ERROR mismatched types + Foo::bar(&42); //~ ERROR mismatched types //~| expected `&Foo` - //~| found `&i32` + //~| found `&_` //~| expected struct `Foo` - //~| found i32 + //~| found integral variable } diff --git a/src/test/compile-fail/mut-pattern-mismatched.rs b/src/test/compile-fail/mut-pattern-mismatched.rs index 6de69a9adb0..9eb24c81960 100644 --- a/src/test/compile-fail/mut-pattern-mismatched.rs +++ b/src/test/compile-fail/mut-pattern-mismatched.rs @@ -9,21 +9,21 @@ // except according to those terms. fn main() { - let foo = &mut 1i32; + let foo = &mut 1; // (separate lines to ensure the spans are accurate) let &_ //~ ERROR mismatched types - //~| expected `&mut i32` + //~| expected `&mut _` //~| found `&_` //~| values differ in mutability = foo; let &mut _ = foo; - let bar = &1i32; + let bar = &1; let &_ = bar; let &mut _ //~ ERROR mismatched types - //~| expected `&i32` + //~| expected `&_` //~| found `&mut _` //~| values differ in mutability = bar; diff --git a/src/test/compile-fail/mutable-class-fields-2.rs b/src/test/compile-fail/mutable-class-fields-2.rs index b6744d4b33a..46af3a862c2 100644 --- a/src/test/compile-fail/mutable-class-fields-2.rs +++ b/src/test/compile-fail/mutable-class-fields-2.rs @@ -29,6 +29,6 @@ fn cat(in_x : usize, in_y : isize) -> cat { } fn main() { - let nyan : cat = cat(52_usize, 99); + let nyan : cat = cat(52, 99); nyan.eat(); } diff --git a/src/test/compile-fail/mutable-class-fields.rs b/src/test/compile-fail/mutable-class-fields.rs index 94b1047f85e..c163dc2b4d2 100644 --- a/src/test/compile-fail/mutable-class-fields.rs +++ b/src/test/compile-fail/mutable-class-fields.rs @@ -21,6 +21,6 @@ fn cat(in_x : usize, in_y : isize) -> cat { } fn main() { - let nyan : cat = cat(52_usize, 99); + let nyan : cat = cat(52, 99); nyan.how_hungry = 0; //~ ERROR cannot assign } diff --git a/src/test/compile-fail/non-exhaustive-pattern-witness.rs b/src/test/compile-fail/non-exhaustive-pattern-witness.rs index 0eb91e0419a..3ed91459ae9 100644 --- a/src/test/compile-fail/non-exhaustive-pattern-witness.rs +++ b/src/test/compile-fail/non-exhaustive-pattern-witness.rs @@ -27,7 +27,7 @@ fn struct_with_a_nested_enum_and_vector() { Foo { first: true, second: None } => (), Foo { first: true, second: Some(_) } => (), Foo { first: false, second: None } => (), - Foo { first: false, second: Some([1_usize, 2_usize, 3_usize, 4_usize]) } => () + Foo { first: false, second: Some([1, 2, 3, 4]) } => () } } diff --git a/src/test/compile-fail/or-patter-mismatch.rs b/src/test/compile-fail/or-patter-mismatch.rs index 4b261d89888..59508d6ac95 100644 --- a/src/test/compile-fail/or-patter-mismatch.rs +++ b/src/test/compile-fail/or-patter-mismatch.rs @@ -12,4 +12,4 @@ enum blah { a(isize, isize, usize), b(isize, isize), } -fn main() { match blah::a(1, 1, 2_usize) { blah::a(_, x, y) | blah::b(x, y) => { } } } +fn main() { match blah::a(1, 1, 2) { blah::a(_, x, y) | blah::b(x, y) => { } } } diff --git a/src/test/compile-fail/phantom-oibit.rs b/src/test/compile-fail/phantom-oibit.rs new file mode 100644 index 00000000000..c912d084daa --- /dev/null +++ b/src/test/compile-fail/phantom-oibit.rs @@ -0,0 +1,41 @@ +// Copyright 2015 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. + +// Ensure that OIBIT checks `T` when it encounters a `PhantomData<T>` field, instead of checking +// the `PhantomData<T>` type itself (which almost always implements a "default" trait +// (`impl Trait for ..`)) + +#![feature(optin_builtin_traits)] + +use std::marker::{MarkerTrait, PhantomData}; + +unsafe trait Zen: MarkerTrait {} + +unsafe impl Zen for .. {} + +unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {} + +struct Guard<'a, T: 'a> { + _marker: PhantomData<&'a T>, +} + +struct Nested<T>(T); + +fn is_zen<T: Zen>(_: T) {} + +fn not_sync<T>(x: Guard<T>) { + is_zen(x) //~ error: the trait `core::marker::Sync` is not implemented for the type `T` +} + +fn nested_not_sync<T>(x: Nested<Guard<T>>) { + is_zen(x) //~ error: the trait `core::marker::Sync` is not implemented for the type `T` +} + +fn main() {} diff --git a/src/test/compile-fail/plugin-extern-crate-attr-deprecated.rs b/src/test/compile-fail/plugin-extern-crate-attr-deprecated.rs index ccda5cbdceb..efa352e386d 100644 --- a/src/test/compile-fail/plugin-extern-crate-attr-deprecated.rs +++ b/src/test/compile-fail/plugin-extern-crate-attr-deprecated.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(plugin)] + #[plugin] //~ ERROR #[plugin] on `extern crate` is deprecated //~^ HELP use a crate attribute instead, i.e. #![plugin(std)] extern crate std; diff --git a/src/test/compile-fail/privacy5.rs b/src/test/compile-fail/privacy5.rs index df570fd4647..a7f6a514b96 100644 --- a/src/test/compile-fail/privacy5.rs +++ b/src/test/compile-fail/privacy5.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:privacy-tuple-struct.rs -// ignore-fast extern crate "privacy-tuple-struct" as other; diff --git a/src/test/compile-fail/private-method.rs b/src/test/compile-fail/private-method.rs index ccbdd52a983..16510c2c8c9 100644 --- a/src/test/compile-fail/private-method.rs +++ b/src/test/compile-fail/private-method.rs @@ -30,6 +30,6 @@ mod kitties { } fn main() { - let nyan : kitties::cat = kitties::cat(52_usize, 99); + let nyan : kitties::cat = kitties::cat(52, 99); nyan.nap(); } diff --git a/src/test/compile-fail/private-struct-field-cross-crate.rs b/src/test/compile-fail/private-struct-field-cross-crate.rs index 243d835d46e..fb4491a6375 100644 --- a/src/test/compile-fail/private-struct-field-cross-crate.rs +++ b/src/test/compile-fail/private-struct-field-cross-crate.rs @@ -13,7 +13,7 @@ extern crate cci_class; use cci_class::kitties::cat; fn main() { - let nyan : cat = cat(52_usize, 99); - assert!((nyan.meows == 52_usize)); + let nyan : cat = cat(52, 99); + assert!((nyan.meows == 52)); //~^ ERROR field `meows` of struct `cci_class::kitties::cat` is private } diff --git a/src/test/compile-fail/range-1.rs b/src/test/compile-fail/range-1.rs index a8b6e399418..e7b34d6d1bc 100644 --- a/src/test/compile-fail/range-1.rs +++ b/src/test/compile-fail/range-1.rs @@ -20,7 +20,7 @@ pub fn main() { //~^ ERROR the trait `core::num::Int` is not implemented for the type `f32` // Unsized type. - let arr: &[_] = &[1u32, 2, 3]; + let arr: &[_] = &[1, 2, 3]; let range = *arr..; //~^ ERROR the trait `core::marker::Sized` is not implemented } diff --git a/src/test/compile-fail/regions-addr-of-self.rs b/src/test/compile-fail/regions-addr-of-self.rs index 45e468b3ab0..04ee0526403 100644 --- a/src/test/compile-fail/regions-addr-of-self.rs +++ b/src/test/compile-fail/regions-addr-of-self.rs @@ -15,18 +15,18 @@ struct dog { impl dog { pub fn chase_cat(&mut self) { let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer - *p += 1_usize; + *p += 1; } pub fn chase_cat_2(&mut self) { let p: &mut usize = &mut self.cats_chased; - *p += 1_usize; + *p += 1; } } fn dog() -> dog { dog { - cats_chased: 0_usize + cats_chased: 0 } } diff --git a/src/test/compile-fail/regions-addr-of-upvar-self.rs b/src/test/compile-fail/regions-addr-of-upvar-self.rs index 8cc2dd6afc6..28491f1155c 100644 --- a/src/test/compile-fail/regions-addr-of-upvar-self.rs +++ b/src/test/compile-fail/regions-addr-of-upvar-self.rs @@ -18,7 +18,7 @@ impl dog { pub fn chase_cat(&mut self) { let _f = || { let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer - *p = 3_usize; + *p = 3; }; } } diff --git a/src/test/compile-fail/regions-creating-enums.rs b/src/test/compile-fail/regions-creating-enums.rs index 4c361427bf3..ad2dc28afef 100644 --- a/src/test/compile-fail/regions-creating-enums.rs +++ b/src/test/compile-fail/regions-creating-enums.rs @@ -14,8 +14,8 @@ enum ast<'a> { } fn build() { - let x = ast::num(3_usize); - let y = ast::num(4_usize); + let x = ast::num(3); + let y = ast::num(4); let z = ast::add(&x, &y); compute(&z); } diff --git a/src/test/compile-fail/regions-pattern-typing-issue-19997.rs b/src/test/compile-fail/regions-pattern-typing-issue-19997.rs index da839d72172..ae9ceb600d4 100644 --- a/src/test/compile-fail/regions-pattern-typing-issue-19997.rs +++ b/src/test/compile-fail/regions-pattern-typing-issue-19997.rs @@ -9,8 +9,8 @@ // except according to those terms. fn main() { - let a0 = 0u8; - let f = 1u8; + let a0 = 0; + let f = 1; let mut a1 = &a0; match (&a1,) { (&ref b0,) => { diff --git a/src/test/compile-fail/regions-return-ref-to-upvar-issue-17403.rs b/src/test/compile-fail/regions-return-ref-to-upvar-issue-17403.rs index aa20efa5a12..1e2224eafae 100644 --- a/src/test/compile-fail/regions-return-ref-to-upvar-issue-17403.rs +++ b/src/test/compile-fail/regions-return-ref-to-upvar-issue-17403.rs @@ -15,7 +15,7 @@ fn main() { // Unboxed closure case { - let mut x = 0_usize; + let mut x = 0; let mut f = || &mut x; //~ ERROR cannot infer let x = f(); let y = f(); diff --git a/src/test/compile-fail/regions-trait-1.rs b/src/test/compile-fail/regions-trait-1.rs index b45a37d26e5..01439ce5e68 100644 --- a/src/test/compile-fail/regions-trait-1.rs +++ b/src/test/compile-fail/regions-trait-1.rs @@ -34,7 +34,7 @@ fn get_v(gc: Box<get_ctxt>) -> usize { } fn main() { - let ctxt = ctxt { v: 22_usize }; + let ctxt = ctxt { v: 22 }; let hc = has_ctxt { c: &ctxt }; - assert_eq!(get_v(box hc as Box<get_ctxt>), 22_usize); + assert_eq!(get_v(box hc as Box<get_ctxt>), 22); } diff --git a/src/test/compile-fail/reserved-attr-on-macro.rs b/src/test/compile-fail/reserved-attr-on-macro.rs new file mode 100644 index 00000000000..db8f82a70e1 --- /dev/null +++ b/src/test/compile-fail/reserved-attr-on-macro.rs @@ -0,0 +1,18 @@ +// Copyright 2015 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. + +#[rustc_attribute_should_be_reserved] //~ ERROR attributes with the prefix `rustc_` are reserved +macro_rules! foo { + () => (()); +} + +fn main() { + foo!(); +} diff --git a/src/test/compile-fail/send-is-not-static-ensures-scoping.rs b/src/test/compile-fail/send-is-not-static-ensures-scoping.rs index fe03ca8353d..fe03ca8353d 100755..100644 --- a/src/test/compile-fail/send-is-not-static-ensures-scoping.rs +++ b/src/test/compile-fail/send-is-not-static-ensures-scoping.rs diff --git a/src/test/compile-fail/single-derive-attr.rs b/src/test/compile-fail/single-derive-attr.rs new file mode 100644 index 00000000000..0b1b3141f5b --- /dev/null +++ b/src/test/compile-fail/single-derive-attr.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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. + +#[derive_Clone] +//~^ ERROR attributes of the form `#[derive_*]` are reserved +struct Test; + +pub fn main() {} diff --git a/src/test/compile-fail/structure-constructor-type-mismatch.rs b/src/test/compile-fail/structure-constructor-type-mismatch.rs index c276228b18e..ea6d63ca540 100644 --- a/src/test/compile-fail/structure-constructor-type-mismatch.rs +++ b/src/test/compile-fail/structure-constructor-type-mismatch.rs @@ -26,40 +26,40 @@ fn main() { let pt = PointF { //~^ ERROR structure constructor specifies a structure of type //~| expected f32 - //~| found i32 - x: 1i32, - y: 2i32, + //~| found integral variable + x: 1, + y: 2, }; let pt2 = Point::<f32> { //~^ ERROR structure constructor specifies a structure of type //~| expected f32 - //~| found i32 - x: 3i32, - y: 4i32, + //~| found integral variable + x: 3, + y: 4, }; let pair = PairF { //~^ ERROR structure constructor specifies a structure of type //~| expected f32 - //~| found i32 - x: 5i32, - y: 6i32, + //~| found integral variable + x: 5, + y: 6, }; let pair2 = PairF::<i32> { //~^ ERROR structure constructor specifies a structure of type //~| expected f32 - //~| found i32 - x: 7i32, - y: 8i32, + //~| found integral variable + x: 7, + y: 8, }; let pt3 = PointF::<i32> { //~^ ERROR wrong number of type arguments //~| ERROR structure constructor specifies a structure of type - x: 9i32, - y: 10i32, + x: 9, + y: 10, }; } diff --git a/src/test/compile-fail/tail-typeck.rs b/src/test/compile-fail/tail-typeck.rs index 9c1d318d588..5c1270aa0e4 100644 --- a/src/test/compile-fail/tail-typeck.rs +++ b/src/test/compile-fail/tail-typeck.rs @@ -12,6 +12,6 @@ fn f() -> isize { return g(); } -fn g() -> usize { return 0_usize; } +fn g() -> usize { return 0; } fn main() { let y = f(); } diff --git a/src/test/compile-fail/traits-assoc-type-in-supertrait-bad.rs b/src/test/compile-fail/traits-assoc-type-in-supertrait-bad.rs new file mode 100644 index 00000000000..971869ba85b --- /dev/null +++ b/src/test/compile-fail/traits-assoc-type-in-supertrait-bad.rs @@ -0,0 +1,26 @@ +// Copyright 2015 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. + +// Test case where an associated type is referenced from within the +// supertrait definition, and the impl makes the wrong +// associations. Issue #20220. + +use std::vec::IntoIter; + +pub trait Foo: Iterator<Item=<Self as Foo>::Key> { + type Key; +} + +impl Foo for IntoIter<i32> { //~ ERROR type mismatch + type Key = u32; +} + +fn main() { +} diff --git a/src/test/compile-fail/traits-issue-23003-overflow.rs b/src/test/compile-fail/traits-issue-23003-overflow.rs new file mode 100644 index 00000000000..ea41775f310 --- /dev/null +++ b/src/test/compile-fail/traits-issue-23003-overflow.rs @@ -0,0 +1,38 @@ +// Copyright 2015 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. + +// A variant of traits-issue-23003 in which an infinite series of +// types are required. This currently creates an overflow. This test +// is included to ensure that some controlled failure, at least, +// results -- but it might be that we should adjust the rules somewhat +// to make this legal. -nmatsakis + +use std::marker::PhantomData; + +trait Async { + type Cancel; +} + +struct Receipt<A:Async> { + marker: PhantomData<A>, +} + +struct Complete<B> { + core: Option<B>, +} + +impl<B> Async for Complete<B> { + type Cancel = Receipt<Complete<Option<B>>>; +} + +fn foo(r: Receipt<Complete<()>>) { } +//~^ ERROR overflow + +fn main() { } diff --git a/src/test/compile-fail/traits-multidispatch-convert-ambig-dest.rs b/src/test/compile-fail/traits-multidispatch-convert-ambig-dest.rs index 0a5aa1b7bd3..8fe1f4d2371 100644 --- a/src/test/compile-fail/traits-multidispatch-convert-ambig-dest.rs +++ b/src/test/compile-fail/traits-multidispatch-convert-ambig-dest.rs @@ -33,7 +33,7 @@ where T : Convert<U> } fn a() { - test(22_i32, std::default::Default::default()); //~ ERROR type annotations required + test(22, std::default::Default::default()); //~ ERROR type annotations required } fn main() {} diff --git a/src/test/compile-fail/traits-repeated-supertrait-ambig.rs b/src/test/compile-fail/traits-repeated-supertrait-ambig.rs new file mode 100644 index 00000000000..d61ac6f08d9 --- /dev/null +++ b/src/test/compile-fail/traits-repeated-supertrait-ambig.rs @@ -0,0 +1,53 @@ +// Copyright 2015 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. + +// Test a case of a trait which extends the same supertrait twice, but +// with difference type parameters. Test then that when we don't give +// enough information to pick between these, no selection is made. In +// this particular case, the two choices are i64/u64 -- so when we use +// an integer literal, we wind up falling this literal back to i32. +// See also `run-pass/trait-repeated-supertrait.rs`. + +trait CompareTo<T> { + fn same_as(&self, t: T) -> bool; +} + +trait CompareToInts : CompareTo<i64> + CompareTo<u64> { +} + +impl CompareTo<i64> for i64 { + fn same_as(&self, t: i64) -> bool { *self == t } +} + +impl CompareTo<u64> for i64 { + fn same_as(&self, t: u64) -> bool { *self == (t as i64) } +} + +impl CompareToInts for i64 { } + +fn with_obj(c: &CompareToInts) -> bool { + c.same_as(22) //~ ERROR `CompareTo<i32>` is not implemented +} + +fn with_trait<C:CompareToInts>(c: &C) -> bool { + c.same_as(22) //~ ERROR `CompareTo<i32>` is not implemented +} + +fn with_ufcs1<C:CompareToInts>(c: &C) -> bool { + CompareToInts::same_as(c, 22) //~ ERROR `CompareTo<i32>` is not implemented +} + +fn with_ufcs2<C:CompareToInts>(c: &C) -> bool { + CompareTo::same_as(c, 22) //~ ERROR `CompareTo<i32>` is not implemented +} + +fn main() { + assert_eq!(22_i64.same_as(22), true); //~ ERROR `CompareTo<i32>` is not implemented +} diff --git a/src/test/compile-fail/tuple-index-out-of-bounds.rs b/src/test/compile-fail/tuple-index-out-of-bounds.rs index 54b8d551f20..c2c41fbbb2a 100644 --- a/src/test/compile-fail/tuple-index-out-of-bounds.rs +++ b/src/test/compile-fail/tuple-index-out-of-bounds.rs @@ -11,14 +11,14 @@ struct Point(i32, i32); fn main() { - let origin = Point(0i32, 0i32); + let origin = Point(0, 0); origin.0; origin.1; origin.2; //~^ ERROR attempted out-of-bounds tuple index `2` on type `Point` - let tuple = (0i32, 0i32); + let tuple = (0, 0); tuple.0; tuple.1; tuple.2; - //~^ ERROR attempted out-of-bounds tuple index `2` on type `(i32, i32)` + //~^ ERROR attempted out-of-bounds tuple index `2` on type `(_, _)` } diff --git a/src/test/compile-fail/type-mismatch-multiple.rs b/src/test/compile-fail/type-mismatch-multiple.rs index 3bf0896d990..627300a0377 100644 --- a/src/test/compile-fail/type-mismatch-multiple.rs +++ b/src/test/compile-fail/type-mismatch-multiple.rs @@ -10,12 +10,12 @@ // Checking that the compiler reports multiple type errors at once -fn main() { let a: bool = 1i32; let b: i32 = true; } +fn main() { let a: bool = 1; let b: i32 = true; } //~^ ERROR mismatched types //~| expected `bool` -//~| found `i32` +//~| found `_` //~| expected bool -//~| found i32 +//~| found integral variable //~| ERROR mismatched types //~| expected `i32` //~| found `bool` diff --git a/src/test/compile-fail/type-params-in-different-spaces-1.rs b/src/test/compile-fail/type-params-in-different-spaces-1.rs index de9623de7cd..88d8788d63a 100644 --- a/src/test/compile-fail/type-params-in-different-spaces-1.rs +++ b/src/test/compile-fail/type-params-in-different-spaces-1.rs @@ -23,7 +23,7 @@ trait BrokenAdd: Int { impl<T: Int> BrokenAdd for T {} pub fn main() { - let foo: u8 = 0u8; + let foo: u8 = 0; let x: u8 = foo.broken_add("hello darkness my old friend".to_string()); println!("{}", x); } diff --git a/src/test/compile-fail/typeck-default-trait-impl-cross-crate-coherence.rs b/src/test/compile-fail/typeck-default-trait-impl-cross-crate-coherence.rs new file mode 100644 index 00000000000..3a29bb9c227 --- /dev/null +++ b/src/test/compile-fail/typeck-default-trait-impl-cross-crate-coherence.rs @@ -0,0 +1,34 @@ +// Copyright 2015 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. + +// aux-build:typeck-default-trait-impl-cross-crate-coherence-lib.rs + +// Test that we do not consider associated types to be sendable without +// some applicable trait bound (and we don't ICE). + +#![feature(optin_builtin_traits)] + +extern crate "typeck-default-trait-impl-cross-crate-coherence-lib" as lib; + +use lib::DefaultedTrait; + +struct A; +impl DefaultedTrait for (A,) { } //~ ERROR E0321 + +struct B; +impl !DefaultedTrait for (B,) { } //~ ERROR E0321 + +struct C; +struct D<T>(T); +impl DefaultedTrait for Box<C> { } //~ ERROR E0321 +impl DefaultedTrait for lib::Something<C> { } //~ ERROR E0321 +impl DefaultedTrait for D<C> { } // OK + +fn main() { } diff --git a/src/test/compile-fail/typeck-default-trait-impl-outside-crate.rs b/src/test/compile-fail/typeck-default-trait-impl-outside-crate.rs index 10ba8c74164..a345bd1b65c 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-outside-crate.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-outside-crate.rs @@ -13,6 +13,6 @@ #![feature(optin_builtin_traits)] impl Copy for .. {} -//~^ ERROR cannot create default implementations for traits outside the crate they're defined in; define a new trait instead. +//~^ ERROR E0318 fn main() {} diff --git a/src/test/compile-fail/typeck_type_placeholder_item.rs b/src/test/compile-fail/typeck_type_placeholder_item.rs index 5bfad94867e..d4f3cdfd8b7 100644 --- a/src/test/compile-fail/typeck_type_placeholder_item.rs +++ b/src/test/compile-fail/typeck_type_placeholder_item.rs @@ -21,7 +21,7 @@ fn test2() -> (_, _) { (5, 5) } static TEST3: _ = "test"; //~^ ERROR the type placeholder `_` is not allowed within types on item signatures -static TEST4: _ = 145u16; +static TEST4: _ = 145; //~^ ERROR the type placeholder `_` is not allowed within types on item signatures static TEST5: (_, _) = (1, 2); @@ -74,7 +74,7 @@ pub fn main() { static FN_TEST3: _ = "test"; //~^ ERROR the type placeholder `_` is not allowed within types on item signatures - static FN_TEST4: _ = 145u16; + static FN_TEST4: _ = 145; //~^ ERROR the type placeholder `_` is not allowed within types on item signatures static FN_TEST5: (_, _) = (1, 2); diff --git a/src/test/compile-fail/unboxed-closure-illegal-move.rs b/src/test/compile-fail/unboxed-closure-illegal-move.rs index 86e326f3c5a..564b1b4669f 100644 --- a/src/test/compile-fail/unboxed-closure-illegal-move.rs +++ b/src/test/compile-fail/unboxed-closure-illegal-move.rs @@ -23,28 +23,28 @@ fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f } fn main() { // By-ref cases { - let x = Box::new(0_usize); + let x = Box::new(0); let f = to_fn(|| drop(x)); //~ ERROR cannot move } { - let x = Box::new(0_usize); + let x = Box::new(0); let f = to_fn_mut(|| drop(x)); //~ ERROR cannot move } { - let x = Box::new(0_usize); + let x = Box::new(0); let f = to_fn_once(|| drop(x)); // OK -- FnOnce } // By-value cases { - let x = Box::new(0_usize); + let x = Box::new(0); let f = to_fn(move || drop(x)); //~ ERROR cannot move } { - let x = Box::new(0_usize); + let x = Box::new(0); let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move } { - let x = Box::new(0_usize); + let x = Box::new(0); let f = to_fn_once(move || drop(x)); // this one is ok } } diff --git a/src/test/compile-fail/unboxed-closure-immutable-capture.rs b/src/test/compile-fail/unboxed-closure-immutable-capture.rs index b40a91181ad..5be2738b47e 100644 --- a/src/test/compile-fail/unboxed-closure-immutable-capture.rs +++ b/src/test/compile-fail/unboxed-closure-immutable-capture.rs @@ -17,7 +17,7 @@ fn set(x: &mut usize) { *x = 0; } fn main() { - let x = 0_usize; + let x = 0; move || x = 1; //~ ERROR cannot assign move || set(&mut x); //~ ERROR cannot borrow move || x = 1; //~ ERROR cannot assign diff --git a/src/test/compile-fail/unboxed-closure-region.rs b/src/test/compile-fail/unboxed-closure-region.rs index 5f4bf0d33be..eee1b6ce30b 100644 --- a/src/test/compile-fail/unboxed-closure-region.rs +++ b/src/test/compile-fail/unboxed-closure-region.rs @@ -14,7 +14,7 @@ // reference cannot escape the region of that variable. fn main() { let _f = { - let x = 0_usize; + let x = 0; || x //~ ERROR `x` does not live long enough }; } diff --git a/src/test/compile-fail/unboxed-closures-borrow-conflict.rs b/src/test/compile-fail/unboxed-closures-borrow-conflict.rs index 1191cfa2600..372f3277931 100644 --- a/src/test/compile-fail/unboxed-closures-borrow-conflict.rs +++ b/src/test/compile-fail/unboxed-closures-borrow-conflict.rs @@ -14,7 +14,7 @@ // cause borrow conflicts. fn main() { - let mut x = 0_usize; + let mut x = 0; let f = || x += 1; let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed } diff --git a/src/test/compile-fail/unboxed-closures-mutate-upvar.rs b/src/test/compile-fail/unboxed-closures-mutate-upvar.rs index 650bb17bb77..35052ec0bd5 100644 --- a/src/test/compile-fail/unboxed-closures-mutate-upvar.rs +++ b/src/test/compile-fail/unboxed-closures-mutate-upvar.rs @@ -20,21 +20,21 @@ fn to_fn<A,F:Fn<A>>(f: F) -> F { f } fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f } fn a() { - let n = 0u8; + let n = 0; let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign n += 1; }); } fn b() { - let mut n = 0u8; + let mut n = 0; let mut f = to_fn_mut(|| { n += 1; // OK }); } fn c() { - let n = 0u8; + let n = 0; let mut f = to_fn_mut(move || { // If we just did a straight-forward desugaring, this would // compile, but we do something a bit more subtle, and hence @@ -44,21 +44,21 @@ fn c() { } fn d() { - let mut n = 0u8; + let mut n = 0; let mut f = to_fn_mut(move || { n += 1; // OK }); } fn e() { - let n = 0u8; + let n = 0; let mut f = to_fn(move || { n += 1; //~ ERROR cannot assign }); } fn f() { - let mut n = 0u8; + let mut n = 0; let mut f = to_fn(move || { n += 1; //~ ERROR cannot assign }); diff --git a/src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.rs b/src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.rs index 2345a86595e..432c7fa5d1b 100644 --- a/src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.rs +++ b/src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.rs @@ -16,7 +16,7 @@ fn call<F>(f: F) where F : Fn() { } fn main() { - let mut counter = 0_u32; + let mut counter = 0; call(|| { counter += 1; //~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure diff --git a/src/test/compile-fail/unreachable-arm.rs b/src/test/compile-fail/unreachable-arm.rs index eb5ffeaf888..bc93b86a391 100644 --- a/src/test/compile-fail/unreachable-arm.rs +++ b/src/test/compile-fail/unreachable-arm.rs @@ -15,4 +15,4 @@ enum foo { a(Box<foo>, isize), b(usize), } -fn main() { match foo::b(1_usize) { foo::b(_) | foo::a(box _, 1) => { } foo::a(_, 1) => { } } } +fn main() { match foo::b(1) { foo::b(_) | foo::a(box _, 1) => { } foo::a(_, 1) => { } } } diff --git a/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs b/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs index 97908118e35..4ea7051775e 100644 --- a/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs +++ b/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs @@ -10,7 +10,7 @@ fn f(p: *const u8) { - *p = 0u8; //~ ERROR dereference of unsafe pointer requires unsafe function or block + *p = 0; //~ ERROR dereference of unsafe pointer requires unsafe function or block return; } diff --git a/src/test/compile-fail/variance-issue-20533.rs b/src/test/compile-fail/variance-issue-20533.rs index 0254f56bd1a..e5473f12bf2 100644 --- a/src/test/compile-fail/variance-issue-20533.rs +++ b/src/test/compile-fail/variance-issue-20533.rs @@ -33,19 +33,19 @@ struct AffineU32(u32); fn main() { { - let a = AffineU32(1_u32); + let a = AffineU32(1); let x = foo(&a); drop(a); //~ ERROR cannot move out of `a` drop(x); } { - let a = AffineU32(1_u32); + let a = AffineU32(1); let x = bar(&a); drop(a); //~ ERROR cannot move out of `a` drop(x); } { - let a = AffineU32(1_u32); + let a = AffineU32(1); let x = baz(&a); drop(a); //~ ERROR cannot move out of `a` drop(x); diff --git a/src/test/compile-fail/vtable-res-trait-param.rs b/src/test/compile-fail/vtable-res-trait-param.rs index cc6ff2d8ebc..654272f5bc6 100644 --- a/src/test/compile-fail/vtable-res-trait-param.rs +++ b/src/test/compile-fail/vtable-res-trait-param.rs @@ -23,7 +23,7 @@ impl TraitB for isize { } fn call_it<B:TraitB>(b: B) -> isize { - let y = 4_usize; + let y = 4; b.gimme_an_a(y) //~ ERROR the trait `TraitA` is not implemented } diff --git a/src/test/debuginfo/associated-types.rs b/src/test/debuginfo/associated-types.rs index 26117e7a13b..63132d91327 100644 --- a/src/test/debuginfo/associated-types.rs +++ b/src/test/debuginfo/associated-types.rs @@ -139,13 +139,13 @@ fn assoc_enum<T: TraitWithAssocType>(arg: Enum<T>) { } fn main() { - assoc_struct(Struct { b: -1i32, b1: 0i64 }); - assoc_local(1i32); - assoc_arg::<i32>(2i64); - assoc_return_value(3i32); - assoc_tuple((4i32, 5i64)); - assoc_enum(Enum::Variant1(6i32, 7i64)); - assoc_enum(Enum::Variant2(8i64, 9i32)); + assoc_struct(Struct { b: -1, b1: 0 }); + assoc_local(1); + assoc_arg::<i32>(2); + assoc_return_value(3); + assoc_tuple((4, 5)); + assoc_enum(Enum::Variant1(6, 7)); + assoc_enum(Enum::Variant2(8, 9)); } fn zzz() { () } diff --git a/src/test/debuginfo/constant-debug-locs.rs b/src/test/debuginfo/constant-debug-locs.rs new file mode 100644 index 00000000000..24332e31775 --- /dev/null +++ b/src/test/debuginfo/constant-debug-locs.rs @@ -0,0 +1,67 @@ +// Copyright 2013-2015 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. + +// ignore-android: FIXME(#10381) +// min-lldb-version: 310 + +// compile-flags:-g + +#![allow(unused_variables)] +#![allow(dead_code)] +#![omit_gdb_pretty_printer_section] + +// This test makes sure that the compiler doesn't crash when trying to assign +// debug locations to const-expressions. + +use std::sync::MUTEX_INIT; +use std::cell::UnsafeCell; + +const CONSTANT: u64 = 3 + 4; + +struct Struct { + a: isize, + b: usize, +} +const STRUCT: Struct = Struct { a: 1, b: 2 }; + +struct TupleStruct(u32); +const TUPLE_STRUCT: TupleStruct = TupleStruct(4); + +enum Enum { + Variant1(char), + Variant2 { a: u8 }, + Variant3 +} + +const VARIANT1: Enum = Enum::Variant1('v'); +const VARIANT2: Enum = Enum::Variant2 { a: 2 }; +const VARIANT3: Enum = Enum::Variant3; + +const STRING: &'static str = "String"; + +const VEC: [u32; 8] = [0; 8]; + +const NESTED: (Struct, TupleStruct) = (STRUCT, TUPLE_STRUCT); + +const UNSAFE_CELL: UnsafeCell<bool> = UnsafeCell { value: false }; + +fn main() { + let mut _constant = CONSTANT; + let mut _struct = STRUCT; + let mut _tuple_struct = TUPLE_STRUCT; + let mut _variant1 = VARIANT1; + let mut _variant2 = VARIANT2; + let mut _variant3 = VARIANT3; + let mut _string = STRING; + let mut _vec = VEC; + let mut _nested = NESTED; + let mut _extern = MUTEX_INIT; + let mut _unsafe_cell = UNSAFE_CELL; +} diff --git a/src/test/debuginfo/cross-crate-spans.rs b/src/test/debuginfo/cross-crate-spans.rs new file mode 100644 index 00000000000..3aef9438a33 --- /dev/null +++ b/src/test/debuginfo/cross-crate-spans.rs @@ -0,0 +1,74 @@ +// Copyright 2013-2015 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. + +#![omit_gdb_pretty_printer_section] + +// ignore-android: FIXME(#10381) +// min-lldb-version: 310 + +// aux-build:cross_crate_spans.rs +extern crate cross_crate_spans; + +// compile-flags:-g + + +// === GDB TESTS =================================================================================== + +// gdb-command:break cross_crate_spans.rs:21 +// gdb-command:run + +// gdb-command:print result +// gdb-check:$1 = {17, 17} +// gdb-command:print a_variable +// gdb-check:$2 = 123456789 +// gdb-command:print another_variable +// gdb-check:$3 = 123456789.5 +// gdb-command:continue + +// gdb-command:print result +// gdb-check:$4 = {1212, 1212} +// gdb-command:print a_variable +// gdb-check:$5 = 123456789 +// gdb-command:print another_variable +// gdb-check:$6 = 123456789.5 +// gdb-command:continue + + + +// === LLDB TESTS ================================================================================== + +// lldb-command:b cross_crate_spans.rs:21 +// lldb-command:run + +// lldb-command:print result +// lldb-check:[...]$0 = (17, 17) +// lldb-command:print a_variable +// lldb-check:[...]$1 = 123456789 +// lldb-command:print another_variable +// lldb-check:[...]$2 = 123456789.5 +// lldb-command:continue + +// lldb-command:print result +// lldb-check:[...]$3 = (1212, 1212) +// lldb-command:print a_variable +// lldb-check:[...]$4 = 123456789 +// lldb-command:print another_variable +// lldb-check:[...]$5 = 123456789.5 +// lldb-command:continue + + +// This test makes sure that we can break in functions inlined from other crates. + +fn main() { + + let _ = cross_crate_spans::generic_function(17u32); + let _ = cross_crate_spans::generic_function(1212i16); + +} diff --git a/src/test/debuginfo/extern-c-fn.rs b/src/test/debuginfo/extern-c-fn.rs new file mode 100644 index 00000000000..9e73417e7de --- /dev/null +++ b/src/test/debuginfo/extern-c-fn.rs @@ -0,0 +1,68 @@ +// Copyright 2013-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. + +// min-lldb-version: 310 + +// compile-flags:-g + +// === GDB TESTS =================================================================================== +// gdb-command:run + +// gdb-command:print s +// gdb-check:$1 = [...]"abcd" +// gdb-command:print len +// gdb-check:$2 = 20 +// gdb-command:print local0 +// gdb-check:$3 = 19 +// gdb-command:print local1 +// gdb-check:$4 = true +// gdb-command:print local2 +// gdb-check:$5 = 20.5 + +// gdb-command:continue + +// === LLDB TESTS ================================================================================== +// lldb-command:run + +// lldb-command:print len +// lldb-check:[...]$0 = 20 +// lldb-command:print local0 +// lldb-check:[...]$1 = 19 +// lldb-command:print local1 +// lldb-check:[...]$2 = true +// lldb-command:print local2 +// lldb-check:[...]$3 = 20.5 + +// lldb-command:continue + +#![allow(unused_variables)] +#![allow(dead_code)] +#![omit_gdb_pretty_printer_section] + + +#[no_mangle] +pub unsafe extern "C" fn fn_with_c_abi(s: *const u8, len: i32) -> i32 { + let local0 = len - 1; + let local1 = len > 2; + let local2 = (len as f64) + 0.5; + + zzz(); // #break + + return 0; +} + +fn main() { + unsafe { + fn_with_c_abi(b"abcd\0".as_ptr(), 20); + } +} + +#[inline(never)] +fn zzz() {()} diff --git a/src/test/debuginfo/recursive-struct.rs b/src/test/debuginfo/recursive-struct.rs index 3b1979337d5..25afd3514b0 100644 --- a/src/test/debuginfo/recursive-struct.rs +++ b/src/test/debuginfo/recursive-struct.rs @@ -128,10 +128,10 @@ fn main() { next: Val { val: box UniqueNode { next: Empty, - value: 1_u16, + value: 1, } }, - value: 0_u16, + value: 0, }; let unique_unique: Box<UniqueNode<u32>> = box UniqueNode { diff --git a/src/test/debuginfo/simd.rs b/src/test/debuginfo/simd.rs index 161392c94c8..12c7b146342 100644 --- a/src/test/debuginfo/simd.rs +++ b/src/test/debuginfo/simd.rs @@ -47,18 +47,18 @@ use std::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2}; fn main() { - let vi8x16 = i8x16(0i8, 1i8, 2i8, 3i8, 4i8, 5i8, 6i8, 7i8, - 8i8, 9i8, 10i8, 11i8, 12i8, 13i8, 14i8, 15i8); - - let vi16x8 = i16x8(16i16, 17i16, 18i16, 19i16, 20i16, 21i16, 22i16, 23i16); - let vi32x4 = i32x4(24i32, 25i32, 26i32, 27i32); - let vi64x2 = i64x2(28i64, 29i64); - - let vu8x16 = u8x16(30u8, 31u8, 32u8, 33u8, 34u8, 35u8, 36u8, 37u8, - 38u8, 39u8, 40u8, 41u8, 42u8, 43u8, 44u8, 45u8); - let vu16x8 = u16x8(46u16, 47u16, 48u16, 49u16, 50u16, 51u16, 52u16, 53u16); - let vu32x4 = u32x4(54u32, 55u32, 56u32, 57u32); - let vu64x2 = u64x2(58u64, 59u64); + let vi8x16 = i8x16(0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15); + + let vi16x8 = i16x8(16, 17, 18, 19, 20, 21, 22, 23); + let vi32x4 = i32x4(24, 25, 26, 27); + let vi64x2 = i64x2(28, 29); + + let vu8x16 = u8x16(30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45); + let vu16x8 = u16x8(46, 47, 48, 49, 50, 51, 52, 53); + let vu32x4 = u32x4(54, 55, 56, 57); + let vu64x2 = u64x2(58, 59); let vf32x4 = f32x4(60.5f32, 61.5f32, 62.5f32, 63.5f32); let vf64x2 = f64x2(64.5f64, 65.5f64); diff --git a/src/test/parse-fail/circular_modules_main.rs b/src/test/parse-fail/circular_modules_main.rs index ac5ec1236ff..3e548981f1e 100644 --- a/src/test/parse-fail/circular_modules_main.rs +++ b/src/test/parse-fail/circular_modules_main.rs @@ -9,10 +9,10 @@ // except according to those terms. #[path = "circular_modules_hello.rs"] -mod circular_modules_hello; //~ERROR: circular modules +mod circular_modules_hello; //~ ERROR: circular modules pub fn hi_str() -> String { - "Hi!".to_string() + "Hi!".to_string() } fn main() { diff --git a/src/test/parse-fail/class-implements-bad-trait.rs b/src/test/parse-fail/class-implements-bad-trait.rs index d709ffdc3fc..7de51c1ea75 100644 --- a/src/test/parse-fail/class-implements-bad-trait.rs +++ b/src/test/parse-fail/class-implements-bad-trait.rs @@ -15,5 +15,5 @@ class cat : nonexistent { } fn main() { - let nyan = cat(0us); + let nyan = cat(0); } diff --git a/src/test/parse-fail/issue-5544-b.rs b/src/test/parse-fail/issue-5544-b.rs index afff5984b46..9c35d77baf0 100644 --- a/src/test/parse-fail/issue-5544-b.rs +++ b/src/test/parse-fail/issue-5544-b.rs @@ -9,6 +9,6 @@ // except according to those terms. fn main() { - let __isize = 0xff_ffff_ffff_ffff_ffff__isize; + let __isize = 0xff_ffff_ffff_ffff_ffff; //~^ ERROR int literal is too large } diff --git a/src/test/parse-fail/issue-5806.rs b/src/test/parse-fail/issue-5806.rs index 597366a1b35..09de97d71b8 100644 --- a/src/test/parse-fail/issue-5806.rs +++ b/src/test/parse-fail/issue-5806.rs @@ -8,15 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Copyright 2013 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. +// ignore-windows +// ignore-freebsd +// ignore-openbsd #[path = "../compile-fail"] mod foo; //~ ERROR: a directory diff --git a/src/test/parse-fail/lex-bad-char-literals.rs b/src/test/parse-fail/lex-bad-char-literals.rs index fbe03e355ee..4aa01bcde69 100644 --- a/src/test/parse-fail/lex-bad-char-literals.rs +++ b/src/test/parse-fail/lex-bad-char-literals.rs @@ -8,36 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -static c: char = - '\u539_' //~ ERROR: illegal character in numeric character escape - //~^ WARNING: \uABCD escapes are deprecated -; - -static c2: char = - '\Uffffffff' //~ ERROR: illegal numeric character escape - //~^ WARNING: \uABCD escapes are deprecated -; - static c3: char = '\x1' //~ ERROR: numeric character escape is too short ; -static c4: char = - '\u23q' //~ ERROR: illegal character in numeric character escape - //~^ WARNING: \uABCD escapes are deprecated -; -//~^^^ ERROR: numeric character escape is too short - static s: &'static str = "\x1" //~ ERROR: numeric character escape is too short ; -static s2: &'static str = - "\u23q" //~ ERROR: illegal character in numeric character escape - //~^ ERROR: numeric character escape is too short - //~^^ WARNING: \uABCD escapes are deprecated -; - static c: char = '\●' //~ ERROR: unknown character escape ; diff --git a/src/test/parse-fail/lex-bad-numeric-literals.rs b/src/test/parse-fail/lex-bad-numeric-literals.rs index 9a490be6a01..62b87e3f480 100644 --- a/src/test/parse-fail/lex-bad-numeric-literals.rs +++ b/src/test/parse-fail/lex-bad-numeric-literals.rs @@ -22,7 +22,7 @@ fn main() { 1e+; //~ ERROR: expected at least one digit in exponent 0x539.0; //~ ERROR: hexadecimal float literal is not supported 99999999999999999999999999999999; //~ ERROR: int literal is too large - 99999999999999999999999999999999u32; //~ ERROR: int literal is too large + 99999999999999999999999999999999; //~ ERROR: int literal is too large 0x; //~ ERROR: no valid digits 0xu32; //~ ERROR: no valid digits 0ou32; //~ ERROR: no valid digits diff --git a/src/test/parse-fail/regions-trait-2.rs b/src/test/parse-fail/regions-trait-2.rs index 8b36e87db3e..7a7113cd594 100644 --- a/src/test/parse-fail/regions-trait-2.rs +++ b/src/test/parse-fail/regions-trait-2.rs @@ -26,7 +26,7 @@ impl<'a> get_ctxt for has_ctxt<'a> { } fn make_gc() -> @get_ctxt { - let ctxt = ctxt { v: 22us }; + let ctxt = ctxt { v: 22 }; let hc = has_ctxt { c: &ctxt }; return @hc as @get_ctxt; //~^ ERROR source contains reference diff --git a/src/test/pretty/block-comment-wchar.pp b/src/test/pretty/block-comment-wchar.pp index 5a55cb4e561..a5d82277d2f 100644 --- a/src/test/pretty/block-comment-wchar.pp +++ b/src/test/pretty/block-comment-wchar.pp @@ -105,10 +105,11 @@ fn f() { fn main() { // Taken from http://www.unicode.org/Public/UNIDATA/PropList.txt let chars = - ['\x0A', '\x0B', '\x0C', '\x0D', '\x20', '\u0085', '\u00A0', '\u1680', - '\u2000', '\u2001', '\u2002', '\u2003', '\u2004', '\u2005', '\u2006', - '\u2007', '\u2008', '\u2009', '\u200A', '\u2028', '\u2029', '\u202F', - '\u205F', '\u3000']; + ['\x0A', '\x0B', '\x0C', '\x0D', '\x20', '\u{85}', '\u{A0}', + '\u{1680}', '\u{2000}', '\u{2001}', '\u{2002}', '\u{2003}', + '\u{2004}', '\u{2005}', '\u{2006}', '\u{2007}', '\u{2008}', + '\u{2009}', '\u{200A}', '\u{2028}', '\u{2029}', '\u{202F}', + '\u{205F}', '\u{3000}']; for c in &chars { let ws = c.is_whitespace(); println!("{} {}" , c , ws); diff --git a/src/test/pretty/block-comment-wchar.rs b/src/test/pretty/block-comment-wchar.rs index c82bdcd8dcb..eb6d2a4a0a1 100644 --- a/src/test/pretty/block-comment-wchar.rs +++ b/src/test/pretty/block-comment-wchar.rs @@ -99,10 +99,11 @@ fn f() { fn main() { // Taken from http://www.unicode.org/Public/UNIDATA/PropList.txt let chars = - ['\x0A', '\x0B', '\x0C', '\x0D', '\x20', '\u0085', '\u00A0', '\u1680', - '\u2000', '\u2001', '\u2002', '\u2003', '\u2004', '\u2005', '\u2006', - '\u2007', '\u2008', '\u2009', '\u200A', '\u2028', '\u2029', '\u202F', - '\u205F', '\u3000']; + ['\x0A', '\x0B', '\x0C', '\x0D', '\x20', '\u{85}', '\u{A0}', + '\u{1680}', '\u{2000}', '\u{2001}', '\u{2002}', '\u{2003}', + '\u{2004}', '\u{2005}', '\u{2006}', '\u{2007}', '\u{2008}', + '\u{2009}', '\u{200A}', '\u{2028}', '\u{2029}', '\u{202F}', + '\u{205F}', '\u{3000}']; for c in &chars { let ws = c.is_whitespace(); println!("{} {}", c , ws); diff --git a/src/test/pretty/empty-lines.rs b/src/test/pretty/empty-lines.rs index 58f6ae960b1..6a9cbef1015 100644 --- a/src/test/pretty/empty-lines.rs +++ b/src/test/pretty/empty-lines.rs @@ -13,5 +13,5 @@ fn a() -> uint { - 1usize + 1 } diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp index 83ee2bd08f4..58cd19059c0 100644 --- a/src/test/pretty/issue-4264.pp +++ b/src/test/pretty/issue-4264.pp @@ -26,12 +26,12 @@ pub fn bar() { const FOO: usize = ((5 as usize) - (4 as usize) as usize); let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]); - let _: [(); (1usize as usize)] = ([(() as ())] as [(); 1]); + let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]); let _ = (((&((([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3])) as [i32; 3]) as &[i32; 3]) as *const _ as *const [i32; 3]) as - *const [i32; (3usize as usize)] as *const [i32; 3]); + *const [i32; (3 as usize)] as *const [i32; 3]); diff --git a/src/test/pretty/issue-4264.rs b/src/test/pretty/issue-4264.rs index 3aa2f4826b2..90757c92c4c 100644 --- a/src/test/pretty/issue-4264.rs +++ b/src/test/pretty/issue-4264.rs @@ -20,9 +20,9 @@ pub fn bar() { const FOO: usize = 5 - 4; let _: [(); FOO] = [()]; - let _ : [(); 1usize] = [()]; + let _ : [(); 1] = [()]; - let _ = &([1,2,3]) as *const _ as *const [i32; 3usize]; + let _ = &([1,2,3]) as *const _ as *const [i32; 3]; format!("test"); } diff --git a/src/test/run-fail/extern-panic.rs b/src/test/run-fail/extern-panic.rs index 225ce5a741b..127700e963a 100644 --- a/src/test/run-fail/extern-panic.rs +++ b/src/test/run-fail/extern-panic.rs @@ -26,10 +26,10 @@ mod rustrt { } extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { - if data == 1_usize { + if data == 1 { data } else { - count(data - 1_usize) + count(data - 1_usize) + count(data - 1) + count(data - 1) } } @@ -41,9 +41,9 @@ fn count(n: uint) -> uint { } fn main() { - for _ in 0..10_usize { + for _ in 0..10 { task::spawn(move|| { - let result = count(5_usize); + let result = count(5); println!("result = %?", result); panic!(); }); diff --git a/src/test/run-fail/if-check-panic.rs b/src/test/run-fail/if-check-panic.rs index 19a57db5ec7..e3af5b2bbf5 100644 --- a/src/test/run-fail/if-check-panic.rs +++ b/src/test/run-fail/if-check-panic.rs @@ -10,9 +10,9 @@ // error-pattern:Number is odd fn even(x: uint) -> bool { - if x < 2_usize { + if x < 2 { return false; - } else if x == 2_usize { return true; } else { return even(x - 2_usize); } + } else if x == 2 { return true; } else { return even(x - 2); } } fn foo(x: uint) { @@ -23,4 +23,4 @@ fn foo(x: uint) { } } -fn main() { foo(3_usize); } +fn main() { foo(3); } diff --git a/src/test/run-fail/overflowing-add.rs b/src/test/run-fail/overflowing-add.rs index 34a03e5f008..cd13b817c2b 100644 --- a/src/test/run-fail/overflowing-add.rs +++ b/src/test/run-fail/overflowing-add.rs @@ -9,6 +9,7 @@ // except according to those terms. // error-pattern:thread '<main>' panicked at 'arithmetic operation overflowed' +// compile-flags: -C debug-assertions // (Work around constant-evaluation) fn value() -> u8 { 200 } diff --git a/src/test/run-fail/overflowing-mul.rs b/src/test/run-fail/overflowing-mul.rs index b18d99cd232..5d2f5396240 100644 --- a/src/test/run-fail/overflowing-mul.rs +++ b/src/test/run-fail/overflowing-mul.rs @@ -9,6 +9,7 @@ // except according to those terms. // error-pattern:thread '<main>' panicked at 'arithmetic operation overflowed' +// compile-flags: -C debug-assertions // (Work around constant-evaluation) fn value() -> u8 { 200 } diff --git a/src/test/run-fail/overflowing-sub.rs b/src/test/run-fail/overflowing-sub.rs index ee32291eca6..b089dccbaa5 100644 --- a/src/test/run-fail/overflowing-sub.rs +++ b/src/test/run-fail/overflowing-sub.rs @@ -9,6 +9,7 @@ // except according to those terms. // error-pattern:thread '<main>' panicked at 'arithmetic operation overflowed' +// compile-flags: -C debug-assertions // (Work around constant-evaluation) fn value() -> u8 { 42 } diff --git a/src/test/run-fail/test-should-fail-bad-message.rs b/src/test/run-fail/test-should-fail-bad-message.rs index 5a5bb53a33a..e18c5d9631a 100644 --- a/src/test/run-fail/test-should-fail-bad-message.rs +++ b/src/test/run-fail/test-should-fail-bad-message.rs @@ -14,7 +14,7 @@ // ignore-pretty: does not work well with `--test` #[test] -#[should_fail(expected = "foobar")] +#[should_panic(expected = "foobar")] fn test_foo() { panic!("blah") } diff --git a/src/test/run-make/bare-outfile/Makefile b/src/test/run-make/bare-outfile/Makefile new file mode 100644 index 00000000000..97d09c837c1 --- /dev/null +++ b/src/test/run-make/bare-outfile/Makefile @@ -0,0 +1,4 @@ +-include ../tools.mk + +all: + $(rustc) -o foo foo.rs diff --git a/src/test/run-make/bare-outfile/foo.rs b/src/test/run-make/bare-outfile/foo.rs new file mode 100644 index 00000000000..63e747901ae --- /dev/null +++ b/src/test/run-make/bare-outfile/foo.rs @@ -0,0 +1,12 @@ +// Copyright 2015 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() { +} diff --git a/src/test/run-make/debug-assertions/Makefile b/src/test/run-make/debug-assertions/Makefile new file mode 100644 index 00000000000..71297562768 --- /dev/null +++ b/src/test/run-make/debug-assertions/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +all: + $(RUSTC) debug.rs -C debug-assertions=no + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=0 + $(call RUN,debug) bad + $(RUSTC) debug.rs -C opt-level=1 + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=2 + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=3 + $(call RUN,debug) good + $(RUSTC) debug.rs -O + $(call RUN,debug) good + $(RUSTC) debug.rs + $(call RUN,debug) bad + $(RUSTC) debug.rs -C debug-assertions=yes -O + $(call RUN,debug) bad + $(RUSTC) debug.rs -C debug-assertions=yes -C opt-level=1 + $(call RUN,debug) bad diff --git a/src/test/run-make/debug-assertions/debug.rs b/src/test/run-make/debug-assertions/debug.rs new file mode 100644 index 00000000000..a0ccc75afd0 --- /dev/null +++ b/src/test/run-make/debug-assertions/debug.rs @@ -0,0 +1,42 @@ +// Copyright 2015 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. + +#![deny(warnings)] + +use std::env; +use std::thread; + +fn main() { + let should_fail = env::args().nth(1) == Some("bad".to_string()); + + assert_eq!(thread::spawn(debug_assert_eq).join().is_err(), should_fail); + assert_eq!(thread::spawn(debug_assert).join().is_err(), should_fail); + assert_eq!(thread::spawn(overflow).join().is_err(), should_fail); +} + +fn debug_assert_eq() { + let mut hit1 = false; + let mut hit2 = false; + debug_assert_eq!({ hit1 = true; 1 }, { hit2 = true; 2 }); + assert!(!hit1); + assert!(!hit2); +} + +fn debug_assert() { + let mut hit = false; + debug_assert!({ hit = true; false }); + assert!(!hit); +} + +fn overflow() { + fn add(a: u8, b: u8) -> u8 { a + b } + + add(200u8, 200u8); +} diff --git a/src/test/run-make/graphviz-flowgraph/f20.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f20.dot-expected.dot index b4ec986ef25..21e84fb858b 100644 --- a/src/test/run-make/graphviz-flowgraph/f20.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f20.dot-expected.dot @@ -1,17 +1,17 @@ digraph block { N0[label="entry"]; N1[label="exit"]; - N2[label="expr 2usize"]; - N3[label="expr 0usize"]; - N4[label="expr 20usize"]; - N5[label="expr [2usize, 0usize, 20usize]"]; + N2[label="expr 2"]; + N3[label="expr 0"]; + N4[label="expr 20"]; + N5[label="expr [2, 0, 20]"]; N6[label="local v"]; - N7[label="stmt let v = [2usize, 0usize, 20usize];"]; + N7[label="stmt let v = [2, 0, 20];"]; N8[label="expr v"]; - N9[label="expr 20usize"]; - N10[label="expr v[20usize]"]; - N11[label="stmt v[20usize];"]; - N12[label="block { let v = [2usize, 0usize, 20usize]; v[20usize]; }"]; + N9[label="expr 20"]; + N10[label="expr v[20]"]; + N11[label="stmt v[20];"]; + N12[label="block { let v = [2, 0, 20]; v[20]; }"]; N0 -> N2; N2 -> N3; N3 -> N4; diff --git a/src/test/run-make/graphviz-flowgraph/f20.rs b/src/test/run-make/graphviz-flowgraph/f20.rs index d65de18b547..d7349932355 100644 --- a/src/test/run-make/graphviz-flowgraph/f20.rs +++ b/src/test/run-make/graphviz-flowgraph/f20.rs @@ -9,6 +9,6 @@ // except according to those terms. pub fn expr_index_20() { - let v = [2_usize, 0_usize, 20_usize]; - v[20_usize]; + let v = [2, 0, 20]; + v[20]; } diff --git a/src/test/run-make/issue-19371/foo.rs b/src/test/run-make/issue-19371/foo.rs index cff4d44910b..1ed816ed729 100644 --- a/src/test/run-make/issue-19371/foo.rs +++ b/src/test/run-make/issue-19371/foo.rs @@ -18,6 +18,8 @@ use rustc::session::config::{basic_options, build_configuration, Input, OutputTy use rustc_driver::driver::{compile_input, CompileController}; use syntax::diagnostics::registry::Registry; +use std::path::PathBuf; + fn main() { let src = r#" fn main() {} @@ -29,9 +31,9 @@ fn main() { panic!("expected rustc path"); } - let tmpdir = Path::new(&args[1]); + let tmpdir = PathBuf::new(&args[1]); - let mut sysroot = Path::new(&args[3]); + let mut sysroot = PathBuf::new(&args[3]); sysroot.pop(); sysroot.pop(); @@ -40,7 +42,7 @@ fn main() { compile(src.to_string(), tmpdir.join("out"), sysroot.clone()); } -fn basic_sess(sysroot: Path) -> Session { +fn basic_sess(sysroot: PathBuf) -> Session { let mut opts = basic_options(); opts.output_types = vec![OutputTypeExe]; opts.maybe_sysroot = Some(sysroot); @@ -51,7 +53,7 @@ fn basic_sess(sysroot: Path) -> Session { sess } -fn compile(code: String, output: Path, sysroot: Path) { +fn compile(code: String, output: PathBuf, sysroot: PathBuf) { let sess = basic_sess(sysroot); let cfg = build_configuration(&sess); let control = CompileController::basic(); diff --git a/src/test/run-make/mismatching-target-triples/bar.rs b/src/test/run-make/mismatching-target-triples/bar.rs index 8695ab58e5f..8695ab58e5f 100755..100644 --- a/src/test/run-make/mismatching-target-triples/bar.rs +++ b/src/test/run-make/mismatching-target-triples/bar.rs diff --git a/src/test/run-make/mismatching-target-triples/foo.rs b/src/test/run-make/mismatching-target-triples/foo.rs index afd4f298a97..afd4f298a97 100755..100644 --- a/src/test/run-make/mismatching-target-triples/foo.rs +++ b/src/test/run-make/mismatching-target-triples/foo.rs diff --git a/src/test/run-make/pretty-expanded-hygiene/input.pp.rs b/src/test/run-make/pretty-expanded-hygiene/input.pp.rs index 6aff4c9b3d5..6aff4c9b3d5 100755..100644 --- a/src/test/run-make/pretty-expanded-hygiene/input.pp.rs +++ b/src/test/run-make/pretty-expanded-hygiene/input.pp.rs diff --git a/src/test/run-make/pretty-expanded-hygiene/input.rs b/src/test/run-make/pretty-expanded-hygiene/input.rs index a46fa12ac05..a46fa12ac05 100755..100644 --- a/src/test/run-make/pretty-expanded-hygiene/input.rs +++ b/src/test/run-make/pretty-expanded-hygiene/input.rs diff --git a/src/test/run-make/save-analysis/foo.rs b/src/test/run-make/save-analysis/foo.rs index 7d94f4c7b17..2e2b8d2578e 100644 --- a/src/test/run-make/save-analysis/foo.rs +++ b/src/test/run-make/save-analysis/foo.rs @@ -39,17 +39,17 @@ static bob: Option<&'static [isize]> = None; // buglink test - see issue #1337. fn test_alias<I: Iterator>(i: Option<<I as Iterator>::Item>) { - let s = sub_struct{ field2: 45u32, }; + let s = sub_struct{ field2: 45, }; // import tests fn foo(x: &Float) {} let _: Option<u8> = from_i32(45); - let x = 42_usize; + let x = 42; myflate::deflate_bytes(&[]); - let x = (3, 4_usize); + let x = (3, 4); let y = x.1; } diff --git a/src/test/run-make/simd-ffi/simd.rs b/src/test/run-make/simd-ffi/simd.rs index f418d5d1fb7..f418d5d1fb7 100755..100644 --- a/src/test/run-make/simd-ffi/simd.rs +++ b/src/test/run-make/simd-ffi/simd.rs diff --git a/src/test/run-make/symbols-are-reasonable/lib.rs b/src/test/run-make/symbols-are-reasonable/lib.rs index e1f36ecda53..f81d4803f8f 100644 --- a/src/test/run-make/symbols-are-reasonable/lib.rs +++ b/src/test/run-make/symbols-are-reasonable/lib.rs @@ -16,5 +16,5 @@ impl Foo for uint {} pub fn dummy() { // force the vtable to be created - let _x = &1_usize as &Foo; + let _x = &1 as &Foo; } diff --git a/src/test/run-make/unicode-input/span_length.rs b/src/test/run-make/unicode-input/span_length.rs index ef6c799336b..a6cb9fe0324 100644 --- a/src/test/run-make/unicode-input/span_length.rs +++ b/src/test/run-make/unicode-input/span_length.rs @@ -80,7 +80,7 @@ fn main() { .arg(format!("{} {}", rustc, main_file.as_str() - .unwrap()).as_slice()) + .unwrap())) .output().unwrap(); let err = String::from_utf8_lossy(result.error.as_slice()); diff --git a/src/test/run-pass-fulldeps/compiler-calls.rs b/src/test/run-pass-fulldeps/compiler-calls.rs index 9e164522d77..75a968c3f81 100644 --- a/src/test/run-pass-fulldeps/compiler-calls.rs +++ b/src/test/run-pass-fulldeps/compiler-calls.rs @@ -25,6 +25,7 @@ use rustc::session::config::{self, Input}; use rustc_driver::{driver, CompilerCalls, Compilation}; use syntax::diagnostics; +use std::path::PathBuf; struct TestCalls { count: u32 @@ -43,14 +44,15 @@ impl<'a> CompilerCalls<'a> for TestCalls { _: &getopts::Matches, _: &Session, _: &Input, - _: &Option<Path>, - _: &Option<Path>) + _: &Option<PathBuf>, + _: &Option<PathBuf>) -> Compilation { self.count *= 3; Compilation::Stop } - fn some_input(&mut self, input: Input, input_path: Option<Path>) -> (Input, Option<Path>) { + fn some_input(&mut self, input: Input, input_path: Option<PathBuf>) + -> (Input, Option<PathBuf>) { self.count *= 5; (input, input_path) } @@ -58,10 +60,10 @@ impl<'a> CompilerCalls<'a> for TestCalls { fn no_input(&mut self, _: &getopts::Matches, _: &config::Options, - _: &Option<Path>, - _: &Option<Path>, + _: &Option<PathBuf>, + _: &Option<PathBuf>, _: &diagnostics::registry::Registry) - -> Option<(Input, Option<Path>)> { + -> Option<(Input, Option<PathBuf>)> { panic!("This shouldn't happen"); } diff --git a/src/test/run-pass-fulldeps/derive-totalsum.rs b/src/test/run-pass-fulldeps/derive-totalsum.rs new file mode 100644 index 00000000000..848b2425e44 --- /dev/null +++ b/src/test/run-pass-fulldeps/derive-totalsum.rs @@ -0,0 +1,59 @@ +// Copyright 2015 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. + +// aux-build:custom_derive_plugin.rs +// ignore-stage1 + +#![feature(plugin, custom_derive)] +#![plugin(custom_derive_plugin)] + +trait TotalSum { + fn total_sum(&self) -> isize; +} + +impl TotalSum for isize { + fn total_sum(&self) -> isize { + *self + } +} + +struct Seven; + +impl TotalSum for Seven { + fn total_sum(&self) -> isize { + 7 + } +} + +#[derive(TotalSum)] +struct Foo { + seven: Seven, + bar: Bar, + baz: isize, +} + +#[derive(TotalSum)] +struct Bar { + quux: isize, + bleh: isize, +} + + +pub fn main() { + let v = Foo { + seven: Seven, + bar: Bar { + quux: 9, + bleh: 3, + }, + baz: 80, + }; + assert_eq!(v.total_sum(), 99); +} diff --git a/src/test/run-pass-fulldeps/macro-crate.rs b/src/test/run-pass-fulldeps/macro-crate.rs index 58ccd79b712..7a2846c31b6 100644 --- a/src/test/run-pass-fulldeps/macro-crate.rs +++ b/src/test/run-pass-fulldeps/macro-crate.rs @@ -11,7 +11,7 @@ // aux-build:macro_crate_test.rs // ignore-stage1 -#![feature(plugin)] +#![feature(plugin, custom_attribute)] #![plugin(macro_crate_test)] #[macro_use] #[no_link] diff --git a/src/test/run-pass-fulldeps/mbe_matching_test_macro.rs b/src/test/run-pass-fulldeps/mbe_matching_test_macro.rs new file mode 100644 index 00000000000..5383b11cf53 --- /dev/null +++ b/src/test/run-pass-fulldeps/mbe_matching_test_macro.rs @@ -0,0 +1,25 @@ +// Copyright 2015 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. + +// aux-build:procedural_mbe_matching.rs +// ignore-stage1 + +#![feature(plugin)] +#![plugin(procedural_mbe_matching)] + +#[no_link] +extern crate procedural_mbe_matching; + +pub fn main() { + let abc = 123u32; + assert_eq!(matches!(Some(123), None | Some(0)), false); + assert_eq!(matches!(Some(123), None | Some(123)), true); + assert_eq!(matches!(true, true), true); +} diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 252d297d12d..92cb0d71e45 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -1,4 +1,4 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -74,6 +74,9 @@ fn main() { let arm = quote_arm!(cx, (ref x, ref y) => (x, y)); check_pp(ext_cx, arm, pprust::print_stmt, "(ref x, ref y) = (x, y)".to_string()); + + let attr = quote_attr!(cx, #![cfg(foo = "bar")]); + check_pp(ext_cx, attr, pprust::print_attribute, "#![cfg(foo = "bar")]".to_string()); } fn check_pp<T>(cx: fake_ext_ctxt, diff --git a/src/test/run-pass-fulldeps/quote-tokens.rs b/src/test/run-pass-fulldeps/quote-tokens.rs index e76c379177b..a9b77419b9a 100644 --- a/src/test/run-pass-fulldeps/quote-tokens.rs +++ b/src/test/run-pass-fulldeps/quote-tokens.rs @@ -40,6 +40,11 @@ fn syntax_extension(cx: &ExtCtxt) { let _k: P<syntax::ast::Method> = quote_method!(cx, #[doc = "hello"] fn foo(&self) {}); let _l: P<syntax::ast::Ty> = quote_ty!(cx, &int); + + let _m: Vec<syntax::ast::TokenTree> = quote_matcher!(cx, $($foo:tt,)* bar); + let _n: syntax::ast::Attribute = quote_attr!(cx, #![cfg(foo, bar = "baz")]); + + let _o: Option<P<syntax::ast::Item>> = quote_item!(cx, fn foo<T: ?Sized>() {}); } fn main() { diff --git a/src/test/run-pass/alias-uninit-value.rs b/src/test/run-pass/alias-uninit-value.rs index b1bebf0b3e6..45dd213d71f 100644 --- a/src/test/run-pass/alias-uninit-value.rs +++ b/src/test/run-pass/alias-uninit-value.rs @@ -17,7 +17,7 @@ enum sty { ty_nil, } struct RawT {struct_: sty, cname: Option<String>, hash: uint} fn mk_raw_ty(st: sty, cname: Option<String>) -> RawT { - return RawT {struct_: st, cname: cname, hash: 0_usize}; + return RawT {struct_: st, cname: cname, hash: 0}; } pub fn main() { mk_raw_ty(sty::ty_nil, None::<String>); } diff --git a/src/test/run-pass/associated-types-constant-type.rs b/src/test/run-pass/associated-types-constant-type.rs index 57e9230336c..299225e3a47 100644 --- a/src/test/run-pass/associated-types-constant-type.rs +++ b/src/test/run-pass/associated-types-constant-type.rs @@ -35,5 +35,5 @@ fn get(x: int) -> <int as SignedUnsigned>::Opposite { fn main() { let x = get(22); - assert_eq!(22_usize, x); + assert_eq!(22, x); } diff --git a/src/test/run-pass/associated-types-return.rs b/src/test/run-pass/associated-types-return.rs index 8ae550be3fc..e7ab910bc95 100644 --- a/src/test/run-pass/associated-types-return.rs +++ b/src/test/run-pass/associated-types-return.rs @@ -43,7 +43,7 @@ fn foo2<I: Foo>(x: I) -> <I as Foo>::A { pub fn main() { let a = 42; - assert!(foo2(a) == 42_usize); + assert!(foo2(a) == 42); let a = Bar; assert!(foo2(a) == 43); diff --git a/src/test/run-pass/associated-types-struct-field-named.rs b/src/test/run-pass/associated-types-struct-field-named.rs index 8667f6c8430..a63274beb0e 100644 --- a/src/test/run-pass/associated-types-struct-field-named.rs +++ b/src/test/run-pass/associated-types-struct-field-named.rs @@ -36,8 +36,8 @@ impl UnifyKey for u32 { pub fn main() { let node: Node<i32> = Node { key: 1, value: Some(22) }; - assert_eq!(foo(&node), Some(22_u32)); + assert_eq!(foo(&node), Some(22)); let node: Node<u32> = Node { key: 1, value: Some(22) }; - assert_eq!(foo(&node), Some(22_i32)); + assert_eq!(foo(&node), Some(22)); } diff --git a/src/test/run-pass/associated-types-struct-field-numbered.rs b/src/test/run-pass/associated-types-struct-field-numbered.rs index 9503f78a71b..3be2623185b 100644 --- a/src/test/run-pass/associated-types-struct-field-numbered.rs +++ b/src/test/run-pass/associated-types-struct-field-numbered.rs @@ -33,8 +33,8 @@ impl UnifyKey for u32 { pub fn main() { let node: Node<i32> = Node(1, Some(22)); - assert_eq!(foo(&node), Some(22_u32)); + assert_eq!(foo(&node), Some(22)); let node: Node<u32> = Node(1, Some(22)); - assert_eq!(foo(&node), Some(22_i32)); + assert_eq!(foo(&node), Some(22)); } diff --git a/src/test/run-pass/associated-types-sugar-path.rs b/src/test/run-pass/associated-types-sugar-path.rs index c068065ac6a..7e7299961d8 100644 --- a/src/test/run-pass/associated-types-sugar-path.rs +++ b/src/test/run-pass/associated-types-sugar-path.rs @@ -41,5 +41,5 @@ impl<T: Foo> C for B<T> { } pub fn main() { - let z: uint = bar(2, 4_usize); + let z: uint = bar(2, 4); } diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index 7c126fc420a..2b84adcb15c 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -131,19 +131,19 @@ enum Quark<T> { enum CLike { A, B, C } pub fn main() { - let a = &Plus(@Minus(@Val(3_usize), @Val(10_usize)), @Plus(@Val(22_usize), @Val(5_usize))); + let a = &Plus(@Minus(@Val(3), @Val(10)), @Plus(@Val(22), @Val(5))); test_rbml(a); - let a = &Spanned {lo: 0_usize, hi: 5_usize, node: 22_usize}; + let a = &Spanned {lo: 0, hi: 5, node: 22}; test_rbml(a); - let a = &Point {x: 3_usize, y: 5_usize}; + let a = &Point {x: 3, y: 5}; test_rbml(a); - let a = &Top(22_usize); + let a = &Top(22); test_rbml(a); - let a = &Bottom(222_usize); + let a = &Bottom(222); test_rbml(a); let a = &A; diff --git a/src/test/run-pass/autoderef-method-on-trait.rs b/src/test/run-pass/autoderef-method-on-trait.rs index 8121edfd2cc..6a90fa47e58 100644 --- a/src/test/run-pass/autoderef-method-on-trait.rs +++ b/src/test/run-pass/autoderef-method-on-trait.rs @@ -16,10 +16,10 @@ trait double { } impl double for uint { - fn double(self: Box<uint>) -> uint { *self * 2_usize } + fn double(self: Box<uint>) -> uint { *self * 2 } } pub fn main() { - let x: Box<_> = box() (box 3_usize as Box<double>); - assert_eq!(x.double(), 6_usize); + let x: Box<_> = box() (box 3 as Box<double>); + assert_eq!(x.double(), 6); } diff --git a/src/test/run-pass/autoderef-method-priority.rs b/src/test/run-pass/autoderef-method-priority.rs index 537894bfd15..cadce45b18d 100644 --- a/src/test/run-pass/autoderef-method-priority.rs +++ b/src/test/run-pass/autoderef-method-priority.rs @@ -20,10 +20,10 @@ impl double for uint { } impl double for Box<uint> { - fn double(self) -> uint { *self * 2_usize } + fn double(self) -> uint { *self * 2 } } pub fn main() { - let x: Box<_> = box 3_usize; - assert_eq!(x.double(), 6_usize); + let x: Box<_> = box 3; + assert_eq!(x.double(), 6); } diff --git a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs index 2ffdd576ffb..746107803c9 100644 --- a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs +++ b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs @@ -16,10 +16,10 @@ trait double { } impl double for Box<uint> { - fn double(self: Box<Box<uint>>) -> uint { **self * 2_usize } + fn double(self: Box<Box<uint>>) -> uint { **self * 2 } } pub fn main() { - let x: Box<Box<Box<Box<Box<_>>>>> = box box box box box 3_usize; - assert_eq!(x.double(), 6_usize); + let x: Box<Box<Box<Box<Box<_>>>>> = box box box box box 3; + assert_eq!(x.double(), 6); } diff --git a/src/test/run-pass/autoderef-method-twice.rs b/src/test/run-pass/autoderef-method-twice.rs index 82510aea162..51b5c98816a 100644 --- a/src/test/run-pass/autoderef-method-twice.rs +++ b/src/test/run-pass/autoderef-method-twice.rs @@ -16,10 +16,10 @@ trait double { } impl double for uint { - fn double(self: Box<uint>) -> uint { *self * 2_usize } + fn double(self: Box<uint>) -> uint { *self * 2 } } pub fn main() { - let x: Box<Box<_>> = box box 3_usize; - assert_eq!(x.double(), 6_usize); + let x: Box<Box<_>> = box box 3; + assert_eq!(x.double(), 6); } diff --git a/src/test/run-pass/autoderef-method.rs b/src/test/run-pass/autoderef-method.rs index c9aa1133101..61e704276af 100644 --- a/src/test/run-pass/autoderef-method.rs +++ b/src/test/run-pass/autoderef-method.rs @@ -16,10 +16,10 @@ trait double { } impl double for uint { - fn double(self: Box<uint>) -> uint { *self * 2_usize } + fn double(self: Box<uint>) -> uint { *self * 2 } } pub fn main() { - let x: Box<_> = box 3_usize; - assert_eq!(x.double(), 6_usize); + let x: Box<_> = box 3; + assert_eq!(x.double(), 6); } diff --git a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs index 6e6e58a7ddf..86d6a91e75b 100644 --- a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs +++ b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs @@ -29,6 +29,6 @@ impl Foo for uint { } pub fn main() { - let x: Box<_> = box 3_usize; + let x: Box<_> = box 3; assert_eq!(x.foo(), "box 3".to_string()); } diff --git a/src/test/run-pass/big-literals.rs b/src/test/run-pass/big-literals.rs index 8afb33c7669..01ac2fc20bf 100644 --- a/src/test/run-pass/big-literals.rs +++ b/src/test/run-pass/big-literals.rs @@ -9,10 +9,10 @@ // except according to those terms. pub fn main() { - assert_eq!(0xffffffffu32, (-1 as u32)); - assert_eq!(4294967295u32, (-1 as u32)); - assert_eq!(0xffffffffffffffffu64, (-1 as u64)); - assert_eq!(18446744073709551615u64, (-1 as u64)); + assert_eq!(0xffffffff, (-1 as u32)); + assert_eq!(4294967295, (-1 as u32)); + assert_eq!(0xffffffffffffffff, (-1 as u64)); + assert_eq!(18446744073709551615, (-1 as u64)); - assert_eq!(-2147483648i32 - 1i32, 2147483647i32); + assert_eq!(-2147483648 - 1, 2147483647); } diff --git a/src/test/run-pass/block-arg-call-as.rs b/src/test/run-pass/block-arg-call-as.rs index d319aaa2f8e..8be6d1bd35a 100644 --- a/src/test/run-pass/block-arg-call-as.rs +++ b/src/test/run-pass/block-arg-call-as.rs @@ -13,6 +13,6 @@ fn asBlock<F>(f: F) -> uint where F: FnOnce() -> uint { } pub fn main() { - let x = asBlock(|| 22_usize); - assert_eq!(x, 22_usize); + let x = asBlock(|| 22); + assert_eq!(x, 22); } diff --git a/src/test/run-pass/block-iter-1.rs b/src/test/run-pass/block-iter-1.rs index d5d26f42ef0..7cbe8104deb 100644 --- a/src/test/run-pass/block-iter-1.rs +++ b/src/test/run-pass/block-iter-1.rs @@ -11,8 +11,8 @@ fn iter_vec<T, F>(v: Vec<T> , mut f: F) where F: FnMut(&T) { for x in &v { f(x); } } pub fn main() { - let v = vec![1i32, 2, 3, 4, 5, 6, 7]; - let mut odds = 0i32; + let v = vec![1, 2, 3, 4, 5, 6, 7]; + let mut odds = 0; iter_vec(v, |i| { if *i % 2 == 1 { odds += 1; diff --git a/src/test/run-pass/block-iter-2.rs b/src/test/run-pass/block-iter-2.rs index 8c079ca4b07..7701f6114ca 100644 --- a/src/test/run-pass/block-iter-2.rs +++ b/src/test/run-pass/block-iter-2.rs @@ -11,7 +11,7 @@ fn iter_vec<T, F>(v: Vec<T>, mut f: F) where F: FnMut(&T) { for x in &v { f(x); } } pub fn main() { - let v = vec![1i32, 2, 3, 4, 5]; + let v = vec![1, 2, 3, 4, 5]; let mut sum = 0; iter_vec(v.clone(), |i| { iter_vec(v.clone(), |j| { diff --git a/src/test/run-pass/borrowck-closures-two-imm.rs b/src/test/run-pass/borrowck-closures-two-imm.rs index c907778339e..75161d16bc0 100644 --- a/src/test/run-pass/borrowck-closures-two-imm.rs +++ b/src/test/run-pass/borrowck-closures-two-imm.rs @@ -15,7 +15,7 @@ // the closures are in scope. Issue #6801. fn a() -> i32 { - let mut x = 3i32; + let mut x = 3; x += 1; let c1 = || x * 4; let c2 = || x * 5; @@ -27,7 +27,7 @@ fn get(x: &i32) -> i32 { } fn b() -> i32 { - let mut x = 3i32; + let mut x = 3; x += 1; let c1 = || get(&x); let c2 = || get(&x); @@ -35,7 +35,7 @@ fn b() -> i32 { } fn c() -> i32 { - let mut x = 3i32; + let mut x = 3; x += 1; let c1 = || x * 5; let c2 = || get(&x); diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index 499650a6e51..d35600ef22e 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -26,7 +26,7 @@ fn add_int(x: &mut Ints, v: int) { fn iter_ints<F>(x: &Ints, mut f: F) -> bool where F: FnMut(&int) -> bool { let l = x.values.len(); - (0_usize..l).all(|i| f(&x.values[i])) + (0..l).all(|i| f(&x.values[i])) } pub fn main() { diff --git a/src/test/run-pass/c-stack-returning-int64.rs b/src/test/run-pass/c-stack-returning-int64.rs index 6246ee9c6c4..1de7520d2b1 100644 --- a/src/test/run-pass/c-stack-returning-int64.rs +++ b/src/test/run-pass/c-stack-returning-int64.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-fast doesn't like extern crate extern crate libc; diff --git a/src/test/run-pass/capture-clauses-unboxed-closures.rs b/src/test/run-pass/capture-clauses-unboxed-closures.rs index dd417f1a9eb..19316590c26 100644 --- a/src/test/run-pass/capture-clauses-unboxed-closures.rs +++ b/src/test/run-pass/capture-clauses-unboxed-closures.rs @@ -17,8 +17,8 @@ fn each<'a,T,F:FnMut(&'a T)>(x: &'a [T], mut f: F) { } fn main() { - let mut sum = 0_usize; - let elems = [ 1_usize, 2, 3, 4, 5 ]; + let mut sum = 0; + let elems = [ 1, 2, 3, 4, 5 ]; each(&elems, |val: &uint| sum += *val); assert_eq!(sum, 15); } diff --git a/src/test/run-pass/cast.rs b/src/test/run-pass/cast.rs index f8a680b2a97..fc71e6c59fc 100644 --- a/src/test/run-pass/cast.rs +++ b/src/test/run-pass/cast.rs @@ -16,6 +16,6 @@ pub fn main() { assert_eq!(u, 'Q' as u32); assert_eq!(i as u8, 'Q' as u8); assert_eq!(i as u8 as i8, 'Q' as u8 as i8); - assert_eq!(0x51u8 as char, 'Q'); + assert_eq!(0x51 as char, 'Q'); assert_eq!(0 as u32, false as u32); } diff --git a/src/test/run-pass/cci_borrow.rs b/src/test/run-pass/cci_borrow.rs index 89babb8f722..cd8f783a2e5 100644 --- a/src/test/run-pass/cci_borrow.rs +++ b/src/test/run-pass/cci_borrow.rs @@ -17,8 +17,8 @@ extern crate cci_borrow_lib; use cci_borrow_lib::foo; pub fn main() { - let p: Box<_> = box 22_usize; + let p: Box<_> = box 22; let r = foo(&*p); println!("r={}", r); - assert_eq!(r, 22_usize); + assert_eq!(r, 22); } diff --git a/src/test/run-pass/cci_impl_exe.rs b/src/test/run-pass/cci_impl_exe.rs index c4b55b9962f..bda3b73e29c 100644 --- a/src/test/run-pass/cci_impl_exe.rs +++ b/src/test/run-pass/cci_impl_exe.rs @@ -17,7 +17,7 @@ pub fn main() { //let bt0 = sys::frame_address(); //println!("%?", bt0); - 3_usize.to(10_usize, |i| { + 3.to(10, |i| { println!("{}", i); //let bt1 = sys::frame_address(); diff --git a/src/test/run-pass/cci_iter_exe.rs b/src/test/run-pass/cci_iter_exe.rs index e4b26ba74be..5b91af7a194 100644 --- a/src/test/run-pass/cci_iter_exe.rs +++ b/src/test/run-pass/cci_iter_exe.rs @@ -13,10 +13,10 @@ extern crate cci_iter_lib; pub fn main() { - //let bt0 = sys::rusti::frame_address(1u32); + //let bt0 = sys::rusti::frame_address(1); //println!("%?", bt0); cci_iter_lib::iter(&[1, 2, 3], |i| { println!("{}", *i); - //assert!(bt0 == sys::rusti::frame_address(2u32)); + //assert!(bt0 == sys::rusti::frame_address(2)); }) } diff --git a/src/test/run-pass/cci_no_inline_exe.rs b/src/test/run-pass/cci_no_inline_exe.rs index 2040bd7ad71..cc76ed530c4 100644 --- a/src/test/run-pass/cci_no_inline_exe.rs +++ b/src/test/run-pass/cci_no_inline_exe.rs @@ -21,7 +21,7 @@ pub fn main() { // actually working. //let bt0 = sys::frame_address(); //println!("%?", bt0); - iter(vec!(1_usize, 2_usize, 3_usize), |i| { + iter(vec!(1, 2, 3), |i| { println!("{}", i); //let bt1 = sys::frame_address(); diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs index 9a388c9bc24..da51ad761c7 100644 --- a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs +++ b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs @@ -25,6 +25,6 @@ fn print_out(thing: Box<ToString>, expected: String) { } pub fn main() { - let nyan: Box<ToString> = box cat(0_usize, 2, "nyan".to_string()) as Box<ToString>; + let nyan: Box<ToString> = box cat(0, 2, "nyan".to_string()) as Box<ToString>; print_out(nyan, "nyan".to_string()); } diff --git a/src/test/run-pass/class-cast-to-trait.rs b/src/test/run-pass/class-cast-to-trait.rs index 476594c270e..01513ab6f47 100644 --- a/src/test/run-pass/class-cast-to-trait.rs +++ b/src/test/run-pass/class-cast-to-trait.rs @@ -42,8 +42,8 @@ impl cat { impl cat { fn meow(&mut self) { println!("Meow"); - self.meows += 1_usize; - if self.meows % 5_usize == 0_usize { + self.meows += 1; + if self.meows % 5 == 0 { self.how_hungry += 1; } } @@ -59,7 +59,7 @@ fn cat(in_x : uint, in_y : int, in_name: String) -> cat { pub fn main() { - let mut nyan = cat(0_usize, 2, "nyan".to_string()); + let mut nyan = cat(0, 2, "nyan".to_string()); let mut nyan: &mut noisy = &mut nyan; nyan.speak(); } diff --git a/src/test/run-pass/class-dtor.rs b/src/test/run-pass/class-dtor.rs index 14247ad7754..c98e53c8a95 100644 --- a/src/test/run-pass/class-dtor.rs +++ b/src/test/run-pass/class-dtor.rs @@ -21,7 +21,7 @@ impl Drop for cat { fn cat(done: extern fn(uint)) -> cat { cat { - meows: 0_usize, + meows: 0, done: done } } diff --git a/src/test/run-pass/class-exports.rs b/src/test/run-pass/class-exports.rs index 4c7d0e6951a..1cf4c35ee96 100644 --- a/src/test/run-pass/class-exports.rs +++ b/src/test/run-pass/class-exports.rs @@ -27,7 +27,7 @@ mod kitty { pub fn cat(in_name: String) -> cat { cat { name: in_name, - meows: 0_usize + meows: 0 } } } diff --git a/src/test/run-pass/class-method-cross-crate.rs b/src/test/run-pass/class-method-cross-crate.rs index 47cc500e44e..55acd2e040d 100644 --- a/src/test/run-pass/class-method-cross-crate.rs +++ b/src/test/run-pass/class-method-cross-crate.rs @@ -13,8 +13,8 @@ extern crate cci_class_2; use cci_class_2::kitties::cat; pub fn main() { - let nyan : cat = cat(52_usize, 99); - let kitty = cat(1000_usize, 2); + let nyan : cat = cat(52, 99); + let kitty = cat(1000, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(); diff --git a/src/test/run-pass/class-methods-cross-crate.rs b/src/test/run-pass/class-methods-cross-crate.rs index d62a726dcdd..34c309780b1 100644 --- a/src/test/run-pass/class-methods-cross-crate.rs +++ b/src/test/run-pass/class-methods-cross-crate.rs @@ -13,10 +13,10 @@ extern crate cci_class_3; use cci_class_3::kitties::cat; pub fn main() { - let mut nyan : cat = cat(52_usize, 99); - let kitty = cat(1000_usize, 2); + let mut nyan : cat = cat(52, 99); + let kitty = cat(1000, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(); - assert_eq!(nyan.meow_count(), 53_usize); + assert_eq!(nyan.meow_count(), 53); } diff --git a/src/test/run-pass/class-methods.rs b/src/test/run-pass/class-methods.rs index 18fb03ec935..8fa76342286 100644 --- a/src/test/run-pass/class-methods.rs +++ b/src/test/run-pass/class-methods.rs @@ -15,7 +15,7 @@ struct cat { } impl cat { - pub fn speak(&mut self) { self.meows += 1_usize; } + pub fn speak(&mut self) { self.meows += 1; } pub fn meow_count(&mut self) -> uint { self.meows } } @@ -27,10 +27,10 @@ fn cat(in_x: uint, in_y: int) -> cat { } pub fn main() { - let mut nyan: cat = cat(52_usize, 99); - let kitty = cat(1000_usize, 2); + let mut nyan: cat = cat(52, 99); + let kitty = cat(1000, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(); - assert_eq!(nyan.meow_count(), 53_usize); + assert_eq!(nyan.meow_count(), 53); } diff --git a/src/test/run-pass/class-poly-methods.rs b/src/test/run-pass/class-poly-methods.rs index b529b0a0772..557f9986238 100644 --- a/src/test/run-pass/class-poly-methods.rs +++ b/src/test/run-pass/class-poly-methods.rs @@ -32,12 +32,12 @@ fn cat<U>(in_x : uint, in_y : int, in_info: Vec<U> ) -> cat<U> { } pub fn main() { - let mut nyan : cat<int> = cat::<int>(52_usize, 99, vec!(9)); - let mut kitty = cat(1000_usize, 2, vec!("tabby".to_string())); + let mut nyan : cat<int> = cat::<int>(52, 99, vec!(9)); + let mut kitty = cat(1000, 2, vec!("tabby".to_string())); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(vec!(1,2,3)); - assert_eq!(nyan.meow_count(), 55_usize); + assert_eq!(nyan.meow_count(), 55); kitty.speak(vec!("meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string())); - assert_eq!(kitty.meow_count(), 1004_usize); + assert_eq!(kitty.meow_count(), 1004); } diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index daff321efcf..2bdc053675f 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -39,8 +39,8 @@ impl cat { impl cat { fn meow(&mut self) { println!("Meow"); - self.meows += 1_usize; - if self.meows % 5_usize == 0_usize { + self.meows += 1; + if self.meows % 5 == 0 { self.how_hungry += 1; } } @@ -67,6 +67,6 @@ fn print_out(thing: Box<ToString>, expected: String) { } pub fn main() { - let nyan: Box<ToString> = box cat(0_usize, 2, "nyan".to_string()) as Box<ToString>; + let nyan: Box<ToString> = box cat(0, 2, "nyan".to_string()) as Box<ToString>; print_out(nyan, "nyan".to_string()); } diff --git a/src/test/run-pass/class-typarams.rs b/src/test/run-pass/class-typarams.rs index b56a749d33b..c50a8cc83a5 100644 --- a/src/test/run-pass/class-typarams.rs +++ b/src/test/run-pass/class-typarams.rs @@ -17,7 +17,7 @@ struct cat<U> { } impl<U> cat<U> { - pub fn speak(&mut self) { self.meows += 1_usize; } + pub fn speak(&mut self) { self.meows += 1; } pub fn meow_count(&mut self) -> uint { self.meows } } @@ -31,6 +31,6 @@ fn cat<U>(in_x : uint, in_y : int) -> cat<U> { pub fn main() { - let _nyan : cat<int> = cat::<int>(52_usize, 99); - // let mut kitty = cat(1000_usize, 2); + let _nyan : cat<int> = cat::<int>(52, 99); + // let mut kitty = cat(1000, 2); } diff --git a/src/test/run-pass/classes-simple-cross-crate.rs b/src/test/run-pass/classes-simple-cross-crate.rs index 8037d77807d..09660454648 100644 --- a/src/test/run-pass/classes-simple-cross-crate.rs +++ b/src/test/run-pass/classes-simple-cross-crate.rs @@ -13,8 +13,8 @@ extern crate cci_class; use cci_class::kitties::cat; pub fn main() { - let nyan : cat = cat(52_usize, 99); - let kitty = cat(1000_usize, 2); + let nyan : cat = cat(52, 99); + let kitty = cat(1000, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); } diff --git a/src/test/run-pass/classes-simple-method.rs b/src/test/run-pass/classes-simple-method.rs index b15d6544fed..502fa73ed93 100644 --- a/src/test/run-pass/classes-simple-method.rs +++ b/src/test/run-pass/classes-simple-method.rs @@ -26,8 +26,8 @@ fn cat(in_x : uint, in_y : int) -> cat { } pub fn main() { - let mut nyan : cat = cat(52_usize, 99); - let kitty = cat(1000_usize, 2); + let mut nyan : cat = cat(52, 99); + let kitty = cat(1000, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(); diff --git a/src/test/run-pass/classes-simple.rs b/src/test/run-pass/classes-simple.rs index 9bf8df3ce4b..3cf529f2958 100644 --- a/src/test/run-pass/classes-simple.rs +++ b/src/test/run-pass/classes-simple.rs @@ -22,8 +22,8 @@ fn cat(in_x : uint, in_y : int) -> cat { } pub fn main() { - let nyan : cat = cat(52_usize, 99); - let kitty = cat(1000_usize, 2); + let nyan : cat = cat(52, 99); + let kitty = cat(1000, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); } diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs index ade18a71259..32230c82a72 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs @@ -18,7 +18,7 @@ fn bip(v: &[uint]) -> Vec<uint> { } pub fn main() { - let mut the_vec = vec!(1_usize, 2, 3, 100); + let mut the_vec = vec!(1, 2, 3, 100); assert_eq!(the_vec.clone(), bar(&mut the_vec)); assert_eq!(the_vec.clone(), bip(&the_vec)); } diff --git a/src/test/run-pass/concat.rs b/src/test/run-pass/concat.rs index b0c3a5922b6..2de881993f1 100644 --- a/src/test/run-pass/concat.rs +++ b/src/test/run-pass/concat.rs @@ -15,12 +15,12 @@ pub fn main() { assert_eq!(concat!("qux", "quux",).to_string(), "quxquux".to_string()); assert_eq!( - concat!(1, 2, 3_usize, 4f32, 4.0, 'a', true), + concat!(1, 2, 3, 4f32, 4.0, 'a', true), "12344.0atrue" ); assert!(match "12344.0atrue" { - concat!(1, 2, 3_usize, 4f32, 4.0, 'a', true) => true, + concat!(1, 2, 3, 4f32, 4.0, 'a', true) => true, _ => false }) } diff --git a/src/test/run-pass/conditional-debug-macro-off.rs b/src/test/run-pass/conditional-debug-macro-off.rs index b5a5f57d07a..90142350772 100644 --- a/src/test/run-pass/conditional-debug-macro-off.rs +++ b/src/test/run-pass/conditional-debug-macro-off.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags: --cfg ndebug +// compile-flags: -C debug-assertions=no // exec-env:RUST_LOG=conditional-debug-macro-off=4 #[macro_use] diff --git a/src/test/run-pass/const-block.rs b/src/test/run-pass/const-block.rs index cdb96e5dcbf..bdde0cf02c9 100644 --- a/src/test/run-pass/const-block.rs +++ b/src/test/run-pass/const-block.rs @@ -58,6 +58,6 @@ pub fn main() { assert_eq!(BLOCK_FN(300), 300); assert_eq!(BLOCK_ENUM_CONSTRUCTOR(200), Some(200)); // FIXME #13972 - // assert_eq!(BLOCK_UNSAFE_SAFE_PTR as *const isize as usize, 0xdeadbeef_us); - // assert_eq!(BLOCK_UNSAFE_SAFE_PTR_2 as *const isize as usize, 0xdeadbeef_us); + // assert_eq!(BLOCK_UNSAFE_SAFE_PTR as *const isize as usize, 0xdeadbeef); + // assert_eq!(BLOCK_UNSAFE_SAFE_PTR_2 as *const isize as usize, 0xdeadbeef); } diff --git a/src/test/run-pass/const-bound.rs b/src/test/run-pass/const-bound.rs index 3a64f53dbb0..9b0e7e4e75e 100644 --- a/src/test/run-pass/const-bound.rs +++ b/src/test/run-pass/const-bound.rs @@ -20,7 +20,7 @@ pub fn main() { foo("hi".to_string()); foo(~[1, 2, 3]); foo(F{field: 42}); - foo((1, 2_usize)); + foo((1, 2)); foo(@1);*/ foo(Box::new(1)); } diff --git a/src/test/run-pass/deprecated-derive.rs b/src/test/run-pass/deprecated-derive.rs new file mode 100644 index 00000000000..494d62c7737 --- /dev/null +++ b/src/test/run-pass/deprecated-derive.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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. + +#[derive(Show)] +//~^ WARNING derive(Show) is deprecated +struct Test1; + +fn main() { } diff --git a/src/test/run-pass/double-ref.rs b/src/test/run-pass/double-ref.rs index 8018f681f38..0cb48670f23 100644 --- a/src/test/run-pass/double-ref.rs +++ b/src/test/run-pass/double-ref.rs @@ -9,23 +9,23 @@ // except according to those terms. fn check_expr() { - let _: & uint = &1_usize; - let _: & & uint = &&1_usize; - let _: & & & uint = &&&1_usize; - let _: & & & uint = & &&1_usize; - let _: & & & & uint = &&&&1_usize; - let _: & & & & uint = & &&&1_usize; - let _: & & & & & uint = &&&&&1_usize; + let _: & uint = &1; + let _: & & uint = &&1; + let _: & & & uint = &&&1; + let _: & & & uint = & &&1; + let _: & & & & uint = &&&&1; + let _: & & & & uint = & &&&1; + let _: & & & & & uint = &&&&&1; } fn check_ty() { - let _: &uint = & 1_usize; - let _: &&uint = & & 1_usize; - let _: &&&uint = & & & 1_usize; - let _: & &&uint = & & & 1_usize; - let _: &&&&uint = & & & & 1_usize; - let _: & &&&uint = & & & & 1_usize; - let _: &&&&&uint = & & & & & 1_usize; + let _: &uint = & 1; + let _: &&uint = & & 1; + let _: &&&uint = & & & 1; + let _: & &&uint = & & & 1; + let _: &&&&uint = & & & & 1; + let _: & &&&uint = & & & & 1; + let _: &&&&&uint = & & & & & 1; } fn check_pat() { diff --git a/src/test/run-pass/drop-trait-enum.rs b/src/test/run-pass/drop-trait-enum.rs index f94da9fc747..353bd7a9ce0 100644 --- a/src/test/run-pass/drop-trait-enum.rs +++ b/src/test/run-pass/drop-trait-enum.rs @@ -62,7 +62,7 @@ pub fn main() { let (sender, receiver) = channel(); { - let v = Foo::NestedVariant(box 42_usize, SendOnDrop { sender: sender.clone() }, sender); + let v = Foo::NestedVariant(box 42, SendOnDrop { sender: sender.clone() }, sender); } assert_eq!(receiver.recv().unwrap(), Message::DestructorRan); assert_eq!(receiver.recv().unwrap(), Message::Dropped); @@ -79,10 +79,10 @@ pub fn main() { let (sender, receiver) = channel(); let t = { thread::spawn(move|| { - let mut v = Foo::NestedVariant(box 42usize, SendOnDrop { + let mut v = Foo::NestedVariant(box 42, SendOnDrop { sender: sender.clone() }, sender.clone()); - v = Foo::NestedVariant(box 42_usize, + v = Foo::NestedVariant(box 42, SendOnDrop { sender: sender.clone() }, sender.clone()); v = Foo::SimpleVariant(sender.clone()); diff --git a/src/test/run-pass/extern-pass-char.rs b/src/test/run-pass/extern-pass-char.rs index 49c3bf62dbc..2e86b3774c8 100644 --- a/src/test/run-pass/extern-pass-char.rs +++ b/src/test/run-pass/extern-pass-char.rs @@ -17,6 +17,6 @@ extern { pub fn main() { unsafe { - assert_eq!(22_u8, rust_dbg_extern_identity_u8(22_u8)); + assert_eq!(22, rust_dbg_extern_identity_u8(22)); } } diff --git a/src/test/run-pass/extern-pass-u32.rs b/src/test/run-pass/extern-pass-u32.rs index 07c04af8e1b..2c018084407 100644 --- a/src/test/run-pass/extern-pass-u32.rs +++ b/src/test/run-pass/extern-pass-u32.rs @@ -17,6 +17,6 @@ extern { pub fn main() { unsafe { - assert_eq!(22_u32, rust_dbg_extern_identity_u32(22_u32)); + assert_eq!(22, rust_dbg_extern_identity_u32(22)); } } diff --git a/src/test/run-pass/extern-pass-u64.rs b/src/test/run-pass/extern-pass-u64.rs index e19c73ebe20..e72e87d3d93 100644 --- a/src/test/run-pass/extern-pass-u64.rs +++ b/src/test/run-pass/extern-pass-u64.rs @@ -17,6 +17,6 @@ extern { pub fn main() { unsafe { - assert_eq!(22_u64, rust_dbg_extern_identity_u64(22_u64)); + assert_eq!(22, rust_dbg_extern_identity_u64(22)); } } diff --git a/src/test/run-pass/extern-stress.rs b/src/test/run-pass/extern-stress.rs deleted file mode 100644 index b9e08e47b37..00000000000 --- a/src/test/run-pass/extern-stress.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2012 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. - -// This creates a bunch of descheduling tasks that run concurrently -// while holding onto C stacks - -extern crate libc; -use std::thread::Thread; - -mod rustrt { - extern crate libc; - - #[link(name = "rust_test_helpers")] - extern { - pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, - data: libc::uintptr_t) - -> libc::uintptr_t; - } -} - -extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { - if data == 1 { - data - } else { - Thread::yield_now(); - count(data - 1) + count(data - 1) - } -} - -fn count(n: libc::uintptr_t) -> libc::uintptr_t { - unsafe { - rustrt::rust_dbg_call(cb, n) - } -} - -pub fn main() { - (0_usize..100).map(|_| { - Thread::scoped(move|| { - assert_eq!(count(5), 16); - }) - }).collect::<Vec<_>>(); -} diff --git a/src/test/run-pass/extern-yield.rs b/src/test/run-pass/extern-yield.rs deleted file mode 100644 index 80428d787f2..00000000000 --- a/src/test/run-pass/extern-yield.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2012 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. - -extern crate libc; -use std::thread::Thread; - -mod rustrt { - extern crate libc; - - #[link(name = "rust_test_helpers")] - extern { - pub fn rust_dbg_call(cb: extern "C" fn (libc::uintptr_t) -> libc::uintptr_t, - data: libc::uintptr_t) - -> libc::uintptr_t; - } -} - -extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { - if data == 1 { - data - } else { - count(data - 1) + count(data - 1) - } -} - -fn count(n: libc::uintptr_t) -> libc::uintptr_t { - unsafe { - Thread::yield_now(); - rustrt::rust_dbg_call(cb, n) - } -} - -pub fn main() { - (0..10_usize).map(|i| { - Thread::scoped(move|| { - let result = count(5); - println!("result = {}", result); - assert_eq!(result, 16); - }) - }).collect::<Vec<_>>(); -} diff --git a/src/test/run-pass/foreign-fn-linkname.rs b/src/test/run-pass/foreign-fn-linkname.rs index 24b711328a1..172ece0c4bf 100644 --- a/src/test/run-pass/foreign-fn-linkname.rs +++ b/src/test/run-pass/foreign-fn-linkname.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-fast doesn't like extern crate extern crate libc; use std::ffi::CString; @@ -32,5 +31,5 @@ fn strlen(str: String) -> uint { pub fn main() { let len = strlen("Rust".to_string()); - assert_eq!(len, 4_usize); + assert_eq!(len, 4); } diff --git a/src/test/run-pass/foreign-mod-unused-const.rs b/src/test/run-pass/foreign-mod-unused-const.rs index e1ed0b8ea3b..03023f03233 100644 --- a/src/test/run-pass/foreign-mod-unused-const.rs +++ b/src/test/run-pass/foreign-mod-unused-const.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-fast doesn't like extern crate extern crate libc; diff --git a/src/test/run-pass/foreign2.rs b/src/test/run-pass/foreign2.rs index ce2f8955664..5ebc4effb37 100644 --- a/src/test/run-pass/foreign2.rs +++ b/src/test/run-pass/foreign2.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-fast doesn't like extern crate extern crate libc; diff --git a/src/test/run-pass/i32-sub.rs b/src/test/run-pass/i32-sub.rs index e5451431ade..cebfd89d8aa 100644 --- a/src/test/run-pass/i32-sub.rs +++ b/src/test/run-pass/i32-sub.rs @@ -11,4 +11,4 @@ -pub fn main() { let mut x: i32 = -400_i32; x = 0_i32 - x; assert!((x == 400_i32)); } +pub fn main() { let mut x: i32 = -400; x = 0 - x; assert!((x == 400)); } diff --git a/src/test/run-pass/i8-incr.rs b/src/test/run-pass/i8-incr.rs index fbb4e446dd5..c91e738b822 100644 --- a/src/test/run-pass/i8-incr.rs +++ b/src/test/run-pass/i8-incr.rs @@ -12,9 +12,9 @@ pub fn main() { - let mut x: i8 = -12i8; - let y: i8 = -12i8; - x = x + 1i8; - x = x - 1i8; + let mut x: i8 = -12; + let y: i8 = -12; + x = x + 1; + x = x - 1; assert_eq!(x, y); } diff --git a/src/test/run-pass/if-check.rs b/src/test/run-pass/if-check.rs index d2a1a3c71a5..766cced4c26 100644 --- a/src/test/run-pass/if-check.rs +++ b/src/test/run-pass/if-check.rs @@ -9,9 +9,9 @@ // except according to those terms. fn even(x: uint) -> bool { - if x < 2_usize { + if x < 2 { return false; - } else if x == 2_usize { return true; } else { return even(x - 2_usize); } + } else if x == 2 { return true; } else { return even(x - 2); } } fn foo(x: uint) { @@ -22,4 +22,4 @@ fn foo(x: uint) { } } -pub fn main() { foo(2_usize); } +pub fn main() { foo(2); } diff --git a/src/test/run-pass/intrinsic-alignment.rs b/src/test/run-pass/intrinsic-alignment.rs index 4b0e9168e19..d111462ed5a 100644 --- a/src/test/run-pass/intrinsic-alignment.rs +++ b/src/test/run-pass/intrinsic-alignment.rs @@ -27,8 +27,8 @@ mod m { #[cfg(target_arch = "x86")] pub fn main() { unsafe { - assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize); - assert_eq!(::rusti::min_align_of::<u64>(), 4_usize); + assert_eq!(::rusti::pref_align_of::<u64>(), 8); + assert_eq!(::rusti::min_align_of::<u64>(), 4); } } @@ -36,8 +36,8 @@ mod m { #[cfg(any(target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64"))] pub fn main() { unsafe { - assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize); - assert_eq!(::rusti::min_align_of::<u64>(), 8_usize); + assert_eq!(::rusti::pref_align_of::<u64>(), 8); + assert_eq!(::rusti::min_align_of::<u64>(), 8); } } } @@ -48,8 +48,8 @@ mod m { #[cfg(target_arch = "x86_64")] pub fn main() { unsafe { - assert_eq!(::rusti::pref_align_of::<u64>(), 8u); - assert_eq!(::rusti::min_align_of::<u64>(), 8u); + assert_eq!(::rusti::pref_align_of::<u64>(), 8); + assert_eq!(::rusti::min_align_of::<u64>(), 8); } } } @@ -60,8 +60,8 @@ mod m { #[cfg(target_arch = "x86")] pub fn main() { unsafe { - assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize); - assert_eq!(::rusti::min_align_of::<u64>(), 8_usize); + assert_eq!(::rusti::pref_align_of::<u64>(), 8); + assert_eq!(::rusti::min_align_of::<u64>(), 8); } } @@ -69,8 +69,8 @@ mod m { #[cfg(target_arch = "x86_64")] pub fn main() { unsafe { - assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize); - assert_eq!(::rusti::min_align_of::<u64>(), 8_usize); + assert_eq!(::rusti::pref_align_of::<u64>(), 8); + assert_eq!(::rusti::min_align_of::<u64>(), 8); } } } @@ -81,8 +81,8 @@ mod m { #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] pub fn main() { unsafe { - assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize); - assert_eq!(::rusti::min_align_of::<u64>(), 8_usize); + assert_eq!(::rusti::pref_align_of::<u64>(), 8); + assert_eq!(::rusti::min_align_of::<u64>(), 8); } } } diff --git a/src/test/run-pass/intrinsics-integer.rs b/src/test/run-pass/intrinsics-integer.rs index 2b0f7cc7d7d..e5724c1e0dc 100644 --- a/src/test/run-pass/intrinsics-integer.rs +++ b/src/test/run-pass/intrinsics-integer.rs @@ -37,83 +37,83 @@ pub fn main() { unsafe { use rusti::*; - assert_eq!(ctpop8(0u8), 0u8); - assert_eq!(ctpop16(0u16), 0u16); - assert_eq!(ctpop32(0u32), 0u32); - assert_eq!(ctpop64(0u64), 0u64); - - assert_eq!(ctpop8(1u8), 1u8); - assert_eq!(ctpop16(1u16), 1u16); - assert_eq!(ctpop32(1u32), 1u32); - assert_eq!(ctpop64(1u64), 1u64); - - assert_eq!(ctpop8(10u8), 2u8); - assert_eq!(ctpop16(10u16), 2u16); - assert_eq!(ctpop32(10u32), 2u32); - assert_eq!(ctpop64(10u64), 2u64); - - assert_eq!(ctpop8(100u8), 3u8); - assert_eq!(ctpop16(100u16), 3u16); - assert_eq!(ctpop32(100u32), 3u32); - assert_eq!(ctpop64(100u64), 3u64); - - assert_eq!(ctpop8(-1u8), 8u8); - assert_eq!(ctpop16(-1u16), 16u16); - assert_eq!(ctpop32(-1u32), 32u32); - assert_eq!(ctpop64(-1u64), 64u64); - - assert_eq!(ctlz8(0u8), 8u8); - assert_eq!(ctlz16(0u16), 16u16); - assert_eq!(ctlz32(0u32), 32u32); - assert_eq!(ctlz64(0u64), 64u64); - - assert_eq!(ctlz8(1u8), 7u8); - assert_eq!(ctlz16(1u16), 15u16); - assert_eq!(ctlz32(1u32), 31u32); - assert_eq!(ctlz64(1u64), 63u64); - - assert_eq!(ctlz8(10u8), 4u8); - assert_eq!(ctlz16(10u16), 12u16); - assert_eq!(ctlz32(10u32), 28u32); - assert_eq!(ctlz64(10u64), 60u64); - - assert_eq!(ctlz8(100u8), 1u8); - assert_eq!(ctlz16(100u16), 9u16); - assert_eq!(ctlz32(100u32), 25u32); - assert_eq!(ctlz64(100u64), 57u64); - - assert_eq!(cttz8(-1u8), 0u8); - assert_eq!(cttz16(-1u16), 0u16); - assert_eq!(cttz32(-1u32), 0u32); - assert_eq!(cttz64(-1u64), 0u64); - - assert_eq!(cttz8(0u8), 8u8); - assert_eq!(cttz16(0u16), 16u16); - assert_eq!(cttz32(0u32), 32u32); - assert_eq!(cttz64(0u64), 64u64); - - assert_eq!(cttz8(1u8), 0u8); - assert_eq!(cttz16(1u16), 0u16); - assert_eq!(cttz32(1u32), 0u32); - assert_eq!(cttz64(1u64), 0u64); - - assert_eq!(cttz8(10u8), 1u8); - assert_eq!(cttz16(10u16), 1u16); - assert_eq!(cttz32(10u32), 1u32); - assert_eq!(cttz64(10u64), 1u64); - - assert_eq!(cttz8(100u8), 2u8); - assert_eq!(cttz16(100u16), 2u16); - assert_eq!(cttz32(100u32), 2u32); - assert_eq!(cttz64(100u64), 2u64); - - assert_eq!(cttz8(-1u8), 0u8); - assert_eq!(cttz16(-1u16), 0u16); - assert_eq!(cttz32(-1u32), 0u32); - assert_eq!(cttz64(-1u64), 0u64); - - assert_eq!(bswap16(0x0A0Bu16), 0x0B0Au16); - assert_eq!(bswap32(0x0ABBCC0Du32), 0x0DCCBB0Au32); - assert_eq!(bswap64(0x0122334455667708u64), 0x0877665544332201u64); + assert_eq!(ctpop8(0), 0); + assert_eq!(ctpop16(0), 0); + assert_eq!(ctpop32(0), 0); + assert_eq!(ctpop64(0), 0); + + assert_eq!(ctpop8(1), 1); + assert_eq!(ctpop16(1), 1); + assert_eq!(ctpop32(1), 1); + assert_eq!(ctpop64(1), 1); + + assert_eq!(ctpop8(10), 2); + assert_eq!(ctpop16(10), 2); + assert_eq!(ctpop32(10), 2); + assert_eq!(ctpop64(10), 2); + + assert_eq!(ctpop8(100), 3); + assert_eq!(ctpop16(100), 3); + assert_eq!(ctpop32(100), 3); + assert_eq!(ctpop64(100), 3); + + assert_eq!(ctpop8(-1), 8); + assert_eq!(ctpop16(-1), 16); + assert_eq!(ctpop32(-1), 32); + assert_eq!(ctpop64(-1), 64); + + assert_eq!(ctlz8(0), 8); + assert_eq!(ctlz16(0), 16); + assert_eq!(ctlz32(0), 32); + assert_eq!(ctlz64(0), 64); + + assert_eq!(ctlz8(1), 7); + assert_eq!(ctlz16(1), 15); + assert_eq!(ctlz32(1), 31); + assert_eq!(ctlz64(1), 63); + + assert_eq!(ctlz8(10), 4); + assert_eq!(ctlz16(10), 12); + assert_eq!(ctlz32(10), 28); + assert_eq!(ctlz64(10), 60); + + assert_eq!(ctlz8(100), 1); + assert_eq!(ctlz16(100), 9); + assert_eq!(ctlz32(100), 25); + assert_eq!(ctlz64(100), 57); + + assert_eq!(cttz8(-1), 0); + assert_eq!(cttz16(-1), 0); + assert_eq!(cttz32(-1), 0); + assert_eq!(cttz64(-1), 0); + + assert_eq!(cttz8(0), 8); + assert_eq!(cttz16(0), 16); + assert_eq!(cttz32(0), 32); + assert_eq!(cttz64(0), 64); + + assert_eq!(cttz8(1), 0); + assert_eq!(cttz16(1), 0); + assert_eq!(cttz32(1), 0); + assert_eq!(cttz64(1), 0); + + assert_eq!(cttz8(10), 1); + assert_eq!(cttz16(10), 1); + assert_eq!(cttz32(10), 1); + assert_eq!(cttz64(10), 1); + + assert_eq!(cttz8(100), 2); + assert_eq!(cttz16(100), 2); + assert_eq!(cttz32(100), 2); + assert_eq!(cttz64(100), 2); + + assert_eq!(cttz8(-1), 0); + assert_eq!(cttz16(-1), 0); + assert_eq!(cttz32(-1), 0); + assert_eq!(cttz64(-1), 0); + + assert_eq!(bswap16(0x0A0B), 0x0B0A); + assert_eq!(bswap32(0x0ABBCC0D), 0x0DCCBB0A); + assert_eq!(bswap64(0x0122334455667708), 0x0877665544332201); } } diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs index ed88b3c65e0..ab65f35dd34 100644 --- a/src/test/run-pass/intrinsics-math.rs +++ b/src/test/run-pass/intrinsics-math.rs @@ -65,8 +65,8 @@ pub fn main() { assert_approx_eq!(sqrtf32(64f32), 8f32); assert_approx_eq!(sqrtf64(64f64), 8f64); - assert_approx_eq!(powif32(25f32, -2i32), 0.0016f32); - assert_approx_eq!(powif64(23.2f64, 2i32), 538.24f64); + assert_approx_eq!(powif32(25f32, -2), 0.0016f32); + assert_approx_eq!(powif64(23.2f64, 2), 538.24f64); assert_approx_eq!(sinf32(0f32), 0f32); assert_approx_eq!(sinf64(f64::consts::PI / 2f64), 1f64); diff --git a/src/test/run-pass/issue-1112.rs b/src/test/run-pass/issue-1112.rs index 22c88c874f0..2ade0df7f6b 100644 --- a/src/test/run-pass/issue-1112.rs +++ b/src/test/run-pass/issue-1112.rs @@ -24,21 +24,21 @@ struct X<T> { pub fn main() { let x: X<int> = X { a: 12345678, - b: 9u8, + b: 9, c: true, - d: 10u8, - e: 11u16, - f: 12u8, - g: 13u8 + d: 10, + e: 11, + f: 12, + g: 13 }; bar(x); } fn bar<T>(x: X<T>) { - assert_eq!(x.b, 9u8); + assert_eq!(x.b, 9); assert_eq!(x.c, true); - assert_eq!(x.d, 10u8); - assert_eq!(x.e, 11u16); - assert_eq!(x.f, 12u8); - assert_eq!(x.g, 13u8); + assert_eq!(x.d, 10); + assert_eq!(x.e, 11); + assert_eq!(x.f, 12); + assert_eq!(x.g, 13); } diff --git a/src/test/run-pass/issue-11736.rs b/src/test/run-pass/issue-11736.rs index b901e95ff55..b09d516dd35 100644 --- a/src/test/run-pass/issue-11736.rs +++ b/src/test/run-pass/issue-11736.rs @@ -15,7 +15,7 @@ use std::num::Float; fn main() { // Generate sieve of Eratosthenes for n up to 1e6 - let n = 1000000_usize; + let n = 1000000; let mut sieve = BitVec::from_elem(n+1, true); let limit: uint = (n as f32).sqrt() as uint; for i in 2..limit+1 { diff --git a/src/test/run-pass/issue-11958.rs b/src/test/run-pass/issue-11958.rs index 00613f35f17..bb34dae77b3 100644 --- a/src/test/run-pass/issue-11958.rs +++ b/src/test/run-pass/issue-11958.rs @@ -19,6 +19,6 @@ use std::thunk::Thunk; pub fn main() { - let mut x = 1i32; + let mut x = 1; let _thunk = Thunk::new(move|| { x = 2; }); } diff --git a/src/test/run-pass/issue-12909.rs b/src/test/run-pass/issue-12909.rs index b7dc98b92e0..11a2e52cf97 100644 --- a/src/test/run-pass/issue-12909.rs +++ b/src/test/run-pass/issue-12909.rs @@ -15,7 +15,7 @@ fn copy<T: Copy>(&x: &T) -> T { } fn main() { - let arr = [(1, 1_usize), (2, 2), (3, 3)]; + let arr = [(1, 1), (2, 2), (3, 3)]; let v1: Vec<&_> = arr.iter().collect(); let v2: Vec<_> = arr.iter().map(copy).collect(); diff --git a/src/test/run-pass/issue-15571.rs b/src/test/run-pass/issue-15571.rs index 5b093d16cbf..3dc76f4a089 100644 --- a/src/test/run-pass/issue-15571.rs +++ b/src/test/run-pass/issue-15571.rs @@ -47,7 +47,7 @@ fn match_on_binding() { } fn match_on_upvar() { - let mut foo: Option<Box<_>> = Some(box 8i32); + let mut foo: Option<Box<_>> = Some(box 8); let f = move|| { match foo { None => {}, diff --git a/src/test/run-pass/issue-15673.rs b/src/test/run-pass/issue-15673.rs index a6b8a04eeb6..227d8f7b8c8 100644 --- a/src/test/run-pass/issue-15673.rs +++ b/src/test/run-pass/issue-15673.rs @@ -11,5 +11,5 @@ use std::iter::AdditiveIterator; fn main() { let x: [u64; 3] = [1, 2, 3]; - assert_eq!(6, (0_usize..3).map(|i| x[i]).sum()); + assert_eq!(6, (0..3).map(|i| x[i]).sum()); } diff --git a/src/test/run-pass/issue-15734.rs b/src/test/run-pass/issue-15734.rs index e66ac8ff53c..18e4190ee45 100644 --- a/src/test/run-pass/issue-15734.rs +++ b/src/test/run-pass/issue-15734.rs @@ -53,12 +53,12 @@ impl<T, M: Index<(uint, uint), Output=T>> Index<uint> for Row<M> { } fn main() { - let m = Mat::new(vec!(1_usize, 2, 3, 4, 5, 6), 3); + let m = Mat::new(vec!(1, 2, 3, 4, 5, 6), 3); let r = m.row(1); assert!(r.index(&2) == &6); assert!(r[2] == 6); - assert!(r[2_usize] == 6_usize); + assert!(r[2] == 6); assert!(6 == r[2]); let e = r[2]; diff --git a/src/test/run-pass/issue-17662.rs b/src/test/run-pass/issue-17662.rs index 7bd41cc5b52..dbfa91553e6 100644 --- a/src/test/run-pass/issue-17662.rs +++ b/src/test/run-pass/issue-17662.rs @@ -17,7 +17,7 @@ use std::marker; struct Bar<'a> { m: marker::PhantomData<&'a ()> } impl<'a> i::Foo<'a, uint> for Bar<'a> { - fn foo(&self) -> uint { 5_usize } + fn foo(&self) -> uint { 5 } } pub fn main() { diff --git a/src/test/run-pass/issue-18539.rs b/src/test/run-pass/issue-18539.rs index ce56f3e8d72..b92cfa1f29b 100644 --- a/src/test/run-pass/issue-18539.rs +++ b/src/test/run-pass/issue-18539.rs @@ -19,5 +19,5 @@ fn uint_to_foo(_: uint) -> Foo { #[allow(unused_must_use)] fn main() { - (0_usize..10).map(uint_to_foo); + (0..10).map(uint_to_foo); } diff --git a/src/test/run-pass/issue-20055-box-trait.rs b/src/test/run-pass/issue-20055-box-trait.rs index 572a0d82528..7e89cfe24e1 100644 --- a/src/test/run-pass/issue-20055-box-trait.rs +++ b/src/test/run-pass/issue-20055-box-trait.rs @@ -41,10 +41,10 @@ pub fn foo(box_1: fn () -> Box<[i8; 1]>, } pub fn main() { - fn box_1() -> Box<[i8; 1]> { Box::new( [1i8; 1] ) } - fn box_2() -> Box<[i8; 2]> { Box::new( [1i8; 2] ) } - fn box_3() -> Box<[i8; 3]> { Box::new( [1i8; 3] ) } - fn box_4() -> Box<[i8; 4]> { Box::new( [1i8; 4] ) } + fn box_1() -> Box<[i8; 1]> { Box::new( [1; 1] ) } + fn box_2() -> Box<[i8; 2]> { Box::new( [1; 2] ) } + fn box_3() -> Box<[i8; 3]> { Box::new( [1; 3] ) } + fn box_4() -> Box<[i8; 4]> { Box::new( [1; 4] ) } foo(box_1, box_2, box_3, box_4); } diff --git a/src/test/run-pass/issue-20055-box-unsized-array.rs b/src/test/run-pass/issue-20055-box-unsized-array.rs index f751be6f13b..5af5186e94f 100644 --- a/src/test/run-pass/issue-20055-box-unsized-array.rs +++ b/src/test/run-pass/issue-20055-box-unsized-array.rs @@ -29,10 +29,10 @@ pub fn foo(box_1: fn () -> Box<[i8; 1]>, } pub fn main() { - fn box_1() -> Box<[i8; 1]> { Box::new( [1i8] ) } - fn box_2() -> Box<[i8; 20]> { Box::new( [1i8; 20] ) } - fn box_3() -> Box<[i8; 300]> { Box::new( [1i8; 300] ) } - fn box_4() -> Box<[i8; 4000]> { Box::new( [1i8; 4000] ) } + fn box_1() -> Box<[i8; 1]> { Box::new( [1] ) } + fn box_2() -> Box<[i8; 20]> { Box::new( [1; 20] ) } + fn box_3() -> Box<[i8; 300]> { Box::new( [1; 300] ) } + fn box_4() -> Box<[i8; 4000]> { Box::new( [1; 4000] ) } foo(box_1, box_2, box_3, box_4); } diff --git a/src/test/run-pass/issue-20676.rs b/src/test/run-pass/issue-20676.rs index 01a2322ae93..640774f9d24 100644 --- a/src/test/run-pass/issue-20676.rs +++ b/src/test/run-pass/issue-20676.rs @@ -15,6 +15,6 @@ use std::fmt; fn main() { - let a: &fmt::Debug = &1_i32; + let a: &fmt::Debug = &1; format!("{:?}", a); } diff --git a/src/test/run-pass/issue-21475.rs b/src/test/run-pass/issue-21475.rs index 145145af519..29701bd668a 100644 --- a/src/test/run-pass/issue-21475.rs +++ b/src/test/run-pass/issue-21475.rs @@ -11,10 +11,10 @@ use m::{START, END}; fn main() { - match 42u32 { + match 42 { m::START...m::END => {}, - 0u32...m::END => {}, - m::START...59u32 => {}, + 0...m::END => {}, + m::START...59 => {}, _ => {}, } } diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index 20ff8d29b70..3da0a67ea8e 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -72,17 +72,17 @@ fn range(lo: uint, hi: uint, it: |uint|) { let mut i = lo; while i < hi { it(i); - i += 1_usize; + i += 1; } } pub fn main() { - let range: 'static ||uint|| = |a| range(0_usize, 1000_usize, a); + let range: 'static ||uint|| = |a| range(0, 1000, a); let filt: 'static ||v: uint|| = |a| filter( range, - |&&n: uint| n % 3_usize != 0_usize && n % 5_usize != 0_usize, + |&&n: uint| n % 3 != 0 && n % 5 != 0, a); - let sum = foldl(filt, 0_usize, |accum, &&n: uint| accum + n ); + let sum = foldl(filt, 0, |accum, &&n: uint| accum + n ); println!("{}", sum); } diff --git a/src/test/run-pass/issue-22036.rs b/src/test/run-pass/issue-22036.rs index c06a29c09f7..7bc6393ef89 100644 --- a/src/test/run-pass/issue-22036.rs +++ b/src/test/run-pass/issue-22036.rs @@ -28,6 +28,6 @@ impl<I> DigitCollection for I where I: Iterator<Item=u8> { } fn main() { - let xs = vec![1u8, 2, 3, 4, 5]; + let xs = vec![1, 2, 3, 4, 5]; assert_eq!(xs.into_iter().digit_sum(), 15); } diff --git a/src/test/run-pass/issue-2550.rs b/src/test/run-pass/issue-2550.rs index 395b2c4b459..c55de959a94 100644 --- a/src/test/run-pass/issue-2550.rs +++ b/src/test/run-pass/issue-2550.rs @@ -22,5 +22,5 @@ fn f<T>(_x: T) { } pub fn main() { - f(C(1_usize)); + f(C(1)); } diff --git a/src/test/run-pass/issue-2989.rs b/src/test/run-pass/issue-2989.rs index 8767d397b64..8b6eb12f102 100644 --- a/src/test/run-pass/issue-2989.rs +++ b/src/test/run-pass/issue-2989.rs @@ -21,11 +21,11 @@ impl methods for () { // the position of this function is significant! - if it comes before methods // then it works, if it comes after it then it doesn't! fn to_bools(bitv: Storage) -> Vec<bool> { - (0_usize..8).map(|i| { + (0..8).map(|i| { let w = i / 64; let b = i % 64; - let x = 1u64 & (bitv.storage[w] >> b); - x == 1u64 + let x = 1 & (bitv.storage[w] >> b); + x == 1 }).collect() } @@ -35,7 +35,7 @@ pub fn main() { let bools = vec!(false, false, true, false, false, true, true, false); let bools2 = to_bools(Storage{storage: vec!(0b01100100)}); - for i in 0_usize..8 { + for i in 0..8 { println!("{} => {} vs {}", i, bools[i], bools2[i]); } diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index 28e44536892..b51edcf8bec 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -28,7 +28,7 @@ fn foo(name: String, samples_chan: Sender<Msg>) { // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let callback: SamplesFn = Box::new(move |buffer| { - for i in 0_usize..buffer.len() { + for i in 0..buffer.len() { println!("{}: {}", i, buffer[i]) } }); diff --git a/src/test/run-pass/issue-4735.rs b/src/test/run-pass/issue-4735.rs index bf422bd0405..196e9748b10 100644 --- a/src/test/run-pass/issue-4735.rs +++ b/src/test/run-pass/issue-4735.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-fast doesn't like extern crate #![allow(unknown_features)] #![feature(box_syntax)] diff --git a/src/test/run-pass/issue-4759-1.rs b/src/test/run-pass/issue-4759-1.rs index ce2f488b90c..a565460c42e 100644 --- a/src/test/run-pass/issue-4759-1.rs +++ b/src/test/run-pass/issue-4759-1.rs @@ -7,9 +7,7 @@ // <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. -// -// ignore-lexer-test FIXME #15877 trait U { fn f(self); } -impl U for int { fn f(self) {} } +impl U for isize { fn f(self) {} } pub fn main() { 4.f(); } diff --git a/src/test/run-pass/issue-6130.rs b/src/test/run-pass/issue-6130.rs index 93429ff10dc..1a1f538a548 100644 --- a/src/test/run-pass/issue-6130.rs +++ b/src/test/run-pass/issue-6130.rs @@ -12,9 +12,9 @@ pub fn main() { let i: uint = 0; - assert!(i <= 0xFFFF_FFFF_usize); + assert!(i <= 0xFFFF_FFFF); let i: int = 0; - assert!(i >= -0x8000_0000__isize); - assert!(i <= 0x7FFF_FFFF__isize); + assert!(i >= -0x8000_0000); + assert!(i <= 0x7FFF_FFFF); } diff --git a/src/test/run-pass/issue-6892.rs b/src/test/run-pass/issue-6892.rs index 557ec82233d..6faca339651 100644 --- a/src/test/run-pass/issue-6892.rs +++ b/src/test/run-pass/issue-6892.rs @@ -49,7 +49,7 @@ fn main() { assert_eq!(unsafe { NUM_DROPS }, 3); { let _x = FooBar::_Foo(Foo); } assert_eq!(unsafe { NUM_DROPS }, 5); - { let _x = FooBar::_Bar(42_usize); } + { let _x = FooBar::_Bar(42); } assert_eq!(unsafe { NUM_DROPS }, 6); { let _ = Foo; } @@ -60,6 +60,6 @@ fn main() { assert_eq!(unsafe { NUM_DROPS }, 9); { let _ = FooBar::_Foo(Foo); } assert_eq!(unsafe { NUM_DROPS }, 11); - { let _ = FooBar::_Bar(42_usize); } + { let _ = FooBar::_Bar(42); } assert_eq!(unsafe { NUM_DROPS }, 12); } diff --git a/src/test/run-pass/issue-7012.rs b/src/test/run-pass/issue-7012.rs index 96db28f4a10..3a9864f3a76 100644 --- a/src/test/run-pass/issue-7012.rs +++ b/src/test/run-pass/issue-7012.rs @@ -18,11 +18,11 @@ would be printed, however the below prints false. struct signature<'a> { pattern : &'a [u32] } static test1: signature<'static> = signature { - pattern: &[0x243f6a88u32,0x85a308d3u32,0x13198a2eu32,0x03707344u32,0xa4093822u32,0x299f31d0u32] + pattern: &[0x243f6a88,0x85a308d3,0x13198a2e,0x03707344,0xa4093822,0x299f31d0] }; pub fn main() { - let test: &[u32] = &[0x243f6a88u32,0x85a308d3u32,0x13198a2eu32, - 0x03707344u32,0xa4093822u32,0x299f31d0u32]; + let test: &[u32] = &[0x243f6a88,0x85a308d3,0x13198a2e, + 0x03707344,0xa4093822,0x299f31d0]; println!("{}",test==test1.pattern); } diff --git a/src/test/run-pass/issue-8783.rs b/src/test/run-pass/issue-8783.rs index 815e00e1291..303dd191006 100644 --- a/src/test/run-pass/issue-8783.rs +++ b/src/test/run-pass/issue-8783.rs @@ -13,7 +13,7 @@ use std::default::Default; struct X { pub x: uint } impl Default for X { fn default() -> X { - X { x: 42_usize } + X { x: 42 } } } diff --git a/src/test/run-pass/issue2170exe.rs b/src/test/run-pass/issue2170exe.rs index b4a41ef44f8..58424089c5e 100644 --- a/src/test/run-pass/issue2170exe.rs +++ b/src/test/run-pass/issue2170exe.rs @@ -12,5 +12,5 @@ extern crate issue2170lib; pub fn main() { - // let _ = issue2170lib::rsrc(2i32); + // let _ = issue2170lib::rsrc(2); } diff --git a/src/test/run-pass/iter-cloned-type-inference.rs b/src/test/run-pass/iter-cloned-type-inference.rs new file mode 100644 index 00000000000..6ce226bbeca --- /dev/null +++ b/src/test/run-pass/iter-cloned-type-inference.rs @@ -0,0 +1,25 @@ +// Copyright 2015 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. + +// Test to see that the element type of .cloned() can be inferred +// properly. Previously this would fail to deduce the type of `sum`. + +#![feature(core)] + +use std::iter::AdditiveIterator; + +fn square_sum(v: &[i64]) -> i64 { + let sum = v.iter().cloned().sum(); + sum * sum +} + +fn main() { + assert_eq!(36, square_sum(&[1,2,3])); +} diff --git a/src/test/run-pass/ivec-tag.rs b/src/test/run-pass/ivec-tag.rs index dd38a5f8b3b..121338823d2 100644 --- a/src/test/run-pass/ivec-tag.rs +++ b/src/test/run-pass/ivec-tag.rs @@ -13,8 +13,8 @@ use std::sync::mpsc::{channel, Sender}; fn producer(tx: &Sender<Vec<u8>>) { tx.send( - vec!(1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8, 9u8, 10u8, 11u8, 12u8, - 13u8)).unwrap(); + vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13)).unwrap(); } pub fn main() { diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index 74ddb990c31..45964efad97 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -19,8 +19,8 @@ struct A { a: Box<isize> } fn foo() -> Box<FnMut() -> isize + 'static> { let k: Box<_> = box 22; let _u = A {a: k.clone()}; - // FIXME(#16640) suffix in `22_isize` suffix shouldn't be necessary - let result = || 22_isize; + // FIXME(#16640) suffix in `22` suffix shouldn't be necessary + let result = || 22; // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. Box::new(result) } diff --git a/src/test/run-pass/logging-enabled-debug.rs b/src/test/run-pass/logging-enabled-debug.rs index 262d9b21eb4..dfc92728270 100644 --- a/src/test/run-pass/logging-enabled-debug.rs +++ b/src/test/run-pass/logging-enabled-debug.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags:--cfg ndebug +// compile-flags:-C debug-assertions=no // exec-env:RUST_LOG=logging-enabled-debug=debug #[macro_use] diff --git a/src/test/run-pass/logging-separate-lines.rs b/src/test/run-pass/logging-separate-lines.rs index 8526dfe72da..82a155b1173 100644 --- a/src/test/run-pass/logging-separate-lines.rs +++ b/src/test/run-pass/logging-separate-lines.rs @@ -10,6 +10,7 @@ // ignore-windows // exec-env:RUST_LOG=debug +// compile-flags:-C debug-assertions=y #[macro_use] extern crate log; diff --git a/src/test/run-pass/macro-interpolation.rs b/src/test/run-pass/macro-interpolation.rs index 069aeb9220e..1cbd4f6bc70 100644 --- a/src/test/run-pass/macro-interpolation.rs +++ b/src/test/run-pass/macro-interpolation.rs @@ -24,6 +24,6 @@ macro_rules! overly_complicated { pub fn main() { assert!(overly_complicated!(f, x, Option<uint>, { return Some(x); }, - Some(8_usize), Some(y), y) == 8_usize) + Some(8), Some(y), y) == 8) } diff --git a/src/test/run-pass/macro-pat.rs b/src/test/run-pass/macro-pat.rs index 6f2626a5af5..7a3e55322c8 100644 --- a/src/test/run-pass/macro-pat.rs +++ b/src/test/run-pass/macro-pat.rs @@ -47,9 +47,9 @@ fn f(c: Option<char>) -> uint { } pub fn main() { - assert_eq!(1_usize, f(Some('x'))); - assert_eq!(2_usize, f(Some('y'))); - assert_eq!(3_usize, f(None)); + assert_eq!(1, f(Some('x'))); + assert_eq!(2, f(Some('y'))); + assert_eq!(3, f(None)); assert_eq!(1, match Some('x') { Some(char_x!()) => 1, diff --git a/src/test/run-pass/match-with-ret-arm.rs b/src/test/run-pass/match-with-ret-arm.rs index d2e27fc822e..79b197f08e2 100644 --- a/src/test/run-pass/match-with-ret-arm.rs +++ b/src/test/run-pass/match-with-ret-arm.rs @@ -16,6 +16,6 @@ pub fn main() { None => return (), Some(num) => num as u32 }; - assert_eq!(f, 1234u32); + assert_eq!(f, 1234); println!("{}", f) } diff --git a/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs b/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs index 0ad600dd85d..3ffac98418a 100644 --- a/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs +++ b/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs @@ -38,7 +38,7 @@ impl<'a> MyWriter for &'a mut [u8] { } fn main() { - let mut buf = [0_u8; 6]; + let mut buf = [0; 6]; { let mut writer: &mut [_] = &mut buf; diff --git a/src/test/run-pass/method-self-arg-aux1.rs b/src/test/run-pass/method-self-arg-aux1.rs index e9a1e19d4bf..81212ee348f 100644 --- a/src/test/run-pass/method-self-arg-aux1.rs +++ b/src/test/run-pass/method-self-arg-aux1.rs @@ -26,5 +26,5 @@ fn main() { x.foo(&x); - assert!(method_self_arg1::get_count() == 2u64*3*3*3*5*5*5*7*7*7); + assert!(method_self_arg1::get_count() == 2*3*3*3*5*5*5*7*7*7); } diff --git a/src/test/run-pass/method-self-arg-aux2.rs b/src/test/run-pass/method-self-arg-aux2.rs index 7fa810ce154..ca81860dd08 100644 --- a/src/test/run-pass/method-self-arg-aux2.rs +++ b/src/test/run-pass/method-self-arg-aux2.rs @@ -30,5 +30,5 @@ fn main() { x.run_trait(); - assert!(method_self_arg2::get_count() == 2u64*2*3*3*5*5*7*7*11*11*13*13*17); + assert!(method_self_arg2::get_count() == 2*2*3*3*5*5*7*7*11*11*13*13*17); } diff --git a/src/test/run-pass/method-self-arg-trait.rs b/src/test/run-pass/method-self-arg-trait.rs index c79141d9795..17fdd7b45c2 100644 --- a/src/test/run-pass/method-self-arg-trait.rs +++ b/src/test/run-pass/method-self-arg-trait.rs @@ -75,5 +75,5 @@ fn main() { x.baz(); - unsafe { assert!(COUNT == 2u64*2*3*3*5*5*7*7*11*11*13*13*17); } + unsafe { assert!(COUNT == 2*2*3*3*5*5*7*7*11*11*13*13*17); } } diff --git a/src/test/run-pass/method-self-arg.rs b/src/test/run-pass/method-self-arg.rs index de24297c7b5..62b3d52860b 100644 --- a/src/test/run-pass/method-self-arg.rs +++ b/src/test/run-pass/method-self-arg.rs @@ -54,5 +54,5 @@ fn main() { x.foo(&x); - unsafe { assert!(COUNT == 2_usize*3*3*3*5*5*5*7*7*7); } + unsafe { assert!(COUNT == 2*3*3*3*5*5*5*7*7*7); } } diff --git a/src/test/run-pass/newtype-struct-with-dtor.rs b/src/test/run-pass/newtype-struct-with-dtor.rs index 8631755f37f..15c4e8b0453 100644 --- a/src/test/run-pass/newtype-struct-with-dtor.rs +++ b/src/test/run-pass/newtype-struct-with-dtor.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-fast doesn't like extern crate extern crate libc; use libc::c_int; diff --git a/src/test/run-pass/nul-characters.rs b/src/test/run-pass/nul-characters.rs index 22786c0abc8..4a14969209f 100644 --- a/src/test/run-pass/nul-characters.rs +++ b/src/test/run-pass/nul-characters.rs @@ -10,10 +10,10 @@ pub fn main() { - let all_nuls1 = "\0\x00\u0000\U00000000"; - let all_nuls2 = "\U00000000\u0000\x00\0"; - let all_nuls3 = "\u0000\U00000000\x00\0"; - let all_nuls4 = "\x00\u0000\0\U00000000"; + let all_nuls1 = "\0\x00\u{0}\u{0}"; + let all_nuls2 = "\u{0}\u{0}\x00\0"; + let all_nuls3 = "\u{0}\u{0}\x00\0"; + let all_nuls4 = "\x00\u{0}\0\u{0}"; // sizes for two should suffice assert_eq!(all_nuls1.len(), 4); @@ -35,8 +35,8 @@ pub fn main() // testing equality between explicit character literals assert_eq!('\0', '\x00'); - assert_eq!('\u0000', '\x00'); - assert_eq!('\u0000', '\U00000000'); + assert_eq!('\u{0}', '\x00'); + assert_eq!('\u{0}', '\u{0}'); // NUL characters should make a difference assert!("Hello World" != "Hello \0World"); diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index bb62b1599a4..03027e40d6c 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -55,7 +55,7 @@ macro_rules! check_fancy { check_fancy!($e, $T, |ptr| assert!(*ptr == $e)); }}; ($e:expr, $T:ty, |$v:ident| $chk:expr) => {{ - assert!(E::Nothing::<$T>((), ((), ()), [23i8; 0]).is_none()); + assert!(E::Nothing::<$T>((), ((), ()), [23; 0]).is_none()); let e = $e; let t_ = E::Thing::<$T>(23, e); match t_.get_ref() { diff --git a/src/test/run-pass/object-method-numbering.rs b/src/test/run-pass/object-method-numbering.rs index 8da753acb96..9c7a925b5bb 100644 --- a/src/test/run-pass/object-method-numbering.rs +++ b/src/test/run-pass/object-method-numbering.rs @@ -29,7 +29,7 @@ impl SomeTrait for i32 { } fn main() { - let x = 22_i32; + let x = 22; let x1: &SomeTrait<SomeType=i32> = &x; let y = get_int(x1); assert_eq!(x, y); diff --git a/src/test/run-pass/objects-coerce-freeze-borrored.rs b/src/test/run-pass/objects-coerce-freeze-borrored.rs index 998af27c338..d2523bc4f24 100644 --- a/src/test/run-pass/objects-coerce-freeze-borrored.rs +++ b/src/test/run-pass/objects-coerce-freeze-borrored.rs @@ -40,9 +40,9 @@ fn do_it_imm(obj: &Foo, v: uint) { } pub fn main() { - let mut x = 22_usize; + let mut x = 22; let obj = &mut x as &mut Foo; do_it_mut(obj); - do_it_imm(obj, 23_usize); + do_it_imm(obj, 23); do_it_mut(obj); } diff --git a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs index 30a8c270bd7..9cee266c4a7 100644 --- a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs +++ b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs @@ -37,7 +37,7 @@ pub fn main() { box BarStruct{ x: 2 } as Box<FooTrait> ); - for i in 0_usize..foos.len() { + for i in 0..foos.len() { assert_eq!(i, foos[i].foo()); } } diff --git a/src/test/run-pass/or-pattern.rs b/src/test/run-pass/or-pattern.rs index 654d2429a0b..ef399044abc 100644 --- a/src/test/run-pass/or-pattern.rs +++ b/src/test/run-pass/or-pattern.rs @@ -16,6 +16,6 @@ fn or_alt(q: blah) -> int { pub fn main() { assert_eq!(or_alt(blah::c), 0); - assert_eq!(or_alt(blah::a(10, 100, 0_usize)), 110); + assert_eq!(or_alt(blah::a(10, 100, 0)), 110); assert_eq!(or_alt(blah::b(20, 200)), 220); } diff --git a/src/test/run-pass/overloaded-calls-param-vtables.rs b/src/test/run-pass/overloaded-calls-param-vtables.rs index 2ef9e08134c..0ac9c97532b 100644 --- a/src/test/run-pass/overloaded-calls-param-vtables.rs +++ b/src/test/run-pass/overloaded-calls-param-vtables.rs @@ -28,5 +28,5 @@ impl<'a, A: Add<i32, Output=i32>> Fn<(A,)> for G<A> { fn main() { // ICE trigger - (G(PhantomData))(1_i32); + (G(PhantomData))(1); } diff --git a/src/test/run-pass/packed-struct-vec.rs b/src/test/run-pass/packed-struct-vec.rs index cfe49c38c52..92f57f04b10 100644 --- a/src/test/run-pass/packed-struct-vec.rs +++ b/src/test/run-pass/packed-struct-vec.rs @@ -24,7 +24,7 @@ pub fn main() { assert_eq!(mem::size_of::<[Foo; 10]>(), 90); - for i in 0_usize..10 { + for i in 0..10 { assert_eq!(foos[i], Foo { bar: 1, baz: 2}); } diff --git a/src/test/run-pass/path.rs b/src/test/run-pass/path.rs index 02d8602d59e..08d00d4dc03 100644 --- a/src/test/run-pass/path.rs +++ b/src/test/run-pass/path.rs @@ -14,4 +14,4 @@ mod foo { pub fn bar(_offset: uint) { } } -pub fn main() { foo::bar(0_usize); } +pub fn main() { foo::bar(0); } diff --git a/src/test/run-pass/private-class-field.rs b/src/test/run-pass/private-class-field.rs index c7380b362fb..b4d04ba18f9 100644 --- a/src/test/run-pass/private-class-field.rs +++ b/src/test/run-pass/private-class-field.rs @@ -26,6 +26,6 @@ fn cat(in_x : uint, in_y : int) -> cat { } pub fn main() { - let mut nyan : cat = cat(52_usize, 99); - assert_eq!(nyan.meow_count(), 52_usize); + let mut nyan : cat = cat(52, 99); + assert_eq!(nyan.meow_count(), 52); } diff --git a/src/test/run-pass/pure-sum.rs b/src/test/run-pass/pure-sum.rs index 1fd83041f62..f12cf82f939 100644 --- a/src/test/run-pass/pure-sum.rs +++ b/src/test/run-pass/pure-sum.rs @@ -14,31 +14,31 @@ #![feature(box_syntax)] fn sums_to(v: Vec<int> , sum: int) -> bool { - let mut i = 0_usize; + let mut i = 0; let mut sum0 = 0; while i < v.len() { sum0 += v[i]; - i += 1_usize; + i += 1; } return sum0 == sum; } fn sums_to_using_uniq(v: Vec<int> , sum: int) -> bool { - let mut i = 0_usize; + let mut i = 0; let mut sum0: Box<_> = box 0; while i < v.len() { *sum0 += v[i]; - i += 1_usize; + i += 1; } return *sum0 == sum; } fn sums_to_using_rec(v: Vec<int> , sum: int) -> bool { - let mut i = 0_usize; + let mut i = 0; let mut sum0 = F {f: 0}; while i < v.len() { sum0.f += v[i]; - i += 1_usize; + i += 1; } return sum0.f == sum; } @@ -46,11 +46,11 @@ fn sums_to_using_rec(v: Vec<int> , sum: int) -> bool { struct F<T> { f: T } fn sums_to_using_uniq_rec(v: Vec<int> , sum: int) -> bool { - let mut i = 0_usize; + let mut i = 0; let mut sum0 = F::<Box<_>> {f: box 0}; while i < v.len() { *sum0.f += v[i]; - i += 1_usize; + i += 1; } return *sum0.f == sum; } diff --git a/src/test/run-pass/ranges-precedence.rs b/src/test/run-pass/ranges-precedence.rs index db414abb7ff..41ed9a74d13 100644 --- a/src/test/run-pass/ranges-precedence.rs +++ b/src/test/run-pass/ranges-precedence.rs @@ -38,7 +38,7 @@ fn main() { let x = ..1+3; assert!(x == (..4)); - let a = &[0i32, 1, 2, 3, 4, 5, 6]; + let a = &[0, 1, 2, 3, 4, 5, 6]; let x = &a[1+1..2+2]; assert!(x == &a[2..4]); let x = &a[..1+2]; diff --git a/src/test/run-pass/raw-str.rs b/src/test/run-pass/raw-str.rs index 35e863d05a1..298ac8f77eb 100644 --- a/src/test/run-pass/raw-str.rs +++ b/src/test/run-pass/raw-str.rs Binary files differdiff --git a/src/test/run-pass/realloc-16687.rs b/src/test/run-pass/realloc-16687.rs index de5b14104c5..e8bcff38131 100644 --- a/src/test/run-pass/realloc-16687.rs +++ b/src/test/run-pass/realloc-16687.rs @@ -35,9 +35,9 @@ unsafe fn test_triangle() -> bool { // from pairs of rows (where each pair of rows is equally sized), // and the elements of the triangle match their row-pair index. unsafe fn sanity_check(ascend: &[*mut u8]) { - for i in 0_usize..COUNT / 2 { + for i in 0..COUNT / 2 { let (p0, p1, size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i)); - for j in 0_usize..size { + for j in 0..size { assert_eq!(*p0.offset(j as int), i as u8); assert_eq!(*p1.offset(j as int), i as u8); } @@ -88,14 +88,14 @@ unsafe fn test_triangle() -> bool { // that at least two rows will be allocated near each other, so // that we trigger the bug (a buffer overrun) in an observable // way.) - for i in 0_usize..COUNT / 2 { + for i in 0..COUNT / 2 { let size = idx_to_size(i); ascend[2*i] = allocate(size, ALIGN); ascend[2*i+1] = allocate(size, ALIGN); } // Initialize each pair of rows to distinct value. - for i in 0_usize..COUNT / 2 { + for i in 0..COUNT / 2 { let (p0, p1, size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i)); for j in 0..size { *p0.offset(j as int) = i as u8; @@ -109,7 +109,7 @@ unsafe fn test_triangle() -> bool { test_3(ascend); // triangle -> square test_4(ascend); // square -> triangle - for i in 0_usize..COUNT / 2 { + for i in 0..COUNT / 2 { let size = idx_to_size(i); deallocate(ascend[2*i], size, ALIGN); deallocate(ascend[2*i+1], size, ALIGN); @@ -123,7 +123,7 @@ unsafe fn test_triangle() -> bool { // rows as we go. unsafe fn test_1(ascend: &mut [*mut u8]) { let new_size = idx_to_size(COUNT-1); - for i in 0_usize..COUNT / 2 { + for i in 0..COUNT / 2 { let (p0, p1, old_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i)); assert!(old_size < new_size); @@ -138,7 +138,7 @@ unsafe fn test_triangle() -> bool { // Test 2: turn the square back into a triangle, top to bottom. unsafe fn test_2(ascend: &mut [*mut u8]) { let old_size = idx_to_size(COUNT-1); - for i in 0_usize..COUNT / 2 { + for i in 0..COUNT / 2 { let (p0, p1, new_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i)); assert!(new_size < old_size); @@ -153,7 +153,7 @@ unsafe fn test_triangle() -> bool { // Test 3: turn triangle into a square, bottom to top. unsafe fn test_3(ascend: &mut [*mut u8]) { let new_size = idx_to_size(COUNT-1); - for i in (0_usize..COUNT / 2).rev() { + for i in (0..COUNT / 2).rev() { let (p0, p1, old_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i)); assert!(old_size < new_size); @@ -168,7 +168,7 @@ unsafe fn test_triangle() -> bool { // Test 4: turn the square back into a triangle, bottom to top. unsafe fn test_4(ascend: &mut [*mut u8]) { let old_size = idx_to_size(COUNT-1); - for i in (0_usize..COUNT / 2).rev() { + for i in (0..COUNT / 2).rev() { let (p0, p1, new_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i)); assert!(new_size < old_size); diff --git a/src/test/run-pass/rec-align-u32.rs b/src/test/run-pass/rec-align-u32.rs index 51b800bc9f0..94fe3f1d9ea 100644 --- a/src/test/run-pass/rec-align-u32.rs +++ b/src/test/run-pass/rec-align-u32.rs @@ -38,19 +38,19 @@ struct Outer { #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "aarch64"))] mod m { - pub fn align() -> uint { 4_usize } - pub fn size() -> uint { 8_usize } + pub fn align() -> uint { 4 } + pub fn size() -> uint { 8 } } #[cfg(target_arch = "x86_64")] mod m { - pub fn align() -> uint { 4_usize } - pub fn size() -> uint { 8_usize } + pub fn align() -> uint { 4 } + pub fn size() -> uint { 8 } } pub fn main() { unsafe { - let x = Outer {c8: 22u8, t: Inner {c64: 44u32}}; + let x = Outer {c8: 22, t: Inner {c64: 44}}; // Send it through the shape code let y = format!("{:?}", x); diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs index 835b4c40f5c..8b7434ed063 100644 --- a/src/test/run-pass/rec-align-u64.rs +++ b/src/test/run-pass/rec-align-u64.rs @@ -44,14 +44,14 @@ struct Outer { mod m { #[cfg(target_arch = "x86")] pub mod m { - pub fn align() -> uint { 4_usize } - pub fn size() -> uint { 12_usize } + pub fn align() -> uint { 4 } + pub fn size() -> uint { 12 } } #[cfg(any(target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64"))] pub mod m { - pub fn align() -> uint { 8_usize } - pub fn size() -> uint { 16_usize } + pub fn align() -> uint { 8 } + pub fn size() -> uint { 16 } } } @@ -59,8 +59,8 @@ mod m { mod m { #[cfg(target_arch = "x86_64")] pub mod m { - pub fn align() -> uint { 8u } - pub fn size() -> uint { 16u } + pub fn align() -> uint { 8 } + pub fn size() -> uint { 16 } } } @@ -68,14 +68,14 @@ mod m { mod m { #[cfg(target_arch = "x86")] pub mod m { - pub fn align() -> uint { 8_usize } - pub fn size() -> uint { 16_usize } + pub fn align() -> uint { 8 } + pub fn size() -> uint { 16 } } #[cfg(target_arch = "x86_64")] pub mod m { - pub fn align() -> uint { 8_usize } - pub fn size() -> uint { 16_usize } + pub fn align() -> uint { 8 } + pub fn size() -> uint { 16 } } } @@ -83,14 +83,14 @@ mod m { mod m { #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] pub mod m { - pub fn align() -> uint { 8_usize } - pub fn size() -> uint { 16_usize } + pub fn align() -> uint { 8 } + pub fn size() -> uint { 16 } } } pub fn main() { unsafe { - let x = Outer {c8: 22u8, t: Inner {c64: 44u64}}; + let x = Outer {c8: 22, t: Inner {c64: 44}}; let y = format!("{:?}", x); diff --git a/src/test/run-pass/record-pat.rs b/src/test/run-pass/record-pat.rs index 282a24a407c..b152470fbb6 100644 --- a/src/test/run-pass/record-pat.rs +++ b/src/test/run-pass/record-pat.rs @@ -20,6 +20,6 @@ fn m(input: t3) -> int { } pub fn main() { - assert_eq!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4_usize)), 10); - assert_eq!(m(t3::c(T2 {x: t1::b(10_usize), y: 5}, 4_usize)), 19); + assert_eq!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4)), 10); + assert_eq!(m(t3::c(T2 {x: t1::b(10), y: 5}, 4)), 19); } diff --git a/src/test/run-pass/regions-borrow-at.rs b/src/test/run-pass/regions-borrow-at.rs index 1e91ab7e921..56dd386ead1 100644 --- a/src/test/run-pass/regions-borrow-at.rs +++ b/src/test/run-pass/regions-borrow-at.rs @@ -16,8 +16,8 @@ fn foo(x: &uint) -> uint { } pub fn main() { - let p: Box<_> = box 22_usize; + let p: Box<_> = box 22; let r = foo(&*p); println!("r={}", r); - assert_eq!(r, 22_usize); + assert_eq!(r, 22); } diff --git a/src/test/run-pass/regions-borrow-uniq.rs b/src/test/run-pass/regions-borrow-uniq.rs index 7c9b1ae226f..0673179eef0 100644 --- a/src/test/run-pass/regions-borrow-uniq.rs +++ b/src/test/run-pass/regions-borrow-uniq.rs @@ -16,7 +16,7 @@ fn foo(x: &uint) -> uint { } pub fn main() { - let p: Box<_> = box 3_usize; + let p: Box<_> = box 3; let r = foo(&*p); - assert_eq!(r, 3_usize); + assert_eq!(r, 3); } diff --git a/src/test/run-pass/regions-copy-closure.rs b/src/test/run-pass/regions-copy-closure.rs index 3704fc1d8d1..b39343b1f57 100644 --- a/src/test/run-pass/regions-copy-closure.rs +++ b/src/test/run-pass/regions-copy-closure.rs @@ -20,7 +20,7 @@ fn box_it<'a>(x: Box<FnMut() + 'a>) -> closure_box<'a> { } pub fn main() { - let mut i = 3i32; + let mut i = 3; assert_eq!(i, 3); { let cl = || i += 1; diff --git a/src/test/run-pass/regions-escape-into-other-fn.rs b/src/test/run-pass/regions-escape-into-other-fn.rs index 0ca17e218d2..3708d187d71 100644 --- a/src/test/run-pass/regions-escape-into-other-fn.rs +++ b/src/test/run-pass/regions-escape-into-other-fn.rs @@ -15,6 +15,6 @@ fn foo(x: &uint) -> &uint { x } fn bar(x: &uint) -> uint { *x } pub fn main() { - let p: Box<_> = box 3_usize; + let p: Box<_> = box 3; assert_eq!(bar(foo(&*p)), 3); } diff --git a/src/test/run-pass/regions-params.rs b/src/test/run-pass/regions-params.rs index c71953e20f8..181d962cfae 100644 --- a/src/test/run-pass/regions-params.rs +++ b/src/test/run-pass/regions-params.rs @@ -21,6 +21,6 @@ fn parameterized(x: &uint) -> uint { } pub fn main() { - let x = 3_usize; - assert_eq!(parameterized(&x), 3_usize); + let x = 3; + assert_eq!(parameterized(&x), 3); } diff --git a/src/test/run-pass/regions-refcell.rs b/src/test/run-pass/regions-refcell.rs index a224017780e..30d8fc34d00 100644 --- a/src/test/run-pass/regions-refcell.rs +++ b/src/test/run-pass/regions-refcell.rs @@ -18,7 +18,7 @@ use std::cell::RefCell; // This version does not yet work (associated type issues)... #[cfg(cannot_use_this_yet)] fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) { - let one = [1_usize]; + let one = [1]; assert_eq!(map.borrow().get("one"), Some(&one[..])); } @@ -26,7 +26,7 @@ fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) { // ... and this version does not work (the lifetime of `one` is // supposed to match the lifetime `'a`) ... fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) { - let one = [1_usize]; + let one = [1]; assert_eq!(map.borrow().get("one"), Some(&one.as_slice())); } @@ -41,9 +41,9 @@ fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) { } fn main() { - let zer = [0u8]; - let one = [1u8]; - let two = [2u8]; + let zer = [0]; + let one = [1]; + let two = [2]; let mut map = HashMap::new(); map.insert("zero", &zer[..]); map.insert("one", &one[..]); diff --git a/src/test/run-pass/regions-trait-object-1.rs b/src/test/run-pass/regions-trait-object-1.rs index eb3bec77326..807227d47db 100644 --- a/src/test/run-pass/regions-trait-object-1.rs +++ b/src/test/run-pass/regions-trait-object-1.rs @@ -37,7 +37,7 @@ fn extension<'e>(x: &'e E<'e>) -> Box<M+'e> { } fn main() { - let w = E { f: &10u8 }; + let w = E { f: &10 }; let o = extension(&w); - assert_eq!(o.n(), 10u8); + assert_eq!(o.n(), 10); } diff --git a/src/test/run-pass/rename-directory.rs b/src/test/run-pass/rename-directory.rs index abe6ffe7d4c..9209db22433 100644 --- a/src/test/run-pass/rename-directory.rs +++ b/src/test/run-pass/rename-directory.rs @@ -34,7 +34,7 @@ fn rename_directory() { let fromp = CString::new(test_file.as_vec()).unwrap(); let modebuf = CString::new(b"w+b").unwrap(); let ostream = libc::fopen(fromp.as_ptr(), modebuf.as_ptr()); - assert!((ostream as uint != 0_usize)); + assert!((ostream as uint != 0)); let s = "hello".to_string(); let buf = CString::new(b"hello").unwrap(); let write_len = libc::fwrite(buf.as_ptr() as *mut _, diff --git a/src/test/run-pass/ret-bang.rs b/src/test/run-pass/ret-bang.rs index 74227192cab..14b398b3d9a 100644 --- a/src/test/run-pass/ret-bang.rs +++ b/src/test/run-pass/ret-bang.rs @@ -14,11 +14,11 @@ fn my_err(s: String) -> ! { println!("{}", s); panic!(); } fn okay(i: uint) -> int { - if i == 3_usize { + if i == 3 { my_err("I don't like three".to_string()); } else { return 42; } } -pub fn main() { okay(4_usize); } +pub fn main() { okay(4); } diff --git a/src/test/run-pass/running-with-no-runtime.rs b/src/test/run-pass/running-with-no-runtime.rs index ec033b74dd1..abb16c39d11 100644 --- a/src/test/run-pass/running-with-no-runtime.rs +++ b/src/test/run-pass/running-with-no-runtime.rs @@ -43,15 +43,15 @@ fn start(argc: int, argv: *const *const u8) -> int { }; let me = &*args[0]; - let x: &[u8] = &[1u8]; + let x: &[u8] = &[1]; pass(Command::new(me).arg(x).output().unwrap()); - let x: &[u8] = &[2u8]; + let x: &[u8] = &[2]; pass(Command::new(me).arg(x).output().unwrap()); - let x: &[u8] = &[3u8]; + let x: &[u8] = &[3]; pass(Command::new(me).arg(x).output().unwrap()); - let x: &[u8] = &[4u8]; + let x: &[u8] = &[4]; pass(Command::new(me).arg(x).output().unwrap()); - let x: &[u8] = &[5u8]; + let x: &[u8] = &[5]; pass(Command::new(me).arg(x).output().unwrap()); 0 diff --git a/src/test/run-pass/send-is-not-static-par-for.rs b/src/test/run-pass/send-is-not-static-par-for.rs index c6b64d97fbd..c6b64d97fbd 100755..100644 --- a/src/test/run-pass/send-is-not-static-par-for.rs +++ b/src/test/run-pass/send-is-not-static-par-for.rs diff --git a/src/test/run-pass/sendfn-is-a-block.rs b/src/test/run-pass/sendfn-is-a-block.rs index 18519573c26..51c20bcd098 100644 --- a/src/test/run-pass/sendfn-is-a-block.rs +++ b/src/test/run-pass/sendfn-is-a-block.rs @@ -10,10 +10,10 @@ fn test<F>(f: F) -> uint where F: FnOnce(uint) -> uint { - return f(22_usize); + return f(22); } pub fn main() { - let y = test(|x| 4_usize * x); - assert_eq!(y, 88_usize); + let y = test(|x| 4 * x); + assert_eq!(y, 88); } diff --git a/src/test/run-pass/shift-various-types.rs b/src/test/run-pass/shift-various-types.rs index 2f56e09b2df..26dc6c5316b 100644 --- a/src/test/run-pass/shift-various-types.rs +++ b/src/test/run-pass/shift-various-types.rs @@ -25,17 +25,17 @@ struct Panolpy { } fn foo(p: &Panolpy) { - assert_eq!(22_i32 >> p.i8, 11_i32); - assert_eq!(22_i32 >> p.i16, 11_i32); - assert_eq!(22_i32 >> p.i32, 11_i32); - assert_eq!(22_i32 >> p.i64, 11_i32); - assert_eq!(22_i32 >> p.isize, 11_i32); + assert_eq!(22 >> p.i8, 11); + assert_eq!(22 >> p.i16, 11); + assert_eq!(22 >> p.i32, 11); + assert_eq!(22 >> p.i64, 11); + assert_eq!(22 >> p.isize, 11); - assert_eq!(22_i32 >> p.u8, 11_i32); - assert_eq!(22_i32 >> p.u16, 11_i32); - assert_eq!(22_i32 >> p.u32, 11_i32); - assert_eq!(22_i32 >> p.u64, 11_i32); - assert_eq!(22_i32 >> p.usize, 11_i32); + assert_eq!(22 >> p.u8, 11); + assert_eq!(22 >> p.u16, 11); + assert_eq!(22 >> p.u32, 11); + assert_eq!(22 >> p.u64, 11); + assert_eq!(22 >> p.usize, 11); } fn main() { diff --git a/src/test/compile-fail/unsized4.rs b/src/test/run-pass/single-derive-attr-with-gate.rs index f8b8ad2bf2e..cc5d8fc7891 100644 --- a/src/test/compile-fail/unsized4.rs +++ b/src/test/run-pass/single-derive-attr-with-gate.rs @@ -1,4 +1,4 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,12 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that bounds are sized-compatible. +#![feature(custom_derive)] -trait T : Sized {} -fn f<Y: ?Sized + T>() { -//~^ERROR incompatible bounds on `Y`, bound `T` does not allow unsized type -} +#[derive_Clone] +struct Test; pub fn main() { + Test.clone(); } diff --git a/src/test/run-pass/small-enums-with-fields.rs b/src/test/run-pass/small-enums-with-fields.rs index 475af8f2b8e..86eed715f32 100644 --- a/src/test/run-pass/small-enums-with-fields.rs +++ b/src/test/run-pass/small-enums-with-fields.rs @@ -29,14 +29,14 @@ macro_rules! check { pub fn main() { check!(Option<u8>, 2, None, "None", - Some(129u8), "Some(129)"); + Some(129), "Some(129)"); check!(Option<i16>, 4, None, "None", - Some(-20000i16), "Some(-20000)"); + Some(-20000), "Some(-20000)"); check!(Either<u8, i8>, 2, - Either::Left(132u8), "Left(132)", - Either::Right(-32i8), "Right(-32)"); + Either::Left(132), "Left(132)", + Either::Right(-32), "Right(-32)"); check!(Either<u8, i16>, 4, - Either::Left(132u8), "Left(132)", - Either::Right(-20000i16), "Right(-20000)"); + Either::Left(132), "Left(132)", + Either::Right(-20000), "Right(-20000)"); } diff --git a/src/test/run-pass/static-methods-in-traits.rs b/src/test/run-pass/static-methods-in-traits.rs index 5f6dc4f2a53..47f46041c22 100644 --- a/src/test/run-pass/static-methods-in-traits.rs +++ b/src/test/run-pass/static-methods-in-traits.rs @@ -21,7 +21,7 @@ mod a { impl Foo for uint { fn foo() -> uint { - 5_usize + 5 } } } diff --git a/src/test/run-pass/string-self-append.rs b/src/test/run-pass/string-self-append.rs index 359c14ea7b0..cef7a93aeed 100644 --- a/src/test/run-pass/string-self-append.rs +++ b/src/test/run-pass/string-self-append.rs @@ -12,12 +12,12 @@ pub fn main() { // Make sure we properly handle repeated self-appends. let mut a: String = "A".to_string(); let mut i = 20; - let mut expected_len = 1_usize; + let mut expected_len = 1; while i > 0 { println!("{}", a.len()); assert_eq!(a.len(), expected_len); a = format!("{}{}", a, a); i -= 1; - expected_len *= 2_usize; + expected_len *= 2; } } diff --git a/src/test/run-pass/struct-order-of-eval-1.rs b/src/test/run-pass/struct-order-of-eval-1.rs index 6cebd17496a..a64477242c0 100644 --- a/src/test/run-pass/struct-order-of-eval-1.rs +++ b/src/test/run-pass/struct-order-of-eval-1.rs @@ -12,11 +12,12 @@ struct S { f0: String, f1: int } pub fn main() { let s = "Hello, world!".to_string(); - let _s = S { + let s = S { f0: s.to_string(), ..S { f0: s, f1: 23 } }; + assert_eq!(s.f0, "Hello, world!"); } diff --git a/src/test/run-pass/struct-order-of-eval-2.rs b/src/test/run-pass/struct-order-of-eval-2.rs index 786f080bb9e..359ecdab630 100644 --- a/src/test/run-pass/struct-order-of-eval-2.rs +++ b/src/test/run-pass/struct-order-of-eval-2.rs @@ -15,8 +15,9 @@ struct S { pub fn main() { let s = "Hello, world!".to_string(); - let _s = S { + let s = S { f1: s.to_string(), f0: s }; + assert_eq!(s.f0, "Hello, world!"); } diff --git a/src/test/run-pass/struct-order-of-eval-3.rs b/src/test/run-pass/struct-order-of-eval-3.rs new file mode 100644 index 00000000000..856ed7c105e --- /dev/null +++ b/src/test/run-pass/struct-order-of-eval-3.rs @@ -0,0 +1,46 @@ +// Copyright 2015 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. + +// Checks that functional-record-update order-of-eval is as expected +// even when no Drop-implementations are involved. + +use std::sync::atomic::{Ordering, AtomicUsize, ATOMIC_USIZE_INIT}; + +struct W { wrapped: u32 } +struct S { f0: W, _f1: i32 } + +pub fn main() { + const VAL: u32 = 0x89AB_CDEF; + let w = W { wrapped: VAL }; + let s = S { + f0: { event(0x01); W { wrapped: w.wrapped + 1 } }, + ..S { + f0: { event(0x02); w}, + _f1: 23 + } + }; + assert_eq!(s.f0.wrapped, VAL + 1); + let actual = event_log(); + let expect = 0x01_02; + assert!(expect == actual, + "expect: 0x{:x} actual: 0x{:x}", expect, actual); +} + +static LOG: AtomicUsize = ATOMIC_USIZE_INIT; + +fn event_log() -> usize { + LOG.load(Ordering::SeqCst) +} + +fn event(tag: u8) { + let old_log = LOG.load(Ordering::SeqCst); + let new_log = (old_log << 8) + tag as usize; + LOG.store(new_log, Ordering::SeqCst); +} diff --git a/src/test/run-pass/struct-order-of-eval-4.rs b/src/test/run-pass/struct-order-of-eval-4.rs new file mode 100644 index 00000000000..25923beffdd --- /dev/null +++ b/src/test/run-pass/struct-order-of-eval-4.rs @@ -0,0 +1,43 @@ +// Copyright 2015 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. + +// Checks that struct-literal expression order-of-eval is as expected +// even when no Drop-implementations are involved. + +use std::sync::atomic::{Ordering, AtomicUsize, ATOMIC_USIZE_INIT}; + +struct W { wrapped: u32 } +struct S { f0: W, _f1: i32 } + +pub fn main() { + const VAL: u32 = 0x89AB_CDEF; + let w = W { wrapped: VAL }; + let s = S { + _f1: { event(0x01); 23 }, + f0: { event(0x02); w }, + }; + assert_eq!(s.f0.wrapped, VAL); + let actual = event_log(); + let expect = 0x01_02; + assert!(expect == actual, + "expect: 0x{:x} actual: 0x{:x}", expect, actual); +} + +static LOG: AtomicUsize = ATOMIC_USIZE_INIT; + +fn event_log() -> usize { + LOG.load(Ordering::SeqCst) +} + +fn event(tag: u8) { + let old_log = LOG.load(Ordering::SeqCst); + let new_log = (old_log << 8) + tag as usize; + LOG.store(new_log, Ordering::SeqCst); +} diff --git a/src/test/run-pass/struct-return.rs b/src/test/run-pass/struct-return.rs index c8768731e2b..d67c6322c61 100644 --- a/src/test/run-pass/struct-return.rs +++ b/src/test/run-pass/struct-return.rs @@ -28,19 +28,19 @@ mod rustrt { fn test1() { unsafe { - let q = Quad { a: 0xaaaa_aaaa_aaaa_aaaa_u64, - b: 0xbbbb_bbbb_bbbb_bbbb_u64, - c: 0xcccc_cccc_cccc_cccc_u64, - d: 0xdddd_dddd_dddd_dddd_u64 }; + let q = Quad { a: 0xaaaa_aaaa_aaaa_aaaa, + b: 0xbbbb_bbbb_bbbb_bbbb, + c: 0xcccc_cccc_cccc_cccc, + d: 0xdddd_dddd_dddd_dddd }; let qq = rustrt::rust_dbg_abi_1(q); println!("a: {:x}", qq.a as uint); println!("b: {:x}", qq.b as uint); println!("c: {:x}", qq.c as uint); println!("d: {:x}", qq.d as uint); - assert_eq!(qq.a, q.c + 1u64); - assert_eq!(qq.b, q.d - 1u64); - assert_eq!(qq.c, q.a + 1u64); - assert_eq!(qq.d, q.b - 1u64); + assert_eq!(qq.a, q.c + 1); + assert_eq!(qq.b, q.d - 1); + assert_eq!(qq.c, q.a + 1); + assert_eq!(qq.d, q.b - 1); } } @@ -48,14 +48,14 @@ fn test1() { fn test2() { unsafe { let f = Floats { a: 1.234567890e-15_f64, - b: 0b_1010_1010_u8, + b: 0b_1010_1010, c: 1.0987654321e-15_f64 }; let ff = rustrt::rust_dbg_abi_2(f); println!("a: {}", ff.a as f64); println!("b: {}", ff.b as uint); println!("c: {}", ff.c as f64); assert_eq!(ff.a, f.c + 1.0f64); - assert_eq!(ff.b, 0xff_u8); + assert_eq!(ff.b, 0xff); assert_eq!(ff.c, f.a - 1.0f64); } } diff --git a/src/test/run-pass/syntax-extension-source-utils.rs b/src/test/run-pass/syntax-extension-source-utils.rs index ddd8cd8be3d..684ca7fa2b6 100644 --- a/src/test/run-pass/syntax-extension-source-utils.rs +++ b/src/test/run-pass/syntax-extension-source-utils.rs @@ -23,7 +23,7 @@ macro_rules! indirect_line { () => ( line!() ) } pub fn main() { assert_eq!(line!(), 25); - assert!((column!() == 4u32)); + assert!((column!() == 4)); assert_eq!(indirect_line!(), 27); assert!((file!().ends_with("syntax-extension-source-utils.rs"))); assert_eq!(stringify!((2*3) + 5).to_string(), "( 2 * 3 ) + 5".to_string()); diff --git a/src/test/run-pass/tag-align-dyn-u64.rs b/src/test/run-pass/tag-align-dyn-u64.rs index b7fe4983b01..8d8d4caad24 100644 --- a/src/test/run-pass/tag-align-dyn-u64.rs +++ b/src/test/run-pass/tag-align-dyn-u64.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-linux #7340 fails on 32-bit Linux -// ignore-macos #7340 fails on 32-bit macos - use std::mem; enum Tag<A> { @@ -23,15 +20,16 @@ struct Rec { } fn mk_rec() -> Rec { - return Rec { c8:0u8, t:Tag::Tag2(0u64) }; + return Rec { c8:0, t:Tag::Tag2(0) }; } -fn is_8_byte_aligned(u: &Tag<u64>) -> bool { +fn is_u64_aligned(u: &Tag<u64>) -> bool { let p: uint = unsafe { mem::transmute(u) }; - return (p & 7_usize) == 0_usize; + let u64_align = std::mem::min_align_of::<u64>(); + return (p & (u64_align - 1)) == 0; } pub fn main() { let x = mk_rec(); - assert!(is_8_byte_aligned(&x.t)); + assert!(is_u64_aligned(&x.t)); } diff --git a/src/test/run-pass/tag-align-dyn-variants.rs b/src/test/run-pass/tag-align-dyn-variants.rs index cb298e720ed..917f2c5b374 100644 --- a/src/test/run-pass/tag-align-dyn-variants.rs +++ b/src/test/run-pass/tag-align-dyn-variants.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-linux #7340 fails on 32-bit Linux -// ignore-macos #7340 fails on 32-bit macos - use std::mem; enum Tag<A,B> { @@ -26,12 +23,12 @@ struct Rec<A,B> { } fn mk_rec<A,B>(a: A, b: B) -> Rec<A,B> { - Rec { chA:0u8, tA:Tag::VarA(a), chB:1u8, tB:Tag::VarB(b) } + Rec { chA:0, tA:Tag::VarA(a), chB:1, tB:Tag::VarB(b) } } fn is_aligned<A>(amnt: uint, u: &A) -> bool { let p: uint = unsafe { mem::transmute(u) }; - return (p & (amnt-1_usize)) == 0_usize; + return (p & (amnt-1)) == 0; } fn variant_data_is_aligned<A,B>(amnt: uint, u: &Tag<A,B>) -> bool { @@ -42,33 +39,34 @@ fn variant_data_is_aligned<A,B>(amnt: uint, u: &Tag<A,B>) -> bool { } pub fn main() { + let u64_align = std::mem::min_align_of::<u64>(); let x = mk_rec(22u64, 23u64); - assert!(is_aligned(8_usize, &x.tA)); - assert!(variant_data_is_aligned(8_usize, &x.tA)); - assert!(is_aligned(8_usize, &x.tB)); - assert!(variant_data_is_aligned(8_usize, &x.tB)); + assert!(is_aligned(u64_align, &x.tA)); + assert!(variant_data_is_aligned(u64_align, &x.tA)); + assert!(is_aligned(u64_align, &x.tB)); + assert!(variant_data_is_aligned(u64_align, &x.tB)); let x = mk_rec(22u64, 23u32); - assert!(is_aligned(8_usize, &x.tA)); - assert!(variant_data_is_aligned(8_usize, &x.tA)); - assert!(is_aligned(8_usize, &x.tB)); - assert!(variant_data_is_aligned(4_usize, &x.tB)); + assert!(is_aligned(u64_align, &x.tA)); + assert!(variant_data_is_aligned(u64_align, &x.tA)); + assert!(is_aligned(u64_align, &x.tB)); + assert!(variant_data_is_aligned(4, &x.tB)); let x = mk_rec(22u32, 23u64); - assert!(is_aligned(8_usize, &x.tA)); - assert!(variant_data_is_aligned(4_usize, &x.tA)); - assert!(is_aligned(8_usize, &x.tB)); - assert!(variant_data_is_aligned(8_usize, &x.tB)); + assert!(is_aligned(u64_align, &x.tA)); + assert!(variant_data_is_aligned(4, &x.tA)); + assert!(is_aligned(u64_align, &x.tB)); + assert!(variant_data_is_aligned(u64_align, &x.tB)); let x = mk_rec(22u32, 23u32); - assert!(is_aligned(4_usize, &x.tA)); - assert!(variant_data_is_aligned(4_usize, &x.tA)); - assert!(is_aligned(4_usize, &x.tB)); - assert!(variant_data_is_aligned(4_usize, &x.tB)); + assert!(is_aligned(4, &x.tA)); + assert!(variant_data_is_aligned(4, &x.tA)); + assert!(is_aligned(4, &x.tB)); + assert!(variant_data_is_aligned(4, &x.tB)); let x = mk_rec(22f64, 23f64); - assert!(is_aligned(8_usize, &x.tA)); - assert!(variant_data_is_aligned(8_usize, &x.tA)); - assert!(is_aligned(8_usize, &x.tB)); - assert!(variant_data_is_aligned(8_usize, &x.tB)); + assert!(is_aligned(u64_align, &x.tA)); + assert!(variant_data_is_aligned(u64_align, &x.tA)); + assert!(is_aligned(u64_align, &x.tB)); + assert!(variant_data_is_aligned(u64_align, &x.tB)); } diff --git a/src/test/run-pass/tag-align-shape.rs b/src/test/run-pass/tag-align-shape.rs index cc0a75181db..5db886c815b 100644 --- a/src/test/run-pass/tag-align-shape.rs +++ b/src/test/run-pass/tag-align-shape.rs @@ -20,7 +20,7 @@ struct t_rec { } pub fn main() { - let x = t_rec {c8: 22u8, t: a_tag::a_tag_var(44u64)}; + let x = t_rec {c8: 22, t: a_tag::a_tag_var(44)}; let y = format!("{:?}", x); println!("y = {:?}", y); assert_eq!(y, "t_rec { c8: 22, t: a_tag_var(44) }".to_string()); diff --git a/src/test/run-pass/tag-align-u64.rs b/src/test/run-pass/tag-align-u64.rs index 713f55cc10c..df99d77142c 100644 --- a/src/test/run-pass/tag-align-u64.rs +++ b/src/test/run-pass/tag-align-u64.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-linux #7340 fails on 32-bit Linux -// ignore-macos #7340 fails on 32-bit macos - use std::mem; enum Tag { @@ -23,15 +20,16 @@ struct Rec { } fn mk_rec() -> Rec { - return Rec { c8:0u8, t:Tag::TagInner(0u64) }; + return Rec { c8:0, t:Tag::TagInner(0) }; } -fn is_8_byte_aligned(u: &Tag) -> bool { +fn is_u64_aligned(u: &Tag) -> bool { let p: uint = unsafe { mem::transmute(u) }; - return (p & 7_usize) == 0_usize; + let u64_align = std::mem::min_align_of::<u64>(); + return (p & (u64_align - 1)) == 0; } pub fn main() { let x = mk_rec(); - assert!(is_8_byte_aligned(&x.t)); + assert!(is_u64_aligned(&x.t)); } diff --git a/src/test/run-pass/task-comm-16.rs b/src/test/run-pass/task-comm-16.rs index 1d297c04c82..ca009677ee9 100644 --- a/src/test/run-pass/task-comm-16.rs +++ b/src/test/run-pass/task-comm-16.rs @@ -16,12 +16,12 @@ fn test_rec() { struct R {val0: int, val1: u8, val2: char} let (tx, rx) = channel(); - let r0: R = R {val0: 0, val1: 1u8, val2: '2'}; + let r0: R = R {val0: 0, val1: 1, val2: '2'}; tx.send(r0).unwrap(); let mut r1: R; r1 = rx.recv().unwrap(); assert_eq!(r1.val0, 0); - assert_eq!(r1.val1, 1u8); + assert_eq!(r1.val1, 1); assert_eq!(r1.val2, '2'); } @@ -84,14 +84,14 @@ fn test_tag() { let (tx, rx) = channel(); tx.send(t::tag1).unwrap(); tx.send(t::tag2(10)).unwrap(); - tx.send(t::tag3(10, 11u8, 'A')).unwrap(); + tx.send(t::tag3(10, 11, 'A')).unwrap(); let mut t1: t; t1 = rx.recv().unwrap(); assert_eq!(t1, t::tag1); t1 = rx.recv().unwrap(); assert_eq!(t1, t::tag2(10)); t1 = rx.recv().unwrap(); - assert_eq!(t1, t::tag3(10, 11u8, 'A')); + assert_eq!(t1, t::tag3(10, 11, 'A')); } fn test_chan() { diff --git a/src/test/run-pass/tcp-stress.rs b/src/test/run-pass/tcp-stress.rs index 82584c83de0..23ea998c026 100644 --- a/src/test/run-pass/tcp-stress.rs +++ b/src/test/run-pass/tcp-stress.rs @@ -52,7 +52,7 @@ fn main() { let addr = rx.recv().unwrap(); let (tx, rx) = channel(); - for _ in 0_usize..1000 { + for _ in 0..1000 { let tx = tx.clone(); Builder::new().stack_size(64 * 1024).spawn(move|| { match TcpStream::connect(addr) { @@ -71,7 +71,7 @@ fn main() { // Wait for all clients to exit, but don't wait for the server to exit. The // server just runs infinitely. drop(tx); - for _ in 0_usize..1000 { + for _ in 0..1000 { rx.recv().unwrap(); } unsafe { libc::exit(0) } diff --git a/src/test/run-pass/test-should-fail-good-message.rs b/src/test/run-pass/test-should-fail-good-message.rs index dcb2fe6dfc0..b8e05b4d35a 100644 --- a/src/test/run-pass/test-should-fail-good-message.rs +++ b/src/test/run-pass/test-should-fail-good-message.rs @@ -12,13 +12,13 @@ // ignore-pretty: does not work well with `--test` #[test] -#[should_fail(expected = "foo")] +#[should_panic(expected = "foo")] fn test_foo() { panic!("foo bar") } #[test] -#[should_fail(expected = "foo")] +#[should_panic(expected = "foo")] fn test_foo_dynamic() { panic!("{} bar", "foo") } diff --git a/src/test/run-pass/trait-default-method-bound-subst4.rs b/src/test/run-pass/trait-default-method-bound-subst4.rs index 383849ca512..acaa74373f0 100644 --- a/src/test/run-pass/trait-default-method-bound-subst4.rs +++ b/src/test/run-pass/trait-default-method-bound-subst4.rs @@ -21,6 +21,6 @@ fn f<T, V: A<T>>(i: V, j: uint) -> uint { } pub fn main () { - assert_eq!(f::<f64, int>(0, 2_usize), 2_usize); - assert_eq!(f::<uint, int>(0, 2_usize), 2_usize); + assert_eq!(f::<f64, int>(0, 2), 2); + assert_eq!(f::<uint, int>(0, 2), 2); } diff --git a/src/test/run-pass/trait-object-generics.rs b/src/test/run-pass/trait-object-generics.rs index 6f89490716f..18097b59b08 100644 --- a/src/test/run-pass/trait-object-generics.rs +++ b/src/test/run-pass/trait-object-generics.rs @@ -49,5 +49,5 @@ impl<V> Trait<u8,V> for () { pub fn main() { let a = box() () as Box<Trait<u8, u8>>; - assert_eq!(a.method(Type::Constant((1u8, 2u8))), 0); + assert_eq!(a.method(Type::Constant((1, 2))), 0); } diff --git a/src/test/run-pass/trait-object-with-lifetime-bound.rs b/src/test/run-pass/trait-object-with-lifetime-bound.rs index 4e481910aa9..99910f15738 100644 --- a/src/test/run-pass/trait-object-with-lifetime-bound.rs +++ b/src/test/run-pass/trait-object-with-lifetime-bound.rs @@ -36,7 +36,7 @@ fn extension<'e>(x: &'e E<'e>) -> Box<M+'e> { } fn main() { - let w = E { f: &10u8 }; + let w = E { f: &10 }; let o = extension(&w); - assert_eq!(o.n(), 10u8); + assert_eq!(o.n(), 10); } diff --git a/src/test/run-pass/traits-assoc-type-in-supertrait.rs b/src/test/run-pass/traits-assoc-type-in-supertrait.rs new file mode 100644 index 00000000000..6a4a6710131 --- /dev/null +++ b/src/test/run-pass/traits-assoc-type-in-supertrait.rs @@ -0,0 +1,31 @@ +// Copyright 2015 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. + +// Test case where an associated type is referenced from within the +// supertrait definition. Issue #20220. + +use std::vec::IntoIter; + +pub trait Foo: Iterator<Item=<Self as Foo>::Key> { + type Key; +} + +impl Foo for IntoIter<i32> { + type Key = i32; +} + +fn sum_foo<F:Foo<Key=i32>>(f: F) -> i32 { + f.fold(0, |a,b| a + b) +} + +fn main() { + let x = sum_foo(vec![11, 10, 1].into_iter()); + assert_eq!(x, 22); +} diff --git a/src/test/run-pass/traits-issue-23003.rs b/src/test/run-pass/traits-issue-23003.rs new file mode 100644 index 00000000000..37b13d319aa --- /dev/null +++ b/src/test/run-pass/traits-issue-23003.rs @@ -0,0 +1,39 @@ +// Copyright 2015 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. + +// Test stack overflow triggered by evaluating the implications. To be +// WF, the type `Receipt<Complete>` would require that `<Complete as +// Async>::Cancel` be WF. This normalizes to `Receipt<Complete>` +// again, leading to an infinite cycle. Issue #23003. + +#![allow(dead_code)] +#![allow(unused_variables)] + +use std::marker::PhantomData; + +trait Async { + type Cancel; +} + +struct Receipt<A:Async> { + marker: PhantomData<A>, +} + +struct Complete { + core: Option<()>, +} + +impl Async for Complete { + type Cancel = Receipt<Complete>; +} + +fn foo(r: Receipt<Complete>) { } + +fn main() { } diff --git a/src/test/run-pass/traits-repeated-supertrait.rs b/src/test/run-pass/traits-repeated-supertrait.rs new file mode 100644 index 00000000000..fdaa8d6f4d6 --- /dev/null +++ b/src/test/run-pass/traits-repeated-supertrait.rs @@ -0,0 +1,56 @@ +// Copyright 2015 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. + +// Test a case of a trait which extends the same supertrait twice, but +// with difference type parameters. Test that we can invoke the +// various methods in various ways successfully. +// See also `compile-fail/trait-repeated-supertrait-ambig.rs`. + +trait CompareTo<T> { + fn same_as(&self, t: T) -> bool; +} + +trait CompareToInts : CompareTo<i64> + CompareTo<u64> { +} + +impl CompareTo<i64> for i64 { + fn same_as(&self, t: i64) -> bool { *self == t } +} + +impl CompareTo<u64> for i64 { + fn same_as(&self, t: u64) -> bool { *self == (t as i64) } +} + +impl CompareToInts for i64 { } + +fn with_obj(c: &CompareToInts) -> bool { + c.same_as(22_i64) && c.same_as(22_u64) +} + +fn with_trait<C:CompareToInts>(c: &C) -> bool { + c.same_as(22_i64) && c.same_as(22_u64) +} + +fn with_ufcs1<C:CompareToInts>(c: &C) -> bool { + CompareToInts::same_as(c, 22_i64) && CompareToInts::same_as(c, 22_u64) +} + +fn with_ufcs2<C:CompareToInts>(c: &C) -> bool { + CompareTo::same_as(c, 22_i64) && CompareTo::same_as(c, 22_u64) +} + +fn main() { + assert_eq!(22_i64.same_as(22_i64), true); + assert_eq!(22_i64.same_as(22_u64), true); + assert_eq!(with_trait(&22), true); + assert_eq!(with_obj(&22), true); + assert_eq!(with_ufcs1(&22), true); + assert_eq!(with_ufcs2(&22), true); +} diff --git a/src/test/run-pass/type-params-in-for-each.rs b/src/test/run-pass/type-params-in-for-each.rs index cf8a09998da..5d80cec2a05 100644 --- a/src/test/run-pass/type-params-in-for-each.rs +++ b/src/test/run-pass/type-params-in-for-each.rs @@ -16,11 +16,11 @@ struct S<T> { fn range_<F>(lo: uint, hi: uint, mut it: F) where F: FnMut(uint) { let mut lo_ = lo; - while lo_ < hi { it(lo_); lo_ += 1_usize; } + while lo_ < hi { it(lo_); lo_ += 1; } } fn create_index<T>(_index: Vec<S<T>> , _hash_fn: extern fn(T) -> uint) { - range_(0_usize, 256_usize, |_i| { + range_(0, 256, |_i| { let _bucket: Vec<T> = Vec::new(); }) } diff --git a/src/test/run-pass/typeck_type_placeholder_1.rs b/src/test/run-pass/typeck_type_placeholder_1.rs index 48dc9443821..c850c01753b 100644 --- a/src/test/run-pass/typeck_type_placeholder_1.rs +++ b/src/test/run-pass/typeck_type_placeholder_1.rs @@ -21,17 +21,17 @@ static CONSTEXPR: TestStruct = TestStruct{x: &413 as *const _}; pub fn main() { - let x: Vec<_> = (0_usize..5).collect(); + let x: Vec<_> = (0..5).collect(); let expected: &[uint] = &[0,1,2,3,4]; assert_eq!(x, expected); - let x = (0_usize..5).collect::<Vec<_>>(); + let x = (0..5).collect::<Vec<_>>(); assert_eq!(x, expected); let y: _ = "hello"; assert_eq!(y.len(), 5); - let ptr = &5_usize; + let ptr = &5; let ptr2 = ptr as *const _; assert_eq!(ptr as *const uint as uint, ptr2 as uint); diff --git a/src/test/run-pass/u32-decr.rs b/src/test/run-pass/u32-decr.rs index 6ad320580df..027bd7ca680 100644 --- a/src/test/run-pass/u32-decr.rs +++ b/src/test/run-pass/u32-decr.rs @@ -12,7 +12,7 @@ pub fn main() { - let mut word: u32 = 200000u32; - word = word - 1u32; - assert_eq!(word, 199999u32); + let mut word: u32 = 200000; + word = word - 1; + assert_eq!(word, 199999); } diff --git a/src/test/run-pass/u8-incr-decr.rs b/src/test/run-pass/u8-incr-decr.rs index 0a178b250af..ff25d95d1fd 100644 --- a/src/test/run-pass/u8-incr-decr.rs +++ b/src/test/run-pass/u8-incr-decr.rs @@ -15,13 +15,13 @@ // These constants were chosen because they aren't used anywhere // in the rest of the generated code so they're easily grep-able. pub fn main() { - let mut x: u8 = 19u8; // 0x13 + let mut x: u8 = 19; // 0x13 - let mut y: u8 = 35u8; // 0x23 + let mut y: u8 = 35; // 0x23 - x = x + 7u8; // 0x7 + x = x + 7; // 0x7 - y = y - 9u8; // 0x9 + y = y - 9; // 0x9 assert_eq!(x, y); } diff --git a/src/test/run-pass/u8-incr.rs b/src/test/run-pass/u8-incr.rs index 90ed3a5eec3..7f69d078134 100644 --- a/src/test/run-pass/u8-incr.rs +++ b/src/test/run-pass/u8-incr.rs @@ -12,12 +12,12 @@ pub fn main() { - let mut x: u8 = 12u8; - let y: u8 = 12u8; - x = x + 1u8; - x = x - 1u8; + let mut x: u8 = 12; + let y: u8 = 12; + x = x + 1; + x = x - 1; assert_eq!(x, y); - // x = 14u8; - // x = x + 1u8; + // x = 14; + // x = x + 1; } diff --git a/src/test/run-pass/ufcs-trait-object.rs b/src/test/run-pass/ufcs-trait-object.rs index 2ae63040d17..34cf44bba2e 100644 --- a/src/test/run-pass/ufcs-trait-object.rs +++ b/src/test/run-pass/ufcs-trait-object.rs @@ -20,6 +20,6 @@ impl Foo for i32 { } fn main() { - let a: &Foo = &22_i32; + let a: &Foo = &22; assert_eq!(Foo::test(a), 22); } diff --git a/src/test/run-pass/unboxed-closures-unique-type-id.rs b/src/test/run-pass/unboxed-closures-unique-type-id.rs index 5c36832d9f6..ce05f077357 100644 --- a/src/test/run-pass/unboxed-closures-unique-type-id.rs +++ b/src/test/run-pass/unboxed-closures-unique-type-id.rs @@ -12,8 +12,8 @@ // // error: internal compiler error: get_unique_type_id_of_type() - // unexpected type: closure, -// ty_closure(syntax::ast::DefId{krate: 0u32, node: 66u32}, -// ReScope(63u32)) +// ty_closure(syntax::ast::DefId{krate: 0, node: 66}, +// ReScope(63)) // // This is a regression test for issue #17021. // @@ -28,8 +28,8 @@ pub fn replace_map<'a, T, F>(src: &mut T, prod: F) where F: FnOnce(T) -> T { } pub fn main() { - let mut a = 7_usize; + let mut a = 7; let b = &mut a; replace_map(b, |x: uint| x * 2); - assert_eq!(*b, 14_usize); + assert_eq!(*b, 14); } diff --git a/src/test/run-pass/unique-pat-2.rs b/src/test/run-pass/unique-pat-2.rs index 5db96bc3564..8141e3bce3c 100644 --- a/src/test/run-pass/unique-pat-2.rs +++ b/src/test/run-pass/unique-pat-2.rs @@ -17,7 +17,7 @@ struct Foo {a: int, b: uint} enum bar { u(Box<Foo>), w(int), } pub fn main() { - assert!(match bar::u(box Foo{a: 10, b: 40_usize}) { + assert!(match bar::u(box Foo{a: 10, b: 40}) { bar::u(box Foo{a: a, b: b}) => { a + (b as int) } _ => { 66 } } == 50); diff --git a/src/test/run-pass/unique-send-2.rs b/src/test/run-pass/unique-send-2.rs index 43824812ec5..654ac9a095c 100644 --- a/src/test/run-pass/unique-send-2.rs +++ b/src/test/run-pass/unique-send-2.rs @@ -20,9 +20,9 @@ fn child(tx: &Sender<Box<uint>>, i: uint) { pub fn main() { let (tx, rx) = channel(); - let n = 100_usize; - let mut expected = 0_usize; - let _t = (0_usize..n).map(|i| { + let n = 100; + let mut expected = 0; + let _t = (0..n).map(|i| { expected += i; let tx = tx.clone(); thread::spawn(move|| { @@ -30,8 +30,8 @@ pub fn main() { }) }).collect::<Vec<_>>(); - let mut actual = 0_usize; - for _ in 0_usize..n { + let mut actual = 0; + for _ in 0..n { let j = rx.recv().unwrap(); actual += *j; } diff --git a/src/test/run-pass/unsized.rs b/src/test/run-pass/unsized.rs index ae175d27b0a..1a479d05d50 100644 --- a/src/test/run-pass/unsized.rs +++ b/src/test/run-pass/unsized.rs @@ -7,8 +7,6 @@ // <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. -// -// ignore-lexer-test FIXME #15879 // Test syntax checks for `?Sized` syntax. diff --git a/src/test/run-pass/unsized2.rs b/src/test/run-pass/unsized2.rs index 10b2f2fb709..e0d37ff40de 100644 --- a/src/test/run-pass/unsized2.rs +++ b/src/test/run-pass/unsized2.rs @@ -7,8 +7,6 @@ // <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. -// -// ignore-lexer-test FIXME #15879 #![allow(unknown_features)] #![feature(box_syntax)] diff --git a/src/test/run-pass/unsized3.rs b/src/test/run-pass/unsized3.rs index c9a9d6ad147..5bd76d093d4 100644 --- a/src/test/run-pass/unsized3.rs +++ b/src/test/run-pass/unsized3.rs @@ -66,12 +66,10 @@ pub fn main() { f: [T; 3] } - let data: Box<_> = box Foo_{f: [1i32, 2, 3] }; + let data: Box<Foo_<i32>> = box Foo_{f: [1, 2, 3] }; let x: &Foo<i32> = mem::transmute(raw::Slice { len: 3, data: &*data }); assert!(x.f.len() == 3); assert!(x.f[0] == 1); - assert!(x.f[1] == 2); - assert!(x.f[2] == 3); struct Baz_ { f1: uint, diff --git a/src/test/run-pass/utf8.rs b/src/test/run-pass/utf8.rs index 96bba01068f..4be54bd7080 100644 --- a/src/test/run-pass/utf8.rs +++ b/src/test/run-pass/utf8.rs @@ -24,7 +24,7 @@ pub fn main() { assert_eq!(y_diaeresis as int, 0xff); assert_eq!(pi as int, 0x3a0); - assert_eq!(pi as int, '\u03a0' as int); + assert_eq!(pi as int, '\u{3a0}' as int); assert_eq!('\x0a' as int, '\n' as int); let bhutan: String = "འབྲུག་ཡུལ།".to_string(); @@ -33,11 +33,11 @@ pub fn main() { let austria: String = "Österreich".to_string(); let bhutan_e: String = - "\u0f60\u0f56\u0fb2\u0f74\u0f42\u0f0b\u0f61\u0f74\u0f63\u0f0d".to_string(); - let japan_e: String = "\u65e5\u672c".to_string(); + "\u{f60}\u{f56}\u{fb2}\u{f74}\u{f42}\u{f0b}\u{f61}\u{f74}\u{f63}\u{f0d}".to_string(); + let japan_e: String = "\u{65e5}\u{672c}".to_string(); let uzbekistan_e: String = - "\u040e\u0437\u0431\u0435\u043a\u0438\u0441\u0442\u043e\u043d".to_string(); - let austria_e: String = "\u00d6sterreich".to_string(); + "\u{40e}\u{437}\u{431}\u{435}\u{43a}\u{438}\u{441}\u{442}\u{43e}\u{43d}".to_string(); + let austria_e: String = "\u{d6}sterreich".to_string(); let oo: char = 'Ö'; assert_eq!(oo as int, 0xd6); diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs index 84f605eef57..c54b3b69c68 100644 --- a/src/test/run-pass/utf8_chars.rs +++ b/src/test/run-pass/utf8_chars.rs @@ -14,30 +14,30 @@ use std::str; pub fn main() { // Chars of 1, 2, 3, and 4 bytes - let chs: Vec<char> = vec!('e', 'é', '€', '\U00010000'); + let chs: Vec<char> = vec!('e', 'é', '€', '\u{10000}'); let s: String = chs.iter().cloned().collect(); let schs: Vec<char> = s.chars().collect(); - assert!(s.len() == 10_usize); - assert!(s.chars().count() == 4_usize); - assert!(schs.len() == 4_usize); + assert!(s.len() == 10); + assert!(s.chars().count() == 4); + assert!(schs.len() == 4); assert!(schs.iter().cloned().collect::<String>() == s); - assert!(s.char_at(0_usize) == 'e'); - assert!(s.char_at(1_usize) == 'é'); + assert!(s.char_at(0) == 'e'); + assert!(s.char_at(1) == 'é'); assert!((str::from_utf8(s.as_bytes()).is_ok())); // invalid prefix - assert!((!str::from_utf8(&[0x80_u8]).is_ok())); + assert!((!str::from_utf8(&[0x80]).is_ok())); // invalid 2 byte prefix - assert!((!str::from_utf8(&[0xc0_u8]).is_ok())); - assert!((!str::from_utf8(&[0xc0_u8, 0x10_u8]).is_ok())); + assert!((!str::from_utf8(&[0xc0]).is_ok())); + assert!((!str::from_utf8(&[0xc0, 0x10]).is_ok())); // invalid 3 byte prefix - assert!((!str::from_utf8(&[0xe0_u8]).is_ok())); - assert!((!str::from_utf8(&[0xe0_u8, 0x10_u8]).is_ok())); - assert!((!str::from_utf8(&[0xe0_u8, 0xff_u8, 0x10_u8]).is_ok())); + assert!((!str::from_utf8(&[0xe0]).is_ok())); + assert!((!str::from_utf8(&[0xe0, 0x10]).is_ok())); + assert!((!str::from_utf8(&[0xe0, 0xff, 0x10]).is_ok())); // invalid 4 byte prefix - assert!((!str::from_utf8(&[0xf0_u8]).is_ok())); - assert!((!str::from_utf8(&[0xf0_u8, 0x10_u8]).is_ok())); - assert!((!str::from_utf8(&[0xf0_u8, 0xff_u8, 0x10_u8]).is_ok())); - assert!((!str::from_utf8(&[0xf0_u8, 0xff_u8, 0xff_u8, 0x10_u8]).is_ok())); + assert!((!str::from_utf8(&[0xf0]).is_ok())); + assert!((!str::from_utf8(&[0xf0, 0x10]).is_ok())); + assert!((!str::from_utf8(&[0xf0, 0xff, 0x10]).is_ok())); + assert!((!str::from_utf8(&[0xf0, 0xff, 0xff, 0x10]).is_ok())); } diff --git a/src/test/run-pass/variadic-ffi.rs b/src/test/run-pass/variadic-ffi.rs index 5a476ed9ee2..b3fff6977a5 100644 --- a/src/test/run-pass/variadic-ffi.rs +++ b/src/test/run-pass/variadic-ffi.rs @@ -13,7 +13,6 @@ extern crate libc; use std::ffi::{self, CString}; use libc::{c_char, c_int}; -// ignore-fast doesn't like extern crate extern { fn sprintf(s: *mut c_char, format: *const c_char, ...) -> c_int; diff --git a/src/test/run-pass/vec-fixed-length.rs b/src/test/run-pass/vec-fixed-length.rs index 015baea5fb5..a0b3564d84e 100644 --- a/src/test/run-pass/vec-fixed-length.rs +++ b/src/test/run-pass/vec-fixed-length.rs @@ -17,11 +17,11 @@ pub fn main() { assert_eq!(x[2], 3); assert_eq!(x[3], 4); - assert_eq!(size_of::<[u8; 4]>(), 4_usize); + assert_eq!(size_of::<[u8; 4]>(), 4); // FIXME #10183 // FIXME #18069 //if cfg!(target_pointer_width = "64") { - // assert_eq!(size_of::<[u8; (1 << 32)]>(), (1_usize << 32)); + // assert_eq!(size_of::<[u8; (1 << 32)]>(), (1 << 32)); //} } diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index baea1b8826a..20e42575b27 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -65,7 +65,7 @@ fn canttouchthis() -> uint { fn p() -> bool { true } let _a = (assert!((true)) == (assert!(p()))); let _c = (assert!((p())) == ()); - let _b: bool = (println!("{}", 0) == (return 0_usize)); + let _b: bool = (println!("{}", 0) == (return 0)); } fn angrydome() { diff --git a/src/test/run-pass/where-for-self.rs b/src/test/run-pass/where-for-self.rs index 1fd223b0dd3..67757d7efa8 100644 --- a/src/test/run-pass/where-for-self.rs +++ b/src/test/run-pass/where-for-self.rs @@ -55,7 +55,7 @@ fn foo2<T>(x: &T) } fn main() { - let x = 42u32; + let x = 42; foo1(&x); foo2(&x); unsafe { diff --git a/src/test/run-pass/x86stdcall.rs b/src/test/run-pass/x86stdcall.rs index dea58c8e86f..b884adb7a6e 100644 --- a/src/test/run-pass/x86stdcall.rs +++ b/src/test/run-pass/x86stdcall.rs @@ -22,7 +22,7 @@ mod kernel32 { #[cfg(windows)] pub fn main() { unsafe { - let expected = 1234_usize; + let expected = 1234; kernel32::SetLastError(expected); let actual = kernel32::GetLastError(); println!("actual = {}", actual); diff --git a/src/test/run-pass/x86stdcall2.rs b/src/test/run-pass/x86stdcall2.rs index 86c1ae0f51f..b5b9d95d87f 100644 --- a/src/test/run-pass/x86stdcall2.rs +++ b/src/test/run-pass/x86stdcall2.rs @@ -30,10 +30,10 @@ mod kernel32 { #[cfg(windows)] pub fn main() { let heap = unsafe { kernel32::GetProcessHeap() }; - let mem = unsafe { kernel32::HeapAlloc(heap, 0u32, 100u32) }; - assert!(mem != 0_usize); - let res = unsafe { kernel32::HeapFree(heap, 0u32, mem) }; - assert!(res != 0u8); + let mem = unsafe { kernel32::HeapAlloc(heap, 0, 100) }; + assert!(mem != 0); + let res = unsafe { kernel32::HeapFree(heap, 0, mem) }; + assert!(res != 0); } #[cfg(not(windows))] |
