From 2651f8c14748bf4598841471329ca260f5860ec0 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Mon, 22 Feb 2016 22:46:45 -0800 Subject: [PATCH] Add regression tests from initial implementation review --- .../run-pass/specialization-out-of-order.rs | 27 ++++++++++++++++++ .../specialization-projection-alias.rs | 28 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/test/run-pass/specialization-out-of-order.rs create mode 100644 src/test/run-pass/specialization-projection-alias.rs diff --git a/src/test/run-pass/specialization-out-of-order.rs b/src/test/run-pass/specialization-out-of-order.rs new file mode 100644 index 0000000000000..2d293f494a347 --- /dev/null +++ b/src/test/run-pass/specialization-out-of-order.rs @@ -0,0 +1,27 @@ +// 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. + +// Test that you can list the more specific impl before the more general one. + +#![feature(specialization)] + +trait Foo { + type Out; +} + +impl Foo for bool { + type Out = (); +} + +impl Foo for T { + default type Out = bool; +} + +fn main() {} diff --git a/src/test/run-pass/specialization-projection-alias.rs b/src/test/run-pass/specialization-projection-alias.rs new file mode 100644 index 0000000000000..2250d77e08e8e --- /dev/null +++ b/src/test/run-pass/specialization-projection-alias.rs @@ -0,0 +1,28 @@ +// 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(specialization)] + +// Regression test for ICE when combining specialized associated types and type +// aliases + +trait Id_ { + type Out; +} + +type Id = ::Out; + +impl Id_ for T { + default type Out = T; +} + +fn main() { + let x: Id = panic!(); +}