|
| 1 | +//@ edition: 2021 |
| 2 | + |
| 3 | +// mod x { |
| 4 | +// use super; // bad |
| 5 | +// use super as name; // good |
| 6 | +// use self; // bad |
| 7 | +// use self as name; // good |
| 8 | +// use crate; // bad |
| 9 | +// use crate as name; // good |
| 10 | +// use $crate; // bad |
| 11 | +// use $crate as name; // good |
| 12 | + |
| 13 | +// mod foo; |
| 14 | +// use foo::crate; // bad |
| 15 | +// use crate::crate; // bad |
| 16 | +// use foo::super; // bad |
| 17 | +// use super::super; // bad |
| 18 | +// use foo::self; // good |
| 19 | +// use self::self; // bad |
| 20 | +// use self::self as name; // good |
| 21 | +// } |
| 22 | + |
| 23 | +fn bar() {} |
| 24 | + |
| 25 | +mod foo { |
| 26 | + pub mod bar { |
| 27 | + pub mod foobar { |
| 28 | + pub fn bar() {} |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + pub use crate as _crate; // Good |
| 33 | + use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` |
| 34 | + use ::crate; //~ ERROR `crate` in paths can only be used in start position |
| 35 | + use bar::crate; //~ ERROR `crate` in paths can only be used in start position |
| 36 | + use crate::crate; //~ ERROR `crate` in paths can only be used in start position |
| 37 | + use super::crate; //~ ERROR `crate` in paths can only be used in start position |
| 38 | + use self::crate; //~ ERROR `crate` in paths can only be used in start position |
| 39 | + use ::crate as _crate2; //~ ERROR `crate` in paths can only be used in start position |
| 40 | + use bar::crate as _crate3; //~ ERROR `crate` in paths can only be used in start position |
| 41 | + use crate::crate as _crate4; //~ ERROR `crate` in paths can only be used in start position |
| 42 | + use super::crate as _crate5; //~ ERROR `crate` in paths can only be used in start position |
| 43 | + use self::crate as _crate6; //~ ERROR `crate` in paths can only be used in start position |
| 44 | + |
| 45 | + pub use super as _super; // Good |
| 46 | + use super; //~ ERROR imports need to be explicitly named: `use super as name;` |
| 47 | + use ::super; //~ ERROR `super` in paths can only be used in start position |
| 48 | + use bar::super; //~ ERROR `super` in paths can only be used in start position |
| 49 | + use crate::super; //~ ERROR `super` in paths can only be used in start position |
| 50 | + use super::super; //~ ERROR `super` in paths can only be used in start position |
| 51 | + use self::super; //~ ERROR `super` in paths can only be used in start position |
| 52 | + use ::super as _super2; //~ ERROR `super` in paths can only be used in start position |
| 53 | + use bar::super as _super3; //~ ERROR `super` in paths can only be used in start position |
| 54 | + use crate::super as _super4; //~ ERROR `super` in paths can only be used in start position |
| 55 | + use super::super as _super5; //~ ERROR `super` in paths can only be used in start position |
| 56 | + use bar::super as _super6; //~ ERROR `super` in paths can only be used in start position |
| 57 | + |
| 58 | + pub use self as _self; // Good |
| 59 | + use self; //~ ERROR imports need to be explicitly named: `use self as name;` |
| 60 | + use ::self; //~ ERROR `self` import can only appear in an import list with a non-empty prefix |
| 61 | + pub use bar::foobar::self; // Good |
| 62 | + use crate::self; //~ ERROR `self` import can only appear in an import list with a non-empty prefix |
| 63 | + use super::self; //~ ERROR `self` import can only appear in an import list with a non-empty prefix |
| 64 | + use self::self; //~ ERROR `self` import can only appear in an import list with a non-empty prefix |
| 65 | + use ::self as _self2; //~ ERROR `self` import can only appear in an import list with a non-empty prefix |
| 66 | + pub use bar::self as _self3; // Good |
| 67 | + use crate::self as _self4; //~ ERROR `self` import can only appear in an import list with a non-empty prefix |
| 68 | + use super::self as _self5; //~ ERROR `self` import can only appear in an import list with a non-empty prefix |
| 69 | + use self::self as _self6; //~ ERROR `self` import can only appear in an import list with a non-empty prefix |
| 70 | +} |
| 71 | + |
| 72 | +fn main() { |
| 73 | + foo::_crate::bar(); |
| 74 | + foo::_super::bar(); |
| 75 | + foo::_self::bar::foobar::bar(); |
| 76 | + foo::foobar::bar(); |
| 77 | + foo::_self3::foobar::bar(); |
| 78 | +} |
0 commit comments