From fa2c24638493cc91c08a9ddab979448286e3dea1 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 20 Sep 2018 20:39:46 +0300 Subject: [PATCH] Stabilize crate_in_paths, extern_absolute_paths and extern_prelude on all editions. --- .../src/language-features/crate-in-paths.md | 49 ------------------- .../extern-absolute-paths.md | 43 ---------------- src/librustc/lib.rs | 2 +- src/librustc_resolve/lib.rs | 21 +------- src/librustc_resolve/macros.rs | 8 --- src/librustc_traits/lib.rs | 4 +- src/librustdoc/core.rs | 4 +- src/libsyntax/feature_gate.rs | 21 +++----- .../run-make-fulldeps/extern-prelude/Makefile | 1 - .../extern-prelude/feature-gate.rs | 13 ----- .../feature-gate-crate_in_paths.rs | 15 ------ .../feature-gate-crate_in_paths.stderr | 11 ----- .../ui/hygiene/dollar-crate-modern.stderr | 8 +++ .../ui/macros/macro-path-prelude-pass.stderr | 8 +++ .../extern/extern-prelude-core.stderr | 8 +++ .../run-pass/extern/extern-prelude-std.stderr | 8 +++ .../crate-path-absolute.stderr | 8 +++ .../crate-path-visibility-ambiguity.stderr | 8 +++ src/tools/cargo | 2 +- 19 files changed, 61 insertions(+), 181 deletions(-) delete mode 100644 src/doc/unstable-book/src/language-features/crate-in-paths.md delete mode 100644 src/doc/unstable-book/src/language-features/extern-absolute-paths.md delete mode 100644 src/test/run-make-fulldeps/extern-prelude/feature-gate.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-crate_in_paths.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-crate_in_paths.stderr create mode 100644 src/test/ui/hygiene/dollar-crate-modern.stderr create mode 100644 src/test/ui/macros/macro-path-prelude-pass.stderr create mode 100644 src/test/ui/run-pass/extern/extern-prelude-core.stderr create mode 100644 src/test/ui/run-pass/extern/extern-prelude-std.stderr create mode 100644 src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr create mode 100644 src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr 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 index 9901dc1ebe3..00000000000 --- a/src/doc/unstable-book/src/language-features/crate-in-paths.md +++ /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 index 6a22e7eba64..00000000000 --- a/src/doc/unstable-book/src/language-features/extern-absolute-paths.md +++ /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"); -} -``` diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index c017c90b895..2eaf1eebb39 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -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"] diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 343ef067a6c..327eaacdf16 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -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, injected_crate: Option>, - - /// 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(&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); diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index cb561b2597b..35d96b9302b 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -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 = diff --git a/src/librustc_traits/lib.rs b/src/librustc_traits/lib.rs index 7fe1af81951..a6618efebb3 100644 --- a/src/librustc_traits/lib.rs +++ b/src/librustc_traits/lib.rs @@ -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))] diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index e8f1733e532..093788d2095 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -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. diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 8ddb7473162..d44d2146d82 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -394,18 +394,12 @@ pub fn walk_feature_fields(&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(&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(&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"); } diff --git a/src/test/run-make-fulldeps/extern-prelude/Makefile b/src/test/run-make-fulldeps/extern-prelude/Makefile index aa8158c6eb3..69af01ccf03 100644 --- a/src/test/run-make-fulldeps/extern-prelude/Makefile +++ b/src/test/run-make-fulldeps/extern-prelude/Makefile @@ -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 index 49763f3ba6a..00000000000 --- a/src/test/run-make-fulldeps/extern-prelude/feature-gate.rs +++ /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 or the MIT license -// , 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 index e667dab621b..00000000000 --- a/src/test/ui/feature-gates/feature-gate-crate_in_paths.rs +++ /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 or the MIT license -// , 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 index 32115ba2111..00000000000 --- a/src/test/ui/feature-gates/feature-gate-crate_in_paths.stderr +++ /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 index 00000000000..5fa7d8eda1d --- /dev/null +++ b/src/test/ui/hygiene/dollar-crate-modern.stderr @@ -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 index 00000000000..edae6a3e3cd --- /dev/null +++ b/src/test/ui/macros/macro-path-prelude-pass.stderr @@ -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 index 00000000000..f7699531857 --- /dev/null +++ b/src/test/ui/run-pass/extern/extern-prelude-core.stderr @@ -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 index 00000000000..8c059b4ebeb --- /dev/null +++ b/src/test/ui/run-pass/extern/extern-prelude-std.stderr @@ -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 index 00000000000..f95237fbbea --- /dev/null +++ b/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr @@ -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 index 00000000000..91f918dbd2c --- /dev/null +++ b/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr @@ -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 + diff --git a/src/tools/cargo b/src/tools/cargo index b1e1d388ea0..de314a8b2d4 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit b1e1d388ea09ecc27515345b180dd02263b087df +Subproject commit de314a8b2d45bce4958fc23939c5e4286e31621c -- 2.44.0