|
| 1 | +// Copyright 2016 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 | +mod m { |
| 12 | + pub enum E { |
| 13 | + Fn(u8), |
| 14 | + Struct { |
| 15 | + s: u8, |
| 16 | + }, |
| 17 | + Unit, |
| 18 | + } |
| 19 | + |
| 20 | + pub mod n { |
| 21 | + pub(in m) enum Z { |
| 22 | + Fn(u8), |
| 23 | + Struct { |
| 24 | + s: u8, |
| 25 | + }, |
| 26 | + Unit, |
| 27 | + } |
| 28 | + } |
| 29 | + |
| 30 | + use m::n::Z; // OK, only the type is imported |
| 31 | + |
| 32 | + fn f() { |
| 33 | + n::Z; |
| 34 | + //~^ ERROR expected value, found enum `n::Z` |
| 35 | + Z; |
| 36 | + //~^ ERROR expected value, found enum `Z` |
| 37 | + let _: Z = Z::Fn; |
| 38 | + //~^ ERROR mismatched types |
| 39 | + let _: Z = Z::Struct; |
| 40 | + //~^ ERROR expected value, found struct variant `Z::Struct` |
| 41 | + let _ = Z::Unit(); |
| 42 | + //~^ ERROR expected function, found enum variant `Z::Unit` |
| 43 | + let _ = Z::Unit {}; |
| 44 | + // This is ok, it is equivalent to not having braces |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +use m::E; // OK, only the type is imported |
| 49 | + |
| 50 | +fn main() { |
| 51 | + let _: E = m::E; |
| 52 | + //~^ ERROR expected value, found enum `m::E` |
| 53 | + let _: E = m::E::Fn; |
| 54 | + //~^ ERROR mismatched types |
| 55 | + let _: E = m::E::Struct; |
| 56 | + //~^ ERROR expected value, found struct variant `m::E::Struct` |
| 57 | + let _: E = m::E::Unit(); |
| 58 | + //~^ ERROR expected function, found enum variant `m::E::Unit` |
| 59 | + let _: E = E; |
| 60 | + //~^ ERROR expected value, found enum `E` |
| 61 | + let _: E = E::Fn; |
| 62 | + //~^ ERROR mismatched types |
| 63 | + let _: E = E::Struct; |
| 64 | + //~^ ERROR expected value, found struct variant `E::Struct` |
| 65 | + let _: E = E::Unit(); |
| 66 | + //~^ ERROR expected function, found enum variant `E::Unit` |
| 67 | + let _: Z = m::n::Z; |
| 68 | + //~^ ERROR cannot find type `Z` in this scope |
| 69 | + //~| ERROR expected value, found enum `m::n::Z` |
| 70 | + //~| ERROR enum `Z` is private |
| 71 | + let _: Z = m::n::Z::Fn; |
| 72 | + //~^ ERROR cannot find type `Z` in this scope |
| 73 | + //~| ERROR enum `Z` is private |
| 74 | + let _: Z = m::n::Z::Struct; |
| 75 | + //~^ ERROR cannot find type `Z` in this scope |
| 76 | + //~| ERROR expected value, found struct variant `m::n::Z::Struct` |
| 77 | + //~| ERROR enum `Z` is private |
| 78 | + let _: Z = m::n::Z::Unit {}; |
| 79 | + //~^ ERROR cannot find type `Z` in this scope |
| 80 | + //~| ERROR enum `Z` is private |
| 81 | +} |
0 commit comments