-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #50100 - Manishearth:edition-path-lint, r=nikomatsakis
Edition breakage lint for absolute paths starting with modules We plan to enable `extern_absolute_paths` in the 2018 edition. To allow for that, folks must transition their paths in a previous edition to the new one. This makes paths which import module contents via `use module::` or `::module::` obsolete, and we must edition-lint these. https://internals.rust-lang.org/t/the-great-module-adventure-continues/6678/205?u=manishearth is the current plan for paths. r? @nikomatsakis Fixes #48722
- Loading branch information
Showing
7 changed files
with
157 additions
and
15 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
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
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
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,41 @@ | ||
// 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. | ||
|
||
#![feature(crate_in_paths)] | ||
#![deny(absolute_path_starting_with_module)] | ||
#![allow(unused)] | ||
|
||
pub mod foo { | ||
use ::bar::Bar; | ||
//~^ ERROR Absolute | ||
//~| WARN this was previously accepted | ||
use super::bar::Bar2; | ||
use crate::bar::Bar3; | ||
} | ||
|
||
|
||
use bar::Bar; | ||
//~^ ERROR Absolute | ||
//~| WARN this was previously accepted | ||
|
||
pub mod bar { | ||
pub struct Bar; | ||
pub type Bar2 = Bar; | ||
pub type Bar3 = Bar; | ||
} | ||
|
||
fn main() { | ||
let x = ::bar::Bar; | ||
//~^ ERROR Absolute | ||
//~| WARN this was previously accepted | ||
let x = bar::Bar; | ||
let x = ::crate::bar::Bar; | ||
let x = self::bar::Bar; | ||
} |
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-paths.rs:16:9 | ||
| | ||
LL | use ::bar::Bar; | ||
| ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar` | ||
| | ||
note: lint level defined here | ||
--> $DIR/edition-lint-paths.rs:12:9 | ||
| | ||
LL | #![deny(absolute_path_starting_with_module)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= 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:24:5 | ||
| | ||
LL | use 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: Absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition | ||
--> $DIR/edition-lint-paths.rs:35: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 3 previous errors | ||
|