-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delay gensym creation for "underscore items" until name resolution
Prohibit `static _` Fis unused import warnings for `use foo as _` Add more tests for `use foo as _`
- Loading branch information
1 parent
c658d73
commit 2d4b633
Showing
16 changed files
with
157 additions
and
36 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
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,3 @@ | ||
// compile-flags: -Z parse-only | ||
|
||
static _: () = (); //~ ERROR expected identifier, found reserved identifier `_` |
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,8 @@ | ||
error: expected identifier, found reserved identifier `_` | ||
--> $DIR/underscore_static.rs:3:8 | ||
| | ||
LL | static _: () = (); //~ ERROR expected identifier, found reserved identifier `_` | ||
| ^ expected identifier, found reserved identifier | ||
|
||
error: aborting due to previous error | ||
|
14 changes: 14 additions & 0 deletions
14
src/test/ui/rfc-2166-underscore-imports/auxiliary/duplicate.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,14 @@ | ||
// force-host | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::*; | ||
|
||
#[proc_macro_attribute] | ||
pub fn duplicate(_: TokenStream, input: TokenStream) -> TokenStream { | ||
let clone = input.clone(); | ||
input.into_iter().chain(clone.into_iter()).collect() | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/ui/rfc-2166-underscore-imports/auxiliary/underscore-imports.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,22 @@ | ||
#![feature(underscore_imports)] | ||
|
||
#[macro_export] | ||
macro_rules! do_nothing { | ||
() => () | ||
} | ||
|
||
mod m1 { | ||
pub trait InScope1 { | ||
fn in_scope1(&self) {} | ||
} | ||
impl InScope1 for () {} | ||
} | ||
mod m2 { | ||
pub trait InScope2 { | ||
fn in_scope2(&self) {} | ||
} | ||
impl InScope2 for () {} | ||
} | ||
|
||
pub use m1::InScope1 as _; | ||
pub use m2::InScope2 as _; |
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,17 @@ | ||
// compile-pass | ||
// aux-build:duplicate.rs | ||
|
||
#![feature(underscore_imports)] | ||
|
||
extern crate duplicate; | ||
|
||
#[duplicate::duplicate] | ||
use main as _; // OK | ||
|
||
macro_rules! duplicate { | ||
($item: item) => { $item $item } | ||
} | ||
|
||
duplicate!(use std as _;); // OK | ||
|
||
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,11 @@ | ||
// compile-pass | ||
// aux-build:underscore-imports.rs | ||
|
||
extern crate underscore_imports; | ||
|
||
use underscore_imports::*; | ||
|
||
fn main() { | ||
().in_scope1(); | ||
().in_scope2(); | ||
} |
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,18 @@ | ||
// edition:2018 | ||
|
||
#![feature(underscore_imports)] | ||
#![deny(unused_imports)] | ||
|
||
mod multi_segment { | ||
use core::any; //~ ERROR unused import: `core::any` | ||
} | ||
|
||
mod single_segment { | ||
use core; //~ ERROR unused import: `core` | ||
} | ||
|
||
mod single_segment_underscore { | ||
use core as _; // OK | ||
} | ||
|
||
fn main() {} |
20 changes: 20 additions & 0 deletions
20
src/test/ui/rfc-2166-underscore-imports/unused-2018.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,20 @@ | ||
error: unused import: `core::any` | ||
--> $DIR/unused-2018.rs:7:9 | ||
| | ||
LL | use core::any; //~ ERROR unused import: `core::any` | ||
| ^^^^^^^^^ | ||
| | ||
note: lint level defined here | ||
--> $DIR/unused-2018.rs:4:9 | ||
| | ||
LL | #![deny(unused_imports)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: unused import: `core` | ||
--> $DIR/unused-2018.rs:11:9 | ||
| | ||
LL | use core; //~ ERROR unused import: `core` | ||
| ^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|