Point at explicit 'static
obligations on a trait by estebank · Pull Request #129070 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation9 Commits1 Checks6 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Given trait Any: 'static
and a struct
with a Box<dyn Any + 'a>
field, point at the 'static
bound in Any
to explain why 'a: 'static
.
error[E0478]: lifetime bound not satisfied
--> f202.rs:2:12
|
2 | value: Box<dyn std::any::Any + 'a>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the lifetime `'a` as defined here
--> f202.rs:1:14
|
1 | struct Hello<'a> {
| ^^
note: but lifetime parameter must outlive the static lifetime
--> /home/gh-estebank/rust/library/core/src/any.rs:113:16
|
113 | pub trait Any: 'static {
| ^^^^^^^
Partially address #33652.
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
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Comment on lines +12 to +13
note: but lifetime parameter must outlive the static lifetime |
---|
--> $SRC_DIR/core/src/any.rs:LL:COL |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locally this actually show the right span, not sure why the stderr doesn't show it correctly.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably has to do with the sorting of the entries. Try to put the Option<Ty>
first?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, no, because we strip standard library sources in UI tests.
Comment on lines +15 to +27
| error[E0310]: the parameter type `T` may not live long enough | | | -------------------------------------------------------------------- | | | --> $DIR/explicit-static-bound-on-trait.rs:8:23 | | | | | | | LL | Self { value: Box::new(value) } | | | | ^^^^^^^^^^^^^^^ | | | | | | | | the parameter type `T` must be valid for the static lifetime... | | | | ...so that the type `T` will meet its required lifetime bounds | | | | | | | help: consider adding an explicit lifetime bound | | | | | | | LL | fn new<T: 'a + 'static>(value: T) -> Self { | | | | +++++++++ | |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual error that we should add context for in order to also support traits that are implicitly 'static
because of the trait.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, r=me unless you want to experiment with compiler-errors' suggestions or your other comment isn't just something you intend to follow-up with.
Given trait Any: 'static
and a struct
with a Box<dyn Any + 'a>
field, point at the 'static
bound in Any
to explain why 'a: 'static
.
error[E0478]: lifetime bound not satisfied
--> f202.rs:2:12
|
2 | value: Box<dyn std::any::Any + 'a>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the lifetime `'a` as defined here
--> f202.rs:1:14
|
1 | struct Hello<'a> {
| ^^
note: but lifetime parameter must outlive the static lifetime
--> /home/gh-estebank/rust/library/core/src/any.rs:113:16
|
113 | pub trait Any: 'static {
| ^^^^^^^
Partially address rust-lang#33652.
📌 Commit f5bae72 has been approved by davidtwco
It is now in the queue for this repository.
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
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 9 pull requests
Successful merges:
- rust-lang#127279 (use old ctx if has same expand environment during decode span)
- rust-lang#127945 (Implement
debug_more_non_exhaustive
) - rust-lang#128941 ( Improve diagnostic-related lints:
untranslatable_diagnostic
&diagnostic_outside_of_impl
) - rust-lang#129070 (Point at explicit
'static
obligations on a trait) - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation)
- rust-lang#129231 (improve submodule updates)
- rust-lang#129264 (Update
library/Cargo.toml
in weekly job) - rust-lang#129284 (rustdoc: animate the
:target
highlight) - rust-lang#129302 (compiletest: use
std::fs::remove_dir_all
now that it is available)
r? @ghost
@rustbot
modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 9 pull requests
Successful merges:
- rust-lang#127279 (use old ctx if has same expand environment during decode span)
- rust-lang#127945 (Implement
debug_more_non_exhaustive
) - rust-lang#128941 ( Improve diagnostic-related lints:
untranslatable_diagnostic
&diagnostic_outside_of_impl
) - rust-lang#129070 (Point at explicit
'static
obligations on a trait) - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation)
- rust-lang#129231 (improve submodule updates)
- rust-lang#129264 (Update
library/Cargo.toml
in weekly job) - rust-lang#129284 (rustdoc: animate the
:target
highlight) - rust-lang#129302 (compiletest: use
std::fs::remove_dir_all
now that it is available)
r? @ghost
@rustbot
modify labels: rollup
jieyouxu added a commit to jieyouxu/rust that referenced this pull request
Point at explicit 'static
obligations on a trait
Given trait Any: 'static
and a struct
with a Box<dyn Any + 'a>
field, point at the 'static
bound in Any
to explain why 'a: 'static
.
error[E0478]: lifetime bound not satisfied
--> f202.rs:2:12
|
2 | value: Box<dyn std::any::Any + 'a>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the lifetime `'a` as defined here
--> f202.rs:1:14
|
1 | struct Hello<'a> {
| ^^
note: but lifetime parameter must outlive the static lifetime
--> /home/gh-estebank/rust/library/core/src/any.rs:113:16
|
113 | pub trait Any: 'static {
| ^^^^^^^
Partially address rust-lang#33652.
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 9 pull requests
Successful merges:
- rust-lang#127279 (use old ctx if has same expand environment during decode span)
- rust-lang#127945 (Implement
debug_more_non_exhaustive
) - rust-lang#128941 ( Improve diagnostic-related lints:
untranslatable_diagnostic
&diagnostic_outside_of_impl
) - rust-lang#129070 (Point at explicit
'static
obligations on a trait) - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation)
- rust-lang#129231 (improve submodule updates)
- rust-lang#129264 (Update
library/Cargo.toml
in weekly job) - rust-lang#129284 (rustdoc: animate the
:target
highlight) - rust-lang#129302 (compiletest: use
std::fs::remove_dir_all
now that it is available)
r? @ghost
@rustbot
modify labels: rollup
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
Rollup merge of rust-lang#129070 - estebank:static-trait, r=davidtwco
Point at explicit 'static
obligations on a trait
Given trait Any: 'static
and a struct
with a Box<dyn Any + 'a>
field, point at the 'static
bound in Any
to explain why 'a: 'static
.
error[E0478]: lifetime bound not satisfied
--> f202.rs:2:12
|
2 | value: Box<dyn std::any::Any + 'a>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the lifetime `'a` as defined here
--> f202.rs:1:14
|
1 | struct Hello<'a> {
| ^^
note: but lifetime parameter must outlive the static lifetime
--> /home/gh-estebank/rust/library/core/src/any.rs:113:16
|
113 | pub trait Any: 'static {
| ^^^^^^^
Partially address rust-lang#33652.
Labels
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the compiler team, which will review and decide on the PR/issue.