rust/compiler/rustc_borrowck/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
..
constraints Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
diagnostics Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, r=oli-obk 2023-08-08 03:30:56 +02:00
region_infer don't ICE on higher ranked hidden types 2023-08-04 15:11:09 +00:00
type_check Rollup merge of #114022 - oli-obk:tait_ice_alias_field_projection, r=cjgillot 2023-08-04 09:18:58 +02:00
util Move some utils out of rustc_const_eval 2023-04-16 12:05:54 +02:00
borrow_set.rs address most easy comments 2023-06-20 20:55:31 +08:00
borrowck_errors.rs inline format!() args from rustc_codegen_llvm to the end (4) 2023-07-25 23:20:28 +02:00
constraint_generation.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
consumers.rs Move DefiningAnchor 2023-05-25 03:21:21 +00:00
dataflow.rs inline format!() args from rustc_codegen_llvm to the end (4) 2023-07-25 23:20:28 +02:00
def_use.rs unique borrows are mutating uses 2023-05-29 17:15:48 +02:00
facts.rs inline format!() args from rustc_codegen_llvm to the end (4) 2023-07-25 23:20:28 +02:00
invalidation.rs Only consider places with the same local in each_borrow_involving_path. 2023-06-27 17:57:10 +00:00
lib.rs Add internal_features lint 2023-08-03 14:50:50 +02:00
location.rs Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
member_constraints.rs remove unused muts 2023-04-28 20:19:48 +02:00
nll.rs inline format!() args from rustc_codegen_llvm to the end (4) 2023-07-25 23:20:28 +02:00
path_utils.rs Only consider places with the same local in each_borrow_involving_path. 2023-06-27 17:57:10 +00:00
place_ext.rs use PlaceRef abstractions more consistently 2023-06-25 20:38:01 -04:00
places_conflict.rs Extract the local != local case in borrow_conflicts_with_place. 2023-06-27 18:19:09 +00:00
prefixes.rs lint auto pass 2022-11-09 20:42:16 +08:00
renumber.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
session_diagnostics.rs Fix another strange suggestion span 2023-07-10 20:09:28 +00:00
universal_regions.rs Use upvar_tys in more places, make it a list 2023-08-01 23:19:31 +00:00
used_muts.rs Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiasko 2023-03-08 21:26:51 +01:00