Skip to content
Open
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
4 changes: 4 additions & 0 deletions tests/ui/cross-crate/auxiliary/pub_static_array.rs
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
//@ no-prefer-dynamic

#![crate_type = "lib"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised that --crate-type dylib overrides #![crate_type = "lib"].

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's documented to behave this way: https://doc.rust-lang.org/reference/linkage.html#r-link.repetition


pub static ARRAY: [u8; 1] = [1];
6 changes: 5 additions & 1 deletion tests/ui/cross-crate/static-array-across-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ static X: &'static u8 = &ARRAY[0];
static Y: &'static u8 = &(&ARRAY)[0];
static Z: u8 = (&ARRAY)[0];

pub fn main() {}
pub fn main() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the auxiliary for this test need to change? This doesn't use extern "C" {} like the other test does.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if the presence of extern "C" makes a material difference. If the auxiliary for this test is not changed, the test fails just like the other one, the symbol name is just mangled:

 a.static_array_across_crate.fff1a89e6847c716-cgu.0.rcgu.o : error LNK2001: unresolved external symbol _ZN16pub_static_array5ARRAY17h4c54e0b13136769dE

// Make sure to actually reference the statics.
assert_eq!(&X, &Y);
assert_eq!(&X, &&Z);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ no-prefer-dynamic

// Helper definition for test/run-pass/check-static-recursion-foreign.rs.

#![feature(rustc_private)]
Expand Down
5 changes: 4 additions & 1 deletion tests/ui/statics/check-recursion-foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ extern "C" {

pub static B: &'static c_int = unsafe { &test_static };

pub fn main() {}
pub fn main() {
// Make sure to actually reference the static.
unsafe { assert_eq!(test_static, 0); }
}
Loading