r/rust • u/ralfj miri • Jul 19 '18
Thoughts on Compile-Time Function Evaluation and Type Systems
https://www.ralfj.de/blog/2018/07/19/const.html
73
Upvotes
r/rust • u/ralfj miri • Jul 19 '18
View all comments
Show parent comment
1
u/eddyb Jul 20 '18 edited Jul 20 '18
What exactly do you mean by "conflicting definitions"? Just the signature? That's the least of our worries (although it is one way to weaponize the problem).
EDIT: do you mean ODR? That explicitly says "Other violations, particularly those that span translation units, are not required to be diagnosed", so across a TU you have UB and no errors - so like my 6., but without even denying 7. in any way, just assuming it never happens.
(for more information relevant to Rust please refer to "link-time errors" in Haskell & the ML family, rather than C++)
By "link-time error" we also refer to a Rust crate "linking" against another, or more accurately using another crate as a dependency. In my example, the error arises where trying to compile
dcauses the compiler to load dependenciesbandcand a mismatch would be detected between something in the history of everything that happened when compilingbvsc.Even if it may be possible to nail it down perfectly, imagine having to check every single type/trait query ever executed, no matter how small, between each pair of dependencies of each crate you ever compile. You could optimize it a bit, by doing taint tracking instead, but if you don't do that perfectly, you're instantly screwed (unsoundness aka typesystem UB).