Skip to content

Commit

Permalink
Auto merge of #56303 - petrochenkov:stabuseas, r=cramertj
Browse files Browse the repository at this point in the history
Stabilize `underscore_imports`

Closes #48216
  • Loading branch information
bors committed Dec 17, 2018
2 parents adbfec2 + 7c901ba commit c9bb68f
Show file tree
Hide file tree
Showing 12 changed files with 11 additions and 69 deletions.
2 changes: 1 addition & 1 deletion src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(if_while_or_patterns)]
#![feature(try_from)]
#![feature(reverse_bits)]
#![feature(underscore_imports)]
#![cfg_attr(stage0, feature(underscore_imports))]

#![recursion_limit="256"]

Expand Down
23 changes: 2 additions & 21 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,6 @@ declare_features! (
// Allows `#[repr(packed)]` attribute on structs.
(active, repr_packed, "1.26.0", Some(33158), None),

// Allows `use path as _;` and `extern crate c as _;`.
(active, underscore_imports, "1.26.0", Some(48216), None),

// Allows macro invocations in `extern {}` blocks.
(active, macros_in_extern, "1.27.0", Some(49476), None),

Expand Down Expand Up @@ -694,6 +691,8 @@ declare_features! (
(accepted, self_struct_ctor, "1.32.0", Some(51994), None),
// `Self` in type definitions (RFC 2300)
(accepted, self_in_typedefs, "1.32.0", Some(49303), None),
// `use path as _;` and `extern crate c as _;`
(accepted, underscore_imports, "1.33.0", Some(48216), None),
);

// If you change this, please modify `src/doc/unstable-book` as well. You must
Expand Down Expand Up @@ -1547,26 +1546,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
}
}

fn visit_use_tree(&mut self, use_tree: &'a ast::UseTree, id: NodeId, _nested: bool) {
if let ast::UseTreeKind::Simple(Some(ident), ..) = use_tree.kind {
if ident.name == "_" {
gate_feature_post!(&self, underscore_imports, use_tree.span,
"renaming imports with `_` is unstable");
}
}

visit::walk_use_tree(self, use_tree, id);
}

fn visit_item(&mut self, i: &'a ast::Item) {
match i.node {
ast::ItemKind::ExternCrate(_) => {
if i.ident.name == "_" {
gate_feature_post!(&self, underscore_imports, i.span,
"renaming extern crates with `_` is unstable");
}
}

ast::ItemKind::Static(..) |
ast::ItemKind::Const(_,_) => {
if i.ident.name == "_" {
Expand Down
14 changes: 0 additions & 14 deletions src/test/ui/feature-gates/feature-gate-underscore-imports.rs

This file was deleted.

19 changes: 0 additions & 19 deletions src/test/ui/feature-gates/feature-gate-underscore-imports.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(underscore_imports)]

#[macro_export]
macro_rules! do_nothing {
() => ()
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rfc-2166-underscore-imports/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// compile-pass
// aux-build:underscore-imports.rs

#![feature(underscore_imports)]
#![warn(unused_imports, unused_extern_crates)]

#[macro_use]
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/rfc-2166-underscore-imports/basic.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
warning: unused import: `m::Tr1 as _`
--> $DIR/basic.rs:37:9
--> $DIR/basic.rs:36:9
|
LL | use m::Tr1 as _; //~ WARN unused import
| ^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/basic.rs:15:9
--> $DIR/basic.rs:14:9
|
LL | #![warn(unused_imports, unused_extern_crates)]
| ^^^^^^^^^^^^^^

warning: unused import: `S as _`
--> $DIR/basic.rs:38:9
--> $DIR/basic.rs:37:9
|
LL | use S as _; //~ WARN unused import
| ^^^^^^
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/rfc-2166-underscore-imports/duplicate.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// compile-pass
// aux-build:duplicate.rs

#![feature(underscore_imports)]

extern crate duplicate;

#[duplicate::duplicate]
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rfc-2166-underscore-imports/unused-2018.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// edition:2018

#![feature(underscore_imports)]
#![deny(unused_imports)]

mod multi_segment {
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/rfc-2166-underscore-imports/unused-2018.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: unused import: `core::any`
--> $DIR/unused-2018.rs:7:9
--> $DIR/unused-2018.rs:6:9
|
LL | use core::any; //~ ERROR unused import: `core::any`
| ^^^^^^^^^
|
note: lint level defined here
--> $DIR/unused-2018.rs:4:9
--> $DIR/unused-2018.rs:3:9
|
LL | #![deny(unused_imports)]
| ^^^^^^^^^^^^^^

error: unused import: `core`
--> $DIR/unused-2018.rs:11:9
--> $DIR/unused-2018.rs:10:9
|
LL | use core; //~ ERROR unused import: `core`
| ^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/rust-2018/future-proofing-locals.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// edition:2018

#![feature(uniform_paths, underscore_imports)]
#![feature(uniform_paths)]

mod T {
pub struct U;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/rust-2018/uniform-paths/macro-rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// For the time being `macro_rules` items are treated as *very* private...

#![feature(underscore_imports, decl_macro, uniform_paths)]
#![feature(decl_macro, uniform_paths)]

mod m1 {
macro_rules! legacy_macro { () => () }
Expand Down

0 comments on commit c9bb68f

Please sign in to comment.