rust/compiler/rustc_middle/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 inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
hir Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, r=oli-obk 2023-08-08 03:30:56 +02:00
infer refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
middle inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
mir Rollup merge of #114505 - ouz-a:cleanup_mir, r=RalfJung 2023-08-06 17:26:29 +02:00
query Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, r=oli-obk 2023-08-08 03:30:56 +02:00
thir refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
traits Rollup merge of #114287 - lcnr:overflow, r=compiler-errors 2023-08-04 19:47:38 -07:00
ty Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, r=oli-obk 2023-08-08 03:30:56 +02:00
util inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
arena.rs Migrate predicates_of and caller_bounds to Clause 2023-06-26 23:12:03 +00:00
error.rs Don't attempt to compute layout of type referencing error 2023-07-27 18:24:08 +00:00
lib.rs Add internal_features lint 2023-08-03 14:50:50 +02:00
lint.rs fix RedundantLocals clippy caused by async and await 2023-08-02 16:32:49 +08:00
macros.rs Make everything builtin! 2023-07-25 16:08:58 +00:00
metadata.rs rustc_metadata: Remove Span from ModChild 2023-04-18 17:25:04 +03:00
tests.rs
thir.rs inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
values.rs Store the laziness of type aliases in the DefKind 2023-08-07 15:54:31 +02:00