From dcf7ac6f9a84ae52b07f9d7310637c9f9d9815ce Mon Sep 17 00:00:00 2001 From: mitaa Date: Sat, 1 Aug 2015 19:41:01 +0200 Subject: [PATCH] Fix and add tests regarding extern crate paths --- src/test/compile-fail/issue-12997-2.rs | 2 +- src/test/compile-fail/issue-1920-1.rs | 22 +++++++++++++++++ src/test/compile-fail/issue-1920-2.rs | 20 ++++++++++++++++ src/test/compile-fail/issue-1920-3.rs | 24 +++++++++++++++++++ src/test/compile-fail/privacy5.rs | 18 +++++++------- src/test/compile-fail/struct-field-privacy.rs | 4 ++-- .../compile-fail/suggest-private-fields.rs | 4 ++-- 7 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 src/test/compile-fail/issue-1920-1.rs create mode 100644 src/test/compile-fail/issue-1920-2.rs create mode 100644 src/test/compile-fail/issue-1920-3.rs diff --git a/src/test/compile-fail/issue-12997-2.rs b/src/test/compile-fail/issue-12997-2.rs index 1cf534e7e41..8b467c2ba11 100644 --- a/src/test/compile-fail/issue-12997-2.rs +++ b/src/test/compile-fail/issue-12997-2.rs @@ -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 diff --git a/src/test/compile-fail/issue-1920-1.rs b/src/test/compile-fail/issue-1920-1.rs new file mode 100644 index 00000000000..c26c5ff8421 --- /dev/null +++ b/src/test/compile-fail/issue-1920-1.rs @@ -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 or the MIT license +// , 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() where T : Clone { } + +fn main() { + assert_clone::(); + //~^ ERROR the trait `foo::core::clone::Clone` is not implemented for the type `foo::core:: +} \ No newline at end of file diff --git a/src/test/compile-fail/issue-1920-2.rs b/src/test/compile-fail/issue-1920-2.rs new file mode 100644 index 00000000000..63cfcbdd8c7 --- /dev/null +++ b/src/test/compile-fail/issue-1920-2.rs @@ -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 or the MIT license +// , 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() where T : Clone { } + +fn main() { + assert_clone::(); + //~^ ERROR the trait `bar::clone::Clone` is not implemented for the type `bar::atomic:: +} \ No newline at end of file diff --git a/src/test/compile-fail/issue-1920-3.rs b/src/test/compile-fail/issue-1920-3.rs new file mode 100644 index 00000000000..619c8c3f3a4 --- /dev/null +++ b/src/test/compile-fail/issue-1920-3.rs @@ -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 or the MIT license +// , 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() where T : Clone { } + +fn main() { + assert_clone::(); + //~^ ERROR the trait `core::clone::Clone` is not implemented for the type `core::atomic:: +} \ No newline at end of file diff --git a/src/test/compile-fail/privacy5.rs b/src/test/compile-fail/privacy5.rs index 4ca37fc2ad2..83e13ff52f6 100644 --- a/src/test/compile-fail/privacy5.rs +++ b/src/test/compile-fail/privacy5.rs @@ -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; diff --git a/src/test/compile-fail/struct-field-privacy.rs b/src/test/compile-fail/struct-field-privacy.rs index a1b6b9a744c..aae09cc0eae 100644 --- a/src/test/compile-fail/struct-field-privacy.rs +++ b/src/test/compile-fail/struct-field-privacy.rs @@ -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() {} diff --git a/src/test/compile-fail/suggest-private-fields.rs b/src/test/compile-fail/suggest-private-fields.rs index f987257d4ee..8bc8a7a60bd 100644 --- a/src/test/compile-fail/suggest-private-fields.rs +++ b/src/test/compile-fail/suggest-private-fields.rs @@ -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 {