]> git.lizzy.rs Git - rust.git/blob - src/test/ui/no-implicit-prelude-nested.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / ui / no-implicit-prelude-nested.rs
1 // Test that things from the prelude aren't in scope. Use many of them
2 // so that renaming some things won't magically make this test fail
3 // for the wrong reason (e.g., if `Add` changes to `Addition`, and
4 // `no_implicit_prelude` stops working, then the `impl Add` will still
5 // fail with the same error message).
6
7 #[no_implicit_prelude]
8 mod foo {
9     mod baz {
10         struct Test;
11         impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope
12         impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope
13         impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope
14         impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope
15         impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope
16
17         fn foo() {
18             drop(2) //~ ERROR cannot find function `drop` in this scope
19         }
20     }
21
22     struct Test;
23     impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope
24     impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope
25     impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope
26     impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope
27     impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope
28
29     fn foo() {
30         drop(2) //~ ERROR cannot find function `drop` in this scope
31     }
32 }
33
34 fn qux() {
35     #[no_implicit_prelude]
36     mod qux_inner {
37         struct Test;
38         impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope
39         impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope
40         impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope
41         impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope
42         impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope
43
44         fn foo() {
45             drop(2) //~ ERROR cannot find function `drop` in this scope
46         }
47     }
48 }
49
50
51 fn main() {
52     // these should work fine
53     drop(2)
54 }