Skip to content
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

Implement associated lang items #72559

Merged
merged 1 commit into from
Jun 25, 2020

Conversation

Aaron1011
Copy link
Member

Fixes #70718

This commit allows making associated items (e.g. associated functions
and types) into lang items via the #[lang] attribute. This allows such
items to be accessed directly, rather than by iterating over the parent
item's associated items.

I've added FnOnce::Output as a lang item, and updated one old usage to
use the new lang item. The remaining uses can be updated separately.

@rust-highfive
Copy link
Collaborator

r? @eddyb

(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 May 25, 2020
@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
##[section]Starting: Linux mingw-check
##[section]Starting: Initialize job
Agent name: 'Azure Pipelines 2'
Agent machine name: 'fv-az619'
Current agent version: '2.169.0'
##[group]Operating System
16.04.6
LTS
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-16.04
Version: 20200517.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu16/20200517.1/images/linux/Ubuntu1604-README.md
##[endgroup]
Agent running as: 'vsts'
Prepare build directory.
Set build variables.
Download all required tasks.
Download all required tasks.
Downloading task: Bash (3.163.2)
Checking job knob settings.
   Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY} 
   Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG} 
Start tracking orphan processes.
##[section]Finishing: Initialize job
##[section]Starting: Configure Job Name
==============================================================================
---
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /home/vsts/work/_temp/d52da9ff-cc3d-4b89-ade3-34634dd9c4b9.sh

##[section]Finishing: Disable git automatic line ending conversion
##[section]Starting: Checkout rust-lang/rust@refs/pull/72559/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
---
##[command]git remote add origin https://github.com/rust-lang/rust
##[command]git config gc.auto 0
##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
##[command]git config --get-all http.proxy
##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/72559/merge:refs/remotes/pull/72559/merge
---
 ---> 3adb0605cc65
Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
 ---> Using cache
 ---> 28dbc326cb7f
Step 7/7 : ENV SCRIPT python3 ../x.py test src/tools/expand-yaml-anchors &&            python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu &&            python3 ../x.py build --stage 0 src/tools/build-manifest &&            python3 ../x.py test --stage 0 src/tools/compiletest &&            python3 ../x.py test src/tools/tidy &&            python3 ../x.py doc --stage 0 src/libstd &&            /scripts/validate-toolstate.sh
 ---> 537a01811900
Successfully built 537a01811900
Successfully tagged rust-ci:latest
Built container sha256:537a018119009dc218456238dec90b5530050db1e2a1e166550c218003f6159d
---
   Compiling compiler_builtins v0.1.28
error: unused attribute
   --> src/libcore/ops/function.rs:227:5
    |
227 |     #[lang = "fn_once_output"]
    |
    = note: `-D unused-attributes` implied by `-D warnings`

error: aborting due to previous error
---
  local time: Mon May 25 03:50:34 UTC 2020
  network time: Mon, 25 May 2020 03:50:34 GMT
== end clock drift check ==

##[error]Bash exited with code '1'.
##[section]Finishing: Run build
##[section]Starting: Checkout rust-lang/rust@refs/pull/72559/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
Author       : Microsoft
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Cleaning any cached credential from repository: rust-lang/rust (GitHub)
##[section]Finishing: Checkout rust-lang/rust@refs/pull/72559/merge to s
Cleaning up task key
Start cleaning up orphan processes.
Terminate orphan process: pid (7102) (python)
##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@@ -21,26 +22,6 @@ use rustc_session::parse::feature_err;
use rustc_span::symbol::sym;
use rustc_span::Span;

fn target_from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem<'_>) -> Target {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the same crate, so you could just make it public instead of moving it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was better to be able to consistently use Target::from_[type]

@eddyb
Copy link
Member

eddyb commented May 25, 2020

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented May 25, 2020

⌛ Trying commit 084a71ffacd64b18fcc094774e3070863e094346 with merge 4c413091cb0a8f9601d37e506e4fcfae154504cc...

@eddyb eddyb 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-review Status: Awaiting review from the assignee but also interested parties. labels May 25, 2020
@bors
Copy link
Contributor

bors commented May 25, 2020

☀️ Try build successful - checks-azure
Build commit: 4c413091cb0a8f9601d37e506e4fcfae154504cc (4c413091cb0a8f9601d37e506e4fcfae154504cc)

@rust-timer
Copy link
Collaborator

Queued 4c413091cb0a8f9601d37e506e4fcfae154504cc with parent ee6c0da, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit 4c413091cb0a8f9601d37e506e4fcfae154504cc, comparison URL.

@Aaron1011 Aaron1011 force-pushed the feature/assoc-lang-items branch 2 times, most recently from 1df2014 to 230394d Compare May 26, 2020 00:39
@Aaron1011
Copy link
Member Author

Aaron1011 commented May 26, 2020

@eddyb: I've moved TargetExt to the proper location. It doesn't look like there was any speedup from this PR.

@Aaron1011 Aaron1011 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 26, 2020
@Aaron1011
Copy link
Member Author

@eddyb: Are there any other changes that you'd like me to make?

@Elinvynia Elinvynia added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 10, 2020
@bors
Copy link
Contributor

bors commented Jun 15, 2020

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

@oli-obk
Copy link
Contributor

oli-obk commented Jun 19, 2020

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned eddyb Jun 19, 2020
@bors
Copy link
Contributor

bors commented Jun 20, 2020

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

@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
##[section]Starting: Linux mingw-check
##[section]Starting: Initialize job
Agent name: 'Azure Pipelines 9'
Agent machine name: 'fv-az578'
Current agent version: '2.170.1'
##[group]Operating System
16.04.6
LTS
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-16.04
Version: 20200614.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu16/20200614.1/images/linux/Ubuntu1604-README.md
##[endgroup]
Agent running as: 'vsts'
Prepare build directory.
Set build variables.
Download all required tasks.
Download all required tasks.
Downloading task: Bash (3.171.1)
Checking job knob settings.
   Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY} 
   Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG} 
Start tracking orphan processes.
##[section]Finishing: Initialize job
##[section]Starting: Configure Job Name
==============================================================================
---
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /home/vsts/work/_temp/55a61f3b-1b23-4d30-a6c2-db9e9ad70c90.sh

##[section]Finishing: Disable git automatic line ending conversion
##[section]Starting: Checkout rust-lang/rust@refs/pull/72559/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
---
##[command]git remote add origin https://github.com/rust-lang/rust
##[command]git config gc.auto 0
##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
##[command]git config --get-all http.proxy
##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/72559/merge:refs/remotes/pull/72559/merge
---
 ---> a9ec21d337b3
Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
 ---> Using cache
 ---> 5ff2c13d8dba
Step 7/7 : ENV SCRIPT python3 ../x.py test src/tools/expand-yaml-anchors &&            python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu &&            python3 ../x.py build --stage 0 src/tools/build-manifest &&            python3 ../x.py test --stage 0 src/tools/compiletest &&            python3 ../x.py test src/tools/tidy &&            python3 ../x.py doc --stage 0 src/libstd &&            /scripts/validate-toolstate.sh
 ---> 6b931e755c7e
Successfully built 6b931e755c7e
Successfully tagged rust-ci:latest
Built container sha256:6b931e755c7ea1f69816640eb9df74fafd40a545d0e5aa8341d35009dabb0f3c
---
    Checking rustc_feature v0.0.0 (/checkout/src/librustc_feature)
    Checking rustc_parse_format v0.0.0 (/checkout/src/librustc_parse_format)
    Checking rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
    Checking rustc_hir v0.0.0 (/checkout/src/librustc_hir)
    Checking rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
    Checking rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
    Checking chalk-engine v0.11.0
    Checking rustc_parse v0.0.0 (/checkout/src/librustc_parse)
    Checking rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---

error[E0433]: failed to resolve: use of undeclared type or module `ItemKind`
  --> src/librustc_middle/hir/mod.rs:94:21
   |
94 |                     ItemKind::Impl { ref of_trait, .. } => of_trait.is_some(),

error[E0433]: failed to resolve: use of undeclared type or module `Target`
  --> src/librustc_middle/hir/mod.rs:98:21
   |
   |
98 |                     Target::Method(MethodKind::Trait { body: true })

error[E0433]: failed to resolve: use of undeclared type or module `MethodKind`
  --> src/librustc_middle/hir/mod.rs:98:36
   |
   |
98 |                     Target::Method(MethodKind::Trait { body: true })
   |                                    ^^^^^^^^^^ use of undeclared type or module `MethodKind`
error[E0433]: failed to resolve: use of undeclared type or module `Target`
   --> src/librustc_middle/hir/mod.rs:100:21
    |
100 |                     Target::Method(MethodKind::Inherent)
---

error[E0412]: cannot find type `ImplItem` in this scope
  --> src/librustc_middle/hir/mod.rs:87:60
   |
87 |     fn from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &ImplItem<'_>) -> Target {
   |
help: consider importing this struct
   |
8  | use rustc_hir::ImplItem;
8  | use rustc_hir::ImplItem;
   |

error[E0412]: cannot find type `Target` in this scope
  --> src/librustc_middle/hir/mod.rs:87:77
   |
87 |     fn from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &ImplItem<'_>) -> Target {
   |
help: consider importing one of these items
   |
8  | use rustc_hir::Target;
---
    |
8   | use rustc_target::spec::Target;
    |

thread 'rustc' panicked at 'Failed to get parent for DefId(0:652 ~ rustc_middle[4e85]::hir[0]::{{impl}}[3])', src/librustc_middle/traits/specialization_graph.rs:46:52

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.
note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: ***/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.45.0-beta.2 (1dc0f6d8e 2020-06-15) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z macro-backtrace -Z unstable-options -Z binary-dep-depinfo -Z force-unstable-if-unmarked -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C link-args=-Wl,-rpath,$ORIGIN/../lib -C prefer-dynamic -C debug-assertions=n --crate-type lib
note: some of the compiler flags provided by cargo are hidden

error: aborting due to 13 previous errors


Some errors have detailed explanations: E0412, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `rustc_middle`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "2" "--release" "--color" "always" "--features" " llvm" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json-render-diagnostics"
failed to run: /checkout/obj/build/bootstrap/debug/bootstrap check
Build completed unsuccessfully in 0:03:38
== clock drift check ==
  local time: Wed Jun 24 22:57:51 UTC 2020
  local time: Wed Jun 24 22:57:51 UTC 2020
  network time: Wed, 24 Jun 2020 22:57:51 GMT
== end clock drift check ==

##[error]Bash exited with code '1'.
##[section]Finishing: Run build
##[section]Starting: Checkout rust-lang/rust@refs/pull/72559/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
Author       : Microsoft
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Cleaning any cached credential from repository: rust-lang/rust (GitHub)
##[section]Finishing: Checkout rust-lang/rust@refs/pull/72559/merge to s
Cleaning up task key
Start cleaning up orphan processes.
Terminate orphan process: pid (3627) (python)
##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

Fixes rust-lang#70718

This commit allows making associated items (e.g. associated functions
and types) into lang items via the `#[lang]` attribute. This allows such
items to be accessed directly, rather than by iterating over the parent
item's associated items.

I've added `FnOnce::Output` as a lang item, and updated one old usage to
use the new lang item. The remaining uses can be updated separately.
@Aaron1011
Copy link
Member Author

@oli-obk: I've moved target_from_impl_item back to being a free function.

@oli-obk
Copy link
Contributor

oli-obk commented Jun 25, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Jun 25, 2020

📌 Commit a13d467 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-review Status: Awaiting review from the assignee but also interested parties. labels Jun 25, 2020
@Aaron1011
Copy link
Member Author

@bors retry

@bors
Copy link
Contributor

bors commented Jun 25, 2020

⌛ Testing commit a13d467 with merge 229e5b2...

@bors
Copy link
Contributor

bors commented Jun 25, 2020

☀️ Test successful - checks-azure
Approved by: oli-obk
Pushing 229e5b2 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 25, 2020
@bors bors merged commit 229e5b2 into rust-lang:master Jun 25, 2020
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #72559!

Tested on commit 229e5b2.
Direct link to PR: #72559

💔 rls on linux: test-pass → test-fail (cc @Xanewok).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Jun 25, 2020
Tested on commit rust-lang/rust@229e5b2.
Direct link to PR: <rust-lang/rust#72559>

💔 rls on linux: test-pass → test-fail (cc @Xanewok).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

Associated lang items
8 participants