Skip to content

Commit

Permalink
core: ensure callsites in test have unique addresses (#2681)
Browse files Browse the repository at this point in the history
The test relies on TEST_CALLSITE_1 and TEST_CALLSITE_2 to have
different addresses. However, as they are zero-sized types, this
is not guaranteed.

This fixes the test failure with LLVM 17 and certain optimization
options reported at rust-lang/rust#114699.
  • Loading branch information
nikic authored and davidbarsky committed Sep 26, 2023
1 parent 88c0a90 commit a24389f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tracing-core/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,9 @@ mod test {
use crate::metadata::{Kind, Level, Metadata};
use crate::stdlib::{borrow::ToOwned, string::String};

struct TestCallsite1;
static TEST_CALLSITE_1: TestCallsite1 = TestCallsite1;
// Make sure TEST_CALLSITE_* have non-zero size, so they can't be located at the same address.
struct TestCallsite1(u8);
static TEST_CALLSITE_1: TestCallsite1 = TestCallsite1(0);
static TEST_META_1: Metadata<'static> = metadata! {
name: "field_test1",
target: module_path!(),
Expand All @@ -1123,8 +1124,8 @@ mod test {
}
}

struct TestCallsite2;
static TEST_CALLSITE_2: TestCallsite2 = TestCallsite2;
struct TestCallsite2(u8);
static TEST_CALLSITE_2: TestCallsite2 = TestCallsite2(0);
static TEST_META_2: Metadata<'static> = metadata! {
name: "field_test2",
target: module_path!(),
Expand Down

0 comments on commit a24389f

Please sign in to comment.