diff --git a/src/test/compile-fail/issue-22312.rs b/src/test/compile-fail/issue-22312.rs new file mode 100644 index 00000000000..4d6e6eded21 --- /dev/null +++ b/src/test/compile-fail/issue-22312.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::Index; + +pub trait Array2D: Index { + fn rows(&self) -> usize; + fn columns(&self) -> usize; + fn get<'a>(&'a self, y: usize, x: usize) -> Option<&'a >::Output> { + if y >= self.rows() || x >= self.columns() { + return None; + } + let i = y * self.columns() + x; + let indexer = &(*self as &Index>::Output>); + //~^ERROR non-scalar cast + Some(indexer.index(i)) + } +} + +fn main() {} diff --git a/src/test/compile-fail/issue-23595-1.rs b/src/test/compile-fail/issue-23595-1.rs new file mode 100644 index 00000000000..749b261e387 --- /dev/null +++ b/src/test/compile-fail/issue-23595-1.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::{Index}; + +trait Hierarchy { + type Value; + type ChildKey; + type Children = Index; + //~^ ERROR: the value of the associated type `ChildKey` + //~^^ ERROR: the value of the associated type `Children` + //~^^^ ERROR: the value of the associated type `Value` + + fn data(&self) -> Option<(Self::Value, Self::Children)>; +} + +fn main() {} diff --git a/src/test/compile-fail/issue-23595-2.rs b/src/test/compile-fail/issue-23595-2.rs new file mode 100644 index 00000000000..78a3f42f1a6 --- /dev/null +++ b/src/test/compile-fail/issue-23595-2.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct C {a:AType} + +pub trait A { + type B = C; + //~^ ERROR: associated type `anything_here_kills_it` not found for `Self` +} + +fn main() {} diff --git a/src/test/run-pass/issue-20544.rs b/src/test/run-pass/issue-20544.rs new file mode 100644 index 00000000000..c70b059d3e7 --- /dev/null +++ b/src/test/run-pass/issue-20544.rs @@ -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 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(core)] + +struct Fun(F); + +impl FnOnce<(T,)> for Fun where F: Fn(T) -> T { + type Output = T; + + extern "rust-call" fn call_once(self, (t,): (T,)) -> T { + (self.0)(t) + } +} + +fn main() { + let fun = Fun(|i: isize| i * 2); + println!("{}", fun(3)); +} diff --git a/src/test/run-pass/issue-21140.rs b/src/test/run-pass/issue-21140.rs new file mode 100644 index 00000000000..c19f3327fbb --- /dev/null +++ b/src/test/run-pass/issue-21140.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Trait where Self::Out: std::fmt::Display { + type Out; +} + +fn main() {}