rust/src/test/ui/traits/inductive-overflow/simultaneous.stderr

19 lines
574 B
Plaintext
Raw Normal View History

Avoid sorting predicates by `DefId` Fixes issue #82920 Even if an item does not change between compilation sessions, it may end up with a different `DefId`, since inserting/deleting an item affects the `DefId`s of all subsequent items. Therefore, we use a `DefPathHash` in the incremental compilation system, which is stable in the face of changes to unrelated items. In particular, the query system will consider the inputs to a query to be unchanged if any `DefId`s in the inputs have their `DefPathHash`es unchanged. Queries are pure functions, so the query result should be unchanged if the query inputs are unchanged. Unfortunately, it's possible to inadvertantly make a query result incorrectly change across compilations, by relying on the specific value of a `DefId`. Specifically, if the query result is a slice that gets sorted by `DefId`, the precise order will depend on how the `DefId`s got assigned in a particular compilation session. If some definitions end up with different `DefId`s (but the same `DefPathHash`es) in a subsequent compilation session, we will end up re-computing a *different* value for the query, even though the query system expects the result to unchanged due to the unchanged inputs. It turns out that we have been sorting the predicates computed during `astconv` by their `DefId`. These predicates make their way into the `super_predicates_that_define_assoc_type`, which ends up getting used to compute the vtables of trait objects. This, re-ordering these predicates between compilation sessions can lead to undefined behavior at runtime - the query system will re-use code built with a *differently ordered* vtable, resulting in the wrong method being invoked at runtime. This PR avoids sorting by `DefId` in `astconv`, fixing the miscompilation. However, it's possible that other instances of this issue exist - they could also be easily introduced in the future. To fully fix this issue, we should 1. Turn on `-Z incremental-verify-ich` by default. This will cause the compiler to ICE whenver an 'unchanged' query result changes between compilation sessions, instead of causing a miscompilation. 2. Remove the `Ord` impls for `CrateNum` and `DefId`. This will make it difficult to introduce ICEs in the first place.
2021-03-12 22:53:02 +00:00
error[E0275]: overflow evaluating the requirement `{integer}: Tweedledee`
2021-02-08 22:15:45 +00:00
--> $DIR/simultaneous.rs:18:5
2018-08-08 12:28:26 +00:00
|
LL | fn is_ee<T: Combo>(t: T) {
2020-04-06 05:15:06 +00:00
| ----- required by this bound in `is_ee`
...
2018-08-08 12:28:26 +00:00
LL | is_ee(4);
| ^^^^^
|
note: required because of the requirements on the impl of `Combo` for `{integer}`
--> $DIR/simultaneous.rs:11:34
|
LL | impl<T: Tweedledee + Tweedledum> Combo for T {}
| ^^^^^ ^
2018-08-08 12:28:26 +00:00
error: aborting due to previous error
For more information about this error, try `rustc --explain E0275`.