]> git.lizzy.rs Git - rust.git/blob - src/test/ui/internal/internal-unstable.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / internal / internal-unstable.rs
1 // Copyright 2015 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 // aux-build:internal_unstable.rs
12
13 #![feature(allow_internal_unstable)]
14
15 #[macro_use]
16 extern crate internal_unstable;
17
18 macro_rules! foo {
19     ($e: expr, $f: expr) => {{
20         $e;
21         $f;
22         internal_unstable::unstable(); //~ ERROR use of unstable
23     }}
24 }
25
26 #[allow_internal_unstable]
27 macro_rules! bar {
28     ($e: expr) => {{
29         foo!($e,
30              internal_unstable::unstable());
31         internal_unstable::unstable();
32     }}
33 }
34
35 fn main() {
36     // ok, the instability is contained.
37     call_unstable_allow!();
38     construct_unstable_allow!(0);
39     |x: internal_unstable::Foo| { call_method_allow!(x) };
40     |x: internal_unstable::Bar| { access_field_allow!(x) };
41
42     // bad.
43     pass_through_allow!(internal_unstable::unstable()); //~ ERROR use of unstable
44
45     pass_through_noallow!(internal_unstable::unstable()); //~ ERROR use of unstable
46
47
48
49     println!("{:?}", internal_unstable::unstable()); //~ ERROR use of unstable
50
51     bar!(internal_unstable::unstable()); //~ ERROR use of unstable
52 }