From dc2ca9d8830a7a34242aa7722f545bc242813af3 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 7 May 2013 17:30:21 -0400 Subject: Refactor representation of bounds to separate out BuiltinBounds into its own type. Use a bitset to represent built-in bounds. There are several places in the language where only builtin bounds (aka kinds) will be accepted, e.g. on closures, destructor type parameters perhaps, and on trait types. --- src/test/compile-fail/issue-2611-3.rs | 29 ----------------------------- src/test/compile-fail/issue-2611-4.rs | 2 +- src/test/run-pass/issue-2611-3.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 30 deletions(-) delete mode 100644 src/test/compile-fail/issue-2611-3.rs create mode 100644 src/test/run-pass/issue-2611-3.rs (limited to 'src/test') diff --git a/src/test/compile-fail/issue-2611-3.rs b/src/test/compile-fail/issue-2611-3.rs deleted file mode 100644 index 248bea2d9b5..00000000000 --- a/src/test/compile-fail/issue-2611-3.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 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. - -// Tests that impl methods are matched to traits exactly: -// we might be tempted to think matching is contravariant, but if -// we let an impl method can have more permissive bounds than the trait -// method it's implementing, the return type might be less specific than -// needed. Just punt and make it invariant. - -trait A { - fn b(x: C) -> C; -} - -struct E { - f: int -} - -impl A for E { - fn b(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but -} - -fn main() {} diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index cf644fc198c..2385be5723e 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -20,7 +20,7 @@ struct E { } impl A for E { - fn b(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 2 bounds, but + fn b(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Const` } fn main() {} diff --git a/src/test/run-pass/issue-2611-3.rs b/src/test/run-pass/issue-2611-3.rs new file mode 100644 index 00000000000..acc6ffd0dd1 --- /dev/null +++ b/src/test/run-pass/issue-2611-3.rs @@ -0,0 +1,26 @@ +// Copyright 2012 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. + +// Tests that impls are allowed to have looser, more permissive bounds +// than the traits require. + +trait A { + fn b(x: C) -> C; +} + +struct E { + f: int +} + +impl A for E { + fn b(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but +} + +fn main() {} -- cgit 1.4.1-3-g733a5