Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
"crate-ify" paths that begin with a renamed crate
- Loading branch information
1 parent
27649b7
commit 2249d65
Showing
11 changed files
with
277 additions
and
1 deletion.
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
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,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-pass | ||
// aux-build:edition-lint-paths.rs | ||
// run-rustfix | ||
|
||
// The "normal case". Ideally we would remove the `extern crate` here, | ||
// but we don't. | ||
|
||
#![feature(rust_2018_preview)] | ||
#![deny(absolute_path_not_starting_with_crate)] | ||
|
||
extern crate edition_lint_paths; | ||
|
||
use edition_lint_paths::foo; | ||
|
||
fn main() { | ||
foo(); | ||
} | ||
|
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,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-pass | ||
// aux-build:edition-lint-paths.rs | ||
// run-rustfix | ||
|
||
// The "normal case". Ideally we would remove the `extern crate` here, | ||
// but we don't. | ||
|
||
#![feature(rust_2018_preview)] | ||
#![deny(absolute_path_not_starting_with_crate)] | ||
|
||
extern crate edition_lint_paths; | ||
|
||
use edition_lint_paths::foo; | ||
|
||
fn main() { | ||
foo(); | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
src/test/ui/rust-2018/extern-crate-referenced-by-self-path.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,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-pass | ||
// aux-build:edition-lint-paths.rs | ||
// run-rustfix | ||
|
||
// Oddball: `edition_lint_paths` is accessed via this `self` path | ||
// rather than being accessed directly. Unless we rewrite that path, | ||
// we can't drop the extern crate. | ||
|
||
#![feature(rust_2018_preview)] | ||
#![deny(absolute_path_not_starting_with_crate)] | ||
|
||
extern crate edition_lint_paths; | ||
use self::edition_lint_paths::foo; | ||
|
||
fn main() { | ||
foo(); | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
src/test/ui/rust-2018/extern-crate-referenced-by-self-path.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,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-pass | ||
// aux-build:edition-lint-paths.rs | ||
// run-rustfix | ||
|
||
// Oddball: `edition_lint_paths` is accessed via this `self` path | ||
// rather than being accessed directly. Unless we rewrite that path, | ||
// we can't drop the extern crate. | ||
|
||
#![feature(rust_2018_preview)] | ||
#![deny(absolute_path_not_starting_with_crate)] | ||
|
||
extern crate edition_lint_paths; | ||
use self::edition_lint_paths::foo; | ||
|
||
fn main() { | ||
foo(); | ||
} | ||
|
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,29 @@ | ||
// 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. | ||
|
||
// aux-build:edition-lint-paths.rs | ||
// run-rustfix | ||
|
||
// Oddball: crate is renamed, making it harder for us to rewrite | ||
// paths. We don't (and we leave the `extern crate` in place). | ||
|
||
#![feature(rust_2018_preview)] | ||
#![deny(absolute_path_not_starting_with_crate)] | ||
|
||
extern crate edition_lint_paths as my_crate; | ||
|
||
use crate::my_crate::foo; | ||
//~^ ERROR absolute paths must start | ||
//~| WARNING this was previously accepted | ||
|
||
fn main() { | ||
foo(); | ||
} | ||
|
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,29 @@ | ||
// 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. | ||
|
||
// aux-build:edition-lint-paths.rs | ||
// run-rustfix | ||
|
||
// Oddball: crate is renamed, making it harder for us to rewrite | ||
// paths. We don't (and we leave the `extern crate` in place). | ||
|
||
#![feature(rust_2018_preview)] | ||
#![deny(absolute_path_not_starting_with_crate)] | ||
|
||
extern crate edition_lint_paths as my_crate; | ||
|
||
use my_crate::foo; | ||
//~^ ERROR absolute paths must start | ||
//~| WARNING this was previously accepted | ||
|
||
fn main() { | ||
foo(); | ||
} | ||
|
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,16 @@ | ||
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition | ||
--> $DIR/extern-crate-rename.rs:22:5 | ||
| | ||
LL | use my_crate::foo; | ||
| ^^^^^^^^^^^^^ help: use `crate`: `crate::my_crate::foo` | ||
| | ||
note: lint level defined here | ||
--> $DIR/extern-crate-rename.rs:18: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 | ||
|
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,36 @@ | ||
// 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. | ||
|
||
// aux-build:edition-lint-paths.rs | ||
// run-rustfix | ||
|
||
// Oddball: extern crate appears in a submodule, making it harder for | ||
// us to rewrite paths. We don't (and we leave the `extern crate` in | ||
// place). | ||
|
||
#![feature(rust_2018_preview)] | ||
#![deny(absolute_path_not_starting_with_crate)] | ||
|
||
mod m { | ||
// Because this extern crate does not appear at the root, we | ||
// ignore it altogether. | ||
pub extern crate edition_lint_paths; | ||
} | ||
|
||
// And we don't being smart about paths like this, even though you | ||
// *could* rewrite it to `use edition_lint_paths::foo` | ||
use crate::m::edition_lint_paths::foo; | ||
//~^ ERROR absolute paths must start | ||
//~| WARNING this was previously accepted | ||
|
||
fn main() { | ||
foo(); | ||
} | ||
|
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,36 @@ | ||
// 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. | ||
|
||
// aux-build:edition-lint-paths.rs | ||
// run-rustfix | ||
|
||
// Oddball: extern crate appears in a submodule, making it harder for | ||
// us to rewrite paths. We don't (and we leave the `extern crate` in | ||
// place). | ||
|
||
#![feature(rust_2018_preview)] | ||
#![deny(absolute_path_not_starting_with_crate)] | ||
|
||
mod m { | ||
// Because this extern crate does not appear at the root, we | ||
// ignore it altogether. | ||
pub extern crate edition_lint_paths; | ||
} | ||
|
||
// And we don't being smart about paths like this, even though you | ||
// *could* rewrite it to `use edition_lint_paths::foo` | ||
use m::edition_lint_paths::foo; | ||
//~^ ERROR absolute paths must start | ||
//~| WARNING this was previously accepted | ||
|
||
fn main() { | ||
foo(); | ||
} | ||
|
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,16 @@ | ||
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition | ||
--> $DIR/extern-crate-submod.rs:29:5 | ||
| | ||
LL | use m::edition_lint_paths::foo; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::m::edition_lint_paths::foo` | ||
| | ||
note: lint level defined here | ||
--> $DIR/extern-crate-submod.rs:19: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 | ||
|