Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use lifetime contravariance to elide more lifetimes in core+alloc+std #59056

Merged
merged 1 commit into from Mar 13, 2019

Conversation

Projects
None yet
4 participants
@scottmcm
Copy link
Member

scottmcm commented Mar 10, 2019

Sample:

-    impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
+    impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &mut A where A: PartialEq<B> {
         #[inline]
-        fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
+        fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) }
         #[inline]
-        fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
+        fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) }
     }

I didn't know this worked until recently, but since defining methods contravariantly in their lifetimes this way has worked back to Rust 1.0, we might as well take advantage of combining it with IHLE.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Mar 10, 2019

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Mar 10, 2019

@bors r+ rollup

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 10, 2019

📌 Commit df4ea90 has been approved by sfackler

Centril added a commit to Centril/rust that referenced this pull request Mar 10, 2019

Rollup merge of rust-lang#59056 - scottmcm:even-fewer-lifetimes, r=sf…
…ackler

Use lifetime contravariance to elide more lifetimes in core+alloc+std

Sample:
```diff
-    impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
+    impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &mut A where A: PartialEq<B> {
         #[inline]
-        fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
+        fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) }
         #[inline]
-        fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
+        fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) }
     }
```

[I didn't know this worked](https://internals.rust-lang.org/t/why-can-you-use-different-unconstrained-lifetimes-to-implement-traits/9544/2?u=scottmcm) until recently, but since defining methods contravariantly in their lifetimes this way has worked back to Rust 1.0, we might as well take advantage of combining it with IHLE.

Centril added a commit to Centril/rust that referenced this pull request Mar 10, 2019

Rollup merge of rust-lang#59056 - scottmcm:even-fewer-lifetimes, r=sf…
…ackler

Use lifetime contravariance to elide more lifetimes in core+alloc+std

Sample:
```diff
-    impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
+    impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &mut A where A: PartialEq<B> {
         #[inline]
-        fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
+        fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) }
         #[inline]
-        fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
+        fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) }
     }
```

[I didn't know this worked](https://internals.rust-lang.org/t/why-can-you-use-different-unconstrained-lifetimes-to-implement-traits/9544/2?u=scottmcm) until recently, but since defining methods contravariantly in their lifetimes this way has worked back to Rust 1.0, we might as well take advantage of combining it with IHLE.

bors added a commit that referenced this pull request Mar 10, 2019

Auto merge of #59067 - Centril:rollup, r=Centril
Rollup of 17 pull requests

Successful merges:

 - #58021 (Fix fallout from #57667)
 - #58330 (Add rustdoc JS non-std tests)
 - #58788 (Make migrate mode work at item level granularity)
 - #58789 (Update compiler_builtins to 0.1.7 to get windows/arm fix)
 - #58803 (fs::copy() linux: set file mode early)
 - #58829 (librustc_interface: Update scoped-tls to 1.0)
 - #58848 (Prevent cache issues on version updates)
 - #58855 (std: Spin for a global malloc lock on wasm32)
 - #58872 (Adds help message in error for invalid `impl for T` syntax)
 - #58876 (Parse lifetimes that start with a number and give specific error)
 - #58901 (Change `std::fs::copy` to use `copyfile` on MacOS and iOS)
 - #58938 (core: ensure VaList passes improper_ctypes lint)
 - #58941 (MIPS: add r6 support)
 - #59035 (When encountetring `||{}()`, suggest the likely intended `(||{})()`)
 - #59036 (Fix ICE in MIR pretty printing)
 - #59047 (resolve: Account for new importable entities)
 - #59056 (Use lifetime contravariance to elide more lifetimes in core+alloc+std)

Failed merges:

r? @ghost

Centril added a commit to Centril/rust that referenced this pull request Mar 10, 2019

Rollup merge of rust-lang#59056 - scottmcm:even-fewer-lifetimes, r=sf…
…ackler

Use lifetime contravariance to elide more lifetimes in core+alloc+std

Sample:
```diff
-    impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
+    impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &mut A where A: PartialEq<B> {
         #[inline]
-        fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
+        fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) }
         #[inline]
-        fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
+        fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) }
     }
```

[I didn't know this worked](https://internals.rust-lang.org/t/why-can-you-use-different-unconstrained-lifetimes-to-implement-traits/9544/2?u=scottmcm) until recently, but since defining methods contravariantly in their lifetimes this way has worked back to Rust 1.0, we might as well take advantage of combining it with IHLE.

bors added a commit that referenced this pull request Mar 10, 2019

Auto merge of #59069 - Centril:rollup, r=Centril
Rollup of 16 pull requests

Successful merges:

 - #58021 (Fix fallout from #57667)
 - #58330 (Add rustdoc JS non-std tests)
 - #58789 (Update compiler_builtins to 0.1.7 to get windows/arm fix)
 - #58803 (fs::copy() linux: set file mode early)
 - #58829 (librustc_interface: Update scoped-tls to 1.0)
 - #58848 (Prevent cache issues on version updates)
 - #58855 (std: Spin for a global malloc lock on wasm32)
 - #58872 (Adds help message in error for invalid `impl for T` syntax)
 - #58876 (Parse lifetimes that start with a number and give specific error)
 - #58901 (Change `std::fs::copy` to use `copyfile` on MacOS and iOS)
 - #58938 (core: ensure VaList passes improper_ctypes lint)
 - #58941 (MIPS: add r6 support)
 - #59035 (When encountetring `||{}()`, suggest the likely intended `(||{})()`)
 - #59036 (Fix ICE in MIR pretty printing)
 - #59047 (resolve: Account for new importable entities)
 - #59056 (Use lifetime contravariance to elide more lifetimes in core+alloc+std)

Failed merges:

r? @ghost

Centril added a commit to Centril/rust that referenced this pull request Mar 10, 2019

Rollup merge of rust-lang#59056 - scottmcm:even-fewer-lifetimes, r=sf…
…ackler

Use lifetime contravariance to elide more lifetimes in core+alloc+std

Sample:
```diff
-    impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
+    impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &mut A where A: PartialEq<B> {
         #[inline]
-        fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
+        fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) }
         #[inline]
-        fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
+        fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) }
     }
```

[I didn't know this worked](https://internals.rust-lang.org/t/why-can-you-use-different-unconstrained-lifetimes-to-implement-traits/9544/2?u=scottmcm) until recently, but since defining methods contravariantly in their lifetimes this way has worked back to Rust 1.0, we might as well take advantage of combining it with IHLE.

bors added a commit that referenced this pull request Mar 10, 2019

Auto merge of #59075 - Centril:rollup, r=Centril
Rollup of 17 pull requests

Successful merges:

 - #58021 (Fix fallout from #57667)
 - #58788 (Make migrate mode work at item level granularity)
 - #58789 (Update compiler_builtins to 0.1.7 to get windows/arm fix)
 - #58803 (fs::copy() linux: set file mode early)
 - #58829 (librustc_interface: Update scoped-tls to 1.0)
 - #58848 (Prevent cache issues on version updates)
 - #58855 (std: Spin for a global malloc lock on wasm32)
 - #58872 (Adds help message in error for invalid `impl for T` syntax)
 - #58876 (Parse lifetimes that start with a number and give specific error)
 - #58901 (Change `std::fs::copy` to use `copyfile` on MacOS and iOS)
 - #58938 (core: ensure VaList passes improper_ctypes lint)
 - #58941 (MIPS: add r6 support)
 - #59035 (When encountetring `||{}()`, suggest the likely intended `(||{})()`)
 - #59036 (Fix ICE in MIR pretty printing)
 - #59047 (resolve: Account for new importable entities)
 - #59056 (Use lifetime contravariance to elide more lifetimes in core+alloc+std)
 - #59072 (we can now skip should_panic tests with the libtest harness)

Failed merges:

r? @ghost

Centril added a commit to Centril/rust that referenced this pull request Mar 11, 2019

Rollup merge of rust-lang#59056 - scottmcm:even-fewer-lifetimes, r=sf…
…ackler

Use lifetime contravariance to elide more lifetimes in core+alloc+std

Sample:
```diff
-    impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
+    impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &mut A where A: PartialEq<B> {
         #[inline]
-        fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
+        fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) }
         #[inline]
-        fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
+        fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) }
     }
```

[I didn't know this worked](https://internals.rust-lang.org/t/why-can-you-use-different-unconstrained-lifetimes-to-implement-traits/9544/2?u=scottmcm) until recently, but since defining methods contravariantly in their lifetimes this way has worked back to Rust 1.0, we might as well take advantage of combining it with IHLE.

bors added a commit that referenced this pull request Mar 11, 2019

Auto merge of #59081 - Centril:rollup, r=Centril
Rollup of 15 pull requests

Successful merges:

 - #58021 (Fix fallout from #57667)
 - #58788 (Make migrate mode work at item level granularity)
 - #58789 (Update compiler_builtins to 0.1.7 to get windows/arm fix)
 - #58829 (librustc_interface: Update scoped-tls to 1.0)
 - #58848 (Prevent cache issues on version updates)
 - #58855 (std: Spin for a global malloc lock on wasm32)
 - #58872 (Adds help message in error for invalid `impl for T` syntax)
 - #58876 (Parse lifetimes that start with a number and give specific error)
 - #58938 (core: ensure VaList passes improper_ctypes lint)
 - #58941 (MIPS: add r6 support)
 - #59035 (When encountetring `||{}()`, suggest the likely intended `(||{})()`)
 - #59036 (Fix ICE in MIR pretty printing)
 - #59047 (resolve: Account for new importable entities)
 - #59056 (Use lifetime contravariance to elide more lifetimes in core+alloc+std)
 - #59072 (we can now skip should_panic tests with the libtest harness)

Failed merges:

r? @ghost

kennytm added a commit to kennytm/rust that referenced this pull request Mar 11, 2019

Rollup merge of rust-lang#59056 - scottmcm:even-fewer-lifetimes, r=sf…
…ackler

Use lifetime contravariance to elide more lifetimes in core+alloc+std

Sample:
```diff
-    impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
+    impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &mut A where A: PartialEq<B> {
         #[inline]
-        fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
+        fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) }
         #[inline]
-        fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
+        fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) }
     }
```

[I didn't know this worked](https://internals.rust-lang.org/t/why-can-you-use-different-unconstrained-lifetimes-to-implement-traits/9544/2?u=scottmcm) until recently, but since defining methods contravariantly in their lifetimes this way has worked back to Rust 1.0, we might as well take advantage of combining it with IHLE.

pietroalbini added a commit to pietroalbini/rust that referenced this pull request Mar 12, 2019

Rollup merge of rust-lang#59056 - scottmcm:even-fewer-lifetimes, r=sf…
…ackler

Use lifetime contravariance to elide more lifetimes in core+alloc+std

Sample:
```diff
-    impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
+    impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &mut A where A: PartialEq<B> {
         #[inline]
-        fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
+        fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) }
         #[inline]
-        fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
+        fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) }
     }
```

[I didn't know this worked](https://internals.rust-lang.org/t/why-can-you-use-different-unconstrained-lifetimes-to-implement-traits/9544/2?u=scottmcm) until recently, but since defining methods contravariantly in their lifetimes this way has worked back to Rust 1.0, we might as well take advantage of combining it with IHLE.

Centril added a commit to Centril/rust that referenced this pull request Mar 13, 2019

Rollup merge of rust-lang#59056 - scottmcm:even-fewer-lifetimes, r=sf…
…ackler

Use lifetime contravariance to elide more lifetimes in core+alloc+std

Sample:
```diff
-    impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
+    impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &mut A where A: PartialEq<B> {
         #[inline]
-        fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
+        fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) }
         #[inline]
-        fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
+        fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) }
     }
```

[I didn't know this worked](https://internals.rust-lang.org/t/why-can-you-use-different-unconstrained-lifetimes-to-implement-traits/9544/2?u=scottmcm) until recently, but since defining methods contravariantly in their lifetimes this way has worked back to Rust 1.0, we might as well take advantage of combining it with IHLE.

bors added a commit that referenced this pull request Mar 13, 2019

Auto merge of #59151 - Centril:rollup, r=Centril
Rollup of 16 pull requests

Successful merges:

 - #58829 (librustc_interface: Update scoped-tls to 1.0)
 - #58876 (Parse lifetimes that start with a number and give specific error)
 - #58908 (Update rand version)
 - #58998 (Fix documentation of from_ne_bytes and from_le_bytes)
 - #59056 (Use lifetime contravariance to elide more lifetimes in core+alloc+std)
 - #59057 (Standardize `Range*` documentation)
 - #59080 (Fix incorrect links in librustc_codegen_llvm documentation)
 - #59083 (Fix #54822 and associated faulty tests)
 - #59093 (Remove precompute_in_scope_traits_hashes)
 - #59101 (Reduces Code Repetitions like `!n >> amt`)
 - #59121 (impl FromIterator for Result: Use assert_eq! instead of assert!)
 - #59124 (Replace assert with assert_eq)
 - #59129 (Visit impl Trait for dead_code lint)
 - #59130 (Note that NonNull does not launder shared references for mutation)
 - #59132 (ignore higher-ranked object bound conditions created by WF)
 - #59138 (Simplify Iterator::{min, max})

Failed merges:

r? @ghost

@bors bors merged commit df4ea90 into rust-lang:master Mar 13, 2019

@scottmcm scottmcm deleted the scottmcm:even-fewer-lifetimes branch Mar 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.