Skip to content

Commit

Permalink
add new test and add an existing scenario I didn't see covered
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed May 22, 2018
1 parent 9f11714 commit dfd2a13
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 4 deletions.
28 changes: 28 additions & 0 deletions src/test/ui/rust-2018/edition-lint-nested-paths.fixed
@@ -0,0 +1,28 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// run-rustfix

#![feature(rust_2018_preview)]
#![deny(absolute_path_not_starting_with_crate)]

use crate::foo::{a, b};
//~^ ERROR absolute paths must start with
//~| this was previously accepted

mod foo {
crate fn a() {}
crate fn b() {}
}

fn main() {
a();
b();
}
28 changes: 28 additions & 0 deletions src/test/ui/rust-2018/edition-lint-nested-paths.rs
@@ -0,0 +1,28 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// run-rustfix

#![feature(rust_2018_preview)]
#![deny(absolute_path_not_starting_with_crate)]

use foo::{a, b};
//~^ ERROR absolute paths must start with
//~| this was previously accepted

mod foo {
crate fn a() {}
crate fn b() {}
}

fn main() {
a();
b();
}
16 changes: 16 additions & 0 deletions src/test/ui/rust-2018/edition-lint-nested-paths.stderr
@@ -0,0 +1,16 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-nested-paths.rs:16:5
|
LL | use foo::{a, b};
| ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}`
|
note: lint level defined here
--> $DIR/edition-lint-nested-paths.rs:14:9
|
LL | #![deny(absolute_path_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
= note: for more information, see issue TBD

error: aborting due to previous error

6 changes: 6 additions & 0 deletions src/test/ui/rust-2018/edition-lint-paths.fixed
Expand Up @@ -40,6 +40,8 @@ pub mod foo {

pub fn test() {
}

pub trait SomeTrait { }
}

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

impl crate::foo::SomeTrait for u32 { }
//~^ ERROR absolute
//~| WARN this was previously accepted

fn main() {
let x = crate::bar::Bar;
//~^ ERROR absolute
Expand Down
6 changes: 6 additions & 0 deletions src/test/ui/rust-2018/edition-lint-paths.rs
Expand Up @@ -40,6 +40,8 @@ pub mod foo {

pub fn test() {
}

pub trait SomeTrait { }
}

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

impl ::foo::SomeTrait for u32 { }
//~^ ERROR absolute
//~| WARN this was previously accepted

fn main() {
let x = ::bar::Bar;
//~^ ERROR absolute
Expand Down
17 changes: 13 additions & 4 deletions src/test/ui/rust-2018/edition-lint-paths.stderr
Expand Up @@ -40,7 +40,7 @@ LL | use {Bar as SomethingElse, main};
= note: for more information, see issue TBD

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

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

error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:63:13
--> $DIR/edition-lint-paths.rs:64:6
|
LL | impl ::foo::SomeTrait for u32 { }
| ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
= note: for more information, see issue TBD

error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
--> $DIR/edition-lint-paths.rs:69:13
|
LL | let x = ::bar::Bar;
| ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
= note: for more information, see issue TBD

error: aborting due to 7 previous errors
error: aborting due to 8 previous errors

0 comments on commit dfd2a13

Please sign in to comment.