From 62d80df0c9dc229d3efda6d84d5967e717d8a996 Mon Sep 17 00:00:00 2001 From: Jakub Bukaj Date: Sun, 7 Dec 2014 15:22:06 +0000 Subject: [PATCH] Add tests for E-needstest issues --- src/test/auxiliary/issue-16822.rs | 30 +++++++++ src/test/auxiliary/issue-18502.rs | 31 ++++++++++ src/test/compile-fail/issue-10176.rs | 16 +++++ src/test/compile-fail/issue-14182.rs | 25 ++++++++ src/test/compile-fail/issue-15381.rs | 20 ++++++ src/test/compile-fail/issue-15480.rs | 20 ++++++ src/test/compile-fail/issue-15756.rs | 24 ++++++++ src/test/compile-fail/issue-16966.rs | 15 +++++ src/test/compile-fail/issue-17545.rs | 18 ++++++ src/test/compile-fail/issue-17905.rs | 27 +++++++++ src/test/compile-fail/issue-18345.rs | 19 ++++++ src/test/compile-fail/issue-18389.rs | 34 +++++++++++ src/test/compile-fail/issue-18400.rs | 36 +++++++++++ src/test/compile-fail/issue-18611.rs | 22 +++++++ src/test/compile-fail/issue-18783.rs | 37 ++++++++++++ src/test/compile-fail/issue-19009.rs | 19 ++++++ src/test/compile-fail/issue-19081.rs | 25 ++++++++ src/test/run-pass-fulldeps/issue-16822.rs | 31 ++++++++++ src/test/run-pass-fulldeps/issue-18502.rs | 17 ++++++ src/test/run-pass/issue-10456.rs | 30 +++++++++ src/test/run-pass/issue-12744.rs | 14 +++++ src/test/run-pass/issue-13264.rs | 74 +++++++++++++++++++++++ src/test/run-pass/issue-13323.rs | 66 ++++++++++++++++++++ src/test/run-pass/issue-15444.rs | 29 +++++++++ src/test/run-pass/issue-17351.rs | 13 ++++ src/test/run-pass/issue-17503.rs | 21 +++++++ src/test/run-pass/issue-17771.rs | 27 +++++++++ src/test/run-pass/issue-17816.rs | 18 ++++++ src/test/run-pass/issue-17897.rs | 21 +++++++ src/test/run-pass/issue-18188.rs | 31 ++++++++++ src/test/run-pass/issue-18232.rs | 29 +++++++++ src/test/run-pass/issue-19098.rs | 24 ++++++++ src/test/run-pass/issue-19127.rs | 18 ++++++ src/test/run-pass/issue-19135.rs | 22 +++++++ src/test/run-pass/issue-5988.rs | 32 ++++++++++ 35 files changed, 935 insertions(+) create mode 100644 src/test/auxiliary/issue-16822.rs create mode 100644 src/test/auxiliary/issue-18502.rs create mode 100644 src/test/compile-fail/issue-10176.rs create mode 100644 src/test/compile-fail/issue-14182.rs create mode 100644 src/test/compile-fail/issue-15381.rs create mode 100644 src/test/compile-fail/issue-15480.rs create mode 100644 src/test/compile-fail/issue-15756.rs create mode 100644 src/test/compile-fail/issue-16966.rs create mode 100644 src/test/compile-fail/issue-17545.rs create mode 100644 src/test/compile-fail/issue-17905.rs create mode 100644 src/test/compile-fail/issue-18345.rs create mode 100644 src/test/compile-fail/issue-18389.rs create mode 100644 src/test/compile-fail/issue-18400.rs create mode 100644 src/test/compile-fail/issue-18611.rs create mode 100644 src/test/compile-fail/issue-18783.rs create mode 100644 src/test/compile-fail/issue-19009.rs create mode 100644 src/test/compile-fail/issue-19081.rs create mode 100644 src/test/run-pass-fulldeps/issue-16822.rs create mode 100644 src/test/run-pass-fulldeps/issue-18502.rs create mode 100644 src/test/run-pass/issue-10456.rs create mode 100644 src/test/run-pass/issue-12744.rs create mode 100644 src/test/run-pass/issue-13264.rs create mode 100644 src/test/run-pass/issue-13323.rs create mode 100644 src/test/run-pass/issue-15444.rs create mode 100644 src/test/run-pass/issue-17351.rs create mode 100644 src/test/run-pass/issue-17503.rs create mode 100644 src/test/run-pass/issue-17771.rs create mode 100644 src/test/run-pass/issue-17816.rs create mode 100644 src/test/run-pass/issue-17897.rs create mode 100644 src/test/run-pass/issue-18188.rs create mode 100644 src/test/run-pass/issue-18232.rs create mode 100644 src/test/run-pass/issue-19098.rs create mode 100644 src/test/run-pass/issue-19127.rs create mode 100644 src/test/run-pass/issue-19135.rs create mode 100644 src/test/run-pass/issue-5988.rs diff --git a/src/test/auxiliary/issue-16822.rs b/src/test/auxiliary/issue-16822.rs new file mode 100644 index 0000000000000..0e3041c11748b --- /dev/null +++ b/src/test/auxiliary/issue-16822.rs @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +use std::cell::RefCell; + +pub struct Window{ + pub data: RefCell +} + +impl Window { + pub fn update(&self, e: i32) { + match e { + 1 => self.data.borrow_mut().update(), + _ => {} + } + } +} + +pub trait Update { + fn update(&mut self); +} diff --git a/src/test/auxiliary/issue-18502.rs b/src/test/auxiliary/issue-18502.rs new file mode 100644 index 0000000000000..718b046e1e477 --- /dev/null +++ b/src/test/auxiliary/issue-18502.rs @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +struct Foo; +// This is the ICE trigger +struct Formatter; + +trait Show { + fn fmt(&self); +} + +impl Show for Foo { + fn fmt(&self) {} +} + +fn bar(f: extern "Rust" fn(&T), t: &T) { } + +// ICE requirement: this has to be marked as inline +#[inline] +pub fn baz() { + bar(Show::fmt, &Foo); +} diff --git a/src/test/compile-fail/issue-10176.rs b/src/test/compile-fail/issue-10176.rs new file mode 100644 index 0000000000000..f537d5cad9779 --- /dev/null +++ b/src/test/compile-fail/issue-10176.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f() -> int { + (return 1, return 2) +//~^ ERROR mismatched types: expected `int`, found `(_, _)` (expected int, found tuple) +} + +fn main() {} diff --git a/src/test/compile-fail/issue-14182.rs b/src/test/compile-fail/issue-14182.rs new file mode 100644 index 0000000000000..24256e31118e3 --- /dev/null +++ b/src/test/compile-fail/issue-14182.rs @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + f: for <'b> |&'b int|: + 'b -> &'b int //~ ERROR use of undeclared lifetime name `'b` +} + +fn main() { + let mut x: Vec< for <'a> || + :'a //~ ERROR use of undeclared lifetime name `'a` + > = Vec::new(); + x.push(|| {}); + + let foo = Foo { + f: |x| x + }; +} diff --git a/src/test/compile-fail/issue-15381.rs b/src/test/compile-fail/issue-15381.rs new file mode 100644 index 0000000000000..6a26073be52b1 --- /dev/null +++ b/src/test/compile-fail/issue-15381.rs @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let values: Vec = vec![1,2,3,4,5,6,7,8]; + + for + [x,y,z] +//~^ ERROR refutable pattern in `for` loop binding: `[]` not covered + in values.as_slice().chunks(3).filter(|&xs| xs.len() == 3) { + println!("y={}", y); + } +} diff --git a/src/test/compile-fail/issue-15480.rs b/src/test/compile-fail/issue-15480.rs new file mode 100644 index 0000000000000..abcc2eb1f98d3 --- /dev/null +++ b/src/test/compile-fail/issue-15480.rs @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let v = vec![ + &3i +//~^ ERROR borrowed value does not live long enough + ]; + + for &&x in v.iter() { + println!("{}", x + 3); + } +} diff --git a/src/test/compile-fail/issue-15756.rs b/src/test/compile-fail/issue-15756.rs new file mode 100644 index 0000000000000..df19de7731a9e --- /dev/null +++ b/src/test/compile-fail/issue-15756.rs @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::slice::Chunks; +use std::slice::MutChunks; + +fn dft_iter<'a, T>(arg1: Chunks<'a,T>, arg2: MutChunks<'a,T>) +{ + for + &something +//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `[T]` + in arg2 + { + } +} + +fn main() {} diff --git a/src/test/compile-fail/issue-16966.rs b/src/test/compile-fail/issue-16966.rs new file mode 100644 index 0000000000000..dfa23c48afa6e --- /dev/null +++ b/src/test/compile-fail/issue-16966.rs @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + panic!( + 1.2 //~ ERROR cannot determine a type for this expression + ); +} diff --git a/src/test/compile-fail/issue-17545.rs b/src/test/compile-fail/issue-17545.rs new file mode 100644 index 0000000000000..0501a3013ccd4 --- /dev/null +++ b/src/test/compile-fail/issue-17545.rs @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] + +pub fn foo<'a, F: Fn<(&'a (),), ()>>(bar: F) { + bar.call(( + &(), //~ ERROR borrowed value does not live long enough + )); +} +fn main() {} diff --git a/src/test/compile-fail/issue-17905.rs b/src/test/compile-fail/issue-17905.rs new file mode 100644 index 0000000000000..2f56b494f32c0 --- /dev/null +++ b/src/test/compile-fail/issue-17905.rs @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[deriving(Show)] +struct Pair (T, V); + +impl Pair< + &str, //~ ERROR missing lifetime specifier + int +> { + fn say(self: &Pair<&str, int>) { +//~^ ERROR mismatched types: expected `Pair<&'static str, int>`, found `Pair<&str, int>` + println!("{}", self); + } +} + +fn main() { + let result = &Pair("shane", 1i); + result.say(); +} diff --git a/src/test/compile-fail/issue-18345.rs b/src/test/compile-fail/issue-18345.rs new file mode 100644 index 0000000000000..298f155faff94 --- /dev/null +++ b/src/test/compile-fail/issue-18345.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +type Step<'s, R, T> = |R, T|: 's -> R; +type Transducer<'t, R, T, U> = |Step<'t, R, U>|: 't -> Step<'t, R, T>; + +fn mapping<'f, R, T, U>(f: |T|: 'f -> U) -> &'f Transducer<'f, R, T, U> { + |step| |r, x| + step(r, f(x)) //~ ERROR the type of this value must be known in this context +} + +fn main() {} diff --git a/src/test/compile-fail/issue-18389.rs b/src/test/compile-fail/issue-18389.rs new file mode 100644 index 0000000000000..38ebbc062f048 --- /dev/null +++ b/src/test/compile-fail/issue-18389.rs @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] +#![feature(associated_types)] + +use std::any::Any; +use std::intrinsics::TypeId; + +pub trait Pt {} +pub trait Rt {} + +trait Private { + fn call(&self, p: P, r: R); +} +pub trait Public: Private< + ::P, +//~^ ERROR illegal recursive type; insert an enum or struct in the cycle, if this is desired + ::R +> { + type P; + type R; + + fn call_inner(&self); +} + +fn main() {} diff --git a/src/test/compile-fail/issue-18400.rs b/src/test/compile-fail/issue-18400.rs new file mode 100644 index 0000000000000..a6662e78f3ee0 --- /dev/null +++ b/src/test/compile-fail/issue-18400.rs @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Set { + fn contains(&self, T) -> bool; + fn set(&mut self, T); +} + +impl<'a, T, S> Set<&'a [T]> for S where + T: Copy, + S: Set, +{ + fn contains(&self, bits: &[T]) -> bool { + bits.iter().all(|&bit| self.contains(bit)) + } + + fn set(&mut self, bits: &[T]) { + for &bit in bits.iter() { + self.set(bit) + } + } +} + +fn main() { + let bits: &[_] = &[0, 1]; + + 0.contains(bits); +//~^ ERROR the trait `Set<_>` is not implemented for the type `_` +} diff --git a/src/test/compile-fail/issue-18611.rs b/src/test/compile-fail/issue-18611.rs new file mode 100644 index 0000000000000..b2f204d747671 --- /dev/null +++ b/src/test/compile-fail/issue-18611.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(associated_types)] + +fn add_state(op: + ::State +//~^ ERROR it is currently unsupported to access associated types except through a type parameter +) {} + +trait HasState { + type State; +} + +fn main() {} diff --git a/src/test/compile-fail/issue-18783.rs b/src/test/compile-fail/issue-18783.rs new file mode 100644 index 0000000000000..8097d93ca0745 --- /dev/null +++ b/src/test/compile-fail/issue-18783.rs @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::cell::RefCell; + +fn main() { + let c = RefCell::new(vec![]); + let mut y = 1u; + c.push(|| y = 0); + c.push(|| y = 0); +//~^ ERROR cannot borrow `y` as mutable more than once at a time +} + +fn ufcs() { + let c = RefCell::new(vec![]); + let mut y = 1u; + + Push::push(&c, || y = 0); + Push::push(&c, || y = 0); +} + +trait Push<'c> { + fn push<'f: 'c>(&self, push: ||:'f -> ()); +} + +impl<'c> Push<'c> for RefCell> { + fn push<'f: 'c>(&self, fun: ||:'f -> ()) { + self.borrow_mut().push(fun) + } +} diff --git a/src/test/compile-fail/issue-19009.rs b/src/test/compile-fail/issue-19009.rs new file mode 100644 index 0000000000000..aa7c4c3060bdb --- /dev/null +++ b/src/test/compile-fail/issue-19009.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(lang_items)] +#![no_std] +#![crate_type="rlib"] +#[lang="sized"] pub trait Sized for Sized? {} + +fn ice(f: for <'s> || + :'s //~ ERROR use of undeclared lifetime name `'s` +) {} +fn main() { ice(||{}) } diff --git a/src/test/compile-fail/issue-19081.rs b/src/test/compile-fail/issue-19081.rs new file mode 100644 index 0000000000000..613ec8acd4131 --- /dev/null +++ b/src/test/compile-fail/issue-19081.rs @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(associated_types)] + +pub trait Hasher{ + type State; + + fn hash::State //~ ERROR no suitable bound on `Self` + >>(&self, value: &T) -> u64; +} + +trait Hash { + fn hash(&self, state: &mut S); +} + +fn main() {} diff --git a/src/test/run-pass-fulldeps/issue-16822.rs b/src/test/run-pass-fulldeps/issue-16822.rs new file mode 100644 index 0000000000000..6306627df0f8d --- /dev/null +++ b/src/test/run-pass-fulldeps/issue-16822.rs @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-16822.rs + +extern crate "issue-16822" as lib; + +use std::cell::RefCell; + +struct App { + i: int +} + +impl lib::Update for App { + fn update(&mut self) { + self.i += 1; + } +} + +fn main(){ + let app = App { i: 5 }; + let window = lib::Window { data: RefCell::new(app) }; + window.update(1); +} diff --git a/src/test/run-pass-fulldeps/issue-18502.rs b/src/test/run-pass-fulldeps/issue-18502.rs new file mode 100644 index 0000000000000..91b24b3b2abac --- /dev/null +++ b/src/test/run-pass-fulldeps/issue-18502.rs @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-18502.rs + +extern crate "issue-18502" as fmt; + +fn main() { + ::fmt::baz(); +} diff --git a/src/test/run-pass/issue-10456.rs b/src/test/run-pass/issue-10456.rs new file mode 100644 index 0000000000000..b714d87f4ef20 --- /dev/null +++ b/src/test/run-pass/issue-10456.rs @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo; + +pub trait Bar { + fn bar(&self); +} + +pub trait Baz {} + +impl Bar for T { + fn bar(&self) {} +} + +impl Baz for Foo {} + +pub fn foo(t: Box) { + t.bar(); // ~Foo doesn't implement Baz + (*t).bar(); // ok b/c Foo implements Baz +} + +fn main() {} diff --git a/src/test/run-pass/issue-12744.rs b/src/test/run-pass/issue-12744.rs new file mode 100644 index 0000000000000..1182cf5b29f85 --- /dev/null +++ b/src/test/run-pass/issue-12744.rs @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + fn test() -> Box { box 1i } + println!("{}", test()) +} diff --git a/src/test/run-pass/issue-13264.rs b/src/test/run-pass/issue-13264.rs new file mode 100644 index 0000000000000..06ab67f2f3e97 --- /dev/null +++ b/src/test/run-pass/issue-13264.rs @@ -0,0 +1,74 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Root { + jsref: JSRef +} + +impl Deref for Root { + fn deref<'a>(&'a self) -> &'a JSRef { + &self.jsref + } +} + +#[deriving(Copy)] +struct JSRef { + node: *const Node +} + +impl Deref for JSRef { + fn deref<'a>(&'a self) -> &'a Node { + self.get() + } +} + +trait INode { + fn RemoveChild(&self); +} + +impl INode for JSRef { + fn RemoveChild(&self) { + self.get().RemoveChild(0) + } +} + +impl JSRef { + fn AddChild(&self) { + self.get().AddChild(0); + } + + fn get<'a>(&'a self) -> &'a Node { + unsafe { + &*self.node + } + } +} + +struct Node; + +impl Node { + fn RemoveChild(&self, _a: uint) { + } + + fn AddChild(&self, _a: uint) { + } +} + +fn main() { + let n = Node; + let jsref = JSRef { node: &n }; + let root = Root { jsref: jsref }; + + root.AddChild(); + jsref.AddChild(); + + root.RemoveChild(); + jsref.RemoveChild(); +} diff --git a/src/test/run-pass/issue-13323.rs b/src/test/run-pass/issue-13323.rs new file mode 100644 index 0000000000000..d9149b0d7466e --- /dev/null +++ b/src/test/run-pass/issue-13323.rs @@ -0,0 +1,66 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct StrWrap { + s: String +} + +impl StrWrap { + fn new(s: &str) -> StrWrap { + StrWrap { s: s.into_string() } + } + + fn get_s<'a>(&'a self) -> &'a str { + self.s.as_slice() + } +} + +struct MyStruct { + s: StrWrap +} + +impl MyStruct { + fn new(s: &str) -> MyStruct { + MyStruct { s: StrWrap::new(s) } + } + + fn get_str_wrap<'a>(&'a self) -> &'a StrWrap { + &self.s + } +} + +trait Matcher { + fn matches(&self, actual: T) -> bool; +} + +fn assert_that>(actual: T, matcher: &U) { + assert!(matcher.matches(actual)); +} + +struct EqualTo { + expected: T +} + +impl Matcher for EqualTo { + fn matches(&self, actual: T) -> bool { + self.expected.eq(&actual) + } +} + +fn equal_to(expected: T) -> Box> { + box EqualTo { expected: expected } +} + +pub fn main() { + let my_struct = MyStruct::new("zomg"); + let s = my_struct.get_str_wrap(); + + assert_that(s.get_s(), &*equal_to("zomg")); +} diff --git a/src/test/run-pass/issue-15444.rs b/src/test/run-pass/issue-15444.rs new file mode 100644 index 0000000000000..f5618c2c7a3c4 --- /dev/null +++ b/src/test/run-pass/issue-15444.rs @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait MyTrait { + fn foo(&self); +} + +impl MyTrait for fn(A, B) -> C { + fn foo(&self) {} +} + +fn bar(t: &T) { + t.foo() +} + +fn thing(a: int, b: int) -> int { + a + b +} + +fn main() { + bar(&thing); +} diff --git a/src/test/run-pass/issue-17351.rs b/src/test/run-pass/issue-17351.rs new file mode 100644 index 0000000000000..0966d4ea45eec --- /dev/null +++ b/src/test/run-pass/issue-17351.rs @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let _: &Str = &"x"; +} diff --git a/src/test/run-pass/issue-17503.rs b/src/test/run-pass/issue-17503.rs new file mode 100644 index 0000000000000..986879e8e461d --- /dev/null +++ b/src/test/run-pass/issue-17503.rs @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(slicing_syntax)] + +fn main() { + let s: &[int] = &[0, 1, 2, 3, 4]; + let ss: &&[int] = &s; + let sss: &&&[int] = &ss; + + println!("{}", s[..3]); + println!("{}", ss[3..]); + println!("{}", sss[2..4]); +} diff --git a/src/test/run-pass/issue-17771.rs b/src/test/run-pass/issue-17771.rs new file mode 100644 index 0000000000000..1e9550acef4cb --- /dev/null +++ b/src/test/run-pass/issue-17771.rs @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Aaa {} + +impl<'a> Aaa for &'a mut (Aaa + 'a) {} + +struct Bar<'a> { + writer: &'a mut (Aaa + 'a), +} + +fn baz(_: &mut Aaa) { +} + +fn foo<'a>(mut bar: Bar<'a>) { + baz(&mut bar.writer); +} + +fn main() { +} diff --git a/src/test/run-pass/issue-17816.rs b/src/test/run-pass/issue-17816.rs new file mode 100644 index 0000000000000..d9d2c771390fd --- /dev/null +++ b/src/test/run-pass/issue-17816.rs @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] + +fn main() { + struct Symbol<'a, F: Fn(Vec<&'a str>) -> &'a str> { function: F } + let f = |&: x: Vec<&str>| -> &str "foobar"; + let sym = Symbol { function: f }; + (sym.function)(vec![]); +} diff --git a/src/test/run-pass/issue-17897.rs b/src/test/run-pass/issue-17897.rs new file mode 100644 index 0000000000000..49b03a974d868 --- /dev/null +++ b/src/test/run-pass/issue-17897.rs @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(default_type_params, unboxed_closures)] + +use std::thunk::Thunk; + +fn action(cb: Thunk) -> uint { + cb.invoke(1) +} + +pub fn main() { + println!("num: {}", action(Thunk::with_arg(move |:u| u))); +} diff --git a/src/test/run-pass/issue-18188.rs b/src/test/run-pass/issue-18188.rs new file mode 100644 index 0000000000000..aa95856a8b5ba --- /dev/null +++ b/src/test/run-pass/issue-18188.rs @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(default_type_params, unboxed_closures)] + +use std::thunk::Thunk; + +pub trait Promisable: Send + Sync {} +impl Promisable for T {} +pub fn propagate(action: F) -> Thunk, Result> + where + T: Promisable + Clone, + E: Promisable + Clone, + F: FnOnce(&T) -> Result + Send, + G: FnOnce(Result) -> Result { + Thunk::with_arg(move |: result: Result| { + match result { + Ok(ref t) => action(t), + Err(ref e) => Err(e.clone()), + } + }) +} + +fn main() {} diff --git a/src/test/run-pass/issue-18232.rs b/src/test/run-pass/issue-18232.rs new file mode 100644 index 0000000000000..15cf5870d40ad --- /dev/null +++ b/src/test/run-pass/issue-18232.rs @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Cursor<'a>; + +trait CursorNavigator { + fn init_cursor<'a, 'b:'a>(&'a self, cursor: &mut Cursor<'b>) -> bool; +} + +struct SimpleNavigator; + +impl CursorNavigator for SimpleNavigator { + fn init_cursor<'a, 'b: 'a>(&'a self, _cursor: &mut Cursor<'b>) -> bool { + false + } +} + +fn main() { + let mut c = Cursor; + let n = SimpleNavigator; + n.init_cursor(&mut c); +} diff --git a/src/test/run-pass/issue-19098.rs b/src/test/run-pass/issue-19098.rs new file mode 100644 index 0000000000000..ef95b4d4f00c5 --- /dev/null +++ b/src/test/run-pass/issue-19098.rs @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] + +pub trait Handler { + fn handle(&self, &mut String); +} + +impl Handler for F +where F: for<'a, 'b> Fn(&'a mut String) { + fn handle(&self, st: &mut String) { + self.call((st,)) + } +} + +fn main() {} diff --git a/src/test/run-pass/issue-19127.rs b/src/test/run-pass/issue-19127.rs new file mode 100644 index 0000000000000..bc43874bfb3c0 --- /dev/null +++ b/src/test/run-pass/issue-19127.rs @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] + +fn foo T>(f: F) {} +fn id<'a>(input: &'a u8) -> &'a u8 { input } + +fn main() { + foo(id); +} diff --git a/src/test/run-pass/issue-19135.rs b/src/test/run-pass/issue-19135.rs new file mode 100644 index 0000000000000..604442d150689 --- /dev/null +++ b/src/test/run-pass/issue-19135.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] + +#[deriving(Show)] +struct LifetimeStruct<'a>; + +fn main() { + takes_hrtb_closure(|&mut: lts| println!("{}", lts)); +} + +fn takes_hrtb_closureFnMut(LifetimeStruct<'a>)>(mut f: F) { + f(LifetimeStruct); +} diff --git a/src/test/run-pass/issue-5988.rs b/src/test/run-pass/issue-5988.rs new file mode 100644 index 0000000000000..cc95b135b27de --- /dev/null +++ b/src/test/run-pass/issue-5988.rs @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::io; +trait B { + fn f(&self); +} + +trait T : B { +} + +struct A; + +impl B for U { + fn f(&self) { io::println("Hey, I'm a T!"); } +} + +impl T for A { +} + +fn main() { + let a = A; + let br = &a as &B; + br.f(); +}