Disallow non-explicit elided lifetimes in async fn#60388
Disallow non-explicit elided lifetimes in async fn#60388bors merged 1 commit intorust-lang:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
b72fa19 to
6b26bf9
Compare
nikomatsakis
left a comment
There was a problem hiding this comment.
Generally positive, but the error wording is a bit confusing. If we don't want to do the proper fix, then perhaps something like "help: use '_ to represent the elided lifetime explicitly"?
There was a problem hiding this comment.
This suggestion seems a bit confusing. It would be nicer, of course, to suggest HasLifetime<'_>, but this is also complicated to do. @zackmdavis put a quite a bit of work into these sorts of things as part of the lint, I wonder if we can reuse that code?
There was a problem hiding this comment.
I've put up a change to reuse the logic from the rust_2018_idioms elided lifetime parameters in types lint-- this gives a nice improvement for the impl headers case as well-- thanks for the recommendation! As a drive-by, I did notice that the error prints somewhat surprisingly:
#![deny(rust_2018_idioms)]
struct Foo<'a>(&'a u8);
fn foo(_: Foo) {}gives
error: hidden lifetime parameters in types are deprecated
--> src/main.rs:5:11
|
5 | fn foo(_: Foo) {}
| ^^^- help: indicate the anonymous lifetime: `<'_>`
Strangely, adding a type parameter makes it spell out the whole type:
#![deny(rust_2018_idioms)]
struct Foo<'a, T>(&'a T);
fn foo<T>(_: Foo<T>) {}error: hidden lifetime parameters in types are deprecated
--> src/main.rs:5:14
|
5 | fn foo<T>(_: Foo<T>) {}
| ^^^^^^ help: indicate the anonymous lifetime: `Foo<'_, T>`
Not sure if that's intended, but I found : <'_> a bit odd.
6b26bf9 to
c6e13bc
Compare
|
@bors r+ |
|
📌 Commit c6e13bc has been approved by |
…ikomatsakis Disallow non-explicit elided lifetimes in async fn Fix rust-lang#60203 r? @nikomatsakis
Rollup of 12 pull requests Successful merges: - #59928 (Make deprecation lint `ambiguous_associated_items` deny-by-default) - #60220 (report fatal errors during doctest parsing) - #60373 (Tidy: ensure lang features are sorted by since) - #60388 (Disallow non-explicit elided lifetimes in async fn) - #60393 ( Do not suggest incorrect syntax on pattern type error due to borrow) - #60401 (Rename `RUST_LOG` to `RUSTC_LOG`) - #60409 (Require a trait in the bounds of existential types) - #60455 (Resolve match arm ty when arms diverge) - #60457 (Const prop refactoring) - #60467 (Avoid repeated interning of static strings.) - #60478 (minor compiler doc tweaks) - #60501 (Propagate mutability from arguments to local bindings in async fn) Failed merges: r? @ghost
Fix #60203
r? @nikomatsakis