Skip to content

Fix xcrate enum namespacing #19317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
@@ -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 {
1 change: 1 addition & 0 deletions src/librustc_llvm/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion src/test/auxiliary/issue-13872-2.rs
Original file line number Diff line number Diff line change
@@ -10,4 +10,4 @@

extern crate "issue-13872-1" as foo;

pub use foo::B;
pub use foo::A::B;
14 changes: 14 additions & 0 deletions src/test/auxiliary/issue_19293.rs
Original file line number Diff line number Diff line change
@@ -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),
}
18 changes: 18 additions & 0 deletions src/test/compile-fail/enums-are-namespaced-xc.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/unreachable-variant.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/xc-private-method2.rs
Original file line number Diff line number Diff line change
@@ -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
}
17 changes: 17 additions & 0 deletions src/test/run-pass/issue-19293.rs
Original file line number Diff line number Diff line change
@@ -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));
}
2 changes: 1 addition & 1 deletion src/test/run-pass/issue-2316-c.rs
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion src/test/run-pass/issue-8259.rs
Original file line number Diff line number Diff line change
@@ -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() {}
2 changes: 1 addition & 1 deletion src/test/run-pass/struct_variant_xc.rs
Original file line number Diff line number Diff line change
@@ -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 };
2 changes: 1 addition & 1 deletion src/test/run-pass/struct_variant_xc_match.rs
Original file line number Diff line number Diff line change
@@ -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 }) {
10 changes: 5 additions & 5 deletions src/test/run-pass/xcrate-unit-struct.rs
Original file line number Diff line number Diff line change
@@ -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);