Stabilize extern_crate_item_prelude

This commit is contained in:
Vadim Petrochenkov 2018-11-17 21:08:00 +03:00
parent c4cf115056
commit 1af682a557
11 changed files with 7 additions and 148 deletions

View File

@ -58,7 +58,6 @@ use syntax::ast::{self, Name, NodeId, Ident, FloatTy, IntTy, UintTy};
use syntax::ext::base::SyntaxExtension; use syntax::ext::base::SyntaxExtension;
use syntax::ext::base::Determinacy::{self, Determined, Undetermined}; use syntax::ext::base::Determinacy::{self, Determined, Undetermined};
use syntax::ext::base::MacroKind; use syntax::ext::base::MacroKind;
use syntax::feature_gate::{emit_feature_err, GateIssue};
use syntax::symbol::{Symbol, keywords}; use syntax::symbol::{Symbol, keywords};
use syntax::util::lev_distance::find_best_match_for_name; use syntax::util::lev_distance::find_best_match_for_name;
@ -2115,7 +2114,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
if !module.no_implicit_prelude { if !module.no_implicit_prelude {
if ns == TypeNS { if ns == TypeNS {
if let Some(binding) = self.extern_prelude_get(ident, !record_used, false) { if let Some(binding) = self.extern_prelude_get(ident, !record_used) {
return Some(LexicalScopeBinding::Item(binding)); return Some(LexicalScopeBinding::Item(binding));
} }
} }
@ -5022,7 +5021,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
self.name_already_seen.insert(name, span); self.name_already_seen.insert(name, span);
} }
fn extern_prelude_get(&mut self, ident: Ident, speculative: bool, skip_feature_gate: bool) fn extern_prelude_get(&mut self, ident: Ident, speculative: bool)
-> Option<&'a NameBinding<'a>> { -> Option<&'a NameBinding<'a>> {
if ident.is_path_segment_keyword() { if ident.is_path_segment_keyword() {
// Make sure `self`, `super` etc produce an error when passed to here. // Make sure `self`, `super` etc produce an error when passed to here.
@ -5030,13 +5029,6 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
} }
self.extern_prelude.get(&ident.modern()).cloned().and_then(|entry| { self.extern_prelude.get(&ident.modern()).cloned().and_then(|entry| {
if let Some(binding) = entry.extern_crate_item { if let Some(binding) = entry.extern_crate_item {
if !speculative && !skip_feature_gate && entry.introduced_by_item &&
!self.session.features_untracked().extern_crate_item_prelude {
emit_feature_err(&self.session.parse_sess, "extern_crate_item_prelude",
ident.span, GateIssue::Language,
"use of extern prelude names introduced \
with `extern crate` items is unstable");
}
Some(binding) Some(binding)
} else { } else {
let crate_id = if !speculative { let crate_id = if !speculative {

View File

@ -738,8 +738,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
} }
WhereToResolve::ExternPrelude => { WhereToResolve::ExternPrelude => {
if use_prelude { if use_prelude {
match self.extern_prelude_get(ident, !record_used, match self.extern_prelude_get(ident, !record_used) {
innermost_result.is_some()) {
Some(binding) => Ok((binding, Flags::PRELUDE)), Some(binding) => Ok((binding, Flags::PRELUDE)),
None => Err(Determinacy::determined( None => Err(Determinacy::determined(
self.graph_root.unresolved_invocations.borrow().is_empty() self.graph_root.unresolved_invocations.borrow().is_empty()
@ -906,7 +905,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
// but its `Def` should coincide with a crate passed with `--extern` // but its `Def` should coincide with a crate passed with `--extern`
// (otherwise there would be ambiguity) and we can skip feature error in this case. // (otherwise there would be ambiguity) and we can skip feature error in this case.
if ns != TypeNS || !use_prelude || if ns != TypeNS || !use_prelude ||
self.extern_prelude_get(ident, true, false).is_none() { self.extern_prelude_get(ident, true).is_none() {
let msg = "imports can only refer to extern crate names \ let msg = "imports can only refer to extern crate names \
passed with `--extern` on stable channel"; passed with `--extern` on stable channel";
let mut err = feature_err(&self.session.parse_sess, "uniform_paths", let mut err = feature_err(&self.session.parse_sess, "uniform_paths",

View File

@ -166,8 +166,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
assert!(!restricted_shadowing); assert!(!restricted_shadowing);
match uniform_root_kind { match uniform_root_kind {
UniformRootKind::ExternPrelude => { UniformRootKind::ExternPrelude => {
return if let Some(binding) = return if let Some(binding) = self.extern_prelude_get(ident, !record_used) {
self.extern_prelude_get(ident, !record_used, false) {
Ok(binding) Ok(binding)
} else if !self.graph_root.unresolved_invocations.borrow().is_empty() { } else if !self.graph_root.unresolved_invocations.borrow().is_empty() {
// Macro-expanded `extern crate` items can add names to extern prelude. // Macro-expanded `extern crate` items can add names to extern prelude.

View File

@ -499,9 +499,6 @@ declare_features! (
// Allows `const _: TYPE = VALUE` // Allows `const _: TYPE = VALUE`
(active, underscore_const_names, "1.31.0", Some(54912), None), (active, underscore_const_names, "1.31.0", Some(54912), None),
// `extern crate foo as bar;` puts `bar` into extern prelude.
(active, extern_crate_item_prelude, "1.31.0", Some(55599), None),
// `reason = ` in lint attributes and `expect` lint attribute // `reason = ` in lint attributes and `expect` lint attribute
(active, lint_reasons, "1.31.0", Some(54503), None), (active, lint_reasons, "1.31.0", Some(54503), None),
); );
@ -691,6 +688,8 @@ declare_features! (
// impl<I:Iterator> Iterator for &mut Iterator // impl<I:Iterator> Iterator for &mut Iterator
// impl Debug for Foo<'_> // impl Debug for Foo<'_>
(accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None), (accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None),
// `extern crate foo as bar;` puts `bar` into extern prelude.
(accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None),
); );
// If you change this, please modify src/doc/unstable-book as well. You must // If you change this, please modify src/doc/unstable-book as well. You must

View File

@ -1,8 +1,6 @@
// compile-pass // compile-pass
// edition:2018 // edition:2018
#![feature(extern_crate_item_prelude)]
extern crate proc_macro; extern crate proc_macro;
use proc_macro::TokenStream; // OK use proc_macro::TokenStream; // OK

View File

@ -1,46 +0,0 @@
// edition:2018
#![feature(alloc, underscore_imports)]
extern crate alloc;
mod in_scope {
fn check() {
let v = alloc::vec![0];
//~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
type A = alloc::boxed::Box<u8>;
//~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
}
}
mod absolute {
fn check() {
let v = ::alloc::vec![0];
//~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
type A = ::alloc::boxed::Box<u8>;
//~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
}
}
mod import_in_scope {
use alloc as _;
//~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
use alloc::boxed;
//~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
}
mod import_absolute {
use ::alloc;
//~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
use ::alloc::boxed;
//~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
}
extern crate alloc as core;
mod unrelated_crate_renamed {
type A = core::boxed::Box<u8>;
//~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
}
fn main() {}

View File

@ -1,75 +0,0 @@
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
--> $DIR/feature-gate-extern_crate_item_prelude.rs:26:9
|
LL | use alloc as _;
| ^^^^^
|
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
--> $DIR/feature-gate-extern_crate_item_prelude.rs:28:9
|
LL | use alloc::boxed;
| ^^^^^
|
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
--> $DIR/feature-gate-extern_crate_item_prelude.rs:33:11
|
LL | use ::alloc;
| ^^^^^
|
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
--> $DIR/feature-gate-extern_crate_item_prelude.rs:35:11
|
LL | use ::alloc::boxed;
| ^^^^^
|
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
--> $DIR/feature-gate-extern_crate_item_prelude.rs:9:17
|
LL | let v = alloc::vec![0];
| ^^^^^
|
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
--> $DIR/feature-gate-extern_crate_item_prelude.rs:11:18
|
LL | type A = alloc::boxed::Box<u8>;
| ^^^^^
|
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
--> $DIR/feature-gate-extern_crate_item_prelude.rs:18:19
|
LL | let v = ::alloc::vec![0];
| ^^^^^
|
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
--> $DIR/feature-gate-extern_crate_item_prelude.rs:20:20
|
LL | type A = ::alloc::boxed::Box<u8>;
| ^^^^^
|
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
--> $DIR/feature-gate-extern_crate_item_prelude.rs:42:14
|
LL | type A = core::boxed::Box<u8>;
| ^^^^
|
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
error: aborting due to 9 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,8 +1,6 @@
// compile-pass // compile-pass
// edition:2018 // edition:2018
#![feature(extern_crate_item_prelude)]
macro_rules! define_iso { () => { macro_rules! define_iso { () => {
extern crate std as iso; extern crate std as iso;
}} }}

View File

@ -1,7 +1,6 @@
// compile-pass // compile-pass
// compile-flags:--cfg my_feature // compile-flags:--cfg my_feature
#![feature(extern_crate_item_prelude)]
#![no_std] #![no_std]
#[cfg(my_feature)] #[cfg(my_feature)]

View File

@ -1,8 +1,6 @@
// compile-pass // compile-pass
// aux-build:two_macros.rs // aux-build:two_macros.rs
#![feature(extern_crate_item_prelude)]
extern crate two_macros; extern crate two_macros;
mod m { mod m {

View File

@ -1,7 +1,5 @@
// aux-build:two_macros.rs // aux-build:two_macros.rs
#![feature(extern_crate_item_prelude)]
macro_rules! define_vec { macro_rules! define_vec {
() => { () => {
extern crate std as Vec; extern crate std as Vec;