From 7b9adfd5747b3e845086d251d008175ee8a3e4a1 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Sat, 27 Aug 2016 18:37:27 -0400 Subject: [PATCH] Add tests for #20433, #26251, #28625, #33687 Closes #20433 Closes #26251 Closes #28625 Closes #33687 --- src/test/compile-fail/issue-20433.rs | 18 +++++++++++++++++ src/test/compile-fail/issue-28625.rs | 30 ++++++++++++++++++++++++++++ src/test/run-pass/issue-26251.rs | 22 ++++++++++++++++++++ src/test/run-pass/issue-33687.rs | 26 ++++++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 src/test/compile-fail/issue-20433.rs create mode 100644 src/test/compile-fail/issue-28625.rs create mode 100644 src/test/run-pass/issue-26251.rs create mode 100644 src/test/run-pass/issue-33687.rs diff --git a/src/test/compile-fail/issue-20433.rs b/src/test/compile-fail/issue-20433.rs new file mode 100644 index 000000000000..d1a139e698e1 --- /dev/null +++ b/src/test/compile-fail/issue-20433.rs @@ -0,0 +1,18 @@ +// Copyright 2016 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() {} + +struct The; + +impl The { + fn iceman(c: Vec<[i32]>) {} + //~^ ERROR the trait bound `[i32]: std::marker::Sized` is not satisfied +} diff --git a/src/test/compile-fail/issue-28625.rs b/src/test/compile-fail/issue-28625.rs new file mode 100644 index 000000000000..c332e4ea4597 --- /dev/null +++ b/src/test/compile-fail/issue-28625.rs @@ -0,0 +1,30 @@ +// Copyright 2016 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 Bar { + type Bar; +} + +struct ArrayPeano { + data: T::Bar, +} + +fn foo(a: &ArrayPeano) -> &[T] where T: Bar { + unsafe { std::mem::transmute(a) } //~ ERROR transmute called with differently sized types +} + +impl Bar for () { + type Bar = (); +} + +fn main() { + let x: ArrayPeano<()> = ArrayPeano { data: () }; + foo(&x); +} diff --git a/src/test/run-pass/issue-26251.rs b/src/test/run-pass/issue-26251.rs new file mode 100644 index 000000000000..1e77d54fbf93 --- /dev/null +++ b/src/test/run-pass/issue-26251.rs @@ -0,0 +1,22 @@ +// Copyright 2016 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 x = 'a'; + + let y = match x { + 'a'...'b' if false => "one", + 'a' => "two", + 'a'...'b' => "three", + _ => panic!("what?"), + }; + + assert_eq!(y, "two"); +} diff --git a/src/test/run-pass/issue-33687.rs b/src/test/run-pass/issue-33687.rs new file mode 100644 index 000000000000..59badca065a1 --- /dev/null +++ b/src/test/run-pass/issue-33687.rs @@ -0,0 +1,26 @@ +// Copyright 2016 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(fn_traits)] + +struct Test; + +impl FnOnce<(u32, u32)> for Test { + type Output = u32; + + extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { + a + b + } +} + +fn main() { + assert_eq!(Test(1u32, 2u32), 3u32); +}