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

Explicit lifetime bound now required for Any #95028

Closed
Sytten opened this issue Mar 17, 2022 · 7 comments
Closed

Explicit lifetime bound now required for Any #95028

Sytten opened this issue Mar 17, 2022 · 7 comments

Comments

@Sytten
Copy link

Sytten commented Mar 17, 2022

This might be working as expected but I just wanted to report that builds of diesel started failing on nightly 2022-03-16 (commit 52b3455).

The lines in question are https://github.com/diesel-rs/diesel/blob/7184f128a3c1435d12b32f413b14b6632e2f753c/diesel/src/connection/mod.rs#L442-L477.

Here are the errors:

error[E0310]: the parameter type `DB` may not live long enough
   --> /home/runner/.cargo/git/checkouts/diesel-6e3331fb3b9331ec/c1b8ddc/diesel/src/connection/mod.rs:278:14
    |
267 | impl<DB: Backend> dyn BoxableConnection<DB> {
    |      --- help: consider adding an explicit lifetime bound...: `DB: 'static +`
...
278 |         self.as_any().downcast_ref::<T>()
    |              ^^^^^^ ...so that the type `(dyn BoxableConnection<DB> + 'static)` will meet its required lifetime bounds...
    |
note: ...that is required by this bound
   --> /home/runner/.cargo/git/checkouts/diesel-6e3331fb3b9331ec/c1b8ddc/diesel/src/connection/mod.rs:246:62
    |
246 | pub trait BoxableConnection<DB: Backend>: SimpleConnection + std::any::Any {
    |                                                              ^^^^^^^^^^^^^

error[E0310]: the parameter type `DB` may not live long enough
   --> /home/runner/.cargo/git/checkouts/diesel-6e3331fb3b9331ec/c1b8ddc/diesel/src/connection/mod.rs:291:14
    |
267 | impl<DB: Backend> dyn BoxableConnection<DB> {
    |      --- help: consider adding an explicit lifetime bound...: `DB: 'static +`
...
291 |         self.as_any_mut().downcast_mut::<T>()
    |              ^^^^^^^^^^ ...so that the type `(dyn BoxableConnection<DB> + 'static)` will meet its required lifetime bounds...
    |
note: ...that is required by this bound
   --> /home/runner/.cargo/git/checkouts/diesel-6e3331fb3b9331ec/c1b8ddc/diesel/src/connection/mod.rs:246:62
    |
246 | pub trait BoxableConnection<DB: Backend>: SimpleConnection + std::any::Any {
    |                                                              ^^^^^^^^^^^^^

error[E0310]: the parameter type `DB` may not live long enough
   --> /home/runner/.cargo/git/checkouts/diesel-6e3331fb3b9331ec/c1b8ddc/diesel/src/connection/mod.rs:300:14
    |
267 | impl<DB: Backend> dyn BoxableConnection<DB> {
    |      --- help: consider adding an explicit lifetime bound...: `DB: 'static +`
...
300 |         self.as_any().is::<T>()
    |              ^^^^^^ ...so that the type `(dyn BoxableConnection<DB> + 'static)` will meet its required lifetime bounds...
    |
note: ...that is required by this bound
   --> /home/runner/.cargo/git/checkouts/diesel-6e3331fb3b9331ec/c1b8ddc/diesel/src/connection/mod.rs:246:62
    |
246 | pub trait BoxableConnection<DB: Backend>: SimpleConnection + std::any::Any {
    |                                                              ^^^^^^^^^^^^^

This might be due to #92285

@compiler-errors
Copy link
Member

Yeah, this is a side-effect of #92285. :/

@Sytten
Copy link
Author

Sytten commented Mar 17, 2022

All good since it was probably a bug not to flag that. I pushed a fix to diesel. I do expect some people will come to report similar issues. I expect it will be in a changelog at some point.

@compiler-errors
Copy link
Member

compiler-errors commented Mar 17, 2022

Yes, it'll be in the release notes for 1.61 -- thanks for the report anyways! I'm curious if this will break any downstream usages in diesel. Please let us know if so.

@weiznich
Copy link
Contributor

I'm curious if this will break any downstream usages in diesel. Please let us know if so.

This breaks diesel itself, so any crate which depends on diesel cannot work due to the broken dependency. Fortunately no released diesel version is affected. Only the master branch contains the relevant code, so it should only affect those users which depend directly on the master. Those users need to expect breaking changes from diesels side anyway. That means from my point of view as diesel maintainer its totally fine to just go on with the planed release strategy for this fix.

@compiler-errors
Copy link
Member

compiler-errors commented Mar 17, 2022

@weiznich: sorry, when I meant "break downstream", I meant that I wonder if that PR (and the resulting changes to diesel) then require downstream crates to similarly need to add additional + 'static bounds, as opposed to just needing to fix up diesel itself at the library-level.

@weiznich
Copy link
Contributor

That likely depends a bit on the actual way the specific trait is used by downstream users. For non generic use cases it shouldn't be required to change anything. For the generic use case the additional bound is likely required. I expect that most users only use a version of that impl that uses a concrete type in place of the generic parameter, as the fully generic version is really hard to use.
In addition to that: As this only affects an explicitly unstable unreleased diesel version + an API that only exists there its fine for me to just change the API to whatever works.

@Sytten
Copy link
Author

Sytten commented Mar 18, 2022

Perfect! It's all fixed now so I will close.
Thanks for the input :)

@Sytten Sytten closed this as completed Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants