]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/auto-traits.rs
New upstream version 1.23.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 {}
14// Redundant but accepted until we remove it.
15#[allow(auto_impl)]
16impl Auto for .. {}
17
18unsafe auto trait AutoUnsafe {}
19
20impl !Auto for bool {}
21impl !AutoUnsafe for bool {}
22
23struct AutoBool(bool);
24
25impl Auto for AutoBool {}
26unsafe impl AutoUnsafe for AutoBool {}
27
28fn take_auto<T: Auto>(_: T) {}
29fn take_auto_unsafe<T: AutoUnsafe>(_: T) {}
30
31fn 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}