Do not require 'static for obtaining reflection information.#152381
Do not require 'static for obtaining reflection information.#152381rust-bors[bot] merged 1 commit intorust-lang:mainfrom
'static for obtaining reflection information.#152381Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Don't have much capacity and going to unsubscribe from this PR, but rly, we should readd |
|
Of note, the typeid crate already implements a hacky way to get a TypeId representing a non-'static type. The crate has a lot of downloads. |
|
r=me unless we want T-lang/libs-api/xxx FCP or similar. |
|
Nope. It's entirely unstable and the point of this experiment is to demonstrate use cases and problematic situations, so now we can explore the latter, too @bors r=Mark-Simulacrum |
…uwer Rollup of 7 pull requests Successful merges: - #152622 (Update GCC subtree) - #145024 (Optimize indexing slices and strs with inclusive ranges) - #151365 (UnsafePinned: implement opsem effects of UnsafeUnpin) - #152381 (Do not require `'static` for obtaining reflection information.) - #143575 (Remove named lifetimes in some `PartialOrd` & `PartialEq` `impl`s) - #152404 (tests: adapt align-offset.rs for InstCombine improvements in LLVM 23) - #152582 (rustc_query_impl: Use `ControlFlow` in `visit_waiters` instead of nested options)
…uwer Rollup of 7 pull requests Successful merges: - #152622 (Update GCC subtree) - #145024 (Optimize indexing slices and strs with inclusive ranges) - #151365 (UnsafePinned: implement opsem effects of UnsafeUnpin) - #152381 (Do not require `'static` for obtaining reflection information.) - #143575 (Remove named lifetimes in some `PartialOrd` & `PartialEq` `impl`s) - #152404 (tests: adapt align-offset.rs for InstCombine improvements in LLVM 23) - #152582 (rustc_query_impl: Use `ControlFlow` in `visit_waiters` instead of nested options)
Rollup merge of #152381 - oli-obk:non_static_reflection, r=Mark-Simulacrum Do not require `'static` for obtaining reflection information. tracking issue #142577 This does not affect the stable `TypeId::of`, as that has its own `'static` bound. But it will allow obtaining `TypeId`s for non-static types via the reflection API. To obtain such a `TypeId` for any type, just use `Type::of::<(T,)>().kind` to extract the first field of a tuple. This effectively reintroduces #41875, which @rust-lang/lang decided against allowing back in 2018 due to lack of sound use cases. We will thus need to have a T-lang meeting specifically about `TypeId` for non-static types before *stabilizing* any part of reflection (in addition to T-lang meetings about reflection in general). I'm adding an explicit point about this to the tracking issue. cc @scottmcm @joshtriplett @9SonSteroids @SpriteOvO @izagawd @BD103
…uwer Rollup of 7 pull requests Successful merges: - rust-lang/rust#152622 (Update GCC subtree) - rust-lang/rust#145024 (Optimize indexing slices and strs with inclusive ranges) - rust-lang/rust#151365 (UnsafePinned: implement opsem effects of UnsafeUnpin) - rust-lang/rust#152381 (Do not require `'static` for obtaining reflection information.) - rust-lang/rust#143575 (Remove named lifetimes in some `PartialOrd` & `PartialEq` `impl`s) - rust-lang/rust#152404 (tests: adapt align-offset.rs for InstCombine improvements in LLVM 23) - rust-lang/rust#152582 (rustc_query_impl: Use `ControlFlow` in `visit_waiters` instead of nested options)
tracking issue #142577
This does not affect the stable
TypeId::of, as that has its own'staticbound.But it will allow obtaining
TypeIds for non-static types via the reflection API. To obtain such aTypeIdfor any type, just useType::of::<(T,)>().kindto extract the first field of a tuple.This effectively reintroduces #41875, which @rust-lang/lang decided against allowing back in 2018 due to lack of sound use cases. We will thus need to have a T-lang meeting specifically about
TypeIdfor non-static types before stabilizing any part of reflection (in addition to T-lang meetings about reflection in general). I'm adding an explicit point about this to the tracking issue.cc @scottmcm @joshtriplett @9SonSteroids @SpriteOvO @izagawd @BD103