]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rust-2018/edition-lint-paths.rs
Rollup merge of #53413 - eddyb:featured-in-the-latest-edition, r=varkor
[rust.git] / src / test / ui / rust-2018 / edition-lint-paths.rs
1 // Copyright 2018 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 // aux-build:edition-lint-paths.rs
12 // run-rustfix
13
14 #![feature(rust_2018_preview)]
15 #![deny(absolute_paths_not_starting_with_crate)]
16 #![allow(unused)]
17
18 extern crate edition_lint_paths;
19
20 pub mod foo {
21     use edition_lint_paths;
22     use ::bar::Bar;
23     //~^ ERROR absolute
24     //~| WARN this was previously accepted
25     use super::bar::Bar2;
26     use crate::bar::Bar3;
27
28     use bar;
29     //~^ ERROR absolute
30     //~| WARN this was previously accepted
31     use crate::{bar as something_else};
32
33     use {Bar as SomethingElse, main};
34     //~^ ERROR absolute
35     //~| WARN this was previously accepted
36
37     use crate::{Bar as SomethingElse2, main as another_main};
38
39     pub fn test() {
40     }
41
42     pub trait SomeTrait { }
43 }
44
45 use bar::Bar;
46 //~^ ERROR absolute
47 //~| WARN this was previously accepted
48
49 pub mod bar {
50     use edition_lint_paths as foo;
51     pub struct Bar;
52     pub type Bar2 = Bar;
53     pub type Bar3 = Bar;
54 }
55
56 mod baz {
57     use *;
58     //~^ ERROR absolute
59     //~| WARN this was previously accepted
60 }
61
62 impl ::foo::SomeTrait for u32 { }
63 //~^ ERROR absolute
64 //~| WARN this was previously accepted
65
66 fn main() {
67     let x = ::bar::Bar;
68     //~^ ERROR absolute
69     //~| WARN this was previously accepted
70     let x = bar::Bar;
71     let x = crate::bar::Bar;
72     let x = self::bar::Bar;
73     foo::test();
74
75     {
76         use edition_lint_paths as bar;
77         edition_lint_paths::foo();
78         bar::foo();
79         ::edition_lint_paths::foo();
80     }
81 }