remove implied link bound per review
also update .stderr outputs
This commit is contained in:
parent
24aab524cb
commit
0d9c01480b
3 changed files with 4 additions and 5 deletions
|
@ -26,9 +26,7 @@ type parameter `T` to outlive `'anon` because of the `T: 'a bound` in
|
||||||
outlive `'anon` in `no_restriction()`.
|
outlive `'anon` in `no_restriction()`.
|
||||||
|
|
||||||
If `no_restriction()` were to use `&T` instead of `&()` as an argument, the
|
If `no_restriction()` were to use `&T` instead of `&()` as an argument, the
|
||||||
compiler would have added an implied bound [implied
|
compiler would have added an implied bound, causing this to compile.
|
||||||
bound](https://rust-lang.github.io/rfcs/2089-implied-bounds.html), causing this
|
|
||||||
to compile.
|
|
||||||
|
|
||||||
This error can be resolved by explicitly naming the elided lifetime for `x` and
|
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:
|
then explicily requiring that the generic parameter `T` outlives that lifetime:
|
||||||
|
|
|
@ -16,8 +16,8 @@ LL | with_restriction::<T>(x)
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
help: consider adding an explicit lifetime bound...
|
help: consider adding an explicit lifetime bound...
|
||||||
|
|
|
|
||||||
LL | fn no_restriction<T: 'a>(x: &()) -> &() {
|
LL | fn no_restriction<'a, T: 'a>(x: &()) -> &() {
|
||||||
| ++++
|
| +++ ++++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -21,3 +21,4 @@ LL | fn no_restriction<'a, T: 'a>(x: &()) -> &() {
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0311`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue