]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #47948 - pietroalbini:use-nested-groups-stabilize, r=petrochenkov
authorkennytm <kennytm@gmail.com>
Mon, 5 Feb 2018 18:13:51 +0000 (02:13 +0800)
committerGitHub <noreply@github.com>
Mon, 5 Feb 2018 18:13:51 +0000 (02:13 +0800)
Stabilize use_nested_groups

As requested in #44494. Documentation PRs already sent.

src/doc/unstable-book/src/language-features/use-nested-groups.md [deleted file]
src/libsyntax/feature_gate.rs
src/test/compile-fail/absolute-paths-in-nested-use-groups.rs
src/test/run-pass/issue-47673.rs
src/test/run-pass/use-nested-groups.rs
src/test/ui/feature-gate-use_nested_groups.rs [deleted file]
src/test/ui/feature-gate-use_nested_groups.stderr [deleted file]
src/test/ui/use-nested-groups-error.rs
src/test/ui/use-nested-groups-error.stderr

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 (file)
index 47b635b..0000000
+++ /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}};`
index 3e858c3b923a1154d218359b1f928bc37b9a6fe6..9c6520cd874a8ec87bdc2a3af0bd44b160adef4e 100644 (file)
@@ -423,9 +423,6 @@ pub fn new() -> 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 @@ pub fn new() -> 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 @@ fn visit_path(&mut self, path: &'a ast::Path, _id: NodeId) {
         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,
index 8e5ba489c565ef5239a113f39a070d11cf32ab7c..fe052f2f47ffda103b01b199ac3f6a1b3e044bac 100644 (file)
@@ -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 {}
index 92f54a44f63c94ae0af9c11fbba66de1f0e2b1ef..22f7f169e298840e9ef7ffb0bdc6e3bd75a9e72d 100644 (file)
@@ -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 {{}, {}};
index a28f8da9ff882f31167faa7d0aebbcc4f6e9da60..be06e463e3b37fac7c475e3840c3e9d12bcf481f 100644 (file)
@@ -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 (file)
index 56413a9..0000000
+++ /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 (file)
index 6ae691c..0000000
+++ /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
-
index a9b6b3ee70d57cb4bddbdc5e07c41aee5286922a..0a68d34ade9faf2d1e85d5bf27226c46c15ef707 100644 (file)
@@ -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 {}
index cae34684c8e38dbed173beffa83a32590740e9d7..c4edb626be0bb488c08b2144998de9598b60a144 100644 (file)
@@ -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