2024-02-16 14:02:50 -06:00
|
|
|
//@ run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(unused_doc_comments)]
|
2020-11-22 21:54:31 -06:00
|
|
|
#![feature(auto_traits)]
|
2020-01-09 04:56:38 -06:00
|
|
|
#![feature(negative_impls)]
|
2017-10-12 17:00:30 -05:00
|
|
|
|
|
|
|
auto trait Auto {}
|
|
|
|
unsafe auto trait AutoUnsafe {}
|
|
|
|
|
|
|
|
impl !Auto for bool {}
|
|
|
|
impl !AutoUnsafe for bool {}
|
|
|
|
|
2023-12-27 16:11:58 -06:00
|
|
|
struct AutoBool(#[allow(dead_code)] bool);
|
2017-10-12 17:00:30 -05:00
|
|
|
|
|
|
|
impl Auto for AutoBool {}
|
|
|
|
unsafe impl AutoUnsafe for AutoBool {}
|
|
|
|
|
|
|
|
fn take_auto<T: Auto>(_: T) {}
|
|
|
|
fn take_auto_unsafe<T: AutoUnsafe>(_: T) {}
|
|
|
|
|
|
|
|
fn main() {
|
2017-12-04 12:26:20 -06:00
|
|
|
// Parse inside functions.
|
2024-02-06 20:42:01 -06:00
|
|
|
auto trait AutoInner {} //~ WARN trait `AutoInner` is never used
|
|
|
|
unsafe auto trait AutoUnsafeInner {} //~ WARN trait `AutoUnsafeInner` is never used
|
2017-12-04 12:26:20 -06:00
|
|
|
|
2017-10-12 17:00:30 -05:00
|
|
|
take_auto(0);
|
|
|
|
take_auto(AutoBool(true));
|
|
|
|
take_auto_unsafe(0);
|
|
|
|
take_auto_unsafe(AutoBool(true));
|
2017-11-04 16:44:19 -05:00
|
|
|
|
|
|
|
/// Auto traits are allowed in trait object bounds.
|
2019-05-28 13:47:21 -05:00
|
|
|
let _: &(dyn Send + Auto) = &0;
|
2017-10-12 17:00:30 -05:00
|
|
|
}
|