Skip to content

Commit dcf7ac6

Browse files
committed
Fix and add tests regarding extern crate paths
1 parent 2b41246 commit dcf7ac6

7 files changed

+80
-14
lines changed

src/test/compile-fail/issue-12997-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#[bench]
1616
fn bar(x: isize) { }
1717
//~^ ERROR mismatched types
18-
//~| expected `fn(&mut test::Bencher)`
18+
//~| expected `fn(&mut __test::test::Bencher)`
1919
//~| found `fn(isize) {bar}`
2020
//~| expected &-ptr
2121
//~| found isize

src/test/compile-fail/issue-1920-1.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2015 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+
//! Test that absolute path names are correct when a crate is not linked into the root namespace
12+
13+
mod foo {
14+
extern crate core;
15+
}
16+
17+
fn assert_clone<T>() where T : Clone { }
18+
19+
fn main() {
20+
assert_clone::<foo::core::atomic::AtomicBool>();
21+
//~^ ERROR the trait `foo::core::clone::Clone` is not implemented for the type `foo::core::
22+
}

src/test/compile-fail/issue-1920-2.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2015 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+
//! Test that when a crate is linked under another name that that name is used in global paths
12+
13+
extern crate core as bar;
14+
15+
fn assert_clone<T>() where T : Clone { }
16+
17+
fn main() {
18+
assert_clone::<bar::atomic::AtomicBool>();
19+
//~^ ERROR the trait `bar::clone::Clone` is not implemented for the type `bar::atomic::
20+
}

src/test/compile-fail/issue-1920-3.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2015 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+
//! Test that when a crate is linked multiple times that the shortest absolute path name is used
12+
13+
mod foo {
14+
extern crate core;
15+
}
16+
17+
extern crate core;
18+
19+
fn assert_clone<T>() where T : Clone { }
20+
21+
fn main() {
22+
assert_clone::<foo::core::atomic::AtomicBool>();
23+
//~^ ERROR the trait `core::clone::Clone` is not implemented for the type `core::atomic::
24+
}

src/test/compile-fail/privacy5.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,30 @@ fn xcrate() {
101101
let c = other::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor
102102
let d = other::D(4);
103103

104-
let other::A(()) = a; //~ ERROR: field #1 of struct `privacy_tuple_struct::A` is private
104+
let other::A(()) = a; //~ ERROR: field #1 of struct `other::A` is private
105105
let other::A(_) = a;
106106
match a { other::A(()) => {} }
107-
//~^ ERROR: field #1 of struct `privacy_tuple_struct::A` is private
107+
//~^ ERROR: field #1 of struct `other::A` is private
108108
match a { other::A(_) => {} }
109109

110110
let other::B(_) = b;
111-
let other::B(_b) = b; //~ ERROR: field #1 of struct `privacy_tuple_struct::B` is private
111+
let other::B(_b) = b; //~ ERROR: field #1 of struct `other::B` is private
112112
match b { other::B(_) => {} }
113113
match b { other::B(_b) => {} }
114-
//~^ ERROR: field #1 of struct `privacy_tuple_struct::B` is private
114+
//~^ ERROR: field #1 of struct `other::B` is private
115115
match b { other::B(1) => {} other::B(_) => {} }
116-
//~^ ERROR: field #1 of struct `privacy_tuple_struct::B` is private
116+
//~^ ERROR: field #1 of struct `other::B` is private
117117

118118
let other::C(_, _) = c;
119119
let other::C(_a, _) = c;
120-
let other::C(_, _b) = c; //~ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
121-
let other::C(_a, _b) = c; //~ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
120+
let other::C(_, _b) = c; //~ ERROR: field #2 of struct `other::C` is private
121+
let other::C(_a, _b) = c; //~ ERROR: field #2 of struct `other::C` is private
122122
match c { other::C(_, _) => {} }
123123
match c { other::C(_a, _) => {} }
124124
match c { other::C(_, _b) => {} }
125-
//~^ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
125+
//~^ ERROR: field #2 of struct `other::C` is private
126126
match c { other::C(_a, _b) => {} }
127-
//~^ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
127+
//~^ ERROR: field #2 of struct `other::C` is private
128128

129129
let other::D(_) = d;
130130
let other::D(_d) = d;

src/test/compile-fail/struct-field-privacy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ fn test(a: A, b: inner::A, c: inner::B, d: xc::A, e: xc::B) {
3737
c.a;
3838
c.b; //~ ERROR: field `b` of struct `inner::B` is private
3939

40-
d.a; //~ ERROR: field `a` of struct `struct_field_privacy::A` is private
40+
d.a; //~ ERROR: field `a` of struct `xc::A` is private
4141
d.b;
4242

4343
e.a;
44-
e.b; //~ ERROR: field `b` of struct `struct_field_privacy::B` is private
44+
e.b; //~ ERROR: field `b` of struct `xc::B` is private
4545
}
4646

4747
fn main() {}

src/test/compile-fail/suggest-private-fields.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ struct A {
2222
fn main () {
2323
// external crate struct
2424
let k = B {
25-
aa: 20, //~ ERROR structure `struct_field_privacy::B` has no field named `aa`
25+
aa: 20, //~ ERROR structure `xc::B` has no field named `aa`
2626
//~^ HELP did you mean `a`?
27-
bb: 20, //~ ERROR structure `struct_field_privacy::B` has no field named `bb`
27+
bb: 20, //~ ERROR structure `xc::B` has no field named `bb`
2828
};
2929
// local crate struct
3030
let l = A {

0 commit comments

Comments
 (0)