Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle fully qualified paths properly when linting
fixes #50970
- Loading branch information
1 parent
be2bb80
commit 42d0b36
Showing
7 changed files
with
261 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/test/ui/rust-2018/edition-lint-fully-qualified-paths.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 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)] | ||
|
||
mod foo { | ||
crate trait Foo { | ||
type Bar; | ||
} | ||
|
||
crate struct Baz { } | ||
|
||
impl Foo for Baz { | ||
type Bar = (); | ||
} | ||
} | ||
|
||
|
||
fn main() { | ||
let _: <foo::Baz as crate::foo::Foo>::Bar = (); | ||
//~^ ERROR absolute paths must start with | ||
//~| this was previously accepted | ||
|
||
let _: <crate::foo::Baz as foo::Foo>::Bar = (); | ||
//~^ ERROR absolute paths must start with | ||
//~| this was previously accepted | ||
} |
37 changes: 37 additions & 0 deletions
37
src/test/ui/rust-2018/edition-lint-fully-qualified-paths.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 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)] | ||
|
||
mod foo { | ||
crate trait Foo { | ||
type Bar; | ||
} | ||
|
||
crate struct Baz { } | ||
|
||
impl Foo for Baz { | ||
type Bar = (); | ||
} | ||
} | ||
|
||
|
||
fn main() { | ||
let _: <foo::Baz as ::foo::Foo>::Bar = (); | ||
//~^ ERROR absolute paths must start with | ||
//~| this was previously accepted | ||
|
||
let _: <::foo::Baz as foo::Foo>::Bar = (); | ||
//~^ ERROR absolute paths must start with | ||
//~| this was previously accepted | ||
} |
25 changes: 25 additions & 0 deletions
25
src/test/ui/rust-2018/edition-lint-fully-qualified-paths.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition | ||
--> $DIR/edition-lint-fully-qualified-paths.rs:30:25 | ||
| | ||
LL | let _: <foo::Baz as ::foo::Foo>::Bar = (); | ||
| ^^^^^^^^^^ help: use `crate`: `crate::foo::Foo` | ||
| | ||
note: lint level defined here | ||
--> $DIR/edition-lint-fully-qualified-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: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition | ||
--> $DIR/edition-lint-fully-qualified-paths.rs:34:13 | ||
| | ||
LL | let _: <::foo::Baz as foo::Foo>::Bar = (); | ||
| ^^^^^^^^^^ help: use `crate`: `crate::foo::Baz` | ||
| | ||
= 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 2 previous errors | ||
|
40 changes: 40 additions & 0 deletions
40
src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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)] | ||
#![allow(unused_imports)] | ||
#![allow(dead_code)] | ||
|
||
crate mod foo { | ||
crate mod bar { | ||
crate mod baz { } | ||
crate mod baz1 { } | ||
|
||
crate struct XX; | ||
} | ||
} | ||
|
||
use crate::foo::{bar::{baz::{}}}; | ||
//~^ ERROR absolute paths must start with | ||
//~| WARN this was previously accepted | ||
|
||
use crate::foo::{bar::{XX, baz::{}}}; | ||
//~^ ERROR absolute paths must start with | ||
//~| WARN this was previously accepted | ||
|
||
use crate::foo::{bar::{baz::{}, baz1::{}}}; | ||
//~^ ERROR absolute paths must start with | ||
//~| WARN this was previously accepted | ||
|
||
fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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)] | ||
#![allow(unused_imports)] | ||
#![allow(dead_code)] | ||
|
||
crate mod foo { | ||
crate mod bar { | ||
crate mod baz { } | ||
crate mod baz1 { } | ||
|
||
crate struct XX; | ||
} | ||
} | ||
|
||
use foo::{bar::{baz::{}}}; | ||
//~^ ERROR absolute paths must start with | ||
//~| WARN this was previously accepted | ||
|
||
use foo::{bar::{XX, baz::{}}}; | ||
//~^ ERROR absolute paths must start with | ||
//~| WARN this was previously accepted | ||
|
||
use foo::{bar::{baz::{}, baz1::{}}}; | ||
//~^ ERROR absolute paths must start with | ||
//~| WARN this was previously accepted | ||
|
||
fn main() { | ||
} |
34 changes: 34 additions & 0 deletions
34
src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition | ||
--> $DIR/edition-lint-nested-empty-paths.rs:27:5 | ||
| | ||
LL | use foo::{bar::{baz::{}}}; | ||
| ^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}}}` | ||
| | ||
note: lint level defined here | ||
--> $DIR/edition-lint-nested-empty-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: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition | ||
--> $DIR/edition-lint-nested-empty-paths.rs:31:5 | ||
| | ||
LL | use foo::{bar::{XX, baz::{}}}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` | ||
| | ||
= 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-nested-empty-paths.rs:35:5 | ||
| | ||
LL | use foo::{bar::{baz::{}, baz1::{}}}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` | ||
| | ||
= 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 3 previous errors | ||
|