-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add "type_name" support in emulate_intrinsic() #61399
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
Closed
Closed
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
d3d82b0
Add "type_name" support in emulate_intrinsic()
TankhouseAle 271cf97
Fix whitespace, change "value" to "name_val"
TankhouseAle 67b3fde
Add a test, as suggested.
TankhouseAle d0cc41d
Do an actual check with assert_eq, as suggested.
TankhouseAle d6e63a3
Adapt implementation to "deterministic type_name"
TankhouseAle cce1392
We need "tcx.tcx", not just "tcx"
TankhouseAle 82215e2
The last commit certainly didn't do what I thought it did.
TankhouseAle 0f0ad45
Can't have ConstValue without ConstValue!
TankhouseAle 892bc65
Move a brace up to be more consistent.
TankhouseAle 19a3814
Add the suggested utility function to type_name.rs
TankhouseAle 11da537
Use the new function to implement type_name
TankhouseAle 78d5c38
Use Immediate and Pointer, but not ConstValue
TankhouseAle fe40101
Actually for real use Immediate and Pointer
TankhouseAle dfb8dbd
Make Tidy happy
TankhouseAle 04736f5
Make Tidy happy
TankhouseAle c326ef1
Literally just remove a single space
TankhouseAle a58a557
Don't need to use Pointer if we do name_id.into()
TankhouseAle 04946c7
Add line break as suggested
TankhouseAle 9a0c77c
Use alloc_type_name() in type_name()
TankhouseAle 9b2d648
Maybe it will merge this way?
TankhouseAle 0a9047b
Change this back temporarily
TankhouseAle c3ef5a5
Merge pull request #2 from rust-lang/master
TankhouseAle 43ba61a
Put my changes back in
TankhouseAle 1c8ce6d
Fix duplicated bounds printing in rustdoc (#4)
TankhouseAle 430f4a6
Update from master
TankhouseAle bbb209d
Merge pull request #8 from rust-lang/master
TankhouseAle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// run-pass | ||
|
||
#![feature(core_intrinsics)] | ||
#![feature(const_fn)] | ||
#![allow(dead_code)] | ||
|
||
const fn type_name_wrapper<T>(_: &T) -> &'static str { | ||
unsafe { core::intrinsics::type_name::<T>() } | ||
RalfJung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
struct Struct<TA, TB, TC> { | ||
a: TA, | ||
b: TB, | ||
c: TC, | ||
} | ||
|
||
type StructInstantiation = Struct<i8, f64, bool>; | ||
|
||
const CONST_STRUCT: StructInstantiation = StructInstantiation { | ||
a: 12, | ||
b: 13.7, | ||
c: false, | ||
}; | ||
|
||
const CONST_STRUCT_NAME: &'static str = type_name_wrapper(&CONST_STRUCT); | ||
|
||
fn main() { | ||
let non_const_struct = StructInstantiation { | ||
a: 87, | ||
b: 65.99, | ||
c: true, | ||
}; | ||
|
||
let non_const_struct_name = type_name_wrapper(&non_const_struct); | ||
|
||
assert_eq!(CONST_STRUCT_NAME, non_const_struct_name); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.