3

Suggest adding a new lifetime parameter when two elided lifetimes should match u...

 2 years ago
source link: https://github.com/rust-lang/rust/pull/94464
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

..

})

| hir::Node::TraitItem(&hir::TraitItem { ref generics, .. })

| hir::Node::ImplItem(&hir::ImplItem { ref generics, .. }) => generics,

Copy link

Contributor

@estebank estebank 10 days ago

We should handle the impl case specifically with extra wording in the suggestion to let people know that they'll have to modify the trait as well. This is likely not a problem in practice, but I'd like us to be thorough and avoid confusing people.

It might be enough to just have a boolean flag that you use to modify the suggestion description with extra wording.

Copy link

Contributor

Author

@kckeiks kckeiks 10 days ago

Good call. I'll make that change.

estebank reacted with thumbs up emoji

Copy link

Contributor

Author

@kckeiks kckeiks 10 days ago

How about this for impl?

help: consider introducing a named lifetime parameter and update trait if needed
   |
32 |     fn foo<'a>(&'a self, x: &i32, z: &'a i32) -> Option<&i32> {
   |           ++++  ++                    ++

error: aborting due to previous error

For more information about this error, try `rustc --explain E0623`.

Copy link

Contributor

@estebank estebank 10 days ago

Ideally we would have something like "consider introducing a named lifetime parameter and update trait TraitName as necessary", by getting the TraitName from the parent DefId, but that can be left as follow up work.

kckeiks reacted with thumbs up emoji

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK