]> git.lizzy.rs Git - rust.git/blob - tests/ui/explore-issue-38412.rs
Rollup merge of #107576 - P1n3appl3:master, r=tmandry
[rust.git] / tests / ui / explore-issue-38412.rs
1 // aux-build:pub-and-stability.rs
2
3 // A big point of this test is that we *declare* `unstable_declared`,
4 // but do *not* declare `unstable_undeclared`. This way we can check
5 // that the compiler is letting in uses of declared feature-gated
6 // stuff but still rejecting uses of undeclared feature-gated stuff.
7 #![feature(unstable_declared)]
8
9 extern crate pub_and_stability;
10 use pub_and_stability::{Record, Trait, Tuple};
11
12 fn main() {
13     // Okay
14     let Record { .. } = Record::new();
15
16     // Okay
17     let Record { a_stable_pub: _, a_unstable_declared_pub: _, .. } = Record::new();
18
19     let Record { a_stable_pub: _, a_unstable_declared_pub: _, a_unstable_undeclared_pub: _, .. } =
20         Record::new();
21     //~^^ ERROR use of unstable library feature 'unstable_undeclared'
22
23     let r = Record::new();
24     let t = Tuple::new();
25
26     r.a_stable_pub;
27     r.a_unstable_declared_pub;
28     r.a_unstable_undeclared_pub; //~ ERROR use of unstable library feature
29     r.b_crate;                   //~ ERROR is private
30     r.c_mod;                     //~ ERROR is private
31     r.d_priv;                    //~ ERROR is private
32
33     t.0;
34     t.1;
35     t.2;                         //~ ERROR use of unstable library feature
36     t.3;                         //~ ERROR is private
37     t.4;                         //~ ERROR is private
38     t.5;                         //~ ERROR is private
39
40     r.stable_trait_method();
41     r.unstable_declared_trait_method();
42     r.unstable_undeclared_trait_method(); //~ ERROR use of unstable library feature
43
44     r.stable();
45     r.unstable_declared();
46     r.unstable_undeclared();              //~ ERROR use of unstable library feature
47
48     r.pub_crate();                        //~ ERROR `pub_crate` is private
49     r.pub_mod();                          //~ ERROR `pub_mod` is private
50     r.private();                          //~ ERROR `private` is private
51
52     let t = Tuple::new();
53     t.stable_trait_method();
54     t.unstable_declared_trait_method();
55     t.unstable_undeclared_trait_method(); //~ ERROR use of unstable library feature
56
57     t.stable();
58     t.unstable_declared();
59     t.unstable_undeclared();              //~ ERROR use of unstable library feature
60
61     t.pub_crate();                        //~ ERROR `pub_crate` is private
62     t.pub_mod();                          //~ ERROR `pub_mod` is private
63     t.private();                          //~ ERROR `private` is private
64 }