rust/compiler/rustc_query_system/src
Matthias Krüger 3cd0a109a8
Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, r=oli-obk
Store the laziness of type aliases in their `DefKind`

Previously, we would treat paths referring to type aliases as *lazy* type aliases if the current crate had lazy type aliases enabled independently of whether the crate which the alias was defined in had the feature enabled or not.

With this PR, the laziness of a type alias depends on the crate it is defined in. This generally makes more sense to me especially if / once lazy type aliases become the default in a new edition and we need to think about *edition interoperability*:

Consider the hypothetical case where the dependency crate has an older edition (and thus eager type aliases), it exports a type alias with bounds & a where-clause (which are void but technically valid), the dependent crate has the latest edition (and thus lazy type aliases) and it uses that type alias. Arguably, the bounds should *not* be checked since at any time, the dependency crate should be allowed to change the bounds at will with a *non*-major version bump & without negatively affecting downstream crates.

As for the reverse case (dependency: lazy type aliases, dependent: eager type aliases), I guess it rules out anything from slight confusion to mild annoyance from upstream crate authors that would be caused by the compiler ignoring the bounds of their type aliases in downstream crates with older editions.

---

This fixes #114468 since before, my assumption that the type alias associated with a given weak projection was lazy (and therefore had its variances computed) did not necessarily hold in cross-crate scenarios (which [I kinda had a hunch about](https://github.com/rust-lang/rust/pull/114253#discussion_r1278608099)) as outlined above. Now it does hold.

`@rustbot` label F-lazy_type_alias
r? `@oli-obk`
2023-08-08 03:30:56 +02:00
..
dep_graph replace few explicit use of parking_lot with rustc_data_structures::sync onces 2023-08-04 18:41:56 +03:00
ich Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
query Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, r=oli-obk 2023-08-08 03:30:56 +02:00
cache.rs Remove a fishy Clone impl 2023-04-04 09:01:44 +00:00
error.rs moved note as unspanned note, moved note to the bottom of the msg 2023-07-18 21:53:34 -04:00
lib.rs Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
values.rs Show which type was not specialized on query cycle misuse 2023-07-05 07:30:28 +00:00