Add testcase for issue-32948

ref : https://github.com/rust-lang/rust/issue/32948
This commit is contained in:
ParkHanbum 2016-09-29 16:24:14 +09:00
parent b543f3a4b2
commit cb700e78ed
3 changed files with 29 additions and 5 deletions

View File

@ -1,12 +1,16 @@
-include ../tools.mk
# This test case makes sure that monomorphizations of the same function with the
# same set of generic arguments will have the same symbol names when
# instantiated in different crates.
# The following command will:
# 1. dump the symbols of a library using `nm`
# 2. extract only those lines that we are interested in via `grep`
# 3. from those lines, extract just the symbol name via `sed`
# (symbol names always start with "_ZN" and end with "E")
# 4. sort those symbol names for deterministic comparison
# 5. write the result into a file
dump-symbols = nm "$(TMPDIR)/lib$(1).rlib" \
| grep "some_test_function" \
| sed "s/^[0-9a-f]\{8,16\}/00000000/" \
| grep -E "some_test_function|Bar|bar" \
| sed "s/.*\(_ZN.*E\).*/\1/" \
| sort \
> "$(TMPDIR)/$(1).nm"

View File

@ -10,6 +10,20 @@
#![crate_type="rlib"]
pub trait Foo {
fn foo<T>();
}
pub struct Bar;
impl Foo for Bar {
fn foo<T>() {}
}
pub fn bar() {
Bar::foo::<Bar>();
}
pub fn some_test_function<T>(t: T) -> T {
t
}

View File

@ -18,3 +18,9 @@ pub fn user() {
let x = 2u64;
stable_symbol_names1::some_test_function(&x);
}
pub fn trait_impl_test_function() {
use stable_symbol_names1::*;
Bar::foo::<Bar>();
bar();
}