Skip to content

Commit

Permalink
Add testcase for issue-32948
Browse files Browse the repository at this point in the history
  • Loading branch information
ParkHanbum committed Oct 6, 2016
1 parent b543f3a commit cb700e7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/test/run-make/stable-symbol-names/Makefile
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
14 changes: 14 additions & 0 deletions src/test/run-make/stable-symbol-names/stable-symbol-names1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/run-make/stable-symbol-names/stable-symbol-names2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit cb700e7

Please sign in to comment.