-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Some refactoring around intrinsic type checking #73834
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
r=me with glob imports removed and replaced with sym::xxx
.
@@ -67,15 +67,17 @@ fn equate_intrinsic_type<'tcx>( | |||
} | |||
|
|||
/// Returns `true` if the given intrinsic is unsafe to call or not. | |||
pub fn intrinsic_operation_unsafety(intrinsic: &str) -> hir::Unsafety { | |||
pub fn intrinsic_operation_unsafety(intrinsic: Symbol) -> hir::Unsafety { | |||
use rustc_span::symbol::sym::*; |
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.
A glob import of sym
pollutes the local namespace with a lot of lower-case constants. For this reason, it's not done anywhere else in the compiler. I realize that it's kind of a pain, but we should uphold this example. It's more relevant in the other big match statement, which has code outside the match.
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.
yea... I knew that to be the right thing... but... laziness XD
@@ -303,7 +302,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) { | |||
) | |||
} | |||
|
|||
"try" => { | |||
rustc_span::symbol::kw::Try => { |
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.
Good catch. Having sym::Try
and kw::Try
mean different things is a bit subtle. I don't see how we could do better though.
@bors r=ecstatic-morse |
📌 Commit 824b2bb has been approved by |
@bors rollup |
…-morse Some refactoring around intrinsic type checking So... This PR went a bit overboard. I wanted to make the `rustc_peek` intrinsic safe (cc @ecstatic-morse ), and remembered a long-standing itch of mine. So I made that huge `&str` match for the intrinsic name a match on `Symbol`s (so basically `u32`s). This is unlikely to have a positive perf effect, even if it likely has better codegen (intrinsics are used rarely, mostly once in their wrapper), so it's mostly a consistency thing since other places actually match on the symbol name of the intrinsics.
…-morse Some refactoring around intrinsic type checking So... This PR went a bit overboard. I wanted to make the `rustc_peek` intrinsic safe (cc @ecstatic-morse ), and remembered a long-standing itch of mine. So I made that huge `&str` match for the intrinsic name a match on `Symbol`s (so basically `u32`s). This is unlikely to have a positive perf effect, even if it likely has better codegen (intrinsics are used rarely, mostly once in their wrapper), so it's mostly a consistency thing since other places actually match on the symbol name of the intrinsics.
…-morse Some refactoring around intrinsic type checking So... This PR went a bit overboard. I wanted to make the `rustc_peek` intrinsic safe (cc @ecstatic-morse ), and remembered a long-standing itch of mine. So I made that huge `&str` match for the intrinsic name a match on `Symbol`s (so basically `u32`s). This is unlikely to have a positive perf effect, even if it likely has better codegen (intrinsics are used rarely, mostly once in their wrapper), so it's mostly a consistency thing since other places actually match on the symbol name of the intrinsics.
I didn't notice anything locally... but let's see @bors try @rust-timer queue |
Awaiting bors try build completion |
🙅 Please do not |
@bors r- |
@bors try |
@bors r+ It's not this PR, some other PR didn't rebase and bless. I'll figure out the problematic PR |
📌 Commit 824b2bb has been approved by |
I think it was https://github.com/rust-lang/rust/pull/73622/files#diff-c4db7f9b504f4fbce6ba0b53e7810379, I'll mention it in that PR nevermind, that's not the one |
I'll try to figure it out later, but some PR included a miri submodule update, even though it should not, idk which one yet. |
ah it was #72983 which already knows about it |
☔ The latest upstream changes (presumably #73954) made this pull request unmergeable. Please resolve the merge conflicts. |
@bors r=ecstatic-morse rollup |
📌 Commit 394b8cd has been approved by |
…-morse Some refactoring around intrinsic type checking So... This PR went a bit overboard. I wanted to make the `rustc_peek` intrinsic safe (cc @ecstatic-morse ), and remembered a long-standing itch of mine. So I made that huge `&str` match for the intrinsic name a match on `Symbol`s (so basically `u32`s). This is unlikely to have a positive perf effect, even if it likely has better codegen (intrinsics are used rarely, mostly once in their wrapper), so it's mostly a consistency thing since other places actually match on the symbol name of the intrinsics.
…-morse Some refactoring around intrinsic type checking So... This PR went a bit overboard. I wanted to make the `rustc_peek` intrinsic safe (cc @ecstatic-morse ), and remembered a long-standing itch of mine. So I made that huge `&str` match for the intrinsic name a match on `Symbol`s (so basically `u32`s). This is unlikely to have a positive perf effect, even if it likely has better codegen (intrinsics are used rarely, mostly once in their wrapper), so it's mostly a consistency thing since other places actually match on the symbol name of the intrinsics.
…arth Rollup of 12 pull requests Successful merges: - rust-lang#72688 (added .collect() into String from Box<str>) - rust-lang#73787 (Add unstable docs for rustc_attrs) - rust-lang#73834 (Some refactoring around intrinsic type checking) - rust-lang#73871 (Fix try_print_visible_def_path for Rust 2018) - rust-lang#73937 (Explain exhaustive matching on {usize,isize} maximum values) - rust-lang#73973 (Use `Span`s to identify unreachable subpatterns in or-patterns) - rust-lang#74000 (add `lazy_normalization_consts` feature gate) - rust-lang#74025 (Remove unnecessary release from Arc::try_unwrap) - rust-lang#74027 (Convert more `DefId`s to `LocalDefId`s) - rust-lang#74055 (Fix spacing in Iterator fold doc) - rust-lang#74057 (expected_found `&T` -> `T`) - rust-lang#74064 (variant_count: avoid incorrect dummy implementation) Failed merges: r? @ghost
So... This PR went a bit overboard. I wanted to make the
rustc_peek
intrinsic safe (cc @ecstatic-morse ), and remembered a long-standing itch of mine. So I made that huge&str
match for the intrinsic name a match onSymbol
s (so basicallyu32
s). This is unlikely to have a positive perf effect, even if it likely has better codegen (intrinsics are used rarely, mostly once in their wrapper), so it's mostly a consistency thing since other places actually match on the symbol name of the intrinsics.