Skip to content

Commit c8887ab

Browse files
committedMay 27, 2019
Tests for external linkage symbol collision check.
Fix rust-lang#61232
1 parent 4e60f53 commit c8887ab

5 files changed

+67
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![feature(linkage)]
2+
#![crate_type = "lib"]
3+
4+
extern {
5+
#[linkage="external"]
6+
pub static collision: *const i32;
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// rust-lang/rust#61232: We used to ICE when trying to detect a
2+
// collision on the symbol generated for the external linkage item in
3+
// an extern crate.
4+
5+
// aux-build:def_colliding_external.rs
6+
7+
extern crate def_colliding_external as dep1;
8+
9+
#[no_mangle]
10+
pub static _rust_extern_with_linkage_collision: i32 = 0;
11+
12+
mod dep2 {
13+
#[no_mangle]
14+
pub static collision: usize = 0;
15+
}
16+
17+
fn main() {
18+
unsafe {
19+
println!("{:p}", &dep1::collision);
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: symbol `collision` is already defined
2+
--> $DIR/auxiliary/def_colliding_external.rs:6:5
3+
|
4+
LL | pub static collision: *const i32;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![feature(linkage)]
2+
3+
mod dep1 {
4+
extern {
5+
#[linkage="external"]
6+
#[no_mangle]
7+
pub static collision: *const i32; //~ ERROR symbol `collision` is already defined
8+
}
9+
}
10+
11+
#[no_mangle]
12+
pub static _rust_extern_with_linkage_collision: i32 = 0;
13+
14+
mod dep2 {
15+
#[no_mangle]
16+
pub static collision: usize = 0;
17+
}
18+
19+
fn main() {
20+
unsafe {
21+
println!("{:p}", &dep1::collision);
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: symbol `collision` is already defined
2+
--> $DIR/linkage-detect-local-generated-name-collision.rs:7:9
3+
|
4+
LL | pub static collision: *const i32;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)
Please sign in to comment.