mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-14 07:53:24 +00:00
Stabilize extern_crate_item_prelude
This commit is contained in:
parent
c4cf115056
commit
1af682a557
@ -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;
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
@ -5022,7 +5021,7 @@ 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.
|
||||
@ -5030,13 +5029,6 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
||||
}
|
||||
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 {
|
||||
|
@ -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()
|
||||
@ -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",
|
||||
|
@ -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.
|
||||
|
@ -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),
|
||||
);
|
||||
@ -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
|
||||
|
@ -1,8 +1,6 @@
|
||||
// compile-pass
|
||||
// edition:2018
|
||||
|
||||
#![feature(extern_crate_item_prelude)]
|
||||
|
||||
extern crate proc_macro;
|
||||
use proc_macro::TokenStream; // OK
|
||||
|
||||
|
@ -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() {}
|
@ -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`.
|
@ -1,8 +1,6 @@
|
||||
// compile-pass
|
||||
// edition:2018
|
||||
|
||||
#![feature(extern_crate_item_prelude)]
|
||||
|
||||
macro_rules! define_iso { () => {
|
||||
extern crate std as iso;
|
||||
}}
|
||||
|
@ -1,7 +1,6 @@
|
||||
// compile-pass
|
||||
// compile-flags:--cfg my_feature
|
||||
|
||||
#![feature(extern_crate_item_prelude)]
|
||||
#![no_std]
|
||||
|
||||
#[cfg(my_feature)]
|
||||
|
@ -1,8 +1,6 @@
|
||||
// compile-pass
|
||||
// aux-build:two_macros.rs
|
||||
|
||||
#![feature(extern_crate_item_prelude)]
|
||||
|
||||
extern crate two_macros;
|
||||
|
||||
mod m {
|
||||
|
@ -1,7 +1,5 @@
|
||||
// aux-build:two_macros.rs
|
||||
|
||||
#![feature(extern_crate_item_prelude)]
|
||||
|
||||
macro_rules! define_vec {
|
||||
() => {
|
||||
extern crate std as Vec;
|
||||
|
Loading…
Reference in New Issue
Block a user