]> git.lizzy.rs Git - rust.git/commitdiff
Stabilize crate_in_paths, extern_absolute_paths and extern_prelude on all editions.
authorEduard-Mihai Burtescu <edy.burt@gmail.com>
Thu, 20 Sep 2018 17:39:46 +0000 (20:39 +0300)
committerEduard-Mihai Burtescu <edy.burt@gmail.com>
Sat, 22 Sep 2018 06:26:40 +0000 (09:26 +0300)
19 files changed:
src/doc/unstable-book/src/language-features/crate-in-paths.md [deleted file]
src/doc/unstable-book/src/language-features/extern-absolute-paths.md [deleted file]
src/librustc/lib.rs
src/librustc_resolve/lib.rs
src/librustc_resolve/macros.rs
src/librustc_traits/lib.rs
src/librustdoc/core.rs
src/libsyntax/feature_gate.rs
src/test/run-make-fulldeps/extern-prelude/Makefile
src/test/run-make-fulldeps/extern-prelude/feature-gate.rs [deleted file]
src/test/ui/feature-gates/feature-gate-crate_in_paths.rs [deleted file]
src/test/ui/feature-gates/feature-gate-crate_in_paths.stderr [deleted file]
src/test/ui/hygiene/dollar-crate-modern.stderr [new file with mode: 0644]
src/test/ui/macros/macro-path-prelude-pass.stderr [new file with mode: 0644]
src/test/ui/run-pass/extern/extern-prelude-core.stderr [new file with mode: 0644]
src/test/ui/run-pass/extern/extern-prelude-std.stderr [new file with mode: 0644]
src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr [new file with mode: 0644]
src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr [new file with mode: 0644]
src/tools/cargo

diff --git a/src/doc/unstable-book/src/language-features/crate-in-paths.md b/src/doc/unstable-book/src/language-features/crate-in-paths.md
deleted file mode 100644 (file)
index 9901dc1..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-# `crate_in_paths`
-
-The tracking issue for this feature is: [#44660]
-
-[#44660]: https://github.com/rust-lang/rust/issues/44660
-
-------------------------
-
-The `crate_in_paths` feature allows to explicitly refer to the crate root in absolute paths
-using keyword `crate`.
-
-This feature is required in `feature(extern_absolute_paths)` mode to refer to any absolute path
-in the local crate (absolute paths refer to extern crates by default in that mode), but can be
-used without `feature(extern_absolute_paths)` as well.
-
-```rust
-#![feature(crate_in_paths)]
-
-// Imports, `::` is added implicitly
-use crate::m::f;
-use crate as root;
-
-mod m {
-    pub fn f() -> u8 { 1 }
-    pub fn g() -> u8 { 2 }
-    pub fn h() -> u8 { 3 }
-
-    // OK, visibilities implicitly add starting `::` as well, like imports
-    pub(in crate::m) struct S;
-}
-
-mod n
-{
-    use crate::m::f;
-    use crate as root;
-    pub fn check() {
-        assert_eq!(f(), 1);
-        assert_eq!(crate::m::g(), 2);
-        assert_eq!(root::m::h(), 3);
-    }
-}
-
-fn main() {
-    assert_eq!(f(), 1);
-    assert_eq!(crate::m::g(), 2);
-    assert_eq!(root::m::h(), 3);
-    n::check();
-}
-```
diff --git a/src/doc/unstable-book/src/language-features/extern-absolute-paths.md b/src/doc/unstable-book/src/language-features/extern-absolute-paths.md
deleted file mode 100644 (file)
index 6a22e7e..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-# `extern_absolute_paths`
-
-The tracking issue for this feature is: [#44660]
-
-[#44660]: https://github.com/rust-lang/rust/issues/44660
-
-------------------------
-
-The `extern_absolute_paths` feature enables mode allowing to refer to names from other crates
-"inline", without introducing `extern crate` items, using absolute paths like `::my_crate::a::b`.
-
-`::my_crate::a::b` will resolve to path `a::b` in crate `my_crate`.
-
-`feature(crate_in_paths)` can be used in `feature(extern_absolute_paths)` mode for referring
-to absolute paths in the local crate (`crate::a::b`).
-
-`feature(extern_in_paths)` provides the same effect by using keyword `extern` to refer to
-paths from other crates (`extern::my_crate::a::b`).
-
-```rust,ignore
-#![feature(extern_absolute_paths)]
-
-// Suppose we have a dependency crate `xcrate` available through `Cargo.toml`, or `--extern`
-// options, or standard Rust distribution, or some other means.
-
-use xcrate::Z;
-
-fn f() {
-    use xcrate;
-    use xcrate as ycrate;
-    let s = xcrate::S;
-    assert_eq!(format!("{:?}", s), "S");
-    let z = ycrate::Z;
-    assert_eq!(format!("{:?}", z), "Z");
-}
-
-fn main() {
-    let s = ::xcrate::S;
-    assert_eq!(format!("{:?}", s), "S");
-    let z = Z;
-    assert_eq!(format!("{:?}", z), "Z");
-}
-```
index c017c90b8955043ad0ab52fc285e09c98a57b0b7..2eaf1eebb394ca5bc09ec9e754825e258de3b29d 100644 (file)
@@ -73,7 +73,7 @@
 #![cfg_attr(not(stage0), feature(impl_header_lifetime_elision))]
 #![feature(in_band_lifetimes)]
 #![feature(macro_at_most_once_rep)]
-#![feature(crate_in_paths)]
+#![cfg_attr(stage0, feature(crate_in_paths))]
 #![feature(crate_visibility_modifier)]
 
 #![recursion_limit="512"]
index 343ef067a6ce86aac59e251bb1e3dd7d58dd8ec8..327eaacdf163bee302fc7191409b3dae2fdf4c50 100644 (file)
@@ -65,7 +65,6 @@
 use syntax::ast::{Item, ItemKind, ImplItem, ImplItemKind};
 use syntax::ast::{Label, Local, Mutability, Pat, PatKind, Path};
 use syntax::ast::{QSelf, TraitItemKind, TraitRef, Ty, TyKind};
-use syntax::feature_gate::{feature_err, GateIssue};
 use syntax::ptr::P;
 
 use syntax_pos::{Span, DUMMY_SP, MultiSpan};
@@ -1466,9 +1465,6 @@ pub struct Resolver<'a, 'b: 'a> {
     current_type_ascription: Vec<Span>,
 
     injected_crate: Option<Module<'a>>,
-
-    /// Only supposed to be used by rustdoc, otherwise should be false.
-    pub ignore_extern_prelude_feature: bool,
 }
 
 /// Nothing really interesting here, it just provides memory for the rest of the crate.
@@ -1766,7 +1762,6 @@ pub fn new(session: &'a Session,
             unused_macros: FxHashSet(),
             current_type_ascription: Vec::new(),
             injected_crate: None,
-            ignore_extern_prelude_feature: false,
         }
     }
 
@@ -1969,13 +1964,6 @@ fn resolve_ident_in_lexical_scope(&mut self,
         if !module.no_implicit_prelude {
             // `record_used` means that we don't try to load crates during speculative resolution
             if record_used && ns == TypeNS && self.extern_prelude.contains(&ident.name) {
-                if !self.session.features_untracked().extern_prelude &&
-                   !self.ignore_extern_prelude_feature {
-                    feature_err(&self.session.parse_sess, "extern_prelude",
-                                ident.span, GateIssue::Language,
-                                "access to extern crates through prelude is experimental").emit();
-                }
-
                 let crate_id = self.crate_loader.process_path_extern(ident.name, ident.span);
                 let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX });
                 self.populate_module_if_necessary(&crate_root);
@@ -3576,7 +3564,6 @@ fn resolve_path_with_parent_scope(
                     }
                     if name == keywords::Extern.name() ||
                        name == keywords::CrateRoot.name() &&
-                       self.session.features_untracked().extern_absolute_paths &&
                        self.session.rust_2018() {
                         module = Some(ModuleOrUniformRoot::UniformRoot(name));
                         continue;
@@ -3715,12 +3702,6 @@ fn lint_if_path_starts_with_module(
             return
         }
 
-        // In the 2015 edition there's no use in emitting lints unless the
-        // crate's already enabled the feature that we're going to suggest
-        if !self.session.features_untracked().crate_in_paths {
-            return
-        }
-
         let (diag_id, diag_span) = match crate_lint {
             CrateLint::No => return,
             CrateLint::SimplePath(id) => (id, path_span),
@@ -4417,7 +4398,7 @@ fn lookup_import_candidates<FilterFn>(&mut self,
             )
         );
 
-        if self.session.features_untracked().extern_prelude {
+        if self.session.rust_2018() {
             let extern_prelude_names = self.extern_prelude.clone();
             for &name in extern_prelude_names.iter() {
                 let ident = Ident::with_empty_ctxt(name);
index cb561b2597b397920e0ac9464bf584e382e04ad5..35d96b9302b43229575ebec76abb445b2c64e48c 100644 (file)
@@ -682,14 +682,6 @@ enum WhereToResolve<'a> {
                 }
                 WhereToResolve::ExternPrelude => {
                     if use_prelude && self.extern_prelude.contains(&ident.name) {
-                        if !self.session.features_untracked().extern_prelude &&
-                           !self.ignore_extern_prelude_feature {
-                            feature_err(&self.session.parse_sess, "extern_prelude",
-                                        ident.span, GateIssue::Language,
-                                        "access to extern crates through prelude is experimental")
-                                        .emit();
-                        }
-
                         let crate_id =
                             self.crate_loader.process_path_extern(ident.name, ident.span);
                         let crate_root =
index 7fe1af819512951ec02cd061c4e54585d66b2338..a6618efebb31017bf933de30bace186678c546e4 100644 (file)
@@ -11,9 +11,9 @@
 //! New recursive solver modeled on Chalk's recursive solver. Most of
 //! the guts are broken up into modules; see the comments in those modules.
 
-#![feature(crate_in_paths)]
+#![cfg_attr(stage0, feature(crate_in_paths))]
 #![feature(crate_visibility_modifier)]
-#![feature(extern_prelude)]
+#![cfg_attr(stage0, feature(extern_prelude))]
 #![feature(in_band_lifetimes)]
 #![cfg_attr(not(stage0), feature(nll))]
 
index e8f1733e532de7125db292e8c224e571d8960812..093788d209569d0b5c0393b596e8b6f768783fb4 100644 (file)
@@ -455,12 +455,10 @@ pub fn run_core(search_paths: SearchPaths,
                                                         |_| Ok(()));
         let driver::InnerExpansionResult {
             mut hir_forest,
-            mut resolver,
+            resolver,
             ..
         } = abort_on_err(result, &sess);
 
-        resolver.ignore_extern_prelude_feature = true;
-
         // We need to hold on to the complete resolver, so we clone everything
         // for the analysis passes to use. Suboptimal, but necessary in the
         // current architecture.
index 8ddb7473162b0db32780d199bb3812cfe36f64c2..d44d2146d82c9c495f26be2c449d0c8bcf9d35be 100644 (file)
@@ -394,18 +394,12 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
     // Allows trait methods with arbitrary self types
     (active, arbitrary_self_types, "1.23.0", Some(44874), None),
 
-    // `crate` in paths
-    (active, crate_in_paths, "1.23.0", Some(45477), Some(Edition::Edition2018)),
-
     // In-band lifetime bindings (e.g. `fn foo(x: &'a u8) -> &'a u8`)
     (active, in_band_lifetimes, "1.23.0", Some(44524), None),
 
     // Generic associated types (RFC 1598)
     (active, generic_associated_types, "1.23.0", Some(44265), None),
 
-    // Resolve absolute paths as paths from other crates
-    (active, extern_absolute_paths, "1.24.0", Some(44660), Some(Edition::Edition2018)),
-
     // `extern` in paths
     (active, extern_in_paths, "1.23.0", Some(44660), None),
 
@@ -455,9 +449,6 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
     // #[doc(alias = "...")]
     (active, doc_alias, "1.27.0", Some(50146), None),
 
-    // Access to crate names passed via `--extern` through prelude
-    (active, extern_prelude, "1.27.0", Some(44660), Some(Edition::Edition2018)),
-
     // Scoped lints
     (active, tool_lints, "1.28.0", Some(44690), None),
 
@@ -683,7 +674,12 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
     (accepted, panic_handler, "1.30.0", Some(44489), None),
     // Used to preserve symbols (see llvm.used)
     (accepted, used, "1.30.0", Some(40289), None),
-
+    // `crate` in paths
+    (accepted, crate_in_paths, "1.30.0", Some(45477), None),
+    // Resolve absolute paths as paths from other crates
+    (accepted, extern_absolute_paths, "1.30.0", Some(44660), None),
+    // Access to crate names passed via `--extern` through prelude
+    (accepted, extern_prelude, "1.30.0", Some(44660), None),
 );
 
 // If you change this, please modify src/doc/unstable-book as well. You must
@@ -1892,10 +1888,7 @@ fn visit_path(&mut self, path: &'a ast::Path, _id: NodeId) {
             // cannot be kept in identifiers, so it's kept in paths instead and we take it from
             // there while keeping location info from the ident span.
             let span = segment.ident.span.with_ctxt(path.span.ctxt());
-            if segment.ident.name == keywords::Crate.name() {
-                gate_feature_post!(&self, crate_in_paths, span,
-                                   "`crate` in paths is experimental");
-            } else if segment.ident.name == keywords::Extern.name() {
+            if segment.ident.name == keywords::Extern.name() {
                 gate_feature_post!(&self, extern_in_paths, span,
                                    "`extern` in paths is experimental");
             }
index aa8158c6eb381a8aa855e8cbf0b8a80edc1fe99d..69af01ccf0369210e4dceb47ff105693c53bb134 100644 (file)
@@ -7,6 +7,5 @@ all:
        $(RUSTC) basic.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib
        $(RUSTC) shadow-mod.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib
        $(RUSTC) shadow-prelude.rs --extern Vec=$(TMPDIR)/libep_vec.rlib
-       $(RUSTC) feature-gate.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib 2>&1 | $(CGREP) "access to extern crates through prelude is experimental"
        $(RUSTC) relative-only.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib 2>&1 | $(CGREP) "unresolved import"
        $(RUSTC) relative-only.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib 2>&1 | $(CGREP) "failed to resolve"
diff --git a/src/test/run-make-fulldeps/extern-prelude/feature-gate.rs b/src/test/run-make-fulldeps/extern-prelude/feature-gate.rs
deleted file mode 100644 (file)
index 49763f3..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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.
-
-fn main() {
-    let s = ep_lib::S; // Feature error
-}
diff --git a/src/test/ui/feature-gates/feature-gate-crate_in_paths.rs b/src/test/ui/feature-gates/feature-gate-crate_in_paths.rs
deleted file mode 100644 (file)
index e667dab..0000000
+++ /dev/null
@@ -1,15 +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.
-
-struct S;
-
-fn main() {
-    let _ = crate::S; //~ ERROR `crate` in paths is experimental
-}
diff --git a/src/test/ui/feature-gates/feature-gate-crate_in_paths.stderr b/src/test/ui/feature-gates/feature-gate-crate_in_paths.stderr
deleted file mode 100644 (file)
index 32115ba..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0658]: `crate` in paths is experimental (see issue #45477)
-  --> $DIR/feature-gate-crate_in_paths.rs:14:13
-   |
-LL |     let _ = crate::S; //~ ERROR `crate` in paths is experimental
-   |             ^^^^^
-   |
-   = help: add #![feature(crate_in_paths)] to the crate attributes to enable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/hygiene/dollar-crate-modern.stderr b/src/test/ui/hygiene/dollar-crate-modern.stderr
new file mode 100644 (file)
index 0000000..5fa7d8e
--- /dev/null
@@ -0,0 +1,8 @@
+warning: the feature `crate_in_paths` has been stable since 1.30.0 and no longer requires an attribute to enable
+  --> $DIR/dollar-crate-modern.rs:16:24
+   |
+LL | #![feature(decl_macro, crate_in_paths)]
+   |                        ^^^^^^^^^^^^^^
+   |
+   = note: #[warn(stable_features)] on by default
+
diff --git a/src/test/ui/macros/macro-path-prelude-pass.stderr b/src/test/ui/macros/macro-path-prelude-pass.stderr
new file mode 100644 (file)
index 0000000..edae6a3
--- /dev/null
@@ -0,0 +1,8 @@
+warning: the feature `extern_prelude` has been stable since 1.30.0 and no longer requires an attribute to enable
+  --> $DIR/macro-path-prelude-pass.rs:13:12
+   |
+LL | #![feature(extern_prelude)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: #[warn(stable_features)] on by default
+
diff --git a/src/test/ui/run-pass/extern/extern-prelude-core.stderr b/src/test/ui/run-pass/extern/extern-prelude-core.stderr
new file mode 100644 (file)
index 0000000..f769953
--- /dev/null
@@ -0,0 +1,8 @@
+warning: the feature `extern_prelude` has been stable since 1.30.0 and no longer requires an attribute to enable
+  --> $DIR/extern-prelude-core.rs:12:12
+   |
+LL | #![feature(extern_prelude, lang_items, start, alloc)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: #[warn(stable_features)] on by default
+
diff --git a/src/test/ui/run-pass/extern/extern-prelude-std.stderr b/src/test/ui/run-pass/extern/extern-prelude-std.stderr
new file mode 100644 (file)
index 0000000..8c059b4
--- /dev/null
@@ -0,0 +1,8 @@
+warning: the feature `extern_prelude` has been stable since 1.30.0 and no longer requires an attribute to enable
+  --> $DIR/extern-prelude-std.rs:12:12
+   |
+LL | #![feature(extern_prelude)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: #[warn(stable_features)] on by default
+
diff --git a/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr b/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr
new file mode 100644 (file)
index 0000000..f95237f
--- /dev/null
@@ -0,0 +1,8 @@
+warning: the feature `crate_in_paths` has been stable since 1.30.0 and no longer requires an attribute to enable
+  --> $DIR/crate-path-absolute.rs:12:12
+   |
+LL | #![feature(crate_in_paths)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: #[warn(stable_features)] on by default
+
diff --git a/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr b/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr
new file mode 100644 (file)
index 0000000..91f918d
--- /dev/null
@@ -0,0 +1,8 @@
+warning: the feature `crate_in_paths` has been stable since 1.30.0 and no longer requires an attribute to enable
+  --> $DIR/crate-path-visibility-ambiguity.rs:12:12
+   |
+LL | #![feature(crate_in_paths)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: #[warn(stable_features)] on by default
+
index b1e1d388ea09ecc27515345b180dd02263b087df..de314a8b2d45bce4958fc23939c5e4286e31621c 160000 (submodule)
@@ -1 +1 @@
-Subproject commit b1e1d388ea09ecc27515345b180dd02263b087df
+Subproject commit de314a8b2d45bce4958fc23939c5e4286e31621c