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