-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Initial implementation of transmutability trait. #92268
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bc4a1de
Initial (incomplete) implementation of transmutability trait.
jswrenn 18751a7
safe transmute: gracefully handle const params of wrong types
jswrenn 8c5c291
safe transmute: test when `ASSUME` params are passed indirectly
jswrenn 0fa70c3
safe transmute: revise `Hash`, `PartialEq` impls on `VariantDef`, `Fi…
jswrenn c0d0ce9
safe transmute: tweak tracing
jswrenn 4a15157
safe transmute: don't mark user impls as unambiguous
jswrenn 402644f
safe transmute: test to ensure that trait is correctly feature-gated
jswrenn 21d1ab4
safe transmute: add `rustc_on_unimplemented` to `BikeshedIntrinsicFrom`
jswrenn b78c3da
safe transmute: reference tracking issue
jswrenn 2268603
safe transmute: tweak `Nfa::union` to consume params by value
jswrenn aee5f31
safe transmute: lowercase tracing levels
jswrenn e8a1925
safe transmute: use `AtomicU32` `State` ids to appease mips
jswrenn 965ffb0
safe transmute: fix broken intradoc link
jswrenn 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
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
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
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,28 @@ | ||
[package] | ||
name = "rustc_transmute" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
tracing = "0.1" | ||
rustc_data_structures = { path = "../rustc_data_structures", optional = true} | ||
rustc_infer = { path = "../rustc_infer", optional = true} | ||
rustc_macros = { path = "../rustc_macros", optional = true} | ||
rustc_middle = { path = "../rustc_middle", optional = true} | ||
rustc_span = { path = "../rustc_span", optional = true} | ||
rustc_target = { path = "../rustc_target", optional = true} | ||
|
||
[features] | ||
rustc = [ | ||
"rustc_middle", | ||
"rustc_data_structures", | ||
"rustc_infer", | ||
"rustc_macros", | ||
"rustc_span", | ||
"rustc_target", | ||
] | ||
|
||
[dev-dependencies] | ||
itertools = "0.10.1" |
Oops, something went wrong.
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.
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.
heh, That's smart. Should probably document this behaviour in the tracking issue so it can get revisited before stabilization.
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.
I don't believe this is a stability issue (even if the feature was on track for stabilization, which it isn't). The
unwrap_or(true)
branch is only reached if the const parameter is of the wrong type. This, in itself, is a type error, which rustc reports separately. However, since rustc nonetheless still tries to confirm this candidate, the compiler would ICE had I only written.unwrap()
. So, what to do instead? I could:Err(Unimplemented)
Ok(ImplSourceBuiltinData { nested: vec![] }),
In all possibilities, at least one error message is always displayed: the error that a const parameter of the wrong type has been passed in. So, whether or not the transmutability system also produces its own error isn't a stability issue, it's just an error message ergonomics issue.