Skip to content

Commit 59b87b3

Browse files
authored
Auto merge of #37127 - jseyfried:stabilize_RFC_1560, r=nrc
Stabilize RFC 1560 Fixes #13598, fixes #23157, fixes #32303. cc #35120 r? @nrc
2 parents b8f6c20 + 649bcd4 commit 59b87b3

39 files changed

+50
-599
lines changed

src/libcoretest/num/flt2dec/strategy/dragon.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use std::prelude::v1::*;
1212
use std::{i16, f64};
1313
use super::super::*;
14-
use core::num::flt2dec::*;
1514
use core::num::bignum::Big32x40 as Big;
1615
use core::num::flt2dec::strategy::dragon::*;
1716

src/libcoretest/num/flt2dec/strategy/grisu.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use std::{i16, f64};
1212
use super::super::*;
13-
use core::num::flt2dec::*;
1413
use core::num::flt2dec::strategy::grisu::*;
1514

1615
#[test]

src/librustc/hir/map/collector.rs

-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
// except according to those terms.
1010

1111
use super::*;
12-
use super::MapEntry::*;
1312

14-
use hir::*;
1513
use hir::intravisit::Visitor;
1614
use hir::def_id::DefId;
1715
use middle::cstore::InlinedItem;

src/librustc/hir/map/def_collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use super::*;
11+
use hir::map::definitions::*;
1212

1313
use hir;
1414
use hir::intravisit;

src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#![feature(core_intrinsics)]
3434
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
3535
#![feature(enumset)]
36+
#![cfg_attr(stage0, feature(item_like_imports))]
3637
#![feature(libc)]
3738
#![feature(nonzero)]
3839
#![feature(quote)]

src/librustc_mir/hair/cx/expr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use rustc_const_eval as const_eval;
2121
use rustc::middle::region::CodeExtent;
2222
use rustc::ty::{self, AdtKind, VariantDef, Ty};
2323
use rustc::ty::cast::CastKind as TyCastKind;
24-
use rustc::mir::*;
2524
use rustc::hir;
2625
use syntax::ptr::P;
2726

src/librustc_mir/hair/cx/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
use hair::*;
19-
use rustc::mir::*;
2019
use rustc::mir::transform::MirSource;
2120

2221
use rustc::middle::const_val::ConstVal;

src/librustc_mir/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
2323
#![feature(associated_consts)]
2424
#![feature(box_patterns)]
2525
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
26+
#![cfg_attr(stage0, feature(item_like_imports))]
2627
#![feature(rustc_diagnostic_macros)]
2728
#![feature(rustc_private)]
2829
#![feature(staged_api)]

src/librustc_resolve/build_reduced_graph.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ impl<'b> Resolver<'b> {
582582
});
583583
} else {
584584
for (name, span) in legacy_imports.imports {
585-
let result = self.resolve_name_in_module(module, name, MacroNS, false, false, None);
585+
let result = self.resolve_name_in_module(module, name, MacroNS, false, None);
586586
if let Success(binding) = result {
587587
self.legacy_import_macro(name, binding, span, allow_shadowing);
588588
} else {
@@ -592,7 +592,7 @@ impl<'b> Resolver<'b> {
592592
}
593593
for (name, span) in legacy_imports.reexports {
594594
self.used_crates.insert(module.def_id().unwrap().krate);
595-
let result = self.resolve_name_in_module(module, name, MacroNS, false, false, None);
595+
let result = self.resolve_name_in_module(module, name, MacroNS, false, None);
596596
if let Success(binding) = result {
597597
self.macro_exports.push(Export { name: name, def: binding.def() });
598598
} else {

src/librustc_resolve/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ items under a new local name.
5959
6060
An example of this error:
6161
62-
```compile_fail
62+
```ignore
6363
use foo::baz;
6464
use bar::*; // error, do `use foo::baz as quux` instead on the previous line
6565

src/librustc_resolve/lib.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,6 @@ pub struct Resolver<'a> {
11311131

11321132
arenas: &'a ResolverArenas<'a>,
11331133
dummy_binding: &'a NameBinding<'a>,
1134-
new_import_semantics: bool, // true if `#![feature(item_like_imports)]`
11351134
use_extern_macros: bool, // true if `#![feature(use_extern_macros)]`
11361135

11371136
pub exported_macros: Vec<ast::MacroDef>,
@@ -1333,7 +1332,6 @@ impl<'a> Resolver<'a> {
13331332
span: DUMMY_SP,
13341333
vis: ty::Visibility::Public,
13351334
}),
1336-
new_import_semantics: session.features.borrow().item_like_imports,
13371335
use_extern_macros: session.features.borrow().use_extern_macros,
13381336

13391337
exported_macros: Vec::new(),
@@ -1442,7 +1440,7 @@ impl<'a> Resolver<'a> {
14421440
-> ResolveResult<Module<'a>> {
14431441
fn search_parent_externals<'a>(this: &mut Resolver<'a>, needle: Name, module: Module<'a>)
14441442
-> Option<Module<'a>> {
1445-
match this.resolve_name_in_module(module, needle, TypeNS, false, false, None) {
1443+
match this.resolve_name_in_module(module, needle, TypeNS, false, None) {
14461444
Success(binding) if binding.is_extern_crate() => Some(module),
14471445
_ => if let (&ModuleKind::Def(..), Some(parent)) = (&module.kind, module.parent) {
14481446
search_parent_externals(this, needle, parent)
@@ -1460,7 +1458,7 @@ impl<'a> Resolver<'a> {
14601458
// modules as we go.
14611459
while index < module_path_len {
14621460
let name = module_path[index].name;
1463-
match self.resolve_name_in_module(search_module, name, TypeNS, false, false, span) {
1461+
match self.resolve_name_in_module(search_module, name, TypeNS, false, span) {
14641462
Failed(_) => {
14651463
let segment_name = name.as_str();
14661464
let module_name = module_to_string(search_module);
@@ -1617,7 +1615,7 @@ impl<'a> Resolver<'a> {
16171615

16181616
if let ModuleRibKind(module) = self.ribs[ns][i].kind {
16191617
let name = ident.name;
1620-
let item = self.resolve_name_in_module(module, name, ns, true, false, record_used);
1618+
let item = self.resolve_name_in_module(module, name, ns, false, record_used);
16211619
if let Success(binding) = item {
16221620
// The ident resolves to an item.
16231621
return Some(LexicalScopeBinding::Item(binding));
@@ -1626,7 +1624,7 @@ impl<'a> Resolver<'a> {
16261624
if let ModuleKind::Block(..) = module.kind { // We can see through blocks
16271625
} else if !module.no_implicit_prelude {
16281626
return self.prelude.and_then(|prelude| {
1629-
self.resolve_name_in_module(prelude, name, ns, false, false, None).success()
1627+
self.resolve_name_in_module(prelude, name, ns, false, None).success()
16301628
}).map(LexicalScopeBinding::Item)
16311629
} else {
16321630
return None;
@@ -2772,7 +2770,7 @@ impl<'a> Resolver<'a> {
27722770
};
27732771

27742772
let name = segments.last().unwrap().identifier.name;
2775-
let result = self.resolve_name_in_module(module, name, namespace, false, false, Some(span));
2773+
let result = self.resolve_name_in_module(module, name, namespace, false, Some(span));
27762774
result.success().ok_or(false)
27772775
}
27782776

@@ -2800,7 +2798,7 @@ impl<'a> Resolver<'a> {
28002798
};
28012799

28022800
let name = segments.last().unwrap().ident().name;
2803-
let result = self.resolve_name_in_module(module, name, namespace, false, false, Some(span));
2801+
let result = self.resolve_name_in_module(module, name, namespace, false, Some(span));
28042802
result.success().ok_or(false)
28052803
}
28062804

src/librustc_resolve/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl<'a> Resolver<'a> {
272272
loop {
273273
// Since expanded macros may not shadow the lexical scope (enforced below),
274274
// we can ignore unresolved invocations (indicated by the penultimate argument).
275-
match self.resolve_name_in_module(module, name, ns, true, true, record_used) {
275+
match self.resolve_name_in_module(module, name, ns, true, record_used) {
276276
Success(binding) => {
277277
let span = match record_used {
278278
Some(span) => span,

src/librustc_resolve/resolve_imports.rs

+13-49
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ pub struct NameResolution<'a> {
7575
single_imports: SingleImports<'a>,
7676
/// The least shadowable known binding for this name, or None if there are no known bindings.
7777
pub binding: Option<&'a NameBinding<'a>>,
78-
duplicate_globs: Vec<&'a NameBinding<'a>>,
7978
}
8079

8180
#[derive(Clone, Debug)]
@@ -141,7 +140,6 @@ impl<'a> Resolver<'a> {
141140
module: Module<'a>,
142141
name: Name,
143142
ns: Namespace,
144-
allow_private_imports: bool,
145143
ignore_unresolved_invocations: bool,
146144
record_used: Option<Span>)
147145
-> ResolveResult<&'a NameBinding<'a>> {
@@ -153,18 +151,8 @@ impl<'a> Resolver<'a> {
153151
_ => return Failed(None), // This happens when there is a cycle of imports
154152
};
155153

156-
let new_import_semantics = self.new_import_semantics;
157-
let is_disallowed_private_import = |binding: &NameBinding| {
158-
!new_import_semantics && !allow_private_imports && // disallowed
159-
binding.vis != ty::Visibility::Public && binding.is_import() && // non-`pub` import
160-
!binding.is_extern_crate() // not an `extern crate`
161-
};
162-
163154
if let Some(span) = record_used {
164155
if let Some(binding) = resolution.binding {
165-
if is_disallowed_private_import(binding) {
166-
return Failed(None);
167-
}
168156
if self.record_use(name, ns, binding, span) {
169157
return Success(self.dummy_binding);
170158
}
@@ -177,9 +165,8 @@ impl<'a> Resolver<'a> {
177165
}
178166

179167
let check_usable = |this: &mut Self, binding: &'a NameBinding<'a>| {
180-
let usable =
181-
this.is_accessible(binding.vis) && !is_disallowed_private_import(binding) ||
182-
binding.is_extern_crate(); // c.f. issue #37020
168+
// `extern crate` are always usable for backwards compatability, see issue #37020.
169+
let usable = this.is_accessible(binding.vis) || binding.is_extern_crate();
183170
if usable { Success(binding) } else { Failed(None) }
184171
};
185172

@@ -202,7 +189,7 @@ impl<'a> Resolver<'a> {
202189
SingleImport { source, .. } => source,
203190
_ => unreachable!(),
204191
};
205-
match self.resolve_name_in_module(module, name, ns, true, false, None) {
192+
match self.resolve_name_in_module(module, name, ns, false, None) {
206193
Failed(_) => {}
207194
_ => return Indeterminate,
208195
}
@@ -224,7 +211,7 @@ impl<'a> Resolver<'a> {
224211
for directive in module.globs.borrow().iter() {
225212
if self.is_accessible(directive.vis.get()) {
226213
if let Some(module) = directive.imported_module.get() {
227-
let result = self.resolve_name_in_module(module, name, ns, true, false, None);
214+
let result = self.resolve_name_in_module(module, name, ns, false, None);
228215
if let Indeterminate = result {
229216
return Indeterminate;
230217
}
@@ -311,22 +298,17 @@ impl<'a> Resolver<'a> {
311298
self.update_resolution(module, name, ns, |this, resolution| {
312299
if let Some(old_binding) = resolution.binding {
313300
if binding.is_glob_import() {
314-
if !this.new_import_semantics {
315-
resolution.duplicate_globs.push(binding);
316-
} else if !old_binding.is_glob_import() &&
317-
!(ns == MacroNS && old_binding.expansion != Mark::root()) {
301+
if !old_binding.is_glob_import() &&
302+
!(ns == MacroNS && old_binding.expansion != Mark::root()) {
318303
} else if binding.def() != old_binding.def() {
319304
resolution.binding = Some(this.ambiguity(old_binding, binding));
320305
} else if !old_binding.vis.is_at_least(binding.vis, this) {
321306
// We are glob-importing the same item but with greater visibility.
322307
resolution.binding = Some(binding);
323308
}
324309
} else if old_binding.is_glob_import() {
325-
if !this.new_import_semantics {
326-
resolution.duplicate_globs.push(old_binding);
327-
resolution.binding = Some(binding);
328-
} else if ns == MacroNS && binding.expansion != Mark::root() &&
329-
binding.def() != old_binding.def() {
310+
if ns == MacroNS && binding.expansion != Mark::root() &&
311+
binding.def() != old_binding.def() {
330312
resolution.binding = Some(this.ambiguity(binding, old_binding));
331313
} else {
332314
resolution.binding = Some(binding);
@@ -366,7 +348,7 @@ impl<'a> Resolver<'a> {
366348
let t = f(self, resolution);
367349

368350
match resolution.binding() {
369-
_ if !self.new_import_semantics && old_binding.is_some() => return t,
351+
_ if old_binding.is_some() => return t,
370352
None => return t,
371353
Some(binding) => match old_binding {
372354
Some(old_binding) if old_binding as *const _ == binding as *const _ => return t,
@@ -377,10 +359,7 @@ impl<'a> Resolver<'a> {
377359

378360
// Define `binding` in `module`s glob importers.
379361
for directive in module.glob_importers.borrow_mut().iter() {
380-
if match self.new_import_semantics {
381-
true => self.is_accessible_from(binding.vis, directive.parent),
382-
false => binding.vis == ty::Visibility::Public,
383-
} {
362+
if self.is_accessible_from(binding.vis, directive.parent) {
384363
let imported_binding = self.import(binding, directive);
385364
let _ = self.try_define(directive.parent, name, ns, imported_binding);
386365
}
@@ -528,7 +507,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
528507
self.per_ns(|this, ns| {
529508
if let Err(Undetermined) = result[ns].get() {
530509
result[ns].set({
531-
match this.resolve_name_in_module(module, source, ns, false, false, None) {
510+
match this.resolve_name_in_module(module, source, ns, false, None) {
532511
Success(binding) => Ok(binding),
533512
Indeterminate => Err(Undetermined),
534513
Failed(_) => Err(Determined),
@@ -624,7 +603,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
624603
if all_ns_err {
625604
let mut all_ns_failed = true;
626605
self.per_ns(|this, ns| {
627-
match this.resolve_name_in_module(module, name, ns, false, false, Some(span)) {
606+
match this.resolve_name_in_module(module, name, ns, false, Some(span)) {
628607
Success(_) => all_ns_failed = false,
629608
_ => {}
630609
}
@@ -729,8 +708,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
729708
resolution.borrow().binding().map(|binding| (*name, binding))
730709
}).collect::<Vec<_>>();
731710
for ((name, ns), binding) in bindings {
732-
if binding.pseudo_vis() == ty::Visibility::Public ||
733-
self.new_import_semantics && self.is_accessible(binding.vis) {
711+
if binding.pseudo_vis() == ty::Visibility::Public || self.is_accessible(binding.vis) {
734712
let imported_binding = self.import(binding, directive);
735713
let _ = self.try_define(directive.parent, name, ns, imported_binding);
736714
}
@@ -761,20 +739,6 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
761739
None => continue,
762740
};
763741

764-
// Report conflicts
765-
if !self.new_import_semantics {
766-
for duplicate_glob in resolution.duplicate_globs.iter() {
767-
// FIXME #31337: We currently allow items to shadow glob-imported re-exports.
768-
if !binding.is_import() {
769-
if let NameBindingKind::Import { binding, .. } = duplicate_glob.kind {
770-
if binding.is_import() { continue }
771-
}
772-
}
773-
774-
self.report_conflict(module, name, ns, duplicate_glob, binding);
775-
}
776-
}
777-
778742
if binding.vis == ty::Visibility::Public &&
779743
(binding.is_import() || binding.is_extern_crate()) {
780744
let def = binding.def();

src/libsyntax/feature_gate.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,6 @@ declare_features! (
284284
// instead of just the platforms on which it is the C ABI
285285
(active, abi_sysv64, "1.13.0", Some(36167)),
286286

287-
// Use the import semantics from RFC 1560.
288-
(active, item_like_imports, "1.13.0", Some(35120)),
289-
290287
// Macros 1.1
291288
(active, proc_macro, "1.13.0", Some(35900)),
292289

@@ -362,6 +359,7 @@ declare_features! (
362359
(accepted, question_mark, "1.13.0", Some(31436)),
363360
// Allows `..` in tuple (struct) patterns
364361
(accepted, dotdot_in_tuple_patterns, "1.14.0", Some(33627)),
362+
(accepted, item_like_imports, "1.14.0", Some(35120)),
365363
);
366364
// (changing above list without updating src/doc/reference.md makes @cmr sad)
367365

src/test/compile-fail/auxiliary/issue_12612_1.rs

-13
This file was deleted.

0 commit comments

Comments
 (0)