-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doctests in libcore sometimes use wrong external crate #4
Comments
@hyd-dev wrote
Well, but real libcore has something similar, doesn't it? There's libcore and there's "libcore built for tests". |
This is the command used by
It looks like it's passing |
Hm... you are probably right. I think for unit tests the situation is very much like Though I am not sure how |
Seems like so. This is the backtrace for the "resolving crate
|
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 |
Yes. |
For the record, that diff was diff --git a/core_miri_test/Cargo.toml b/core_miri_test/Cargo.toml
index 524cce8..b8df702 100644
--- a/core_miri_test/Cargo.toml
+++ b/core_miri_test/Cargo.toml
@@ -12,6 +12,10 @@ path = "../libcore/src/lib.rs"
test = false
bench = false
+[features]
+miri-test = []
+default = ["miri-test"]
+
[[test]]
name = "coretests"
path = "../libcore/tests/lib.rs"
diff --git a/rust-src.diff b/rust-src.diff
index e69de29..965f559 100644
--- a/rust-src.diff
+++ b/rust-src.diff
@@ -0,0 +1,12 @@
+diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
+index 3557dbad..6c089b0c 100644
+--- a/library/core/src/lib.rs
++++ b/library/core/src/lib.rs
+@@ -49,6 +49,7 @@
+ //
+ // This cfg won't affect doc tests.
+ #![cfg(not(test))]
++#![cfg(any(not(feature = "miri-test"), doctest))]
+ #![stable(feature = "core", since = "1.6.0")]
+ #![doc(
+ html_playground_url = "https://play.rust-lang.org/", |
…Simulacrum better support for running libcore tests with Miri See rust-lang/miri-test-libstd#4 for a description of the problem that this fixes. Thanks to `@hyd-dev` for suggesting this patch!
thin_box test: import from std, not alloc Importing from `alloc` makes [Miri fail](https://github.com/rust-lang/miri-test-libstd/runs/5964922742?check_suite_focus=true), probably due to the hack that we used to resolve rust-lang/miri-test-libstd#4. There might be better ways around this, but for now this is the easiest thing to do -- no other alloc integration test is importing from `alloc::`.
thin_box test: import from std, not alloc Importing from `alloc` makes [Miri fail](https://github.com/rust-lang/miri-test-libstd/runs/5964922742?check_suite_focus=true), probably due to the hack that we used to resolve rust-lang/miri-test-libstd#4. There might be better ways around this, but for now this is the easiest thing to do -- no other alloc integration test is importing from `alloc::`.
thin_box test: import from std, not alloc Importing from `alloc` makes [Miri fail](https://github.com/rust-lang/miri-test-libstd/runs/5964922742?check_suite_focus=true), probably due to the hack that we used to resolve rust-lang/miri-test-libstd#4. There might be better ways around this, but for now this is the easiest thing to do -- no other alloc integration test is importing from `alloc::`.
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.
Cc @hyd-dev
The text was updated successfully, but these errors were encountered: