|
| 1 | +//! Check that when the feature `import_trait_associated_functions` is enabled, |
| 2 | +//! and one trys to import inherent associated items, the error message is |
| 3 | +//! updated to reflect that only trait associated items can be imported. |
| 4 | +//! |
| 5 | +//! Regression test for <https://github.com/rust-lang/rust/issues/148009>. |
| 6 | +
|
| 7 | +//@ check-fail |
| 8 | + |
| 9 | +#![feature(import_trait_associated_functions, extern_types)] |
| 10 | + |
| 11 | +pub struct TestStruct; |
| 12 | + |
| 13 | +impl TestStruct { |
| 14 | + pub fn m1() {} |
| 15 | + pub const C1: usize = 0; |
| 16 | +} |
| 17 | + |
| 18 | +pub use self::TestStruct::{C1, m1}; |
| 19 | +//~^ ERROR unresolved import `self::TestStruct` [E0432] |
| 20 | +//~| NOTE `TestStruct` is a struct, not a module or a trait |
| 21 | +//~| NOTE cannot import inherent associated items, only trait associated items |
| 22 | + |
| 23 | +pub union TestUnion { |
| 24 | + pub f: f32, |
| 25 | + pub i: i32, |
| 26 | +} |
| 27 | + |
| 28 | +impl TestUnion { |
| 29 | + pub fn m2() {} |
| 30 | + pub const C2: usize = 0; |
| 31 | +} |
| 32 | + |
| 33 | +pub use self::TestUnion::{C2, m2}; |
| 34 | +//~^ ERROR unresolved import `self::TestUnion` [E0432] |
| 35 | +//~| NOTE `TestUnion` is a union, not a module or a trait |
| 36 | +//~| NOTE cannot import inherent associated items, only trait associated items |
| 37 | + |
| 38 | +pub enum TestEnum { |
| 39 | + V1, |
| 40 | + V2, |
| 41 | +} |
| 42 | + |
| 43 | +impl TestEnum { |
| 44 | + pub fn m3() {} |
| 45 | + pub const C3: usize = 0; |
| 46 | +} |
| 47 | + |
| 48 | +pub use self::TestEnum::{C3, m3}; |
| 49 | +//~^ ERROR unresolved imports `self::TestEnum::C3`, `self::TestEnum::m3` [E0432] |
| 50 | +//~| NOTE no `m3` in `TestEnum` |
| 51 | +//~| NOTE no `C3` in `TestEnum` |
| 52 | +//~| NOTE cannot import inherent associated items, only trait associated items |
| 53 | + |
| 54 | +extern "C" { |
| 55 | + pub type TestForeignTy; |
| 56 | +} |
| 57 | + |
| 58 | +impl TestForeignTy { |
| 59 | + pub fn m4() {} |
| 60 | + pub const C4: usize = 0; |
| 61 | +} |
| 62 | + |
| 63 | +pub use self::TestForeignTy::{C4, m4}; |
| 64 | +//~^ ERROR unresolved import `self::TestForeignTy` [E0432] |
| 65 | +//~| NOTE `TestForeignTy` is a foreign type, not a module or a trait |
| 66 | +//~| NOTE cannot import inherent associated items, only trait associated items |
| 67 | + |
| 68 | +fn main() {} |
0 commit comments