rollup merge of #19317: sfackler/xcrate-namespace

The chunk of code in encoder.rs was at one point deleted, but must have come back in a rebase or something :(

Closes #19293
This commit is contained in:
Alex Crichton 2014-11-26 09:46:59 -08:00
commit 99338cf8f6
13 changed files with 62 additions and 22 deletions

View File

@ -500,20 +500,10 @@ fn encode_reexported_static_methods(ecx: &EncodeContext,
/// Iterates through "auxiliary node IDs", which are node IDs that describe
/// top-level items that are sub-items of the given item. Specifically:
///
/// * For enums, iterates through the node IDs of the variants.
///
/// * For newtype structs, iterates through the node ID of the constructor.
fn each_auxiliary_node_id(item: &ast::Item, callback: |NodeId| -> bool) -> bool {
let mut continue_ = true;
match item.node {
ast::ItemEnum(ref enum_def, _) => {
for variant in enum_def.variants.iter() {
continue_ = callback(variant.node.id);
if !continue_ {
break
}
}
}
ast::ItemStruct(ref struct_def, _) => {
// If this is a newtype struct, return the constructor.
match struct_def.ctor_id {

View File

@ -45,6 +45,7 @@ pub use self::DiagnosticKind::*;
pub use self::CallConv::*;
pub use self::Visibility::*;
pub use self::DiagnosticSeverity::*;
pub use self::Linkage::*;
use std::c_str::ToCStr;
use std::cell::RefCell;

View File

@ -10,4 +10,4 @@
extern crate "issue-13872-1" as foo;
pub use foo::B;
pub use foo::A::B;

View File

@ -0,0 +1,14 @@
// 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 struct Foo (pub int);
pub enum MyEnum {
Foo(Foo),
}

View File

@ -0,0 +1,18 @@
// 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:namespaced_enums.rs
extern crate namespaced_enums;
fn main() {
let _ = namespaced_enums::A; //~ ERROR unresolved name
let _ = namespaced_enums::B(10); //~ ERROR unresolved name
let _ = namespaced_enums::C { a: 10 }; //~ ERROR does not name a structure
}

View File

@ -13,5 +13,5 @@
extern crate "unreachable-variant" as other;
fn main() {
let _x = other::super_sekrit::baz; //~ ERROR is private
let _x = other::super_sekrit::sooper_sekrit::baz; //~ ERROR is private
}

View File

@ -16,6 +16,6 @@ fn main() {
let _ = xc_private_method_lib::Struct{ x: 10 }.meth_struct();
//~^ ERROR method `meth_struct` is private
let _ = xc_private_method_lib::Variant1(20).meth_enum();
let _ = xc_private_method_lib::Enum::Variant1(20).meth_enum();
//~^ ERROR method `meth_enum` is private
}

View File

@ -0,0 +1,17 @@
// 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_19293.rs
extern crate issue_19293;
use issue_19293::{Foo, MyEnum};
fn main() {
MyEnum::Foo(Foo(5));
}

View File

@ -15,5 +15,5 @@ extern crate issue_2316_b;
use issue_2316_b::cloth;
pub fn main() {
let _c: cloth::fabric = cloth::calico;
let _c: cloth::fabric = cloth::fabric::calico;
}

View File

@ -11,6 +11,6 @@
// aux-build:issue-8259.rs
extern crate "issue-8259" as other;
static a: other::Foo<'static> = other::A;
static a: other::Foo<'static> = other::Foo::A;
pub fn main() {}

View File

@ -11,7 +11,7 @@
// aux-build:struct_variant_xc_aux.rs
extern crate struct_variant_xc_aux;
use struct_variant_xc_aux::StructVariant;
use struct_variant_xc_aux::Enum::StructVariant;
pub fn main() {
let _ = StructVariant { arg: 1 };

View File

@ -11,7 +11,7 @@
// aux-build:struct_variant_xc_aux.rs
extern crate struct_variant_xc_aux;
use struct_variant_xc_aux::{StructVariant, Variant};
use struct_variant_xc_aux::Enum::{StructVariant, Variant};
pub fn main() {
let arg = match (StructVariant { arg: 42 }) {

View File

@ -12,10 +12,10 @@
extern crate xcrate_unit_struct;
const s1: xcrate_unit_struct::Struct = xcrate_unit_struct::Struct;
static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::UnitVariant;
static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::Unit::UnitVariant;
static s3: xcrate_unit_struct::Unit =
xcrate_unit_struct::Argument(xcrate_unit_struct::Struct);
static s4: xcrate_unit_struct::Unit = xcrate_unit_struct::Argument(s1);
xcrate_unit_struct::Unit::Argument(xcrate_unit_struct::Struct);
static s4: xcrate_unit_struct::Unit = xcrate_unit_struct::Unit::Argument(s1);
static s5: xcrate_unit_struct::TupleStruct = xcrate_unit_struct::TupleStruct(20, "foo");
fn f1(_: xcrate_unit_struct::Struct) {}
@ -24,8 +24,8 @@ fn f3(_: xcrate_unit_struct::TupleStruct) {}
pub fn main() {
f1(xcrate_unit_struct::Struct);
f2(xcrate_unit_struct::UnitVariant);
f2(xcrate_unit_struct::Argument(xcrate_unit_struct::Struct));
f2(xcrate_unit_struct::Unit::UnitVariant);
f2(xcrate_unit_struct::Unit::Argument(xcrate_unit_struct::Struct));
f3(xcrate_unit_struct::TupleStruct(10, "bar"));
f1(s1);