Merge remote-tracking branch 'rust-lang/master'

Conflicts:
	mk/tests.mk
	src/liballoc/arc.rs
	src/liballoc/boxed.rs
	src/liballoc/rc.rs
	src/libcollections/bit.rs
	src/libcollections/btree/map.rs
	src/libcollections/btree/set.rs
	src/libcollections/dlist.rs
	src/libcollections/ring_buf.rs
	src/libcollections/slice.rs
	src/libcollections/str.rs
	src/libcollections/string.rs
	src/libcollections/vec.rs
	src/libcollections/vec_map.rs
	src/libcore/any.rs
	src/libcore/array.rs
	src/libcore/borrow.rs
	src/libcore/error.rs
	src/libcore/fmt/mod.rs
	src/libcore/iter.rs
	src/libcore/marker.rs
	src/libcore/ops.rs
	src/libcore/result.rs
	src/libcore/slice.rs
	src/libcore/str/mod.rs
	src/libregex/lib.rs
	src/libregex/re.rs
	src/librustc/lint/builtin.rs
	src/libstd/collections/hash/map.rs
	src/libstd/collections/hash/set.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/mutex.rs
	src/libstd/sync/poison.rs
	src/libstd/sync/rwlock.rs
	src/libsyntax/feature_gate.rs
	src/libsyntax/test.rs
This commit is contained in:
Brian Anderson 2015-01-24 09:15:42 -08:00
commit 63fcbcf3ce
433 changed files with 7348 additions and 12011 deletions

View file

@ -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,4 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub fn bar() {}
#![crate_type="lib"]
pub const X: () = ();

View file

@ -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,4 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub fn foo() {}
#![crate_type="lib"]
pub const Y: () = ();

View file

@ -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.
#![crate_type = "lib"]
#[macro_export]
macro_rules! declare {
() => (
pub fn aaa() {}
pub mod bbb {
use super::aaa;
pub fn ccc() {
aaa();
}
}
)
}

View file

@ -20,7 +20,7 @@ use syntax::codemap::Span;
use syntax::parse::token;
use syntax::ast::{TokenTree, TtToken};
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacExpr};
use syntax::ext::build::AstBuilder; // trait for expr_uint
use syntax::ext::build::AstBuilder; // trait for expr_usize
use rustc::plugin::Registry;
// WARNING WARNING WARNING WARNING WARNING
@ -61,7 +61,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
}
}
MacExpr::new(cx.expr_uint(sp, total))
MacExpr::new(cx.expr_usize(sp, total))
}
#[plugin_registrar]

View file

@ -41,7 +41,7 @@
extern crate arena;
use std::iter::range_step;
use std::thread::Thread;
use std::thread::{Thread, JoinGuard};
use arena::TypedArena;
struct Tree<'a> {
@ -71,6 +71,18 @@ fn bottom_up_tree<'r>(arena: &'r TypedArena<Tree<'r>>, item: i32, depth: i32)
}
}
fn inner(depth: i32, iterations: i32) -> String {
let mut chk = 0;
for i in 1 .. iterations + 1 {
let arena = TypedArena::new();
let a = bottom_up_tree(&arena, i, depth);
let b = bottom_up_tree(&arena, -i, depth);
chk += item_check(&a) + item_check(&b);
}
format!("{}\t trees of depth {}\t check: {}",
iterations * 2, depth, chk)
}
fn main() {
let args = std::os::args();
let args = args.as_slice();
@ -97,20 +109,10 @@ fn main() {
let long_lived_tree = bottom_up_tree(&long_lived_arena, 0, max_depth);
let messages = range_step(min_depth, max_depth + 1, 2).map(|depth| {
use std::num::Int;
let iterations = 2.pow((max_depth - depth + min_depth) as usize);
Thread::scoped(move|| {
let mut chk = 0;
for i in 1 .. iterations + 1 {
let arena = TypedArena::new();
let a = bottom_up_tree(&arena, i, depth);
let b = bottom_up_tree(&arena, -i, depth);
chk += item_check(&a) + item_check(&b);
}
format!("{}\t trees of depth {}\t check: {}",
iterations * 2, depth, chk)
})
}).collect::<Vec<_>>();
use std::num::Int;
let iterations = 2.pow((max_depth - depth + min_depth) as usize);
Thread::scoped(move || inner(depth, iterations))
}).collect::<Vec<_>>();
for message in messages.into_iter() {
println!("{}", message.join().ok().unwrap());

View file

@ -103,7 +103,7 @@ impl Perm {
let d = idx / self.fact[i] as i32;
self.cnt[i] = d;
idx %= self.fact[i] as i32;
for (place, val) in pp.iter_mut().zip(self.perm.p[..(i+1)].iter()) {
for (place, val) in pp.iter_mut().zip(self.perm.p[..i+1].iter()) {
*place = (*val) as u8
}

View file

@ -97,7 +97,7 @@ fn make_fasta<W: Writer, I: Iterator<Item=u8>>(
}
n -= nb;
line[nb] = '\n' as u8;
try!(wr.write(&line[..(nb+1)]));
try!(wr.write(&line[..nb+1]));
}
Ok(())
}

View file

@ -101,11 +101,11 @@ fn windows_with_carry<F>(bb: &[u8], nn: uint, mut it: F) -> Vec<u8> where
let len = bb.len();
while ii < len - (nn - 1u) {
it(&bb[ii..(ii+nn)]);
it(&bb[ii..ii+nn]);
ii += 1u;
}
return bb[(len - (nn - 1u))..len].to_vec();
return bb[len - (nn - 1u)..len].to_vec();
}
fn make_sequence_processor(sz: uint,

View file

@ -1,126 +0,0 @@
// The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by the Rust Project Developers
// Copyright (c) 2014 The Rust Project Developers
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// - Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
//
// - Neither the name of "The Computer Language Benchmarks Game" nor
// the name of "The Computer Language Shootout Benchmarks" nor the
// names of its contributors may be used to endorse or promote
// products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
// ignore-stage1
// ignore-cross-compile #12102
#![feature(box_syntax)]
extern crate regex;
use std::io;
use regex::{NoExpand, Regex};
use std::sync::{Arc, Future};
macro_rules! regex {
($e:expr) => (Regex::new($e).unwrap())
}
fn count_matches(seq: &str, variant: &Regex) -> int {
let mut n = 0;
for _ in variant.find_iter(seq) {
n += 1;
}
n
}
fn main() {
let mut rdr = if std::os::getenv("RUST_BENCH").is_some() {
let fd = io::File::open(&Path::new("shootout-k-nucleotide.data"));
box io::BufferedReader::new(fd) as Box<io::Reader>
} else {
box io::stdin() as Box<io::Reader>
};
let mut seq = rdr.read_to_string().unwrap();
let ilen = seq.len();
seq = regex!(">[^\n]*\n|\n").replace_all(seq.as_slice(), NoExpand(""));
let seq_arc = Arc::new(seq.clone()); // copy before it moves
let clen = seq.len();
let mut seqlen = Future::spawn(move|| {
let substs = vec![
(regex!("B"), "(c|g|t)"),
(regex!("D"), "(a|g|t)"),
(regex!("H"), "(a|c|t)"),
(regex!("K"), "(g|t)"),
(regex!("M"), "(a|c)"),
(regex!("N"), "(a|c|g|t)"),
(regex!("R"), "(a|g)"),
(regex!("S"), "(c|g)"),
(regex!("V"), "(a|c|g)"),
(regex!("W"), "(a|t)"),
(regex!("Y"), "(c|t)"),
];
let mut seq = seq;
for (re, replacement) in substs.into_iter() {
seq = re.replace_all(seq.as_slice(), NoExpand(replacement));
}
seq.len()
});
let variants = vec![
regex!("agggtaaa|tttaccct"),
regex!("[cgt]gggtaaa|tttaccc[acg]"),
regex!("a[act]ggtaaa|tttacc[agt]t"),
regex!("ag[act]gtaaa|tttac[agt]ct"),
regex!("agg[act]taaa|ttta[agt]cct"),
regex!("aggg[acg]aaa|ttt[cgt]ccct"),
regex!("agggt[cgt]aa|tt[acg]accct"),
regex!("agggta[cgt]a|t[acg]taccct"),
regex!("agggtaa[cgt]|[acg]ttaccct"),
];
let (mut variant_strs, mut counts) = (vec!(), vec!());
for variant in variants.into_iter() {
let seq_arc_copy = seq_arc.clone();
variant_strs.push(variant.to_string());
counts.push(Future::spawn(move|| {
count_matches(seq_arc_copy.as_slice(), &variant)
}));
}
for (i, variant) in variant_strs.iter().enumerate() {
println!("{} {}", variant, counts[i].get());
}
println!("");
println!("{}", ilen);
println!("{}", clen);
println!("{}", seqlen.get());
}

View file

@ -11,8 +11,7 @@
// aux-build:macro_crate_test.rs
// ignore-stage1
#[plugin] #[no_link]
#[plugin] #[no_link] extern crate macro_crate_test;
//~^ ERROR compiler plugins are experimental and possibly buggy
extern crate macro_crate_test;
fn main() {}

View file

@ -0,0 +1,20 @@
// 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.
mod foo { pub struct Bar; }
fn main() {
{
struct Bar;
use foo::Bar;
//~^ ERROR import `Bar` conflicts with type in this module
//~^^ ERROR import `Bar` conflicts with value in this module
}
}

View file

@ -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.
mod foo { struct bar; }
fn main() {
let bar = 5;
//~^ ERROR declaration of `bar` shadows an enum variant or unit-like struct in scope
use foo::bar;
//~^ ERROR imports are not allowed after non-item statements
}

View file

@ -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,9 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![crate_type = "lib"]
mod foo { pub mod foo { } }
#[test]
fn test_1() { }
#[test]
fn test_2() { }
use foo::foo; //~ ERROR import `foo` conflicts with existing submodule
fn main() {}

View file

@ -0,0 +1,20 @@
// 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.
mod bar {
pub fn foo() -> bool { true }
}
fn main() {
let foo = |&:| false;
use bar::foo;
//~^ ERROR imports are not allowed after non-item statements
assert_eq!(foo(), false);
}

View file

@ -12,7 +12,7 @@
// can't be used as rvalues
use std::ops::Index;
use std::fmt::Show;
use std::fmt::Debug;
struct S;
@ -31,9 +31,9 @@ struct T;
impl Copy for T {}
impl Index<usize> for T {
type Output = Show + 'static;
type Output = Debug + 'static;
fn index<'a>(&'a self, idx: &usize) -> &'a (Show + 'static) {
fn index<'a>(&'a self, idx: &usize) -> &'a (Debug + 'static) {
static x: usize = 42;
&x
}

View file

@ -19,17 +19,17 @@ trait Bar {
struct Foo<'a> {
a: &'a Bar+'a,
//~^ ERROR E0178
//~^^ NOTE perhaps you meant `&'a (Bar + 'a)`?
//~^^ HELP perhaps you meant `&'a (Bar + 'a)`?
b: &'a mut Bar+'a,
//~^ ERROR E0178
//~^^ NOTE perhaps you meant `&'a mut (Bar + 'a)`?
//~^^ HELP perhaps you meant `&'a mut (Bar + 'a)`?
c: Box<Bar+'a>, // OK, no paren needed in this context
d: fn() -> Bar+'a,
//~^ ERROR E0178
//~^^ NOTE perhaps you forgot parentheses
//~^^ HELP perhaps you forgot parentheses
//~^^^ WARN deprecated syntax
}

View file

@ -8,12 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::fmt::Show;
use std::fmt::Debug;
trait Str {}
trait Something {
fn yay<T: Show>(_: Option<Self>, thing: &[T]);
fn yay<T: Debug>(_: Option<Self>, thing: &[T]);
}
struct X { data: u32 }

View file

@ -12,19 +12,19 @@
use std::{fmt, ops};
struct Shower<T> {
struct Debuger<T> {
x: T
}
impl<T: fmt::Show> ops::Fn<(), ()> for Shower<T> {
impl<T: fmt::Debug> ops::Fn<(), ()> for Debuger<T> {
fn call(&self, _args: ()) {
//~^ ERROR `call` has an incompatible type for trait: expected "rust-call" fn, found "Rust" fn
println!("{:?}", self.x);
}
}
fn make_shower<T>(x: T) -> Shower<T> {
Shower { x: x }
fn make_shower<T>(x: T) -> Debuger<T> {
Debuger { x: x }
}
pub fn main() {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![crate_name="foo"]
macro_rules! test { ($wrong:t_ty ..) => () }
//~^ ERROR: unrecognized builtin nonterminal `t_ty`
pub mod foo;
pub mod bar;
fn main() {}

View file

@ -10,7 +10,7 @@
#![allow(dead_code)]
// compile-flags: -D type-limits
// compile-flags: -D unused-comparisons
fn main() { }
fn foo() {

View file

@ -8,13 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn send<T:Send + std::fmt::Show>(ch: _chan<T>, data: T) {
fn send<T:Send + std::fmt::Debug>(ch: _chan<T>, data: T) {
println!("{:?}", ch);
println!("{:?}", data);
panic!();
}
#[derive(Show)]
#[derive(Debug)]
struct _chan<T>(isize);
// Tests that "log(debug, message);" is flagged as using

View file

@ -0,0 +1,22 @@
// 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.
// issue #21405
fn foo<F>(f: F) where F: FnMut(usize) {}
fn main() {
foo(|s| s.is_empty());
//~^ ERROR does not implement any method
//~^^ HELP #1: `core::slice::SliceExt`
//~^^^ HELP #2: `core::str::StrExt`
//~^^^^ HELP #3: `collections::slice::SliceExt`
//~^^^^^ HELP #4: `collections::str::StrExt`
}

View file

@ -21,6 +21,6 @@ pub fn main() {
// Unsized type.
let arr: &[_] = &[1us, 2, 3];
let range = (*arr)..;
let range = *arr..;
//~^ ERROR the trait `core::marker::Sized` is not implemented
}

View file

@ -12,7 +12,7 @@
pub fn main() {
let r = {
(&42is)..&42
&42is..&42
//~^ ERROR borrowed value does not live long enough
//~^^ ERROR borrowed value does not live long enough
};

View file

@ -8,8 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub extern crate core; //~ ERROR: `pub` visibility is not allowed
// Test range syntax - syntax errors.
fn main() {
pub use std::usize; //~ ERROR: imports in functions are never reachable
}
pub fn main() {
let r = 1..2..3;
//~^ ERROR expected one of `.`, `;`, or an operator, found `..`
}

View file

@ -0,0 +1,16 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test range syntax - syntax errors.
pub fn main() {
let r = ..1..2;
//~^ ERROR expected one of `.`, `;`, or an operator, found `..`
}

View file

@ -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 that the compiler checks that arbitrary region bounds declared
// in the trait must be satisfied on the impl. Issue #20890.
trait Foo<'a> { type Value: 'a; }
impl<'a> Foo<'a> for &'a i16 {
// OK.
type Value = &'a i32;
}
impl<'a> Foo<'static> for &'a i32 {
//~^ ERROR cannot infer
type Value = &'a i32;
}
impl<'a,'b> Foo<'b> for &'a i64 {
//~^ ERROR cannot infer
type Value = &'a i32;
}
fn main() { }

View file

@ -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 that the compiler checks that the 'static bound declared in
// the trait must be satisfied on the impl. Issue #20890.
trait Foo { type Value: 'static; }
impl<'a> Foo for &'a i32 {
//~^ ERROR cannot infer
type Value = &'a i32;
}
impl<'a> Foo for i32 {
// OK.
type Value = i32;
}
fn main() { }

View file

@ -19,5 +19,5 @@ fn main() {
f<X>();
//~^ ERROR: Chained comparison operators require parentheses
//~^^ HELP: Use ::< instead of < if you meant to specify type arguments.
//~^^ HELP: use ::< instead of < if you meant to specify type arguments
}

View file

@ -13,18 +13,18 @@
struct Foo<'a>(&'a isize);
impl<'a> Foo<'a> {
//~^ HELP shadowed lifetime `'a` declared here
//~^ NOTE shadowed lifetime `'a` declared here
fn shadow_in_method<'a>(&'a self) -> &'a isize {
//~^ WARNING lifetime name `'a` shadows another lifetime name that is already in scope
//~| HELP deprecated
//~| NOTE deprecated
self.0
}
fn shadow_in_type<'b>(&'b self) -> &'b isize {
//~^ HELP shadowed lifetime `'b` declared here
//~^ NOTE shadowed lifetime `'b` declared here
let x: for<'b> fn(&'b isize) = panic!();
//~^ WARNING lifetime name `'b` shadows another lifetime name that is already in scope
//~| HELP deprecated
//~| NOTE deprecated
self.0
}

View file

@ -0,0 +1,24 @@
// 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.
struct A {
foo : i32,
car : i32,
barr : i32
}
fn main() {
let a = A {
foo : 5,
bar : 42,//~ ERROR structure `A` has no field named `bar`
//~^ HELP did you mean `barr`?
car : 9,
};
}

View file

@ -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.
struct A {
foo : i32,
car : i32,
barr : i32
}
fn main() {
let a = A {
foo : 5,
bar : 42,//~ ERROR structure `A` has no field named `bar`
//~^ HELP did you mean `car`?
};
}

View file

@ -0,0 +1,24 @@
// 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.
struct BuildData {
foo: isize,
bar: f32
}
fn main() {
let foo = BuildData {
foo: 0,
bar: 0.5,
};
let x = foo.baa;//~ ERROR attempted access of field `baa` on type `BuildData`
//~^ HELP did you mean `bar`?
println!("{}", x);
}

View file

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// 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.
//
@ -9,6 +9,7 @@
// except according to those terms.
fn main() {
pub use std::uint; //~ ERROR: visibility has no effect
pub struct A; //~ ERROR: visibility has no effect
pub enum B {} //~ ERROR: visibility has no effect
pub trait C { //~ ERROR: visibility has no effect

View file

@ -16,5 +16,5 @@ pub fn main() {
f<type>();
//~^ ERROR expected identifier, found keyword `type`
//~^^ ERROR: Chained comparison operators require parentheses
//~^^^ HELP: Use ::< instead of < if you meant to specify type arguments.
//~^^^ HELP: use ::< instead of < if you meant to specify type arguments
}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: -D path-statement
// compile-flags: -D path-statements
fn main() {
let x = 10is;

View file

@ -0,0 +1,152 @@
// 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.
// ignore-android: FIXME(#10381)
// min-lldb-version: 310
// compile-flags:-g
// === GDB TESTS ===================================================================================
// gdb-command:run
// gdb-command:print arg
// gdb-check:$1 = {b = -1, b1 = 0}
// gdb-command:continue
// gdb-command:print inferred
// gdb-check:$2 = 1
// gdb-command:print explicitly
// gdb-check:$3 = 1
// gdb-command:continue
// gdb-command:print arg
// gdb-check:$4 = 2
// gdb-command:continue
// gdb-command:print arg
// gdb-check:$5 = {4, 5}
// gdb-command:continue
// gdb-command:print a
// gdb-check:$6 = 6
// gdb-command:print b
// gdb-check:$7 = 7
// gdb-command:continue
// gdb-command:print a
// gdb-check:$8 = 8
// gdb-command:print b
// gdb-check:$9 = 9
// gdb-command:continue
// === LLDB TESTS ==================================================================================
// lldb-command:run
// lldb-command:print arg
// lldb-check:[...]$0 = Struct<i32> { b: -1, b1: 0 }
// lldb-command:continue
// lldb-command:print inferred
// lldb-check:[...]$1 = 1
// lldb-command:print explicitly
// lldb-check:[...]$2 = 1
// lldb-command:continue
// lldb-command:print arg
// lldb-check:[...]$3 = 2
// lldb-command:continue
// lldb-command:print arg
// lldb-check:[...]$4 = (4, 5)
// lldb-command:continue
// lldb-command:print a
// lldb-check:[...]$5 = 6
// lldb-command:print b
// lldb-check:[...]$6 = 7
// lldb-command:continue
// lldb-command:print a
// lldb-check:[...]$7 = 8
// lldb-command:print b
// lldb-check:[...]$8 = 9
// lldb-command:continue
#![allow(unused_variables)]
#![allow(dead_code)]
#![omit_gdb_pretty_printer_section]
trait TraitWithAssocType {
type Type;
fn get_value(&self) -> Self::Type;
}
impl TraitWithAssocType for i32 {
type Type = i64;
fn get_value(&self) -> i64 { *self as i64 }
}
struct Struct<T: TraitWithAssocType> {
b: T,
b1: T::Type,
}
enum Enum<T: TraitWithAssocType> {
Variant1(T, T::Type),
Variant2(T::Type, T)
}
fn assoc_struct<T: TraitWithAssocType>(arg: Struct<T>) {
zzz(); // #break
}
fn assoc_local<T: TraitWithAssocType>(x: T) {
let inferred = x.get_value();
let explicitly: T::Type = x.get_value();
zzz(); // #break
}
fn assoc_arg<T: TraitWithAssocType>(arg: T::Type) {
zzz(); // #break
}
fn assoc_return_value<T: TraitWithAssocType>(arg: T) -> T::Type {
return arg.get_value();
}
fn assoc_tuple<T: TraitWithAssocType>(arg: (T, T::Type)) {
zzz(); // #break
}
fn assoc_enum<T: TraitWithAssocType>(arg: Enum<T>) {
match arg {
Enum::Variant1(a, b) => {
zzz(); // #break
}
Enum::Variant2(a, b) => {
zzz(); // #break
}
}
}
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));
}
fn zzz() { () }

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags:--debuginfo=1
// compile-flags:-C debuginfo=1
// min-lldb-version: 310
pub trait TraitWithDefaultMethod : Sized {

View file

@ -11,7 +11,7 @@
// ignore-android: FIXME(#10381)
// min-lldb-version: 310
// compile-flags:--debuginfo=1
// compile-flags:-C debuginfo=1
// gdb-command:run
// lldb-command:run

View file

@ -12,7 +12,7 @@
// ignore-lldb
// compile-flags:--debuginfo=1
// compile-flags:-C debuginfo=1
// Make sure functions have proper names
// gdb-command:info functions

View file

@ -9,6 +9,7 @@
// except according to those terms.
// ignore-android: FIXME(#10381)
// ignore-windows
// min-lldb-version: 310
// compile-flags:-g

View file

@ -1,8 +1,8 @@
#![no_std]
#[macro_use]
extern crate "std" as std;
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate "std" as std;
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern:assertion failed: `(left == right) && (right == left)` (left: `14i`, right: `15i`)
// error-pattern:assertion failed: `(left == right) && (right == left)` (left: `14`, right: `15`)
fn main() {
assert_eq!(14i,15i);

View file

@ -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.
// Regression test for Issue #20971.
// error-pattern:Hello, world!
pub trait Parser {
type Input;
fn parse(&mut self, input: <Self as Parser>::Input);
}
impl Parser for () {
type Input = ();
fn parse(&mut self, input: ()) {
}
}
pub fn many() -> Box<Parser<Input=<() as Parser>::Input> + 'static> {
panic!("Hello, world!")
}
fn main() {
many()
.parse(());
}

View file

@ -1,10 +1,10 @@
-include ../tools.mk
all:
[ `$(RUSTC) --print-crate-name crate.rs` = "foo" ]
[ `$(RUSTC) --print-file-name crate.rs` = "$(call BIN,foo)" ]
[ `$(RUSTC) --print-file-name --crate-type=lib \
[ `$(RUSTC) --print crate-name crate.rs` = "foo" ]
[ `$(RUSTC) --print file-names crate.rs` = "$(call BIN,foo)" ]
[ `$(RUSTC) --print file-names --crate-type=lib \
--test crate.rs` = "$(call BIN,foo)" ]
[ `$(RUSTC) --print-file-name --test lib.rs` = "$(call BIN,mylib)" ]
$(RUSTC) --print-file-name lib.rs
$(RUSTC) --print-file-name rlib.rs
[ `$(RUSTC) --print file-names --test lib.rs` = "$(call BIN,mylib)" ]
$(RUSTC) --print file-names lib.rs
$(RUSTC) --print file-names rlib.rs

View file

@ -1,25 +0,0 @@
-include ../tools.mk
# FIXME: ignore freebsd/windows
# (windows: see `../dep-info/Makefile`)
ifneq ($(shell uname),FreeBSD)
ifndef IS_WINDOWS
all:
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
sleep 1
touch foo.rs
-rm -f $(TMPDIR)/done
$(MAKE) -drf Makefile.foo
rm $(TMPDIR)/done
pwd
$(MAKE) -drf Makefile.foo
rm $(TMPDIR)/done && exit 1 || exit 0
else
all:
endif
else
all:
endif

View file

@ -1,7 +0,0 @@
LIB := $(shell $(RUSTC) --print file-names --crate-type=lib lib.rs)
$(TMPDIR)/$(LIB):
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
touch $(TMPDIR)/done
-include $(TMPDIR)/custom-deps-file.d

View file

@ -5,7 +5,7 @@
ifneq ($(shell uname),FreeBSD)
ifndef IS_WINDOWS
all:
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
$(RUSTC) --emit link,dep-info --crate-type=lib lib.rs
sleep 1
touch 'foo foo.rs'
-rm -f $(TMPDIR)/done

View file

@ -1,7 +1,7 @@
LIB := $(shell $(RUSTC) --print-file-name --crate-type=lib lib.rs)
LIB := $(shell $(RUSTC) --print file-names --crate-type=lib lib.rs)
$(TMPDIR)/$(LIB):
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
$(RUSTC) --emit link,dep-info --crate-type=lib lib.rs
touch $(TMPDIR)/done
-include $(TMPDIR)/custom-deps-file.d
-include $(TMPDIR)/lib.d

View file

@ -7,7 +7,7 @@
ifneq ($(shell uname),FreeBSD)
ifndef IS_WINDOWS
all:
$(RUSTC) --dep-info --crate-type=lib lib.rs
$(RUSTC) --emit dep-info,link --crate-type=lib lib.rs
sleep 2
touch foo.rs
-rm -f $(TMPDIR)/done

View file

@ -2,7 +2,7 @@
all:
# Let's get a nice error message
$(RUSTC) foo.rs --dep-info foo/bar/baz 2>&1 | \
$(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | \
grep "error writing dependencies"
# Make sure the filename shows up
$(RUSTC) foo.rs --dep-info foo/bar/baz 2>&1 | grep "baz"
$(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | grep "baz"

View file

@ -13,7 +13,7 @@ all: $(patsubst %.rs,$(TMPDIR)/%.check,$(FILES))
RUSTC_LIB=$(RUSTC) --crate-type=lib
define FIND_LAST_BLOCK
LASTBLOCKNUM_$(1) := $(shell $(RUSTC_LIB) --pretty=expanded,identified $(1) \
LASTBLOCKNUM_$(1) := $(shell $(RUSTC_LIB) -Z unstable-options --pretty=expanded,identified $(1) \
| grep block
| tail -1
| sed -e 's@.*/\* block \([0-9]*\) \*/.*@\1@')

View file

@ -44,7 +44,7 @@ fn basic_sess(sysroot: Path) -> Session {
opts.output_types = vec![OutputTypeExe];
opts.maybe_sysroot = Some(sysroot);
let descriptions = Registry::new(&rustc::DIAGNOSTICS);
let descriptions = Registry::new(&rustc::diagnostics::DIAGNOSTICS);
let sess = build_session(opts, None, descriptions);
sess
}

View file

@ -3,7 +3,8 @@
REPLACEMENT := s/[0-9][0-9]*\#[0-9][0-9]*/$(shell date)/g
all:
$(RUSTC) -o $(TMPDIR)/input.out --pretty expanded,hygiene input.rs
$(RUSTC) -o $(TMPDIR)/input.out -Z unstable-options \
--pretty expanded,hygiene input.rs
# the name/ctxt numbers are very internals-dependent and thus
# change relatively frequently, and testing for their exact values

View file

@ -1,4 +1,5 @@
-include ../tools.mk
all:
$(RUSTC) -o $(TMPDIR)/input.expanded.rs --pretty=expanded input.rs
$(RUSTC) -o $(TMPDIR)/input.expanded.rs -Z unstable-options \
--pretty=expanded input.rs

View file

@ -1,9 +1,9 @@
-include ../tools.mk
all:
$(RUSTC) -o $(TMPDIR)/foo.out --pretty normal=foo input.rs
$(RUSTC) -o $(TMPDIR)/nest_foo.out --pretty normal=nest::foo input.rs
$(RUSTC) -o $(TMPDIR)/foo_method.out --pretty normal=foo_method input.rs
$(RUSTC) -o $(TMPDIR)/foo.out -Z unstable-options --pretty normal=foo input.rs
$(RUSTC) -o $(TMPDIR)/nest_foo.out -Z unstable-options --pretty normal=nest::foo input.rs
$(RUSTC) -o $(TMPDIR)/foo_method.out -Z unstable-options --pretty normal=foo_method input.rs
diff -u $(TMPDIR)/foo.out foo.pp
diff -u $(TMPDIR)/nest_foo.out nest_foo.pp
diff -u $(TMPDIR)/foo_method.out foo_method.pp

View file

@ -1,5 +1,5 @@
-include ../tools.mk
all:
$(RUSTC) -o $(TMPDIR)/input.out --pretty=normal input.rs
$(RUSTC) -o $(TMPDIR)/input.out --pretty=normal -Z unstable-options input.rs
diff -u $(TMPDIR)/input.out input.pp

View file

@ -0,0 +1,6 @@
-include ../tools.mk
all: foo.rs
$(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs
$(HTMLDOCCK) $(TMPDIR)/doc foo.rs

View file

@ -0,0 +1,22 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(optin_builtin_traits)]
// @matches foo/struct.Alpha.html '//pre' "pub struct Alpha"
pub struct Alpha;
// @matches foo/struct.Bravo.html '//pre' "pub struct Bravo<B>"
pub struct Bravo<B>;
// @matches foo/struct.Alpha.html '//*[@class="impl"]//code' "impl !.*Send.* for .*Alpha"
impl !Send for Alpha {}
// @matches foo/struct.Bravo.html '//*[@class="impl"]//code' "impl<B> !.*Send.* for .*Bravo.*<B>"
impl<B> !Send for Bravo<B> {}

View file

@ -1,7 +0,0 @@
-include ../tools.mk
all:
# Running all the shards should hit every test
$(RUSTC) --test main.rs
$(call RUN,main) --test-shard 1.2 | grep "test_1 ... ok"
$(call RUN,main) --test-shard 2.2 | grep "test_2 ... ok"

View file

@ -5,7 +5,8 @@ HOST_RPATH_ENV = \
TARGET_RPATH_ENV = \
$(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(TARGET_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
RUSTC := $(HOST_RPATH_ENV) $(RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR)
BARE_RUSTC := $(HOST_RPATH_ENV) $(RUSTC)
RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR)
CC := $(CC) -L $(TMPDIR)
HTMLDOCCK := $(PYTHON) $(S)/src/etc/htmldocck.py

View file

@ -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.
// aux-build:blind-item-mixed-crate-use-item-foo.rs
// aux-build:blind-item-mixed-crate-use-item-foo2.rs
mod m {
pub fn f<T>(_: T, _: (), _: ()) { }
pub fn g<T>(_: T, _: (), _: ()) { }
}
const BAR: () = ();
struct Data;
use m::f;
extern crate "blind-item-mixed-crate-use-item-foo" as foo;
fn main() {
const BAR2: () = ();
struct Data2;
use m::g;
extern crate "blind-item-mixed-crate-use-item-foo2" as foo2;
f(Data, BAR, foo::X);
g(Data2, BAR2, foo2::Y);
}

View file

@ -0,0 +1,27 @@
// 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.
mod m {
pub fn f<T>(_: T, _: ()) { }
pub fn g<T>(_: T, _: ()) { }
}
const BAR: () = ();
struct Data;
use m::f;
fn main() {
const BAR2: () = ();
struct Data2;
use m::g;
f(Data, BAR);
g(Data2, BAR2);
}

View file

@ -10,44 +10,44 @@
// compile-flags:--cfg set1 --cfg set2
#![allow(dead_code)]
use std::fmt::Show;
use std::fmt::Debug;
struct NotShowable;
struct NotDebugable;
#[cfg_attr(set1, derive(Show))]
#[cfg_attr(set1, derive(Debug))]
struct Set1;
#[cfg_attr(notset, derive(Show))]
struct Notset(NotShowable);
#[cfg_attr(notset, derive(Debug))]
struct Notset(NotDebugable);
#[cfg_attr(not(notset), derive(Show))]
#[cfg_attr(not(notset), derive(Debug))]
struct NotNotset;
#[cfg_attr(not(set1), derive(Show))]
struct NotSet1(NotShowable);
#[cfg_attr(not(set1), derive(Debug))]
struct NotSet1(NotDebugable);
#[cfg_attr(all(set1, set2), derive(Show))]
#[cfg_attr(all(set1, set2), derive(Debug))]
struct AllSet1Set2;
#[cfg_attr(all(set1, notset), derive(Show))]
struct AllSet1Notset(NotShowable);
#[cfg_attr(all(set1, notset), derive(Debug))]
struct AllSet1Notset(NotDebugable);
#[cfg_attr(any(set1, notset), derive(Show))]
#[cfg_attr(any(set1, notset), derive(Debug))]
struct AnySet1Notset;
#[cfg_attr(any(notset, notset2), derive(Show))]
struct AnyNotsetNotset2(NotShowable);
#[cfg_attr(any(notset, notset2), derive(Debug))]
struct AnyNotsetNotset2(NotDebugable);
#[cfg_attr(all(not(notset), any(set1, notset)), derive(Show))]
#[cfg_attr(all(not(notset), any(set1, notset)), derive(Debug))]
struct Complex;
#[cfg_attr(any(notset, not(any(set1, notset))), derive(Show))]
struct ComplexNot(NotShowable);
#[cfg_attr(any(notset, not(any(set1, notset))), derive(Debug))]
struct ComplexNot(NotDebugable);
#[cfg_attr(any(target_endian = "little", target_endian = "big"), derive(Show))]
#[cfg_attr(any(target_endian = "little", target_endian = "big"), derive(Debug))]
struct KeyValue;
fn is_show<T: Show>() {}
fn is_show<T: Debug>() {}
fn main() {
is_show::<Set1>();

View file

@ -11,7 +11,7 @@
#![allow(unknown_features)]
#![feature(box_syntax)]
use std::fmt::Show;
use std::fmt::Debug;
// Check that coercions apply at the pointer level and don't cause
// rvalue expressions to be unsized. See #20169 for more information.
@ -21,16 +21,21 @@ pub fn main() {
let _: Box<[int]> = box if true { [1, 2, 3] } else { [1, 3, 4] };
let _: Box<[int]> = box match true { true => [1, 2, 3], false => [1, 3, 4] };
let _: Box<Fn(int) -> _> = box { |x| (x as u8) };
let _: Box<Show> = box if true { false } else { true };
let _: Box<Show> = box match true { true => 'a', false => 'b' };
let _: Box<Debug> = box if true { false } else { true };
let _: Box<Debug> = box match true { true => 'a', false => 'b' };
let _: &[int] = &{ [1, 2, 3] };
let _: &[int] = &if true { [1, 2, 3] } else { [1, 3, 4] };
let _: &[int] = &match true { true => [1, 2, 3], false => [1, 3, 4] };
let _: &Fn(int) -> _ = &{ |x| (x as u8) };
let _: &Show = &if true { false } else { true };
let _: &Show = &match true { true => 'a', false => 'b' };
let _: &Debug = &if true { false } else { true };
let _: &Debug = &match true { true => 'a', false => 'b' };
let _: Box<[int]> = Box::new([1, 2, 3]);
let _: Box<Fn(int) -> _> = Box::new(|x| (x as u8));
let _: Vec<Box<Fn(int) -> _>> = vec![
Box::new(|x| (x as u8)),
box |x| (x as i16 as u8),
];
}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::fmt::Show;
use std::fmt::Debug;
use std::default::Default;
trait MyTrait {
@ -23,7 +23,7 @@ impl<T> MyTrait for T
}
}
#[derive(Clone,Show,PartialEq)]
#[derive(Clone,Debug,PartialEq)]
struct MyType {
dummy: uint
}
@ -35,7 +35,7 @@ impl MyTrait for MyType {
}
fn test_eq<M>(m: M, n: M)
where M : MyTrait + Show + PartialEq
where M : MyTrait + Debug + PartialEq
{
assert_eq!(m.get(), n);
}

View file

@ -14,7 +14,7 @@
use std::marker::Sync;
struct Foo {
a: uint,
a: usize,
b: *const ()
}
@ -24,27 +24,24 @@ fn foo<T>(a: T) -> T {
a
}
static BLOCK_INTEGRAL: uint = { 1 };
static BLOCK_INTEGRAL: usize = { 1 };
static BLOCK_EXPLICIT_UNIT: () = { () };
static BLOCK_IMPLICIT_UNIT: () = { };
static BLOCK_FLOAT: f64 = { 1.0 };
static BLOCK_ENUM: Option<uint> = { Some(100) };
static BLOCK_ENUM: Option<usize> = { Some(100) };
static BLOCK_STRUCT: Foo = { Foo { a: 12, b: 0 as *const () } };
static BLOCK_UNSAFE: uint = unsafe { 1000 };
static BLOCK_UNSAFE: usize = unsafe { 1000 };
// FIXME: #13970
// static BLOCK_FN_INFERRED: fn(uint) -> uint = { foo };
static BLOCK_FN_INFERRED: fn(usize) -> usize = { foo };
// FIXME: #13971
// static BLOCK_FN: fn(uint) -> uint = { foo::<uint> };
static BLOCK_FN: fn(usize) -> usize = { foo::<usize> };
// FIXME: #13972
// static BLOCK_ENUM_CONSTRUCTOR: fn(uint) -> Option<uint> = { Some };
static BLOCK_ENUM_CONSTRUCTOR: fn(usize) -> Option<usize> = { Some };
// FIXME: #13973
// static BLOCK_UNSAFE_SAFE_PTR: &'static int = unsafe { &*(0xdeadbeef as *int) };
// static BLOCK_UNSAFE_SAFE_PTR_2: &'static int = unsafe {
// static X: *int = 0xdeadbeef as *int;
// FIXME #13972
// static BLOCK_UNSAFE_SAFE_PTR: &'static isize = unsafe { &*(0xdeadbeef as *const isize) };
// static BLOCK_UNSAFE_SAFE_PTR_2: &'static isize = unsafe {
// const X: *const isize = 0xdeadbeef as *const isize;
// &*X
// };
@ -57,17 +54,10 @@ pub fn main() {
assert_eq!(BLOCK_STRUCT.b, 0 as *const ());
assert_eq!(BLOCK_ENUM, Some(100));
assert_eq!(BLOCK_UNSAFE, 1000);
// FIXME: #13970
// assert_eq!(BLOCK_FN_INFERRED(300), 300);
// FIXME: #13971
// assert_eq!(BLOCK_FN(300), 300);
// FIXME: #13972
// assert_eq!(BLOCK_ENUM_CONSTRUCTOR(200), Some(200));
// FIXME: #13973
// assert_eq!(BLOCK_UNSAFE_SAFE_PTR as *int as uint, 0xdeadbeef_u);
// assert_eq!(BLOCK_UNSAFE_SAFE_PTR_2 as *int as uint, 0xdeadbeef_u);
assert_eq!(BLOCK_FN_INFERRED(300), 300);
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);
}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags:--crate-name crate-name-attr-used -F unused-attribute
// compile-flags:--crate-name crate-name-attr-used -F unused-attributes
#![crate_name = "crate-name-attr-used"]

View file

@ -10,39 +10,39 @@
use std::fmt;
#[derive(Show)]
#[derive(Debug)]
enum A {}
#[derive(Show)]
#[derive(Debug)]
enum B { B1, B2, B3 }
#[derive(Show)]
#[derive(Debug)]
enum C { C1(int), C2(B), C3(String) }
#[derive(Show)]
#[derive(Debug)]
enum D { D1{ a: int } }
#[derive(Show)]
#[derive(Debug)]
struct E;
#[derive(Show)]
#[derive(Debug)]
struct F(int);
#[derive(Show)]
#[derive(Debug)]
struct G(int, int);
#[derive(Show)]
#[derive(Debug)]
struct H { a: int }
#[derive(Show)]
#[derive(Debug)]
struct I { a: int, b: int }
#[derive(Show)]
#[derive(Debug)]
struct J(Custom);
struct Custom;
impl fmt::Show for Custom {
impl fmt::Debug for Custom {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "yay")
}
}
trait ToShow {
trait ToDebug {
fn to_show(&self) -> String;
}
impl<T: fmt::Show> ToShow for T {
impl<T: fmt::Debug> ToDebug for T {
fn to_show(&self) -> String {
format!("{:?}", self)
}
@ -51,12 +51,12 @@ impl<T: fmt::Show> ToShow for T {
pub fn main() {
assert_eq!(B::B1.to_show(), "B1".to_string());
assert_eq!(B::B2.to_show(), "B2".to_string());
assert_eq!(C::C1(3).to_show(), "C1(3i)".to_string());
assert_eq!(C::C1(3).to_show(), "C1(3)".to_string());
assert_eq!(C::C2(B::B2).to_show(), "C2(B2)".to_string());
assert_eq!(D::D1{ a: 2 }.to_show(), "D1 { a: 2i }".to_string());
assert_eq!(D::D1{ a: 2 }.to_show(), "D1 { a: 2 }".to_string());
assert_eq!(E.to_show(), "E".to_string());
assert_eq!(F(3).to_show(), "F(3i)".to_string());
assert_eq!(G(3, 4).to_show(), "G(3i, 4i)".to_string());
assert_eq!(I{ a: 2, b: 4 }.to_show(), "I { a: 2i, b: 4i }".to_string());
assert_eq!(F(3).to_show(), "F(3)".to_string());
assert_eq!(G(3, 4).to_show(), "G(3, 4)".to_string());
assert_eq!(I{ a: 2, b: 4 }.to_show(), "I { a: 2, b: 4 }".to_string());
assert_eq!(J(Custom).to_show(), "J(yay)".to_string());
}

View file

@ -8,16 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Show)]
#[derive(Debug)]
struct Unit;
#[derive(Show)]
#[derive(Debug)]
struct Tuple(int, uint);
#[derive(Show)]
#[derive(Debug)]
struct Struct { x: int, y: uint }
#[derive(Show)]
#[derive(Debug)]
enum Enum {
Nullary,
Variant(int, uint),
@ -32,9 +32,9 @@ macro_rules! t {
pub fn main() {
t!(Unit, "Unit");
t!(Tuple(1, 2), "Tuple(1i, 2u)");
t!(Struct { x: 1, y: 2 }, "Struct { x: 1i, y: 2u }");
t!(Tuple(1, 2), "Tuple(1, 2)");
t!(Struct { x: 1, y: 2 }, "Struct { x: 1, y: 2 }");
t!(Enum::Nullary, "Nullary");
t!(Enum::Variant(1, 2), "Variant(1i, 2u)");
t!(Enum::StructVariant { x: 1, y: 2 }, "StructVariant { x: 1i, y: 2u }");
t!(Enum::Variant(1, 2), "Variant(1, 2)");
t!(Enum::StructVariant { x: 1, y: 2 }, "StructVariant { x: 1, y: 2 }");
}

View file

@ -12,7 +12,7 @@
// work and don't ICE.
use std::ops::Index;
use std::fmt::Show;
use std::fmt::Debug;
struct S;
@ -27,16 +27,16 @@ impl Index<uint> for S {
struct T;
impl Index<uint> for T {
type Output = Show + 'static;
type Output = Debug + 'static;
fn index<'a>(&'a self, idx: &uint) -> &'a (Show + 'static) {
fn index<'a>(&'a self, idx: &uint) -> &'a (Debug + 'static) {
static X: uint = 42;
&X as &(Show + 'static)
&X as &(Debug + 'static)
}
}
fn main() {
assert_eq!(&S[0], "hello");
&T[0];
// let x = &x as &Show;
// let x = &x as &Debug;
}

View file

@ -32,7 +32,7 @@ impl fmt::UpperHex for B {
f.write_str("adios")
}
}
impl fmt::String for C {
impl fmt::Display for C {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad_integral(true, "", "123")
}
@ -62,8 +62,8 @@ pub fn main() {
t!(format!("{}", 10i), "10");
t!(format!("{}", 10u), "10");
t!(format!("{:?}", '☃'), "'\\u{2603}'");
t!(format!("{:?}", 10i), "10i");
t!(format!("{:?}", 10u), "10u");
t!(format!("{:?}", 10i), "10");
t!(format!("{:?}", 10u), "10");
t!(format!("{:?}", "true"), "\"true\"");
t!(format!("{:?}", "foo\nbar"), "\"foo\\nbar\"");
t!(format!("{:o}", 10u), "12");
@ -71,22 +71,22 @@ pub fn main() {
t!(format!("{:X}", 10u), "A");
t!(format!("{}", "foo"), "foo");
t!(format!("{}", "foo".to_string()), "foo");
t!(format!("{:p}", 0x1234 as *const int), "0x1234");
t!(format!("{:p}", 0x1234 as *mut int), "0x1234");
t!(format!("{:p}", 0x1234 as *const isize), "0x1234");
t!(format!("{:p}", 0x1234 as *mut isize), "0x1234");
t!(format!("{:x}", A), "aloha");
t!(format!("{:X}", B), "adios");
t!(format!("foo {} ☃☃☃☃☃☃", "bar"), "foo bar ☃☃☃☃☃☃");
t!(format!("{1} {0}", 0i, 1i), "1 0");
t!(format!("{foo} {bar}", foo=0i, bar=1i), "0 1");
t!(format!("{foo} {1} {bar} {0}", 0i, 1i, foo=2i, bar=3i), "2 1 3 0");
t!(format!("{foo} {bar}", foo=0i, bar=1is), "0 1");
t!(format!("{foo} {1} {bar} {0}", 0is, 1is, foo=2is, bar=3is), "2 1 3 0");
t!(format!("{} {0}", "a"), "a a");
t!(format!("{foo_bar}", foo_bar=1i), "1");
t!(format!("{}", 5i + 5i), "10");
t!(format!("{:#4}", C), "☃123");
// FIXME(#20676)
// let a: &fmt::Show = &1i;
// t!(format!("{:?}", a), "1i");
// let a: &fmt::Debug = &1i;
// t!(format!("{:?}", a), "1");
// Formatting strings and their arguments
@ -153,7 +153,7 @@ pub fn main() {
// make sure that format! doesn't cause spurious unused-unsafe warnings when
// it's inside of an outer unsafe block
unsafe {
let a: int = ::std::mem::transmute(3u);
let a: isize = ::std::mem::transmute(3u);
format!("{}", a);
}
@ -214,8 +214,8 @@ fn test_format_args() {
fn test_order() {
// Make sure format!() arguments are always evaluated in a left-to-right
// ordering
fn foo() -> int {
static mut FOO: int = 0;
fn foo() -> isize {
static mut FOO: isize = 0;
unsafe {
FOO += 1;
FOO

View file

@ -14,6 +14,8 @@
#![feature(intrinsics)]
use std::thread::Thread;
extern "rust-intrinsic" {
pub fn init<T>() -> T;
}
@ -21,5 +23,8 @@ extern "rust-intrinsic" {
const SIZE: usize = 1024 * 1024;
fn main() {
let _memory: [u8; SIZE] = unsafe { init() };
// do the test in a new thread to avoid (spurious?) stack overflows
let _ = Thread::scoped(|| {
let _memory: [u8; SIZE] = unsafe { init() };
}).join();
}

View file

@ -15,6 +15,6 @@
use std::fmt;
fn main() {
let a: &fmt::Show = &1_i32;
let a: &fmt::Debug = &1_i32;
format!("{:?}", a);
}

View file

@ -0,0 +1,32 @@
// 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.
trait T0 { type O; }
struct S<A>(A);
impl<A> T0 for S<A> { type O = A; }
trait T1: T0 {
// this looks okay but as we see below, `f` is unusable
fn m0<F: Fn(<Self as T0>::O) -> bool>(self, f: F) -> bool;
}
// complains about the bounds on F here not being required by the trait
impl<A> T1 for S<A> {
fn m0<F: Fn(A) -> bool>(self, f: F) -> bool { f(self.0) }
}
// // complains about mismatched types: <S<A> as T0>::O vs. A
// impl<A> T1 for S<A>
// {
// fn m0<F: Fn(<Self as T0>::O) -> bool>(self, f: F) -> bool { f(self.0) }
// }
fn main() { }

View file

@ -0,0 +1,27 @@
// 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.
trait T0 { type O; }
struct S<A>(A);
impl<A> T0 for S<A> { type O = A; }
trait T1: T0 {
// this looks okay but as we see below, `f` is unusable
fn m0<F: Fn(<Self as T0>::O) -> bool>(self, f: F) -> bool;
}
// complains about mismatched types: <S<A> as T0>::O vs. A
impl<A> T1 for S<A>
{
fn m0<F: Fn(<Self as T0>::O) -> bool>(self, f: F) -> bool { f(self.0) }
}
fn main() { }

View file

@ -0,0 +1,94 @@
// 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-android
// ignore-windows
// Regression test for #20797.
use std::default::Default;
use std::io::IoResult;
use std::io::fs;
use std::io::fs::PathExtensions;
/// A strategy for acquiring more subpaths to walk.
pub trait Strategy {
type P: PathExtensions;
/// Get additional subpaths from a given path.
fn get_more(&self, item: &Self::P) -> IoResult<Vec<Self::P>>;
/// Determine whether a path should be walked further.
/// This is run against each item from `get_more()`.
fn prune(&self, p: &Self::P) -> bool;
}
/// The basic fully-recursive strategy. Nothing is pruned.
#[derive(Copy, Default)]
pub struct Recursive;
impl Strategy for Recursive {
type P = Path;
fn get_more(&self, p: &Path) -> IoResult<Vec<Path>> { fs::readdir(p) }
fn prune(&self, _: &Path) -> bool { false }
}
/// A directory walker of `P` using strategy `S`.
pub struct Subpaths<S: Strategy> {
stack: Vec<S::P>,
strategy: S,
}
impl<S: Strategy> Subpaths<S> {
/// Create a directory walker with a root path and strategy.
pub fn new(p: &S::P, strategy: S) -> IoResult<Subpaths<S>> {
let stack = try!(strategy.get_more(p));
Ok(Subpaths { stack: stack, strategy: strategy })
}
}
impl<S: Default + Strategy> Subpaths<S> {
/// Create a directory walker with a root path and a default strategy.
pub fn walk(p: &S::P) -> IoResult<Subpaths<S>> {
Subpaths::new(p, Default::default())
}
}
impl<S: Default + Strategy> Default for Subpaths<S> {
fn default() -> Subpaths<S> {
Subpaths { stack: Vec::new(), strategy: Default::default() }
}
}
impl<S: Strategy> Iterator for Subpaths<S> {
type Item = S::P;
fn next (&mut self) -> Option<S::P> {
let mut opt_path = self.stack.pop();
while opt_path.is_some() && self.strategy.prune(opt_path.as_ref().unwrap()) {
opt_path = self.stack.pop();
}
match opt_path {
Some(path) => {
if PathExtensions::is_dir(&path) {
let result = self.strategy.get_more(&path);
match result {
Ok(dirs) => { self.stack.extend(dirs.into_iter()); },
Err(..) => { }
}
}
Some(path)
}
None => None,
}
}
}
fn main() {
let mut walker: Subpaths<Recursive> = Subpaths::walk(&Path::new("/home")).unwrap();
}

View file

@ -0,0 +1,19 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() {
let mut shrinker: Box<Iterator<Item=i32>> = Box::new(vec![1].into_iter());
println!("{:?}", shrinker.next());
for v in shrinker { assert!(false); }
let mut shrinker: &mut Iterator<Item=i32> = &mut vec![1].into_iter();
println!("{:?}", shrinker.next());
for v in shrinker { assert!(false); }
}

View file

@ -8,9 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Check that lint deprecation works
fn main() {
let v = vec![1, 2, 3];
let boxed: Box<Iterator<Item=i32>> = Box::new(v.into_iter());
assert_eq!(boxed.max(), Some(3));
#[deny(unused_variable)] //~ warning: lint unused_variable has been renamed to unused_variables
pub fn main() {
let x = 0u8; //~ error: unused variable:
let v = vec![1, 2, 3];
let boxed: &mut Iterator<Item=i32> = &mut v.into_iter();
assert_eq!(boxed.max(), Some(3));
}

View file

@ -24,6 +24,6 @@ pub fn main() {
let mut table = HashMap::new();
table.insert("one".to_string(), 1i);
table.insert("two".to_string(), 2i);
assert!(check_strs(format!("{:?}", table).as_slice(), "HashMap {\"one\": 1i, \"two\": 2i}") ||
check_strs(format!("{:?}", table).as_slice(), "HashMap {\"two\": 2i, \"one\": 1i}"));
assert!(check_strs(format!("{:?}", table).as_slice(), "HashMap {\"one\": 1, \"two\": 2}") ||
check_strs(format!("{:?}", table).as_slice(), "HashMap {\"two\": 2, \"one\": 1}"));
}

View file

@ -11,28 +11,28 @@
#![feature(unsafe_destructor)]
trait X {
fn call<T: std::fmt::Show>(&self, x: &T);
fn default_method<T: std::fmt::Show>(&self, x: &T) {
fn call<T: std::fmt::Debug>(&self, x: &T);
fn default_method<T: std::fmt::Debug>(&self, x: &T) {
println!("X::default_method {:?}", x);
}
}
#[derive(Show)]
#[derive(Debug)]
struct Y(int);
#[derive(Show)]
#[derive(Debug)]
struct Z<T> {
x: T
}
impl X for Y {
fn call<T: std::fmt::Show>(&self, x: &T) {
fn call<T: std::fmt::Debug>(&self, x: &T) {
println!("X::call {:?} {:?}", self, x);
}
}
#[unsafe_destructor]
impl<T: X + std::fmt::Show> Drop for Z<T> {
impl<T: X + std::fmt::Debug> Drop for Z<T> {
fn drop(&mut self) {
// These statements used to cause an ICE.
self.x.call(self);

View file

@ -8,17 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn assert_repr_eq<T: std::fmt::Show>(obj : T, expected : String) {
fn assert_repr_eq<T: std::fmt::Debug>(obj : T, expected : String) {
assert_eq!(expected, format!("{:?}", obj));
}
pub fn main() {
let abc = [1i, 2, 3];
let abc = [1, 2, 3];
let tf = [true, false];
let x = [(), ()];
let slice = &x[..1];
assert_repr_eq(&abc[], "[1i, 2i, 3i]".to_string());
assert_repr_eq(&abc[], "[1, 2, 3]".to_string());
assert_repr_eq(&tf[], "[true, false]".to_string());
assert_repr_eq(&x[], "[(), ()]".to_string());
assert_repr_eq(slice, "[()]".to_string());

View file

@ -8,19 +8,19 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Clone, Show)]
#[derive(Clone, Debug)]
enum foo {
a(uint),
b(String),
}
fn check_log<T: std::fmt::Show>(exp: String, v: T) {
fn check_log<T: std::fmt::Debug>(exp: String, v: T) {
assert_eq!(exp, format!("{:?}", v));
}
pub fn main() {
let mut x = Some(foo::a(22u));
let exp = "Some(a(22u))".to_string();
let mut x = Some(foo::a(22));
let exp = "Some(a(22))".to_string();
let act = format!("{:?}", x);
assert_eq!(act, exp);
check_log(exp, x);

View file

@ -8,20 +8,20 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Show)]
#[derive(Debug)]
enum foo {
a(uint),
a(usize),
b(String),
c,
}
#[derive(Show)]
#[derive(Debug)]
enum bar {
d, e, f
}
pub fn main() {
assert_eq!("a(22u)".to_string(), format!("{:?}", foo::a(22u)));
assert_eq!("a(22)".to_string(), format!("{:?}", foo::a(22)));
assert_eq!("c".to_string(), format!("{:?}", foo::c));
assert_eq!("d".to_string(), format!("{:?}", bar::d));
}

View file

@ -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.
//
@ -8,12 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate test;
// aux-build:macro_with_super_1.rs
fn f() {
}
#[macro_use]
extern crate macro_with_super_1;
use test::net; //~ ERROR `use` and `extern crate` declarations must precede items
declare!();
fn main() {
bbb::ccc();
}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::fmt::Show;
use std::fmt::Debug;
trait MyTrait<T> {
fn get(&self) -> T;
@ -29,7 +29,7 @@ impl MyTrait<u8> for MyType {
}
fn test_eq<T,M>(m: M, v: T)
where T : Eq + Show,
where T : Eq + Debug,
M : MyTrait<T>
{
assert_eq!(m.get(), v);

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::fmt::Show;
use std::fmt::Debug;
use std::default::Default;
trait MyTrait<T> {
@ -34,7 +34,7 @@ impl MyTrait<uint> for MyType {
}
fn test_eq<T,M>(m: M, v: T)
where T : Eq + Show,
where T : Eq + Debug,
M : MyTrait<T>
{
assert_eq!(m.get(), v);

View file

@ -26,6 +26,6 @@ fn main() {
Thread::scoped(move|| -> () {
let _a = A;
panic!();
}).join().unwrap_err();
}).join().err().unwrap();
assert!(unsafe { !HIT });
}

View file

@ -28,7 +28,7 @@ impl<K,V> AssociationList<K,V> {
}
}
impl<K: PartialEq + std::fmt::Show, V:Clone> Index<K> for AssociationList<K,V> {
impl<K: PartialEq + std::fmt::Debug, V:Clone> Index<K> for AssociationList<K,V> {
type Output = V;
fn index<'a>(&'a self, index: &K) -> &'a V {

View file

@ -48,5 +48,12 @@ fn main() {
assert!(x == &a[3..]);
for _i in 2+4..10-3 {}
let i = 42;
for _ in 1..i {}
for _ in 1.. { break; }
let x = [1]..[2];
assert!(x == (([1])..([2])));
}

View file

@ -22,14 +22,14 @@ mod rusti {
}
// This is the type with the questionable alignment
#[derive(Show)]
#[derive(Debug)]
struct Inner {
c64: u32
}
// This is the type that contains the type with the
// questionable alignment, for testing
#[derive(Show)]
#[derive(Debug)]
struct Outer {
c8: u8,
t: Inner
@ -66,6 +66,6 @@ pub fn main() {
// because `inner`s alignment was 4.
assert_eq!(mem::size_of::<Outer>(), m::size());
assert_eq!(y, "Outer { c8: 22u8, t: Inner { c64: 44u32 } }".to_string());
assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string());
}
}

View file

@ -22,14 +22,14 @@ mod rusti {
}
// This is the type with the questionable alignment
#[derive(Show)]
#[derive(Debug)]
struct Inner {
c64: u64
}
// This is the type that contains the type with the
// questionable alignment, for testing
#[derive(Show)]
#[derive(Debug)]
struct Outer {
c8: u8,
t: Inner
@ -95,6 +95,6 @@ pub fn main() {
// because `Inner`s alignment was 4.
assert_eq!(mem::size_of::<Outer>(), m::m::size());
assert_eq!(y, "Outer { c8: 22u8, t: Inner { c64: 44u64 } }".to_string());
assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string());
}
}

View file

@ -0,0 +1,28 @@
// 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 the compiler considers the 'a bound declared in the
// trait. Issue #20890.
trait Foo<'a> {
type Value: 'a;
fn get(&self) -> &'a Self::Value;
}
fn takes_foo<'a,F: Foo<'a>>(f: &'a F) {
// This call would be illegal, because it results in &'a F::Value,
// and the only way we know that `F::Value : 'a` is because of the
// trait declaration.
f.get();
}
fn main() { }

View file

@ -0,0 +1,22 @@
// 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 the compiler considers the 'static bound declared in the
// trait. Issue #20890.
trait Foo { type Value: 'static; }
fn require_static<T: 'static>() {}
fn takes_foo<F: Foo>() {
require_static::<F::Value>()
}
fn main() { }

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// exec-env:RUST_LOG=rust-log-filter/f.o
// exec-env:RUST_LOG=rust-log-filter/foo
#![allow(unknown_features)]
#![feature(box_syntax)]
@ -42,18 +42,14 @@ pub fn main() {
let _t = Thread::spawn(move|| {
log::set_logger(logger);
// our regex is "f.o"
// ensure it is a regex, and isn't anchored
info!("foo");
info!("bar");
info!("foo bar");
info!("bar foo");
info!("f1o");
});
assert_eq!(rx.recv().unwrap().as_slice(), "foo");
assert_eq!(rx.recv().unwrap().as_slice(), "foo bar");
assert_eq!(rx.recv().unwrap().as_slice(), "bar foo");
assert_eq!(rx.recv().unwrap().as_slice(), "f1o");
assert!(rx.recv().is_err());
}

View file

@ -36,5 +36,5 @@ mod b {
}
fn main() {
Thread::scoped(move|| { ::b::g() }).join().unwrap_err();
Thread::scoped(move|| { ::b::g() }).join().err().unwrap();
}

View file

@ -11,7 +11,7 @@
#![allow(unknown_features)]
#![feature(box_syntax)]
#[derive(Show)]
#[derive(Debug)]
struct Foo(Box<[u8]>);
pub fn main() {

View file

@ -10,7 +10,7 @@
use std::mem::size_of;
#[derive(PartialEq, Show)]
#[derive(PartialEq, Debug)]
enum Either<T, U> { Left(T), Right(U) }
macro_rules! check {
@ -29,14 +29,14 @@ macro_rules! check {
pub fn main() {
check!(Option<u8>, 2,
None, "None",
Some(129u8), "Some(129u8)");
Some(129u8), "Some(129)");
check!(Option<i16>, 4,
None, "None",
Some(-20000i16), "Some(-20000i16)");
Some(-20000i16), "Some(-20000)");
check!(Either<u8, i8>, 2,
Either::Left(132u8), "Left(132u8)",
Either::Right(-32i8), "Right(-32i8)");
Either::Left(132u8), "Left(132)",
Either::Right(-32i8), "Right(-32)");
check!(Either<u8, i16>, 4,
Either::Left(132u8), "Left(132u8)",
Either::Right(-20000i16), "Right(-20000i16)");
Either::Left(132u8), "Left(132)",
Either::Right(-20000i16), "Right(-20000)");
}

View file

@ -8,12 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Show)]
#[derive(Debug)]
enum a_tag {
a_tag_var(u64)
}
#[derive(Show)]
#[derive(Debug)]
struct t_rec {
c8: u8,
t: a_tag
@ -23,5 +23,5 @@ pub fn main() {
let x = t_rec {c8: 22u8, t: a_tag::a_tag_var(44u64)};
let y = format!("{:?}", x);
println!("y = {:?}", y);
assert_eq!(y, "t_rec { c8: 22u8, t: a_tag_var(44u64) }".to_string());
assert_eq!(y, "t_rec { c8: 22, t: a_tag_var(44) }".to_string());
}

View file

@ -26,6 +26,6 @@ pub fn main() {
let _b = Foo;
}).join();
let s = x.unwrap_err().downcast::<&'static str>().unwrap();
let s = x.err().unwrap().downcast::<&'static str>().ok().unwrap();
assert_eq!(s.as_slice(), "This panic should happen.");
}

Some files were not shown because too many files have changed in this diff Show more