Skip to content

Commit 79d9beb

Browse files
committed
Fix xcrate enum namespacing
Closes #19293
1 parent 48ca6d1 commit 79d9beb

13 files changed

+62
-22
lines changed

src/librustc/metadata/encoder.rs

-10
Original file line numberDiff line numberDiff line change
@@ -500,20 +500,10 @@ fn encode_reexported_static_methods(ecx: &EncodeContext,
500500
/// Iterates through "auxiliary node IDs", which are node IDs that describe
501501
/// top-level items that are sub-items of the given item. Specifically:
502502
///
503-
/// * For enums, iterates through the node IDs of the variants.
504-
///
505503
/// * For newtype structs, iterates through the node ID of the constructor.
506504
fn each_auxiliary_node_id(item: &ast::Item, callback: |NodeId| -> bool) -> bool {
507505
let mut continue_ = true;
508506
match item.node {
509-
ast::ItemEnum(ref enum_def, _) => {
510-
for variant in enum_def.variants.iter() {
511-
continue_ = callback(variant.node.id);
512-
if !continue_ {
513-
break
514-
}
515-
}
516-
}
517507
ast::ItemStruct(ref struct_def, _) => {
518508
// If this is a newtype struct, return the constructor.
519509
match struct_def.ctor_id {

src/librustc_llvm/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub use self::DiagnosticKind::*;
4545
pub use self::CallConv::*;
4646
pub use self::Visibility::*;
4747
pub use self::DiagnosticSeverity::*;
48+
pub use self::Linkage::*;
4849

4950
use std::c_str::ToCStr;
5051
use std::cell::RefCell;

src/test/auxiliary/issue-13872-2.rs

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

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

13-
pub use foo::B;
13+
pub use foo::A::B;

src/test/auxiliary/issue_19293.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub struct Foo (pub int);
12+
pub enum MyEnum {
13+
Foo(Foo),
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:namespaced_enums.rs
12+
extern crate namespaced_enums;
13+
14+
fn main() {
15+
let _ = namespaced_enums::A; //~ ERROR unresolved name
16+
let _ = namespaced_enums::B(10); //~ ERROR unresolved name
17+
let _ = namespaced_enums::C { a: 10 }; //~ ERROR does not name a structure
18+
}

src/test/compile-fail/unreachable-variant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
extern crate "unreachable-variant" as other;
1414

1515
fn main() {
16-
let _x = other::super_sekrit::baz; //~ ERROR is private
16+
let _x = other::super_sekrit::sooper_sekrit::baz; //~ ERROR is private
1717
}

src/test/compile-fail/xc-private-method2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ fn main() {
1616
let _ = xc_private_method_lib::Struct{ x: 10 }.meth_struct();
1717
//~^ ERROR method `meth_struct` is private
1818

19-
let _ = xc_private_method_lib::Variant1(20).meth_enum();
19+
let _ = xc_private_method_lib::Enum::Variant1(20).meth_enum();
2020
//~^ ERROR method `meth_enum` is private
2121
}

src/test/run-pass/issue-19293.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:issue_19293.rs
12+
extern crate issue_19293;
13+
use issue_19293::{Foo, MyEnum};
14+
15+
fn main() {
16+
MyEnum::Foo(Foo(5));
17+
}

src/test/run-pass/issue-2316-c.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ extern crate issue_2316_b;
1515
use issue_2316_b::cloth;
1616

1717
pub fn main() {
18-
let _c: cloth::fabric = cloth::calico;
18+
let _c: cloth::fabric = cloth::fabric::calico;
1919
}

src/test/run-pass/issue-8259.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
// aux-build:issue-8259.rs
1212

1313
extern crate "issue-8259" as other;
14-
static a: other::Foo<'static> = other::A;
14+
static a: other::Foo<'static> = other::Foo::A;
1515

1616
pub fn main() {}

src/test/run-pass/struct_variant_xc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// aux-build:struct_variant_xc_aux.rs
1212
extern crate struct_variant_xc_aux;
1313

14-
use struct_variant_xc_aux::StructVariant;
14+
use struct_variant_xc_aux::Enum::StructVariant;
1515

1616
pub fn main() {
1717
let _ = StructVariant { arg: 1 };

src/test/run-pass/struct_variant_xc_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// aux-build:struct_variant_xc_aux.rs
1212
extern crate struct_variant_xc_aux;
1313

14-
use struct_variant_xc_aux::{StructVariant, Variant};
14+
use struct_variant_xc_aux::Enum::{StructVariant, Variant};
1515

1616
pub fn main() {
1717
let arg = match (StructVariant { arg: 42 }) {

src/test/run-pass/xcrate-unit-struct.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
extern crate xcrate_unit_struct;
1313

1414
const s1: xcrate_unit_struct::Struct = xcrate_unit_struct::Struct;
15-
static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::UnitVariant;
15+
static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::Unit::UnitVariant;
1616
static s3: xcrate_unit_struct::Unit =
17-
xcrate_unit_struct::Argument(xcrate_unit_struct::Struct);
18-
static s4: xcrate_unit_struct::Unit = xcrate_unit_struct::Argument(s1);
17+
xcrate_unit_struct::Unit::Argument(xcrate_unit_struct::Struct);
18+
static s4: xcrate_unit_struct::Unit = xcrate_unit_struct::Unit::Argument(s1);
1919
static s5: xcrate_unit_struct::TupleStruct = xcrate_unit_struct::TupleStruct(20, "foo");
2020

2121
fn f1(_: xcrate_unit_struct::Struct) {}
@@ -24,8 +24,8 @@ fn f3(_: xcrate_unit_struct::TupleStruct) {}
2424

2525
pub fn main() {
2626
f1(xcrate_unit_struct::Struct);
27-
f2(xcrate_unit_struct::UnitVariant);
28-
f2(xcrate_unit_struct::Argument(xcrate_unit_struct::Struct));
27+
f2(xcrate_unit_struct::Unit::UnitVariant);
28+
f2(xcrate_unit_struct::Unit::Argument(xcrate_unit_struct::Struct));
2929
f3(xcrate_unit_struct::TupleStruct(10, "bar"));
3030

3131
f1(s1);

0 commit comments

Comments
 (0)