From 0d9c01480b9142e9c0aea24500a9461c2bee5a68 Mon Sep 17 00:00:00 2001 From: Matthew Kelly Date: Mon, 26 Sep 2022 20:50:33 -0400 Subject: [PATCH] remove implied link bound per review also update .stderr outputs --- compiler/rustc_error_codes/src/error_codes/E0311.md | 4 +--- src/test/ui/error-codes/E0311.stderr | 4 ++-- .../suggest-introducing-and-adding-missing-lifetime.stderr | 1 + 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes/E0311.md b/compiler/rustc_error_codes/src/error_codes/E0311.md index 638c3e0a437..768b849817d 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0311.md +++ b/compiler/rustc_error_codes/src/error_codes/E0311.md @@ -26,9 +26,7 @@ type parameter `T` to outlive `'anon` because of the `T: 'a bound` in outlive `'anon` in `no_restriction()`. If `no_restriction()` were to use `&T` instead of `&()` as an argument, the -compiler would have added an implied bound [implied -bound](https://rust-lang.github.io/rfcs/2089-implied-bounds.html), causing this -to compile. +compiler would have added an implied bound, causing this to compile. This error can be resolved by explicitly naming the elided lifetime for `x` and then explicily requiring that the generic parameter `T` outlives that lifetime: diff --git a/src/test/ui/error-codes/E0311.stderr b/src/test/ui/error-codes/E0311.stderr index bc0182555af..9873b5ae6ff 100644 --- a/src/test/ui/error-codes/E0311.stderr +++ b/src/test/ui/error-codes/E0311.stderr @@ -16,8 +16,8 @@ LL | with_restriction::(x) | ^^^^^^^^^^^^^^^^^^^^^ help: consider adding an explicit lifetime bound... | -LL | fn no_restriction(x: &()) -> &() { - | ++++ +LL | fn no_restriction<'a, T: 'a>(x: &()) -> &() { + | +++ ++++ error: aborting due to previous error diff --git a/src/test/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr b/src/test/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr index a8b0996d8b0..31fd8a4d633 100644 --- a/src/test/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr +++ b/src/test/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr @@ -21,3 +21,4 @@ LL | fn no_restriction<'a, T: 'a>(x: &()) -> &() { error: aborting due to previous error +For more information about this error, try `rustc --explain E0311`.