Skip to content

Add testcase for issue-32948 #36832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}