diff options
| author | Without Boats <woboats@gmail.com> | 2017-04-24 01:19:12 -0700 |
|---|---|---|
| committer | Without Boats <woboats@gmail.com> | 2017-04-24 01:19:12 -0700 |
| commit | bd31498ef668ee6c6ac0d2777ed5195b5f5d77e4 (patch) | |
| tree | c130396204f4f2367e0db07bb32b88e8a3e5e613 /src/test | |
| parent | 86b10671dbb7edf4090cb04476b4da205fd892b2 (diff) | |
Add compile-fail test.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/object-safety-associated-consts.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/compile-fail/object-safety-associated-consts.rs b/src/test/compile-fail/object-safety-associated-consts.rs new file mode 100644 index 00000000000..e38187fe86a --- /dev/null +++ b/src/test/compile-fail/object-safety-associated-consts.rs @@ -0,0 +1,26 @@ +// Copyright 2014 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we correctly prevent users from making trait objects +// from traits with associated consts. + +trait Bar { + const X: usize; +} + +fn make_bar<T:Bar>(t: &T) -> &Bar { + //~^ ERROR E0038 + //~| NOTE the trait cannot contain associated consts like `X` + //~| NOTE the trait `Bar` cannot be made into an object + t +} + +fn main() { +} |
