Skip to content

Bound Any with 'static #17132

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

Merged
merged 1 commit into from
Oct 1, 2014
Merged

Bound Any with 'static #17132

merged 1 commit into from
Oct 1, 2014

Conversation

reem
Copy link
Contributor

@reem reem commented Sep 9, 2014

This bound is already implicit through the AnyPrivate trait,
but since it is not explicit, you still have to write Box<Any + 'static>,
even though Any can only be 'static.

Introducing the 'static bound here makes this bound explicit, making
Box legal.

@alexcrichton
Copy link
Member

Closing to see if this unsticks bors.

@alexcrichton
Copy link
Member

Don't think this was it.

@alexcrichton alexcrichton reopened this Sep 15, 2014
@alexcrichton
Copy link
Member

Closing due to inactivity, but feel free to reopen with the issue addressed!

@reem
Copy link
Contributor Author

reem commented Sep 29, 2014

@alexcrichton not clear on why this has been closed. You tried to merge it earlier.

@alexcrichton
Copy link
Member

Ah the build failed:

/home/ubuntu/src/rust-buildbot/slave/auto-linux-64-nopt-c/build/src/libcore/any.rs:188:12: 188:16 error: mismatched types: expected `&any::Any+'static`, found `&any::Any+'a` (lifetime mismatch)
/home/ubuntu/src/rust-buildbot/slave/auto-linux-64-nopt-c/build/src/libcore/any.rs:188         if self.is::<T>() {
                                                                                                  ^~~~
/home/ubuntu/src/rust-buildbot/slave/auto-linux-64-nopt-c/build/src/libcore/any.rs:187:60: 199:6 note: the lifetime 'a as defined on the block at 187:59...
/home/ubuntu/src/rust-buildbot/slave/auto-linux-64-nopt-c/build/src/libcore/any.rs:187     fn downcast_mut<T: 'static>(self) -> Option<&'a mut T> {
/home/ubuntu/src/rust-buildbot/slave/auto-linux-64-nopt-c/build/src/libcore/any.rs:188         if self.is::<T>() {
/home/ubuntu/src/rust-buildbot/slave/auto-linux-64-nopt-c/build/src/libcore/any.rs:189             unsafe {
/home/ubuntu/src/rust-buildbot/slave/auto-linux-64-nopt-c/build/src/libcore/any.rs:190                 // Get the raw representation of the trait object
/home/ubuntu/src/rust-buildbot/slave/auto-linux-64-nopt-c/build/src/libcore/any.rs:191                 let to: TraitObject = transmute_copy(&self);
/home/ubuntu/src/rust-buildbot/slave/auto-linux-64-nopt-c/build/src/libcore/any.rs:192 
                                                                                       ...
note: ...does not necessarily outlive the static lifetime
error: aborting due to previous error
make: *** [x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/stamp.core] Error 101
program finished with exit code 2

Do you want me to reopen?

@reem
Copy link
Contributor Author

reem commented Sep 29, 2014

Oh, that's weird, it built for me locally. If you reopen I will update the PR.

@alexcrichton alexcrichton reopened this Sep 30, 2014
This bound is already implicit through the AnyPrivate trait,
but since it is not explicit, you still have to write Box<Any + 'static>,
even though Any can only be 'static.

Introducing the 'static bound here makes this bound explicit, making
Box<Any> legal.
@reem reem force-pushed the any-static-bound branch from c47a0bc to 0cf60b6 Compare October 1, 2014 01:40
@reem
Copy link
Contributor Author

reem commented Oct 1, 2014

@alexcrichton I believe I fixed it.

bors added a commit that referenced this pull request Oct 1, 2014
This bound is already implicit through the AnyPrivate trait,
but since it is not explicit, you still have to write Box<Any + 'static>,
even though Any can only be 'static.

Introducing the 'static bound here makes this bound explicit, making
Box<Any> legal.
@bors bors closed this Oct 1, 2014
@bors bors merged commit 0cf60b6 into rust-lang:master Oct 1, 2014
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

Successfully merging this pull request may close these issues.

3 participants