1
Fork 0

Auto merge of #37127 - jseyfried:stabilize_RFC_1560, r=nrc

Stabilize RFC 1560

Fixes #13598, fixes #23157, fixes #32303.
cc #35120
r? @nrc
This commit is contained in:
bors 2016-11-21 04:54:46 -06:00 committed by GitHub
commit 59b87b3975
39 changed files with 50 additions and 599 deletions

View file

@ -11,7 +11,6 @@
use std::prelude::v1::*;
use std::{i16, f64};
use super::super::*;
use core::num::flt2dec::*;
use core::num::bignum::Big32x40 as Big;
use core::num::flt2dec::strategy::dragon::*;

View file

@ -10,7 +10,6 @@
use std::{i16, f64};
use super::super::*;
use core::num::flt2dec::*;
use core::num::flt2dec::strategy::grisu::*;
#[test]

View file

@ -9,9 +9,7 @@
// except according to those terms.
use super::*;
use super::MapEntry::*;
use hir::*;
use hir::intravisit::Visitor;
use hir::def_id::DefId;
use middle::cstore::InlinedItem;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use super::*;
use hir::map::definitions::*;
use hir;
use hir::intravisit;

View file

@ -33,6 +33,7 @@
#![feature(core_intrinsics)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![feature(enumset)]
#![cfg_attr(stage0, feature(item_like_imports))]
#![feature(libc)]
#![feature(nonzero)]
#![feature(quote)]

View file

@ -21,7 +21,6 @@ use rustc_const_eval as const_eval;
use rustc::middle::region::CodeExtent;
use rustc::ty::{self, AdtKind, VariantDef, Ty};
use rustc::ty::cast::CastKind as TyCastKind;
use rustc::mir::*;
use rustc::hir;
use syntax::ptr::P;

View file

@ -16,7 +16,6 @@
*/
use hair::*;
use rustc::mir::*;
use rustc::mir::transform::MirSource;
use rustc::middle::const_val::ConstVal;

View file

@ -23,6 +23,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(associated_consts)]
#![feature(box_patterns)]
#![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
#![cfg_attr(stage0, feature(item_like_imports))]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]

View file

@ -582,7 +582,7 @@ impl<'b> Resolver<'b> {
});
} else {
for (name, span) in legacy_imports.imports {
let result = self.resolve_name_in_module(module, name, MacroNS, false, false, None);
let result = self.resolve_name_in_module(module, name, MacroNS, false, None);
if let Success(binding) = result {
self.legacy_import_macro(name, binding, span, allow_shadowing);
} else {
@ -592,7 +592,7 @@ impl<'b> Resolver<'b> {
}
for (name, span) in legacy_imports.reexports {
self.used_crates.insert(module.def_id().unwrap().krate);
let result = self.resolve_name_in_module(module, name, MacroNS, false, false, None);
let result = self.resolve_name_in_module(module, name, MacroNS, false, None);
if let Success(binding) = result {
self.macro_exports.push(Export { name: name, def: binding.def() });
} else {

View file

@ -59,7 +59,7 @@ items under a new local name.
An example of this error:
```compile_fail
```ignore
use foo::baz;
use bar::*; // error, do `use foo::baz as quux` instead on the previous line

View file

@ -1131,7 +1131,6 @@ pub struct Resolver<'a> {
arenas: &'a ResolverArenas<'a>,
dummy_binding: &'a NameBinding<'a>,
new_import_semantics: bool, // true if `#![feature(item_like_imports)]`
use_extern_macros: bool, // true if `#![feature(use_extern_macros)]`
pub exported_macros: Vec<ast::MacroDef>,
@ -1333,7 +1332,6 @@ impl<'a> Resolver<'a> {
span: DUMMY_SP,
vis: ty::Visibility::Public,
}),
new_import_semantics: session.features.borrow().item_like_imports,
use_extern_macros: session.features.borrow().use_extern_macros,
exported_macros: Vec::new(),
@ -1442,7 +1440,7 @@ impl<'a> Resolver<'a> {
-> ResolveResult<Module<'a>> {
fn search_parent_externals<'a>(this: &mut Resolver<'a>, needle: Name, module: Module<'a>)
-> Option<Module<'a>> {
match this.resolve_name_in_module(module, needle, TypeNS, false, false, None) {
match this.resolve_name_in_module(module, needle, TypeNS, false, None) {
Success(binding) if binding.is_extern_crate() => Some(module),
_ => if let (&ModuleKind::Def(..), Some(parent)) = (&module.kind, module.parent) {
search_parent_externals(this, needle, parent)
@ -1460,7 +1458,7 @@ impl<'a> Resolver<'a> {
// modules as we go.
while index < module_path_len {
let name = module_path[index].name;
match self.resolve_name_in_module(search_module, name, TypeNS, false, false, span) {
match self.resolve_name_in_module(search_module, name, TypeNS, false, span) {
Failed(_) => {
let segment_name = name.as_str();
let module_name = module_to_string(search_module);
@ -1617,7 +1615,7 @@ impl<'a> Resolver<'a> {
if let ModuleRibKind(module) = self.ribs[ns][i].kind {
let name = ident.name;
let item = self.resolve_name_in_module(module, name, ns, true, false, record_used);
let item = self.resolve_name_in_module(module, name, ns, false, record_used);
if let Success(binding) = item {
// The ident resolves to an item.
return Some(LexicalScopeBinding::Item(binding));
@ -1626,7 +1624,7 @@ impl<'a> Resolver<'a> {
if let ModuleKind::Block(..) = module.kind { // We can see through blocks
} else if !module.no_implicit_prelude {
return self.prelude.and_then(|prelude| {
self.resolve_name_in_module(prelude, name, ns, false, false, None).success()
self.resolve_name_in_module(prelude, name, ns, false, None).success()
}).map(LexicalScopeBinding::Item)
} else {
return None;
@ -2772,7 +2770,7 @@ impl<'a> Resolver<'a> {
};
let name = segments.last().unwrap().identifier.name;
let result = self.resolve_name_in_module(module, name, namespace, false, false, Some(span));
let result = self.resolve_name_in_module(module, name, namespace, false, Some(span));
result.success().ok_or(false)
}
@ -2800,7 +2798,7 @@ impl<'a> Resolver<'a> {
};
let name = segments.last().unwrap().ident().name;
let result = self.resolve_name_in_module(module, name, namespace, false, false, Some(span));
let result = self.resolve_name_in_module(module, name, namespace, false, Some(span));
result.success().ok_or(false)
}

View file

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

View file

@ -75,7 +75,6 @@ pub struct NameResolution<'a> {
single_imports: SingleImports<'a>,
/// The least shadowable known binding for this name, or None if there are no known bindings.
pub binding: Option<&'a NameBinding<'a>>,
duplicate_globs: Vec<&'a NameBinding<'a>>,
}
#[derive(Clone, Debug)]
@ -141,7 +140,6 @@ impl<'a> Resolver<'a> {
module: Module<'a>,
name: Name,
ns: Namespace,
allow_private_imports: bool,
ignore_unresolved_invocations: bool,
record_used: Option<Span>)
-> ResolveResult<&'a NameBinding<'a>> {
@ -153,18 +151,8 @@ impl<'a> Resolver<'a> {
_ => return Failed(None), // This happens when there is a cycle of imports
};
let new_import_semantics = self.new_import_semantics;
let is_disallowed_private_import = |binding: &NameBinding| {
!new_import_semantics && !allow_private_imports && // disallowed
binding.vis != ty::Visibility::Public && binding.is_import() && // non-`pub` import
!binding.is_extern_crate() // not an `extern crate`
};
if let Some(span) = record_used {
if let Some(binding) = resolution.binding {
if is_disallowed_private_import(binding) {
return Failed(None);
}
if self.record_use(name, ns, binding, span) {
return Success(self.dummy_binding);
}
@ -177,9 +165,8 @@ impl<'a> Resolver<'a> {
}
let check_usable = |this: &mut Self, binding: &'a NameBinding<'a>| {
let usable =
this.is_accessible(binding.vis) && !is_disallowed_private_import(binding) ||
binding.is_extern_crate(); // c.f. issue #37020
// `extern crate` are always usable for backwards compatability, see issue #37020.
let usable = this.is_accessible(binding.vis) || binding.is_extern_crate();
if usable { Success(binding) } else { Failed(None) }
};
@ -202,7 +189,7 @@ impl<'a> Resolver<'a> {
SingleImport { source, .. } => source,
_ => unreachable!(),
};
match self.resolve_name_in_module(module, name, ns, true, false, None) {
match self.resolve_name_in_module(module, name, ns, false, None) {
Failed(_) => {}
_ => return Indeterminate,
}
@ -224,7 +211,7 @@ impl<'a> Resolver<'a> {
for directive in module.globs.borrow().iter() {
if self.is_accessible(directive.vis.get()) {
if let Some(module) = directive.imported_module.get() {
let result = self.resolve_name_in_module(module, name, ns, true, false, None);
let result = self.resolve_name_in_module(module, name, ns, false, None);
if let Indeterminate = result {
return Indeterminate;
}
@ -311,10 +298,8 @@ impl<'a> Resolver<'a> {
self.update_resolution(module, name, ns, |this, resolution| {
if let Some(old_binding) = resolution.binding {
if binding.is_glob_import() {
if !this.new_import_semantics {
resolution.duplicate_globs.push(binding);
} else if !old_binding.is_glob_import() &&
!(ns == MacroNS && old_binding.expansion != Mark::root()) {
if !old_binding.is_glob_import() &&
!(ns == MacroNS && old_binding.expansion != Mark::root()) {
} else if binding.def() != old_binding.def() {
resolution.binding = Some(this.ambiguity(old_binding, binding));
} else if !old_binding.vis.is_at_least(binding.vis, this) {
@ -322,11 +307,8 @@ impl<'a> Resolver<'a> {
resolution.binding = Some(binding);
}
} else if old_binding.is_glob_import() {
if !this.new_import_semantics {
resolution.duplicate_globs.push(old_binding);
resolution.binding = Some(binding);
} else if ns == MacroNS && binding.expansion != Mark::root() &&
binding.def() != old_binding.def() {
if ns == MacroNS && binding.expansion != Mark::root() &&
binding.def() != old_binding.def() {
resolution.binding = Some(this.ambiguity(binding, old_binding));
} else {
resolution.binding = Some(binding);
@ -366,7 +348,7 @@ impl<'a> Resolver<'a> {
let t = f(self, resolution);
match resolution.binding() {
_ if !self.new_import_semantics && old_binding.is_some() => return t,
_ if old_binding.is_some() => return t,
None => return t,
Some(binding) => match old_binding {
Some(old_binding) if old_binding as *const _ == binding as *const _ => return t,
@ -377,10 +359,7 @@ impl<'a> Resolver<'a> {
// Define `binding` in `module`s glob importers.
for directive in module.glob_importers.borrow_mut().iter() {
if match self.new_import_semantics {
true => self.is_accessible_from(binding.vis, directive.parent),
false => binding.vis == ty::Visibility::Public,
} {
if self.is_accessible_from(binding.vis, directive.parent) {
let imported_binding = self.import(binding, directive);
let _ = self.try_define(directive.parent, name, ns, imported_binding);
}
@ -528,7 +507,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
self.per_ns(|this, ns| {
if let Err(Undetermined) = result[ns].get() {
result[ns].set({
match this.resolve_name_in_module(module, source, ns, false, false, None) {
match this.resolve_name_in_module(module, source, ns, false, None) {
Success(binding) => Ok(binding),
Indeterminate => Err(Undetermined),
Failed(_) => Err(Determined),
@ -624,7 +603,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
if all_ns_err {
let mut all_ns_failed = true;
self.per_ns(|this, ns| {
match this.resolve_name_in_module(module, name, ns, false, false, Some(span)) {
match this.resolve_name_in_module(module, name, ns, false, Some(span)) {
Success(_) => all_ns_failed = false,
_ => {}
}
@ -729,8 +708,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
resolution.borrow().binding().map(|binding| (*name, binding))
}).collect::<Vec<_>>();
for ((name, ns), binding) in bindings {
if binding.pseudo_vis() == ty::Visibility::Public ||
self.new_import_semantics && self.is_accessible(binding.vis) {
if binding.pseudo_vis() == ty::Visibility::Public || self.is_accessible(binding.vis) {
let imported_binding = self.import(binding, directive);
let _ = self.try_define(directive.parent, name, ns, imported_binding);
}
@ -761,20 +739,6 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
None => continue,
};
// Report conflicts
if !self.new_import_semantics {
for duplicate_glob in resolution.duplicate_globs.iter() {
// FIXME #31337: We currently allow items to shadow glob-imported re-exports.
if !binding.is_import() {
if let NameBindingKind::Import { binding, .. } = duplicate_glob.kind {
if binding.is_import() { continue }
}
}
self.report_conflict(module, name, ns, duplicate_glob, binding);
}
}
if binding.vis == ty::Visibility::Public &&
(binding.is_import() || binding.is_extern_crate()) {
let def = binding.def();

View file

@ -284,9 +284,6 @@ declare_features! (
// instead of just the platforms on which it is the C ABI
(active, abi_sysv64, "1.13.0", Some(36167)),
// Use the import semantics from RFC 1560.
(active, item_like_imports, "1.13.0", Some(35120)),
// Macros 1.1
(active, proc_macro, "1.13.0", Some(35900)),
@ -362,6 +359,7 @@ declare_features! (
(accepted, question_mark, "1.13.0", Some(31436)),
// Allows `..` in tuple (struct) patterns
(accepted, dotdot_in_tuple_patterns, "1.14.0", Some(33627)),
(accepted, item_like_imports, "1.14.0", Some(35120)),
);
// (changing above list without updating src/doc/reference.md makes @cmr sad)

View file

@ -1,13 +0,0 @@
// Copyright 2014 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub mod bar {
pub fn foo() {}
}

View file

@ -1,83 +0,0 @@
// Copyright 2016 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// FIXME: Remove when `item_like_imports` is stabilized.
pub mod c {
pub struct S {}
pub struct TS();
pub struct US;
pub enum E {
V {},
TV(),
UV,
}
pub struct Item;
}
pub mod proxy {
pub use c::*;
pub use c::E::*;
}
pub mod xm1 {
pub use ::proxy::*;
pub type S = ::c::Item;
}
pub mod xm2 {
pub use ::proxy::*;
pub const S: ::c::Item = ::c::Item;
}
pub mod xm3 {
pub use ::proxy::*;
pub type TS = ::c::Item;
}
pub mod xm4 {
pub use ::proxy::*;
pub const TS: ::c::Item = ::c::Item;
}
pub mod xm5 {
pub use ::proxy::*;
pub type US = ::c::Item;
}
pub mod xm6 {
pub use ::proxy::*;
pub const US: ::c::Item = ::c::Item;
}
pub mod xm7 {
pub use ::proxy::*;
pub type V = ::c::Item;
}
pub mod xm8 {
pub use ::proxy::*;
pub const V: ::c::Item = ::c::Item;
}
pub mod xm9 {
pub use ::proxy::*;
pub type TV = ::c::Item;
}
pub mod xmA {
pub use ::proxy::*;
pub const TV: ::c::Item = ::c::Item;
}
pub mod xmB {
pub use ::proxy::*;
pub type UV = ::c::Item;
}
pub mod xmC {
pub use ::proxy::*;
pub const UV: ::c::Item = ::c::Item;
}

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(item_like_imports)]
pub mod c {
pub struct S {}
pub struct TS();

View file

@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustc_attrs)]
mod foo {
pub use bar::*;
pub use main as f; //~ ERROR has already been imported
pub use main as f;
}
mod bar {
@ -18,9 +20,10 @@ mod bar {
}
pub use foo::*;
pub use baz::*; //~ ERROR has already been imported
pub use baz::*;
mod baz {
pub use super::*;
}
pub fn main() {}
#[rustc_error]
pub fn main() {} //~ ERROR compilation successful

View file

@ -1,30 +0,0 @@
// Copyright 2014 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
use foo::*;
use bar::*; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = isize;
}
mod bar {
pub type Baz = isize;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View file

@ -1,30 +0,0 @@
// Copyright 2014 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
use foo::*;
use foo::*; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = isize;
}
mod bar {
pub type Baz = isize;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View file

@ -1,30 +0,0 @@
// Copyright 2014 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
use foo::Baz;
use bar::*; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = isize;
}
mod bar {
pub type Baz = isize;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View file

@ -1,30 +0,0 @@
// Copyright 2014 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
use foo::*;
use bar::Baz; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = isize;
}
mod bar {
pub type Baz = isize;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View file

@ -1,30 +0,0 @@
// Copyright 2014 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
use foo::Baz;
use bar::Baz; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = isize;
}
mod bar {
pub type Baz = isize;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View file

@ -1,30 +0,0 @@
// Copyright 2014 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
use qux::*;
use foo::*; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = isize;
}
mod bar {
pub type Baz = isize;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View file

@ -1,30 +0,0 @@
// Copyright 2014 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that import shadowing using globs causes errors
#![no_implicit_prelude]
use foo::*;
use qux::*; //~ERROR a type named `Baz` has already been imported in this module
mod foo {
pub type Baz = isize;
}
mod bar {
pub type Baz = isize;
}
mod qux {
pub use bar::Baz;
}
fn main() {}

View file

@ -20,6 +20,6 @@ mod zed {
}
fn main() {
zed::foo(); //~ ERROR unresolved name
zed::foo(); //~ ERROR `foo` is private
bar();
}

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(item_like_imports)]
mod a {
pub fn foo() {}
}

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(item_like_imports)]
mod a {
fn foo() {}
mod foo {}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(pub_restricted, item_like_imports)]
#![feature(pub_restricted)]
#![deny(unused)]
mod foo {

View file

@ -1,22 +0,0 @@
// Copyright 2014 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// aux-build:issue_12612_1.rs
extern crate issue_12612_1 as foo;
use foo::bar;
mod test {
use bar::foo; //~ ERROR unresolved import `bar::foo` [E0432]
//~^ Maybe a missing `extern crate bar;`?
}
fn main() {}

View file

@ -8,14 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustc_attrs)]
pub use bar::*;
mod bar {
pub use super::*;
}
pub use baz::*; //~ ERROR already been imported
pub use baz::*;
mod baz {
pub use main as f;
}
pub fn main() {}
#[rustc_error]
pub fn main() {} //~ ERROR compilation successful

View file

@ -11,8 +11,7 @@
use bar::Foo; //~ ERROR unresolved import `bar::Foo` [E0432]
//~^ no `Foo` in `bar`
mod bar {
use Foo; //~ ERROR unresolved import `Foo` [E0432]
//~^ no `Foo` in the root
use Foo;
}
fn main() {}

View file

@ -1,172 +0,0 @@
// Copyright 2016 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// FIXME: Remove when `item_like_imports` is stabilized.
// aux-build:namespace-mix-old.rs
extern crate namespace_mix_old;
use namespace_mix_old::{xm1, xm2, xm3, xm4, xm5, xm6, xm7, xm8, xm9, xmA, xmB, xmC};
mod c {
pub struct S {}
pub struct TS();
pub struct US;
pub enum E {
V {},
TV(),
UV,
}
pub struct Item;
}
mod proxy {
pub use c::*;
pub use c::E::*;
}
// Use something emitting the type argument name, e.g. unsatisfied bound.
trait Impossible {}
fn check<T: Impossible>(_: T) {}
mod m1 {
pub use ::proxy::*;
pub type S = ::c::Item;
}
mod m2 {
pub use ::proxy::*;
pub const S: ::c::Item = ::c::Item;
}
fn f12() {
check(m1::S{}); //~ ERROR c::Item
check(m1::S); //~ ERROR unresolved name
check(m2::S{}); //~ ERROR c::S
check(m2::S); //~ ERROR c::Item
}
fn xf12() {
check(xm1::S{}); //~ ERROR c::Item
check(xm1::S); //~ ERROR unresolved name
check(xm2::S{}); //~ ERROR c::S
check(xm2::S); //~ ERROR c::Item
}
mod m3 {
pub use ::proxy::*;
pub type TS = ::c::Item;
}
mod m4 {
pub use ::proxy::*;
pub const TS: ::c::Item = ::c::Item;
}
fn f34() {
check(m3::TS{}); //~ ERROR c::Item
check(m3::TS); //~ ERROR c::TS
check(m4::TS{}); //~ ERROR c::TS
check(m4::TS); //~ ERROR c::Item
}
fn xf34() {
check(xm3::TS{}); //~ ERROR c::Item
check(xm3::TS); //~ ERROR c::TS
check(xm4::TS{}); //~ ERROR c::TS
check(xm4::TS); //~ ERROR c::Item
}
mod m5 {
pub use ::proxy::*;
pub type US = ::c::Item;
}
mod m6 {
pub use ::proxy::*;
pub const US: ::c::Item = ::c::Item;
}
fn f56() {
check(m5::US{}); //~ ERROR c::Item
check(m5::US); //~ ERROR c::US
check(m6::US{}); //~ ERROR c::US
check(m6::US); //~ ERROR c::Item
}
fn xf56() {
check(xm5::US{}); //~ ERROR c::Item
check(xm5::US); //~ ERROR c::US
check(xm6::US{}); //~ ERROR c::US
check(xm6::US); //~ ERROR c::Item
}
mod m7 {
pub use ::proxy::*;
pub type V = ::c::Item;
}
mod m8 {
pub use ::proxy::*;
pub const V: ::c::Item = ::c::Item;
}
fn f78() {
check(m7::V{}); //~ ERROR c::Item
check(m7::V); //~ ERROR name of a struct or struct variant
check(m8::V{}); //~ ERROR c::E
check(m8::V); //~ ERROR c::Item
}
fn xf78() {
check(xm7::V{}); //~ ERROR c::Item
check(xm7::V); //~ ERROR name of a struct or struct variant
check(xm8::V{}); //~ ERROR c::E
check(xm8::V); //~ ERROR c::Item
}
mod m9 {
pub use ::proxy::*;
pub type TV = ::c::Item;
}
mod mA {
pub use ::proxy::*;
pub const TV: ::c::Item = ::c::Item;
}
fn f9A() {
check(m9::TV{}); //~ ERROR c::Item
check(m9::TV); //~ ERROR c::E
check(mA::TV{}); //~ ERROR c::E
check(mA::TV); //~ ERROR c::Item
}
fn xf9A() {
check(xm9::TV{}); //~ ERROR c::Item
check(xm9::TV); //~ ERROR c::E
check(xmA::TV{}); //~ ERROR c::E
check(xmA::TV); //~ ERROR c::Item
}
mod mB {
pub use ::proxy::*;
pub type UV = ::c::Item;
}
mod mC {
pub use ::proxy::*;
pub const UV: ::c::Item = ::c::Item;
}
fn fBC() {
check(mB::UV{}); //~ ERROR c::Item
check(mB::UV); //~ ERROR c::E
check(mC::UV{}); //~ ERROR c::E
check(mC::UV); //~ ERROR c::Item
}
fn xfBC() {
check(xmB::UV{}); //~ ERROR c::Item
check(xmB::UV); //~ ERROR c::E
check(xmC::UV{}); //~ ERROR c::E
check(xmC::UV); //~ ERROR c::Item
}
fn main() {}

View file

@ -8,12 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// aux-build:namespace-mix-new.rs
// aux-build:namespace-mix.rs
#![feature(item_like_imports)]
extern crate namespace_mix_new;
use namespace_mix_new::*;
extern crate namespace_mix;
use namespace_mix::*;
mod c {
pub struct S {}

View file

@ -31,8 +31,7 @@ fn test1() {
fn test2() {
use bar::glob::foo;
//~^ ERROR unresolved import `bar::glob::foo` [E0432]
//~| no `foo` in `bar::glob`
//~^ ERROR `foo` is private
}
#[start] fn main(_: isize, _: *const *const u8) -> isize { 3 }

View file

@ -16,11 +16,11 @@ mod foo {
}
mod bar {
use foo::bar::f as g; //~ ERROR unresolved import
use foo::bar::f as g; //~ ERROR module `bar` is private
use foo as f;
pub use foo::*;
}
use bar::f::f; //~ ERROR unresolved import
use bar::f::f; //~ ERROR module `f` is private
fn main() {}

View file

@ -31,11 +31,11 @@ const XTuple: u8 = 0;
const XUnit: u8 = 0;
extern crate variant_namespacing;
pub use variant_namespacing::XE::*;
pub use variant_namespacing::XE::{XStruct, XTuple, XUnit};
//~^ ERROR `XStruct` has already been defined
//~| ERROR `XTuple` has already been defined
//~| ERROR `XUnit` has already been defined
pub use E::*;
pub use E::{Struct, Tuple, Unit};
//~^ ERROR `Struct` has already been defined
//~| ERROR `Tuple` has already been defined
//~| ERROR `Unit` has already been defined

View file

@ -10,7 +10,7 @@
// force-host
#![feature(plugin_registrar, rustc_private, item_like_imports)]
#![feature(plugin_registrar, rustc_private)]
extern crate syntax;
extern crate syntax_ext;

View file

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(item_like_imports)]
#![allow(unused)]
// Like other items, private imports can be imported and used non-lexically in paths.