Skip to content

Commit cb700e7

Browse files
committed
Add testcase for issue-32948
ref : https://github.com/rust-lang/rust/issue/32948
1 parent b543f3a commit cb700e7

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

src/test/run-make/stable-symbol-names/Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
-include ../tools.mk
22

3-
# This test case makes sure that monomorphizations of the same function with the
4-
# same set of generic arguments will have the same symbol names when
5-
# instantiated in different crates.
3+
# The following command will:
4+
# 1. dump the symbols of a library using `nm`
5+
# 2. extract only those lines that we are interested in via `grep`
6+
# 3. from those lines, extract just the symbol name via `sed`
7+
# (symbol names always start with "_ZN" and end with "E")
8+
# 4. sort those symbol names for deterministic comparison
9+
# 5. write the result into a file
610

711
dump-symbols = nm "$(TMPDIR)/lib$(1).rlib" \
8-
| grep "some_test_function" \
9-
| sed "s/^[0-9a-f]\{8,16\}/00000000/" \
12+
| grep -E "some_test_function|Bar|bar" \
13+
| sed "s/.*\(_ZN.*E\).*/\1/" \
1014
| sort \
1115
> "$(TMPDIR)/$(1).nm"
1216

src/test/run-make/stable-symbol-names/stable-symbol-names1.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@
1010

1111
#![crate_type="rlib"]
1212

13+
pub trait Foo {
14+
fn foo<T>();
15+
}
16+
17+
pub struct Bar;
18+
19+
impl Foo for Bar {
20+
fn foo<T>() {}
21+
}
22+
23+
pub fn bar() {
24+
Bar::foo::<Bar>();
25+
}
26+
1327
pub fn some_test_function<T>(t: T) -> T {
1428
t
1529
}

src/test/run-make/stable-symbol-names/stable-symbol-names2.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ pub fn user() {
1818
let x = 2u64;
1919
stable_symbol_names1::some_test_function(&x);
2020
}
21+
22+
pub fn trait_impl_test_function() {
23+
use stable_symbol_names1::*;
24+
Bar::foo::<Bar>();
25+
bar();
26+
}

0 commit comments

Comments
 (0)