]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/auto-traits.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / test / run-pass / auto-traits.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(optin_builtin_traits)]
12
13 auto trait Auto {}
14 // Redundant but accepted until we remove it.
15 #[allow(auto_impl)]
16 impl Auto for .. {}
17
18 unsafe auto trait AutoUnsafe {}
19
20 impl !Auto for bool {}
21 impl !AutoUnsafe for bool {}
22
23 struct AutoBool(bool);
24
25 impl Auto for AutoBool {}
26 unsafe impl AutoUnsafe for AutoBool {}
27
28 fn take_auto<T: Auto>(_: T) {}
29 fn take_auto_unsafe<T: AutoUnsafe>(_: T) {}
30
31 fn main() {
32 take_auto(0);
33 take_auto(AutoBool(true));
34 take_auto_unsafe(0);
35 take_auto_unsafe(AutoBool(true));
36
37 /// Auto traits are allowed in trait object bounds.
38 let _: &(Send + Auto) = &0;
39 }