]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/auto-traits.rs
New upstream version 1.25.0+dfsg1
[rustc.git] / src / test / run-pass / auto-traits.rs
CommitLineData
abe05a73
XL
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
13auto trait Auto {}
abe05a73
XL
14unsafe auto trait AutoUnsafe {}
15
16impl !Auto for bool {}
17impl !AutoUnsafe for bool {}
18
19struct AutoBool(bool);
20
21impl Auto for AutoBool {}
22unsafe impl AutoUnsafe for AutoBool {}
23
24fn take_auto<T: Auto>(_: T) {}
25fn take_auto_unsafe<T: AutoUnsafe>(_: T) {}
26
27fn main() {
2c00a5a8
XL
28 // Parse inside functions.
29 auto trait AutoInner {}
30 unsafe auto trait AutoUnsafeInner {}
31
abe05a73
XL
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}