diff options
| author | bors <bors@rust-lang.org> | 2016-03-25 18:09:28 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-03-25 18:09:28 -0700 |
| commit | 8d2d2be6c61c17da8027a72da91f87a0e2487f74 (patch) | |
| tree | d48967badd66eabf6c53f32d0250ca1eba94ddf7 /src/test | |
| parent | a1e29daf1a9ca4e26719887b0c934de5d1695031 (diff) | |
| parent | 1ea93c2a6388b7dcddf1ae89105a9f6f2e1da9f1 (diff) | |
| download | rust-8d2d2be6c61c17da8027a72da91f87a0e2487f74.tar.gz rust-8d2d2be6c61c17da8027a72da91f87a0e2487f74.zip | |
Auto merge of #32293 - nikomatsakis:incr-comp-def-path-munging, r=alexcrichton
Revamp symbol names for impls (and make them deterministic, etc) This builds on @michaelwoerister's epic PR #31539 (note that his PR never landed, so I just incorporated it into this one). The main change here is that we remove the "name" from `DefPathData` for impls, since that name is synthetic and not sufficiently predictable for incr comp. However, just doing that would cause bad symbol names since those are based on the `DefPath`. Therefore, I introduce a new mechanism for getting symbol names (and also paths for user display) called `item_path`. This is kind of simplistic for now (based on strings) but I expect to expand it later to support richer types, hopefully generating C++-mangled names that gdb etc can understand. Along the way I cleaned up how we track the path that leads to an extern crate. There is still some cleanup left undone here. Notably, I didn't remove the impl names altogether -- that would probably make sense. I also didn't try to remove the `item_symbols` vector. Mostly I want to unblock my other incr. comp. work. =) r? @eddyb cc @eddyb @alexcrichton @michaelwoerister
Diffstat (limited to 'src/test')
47 files changed, 440 insertions, 119 deletions
diff --git a/src/test/auxiliary/inline-default-methods.rs b/src/test/auxiliary/inline-default-methods.rs index 5f1bd7ab522..e21e6ad2043 100644 --- a/src/test/auxiliary/inline-default-methods.rs +++ b/src/test/auxiliary/inline-default-methods.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Cmetadata=aux + pub trait Foo { fn bar(&self); fn foo(&mut self) {} diff --git a/src/test/auxiliary/issue-13698.rs b/src/test/auxiliary/issue-13698.rs index 0bb2133c833..ecddfe99b3b 100644 --- a/src/test/auxiliary/issue-13698.rs +++ b/src/test/auxiliary/issue-13698.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Cmetadata=aux + pub trait Foo { #[doc(hidden)] fn foo(&self) {} diff --git a/src/test/auxiliary/issue-15318.rs b/src/test/auxiliary/issue-15318.rs index 9e42dbfbc6b..145b4df6299 100644 --- a/src/test/auxiliary/issue-15318.rs +++ b/src/test/auxiliary/issue-15318.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Cmetadata=aux + #![doc(html_root_url = "http://example.com/")] /// dox diff --git a/src/test/auxiliary/issue-17476.rs b/src/test/auxiliary/issue-17476.rs index d3a86035742..644d1634e9d 100644 --- a/src/test/auxiliary/issue-17476.rs +++ b/src/test/auxiliary/issue-17476.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Cmetadata=aux #![doc(html_root_url = "http://example.com")] diff --git a/src/test/auxiliary/issue-17718.rs b/src/test/auxiliary/issue-17718-aux.rs index 373fc042175..373fc042175 100644 --- a/src/test/auxiliary/issue-17718.rs +++ b/src/test/auxiliary/issue-17718-aux.rs diff --git a/src/test/auxiliary/issue-19190-3.rs b/src/test/auxiliary/issue-19190-3.rs index 7403bcf4afb..2c9271202a6 100644 --- a/src/test/auxiliary/issue-19190-3.rs +++ b/src/test/auxiliary/issue-19190-3.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Cmetadata=aux + use std::ops::Deref; pub struct Foo; diff --git a/src/test/auxiliary/issue-20646.rs b/src/test/auxiliary/issue-20646.rs index 150d8018f08..815b78a91d9 100644 --- a/src/test/auxiliary/issue-20646.rs +++ b/src/test/auxiliary/issue-20646.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Cmetadata=aux + pub trait Trait { type Output; } diff --git a/src/test/auxiliary/issue-20727.rs b/src/test/auxiliary/issue-20727.rs index aea8b429d9f..2ec761fad96 100644 --- a/src/test/auxiliary/issue-20727.rs +++ b/src/test/auxiliary/issue-20727.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Cmetadata=aux + pub trait Deref { type Target: ?Sized; diff --git a/src/test/auxiliary/issue-21092.rs b/src/test/auxiliary/issue-21092.rs index 6d6046cc7bf..e906311e3ae 100644 --- a/src/test/auxiliary/issue-21092.rs +++ b/src/test/auxiliary/issue-21092.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Cmetadata=aux + pub trait Foo { type Bar; fn foo(&self) {} diff --git a/src/test/auxiliary/issue-21801.rs b/src/test/auxiliary/issue-21801.rs index ada6c692502..f618edec598 100644 --- a/src/test/auxiliary/issue-21801.rs +++ b/src/test/auxiliary/issue-21801.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Cmetadata=aux + pub struct Foo; impl Foo { diff --git a/src/test/auxiliary/issue-22025.rs b/src/test/auxiliary/issue-22025.rs index 554b580ae2b..35a37e27d91 100644 --- a/src/test/auxiliary/issue-22025.rs +++ b/src/test/auxiliary/issue-22025.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Cmetadata=aux + pub mod foo { pub trait Foo {} diff --git a/src/test/auxiliary/issue-27362.rs b/src/test/auxiliary/issue-27362.rs index e551d623ae7..25de698cad1 100644 --- a/src/test/auxiliary/issue-27362.rs +++ b/src/test/auxiliary/issue-27362.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Cmetadata=aux + #![feature(const_fn)] pub const fn foo() {} diff --git a/src/test/auxiliary/issue-29584.rs b/src/test/auxiliary/issue-29584.rs index 4a9e6126fc6..63c79f875ef 100644 --- a/src/test/auxiliary/issue-29584.rs +++ b/src/test/auxiliary/issue-29584.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Cmetadata=aux + pub struct Foo; #[doc(hidden)] diff --git a/src/test/auxiliary/typeid-intrinsic.rs b/src/test/auxiliary/typeid-intrinsic-aux1.rs index 388d3238d42..388d3238d42 100644 --- a/src/test/auxiliary/typeid-intrinsic.rs +++ b/src/test/auxiliary/typeid-intrinsic-aux1.rs diff --git a/src/test/auxiliary/typeid-intrinsic2.rs b/src/test/auxiliary/typeid-intrinsic-aux2.rs index 3ad307fd3b5..3ad307fd3b5 100644 --- a/src/test/auxiliary/typeid-intrinsic2.rs +++ b/src/test/auxiliary/typeid-intrinsic-aux2.rs diff --git a/src/test/codegen-units/cross-crate-closures.rs b/src/test/codegen-units/cross-crate-closures.rs index 32b07d42fec..30f3ef12d07 100644 --- a/src/test/codegen-units/cross-crate-closures.rs +++ b/src/test/codegen-units/cross-crate-closures.rs @@ -19,12 +19,12 @@ extern crate cgu_extern_closures; //~ TRANS_ITEM fn cross_crate_closures::main[0] fn main() { - //~ TRANS_ITEM fn cgu_extern_closures[0]::inlined_fn[0] - //~ TRANS_ITEM fn cgu_extern_closures[0]::inlined_fn[0]::{{closure}}[0] + //~ TRANS_ITEM fn cgu_extern_closures::inlined_fn[0] + //~ TRANS_ITEM fn cgu_extern_closures::inlined_fn[0]::{{closure}}[0] let _ = cgu_extern_closures::inlined_fn(1, 2); - //~ TRANS_ITEM fn cgu_extern_closures[0]::inlined_fn_generic[0]<i32> - //~ TRANS_ITEM fn cgu_extern_closures[0]::inlined_fn_generic[0]::{{closure}}[0]<i32> + //~ TRANS_ITEM fn cgu_extern_closures::inlined_fn_generic[0]<i32> + //~ TRANS_ITEM fn cgu_extern_closures::inlined_fn_generic[0]::{{closure}}[0]<i32> let _ = cgu_extern_closures::inlined_fn_generic(3, 4, 5i32); // Nothing should be generated for this call, we just link to the instance instance diff --git a/src/test/codegen-units/cross-crate-generic-functions.rs b/src/test/codegen-units/cross-crate-generic-functions.rs index 82d940a1548..ada1234b852 100644 --- a/src/test/codegen-units/cross-crate-generic-functions.rs +++ b/src/test/codegen-units/cross-crate-generic-functions.rs @@ -19,12 +19,12 @@ extern crate cgu_generic_function; //~ TRANS_ITEM fn cross_crate_generic_functions::main[0] fn main() { - //~ TRANS_ITEM fn cgu_generic_function[0]::bar[0]<u32> - //~ TRANS_ITEM fn cgu_generic_function[0]::foo[0]<u32> + //~ TRANS_ITEM fn cgu_generic_function::bar[0]<u32> + //~ TRANS_ITEM fn cgu_generic_function::foo[0]<u32> let _ = cgu_generic_function::foo(1u32); - //~ TRANS_ITEM fn cgu_generic_function[0]::bar[0]<u64> - //~ TRANS_ITEM fn cgu_generic_function[0]::foo[0]<u64> + //~ TRANS_ITEM fn cgu_generic_function::bar[0]<u64> + //~ TRANS_ITEM fn cgu_generic_function::foo[0]<u64> let _ = cgu_generic_function::foo(2u64); // This should not introduce a codegen item diff --git a/src/test/codegen-units/cross-crate-trait-method.rs b/src/test/codegen-units/cross-crate-trait-method.rs index aa1f6b06c81..9f29a90bffb 100644 --- a/src/test/codegen-units/cross-crate-trait-method.rs +++ b/src/test/codegen-units/cross-crate-trait-method.rs @@ -29,31 +29,31 @@ fn main() // Currently, no object code is generated for trait methods with default // implemenations, unless they are actually called from somewhere. Therefore // we cannot import the implementations and have to create our own inline. - //~ TRANS_ITEM fn cgu_export_trait_method[0]::Trait[0]::with_default_impl[0]<u32> + //~ TRANS_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl[0]<u32> let _ = Trait::with_default_impl(0u32); - //~ TRANS_ITEM fn cgu_export_trait_method[0]::Trait[0]::with_default_impl[0]<char> + //~ TRANS_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl[0]<char> let _ = Trait::with_default_impl('c'); - //~ TRANS_ITEM fn cgu_export_trait_method[0]::Trait[0]::with_default_impl_generic[0]<u32, &str> + //~ TRANS_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl_generic[0]<u32, &str> let _ = Trait::with_default_impl_generic(0u32, "abc"); - //~ TRANS_ITEM fn cgu_export_trait_method[0]::Trait[0]::with_default_impl_generic[0]<u32, bool> + //~ TRANS_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl_generic[0]<u32, bool> let _ = Trait::with_default_impl_generic(0u32, false); - //~ TRANS_ITEM fn cgu_export_trait_method[0]::Trait[0]::with_default_impl_generic[0]<char, i16> + //~ TRANS_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl_generic[0]<char, i16> let _ = Trait::with_default_impl_generic('x', 1i16); - //~ TRANS_ITEM fn cgu_export_trait_method[0]::Trait[0]::with_default_impl_generic[0]<char, i32> + //~ TRANS_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl_generic[0]<char, i32> let _ = Trait::with_default_impl_generic('y', 0i32); - //~ TRANS_ITEM fn cgu_export_trait_method[0]::u32.Trait[0]::without_default_impl_generic[0]<char> + //~ TRANS_ITEM fn cgu_export_trait_method::{{impl}}[1]::without_default_impl_generic[0]<char> let _: (u32, char) = Trait::without_default_impl_generic('c'); - //~ TRANS_ITEM fn cgu_export_trait_method[0]::u32.Trait[0]::without_default_impl_generic[0]<bool> + //~ TRANS_ITEM fn cgu_export_trait_method::{{impl}}[1]::without_default_impl_generic[0]<bool> let _: (u32, bool) = Trait::without_default_impl_generic(false); - //~ TRANS_ITEM fn cgu_export_trait_method[0]::char.Trait[0]::without_default_impl_generic[0]<char> + //~ TRANS_ITEM fn cgu_export_trait_method::{{impl}}[0]::without_default_impl_generic[0]<char> let _: (char, char) = Trait::without_default_impl_generic('c'); - //~ TRANS_ITEM fn cgu_export_trait_method[0]::char.Trait[0]::without_default_impl_generic[0]<bool> + //~ TRANS_ITEM fn cgu_export_trait_method::{{impl}}[0]::without_default_impl_generic[0]<bool> let _: (char, bool) = Trait::without_default_impl_generic(false); } diff --git a/src/test/codegen-units/generic-drop-glue.rs b/src/test/codegen-units/generic-drop-glue.rs index f89d6e61bc5..476c84044e6 100644 --- a/src/test/codegen-units/generic-drop-glue.rs +++ b/src/test/codegen-units/generic-drop-glue.rs @@ -49,17 +49,17 @@ struct NonGenericWithDrop(i32); impl Drop for NonGenericWithDrop { fn drop(&mut self) {} -//~ TRANS_ITEM fn generic_drop_glue::NonGenericWithDrop.Drop[0]::drop[0] +//~ TRANS_ITEM fn generic_drop_glue::{{impl}}[2]::drop[0] } //~ TRANS_ITEM fn generic_drop_glue::main[0] fn main() { //~ TRANS_ITEM drop-glue generic_drop_glue::StructWithDrop[0]<i8, char> - //~ TRANS_ITEM fn generic_drop_glue::StructWithDrop<T1, T2>.Drop[0]::drop[0]<i8, char> + //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[0]::drop[0]<i8, char> let _ = StructWithDrop { x: 0i8, y: 'a' }.x; //~ TRANS_ITEM drop-glue generic_drop_glue::StructWithDrop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]> - //~ TRANS_ITEM fn generic_drop_glue::StructWithDrop<T1, T2>.Drop[0]::drop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]> + //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[0]::drop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]> let _ = StructWithDrop { x: "&str", y: NonGenericNoDrop(0) }.y; // Should produce no drop glue @@ -71,14 +71,14 @@ fn main() { let _ = StructNoDrop { x: NonGenericWithDrop(0), y: 0f64 }.y; //~ TRANS_ITEM drop-glue generic_drop_glue::EnumWithDrop[0]<i32, i64> - //~ TRANS_ITEM fn generic_drop_glue::EnumWithDrop<T1, T2>.Drop[0]::drop[0]<i32, i64> + //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[1]::drop[0]<i32, i64> let _ = match EnumWithDrop::A::<i32, i64>(0) { EnumWithDrop::A(x) => x, EnumWithDrop::B(x) => x as i32 }; //~ TRANS_ITEM drop-glue generic_drop_glue::EnumWithDrop[0]<f64, f32> - //~ TRANS_ITEM fn generic_drop_glue::EnumWithDrop<T1, T2>.Drop[0]::drop[0]<f64, f32> + //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[1]::drop[0]<f64, f32> let _ = match EnumWithDrop::B::<f64, f32>(1.0) { EnumWithDrop::A(x) => x, EnumWithDrop::B(x) => x as f64 diff --git a/src/test/codegen-units/generic-impl.rs b/src/test/codegen-units/generic-impl.rs index 6e6bb5cbf53..a27515fd39b 100644 --- a/src/test/codegen-units/generic-impl.rs +++ b/src/test/codegen-units/generic-impl.rs @@ -40,11 +40,11 @@ pub struct LifeTimeOnly<'a> { impl<'a> LifeTimeOnly<'a> { - //~ TRANS_ITEM fn generic_impl::LifeTimeOnly<'a>[0]::foo[0] + //~ TRANS_ITEM fn generic_impl::{{impl}}[1]::foo[0] pub fn foo(&self) {} - //~ TRANS_ITEM fn generic_impl::LifeTimeOnly<'a>[0]::bar[0] + //~ TRANS_ITEM fn generic_impl::{{impl}}[1]::bar[0] pub fn bar(&'a self) {} - //~ TRANS_ITEM fn generic_impl::LifeTimeOnly<'a>[0]::baz[0] + //~ TRANS_ITEM fn generic_impl::{{impl}}[1]::baz[0] pub fn baz<'b>(&'b self) {} pub fn non_instantiated<T>(&self) {} @@ -53,27 +53,27 @@ impl<'a> LifeTimeOnly<'a> { //~ TRANS_ITEM fn generic_impl::main[0] fn main() { - //~ TRANS_ITEM fn generic_impl::Struct<T>[0]::new[0]<i32> + //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<i32> //~ TRANS_ITEM fn generic_impl::id[0]<i32> - //~ TRANS_ITEM fn generic_impl::Struct<T>[0]::get[0]<i32, i16> + //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::get[0]<i32, i16> let _ = Struct::new(0i32).get(0i16); - //~ TRANS_ITEM fn generic_impl::Struct<T>[0]::new[0]<i64> + //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<i64> //~ TRANS_ITEM fn generic_impl::id[0]<i64> - //~ TRANS_ITEM fn generic_impl::Struct<T>[0]::get[0]<i64, i16> + //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::get[0]<i64, i16> let _ = Struct::new(0i64).get(0i16); - //~ TRANS_ITEM fn generic_impl::Struct<T>[0]::new[0]<char> + //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<char> //~ TRANS_ITEM fn generic_impl::id[0]<char> - //~ TRANS_ITEM fn generic_impl::Struct<T>[0]::get[0]<char, i16> + //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::get[0]<char, i16> let _ = Struct::new('c').get(0i16); - //~ TRANS_ITEM fn generic_impl::Struct<T>[0]::new[0]<&str> + //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<&str> //~ TRANS_ITEM fn generic_impl::id[0]<&str> - //~ TRANS_ITEM fn generic_impl::Struct<T>[0]::get[0]<generic_impl::Struct[0]<&str>, i16> + //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::get[0]<generic_impl::Struct[0]<&str>, i16> let _ = Struct::new(Struct::new("str")).get(0i16); - //~ TRANS_ITEM fn generic_impl::Struct<T>[0]::new[0]<generic_impl::Struct[0]<&str>> + //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<generic_impl::Struct[0]<&str>> //~ TRANS_ITEM fn generic_impl::id[0]<generic_impl::Struct[0]<&str>> let _ = (Struct::new(Struct::new("str")).f)(Struct::new("str")); } diff --git a/src/test/codegen-units/impl-in-non-instantiated-generic.rs b/src/test/codegen-units/impl-in-non-instantiated-generic.rs index e17a1a7094f..a3bfa67e1ae 100644 --- a/src/test/codegen-units/impl-in-non-instantiated-generic.rs +++ b/src/test/codegen-units/impl-in-non-instantiated-generic.rs @@ -21,7 +21,7 @@ trait SomeTrait { // discovered. pub fn generic_function<T>(x: T) -> (T, i32) { impl SomeTrait for i64 { - //~ TRANS_ITEM fn impl_in_non_instantiated_generic::generic_function[0]::i64.SomeTrait[0]::foo[0] + //~ TRANS_ITEM fn impl_in_non_instantiated_generic::generic_function[0]::{{impl}}[0]::foo[0] fn foo(&self) {} } diff --git a/src/test/codegen-units/instantiation-through-vtable.rs b/src/test/codegen-units/instantiation-through-vtable.rs index 46587b2b0a1..b7725251220 100644 --- a/src/test/codegen-units/instantiation-through-vtable.rs +++ b/src/test/codegen-units/instantiation-through-vtable.rs @@ -31,12 +31,12 @@ impl<T> Trait for Struct<T> { fn main() { let s1 = Struct { _a: 0u32 }; - //~ TRANS_ITEM fn instantiation_through_vtable::Struct<T>.Trait[0]::foo[0]<u32> - //~ TRANS_ITEM fn instantiation_through_vtable::Struct<T>.Trait[0]::bar[0]<u32> + //~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::foo[0]<u32> + //~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::bar[0]<u32> let _ = &s1 as &Trait; let s1 = Struct { _a: 0u64 }; - //~ TRANS_ITEM fn instantiation_through_vtable::Struct<T>.Trait[0]::foo[0]<u64> - //~ TRANS_ITEM fn instantiation_through_vtable::Struct<T>.Trait[0]::bar[0]<u64> + //~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::foo[0]<u64> + //~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::bar[0]<u64> let _ = &s1 as &Trait; } diff --git a/src/test/codegen-units/non-generic-drop-glue.rs b/src/test/codegen-units/non-generic-drop-glue.rs index a82e85b7a53..bd8b0c605ae 100644 --- a/src/test/codegen-units/non-generic-drop-glue.rs +++ b/src/test/codegen-units/non-generic-drop-glue.rs @@ -19,7 +19,7 @@ struct StructWithDrop { } impl Drop for StructWithDrop { - //~ TRANS_ITEM fn non_generic_drop_glue::StructWithDrop.Drop[0]::drop[0] + //~ TRANS_ITEM fn non_generic_drop_glue::{{impl}}[0]::drop[0] fn drop(&mut self) {} } @@ -33,7 +33,7 @@ enum EnumWithDrop { } impl Drop for EnumWithDrop { - //~ TRANS_ITEM fn non_generic_drop_glue::EnumWithDrop.Drop[0]::drop[0] + //~ TRANS_ITEM fn non_generic_drop_glue::{{impl}}[1]::drop[0] fn drop(&mut self) {} } diff --git a/src/test/codegen-units/non-generic-functions.rs b/src/test/codegen-units/non-generic-functions.rs index 687ce7fa05c..4e2a7c85084 100644 --- a/src/test/codegen-units/non-generic-functions.rs +++ b/src/test/codegen-units/non-generic-functions.rs @@ -38,31 +38,31 @@ fn bar() { struct Struct { _x: i32 } impl Struct { - //~ TRANS_ITEM fn non_generic_functions::Struct[0]::foo[0] + //~ TRANS_ITEM fn non_generic_functions::{{impl}}[0]::foo[0] fn foo() { { - //~ TRANS_ITEM fn non_generic_functions::Struct[0]::foo[0]::foo[0] + //~ TRANS_ITEM fn non_generic_functions::{{impl}}[0]::foo[0]::foo[0] fn foo() {} foo(); } { - //~ TRANS_ITEM fn non_generic_functions::Struct[0]::foo[0]::foo[1] + //~ TRANS_ITEM fn non_generic_functions::{{impl}}[0]::foo[0]::foo[1] fn foo() {} foo(); } } - //~ TRANS_ITEM fn non_generic_functions::Struct[0]::bar[0] + //~ TRANS_ITEM fn non_generic_functions::{{impl}}[0]::bar[0] fn bar(&self) { { - //~ TRANS_ITEM fn non_generic_functions::Struct[0]::bar[0]::foo[0] + //~ TRANS_ITEM fn non_generic_functions::{{impl}}[0]::bar[0]::foo[0] fn foo() {} foo(); } { - //~ TRANS_ITEM fn non_generic_functions::Struct[0]::bar[0]::foo[1] + //~ TRANS_ITEM fn non_generic_functions::{{impl}}[0]::bar[0]::foo[1] fn foo() {} foo(); } diff --git a/src/test/codegen-units/overloaded-operators.rs b/src/test/codegen-units/overloaded-operators.rs index 134110222f3..c275eb954b0 100644 --- a/src/test/codegen-units/overloaded-operators.rs +++ b/src/test/codegen-units/overloaded-operators.rs @@ -23,7 +23,7 @@ pub struct Indexable { impl Index<usize> for Indexable { type Output = u8; - //~ TRANS_ITEM fn overloaded_operators::Indexable.Index<usize>[0]::index[0] + //~ TRANS_ITEM fn overloaded_operators::{{impl}}[0]::index[0] fn index(&self, index: usize) -> &Self::Output { if index >= 3 { &self.data[0] @@ -34,7 +34,7 @@ impl Index<usize> for Indexable { } impl IndexMut<usize> for Indexable { - //~ TRANS_ITEM fn overloaded_operators::Indexable.IndexMut<usize>[0]::index_mut[0] + //~ TRANS_ITEM fn overloaded_operators::{{impl}}[1]::index_mut[0] fn index_mut(&mut self, index: usize) -> &mut Self::Output { if index >= 3 { &mut self.data[0] @@ -45,8 +45,8 @@ impl IndexMut<usize> for Indexable { } -//~ TRANS_ITEM fn overloaded_operators::Equatable.::std::cmp::PartialEq[0]::eq[0] -//~ TRANS_ITEM fn overloaded_operators::Equatable.::std::cmp::PartialEq[0]::ne[0] +//~ TRANS_ITEM fn overloaded_operators::{{impl}}[2]::eq[0] +//~ TRANS_ITEM fn overloaded_operators::{{impl}}[2]::ne[0] #[derive(PartialEq)] pub struct Equatable(u32); @@ -54,7 +54,7 @@ pub struct Equatable(u32); impl Add<u32> for Equatable { type Output = u32; - //~ TRANS_ITEM fn overloaded_operators::Equatable.Add<u32>[0]::add[0] + //~ TRANS_ITEM fn overloaded_operators::{{impl}}[3]::add[0] fn add(self, rhs: u32) -> u32 { self.0 + rhs } @@ -63,7 +63,7 @@ impl Add<u32> for Equatable { impl Deref for Equatable { type Target = u32; - //~ TRANS_ITEM fn overloaded_operators::Equatable.Deref[0]::deref[0] + //~ TRANS_ITEM fn overloaded_operators::{{impl}}[4]::deref[0] fn deref(&self) -> &Self::Target { &self.0 } diff --git a/src/test/codegen-units/trait-implementations.rs b/src/test/codegen-units/trait-implementations.rs index 590859f15a3..2eb2212f0ca 100644 --- a/src/test/codegen-units/trait-implementations.rs +++ b/src/test/codegen-units/trait-implementations.rs @@ -20,7 +20,7 @@ pub trait SomeTrait { impl SomeTrait for i64 { - //~ TRANS_ITEM fn trait_implementations::i64.SomeTrait[0]::foo[0] + //~ TRANS_ITEM fn trait_implementations::{{impl}}[0]::foo[0] fn foo(&self) {} fn bar<T>(&self, _: T) {} @@ -28,7 +28,7 @@ impl SomeTrait for i64 { impl SomeTrait for i32 { - //~ TRANS_ITEM fn trait_implementations::i32.SomeTrait[0]::foo[0] + //~ TRANS_ITEM fn trait_implementations::{{impl}}[1]::foo[0] fn foo(&self) {} fn bar<T>(&self, _: T) {} @@ -42,7 +42,7 @@ pub trait SomeGenericTrait<T> { // Concrete impl of generic trait impl SomeGenericTrait<u32> for f64 { - //~ TRANS_ITEM fn trait_implementations::f64.SomeGenericTrait<u32>[0]::foo[0] + //~ TRANS_ITEM fn trait_implementations::{{impl}}[2]::foo[0] fn foo(&self, _: u32) {} fn bar<T2>(&self, _: u32, _: T2) {} @@ -57,25 +57,25 @@ impl<T> SomeGenericTrait<T> for f32 { //~ TRANS_ITEM fn trait_implementations::main[0] fn main() { - //~ TRANS_ITEM fn trait_implementations::i32.SomeTrait[0]::bar[0]<char> + //~ TRANS_ITEM fn trait_implementations::{{impl}}[1]::bar[0]<char> 0i32.bar('x'); - //~ TRANS_ITEM fn trait_implementations::f64.SomeGenericTrait<u32>[0]::bar[0]<&str> + //~ TRANS_ITEM fn trait_implementations::{{impl}}[2]::bar[0]<&str> 0f64.bar(0u32, "&str"); - //~ TRANS_ITEM fn trait_implementations::f64.SomeGenericTrait<u32>[0]::bar[0]<()> + //~ TRANS_ITEM fn trait_implementations::{{impl}}[2]::bar[0]<()> 0f64.bar(0u32, ()); - //~ TRANS_ITEM fn trait_implementations::f32.SomeGenericTrait<T>[0]::foo[0]<char> + //~ TRANS_ITEM fn trait_implementations::{{impl}}[3]::foo[0]<char> 0f32.foo('x'); - //~ TRANS_ITEM fn trait_implementations::f32.SomeGenericTrait<T>[0]::foo[0]<i64> + //~ TRANS_ITEM fn trait_implementations::{{impl}}[3]::foo[0]<i64> 0f32.foo(-1i64); - //~ TRANS_ITEM fn trait_implementations::f32.SomeGenericTrait<T>[0]::bar[0]<u32, ()> + //~ TRANS_ITEM fn trait_implementations::{{impl}}[3]::bar[0]<u32, ()> 0f32.bar(0u32, ()); - //~ TRANS_ITEM fn trait_implementations::f32.SomeGenericTrait<T>[0]::bar[0]<&str, &str> + //~ TRANS_ITEM fn trait_implementations::{{impl}}[3]::bar[0]<&str, &str> 0f32.bar("&str", "&str"); } diff --git a/src/test/codegen-units/trait-method-as-argument.rs b/src/test/codegen-units/trait-method-as-argument.rs index fdf63df5471..e7006d73ef1 100644 --- a/src/test/codegen-units/trait-method-as-argument.rs +++ b/src/test/codegen-units/trait-method-as-argument.rs @@ -39,7 +39,7 @@ fn take_foo_mut<T, F: FnMut(T) -> T>(mut f: F, arg: T) -> T { //~ TRANS_ITEM fn trait_method_as_argument::main[0] fn main() { //~ TRANS_ITEM fn trait_method_as_argument::take_foo_once[0]<u32, fn(u32) -> u32> - //~ TRANS_ITEM fn trait_method_as_argument::u32.Trait[0]::foo[0] + //~ TRANS_ITEM fn trait_method_as_argument::{{impl}}[0]::foo[0] take_foo_once(Trait::foo, 0u32); //~ TRANS_ITEM fn trait_method_as_argument::take_foo_once[0]<char, fn(char) -> char> diff --git a/src/test/codegen-units/transitive-drop-glue.rs b/src/test/codegen-units/transitive-drop-glue.rs index 6982cb9299a..21bb29199a6 100644 --- a/src/test/codegen-units/transitive-drop-glue.rs +++ b/src/test/codegen-units/transitive-drop-glue.rs @@ -21,7 +21,7 @@ struct Intermediate(Leaf); struct Leaf; impl Drop for Leaf { - //~ TRANS_ITEM fn transitive_drop_glue::Leaf.Drop[0]::drop[0] + //~ TRANS_ITEM fn transitive_drop_glue::{{impl}}[0]::drop[0] fn drop(&mut self) {} } @@ -44,12 +44,12 @@ fn main() { //~ TRANS_ITEM drop-glue transitive_drop_glue::RootGen[0]<u32> //~ TRANS_ITEM drop-glue transitive_drop_glue::IntermediateGen[0]<u32> //~ TRANS_ITEM drop-glue transitive_drop_glue::LeafGen[0]<u32> - //~ TRANS_ITEM fn transitive_drop_glue::LeafGen<T>.Drop[0]::drop[0]<u32> + //~ TRANS_ITEM fn transitive_drop_glue::{{impl}}[1]::drop[0]<u32> let _ = RootGen(IntermediateGen(LeafGen(0u32))); //~ TRANS_ITEM drop-glue transitive_drop_glue::RootGen[0]<i16> //~ TRANS_ITEM drop-glue transitive_drop_glue::IntermediateGen[0]<i16> //~ TRANS_ITEM drop-glue transitive_drop_glue::LeafGen[0]<i16> - //~ TRANS_ITEM fn transitive_drop_glue::LeafGen<T>.Drop[0]::drop[0]<i16> + //~ TRANS_ITEM fn transitive_drop_glue::{{impl}}[1]::drop[0]<i16> let _ = RootGen(IntermediateGen(LeafGen(0i16))); } diff --git a/src/test/codegen-units/tuple-drop-glue.rs b/src/test/codegen-units/tuple-drop-glue.rs index 87fcb00eab8..1bc235de88e 100644 --- a/src/test/codegen-units/tuple-drop-glue.rs +++ b/src/test/codegen-units/tuple-drop-glue.rs @@ -17,7 +17,7 @@ struct Dropped; impl Drop for Dropped { - //~ TRANS_ITEM fn tuple_drop_glue::Dropped.Drop[0]::drop[0] + //~ TRANS_ITEM fn tuple_drop_glue::{{impl}}[0]::drop[0] fn drop(&mut self) {} } diff --git a/src/test/codegen-units/unsizing.rs b/src/test/codegen-units/unsizing.rs index dd90d32858f..45ba441bc8b 100644 --- a/src/test/codegen-units/unsizing.rs +++ b/src/test/codegen-units/unsizing.rs @@ -57,11 +57,11 @@ fn main() { // simple case let bool_sized = &true; - //~ TRANS_ITEM fn unsizing::bool.Trait[0]::foo[0] + //~ TRANS_ITEM fn unsizing::{{impl}}[0]::foo[0] let _bool_unsized = bool_sized as &Trait; let char_sized = &true; - //~ TRANS_ITEM fn unsizing::char.Trait[0]::foo[0] + //~ TRANS_ITEM fn unsizing::{{impl}}[1]::foo[0] let _char_unsized = char_sized as &Trait; // struct field @@ -70,11 +70,11 @@ fn main() _b: 2, _c: 3.0f64 }; - //~ TRANS_ITEM fn unsizing::f64.Trait[0]::foo[0] + //~ TRANS_ITEM fn unsizing::{{impl}}[2]::foo[0] let _struct_unsized = struct_sized as &Struct<Trait>; // custom coercion let wrapper_sized = Wrapper(&0u32); - //~ TRANS_ITEM fn unsizing::u32.Trait[0]::foo[0] + //~ TRANS_ITEM fn unsizing::{{impl}}[3]::foo[0] let _wrapper_sized = wrapper_sized as Wrapper<Trait>; } diff --git a/src/test/codegen-units/unused-traits-and-generics.rs b/src/test/codegen-units/unused-traits-and-generics.rs index a4c5099ab97..8689beb3fb7 100644 --- a/src/test/codegen-units/unused-traits-and-generics.rs +++ b/src/test/codegen-units/unused-traits-and-generics.rs @@ -85,5 +85,5 @@ impl NonGeneric { } // Only the non-generic methods should be instantiated: -//~ TRANS_ITEM fn unused_traits_and_generics::NonGeneric[0]::foo[0] +//~ TRANS_ITEM fn unused_traits_and_generics::{{impl}}[3]::foo[0] //~ TRANS_ITEM drop-glue i8 diff --git a/src/test/compile-fail/symbol-names/basic.rs b/src/test/compile-fail/symbol-names/basic.rs new file mode 100644 index 00000000000..0095774fcb8 --- /dev/null +++ b/src/test/compile-fail/symbol-names/basic.rs @@ -0,0 +1,16 @@ +// Copyright 2012-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. + +#![feature(rustc_attrs)] + +#[rustc_symbol_name] //~ ERROR _ZN5basic4main +#[rustc_item_path] //~ ERROR item-path(main) +fn main() { +} diff --git a/src/test/compile-fail/symbol-names/impl1.rs b/src/test/compile-fail/symbol-names/impl1.rs new file mode 100644 index 00000000000..39bee26da20 --- /dev/null +++ b/src/test/compile-fail/symbol-names/impl1.rs @@ -0,0 +1,35 @@ +// Copyright 2012-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. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod foo { + pub struct Foo { x: u32 } + + impl Foo { + #[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar + #[rustc_item_path] //~ ERROR item-path(foo::Foo::bar) + fn bar() { } + } +} + +mod bar { + use foo::Foo; + + impl Foo { + #[rustc_symbol_name] //~ ERROR _ZN5impl13bar26_$LT$impl$u20$foo..Foo$GT$3baz + #[rustc_item_path] //~ ERROR item-path(bar::<impl foo::Foo>::baz) + fn baz() { } + } +} + +fn main() { +} diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp index fedb68a26af..fe4337eedc6 100644 --- a/src/test/pretty/issue-4264.pp +++ b/src/test/pretty/issue-4264.pp @@ -41,37 +41,37 @@ pub fn bar() { ((::std::fmt::format as fn(core::fmt::Arguments<'_>) -> collections::string::String {collections::fmt::format})(((::std::fmt::Arguments::new_v1 as - fn(&[&str], &[core::fmt::ArgumentV1<'_>]) -> core::fmt::Arguments<'_> {core::fmt::Arguments<'a><'_>::new_v1})(({ - static __STATIC_FMTSTR: - &'static [&'static str] - = - (&([("test" - as - &'static str)] - as - [&'static str; 1]) + fn(&[&str], &[core::fmt::ArgumentV1<'_>]) -> core::fmt::Arguments<'_> {core::fmt::Arguments<'_>::new_v1})(({ + static __STATIC_FMTSTR: + &'static [&'static str] + = + (&([("test" as - &'static [&'static str; 1]); - (__STATIC_FMTSTR - as - &'static [&'static str]) - } - as - &[&str]), - (&(match (() - as - ()) - { - () - => - ([] + &'static str)] as - [core::fmt::ArgumentV1<'_>; 0]), - } - as - [core::fmt::ArgumentV1<'_>; 0]) - as - &[core::fmt::ArgumentV1<'_>; 0])) + [&'static str; 1]) + as + &'static [&'static str; 1]); + (__STATIC_FMTSTR + as + &'static [&'static str]) + } + as + &[&str]), + (&(match (() + as + ()) + { + () + => + ([] + as + [core::fmt::ArgumentV1<'_>; 0]), + } + as + [core::fmt::ArgumentV1<'_>; 0]) + as + &[core::fmt::ArgumentV1<'_>; 0])) as core::fmt::Arguments<'_>)) as collections::string::String); diff --git a/src/test/run-make/a-b-a-linker-guard/Makefile b/src/test/run-make/a-b-a-linker-guard/Makefile new file mode 100644 index 00000000000..0962ebfbff5 --- /dev/null +++ b/src/test/run-make/a-b-a-linker-guard/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +# Test that if we build `b` against a version of `a` that has one set +# of types, it will not run with a dylib that has a different set of +# types. + +all: + $(RUSTC) a.rs --cfg x -C prefer-dynamic + $(RUSTC) b.rs -C prefer-dynamic + $(call RUN,b) + $(RUSTC) a.rs --cfg y -C prefer-dynamic + $(call FAIL,b) diff --git a/src/test/run-make/a-b-a-linker-guard/a.rs b/src/test/run-make/a-b-a-linker-guard/a.rs new file mode 100644 index 00000000000..e6cbe2e64d0 --- /dev/null +++ b/src/test/run-make/a-b-a-linker-guard/a.rs @@ -0,0 +1,20 @@ +// 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. + +#![crate_name = "a"] +#![crate_type = "dylib"] + +#[cfg(x)] +pub fn foo(x: u32) { } + +#[cfg(y)] +pub fn foo(x: i32) { } + + diff --git a/src/test/run-make/a-b-a-linker-guard/b.rs b/src/test/run-make/a-b-a-linker-guard/b.rs new file mode 100644 index 00000000000..89fd48de5bb --- /dev/null +++ b/src/test/run-make/a-b-a-linker-guard/b.rs @@ -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. + +#![crate_name = "b"] + +extern crate a; + +fn main() { + a::foo(22_u32); +} diff --git a/src/test/run-make/extern-overrides-distribution/Makefile b/src/test/run-make/extern-overrides-distribution/Makefile index 110db9f068d..7d063a4c83c 100644 --- a/src/test/run-make/extern-overrides-distribution/Makefile +++ b/src/test/run-make/extern-overrides-distribution/Makefile @@ -1,5 +1,5 @@ -include ../tools.mk all: - $(RUSTC) libc.rs + $(RUSTC) libc.rs -Cmetadata=foo $(RUSTC) main.rs --extern libc=$(TMPDIR)/liblibc.rlib diff --git a/src/test/run-make/issue-26006/Makefile b/src/test/run-make/issue-26006/Makefile index de89a6f6ad6..66aa78d5386 100644 --- a/src/test/run-make/issue-26006/Makefile +++ b/src/test/run-make/issue-26006/Makefile @@ -12,7 +12,7 @@ time: libc libc: mkdir -p $(OUT)/libc - $(RUSTC) in/libc/lib.rs --crate-name=libc -o $(OUT)/libc/liblibc.rlib + $(RUSTC) in/libc/lib.rs --crate-name=libc -Cmetadata=foo -o $(OUT)/libc/liblibc.rlib else all: endif diff --git a/src/test/run-make/relocation-model/Makefile b/src/test/run-make/relocation-model/Makefile index b22f34fa35b..485ecbb4b5a 100644 --- a/src/test/run-make/relocation-model/Makefile +++ b/src/test/run-make/relocation-model/Makefile @@ -7,8 +7,7 @@ all: others $(RUSTC) -C relocation-model=default foo.rs $(call RUN,foo) - $(RUSTC) -C relocation-model=default --crate-type=dylib foo.rs - $(RUSTC) -C relocation-model=dynamic-no-pic --crate-type=dylib foo.rs + $(RUSTC) -C relocation-model=dynamic-no-pic --crate-type=dylib foo.rs --emit=link,obj ifdef IS_MSVC # FIXME(#28026) @@ -17,5 +16,4 @@ else others: $(RUSTC) -C relocation-model=static foo.rs $(call RUN,foo) - $(RUSTC) -C relocation-model=static --crate-type=dylib foo.rs endif diff --git a/src/test/run-make/reproducible-build/Makefile b/src/test/run-make/reproducible-build/Makefile new file mode 100644 index 00000000000..8e799ca1a43 --- /dev/null +++ b/src/test/run-make/reproducible-build/Makefile @@ -0,0 +1,20 @@ +-include ../tools.mk +all: + $(RUSTC) reproducible-build-aux.rs + $(RUSTC) reproducible-build.rs -o"$(TMPDIR)/reproducible-build1" + $(RUSTC) reproducible-build.rs -o"$(TMPDIR)/reproducible-build2" + nm "$(TMPDIR)/reproducible-build1" | sort > "$(TMPDIR)/reproducible-build1.nm" + nm "$(TMPDIR)/reproducible-build2" | sort > "$(TMPDIR)/reproducible-build2.nm" + cmp "$(TMPDIR)/reproducible-build1.nm" "$(TMPDIR)/reproducible-build2.nm" || exit 1 + $(RUSTC) reproducible-build-aux.rs -g + $(RUSTC) reproducible-build.rs -g -o"$(TMPDIR)/reproducible-build1-debug" + $(RUSTC) reproducible-build.rs -g -o"$(TMPDIR)/reproducible-build2-debug" + nm "$(TMPDIR)/reproducible-build1-debug" | sort > "$(TMPDIR)/reproducible-build1-debug.nm" + nm "$(TMPDIR)/reproducible-build2-debug" | sort > "$(TMPDIR)/reproducible-build2-debug.nm" + cmp "$(TMPDIR)/reproducible-build1-debug.nm" "$(TMPDIR)/reproducible-build2-debug.nm" || exit 1 + $(RUSTC) reproducible-build-aux.rs -O + $(RUSTC) reproducible-build.rs -O -o"$(TMPDIR)/reproducible-build1-opt" + $(RUSTC) reproducible-build.rs -O -o"$(TMPDIR)/reproducible-build2-opt" + nm "$(TMPDIR)/reproducible-build1-opt" | sort > "$(TMPDIR)/reproducible-build1-opt.nm" + nm "$(TMPDIR)/reproducible-build2-opt" | sort > "$(TMPDIR)/reproducible-build2-opt.nm" + cmp "$(TMPDIR)/reproducible-build1-opt.nm" "$(TMPDIR)/reproducible-build2-opt.nm" || exit 1 diff --git a/src/test/run-make/reproducible-build/reproducible-build-aux.rs b/src/test/run-make/reproducible-build/reproducible-build-aux.rs new file mode 100644 index 00000000000..9ef853e7996 --- /dev/null +++ b/src/test/run-make/reproducible-build/reproducible-build-aux.rs @@ -0,0 +1,38 @@ +// Copyright 2016 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. + +#![crate_type="lib"] + +pub static STATIC: i32 = 1234; + +pub struct Struct<T1, T2> { + _t1: std::marker::PhantomData<T1>, + _t2: std::marker::PhantomData<T2>, +} + +pub fn regular_fn(_: i32) {} + +pub fn generic_fn<T1, T2>() {} + +impl<T1, T2> Drop for Struct<T1, T2> { + fn drop(&mut self) {} +} + +pub enum Enum { + Variant1, + Variant2(u32), + Variant3 { x: u32 } +} + +pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64); + +pub trait Trait<T1, T2> { + fn foo(&self); +} diff --git a/src/test/run-make/reproducible-build/reproducible-build.rs b/src/test/run-make/reproducible-build/reproducible-build.rs new file mode 100644 index 00000000000..dc7c702e5cc --- /dev/null +++ b/src/test/run-make/reproducible-build/reproducible-build.rs @@ -0,0 +1,128 @@ +// Copyright 2016 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. + +// This test case makes sure that two identical invocations of the compiler +// (i.e. same code base, same compile-flags, same compiler-versions, etc.) +// produce the same output. In the past, symbol names of monomorphized functions +// were not deterministic (which we want to avoid). +// +// The test tries to exercise as many different paths into symbol name +// generation as possible: +// +// - regular functions +// - generic functions +// - methods +// - statics +// - closures +// - enum variant constructors +// - tuple struct constructors +// - drop glue +// - FnOnce adapters +// - Trait object shims +// - Fn Pointer shims + +#![allow(dead_code)] + +extern crate reproducible_build_aux; + +static STATIC: i32 = 1234; + +pub struct Struct<T1, T2> { + x: T1, + y: T2, +} + +fn regular_fn(_: i32) {} + +fn generic_fn<T1, T2>() {} + +impl<T1, T2> Drop for Struct<T1, T2> { + fn drop(&mut self) {} +} + +pub enum Enum { + Variant1, + Variant2(u32), + Variant3 { x: u32 } +} + +struct TupleStruct(i8, i16, i32, i64); + +impl TupleStruct { + pub fn bar(&self) {} +} + +trait Trait<T1, T2> { + fn foo(&self); +} + +impl Trait<i32, u64> for u64 { + fn foo(&self) {} +} + +impl reproducible_build_aux::Trait<char, String> for TupleStruct { + fn foo(&self) {} +} + +fn main() { + regular_fn(STATIC); + generic_fn::<u32, char>(); + generic_fn::<char, Struct<u32, u64>>(); + generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>(); + + let dropped = Struct { + x: "", + y: 'a', + }; + + let _ = Enum::Variant1; + let _ = Enum::Variant2(0); + let _ = Enum::Variant3 { x: 0 }; + let _ = TupleStruct(1, 2, 3, 4); + + let closure = |x| { + x + 1i32 + }; + + fn inner<F: Fn(i32) -> i32>(f: F) -> i32 { + f(STATIC) + } + + println!("{}", inner(closure)); + + let object_shim: &Trait<i32, u64> = &0u64; + object_shim.foo(); + + fn with_fn_once_adapter<F: FnOnce(i32)>(f: F) { + f(0); + } + + with_fn_once_adapter(|_:i32| { }); + + reproducible_build_aux::regular_fn(STATIC); + reproducible_build_aux::generic_fn::<u32, char>(); + reproducible_build_aux::generic_fn::<char, Struct<u32, u64>>(); + reproducible_build_aux::generic_fn::<Struct<u64, u32>, + reproducible_build_aux::Struct<u32, u64>>(); + + let _ = reproducible_build_aux::Enum::Variant1; + let _ = reproducible_build_aux::Enum::Variant2(0); + let _ = reproducible_build_aux::Enum::Variant3 { x: 0 }; + let _ = reproducible_build_aux::TupleStruct(1, 2, 3, 4); + + let object_shim: &reproducible_build_aux::Trait<char, String> = &TupleStruct(0, 1, 2, 3); + object_shim.foo(); + + let pointer_shim: &Fn(i32) = ®ular_fn; + + TupleStruct(1, 2, 3, 4).bar(); +} + + diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs index 2a98706351a..36cac8f50a8 100644 --- a/src/test/run-pass/backtrace.rs +++ b/src/test/run-pass/backtrace.rs @@ -51,13 +51,29 @@ fn template(me: &str) -> Command { return m; } +fn expected(fn_name: &str) -> String { + // FIXME(#32481) + // + // On windows, we read the function name from debuginfo using some + // system APIs. For whatever reason, these APIs seem to use the + // "name" field, which is only the "relative" name, not the full + // name with namespace info, so we just see `foo` and not + // `backtrace::foo` as we see on linux (which uses the linkage + // name). + if cfg!(windows) && cfg!(target_env = "msvc") { + format!(" - {}", fn_name) + } else { + format!(" - backtrace::{}", fn_name) + } +} + fn runtest(me: &str) { // Make sure that the stack trace is printed let p = template(me).arg("fail").env("RUST_BACKTRACE", "1").spawn().unwrap(); let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); let s = str::from_utf8(&out.stderr).unwrap(); - assert!(s.contains("stack backtrace") && s.contains(" - foo"), + assert!(s.contains("stack backtrace") && s.contains(&expected("foo")), "bad output: {}", s); // Make sure the stack trace is *not* printed @@ -67,7 +83,7 @@ fn runtest(me: &str) { let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); let s = str::from_utf8(&out.stderr).unwrap(); - assert!(!s.contains("stack backtrace") && !s.contains(" - foo"), + assert!(!s.contains("stack backtrace") && !s.contains(&expected("foo")), "bad output2: {}", s); // Make sure a stack trace is printed @@ -77,7 +93,7 @@ fn runtest(me: &str) { let s = str::from_utf8(&out.stderr).unwrap(); // loosened the following from double::h to double:: due to // spurious failures on mac, 32bit, optimized - assert!(s.contains("stack backtrace") && s.contains(" - double"), + assert!(s.contains("stack backtrace") && s.contains(&expected("double")), "bad output3: {}", s); // Make sure a stack trace isn't printed too many times diff --git a/src/test/run-pass/command-before-exec.rs b/src/test/run-pass/command-before-exec.rs index 7c5a21911db..16560637b69 100644 --- a/src/test/run-pass/command-before-exec.rs +++ b/src/test/run-pass/command-before-exec.rs @@ -9,8 +9,6 @@ // except according to those terms. // ignore-windows - this is a unix-specific test -// no-prefer-dynamic - this test breaks with dynamic linking as -// some LD_LIBRARY_PATH entries are relative and it cd's to /. #![feature(process_exec, libc)] diff --git a/src/test/run-pass/issue-17718.rs b/src/test/run-pass/issue-17718.rs index 2bb69d105ff..744e63f159b 100644 --- a/src/test/run-pass/issue-17718.rs +++ b/src/test/run-pass/issue-17718.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// aux-build:issue-17718.rs +// aux-build:issue-17718-aux.rs #![feature(core)] #![feature(const_fn)] -extern crate issue_17718 as other; +extern crate issue_17718_aux as other; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/src/test/run-pass/typeid-intrinsic.rs b/src/test/run-pass/typeid-intrinsic.rs index db53fa855f1..4bd82baafeb 100644 --- a/src/test/run-pass/typeid-intrinsic.rs +++ b/src/test/run-pass/typeid-intrinsic.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// aux-build:typeid-intrinsic.rs -// aux-build:typeid-intrinsic2.rs +// aux-build:typeid-intrinsic-aux1.rs +// aux-build:typeid-intrinsic-aux2.rs #![feature(core_intrinsics)] -extern crate typeid_intrinsic as other1; -extern crate typeid_intrinsic2 as other2; +extern crate typeid_intrinsic_aux1 as other1; +extern crate typeid_intrinsic_aux2 as other2; use std::hash::{SipHasher, Hasher, Hash}; use std::any::TypeId; |
