Skip to content

Some refactoring around intrinsic type checking #73834

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Jul 6, 2020

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jun 28, 2020

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 Symbols (so basically u32s). 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.

@rust-highfive
Copy link
Contributor

r? @ecstatic-morse

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 28, 2020
@rust-highfive

This comment has been minimized.

@oli-obk

This comment has been minimized.

@oli-obk

This comment has been minimized.

Copy link
Contributor

@ecstatic-morse ecstatic-morse left a 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::*;
Copy link
Contributor

@ecstatic-morse ecstatic-morse Jun 28, 2020

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.

Copy link
Contributor Author

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 => {
Copy link
Contributor

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.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 28, 2020

@bors r=ecstatic-morse

@bors
Copy link
Collaborator

bors commented Jun 28, 2020

📌 Commit 824b2bb has been approved by ecstatic-morse

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 28, 2020
@ecstatic-morse
Copy link
Contributor

@bors rollup

Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 29, 2020
…-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.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 29, 2020
…-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.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 30, 2020
…-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.
@Manishearth
Copy link
Member

Is there a chance this PR is massively slowing down CI? It was a part of two rollups (#73880, #73864) that timed out, and while this is not the only suspect, it's worth investigating.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 30, 2020

I didn't notice anything locally... but let's see

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Collaborator

bors commented Jun 30, 2020

🙅 Please do not try after a pull request has been r+ed. If you need to try, unapprove (r-) it first.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 30, 2020

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 30, 2020
@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 30, 2020

@bors try

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 1, 2020
@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 2, 2020

@bors r+

It's not this PR, some other PR didn't rebase and bless. I'll figure out the problematic PR

@bors
Copy link
Collaborator

bors commented Jul 2, 2020

📌 Commit 824b2bb has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 2, 2020
@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 2, 2020

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

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 2, 2020

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.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 2, 2020

ah it was #72983 which already knows about it

@bors
Copy link
Collaborator

bors commented Jul 2, 2020

☔ The latest upstream changes (presumably #73954) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 2, 2020
@oli-obk oli-obk force-pushed the safe_intrinsics branch from 824b2bb to 394b8cd Compare July 4, 2020 16:38
@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 4, 2020

@bors r=ecstatic-morse rollup

@bors
Copy link
Collaborator

bors commented Jul 4, 2020

📌 Commit 394b8cd has been approved by ecstatic-morse

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 4, 2020
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 4, 2020
…-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.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 5, 2020
…-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.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 5, 2020
…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
@bors bors merged commit fed2013 into rust-lang:master Jul 6, 2020
@oli-obk oli-obk deleted the safe_intrinsics branch March 16, 2021 12:14
@cuviper cuviper added this to the 1.46 milestone May 2, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants