Skip to content

Commit dfd2a13

Browse files
committed
add new test and add an existing scenario I didn't see covered
1 parent 9f11714 commit dfd2a13

6 files changed

+97
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
// run-rustfix
12+
13+
#![feature(rust_2018_preview)]
14+
#![deny(absolute_path_not_starting_with_crate)]
15+
16+
use crate::foo::{a, b};
17+
//~^ ERROR absolute paths must start with
18+
//~| this was previously accepted
19+
20+
mod foo {
21+
crate fn a() {}
22+
crate fn b() {}
23+
}
24+
25+
fn main() {
26+
a();
27+
b();
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
// run-rustfix
12+
13+
#![feature(rust_2018_preview)]
14+
#![deny(absolute_path_not_starting_with_crate)]
15+
16+
use foo::{a, b};
17+
//~^ ERROR absolute paths must start with
18+
//~| this was previously accepted
19+
20+
mod foo {
21+
crate fn a() {}
22+
crate fn b() {}
23+
}
24+
25+
fn main() {
26+
a();
27+
b();
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
2+
--> $DIR/edition-lint-nested-paths.rs:16:5
3+
|
4+
LL | use foo::{a, b};
5+
| ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}`
6+
|
7+
note: lint level defined here
8+
--> $DIR/edition-lint-nested-paths.rs:14:9
9+
|
10+
LL | #![deny(absolute_path_not_starting_with_crate)]
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: aborting due to previous error
16+

src/test/ui/rust-2018/edition-lint-paths.fixed

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub mod foo {
4040

4141
pub fn test() {
4242
}
43+
44+
pub trait SomeTrait { }
4345
}
4446

4547
use crate::bar::Bar;
@@ -59,6 +61,10 @@ mod baz {
5961
//~| WARN this was previously accepted
6062
}
6163

64+
impl crate::foo::SomeTrait for u32 { }
65+
//~^ ERROR absolute
66+
//~| WARN this was previously accepted
67+
6268
fn main() {
6369
let x = crate::bar::Bar;
6470
//~^ ERROR absolute

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

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub mod foo {
4040

4141
pub fn test() {
4242
}
43+
44+
pub trait SomeTrait { }
4345
}
4446

4547
use bar::Bar;
@@ -59,6 +61,10 @@ mod baz {
5961
//~| WARN this was previously accepted
6062
}
6163

64+
impl ::foo::SomeTrait for u32 { }
65+
//~^ ERROR absolute
66+
//~| WARN this was previously accepted
67+
6268
fn main() {
6369
let x = ::bar::Bar;
6470
//~^ ERROR absolute

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

+13-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ LL | use {Bar as SomethingElse, main};
4040
= note: for more information, see issue TBD
4141

4242
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
43-
--> $DIR/edition-lint-paths.rs:45:5
43+
--> $DIR/edition-lint-paths.rs:47:5
4444
|
4545
LL | use bar::Bar;
4646
| ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
@@ -49,7 +49,7 @@ LL | use bar::Bar;
4949
= note: for more information, see issue TBD
5050

5151
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
52-
--> $DIR/edition-lint-paths.rs:57:9
52+
--> $DIR/edition-lint-paths.rs:59:9
5353
|
5454
LL | use *;
5555
| ^ help: use `crate`: `crate::*`
@@ -58,13 +58,22 @@ LL | use *;
5858
= note: for more information, see issue TBD
5959

6060
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
61-
--> $DIR/edition-lint-paths.rs:63:13
61+
--> $DIR/edition-lint-paths.rs:64:6
62+
|
63+
LL | impl ::foo::SomeTrait for u32 { }
64+
| ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait`
65+
|
66+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
67+
= note: for more information, see issue TBD
68+
69+
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
70+
--> $DIR/edition-lint-paths.rs:69:13
6271
|
6372
LL | let x = ::bar::Bar;
6473
| ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar`
6574
|
6675
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
6776
= note: for more information, see issue TBD
6877

69-
error: aborting due to 7 previous errors
78+
error: aborting due to 8 previous errors
7079

0 commit comments

Comments
 (0)