Skip to content

Conversation

@estebank
Copy link
Contributor

@estebank estebank commented Nov 4, 2025

error[E0310]: the parameter type `R` may not live long enough
  --> $DIR/implicit-static-lifetime-in-dyn-trait-return-type.rs:10:5
   |
LL | fn bb<R>(r: R) -> Box<dyn Foo> {
   |                       ------- this `dyn Trait` has an implicit `'static` lifetime bound
LL |     Box::new(Bar(r))
   |     ^^^^^^^^^^^^^^^^
   |     |
   |     the parameter type `R` must be valid for the static lifetime...
   |     ...so that the type `R` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL | fn bb<R: 'static>(r: R) -> Box<dyn Foo> {
   |        +++++++++

Partly address #41966 and #54753. #103849, which shows a case where there's an intermediary binding, is not addressed at all, as aren't cases other than Box<dyn Trait> return type.

… Box<dyn Trait>`

```
error[E0310]: the parameter type `R` may not live long enough
  --> $DIR/implicit-static-lifetime-in-dyn-trait-return-type.rs:10:5
   |
LL | fn bb<R>(r: R) -> Box<dyn Foo> {
   |                       ------- this `dyn Trait` has an implicit `'static` lifetime bound
LL |     Box::new(Bar(r))
   |     ^^^^^^^^^^^^^^^^
   |     |
   |     the parameter type `R` must be valid for the static lifetime...
   |     ...so that the type `R` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL | fn bb<R: 'static>(r: R) -> Box<dyn Foo> {
   |        +++++++++
```
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 4, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@davidtwco
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Nov 10, 2025

📌 Commit a49d4d7 has been approved by davidtwco

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 10, 2025
ChrisDenton added a commit to ChrisDenton/rust that referenced this pull request Nov 10, 2025
Special case detecting `'static` lifetime requirement coming from `-> Box<dyn Trait>`

```
error[E0310]: the parameter type `R` may not live long enough
  --> $DIR/implicit-static-lifetime-in-dyn-trait-return-type.rs:10:5
   |
LL | fn bb<R>(r: R) -> Box<dyn Foo> {
   |                       ------- this `dyn Trait` has an implicit `'static` lifetime bound
LL |     Box::new(Bar(r))
   |     ^^^^^^^^^^^^^^^^
   |     |
   |     the parameter type `R` must be valid for the static lifetime...
   |     ...so that the type `R` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL | fn bb<R: 'static>(r: R) -> Box<dyn Foo> {
   |        +++++++++
```

Partly address rust-lang#41966 and rust-lang#54753. rust-lang#103849, which shows a case where there's an intermediary binding, is not addressed at all, as aren't cases *other* than `Box<dyn Trait>` return type.
ChrisDenton added a commit to ChrisDenton/rust that referenced this pull request Nov 10, 2025
Special case detecting `'static` lifetime requirement coming from `-> Box<dyn Trait>`

```
error[E0310]: the parameter type `R` may not live long enough
  --> $DIR/implicit-static-lifetime-in-dyn-trait-return-type.rs:10:5
   |
LL | fn bb<R>(r: R) -> Box<dyn Foo> {
   |                       ------- this `dyn Trait` has an implicit `'static` lifetime bound
LL |     Box::new(Bar(r))
   |     ^^^^^^^^^^^^^^^^
   |     |
   |     the parameter type `R` must be valid for the static lifetime...
   |     ...so that the type `R` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL | fn bb<R: 'static>(r: R) -> Box<dyn Foo> {
   |        +++++++++
```

Partly address rust-lang#41966 and rust-lang#54753. rust-lang#103849, which shows a case where there's an intermediary binding, is not addressed at all, as aren't cases *other* than `Box<dyn Trait>` return type.
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 11, 2025
Special case detecting `'static` lifetime requirement coming from `-> Box<dyn Trait>`

```
error[E0310]: the parameter type `R` may not live long enough
  --> $DIR/implicit-static-lifetime-in-dyn-trait-return-type.rs:10:5
   |
LL | fn bb<R>(r: R) -> Box<dyn Foo> {
   |                       ------- this `dyn Trait` has an implicit `'static` lifetime bound
LL |     Box::new(Bar(r))
   |     ^^^^^^^^^^^^^^^^
   |     |
   |     the parameter type `R` must be valid for the static lifetime...
   |     ...so that the type `R` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL | fn bb<R: 'static>(r: R) -> Box<dyn Foo> {
   |        +++++++++
```

Partly address rust-lang#41966 and rust-lang#54753. rust-lang#103849, which shows a case where there's an intermediary binding, is not addressed at all, as aren't cases *other* than `Box<dyn Trait>` return type.
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 11, 2025
Special case detecting `'static` lifetime requirement coming from `-> Box<dyn Trait>`

```
error[E0310]: the parameter type `R` may not live long enough
  --> $DIR/implicit-static-lifetime-in-dyn-trait-return-type.rs:10:5
   |
LL | fn bb<R>(r: R) -> Box<dyn Foo> {
   |                       ------- this `dyn Trait` has an implicit `'static` lifetime bound
LL |     Box::new(Bar(r))
   |     ^^^^^^^^^^^^^^^^
   |     |
   |     the parameter type `R` must be valid for the static lifetime...
   |     ...so that the type `R` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL | fn bb<R: 'static>(r: R) -> Box<dyn Foo> {
   |        +++++++++
```

Partly address rust-lang#41966 and rust-lang#54753. rust-lang#103849, which shows a case where there's an intermediary binding, is not addressed at all, as aren't cases *other* than `Box<dyn Trait>` return type.
bors added a commit that referenced this pull request Nov 11, 2025
Rollup of 16 pull requests

Successful merges:

 - #141470 (Add new `function_casts_as_integer` lint)
 - #143619 (`c_variadic`: Add future-incompatibility warning for `...` arguments without a pattern outside of `extern` blocks)
 - #146495 (rustdoc: Erase `#![doc(document_private_items)]`)
 - #147771 (Rename `*exact_{div,shr,shl}` to `*{div,shr,shl}_exact`)
 - #147833 (rustdoc-json: move `target` to `json::conversions`)
 - #147952 (Add a timeout to the `remote-test-client` connection)
 - #147955 (compiletest: Migrate `TestProps` directive handling to a system of named handlers)
 - #148480 (Add `Steal::risky_hack_borrow_mut`)
 - #148506 (Special case detecting `'static` lifetime requirement coming from `-> Box<dyn Trait>`)
 - #148508 (Provide more context when mutably borrowing an imutably borrowed value)
 - #148530 (update the bootstrap readme)
 - #148608 (Add test for --test-builder success path)
 - #148636 (bootstrap: respect `build.python` on macOS)
 - #148639 (test(rustdoc): move tests into jump-to-def)
 - #148647 (Check unsafety for non-macro attributes in `validate_attr`)
 - #148667 (a few small clippy fixes)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Nov 11, 2025
Rollup of 16 pull requests

Successful merges:

 - #141470 (Add new `function_casts_as_integer` lint)
 - #143619 (`c_variadic`: Add future-incompatibility warning for `...` arguments without a pattern outside of `extern` blocks)
 - #146495 (rustdoc: Erase `#![doc(document_private_items)]`)
 - #147771 (Rename `*exact_{div,shr,shl}` to `*{div,shr,shl}_exact`)
 - #147833 (rustdoc-json: move `target` to `json::conversions`)
 - #147952 (Add a timeout to the `remote-test-client` connection)
 - #147955 (compiletest: Migrate `TestProps` directive handling to a system of named handlers)
 - #148480 (Add `Steal::risky_hack_borrow_mut`)
 - #148506 (Special case detecting `'static` lifetime requirement coming from `-> Box<dyn Trait>`)
 - #148508 (Provide more context when mutably borrowing an imutably borrowed value)
 - #148530 (update the bootstrap readme)
 - #148608 (Add test for --test-builder success path)
 - #148636 (bootstrap: respect `build.python` on macOS)
 - #148639 (test(rustdoc): move tests into jump-to-def)
 - #148647 (Check unsafety for non-macro attributes in `validate_attr`)
 - #148667 (a few small clippy fixes)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Nov 11, 2025
Rollup of 15 pull requests

Successful merges:

 - #141470 (Add new `function_casts_as_integer` lint)
 - #143619 (`c_variadic`: Add future-incompatibility warning for `...` arguments without a pattern outside of `extern` blocks)
 - #146495 (rustdoc: Erase `#![doc(document_private_items)]`)
 - #147771 (Rename `*exact_{div,shr,shl}` to `*{div,shr,shl}_exact`)
 - #147833 (rustdoc-json: move `target` to `json::conversions`)
 - #147955 (compiletest: Migrate `TestProps` directive handling to a system of named handlers)
 - #148480 (Add `Steal::risky_hack_borrow_mut`)
 - #148506 (Special case detecting `'static` lifetime requirement coming from `-> Box<dyn Trait>`)
 - #148508 (Provide more context when mutably borrowing an imutably borrowed value)
 - #148530 (update the bootstrap readme)
 - #148608 (Add test for --test-builder success path)
 - #148636 (bootstrap: respect `build.python` on macOS)
 - #148639 (test(rustdoc): move tests into jump-to-def)
 - #148647 (Check unsafety for non-macro attributes in `validate_attr`)
 - #148667 (a few small clippy fixes)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit eb415e9 into rust-lang:main Nov 11, 2025
11 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 11, 2025
rust-timer added a commit that referenced this pull request Nov 11, 2025
Rollup merge of #148506 - estebank:issue-41966, r=davidtwco

Special case detecting `'static` lifetime requirement coming from `-> Box<dyn Trait>`

```
error[E0310]: the parameter type `R` may not live long enough
  --> $DIR/implicit-static-lifetime-in-dyn-trait-return-type.rs:10:5
   |
LL | fn bb<R>(r: R) -> Box<dyn Foo> {
   |                       ------- this `dyn Trait` has an implicit `'static` lifetime bound
LL |     Box::new(Bar(r))
   |     ^^^^^^^^^^^^^^^^
   |     |
   |     the parameter type `R` must be valid for the static lifetime...
   |     ...so that the type `R` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL | fn bb<R: 'static>(r: R) -> Box<dyn Foo> {
   |        +++++++++
```

Partly address #41966 and #54753. #103849, which shows a case where there's an intermediary binding, is not addressed at all, as aren't cases *other* than `Box<dyn Trait>` return type.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Nov 12, 2025
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#141470 (Add new `function_casts_as_integer` lint)
 - rust-lang/rust#143619 (`c_variadic`: Add future-incompatibility warning for `...` arguments without a pattern outside of `extern` blocks)
 - rust-lang/rust#146495 (rustdoc: Erase `#![doc(document_private_items)]`)
 - rust-lang/rust#147771 (Rename `*exact_{div,shr,shl}` to `*{div,shr,shl}_exact`)
 - rust-lang/rust#147833 (rustdoc-json: move `target` to `json::conversions`)
 - rust-lang/rust#147955 (compiletest: Migrate `TestProps` directive handling to a system of named handlers)
 - rust-lang/rust#148480 (Add `Steal::risky_hack_borrow_mut`)
 - rust-lang/rust#148506 (Special case detecting `'static` lifetime requirement coming from `-> Box<dyn Trait>`)
 - rust-lang/rust#148508 (Provide more context when mutably borrowing an imutably borrowed value)
 - rust-lang/rust#148530 (update the bootstrap readme)
 - rust-lang/rust#148608 (Add test for --test-builder success path)
 - rust-lang/rust#148636 (bootstrap: respect `build.python` on macOS)
 - rust-lang/rust#148639 (test(rustdoc): move tests into jump-to-def)
 - rust-lang/rust#148647 (Check unsafety for non-macro attributes in `validate_attr`)
 - rust-lang/rust#148667 (a few small clippy fixes)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants