Fix and add tests regarding extern crate paths
This commit is contained in:
parent
2b4124684e
commit
dcf7ac6f9a
@ -15,7 +15,7 @@
|
||||
#[bench]
|
||||
fn bar(x: isize) { }
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected `fn(&mut test::Bencher)`
|
||||
//~| expected `fn(&mut __test::test::Bencher)`
|
||||
//~| found `fn(isize) {bar}`
|
||||
//~| expected &-ptr
|
||||
//~| found isize
|
||||
|
22
src/test/compile-fail/issue-1920-1.rs
Normal file
22
src/test/compile-fail/issue-1920-1.rs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2015 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 absolute path names are correct when a crate is not linked into the root namespace
|
||||
|
||||
mod foo {
|
||||
extern crate core;
|
||||
}
|
||||
|
||||
fn assert_clone<T>() where T : Clone { }
|
||||
|
||||
fn main() {
|
||||
assert_clone::<foo::core::atomic::AtomicBool>();
|
||||
//~^ ERROR the trait `foo::core::clone::Clone` is not implemented for the type `foo::core::
|
||||
}
|
20
src/test/compile-fail/issue-1920-2.rs
Normal file
20
src/test/compile-fail/issue-1920-2.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2015 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 when a crate is linked under another name that that name is used in global paths
|
||||
|
||||
extern crate core as bar;
|
||||
|
||||
fn assert_clone<T>() where T : Clone { }
|
||||
|
||||
fn main() {
|
||||
assert_clone::<bar::atomic::AtomicBool>();
|
||||
//~^ ERROR the trait `bar::clone::Clone` is not implemented for the type `bar::atomic::
|
||||
}
|
24
src/test/compile-fail/issue-1920-3.rs
Normal file
24
src/test/compile-fail/issue-1920-3.rs
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2015 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 when a crate is linked multiple times that the shortest absolute path name is used
|
||||
|
||||
mod foo {
|
||||
extern crate core;
|
||||
}
|
||||
|
||||
extern crate core;
|
||||
|
||||
fn assert_clone<T>() where T : Clone { }
|
||||
|
||||
fn main() {
|
||||
assert_clone::<foo::core::atomic::AtomicBool>();
|
||||
//~^ ERROR the trait `core::clone::Clone` is not implemented for the type `core::atomic::
|
||||
}
|
@ -101,30 +101,30 @@ fn xcrate() {
|
||||
let c = other::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor
|
||||
let d = other::D(4);
|
||||
|
||||
let other::A(()) = a; //~ ERROR: field #1 of struct `privacy_tuple_struct::A` is private
|
||||
let other::A(()) = a; //~ ERROR: field #1 of struct `other::A` is private
|
||||
let other::A(_) = a;
|
||||
match a { other::A(()) => {} }
|
||||
//~^ ERROR: field #1 of struct `privacy_tuple_struct::A` is private
|
||||
//~^ ERROR: field #1 of struct `other::A` is private
|
||||
match a { other::A(_) => {} }
|
||||
|
||||
let other::B(_) = b;
|
||||
let other::B(_b) = b; //~ ERROR: field #1 of struct `privacy_tuple_struct::B` is private
|
||||
let other::B(_b) = b; //~ ERROR: field #1 of struct `other::B` is private
|
||||
match b { other::B(_) => {} }
|
||||
match b { other::B(_b) => {} }
|
||||
//~^ ERROR: field #1 of struct `privacy_tuple_struct::B` is private
|
||||
//~^ ERROR: field #1 of struct `other::B` is private
|
||||
match b { other::B(1) => {} other::B(_) => {} }
|
||||
//~^ ERROR: field #1 of struct `privacy_tuple_struct::B` is private
|
||||
//~^ ERROR: field #1 of struct `other::B` is private
|
||||
|
||||
let other::C(_, _) = c;
|
||||
let other::C(_a, _) = c;
|
||||
let other::C(_, _b) = c; //~ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
|
||||
let other::C(_a, _b) = c; //~ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
|
||||
let other::C(_, _b) = c; //~ ERROR: field #2 of struct `other::C` is private
|
||||
let other::C(_a, _b) = c; //~ ERROR: field #2 of struct `other::C` is private
|
||||
match c { other::C(_, _) => {} }
|
||||
match c { other::C(_a, _) => {} }
|
||||
match c { other::C(_, _b) => {} }
|
||||
//~^ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
|
||||
//~^ ERROR: field #2 of struct `other::C` is private
|
||||
match c { other::C(_a, _b) => {} }
|
||||
//~^ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
|
||||
//~^ ERROR: field #2 of struct `other::C` is private
|
||||
|
||||
let other::D(_) = d;
|
||||
let other::D(_d) = d;
|
||||
|
@ -37,11 +37,11 @@ fn test(a: A, b: inner::A, c: inner::B, d: xc::A, e: xc::B) {
|
||||
c.a;
|
||||
c.b; //~ ERROR: field `b` of struct `inner::B` is private
|
||||
|
||||
d.a; //~ ERROR: field `a` of struct `struct_field_privacy::A` is private
|
||||
d.a; //~ ERROR: field `a` of struct `xc::A` is private
|
||||
d.b;
|
||||
|
||||
e.a;
|
||||
e.b; //~ ERROR: field `b` of struct `struct_field_privacy::B` is private
|
||||
e.b; //~ ERROR: field `b` of struct `xc::B` is private
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -22,9 +22,9 @@ struct A {
|
||||
fn main () {
|
||||
// external crate struct
|
||||
let k = B {
|
||||
aa: 20, //~ ERROR structure `struct_field_privacy::B` has no field named `aa`
|
||||
aa: 20, //~ ERROR structure `xc::B` has no field named `aa`
|
||||
//~^ HELP did you mean `a`?
|
||||
bb: 20, //~ ERROR structure `struct_field_privacy::B` has no field named `bb`
|
||||
bb: 20, //~ ERROR structure `xc::B` has no field named `bb`
|
||||
};
|
||||
// local crate struct
|
||||
let l = A {
|
||||
|
Loading…
Reference in New Issue
Block a user