-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Mismatched type error: type of crate instead of std is displayed #46112
Comments
Confirming - broken on nightly (1.23), good on beta. |
bisected across nightlys: bug was injected between |
Skimming output from |
This is recent enough that we should be able to run bisect-rust on it (cc @est31). |
#45452 it is cc @estebank @nikomatsakis . |
I'm a little surprised that this would be caused by that PR. I can push a revert but would like to first test locally to make sure that revert that PR will fix this. |
I have misread @pnkfelix 's statement. Your PR is not at fault, sorry. I'm doing another search further back to find the causing PR. |
@est31 I tried it locally in the meantime and I can confirm it is not :) |
Okay so the bug dates as far back as efceda2 from September 2nd which is as close to the limit as I dare to go. So to the people in control, please, prolong the limit :). |
@pnkfelix suggests that the bug was introduced much more recently (11-08 to 11-09). Maybe the bisection script was wrong? |
@Mark-Simulacrum I should probably have read the original issue more closely :). @estebank sorry for pinging you!
It seems to be #45725 cc @alexcrichton |
In particular, I have bisected it down to the commit: 6bc8f16 I have been trying to further dissect that commit to figure out why it causes the change we observe here. My current hypothesis (that I have not yet managed to confirm) is that it has to do with how we seed the hashmap's hashers with randomized state. (This commit changes our behavior in certain scenarios.) If this hypothesis is actually true, though, then I would think that this represents either a bug in hashmap itself, or a bug in how the compiler is using the hashmap... |
Hmm. Its something more subtle than a hashmap-related bug. In particular, I can reproduce the old behavior on master by just linking in the old That, to me, seems very strange. I'm now trying to reduce down the size of the |
triage: P-high |
… whole crate forest.
Fix visible_parent_map to choose globally minimal paths Fix #46112: visible_parent_map construction needs a BFS over whole crate forest to get globally minimal paths. (There are other latent bugs that were e.g. causing this test case to have weirdness like `<unnamed>` in the diagnostic output. Those bugs are not fixed here, since they are issues long-standing in the stable channel.)
I still get a non std types in erros when the path has the same length. That would be okay if it is somehow deterministic, but I get different type errors within the same file for the same types. error[E0308]: mismatched types
--> src/bus/mod.rs:350:25
|
350 | Err(BusError::ServiceTimeout(elapsed))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
= note: expected type `std::option::Option<_>`
found type `std::result::Result<_, bus::BusError>` error[E0308]: mismatched types
--> src/bus/mod.rs:339:37
|
339 | .and_then(|len| T::from_bytes(&self.buffer[0..len]))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `serde::export::Option`, found enum `serde::export::Result`
|
= note: expected type `serde::export::Option<_>`
found type `serde::export::Result<C, services::ServiceError>` |
@SWW13 is that a regression from the stable channel? While I absolutely agree that a deterministic result would be better (and better stilll, a deterministic result that favored minimal-length paths rooted at |
Hmm I guess since @SWW13 is the person who filed the original ticket then it is reasonable to infer that they are indeed seeing the described |
error[E0308]: mismatched types
--> src/bus/mod.rs:339:37
|
339 | .and_then(|len| T::from_bytes(&self.buffer[0..len]))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `serde::export::Option`, found enum `serde::export::Result`
|
= note: expected type `serde::export::Option<_>`
found type `serde::export::Result<C, services::ServiceError>`
error[E0308]: mismatched types
--> src/bus/mod.rs:350:25
|
350 | Err(BusError::ServiceTimeout(elapsed))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `serde::export::Option`, found enum `serde::export::Result`
|
= note: expected type `serde::export::Option<_>`
found type `serde::export::Result<_, bus::BusError>`
error[E0308]: mismatched types
--> src/bus/mod.rs:339:37
|
339 | .and_then(|len| T::from_bytes(&self.buffer[0..len]))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
= note: expected type `std::option::Option<_>`
found type `std::result::Result<C, services::ServiceError>`
error[E0308]: mismatched types
--> src/bus/mod.rs:350:25
|
350 | Err(BusError::ServiceTimeout(elapsed))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
= note: expected type `std::option::Option<_>`
found type `std::result::Result<_, bus::BusError>` Maybe this was some sort of partial compile cache issue? I haven't found a way to reproduce these mixed errors yet. |
Sorting by crate-num should ensure that we favor `std::foo::bar` over `any_other_crate::foo::bar`. Interestingly, *this* change had a much larger impact on our internal test suite than PR rust-lang#46708 (which was my original fix to rust-lang#46112).
Sorting by crate-num should ensure that we favor `std::foo::bar` over `any_other_crate::foo::bar`. Interestingly, *this* change had a much larger impact on our internal test suite than PR rust-lang#46708 (which was my original fix to rust-lang#46112). ---- (This is cherry-pick of aa030dd to beta.)
…re::` The reason we see `core::` even after visiting the `std` crate first is the special case code that looks like this: ```rust Entry::Occupied(mut entry) => { // If `child` is defined in crate `cnum`, ensure // that it is mapped to a parent in `cnum`. if child.krate == cnum && entry.get().krate != cnum { entry.insert(parent); } } ``` This causes items to be associated with the crates they were originally defined in, even if we had encountered them during the traversal of an earlier crate. (Having said that, I am not clear on why this same logic does not apply when both rust-lang#46708 and rust-lang#46838 have been applied. But at this point, I am just happy to have a plausible explanation for why we see `core::foo::bar` in the output for these tests, and want to focus on getting this fix for rust-lang#46112 backported to beta.)
…woerister Backport 46112 fix to beta Its probably easiest to focus on the diff rather than the commit series. If you prefer I could squash them, but I figured preserving the cherry-picking will make it easier to relate what has happened here to what happens on the `master` branch. Note: This is a backport of *just* #46838. It does not include #46708 (which we may end up wanting to revert). Fix #46112
This looks like a duplicate of #45070. That issue has some repro cases that affect the 1.22.1 stable compiler but not 1.21.0. |
When I bisected the nightlies by hand on #45070 I ended up with a range (d93036a...dead08c) that does not include the
I wonder whether merely linking |
Any evidence of this problem existing with the newest nightly? |
On nightly rustc (cargo) I get misleading expected type errors. If a crate has the same(?) type it is displayed instead of the std type.
I tried this code:
I expected to see this happen: (stable rust)
Instead, this happened: (nightly)
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: