Closed
Description
The code:
// aux.rs
#[crate_type = "lib"];
pub static Foo: uint = 1;
// main.rs
extern mod aux;
fn main() {
let x = aux::Foo;
match x {
aux::Foo => println("Foo == Foo"),
_ => println("Foo != Foo")
}
}
produces the expected output: Foo == Foo
But after changing aux.rs
to
#[crate_type = "lib"];
pub static Foo: uint = 2;
and recompiling only aux.rs
, the output is Foo != Foo
This is because rustc
is too eager and replaces the match pattern aux::Foo
with 1
at compile-time. That works until we change aux::Foo
. Because x
gets its value at runtime, it becomes 2
and doesn't fit the first match arm.
Metadata
Metadata
Assignees
Labels
No labels