]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail-fulldeps/explore-issue-38412.rs
Auto merge of #38779 - Craig-Macomber:bench, r=alexcrichton
[rust.git] / src / test / compile-fail-fulldeps / explore-issue-38412.rs
1 // Copyright 2014 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:pub_and_stability.rs
12
13 #![feature(staged_api)]
14 #![feature(unused_feature)]
15
16 // A big point of this test is that we *declare* `unstable_declared`,
17 // but do *not* declare `unstable_undeclared`. This way we can check
18 // that the compiler is letting in uses of declared feature-gated
19 // stuff but still rejecting uses of undeclared feature-gated stuff.
20 #![feature(unstable_declared)]
21
22 extern crate pub_and_stability;
23 use pub_and_stability::{Record, Trait, Tuple};
24
25 fn main() {
26     // Okay
27     let Record { .. } = Record::new();
28     // Okay (for now; see RFC Issue #902)
29     let Tuple(..) = Tuple::new();
30
31     // Okay
32     let Record { a_stable_pub: _, a_unstable_declared_pub: _, .. } = Record::new();
33     // Okay (for now; see RFC Issue #902)
34     let Tuple(_, _, ..) = Tuple::new(); // analogous to above
35
36     let Record { a_stable_pub: _, a_unstable_declared_pub: _, a_unstable_undeclared_pub: _, .. } =
37         Record::new();
38     //~^^ ERROR use of unstable library feature 'unstable_undeclared'
39
40     let Tuple(_, _, _, ..) = Tuple::new(); // analogous to previous
41     //~^ ERROR use of unstable library feature 'unstable_undeclared'
42
43     let r = Record::new();
44     let t = Tuple::new();
45
46     r.a_stable_pub;
47     r.a_unstable_declared_pub;
48     r.a_unstable_undeclared_pub; //~ ERROR use of unstable library feature
49     r.b_crate;                   //~ ERROR is private
50     r.c_mod;                     //~ ERROR is private
51     r.d_priv;                    //~ ERROR is private
52
53     t.0;
54     t.1;
55     t.2;                         //~ ERROR use of unstable library feature
56     t.3;                         //~ ERROR is private
57     t.4;                         //~ ERROR is private
58     t.5;                         //~ ERROR is private
59
60     r.stable_trait_method();
61     r.unstable_declared_trait_method();
62     r.unstable_undeclared_trait_method(); //~ ERROR use of unstable library feature
63
64     r.stable();
65     r.unstable_declared();
66     r.unstable_undeclared();              //~ ERROR use of unstable library feature
67
68     r.pub_crate();                        //~ ERROR `pub_crate` is private
69     r.pub_mod();                          //~ ERROR `pub_mod` is private
70     r.private();                          //~ ERROR `private` is private
71
72     let t = Tuple::new();
73     t.stable_trait_method();
74     t.unstable_declared_trait_method();
75     t.unstable_undeclared_trait_method(); //~ ERROR use of unstable library feature
76
77     t.stable();
78     t.unstable_declared();
79     t.unstable_undeclared();              //~ ERROR use of unstable library feature
80
81     t.pub_crate();                        //~ ERROR `pub_crate` is private
82     t.pub_mod();                          //~ ERROR `pub_mod` is private
83     t.private();                          //~ ERROR `private` is private
84
85 }