You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under some circumstances, Miri goes all crazy on libcore doctests: it seems to load two distinct copies of libcore and then hell breaks loose.
Specifically, this seems to be triggered when the code contains a variable that does not exist -- rustc will try to make szggestions for names to use, which can trigger loading external crates, which might be what is happening here.
cargo test without Miri fails with same errors in that repository and all other libcore tests passed. It's caused by the miri-test-libstd-specific core_miri_test crate which is effectively another libcore.
Well, but real libcore has something similar, doesn't it? There's libcore and there's "libcore built for tests".
It looks like it's passing --extern core=... which will override the libcore from sysroot. Actually the sysroot one and the deps one have the same content in this case (I belive one is copied/hardlinked to another), so there is not a seperate "libcore built for tests".
However, the situation is different for core_miri_test. It's built differently than the sysroot core. Even if I rename the crate to core, rustc/Miri thinks libstd (and maybe also other libraries in the sysroot) needs a different version of core (it has a different hash), and still tries to load the core from sysroot.
Hm... you are probably right. I think for unit tests the situation is very much like core: those are a separately built crate in both cases. For doctests the situation might well be different. We'd need to make it so that rustdoc/rustc think of the sysroot core crate as being "the crate associated with this doctest" -- like, not have core_miri_test around at all.
Though I am not sure how core_miri_test gets imported at all currently... maybe that is the thing that the search for suggestions is doing, eagerly loading more crates than it otherwise would?
I think I've seen this behavior of rustc suggestions cause similar trouble in the past... but OTOH it kind of has to load all the crates since ´extern crate` is implicit since the 2018 edition.
So probably the only thing we can do is to try and make the core_miri_test crate empty. I assume that is what the patch you showed on Zulip does?
Activity
RalfJung commentedon Jul 16, 2021
@hyd-dev wrote
Well, but real libcore has something similar, doesn't it? There's libcore and there's "libcore built for tests".
ghost commentedon Jul 16, 2021
This is the command used by
x.py test library/core --stage 0 --doc
:It looks like it's passing
--extern core=...
which will override the libcore from sysroot. Actually the sysroot one and thedeps
one have the same content in this case (I belive one is copied/hardlinked to another), so there is not a seperate "libcore built for tests".However, the situation is different for
core_miri_test
. It's built differently than the sysrootcore
. Even if I rename the crate tocore
, rustc/Miri thinks libstd (and maybe also other libraries in the sysroot) needs a different version ofcore
(it has a different hash), and still tries to load thecore
from sysroot.RalfJung commentedon Jul 16, 2021
Hm... you are probably right. I think for unit tests the situation is very much like
core
: those are a separately built crate in both cases. For doctests the situation might well be different. We'd need to make it so that rustdoc/rustc think of the sysroot core crate as being "the crate associated with this doctest" -- like, not havecore_miri_test
around at all.Though I am not sure how
core_miri_test
gets imported at all currently... maybe that is the thing that the search for suggestions is doing, eagerly loading more crates than it otherwise would?ghost commentedon Jul 18, 2021
Seems like so. This is the backtrace for the "resolving crate
core_miri_test
" log message:RalfJung commentedon Jul 18, 2021
I think I've seen this behavior of rustc suggestions cause similar trouble in the past... but OTOH it kind of has to load all the crates since ´extern crate` is implicit since the 2018 edition.
So probably the only thing we can do is to try and make the
core_miri_test
crate empty. I assume that is what the patch you showed on Zulip does?ghost commentedon Jul 18, 2021
Yes.
RalfJung commentedon Jul 18, 2021
For the record, that diff was
Rollup merge of rust-lang#87255 - RalfJung:miri-test-libcore, r=Mark-…
core_miri_test
andalloc_miri_test
unlesscfg(any(test, doctest))
#5Rollup merge of rust-lang#95917 - RalfJung:thin-box-test, r=dtolnay
Rollup merge of rust-lang#95917 - RalfJung:thin-box-test, r=dtolnay
Rollup merge of #95917 - RalfJung:thin-box-test, r=dtolnay