Uh oh!
There was an error while loading. Please reload this page.
Compute variances for lazy type aliases - #114253
Conversation
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
0e5d01b to
253495aCompareUh oh!
There was an error while loading. Please reload this page.
I'm pretty sure that all occurrences of I tried that locally and all UI tests succeeded except for
I don't think I know enough about TAITs to be able to fix point (1). @rustbot ready |
There was a problem hiding this comment.
Leave a comment explaining that we need to check the DefKind, because type_of(def_id) returns the type behind the alias, not ty::Alias(ty::Weak, ..)
oli-obk
commented
Aug 1, 2023
you could dump the variance ( Note that that test's RPIT equivalent does not compile (https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b00a68250b843d20bfa300f35fc7c29c) without also adding a |
253495a to
1abe10aCompare1abe10a to
33faad6Compare
This comment has been minimized.
This comment has been minimized.
33faad6 to
16e3b80Compare
This comment has been minimized.
This comment has been minimized.
16e3b80 to
6f5d855CompareThere was a problem hiding this comment.
why is this test affected? It has neither opaque types nor the lazy type alias feature gate
fmease
commented
Aug 3, 2023
Note that inherent associated types bound to type aliases now lead to cycle errors as previously touched upon. In the relevant UI tests I've replaced type aliases with functions wherever possible. Superficially the cycles are caused by the added I'm pretty sure those regressions are unavoidable at the present time. I plan on attempting an IAT rewrite at some point of which I'm not sure if it will pan out or not. |
oli-obk
commented
Aug 3, 2023
@bors r+ |
bors
commented
Aug 3, 2023
…ty-aliases, r=oli-obk Compute variances for lazy type aliases Fixesrust-lang#114221. CC `@oli-obk` r? types
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#114022 (Perform OpaqueCast field projection on HIR, too.) - rust-lang#114253 (Compute variances for lazy type aliases) - rust-lang#114355 (resolve before canonicalization in new solver, ICE if unresolved) - rust-lang#114427 (Handle non-utf8 rpaths (fix FIXME)) - rust-lang#114440 (bootstrap: config: fix version comparison bug) r? `@ghost` `@rustbot` modify labels: rollup
…e-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 fixesrust-lang#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](rust-lang#114253 (comment))) as outlined above. Now it does hold. `@rustbot` label F-lazy_type_alias r? `@oli-obk`
…c, 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](rust-lang/rust#114253 (comment))) as outlined above. Now it does hold. `@rustbot` label F-lazy_type_alias r? `@oli-obk`
Fixes#114221.
CC @oli-obk
r? types