]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/no-implicit-prelude-nested.rs
New upstream version 1.24.1+dfsg1
[rustc.git] / src / test / compile-fail / no-implicit-prelude-nested.rs
1 // Copyright 2013 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 // Test that things from the prelude aren't in scope. Use many of them
12 // so that renaming some things won't magically make this test fail
13 // for the wrong reason (e.g. if `Add` changes to `Addition`, and
14 // `no_implicit_prelude` stops working, then the `impl Add` will still
15 // fail with the same error message).
16
17 #[no_implicit_prelude]
18 mod foo {
19 mod baz {
20 struct Test;
21 impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope
22 impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope
23 impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope
24 impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope
25 impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope
26
27 fn foo() {
28 drop(2) //~ ERROR cannot find function `drop` in this scope
29 }
30 }
31
32 struct Test;
33 impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope
34 impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope
35 impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope
36 impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope
37 impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope
38
39 fn foo() {
40 drop(2) //~ ERROR cannot find function `drop` in this scope
41 }
42 }
43
44 fn qux() {
45 #[no_implicit_prelude]
46 mod qux_inner {
47 struct Test;
48 impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope
49 impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope
50 impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope
51 impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope
52 impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope
53
54 fn foo() {
55 drop(2) //~ ERROR cannot find function `drop` in this scope
56 }
57 }
58 }
59
60
61 fn main() {
62 // these should work fine
63 drop(2)
64 }