That depends on what we mean by “work”.
If “work” means “will build the correct final artifact” then I think it will just work. If we relied only on the file name hash is and did not account for rust RUST_FLAGS we could, for example, end up linking code for the wrong CPU. So getting the correct output is not a small achievement.
If “work” means “setting the cache-dir to the same folder for more than one project will always save you time” then, at this time, it will definitely not work. Your example is excellent, one project “A-bin” has a config that sets RUST_FLAGS=“a”, another project “B-bin” has a config that sets RUST_FLAGS=“b” both of which use the same cache-dir. On building “A-bin” the cache will fill with deps that are built for RUST_FLAGS=“a”. Then on building “B-bin” the cache will be overwritten with deps that are built for RUST_FLAGS=“b”. Then “A-bin” will have to build them to put them back. We have a kind of false sharing.
These kinds of issues can be reduced by storing more info in the folder structure, but it will take time to find them all and design the best solution for each. A more ambitious proposal could suggest a plan for how to encode all sutch info, and thus suggest using a shared cache-dir by default. I am very welcome to hearing other proposals. In the meantime, I think my proposal, to add the infrastructure but have it off by default, allows us to start experimenting to find what needs to be improved without needing to get it all wright before we can merge.