Navigation Menu

Skip to content

Commit

Permalink
Stabilize extern_crate_item_prelude
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Nov 20, 2018
1 parent c4cf115 commit 1af682a
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 148 deletions.
12 changes: 2 additions & 10 deletions src/librustc_resolve/lib.rs
Expand Up @@ -58,7 +58,6 @@ use syntax::ast::{self, Name, NodeId, Ident, FloatTy, IntTy, UintTy};
use syntax::ext::base::SyntaxExtension;
use syntax::ext::base::Determinacy::{self, Determined, Undetermined};
use syntax::ext::base::MacroKind;
use syntax::feature_gate::{emit_feature_err, GateIssue};
use syntax::symbol::{Symbol, keywords};
use syntax::util::lev_distance::find_best_match_for_name;

Expand Down Expand Up @@ -2115,7 +2114,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {

if !module.no_implicit_prelude {
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));
}
}
Expand Down Expand Up @@ -5022,21 +5021,14 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
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>> {
if ident.is_path_segment_keyword() {
// Make sure `self`, `super` etc produce an error when passed to here.
return None;
}
self.extern_prelude.get(&ident.modern()).cloned().and_then(|entry| {
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)
} else {
let crate_id = if !speculative {
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_resolve/macros.rs
Expand Up @@ -738,8 +738,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
}
WhereToResolve::ExternPrelude => {
if use_prelude {
match self.extern_prelude_get(ident, !record_used,
innermost_result.is_some()) {
match self.extern_prelude_get(ident, !record_used) {
Some(binding) => Ok((binding, Flags::PRELUDE)),
None => Err(Determinacy::determined(
self.graph_root.unresolved_invocations.borrow().is_empty()
Expand Down Expand Up @@ -906,7 +905,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
// 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.
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 \
passed with `--extern` on stable channel";
let mut err = feature_err(&self.session.parse_sess, "uniform_paths",
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_resolve/resolve_imports.rs
Expand Up @@ -166,8 +166,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
assert!(!restricted_shadowing);
match uniform_root_kind {
UniformRootKind::ExternPrelude => {
return if let Some(binding) =
self.extern_prelude_get(ident, !record_used, false) {
return if let Some(binding) = self.extern_prelude_get(ident, !record_used) {
Ok(binding)
} else if !self.graph_root.unresolved_invocations.borrow().is_empty() {
// Macro-expanded `extern crate` items can add names to extern prelude.
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/feature_gate.rs
Expand Up @@ -499,9 +499,6 @@ declare_features! (
// Allows `const _: TYPE = VALUE`
(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
(active, lint_reasons, "1.31.0", Some(54503), None),
);
Expand Down Expand Up @@ -691,6 +688,8 @@ declare_features! (
// impl<I:Iterator> Iterator for &mut Iterator
// impl Debug for Foo<'_>
(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
Expand Down
@@ -1,8 +1,6 @@
// compile-pass
// edition:2018

#![feature(extern_crate_item_prelude)]

extern crate proc_macro;
use proc_macro::TokenStream; // OK

Expand Down

This file was deleted.

This file was deleted.

@@ -1,8 +1,6 @@
// compile-pass
// edition:2018

#![feature(extern_crate_item_prelude)]

macro_rules! define_iso { () => {
extern crate std as iso;
}}
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/imports/extern-prelude-extern-crate-cfg.rs
@@ -1,7 +1,6 @@
// compile-pass
// compile-flags:--cfg my_feature

#![feature(extern_crate_item_prelude)]
#![no_std]

#[cfg(my_feature)]
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/imports/extern-prelude-extern-crate-pass.rs
@@ -1,8 +1,6 @@
// compile-pass
// aux-build:two_macros.rs

#![feature(extern_crate_item_prelude)]

extern crate two_macros;

mod m {
Expand Down
@@ -1,7 +1,5 @@
// aux-build:two_macros.rs

#![feature(extern_crate_item_prelude)]

macro_rules! define_vec {
() => {
extern crate std as Vec;
Expand Down

0 comments on commit 1af682a

Please sign in to comment.