-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Support pointers in type reflection #151119
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
Conversation
|
rustbot has assigned @JonathanBrouwer. Use |
|
r? @oli-obk |
|
|
e298be8 to
c0a4f8c
Compare
This comment has been minimized.
This comment has been minimized.
c0a4f8c to
2a7b6c5
Compare
This comment has been minimized.
This comment has been minimized.
feat: Support references in reflection type info Tracking issue: rust-lang#146922 `#![feature(type_info)]` Based on rust-lang#151119 implementation for pointers for consistency r? oli-obk
|
Needs a rebase |
2a7b6c5 to
f3afe60
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
tests/ui/reflection/dump.rs
Outdated
| &Unsized, &str, &[u8], | ||
| str, [u8], | ||
| &u8, &mut u8, | ||
| *const u8, *mut u8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we encountered problems with dumps in other PRs with these dumps let's not add more here. You already added assert tests, those are sufficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good call. Is there still a benefit in dump.rs, or can it be deleted? (In a follow-up PR.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should make sure there is sufficient other testing for the existing cases, but yea, that seems like the best
f3afe60 to
976cea3
Compare
|
@bors r+ rollup |
…uwer Rollup of 15 pull requests Successful merges: - #148623 (Ignore `#[doc(hidden)]` items when computing trimmed paths for printing) - #150550 (Miscellaneous cleanups to borrowck related code) - #150879 (Remove the diagnostic lints) - #150895 (rustc_errors: Add (heuristic) Syntax Highlighting for `rustc --explain`) - #150987 (remote-test-server: Fix header in batch mode) - #151004 (std: implement `sleep_until` on Apple platforms) - #151045 (Simplify some literal-value negations with `u128::wrapping_neg`) - #151119 (Support pointers in type reflection) - #151171 (Do not recover from `Trait()` if generic list is unterminated) - #151231 (HIR typeck cleanup: clarify and re-style `check_expr_unop`) - #151249 (Parse ident with allowing recovery when trying to diagnose) - #151295 (THIR patterns: Use `ty::Value` in more places throughout `const_to_pat`) - #151326 (Remove `DiagMessage::Translated` in favour of `DiagMessage::Str`) - #151361 (add test for issue 61463) - #151371 (Add `S-blocked` to `labels_blocking_approval`) r? @ghost
Rollup merge of #151119 - reflect-pointers, r=oli-obk Support pointers in type reflection Tracking issue: #146922 This PR adds support for inspecting pointers `*const T` and `*mut T` through type reflection. It does so by adding the new `Pointer` struct + variant: ```rust pub struct Pointer { /// The type of the value being pointed to. pub ty: TypeId, /// Whether this pointer is mutable or not. pub mutable: bool, } ``` This can be gathered using `Type::of`, for example: ```rust match const { Type::of::<*const u8>() }.kind { TypeKind::Pointer(pointer) => { assert_eq!(pointer.ty, TypeId::of::<u8>()); assert!(!pointer.mutable); } _ => unreachable!(), } ```
…uwer Rollup of 15 pull requests Successful merges: - rust-lang/rust#148623 (Ignore `#[doc(hidden)]` items when computing trimmed paths for printing) - rust-lang/rust#150550 (Miscellaneous cleanups to borrowck related code) - rust-lang/rust#150879 (Remove the diagnostic lints) - rust-lang/rust#150895 (rustc_errors: Add (heuristic) Syntax Highlighting for `rustc --explain`) - rust-lang/rust#150987 (remote-test-server: Fix header in batch mode) - rust-lang/rust#151004 (std: implement `sleep_until` on Apple platforms) - rust-lang/rust#151045 (Simplify some literal-value negations with `u128::wrapping_neg`) - rust-lang/rust#151119 (Support pointers in type reflection) - rust-lang/rust#151171 (Do not recover from `Trait()` if generic list is unterminated) - rust-lang/rust#151231 (HIR typeck cleanup: clarify and re-style `check_expr_unop`) - rust-lang/rust#151249 (Parse ident with allowing recovery when trying to diagnose) - rust-lang/rust#151295 (THIR patterns: Use `ty::Value` in more places throughout `const_to_pat`) - rust-lang/rust#151326 (Remove `DiagMessage::Translated` in favour of `DiagMessage::Str`) - rust-lang/rust#151361 (add test for issue 61463) - rust-lang/rust#151371 (Add `S-blocked` to `labels_blocking_approval`) r? @ghost
Tracking issue: #146922
This PR adds support for inspecting pointers
*const Tand*mut Tthrough type reflection. It does so by adding the newPointerstruct + variant:This can be gathered using
Type::of, for example: