Skip to content

Commit 2a5ce10

Browse files
committed
Add test
1 parent 11c62de commit 2a5ce10

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

src/test/ui/edition-lint-paths.rs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
#![feature(crate_in_paths)]
12+
#![deny(absolute_path_starting_with_module)]
13+
#![allow(unused)]
14+
15+
pub mod foo {
16+
use ::bar::Bar;
17+
//~^ ERROR Absolute
18+
//~| WARN this was previously accepted
19+
use super::bar::Bar2;
20+
use crate::bar::Bar3;
21+
}
22+
23+
24+
use bar::Bar;
25+
//~^ ERROR Absolute
26+
//~| WARN this was previously accepted
27+
28+
pub mod bar {
29+
pub struct Bar;
30+
pub type Bar2 = Bar;
31+
pub type Bar3 = Bar;
32+
}
33+
34+
fn main() {
35+
let x = ::bar::Bar;
36+
//~^ ERROR Absolute
37+
//~| WARN this was previously accepted
38+
let x = bar::Bar;
39+
let x = ::crate::bar::Bar;
40+
let x = self::bar::Bar;
41+
}

src/test/ui/edition-lint-paths.stderr

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error: Absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
2+
--> $DIR/edition-lint-paths.rs:16:9
3+
|
4+
LL | use ::bar::Bar;
5+
| ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar`
6+
|
7+
note: lint level defined here
8+
--> $DIR/edition-lint-paths.rs:12:9
9+
|
10+
LL | #![deny(absolute_path_starting_with_module)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
13+
= note: for more information, see issue TBD
14+
15+
error: Absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
16+
--> $DIR/edition-lint-paths.rs:24:5
17+
|
18+
LL | use bar::Bar;
19+
| ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
20+
|
21+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
22+
= note: for more information, see issue TBD
23+
24+
error: Absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
25+
--> $DIR/edition-lint-paths.rs:35:13
26+
|
27+
LL | let x = ::bar::Bar;
28+
| ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar`
29+
|
30+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
31+
= note: for more information, see issue TBD
32+
33+
error: aborting due to 3 previous errors
34+

0 commit comments

Comments
 (0)