-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Open
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-parallel-compilerArea: parallel compilerArea: parallel compilerA-reproducibilityArea: Reproducible / deterministic buildsArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.Category: This is a bug.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
I tried this code:
pub struct A<T> { pub v: T }
pub struct B<T> { pub v: T }
pub mod test {
pub struct A<T> { pub v: T }
impl<T> A<T> {
pub fn foo(&self) -> isize {
static a: isize = 5;
return a
}
pub fn bar(&self) -> isize {
static a: isize = 6;
return a;
}
}
}
rustc inner_static.rs --emit=mir --crate-type lib -o out -Zthreads=60 ; md5sum out
I expected to see this happen: explanation
equal md5s
Instead, this happened: explanation
different md5s
ba0be6d56e74c5a05f5b5964a2a9ca3c
fcc907ca72b311ae42bd6fe7d3a0ad91
--- 1 2026-03-23 22:42:02.040187880 +0100
+++ 2 2026-03-23 22:41:53.408130384 +0100
@@ -7,13 +7,13 @@
let mut _2: &isize;
bb0: {
- _2 = const {alloc2: &isize};
+ _2 = const {alloc1: &isize};
_0 = copy (*_2);
return;
}
}
-alloc2 (static: test::A::<T>::foo::a, size: 8, align: 8) {
+alloc1 (static: test::A::<T>::foo::a, size: 8, align: 8) {
05 00 00 00 00 00 00 00 │ ........
}
@@ -32,13 +32,13 @@
let mut _2: &isize;
bb0: {
- _2 = const {alloc1: &isize};
+ _2 = const {alloc2: &isize};
_0 = copy (*_2);
return;
}
}
-alloc1 (static: test::A::<T>::bar::a, size: 8, align: 8) {
+alloc2 (static: test::A::<T>::bar::a, size: 8, align: 8) {
06 00 00 00 00 00 00 00 │ ........
}Meta
rustc --version --verbose:
rustc 1.96.0-nightly (562dee482 2026-03-21)
binary: rustc
commit-hash: 562dee4820c458d823175268e41601d4c060588a
commit-date: 2026-03-21
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-parallel-compilerArea: parallel compilerArea: parallel compilerA-reproducibilityArea: Reproducible / deterministic buildsArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.Category: This is a bug.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Type
Fields
Give feedbackNo fields configured for issues without a type.