diff --git a/src/test/compile-fail/issue-25145.rs b/src/test/compile-fail/issue-25145.rs new file mode 100644 index 00000000000..e8a9c8d2ea3 --- /dev/null +++ b/src/test/compile-fail/issue-25145.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(associated_consts)] + +struct S; + +impl S { + const N: usize = 3; +} + +static STUFF: [u8; S::N] = [0; S::N]; +//~^ ERROR array length constant evaluation error: unresolved path in constant expression + +fn main() {} diff --git a/src/test/compile-fail/issue-26459.rs b/src/test/compile-fail/issue-26459.rs new file mode 100644 index 00000000000..48eda91fbae --- /dev/null +++ b/src/test/compile-fail/issue-26459.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + match 'a' { + char{ch} => true + //~^ ERROR `char` does not name a struct or a struct variant + }; +} diff --git a/src/test/compile-fail/issue-27895.rs b/src/test/compile-fail/issue-27895.rs new file mode 100644 index 00000000000..959818b49c9 --- /dev/null +++ b/src/test/compile-fail/issue-27895.rs @@ -0,0 +1,21 @@ +// 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. + +fn main() { + let i = 5; + let index = 6; + + match i { + 0...index => println!("winner"), + //~^ ERROR paths in constants may only refer to constants or functions + //~| ERROR non-constant path in constant expression + _ => println!("hello"), + } +} diff --git a/src/test/run-pass/issue-22781.rs b/src/test/run-pass/issue-22781.rs new file mode 100644 index 00000000000..1aa32f20142 --- /dev/null +++ b/src/test/run-pass/issue-22781.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::collections::HashMap; +use std::collections::hash_map::Entry::Vacant; + +pub fn foo() { + type F = Box; + let mut map: HashMap<(), F> = HashMap::new(); + let x: &mut F = match map.entry(()) { + Vacant(_) => unimplemented!(), + _ => unimplemented!() + }; +} + +fn main() {} diff --git a/src/test/run-pass/issue-23891.rs b/src/test/run-pass/issue-23891.rs new file mode 100644 index 00000000000..55536de9123 --- /dev/null +++ b/src/test/run-pass/issue-23891.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! id { + ($s: pat) => ($s); +} + +fn main() { + match (Some(123), Some(456)) { + (id!(Some(a)), _) | (_, id!(Some(a))) => println!("{}", a), + _ => (), + } +} diff --git a/src/test/run-pass/issue-24956.rs b/src/test/run-pass/issue-24956.rs new file mode 100644 index 00000000000..501b713d520 --- /dev/null +++ b/src/test/run-pass/issue-24956.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo(bool); +const NEW_FALSE: bool = false; +const STATIC_FOO: Foo = Foo(NEW_FALSE); + +pub fn main() { + match (Foo(false)) { + STATIC_FOO => 3, + _ => 11 + }; +} diff --git a/src/test/run-pass/issue-25693.rs b/src/test/run-pass/issue-25693.rs new file mode 100644 index 00000000000..aee89befda8 --- /dev/null +++ b/src/test/run-pass/issue-25693.rs @@ -0,0 +1,30 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Paramters { type SelfRef; } + +struct RP<'a> { _marker: std::marker::PhantomData<&'a ()> } +struct BP; + +impl<'a> Paramters for RP<'a> { type SelfRef = &'a X>; } +impl Paramters for BP { type SelfRef = Box>; } + +pub struct Y; +pub enum X { + Nothing, + SameAgain(P::SelfRef, Y) +} + +fn main() { + let bnil: Box> = Box::new(X::Nothing); + let bx: Box> = Box::new(X::SameAgain(bnil, Y)); + let rnil: X = X::Nothing; + let rx: X = X::SameAgain(&rnil, Y); +} diff --git a/src/test/run-pass/issue-26095.rs b/src/test/run-pass/issue-26095.rs new file mode 100644 index 00000000000..f34685c6936 --- /dev/null +++ b/src/test/run-pass/issue-26095.rs @@ -0,0 +1,30 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(associated_consts)] + +trait HasNumber { + const Number: usize; +} + +enum One {} +enum Two {} + +enum Foo {} + +impl HasNumber for One { + const Number: usize = 1; +} + +impl HasNumber for Two { + const Number: usize = 2; +} + +fn main() {} diff --git a/src/test/run-pass/issue-27320.rs b/src/test/run-pass/issue-27320.rs new file mode 100644 index 00000000000..dde1d3bfe93 --- /dev/null +++ b/src/test/run-pass/issue-27320.rs @@ -0,0 +1,21 @@ +// 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. + +macro_rules! piece( + ($piece:pat) => ($piece); +); + +enum Piece {A, B} + +fn main() { + match Piece::A { + piece!(pt@ Piece::A) | piece!(pt@ Piece::B) => {} + } +}