]> git.lizzy.rs Git - rust.git/blob - src/test/ui/internal/internal-unstable.rs
Auto merge of #84589 - In-line:zircon-thread-name, r=JohnTitor
[rust.git] / src / test / ui / internal / internal-unstable.rs
1 // aux-build:internal_unstable.rs
2
3 #![feature(allow_internal_unstable)]
4 #[allow(dead_code)]
5
6 #[macro_use]
7 extern crate internal_unstable;
8
9 struct Baz {
10     #[allow_internal_unstable]
11     //^ WARN `#[allow_internal_unstable]` is ignored on struct fields and match arms
12     baz: u8,
13 }
14
15 macro_rules! foo {
16     ($e: expr, $f: expr) => {{
17         $e;
18         $f;
19         internal_unstable::unstable(); //~ ERROR use of unstable
20     }}
21 }
22
23 #[allow_internal_unstable(function)]
24 macro_rules! bar {
25     ($e: expr) => {{
26         foo!($e,
27              internal_unstable::unstable());
28         internal_unstable::unstable();
29     }}
30 }
31
32 fn main() {
33     // ok, the instability is contained.
34     call_unstable_allow!();
35     construct_unstable_allow!(0);
36     |x: internal_unstable::Foo| { call_method_allow!(x) };
37     |x: internal_unstable::Bar| { access_field_allow!(x) };
38     |x: internal_unstable::Bar| { access_field_allow2!(x) }; // regression test for #77088
39
40     // bad.
41     pass_through_allow!(internal_unstable::unstable()); //~ ERROR use of unstable
42
43     pass_through_noallow!(internal_unstable::unstable()); //~ ERROR use of unstable
44
45
46
47     println!("{:?}", internal_unstable::unstable()); //~ ERROR use of unstable
48
49     bar!(internal_unstable::unstable()); //~ ERROR use of unstable
50
51     match true {
52         #[allow_internal_unstable]
53         //^ WARN `#[allow_internal_unstable]` is ignored on struct fields and match arms
54         _ => {}
55     }
56 }