about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2018-02-01 22:55:20 +0100
committerPietro Albini <pietro@pietroalbini.org>2018-02-05 10:23:40 +0100
commit01f0814a2a7db7d93b4cb90b74242b082861e674 (patch)
treeea9d2141f3faa3f1092cdf67bcbf2096a37e0f40
parent07ea2604075d6f896addce0e6949c7cf25dd3715 (diff)
downloadrust-01f0814a2a7db7d93b4cb90b74242b082861e674.tar.gz
rust-01f0814a2a7db7d93b4cb90b74242b082861e674.zip
Stabilize use_nested_groups
-rw-r--r--src/doc/unstable-book/src/language-features/use-nested-groups.md90
-rw-r--r--src/libsyntax/feature_gate.rs28
-rw-r--r--src/test/compile-fail/absolute-paths-in-nested-use-groups.rs1
-rw-r--r--src/test/run-pass/issue-47673.rs1
-rw-r--r--src/test/run-pass/use-nested-groups.rs2
-rw-r--r--src/test/ui/feature-gate-use_nested_groups.rs31
-rw-r--r--src/test/ui/feature-gate-use_nested_groups.stderr26
-rw-r--r--src/test/ui/use-nested-groups-error.rs2
-rw-r--r--src/test/ui/use-nested-groups-error.stderr4
9 files changed, 4 insertions, 181 deletions
diff --git a/src/doc/unstable-book/src/language-features/use-nested-groups.md b/src/doc/unstable-book/src/language-features/use-nested-groups.md
deleted file mode 100644
index 47b635bad73..00000000000
--- a/src/doc/unstable-book/src/language-features/use-nested-groups.md
+++ /dev/null
@@ -1,90 +0,0 @@
-# `use_nested_groups`
-
-The tracking issue for this feature is: [#44494]
-
-[#44494]: https://github.com/rust-lang/rust/issues/44494
-
-------------------------
-
-The `use_nested_groups` feature allows you to import multiple items from a
-complex module tree easily, by nesting different imports in the same
-declaration. For example:
-
-```rust
-#![feature(use_nested_groups)]
-# #![allow(unused_imports, dead_code)]
-#
-# mod foo {
-#     pub mod bar {
-#         pub type Foo = ();
-#     }
-#     pub mod baz {
-#         pub mod quux {
-#             pub type Bar = ();
-#         }
-#     }
-# }
-
-use foo::{
-    bar::{self, Foo},
-    baz::{*, quux::Bar},
-};
-#
-# fn main() {}
-```
-
-## Snippet for the book's new features appendix
-
-When stabilizing, add this to
-`src/doc/book/second-edition/src/appendix-07-newest-features.md`:
-
-### Nested groups in `use` declarations
-
-If you have a complex module tree with many different submodules and you need
-to import a few items from each one, it might be useful to group all the
-imports in the same declaration to keep your code clean and avoid repeating the
-base modules' name.
-
-The `use` declaration supports nesting to help you in those cases, both with
-simple imports and glob ones. For example this snippets imports `bar`, `Foo`,
-all the items in `baz` and `Bar`:
-
-```rust
-# #![feature(use_nested_groups)]
-# #![allow(unused_imports, dead_code)]
-#
-# mod foo {
-#     pub mod bar {
-#         pub type Foo = ();
-#     }
-#     pub mod baz {
-#         pub mod quux {
-#             pub type Bar = ();
-#         }
-#     }
-# }
-#
-use foo::{
-    bar::{self, Foo},
-    baz::{*, quux::Bar},
-};
-#
-# fn main() {}
-```
-
-## Updated reference
-
-When stabilizing, replace the shortcut list in
-`src/doc/reference/src/items/use-declarations.md` with this updated one:
-
-* Simultaneously binding a list of paths with a common prefix, using the
-  glob-like brace syntax `use a::b::{c, d, e::f, g::h::i};`
-* Simultaneously binding a list of paths with a common prefix and their common
-  parent module, using the `self` keyword, such as `use a::b::{self, c, d::e};`
-* Rebinding the target name as a new local name, using the syntax `use p::q::r
-  as x;`. This can also be used with the last two features:
-  `use a::b::{self as ab, c as abc}`.
-* Binding all paths matching a given prefix, using the asterisk wildcard syntax
-  `use a::b::*;`.
-* Nesting groups of the previous features multiple times, such as
-  `use a::b::{self as ab, c d::{*, e::f}};`
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 3e858c3b923..9c6520cd874 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -423,9 +423,6 @@ declare_features! (
     // In-band lifetime bindings (e.g. `fn foo(x: &'a u8) -> &'a u8`)
     (active, in_band_lifetimes, "1.23.0", Some(44524)),
 
-    // Nested groups in `use` (RFC 2128)
-    (active, use_nested_groups, "1.23.0", Some(44494)),
-
     // generic associated types (RFC 1598)
     (active, generic_associated_types, "1.23.0", Some(44265)),
 
@@ -544,6 +541,8 @@ declare_features! (
     (accepted, repr_align, "1.24.0", Some(33626)),
     // allow '|' at beginning of match arms (RFC 1925)
     (accepted, match_beginning_vert, "1.25.0", Some(44101)),
+    // Nested groups in `use` (RFC 2128)
+    (accepted, use_nested_groups, "1.25.0", Some(44494)),
 );
 
 // If you change this, please modify src/doc/unstable-book as well. You must
@@ -1805,29 +1804,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
         visit::walk_path(self, path);
     }
 
-    fn visit_use_tree(&mut self, use_tree: &'a ast::UseTree, id: NodeId, nested: bool) {
-        if nested {
-            match use_tree.kind {
-                ast::UseTreeKind::Simple(_) => {
-                    if use_tree.prefix.segments.len() != 1 {
-                        gate_feature_post!(&self, use_nested_groups, use_tree.span,
-                                           "paths in `use` groups are experimental");
-                    }
-                }
-                ast::UseTreeKind::Glob => {
-                    gate_feature_post!(&self, use_nested_groups, use_tree.span,
-                                       "glob imports in `use` groups are experimental");
-                }
-                ast::UseTreeKind::Nested(_) => {
-                    gate_feature_post!(&self, use_nested_groups, use_tree.span,
-                                       "nested groups in `use` are experimental");
-                }
-            }
-        }
-
-        visit::walk_use_tree(self, use_tree, id);
-    }
-
     fn visit_vis(&mut self, vis: &'a ast::Visibility) {
         if let ast::Visibility::Crate(span, ast::CrateSugar::JustCrate) = *vis {
             gate_feature_post!(&self, crate_visibility_modifier, span,
diff --git a/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs b/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs
index 8e5ba489c56..fe052f2f47f 100644
--- a/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs
+++ b/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(use_nested_groups)]
 #![allow(unused_imports)]
 
 mod foo {}
diff --git a/src/test/run-pass/issue-47673.rs b/src/test/run-pass/issue-47673.rs
index 92f54a44f63..22f7f169e29 100644
--- a/src/test/run-pass/issue-47673.rs
+++ b/src/test/run-pass/issue-47673.rs
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(use_nested_groups)]
 #![allow(unused_import)]
 
 use {{}, {}};
diff --git a/src/test/run-pass/use-nested-groups.rs b/src/test/run-pass/use-nested-groups.rs
index a28f8da9ff8..be06e463e3b 100644
--- a/src/test/run-pass/use-nested-groups.rs
+++ b/src/test/run-pass/use-nested-groups.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(use_nested_groups)]
-
 mod a {
     pub enum B {}
 
diff --git a/src/test/ui/feature-gate-use_nested_groups.rs b/src/test/ui/feature-gate-use_nested_groups.rs
deleted file mode 100644
index 56413a999d7..00000000000
--- a/src/test/ui/feature-gate-use_nested_groups.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2017 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.
-
-#![allow(unused_imports, dead_code)]
-
-mod a {
-    pub enum B {}
-    pub enum C {}
-
-    pub mod d {
-        pub enum E {}
-        pub enum F {}
-
-        pub mod g {
-            pub enum H {}
-        }
-    }
-}
-
-use a::{B, d::{*, g::H}};  //~ ERROR glob imports in `use` groups are experimental
-                           //~^ ERROR nested groups in `use` are experimental
-                           //~^^ ERROR paths in `use` groups are experimental
-
-fn main() {}
diff --git a/src/test/ui/feature-gate-use_nested_groups.stderr b/src/test/ui/feature-gate-use_nested_groups.stderr
deleted file mode 100644
index 6ae691c384b..00000000000
--- a/src/test/ui/feature-gate-use_nested_groups.stderr
+++ /dev/null
@@ -1,26 +0,0 @@
-error[E0658]: nested groups in `use` are experimental (see issue #44494)
-  --> $DIR/feature-gate-use_nested_groups.rs:27:12
-   |
-27 | use a::{B, d::{*, g::H}};  //~ ERROR glob imports in `use` groups are experimental
-   |            ^^^^^^^^^^^^
-   |
-   = help: add #![feature(use_nested_groups)] to the crate attributes to enable
-
-error[E0658]: glob imports in `use` groups are experimental (see issue #44494)
-  --> $DIR/feature-gate-use_nested_groups.rs:27:16
-   |
-27 | use a::{B, d::{*, g::H}};  //~ ERROR glob imports in `use` groups are experimental
-   |                ^
-   |
-   = help: add #![feature(use_nested_groups)] to the crate attributes to enable
-
-error[E0658]: paths in `use` groups are experimental (see issue #44494)
-  --> $DIR/feature-gate-use_nested_groups.rs:27:19
-   |
-27 | use a::{B, d::{*, g::H}};  //~ ERROR glob imports in `use` groups are experimental
-   |                   ^^^^
-   |
-   = help: add #![feature(use_nested_groups)] to the crate attributes to enable
-
-error: aborting due to 3 previous errors
-
diff --git a/src/test/ui/use-nested-groups-error.rs b/src/test/ui/use-nested-groups-error.rs
index a9b6b3ee70d..0a68d34ade9 100644
--- a/src/test/ui/use-nested-groups-error.rs
+++ b/src/test/ui/use-nested-groups-error.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(use_nested_groups)]
-
 mod a {
     pub mod b1 {
         pub enum C2 {}
diff --git a/src/test/ui/use-nested-groups-error.stderr b/src/test/ui/use-nested-groups-error.stderr
index cae34684c8e..c4edb626be0 100644
--- a/src/test/ui/use-nested-groups-error.stderr
+++ b/src/test/ui/use-nested-groups-error.stderr
@@ -1,7 +1,7 @@
 error[E0432]: unresolved import `a::b1::C1`
-  --> $DIR/use-nested-groups-error.rs:21:14
+  --> $DIR/use-nested-groups-error.rs:19:14
    |
-21 | use a::{b1::{C1, C2}, B2};
+19 | use a::{b1::{C1, C2}, B2};
    |              ^^ no `C1` in `a::b1`. Did you mean to use `C2`?
 
 error: aborting due to previous error