diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-01-28 05:20:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-28 05:20:18 +0100 |
| commit | a5caa989c94f0a0ca3f977b013a1a7c2c2c5c3a0 (patch) | |
| tree | 58f37390e1e5146c188a26da7a508834ddf8d52e /compiler/rustc_codegen_gcc/example/std_example.rs | |
| parent | fa2cd945af6bfb14c16cfaa8b74c636dfb821b48 (diff) | |
| parent | 43cb610464393640a56fd7aa528c1c8f5b33ad0d (diff) | |
| download | rust-a5caa989c94f0a0ca3f977b013a1a7c2c2c5c3a0.tar.gz rust-a5caa989c94f0a0ca3f977b013a1a7c2c2c5c3a0.zip | |
Rollup merge of #107339 - aliemjay:covariant, r=lcnr
internally change regions to be covariant
Surprisingly, we consider the reference type `&'a T` to be contravaraint in its lifetime parameter. This is confusing and conflicts with the documentation we have in the reference, rustnomicon, and rustc-dev-guide. This also arguably not the correct use of terminology since we can use `&'static u8` in a place where `&' a u8` is expected, this implies that `&'static u8 <: &' a u8` and consequently `'static <: ' a`, hence covariance.
Because of this, when relating two types, we used to switch the argument positions in a confusing way:
`Subtype(&'a u8 <: &'b u8) => Subtype('b <: 'a) => Outlives('a: 'b) => RegionSubRegion('b <= 'a)`
The reason for the current behavior is probably that we wanted `Subtype('b <: 'a)` and `RegionSubRegion('b <= 'a)` to be equivalent, but I don' t think this is a good reason since these relations are sufficiently different in that the first is a relation in the subtyping lattice and is intrinsic to the type-systems, while the the second relation is an implementation detail of regionck.
This PR changes this behavior to use covariance, so..
`Subtype(&'a u8 <: &'b u8) => Subtype('a <: 'b) => Outlives('a: 'b) => RegionSubRegion('b <= 'a) `
Resolves #103676
r? `@lcnr`
Diffstat (limited to 'compiler/rustc_codegen_gcc/example/std_example.rs')
0 files changed, 0 insertions, 0 deletions
