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

Clean up type alias impl trait implementation #72080

Merged
merged 11 commits into from
Jun 15, 2020

Conversation

matthewjasper
Copy link
Contributor

@matthewjasper matthewjasper commented May 10, 2020

  • Removes special case for top-level impl trait
  • Removes associated opaque types
  • Forbid lifetime elision in let position impl trait. This is consistent with the behavior for inferred types.
  • Handle lifetimes in type alias impl trait more uniformly with other parameters

cc #69323
cc #63063
Closes #57188
Closes #62988
Closes #69136
Closes #73061

@matthewjasper matthewjasper added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` labels May 10, 2020
@rust-highfive
Copy link
Collaborator

r? @davidtwco

(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 10, 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 5'
Agent machine name: 'fv-az578'
Current agent version: '2.168.2'
##[group]Operating System
16.04.6
LTS
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-16.04
Version: 20200430.2
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu16/20200430.2/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.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/16b01af5-3b80-4fa1-b5f7-44c64dbabe31.sh

##[section]Finishing: Disable git automatic line ending conversion
##[section]Starting: Checkout rust-lang/rust@refs/pull/72080/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/72080/merge:refs/remotes/pull/72080/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
---
    Checking rustc_feature v0.0.0 (/checkout/src/librustc_feature)
    Checking fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
    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 chalk-rust-ir v0.10.0
    Checking rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
    Checking rustc_parse v0.0.0 (/checkout/src/librustc_parse)
    Checking rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
     |
1143 |             hir::ImplItemKind::OpaqueTy(ref bounds) => OpaqueTyItem(
     |                                ^^^^^^^^ variant or associated item not found in `rustc_hir::ImplItemKind<'_>`

error[E0599]: no variant or associated item named `OpaqueTy` found for enum `rustc_middle::ty::AssocKind` in the current scope
     |
1313 |             ty::AssocKind::OpaqueTy => unimplemented!(),
     |                            ^^^^^^^^ variant or associated item not found in `rustc_middle::ty::AssocKind`

---
  local time: Sun May 10 12:48:58 UTC 2020
  network time: Sun, 10 May 2020 12:48:59 GMT
== end clock drift check ==

##[error]Bash exited with code '1'.
##[section]Finishing: Run build
##[section]Starting: Checkout rust-lang/rust@refs/pull/72080/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/72080/merge to s
Cleaning up task key
Start cleaning up orphan processes.
Terminate orphan process: pid (4263) (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)

@davidtwco
Copy link
Member

r? @eddyb

@rust-highfive rust-highfive assigned eddyb and unassigned davidtwco May 15, 2020
@bors
Copy link
Contributor

bors commented May 21, 2020

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

@eddyb
Copy link
Member

eddyb commented May 25, 2020

Sorry for not seeing this earlier. Also, I'm not the best person to review this (but I will go through it).

r? @nikomatsakis

@rust-highfive rust-highfive assigned nikomatsakis and unassigned eddyb May 25, 2020
Copy link
Member

@eddyb eddyb left a comment

Choose a reason for hiding this comment

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

Seems pretty good, overall, especially all the removed code. I'll let @nikomatsakis take a closer look though.

} else {
// Non return-position impl trait captures all of the lifetimes of
// the parent item.
(&[], &[])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needs to include the bound regions that the type captures.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is your intent to patch this code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, although it ended up being a somewhat large change.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

This all looks good. I left various comments and nits.

src/librustc_typeck/check/wfcheck.rs Show resolved Hide resolved
src/librustc_typeck/check/wfcheck.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/wfcheck.rs Outdated Show resolved Hide resolved
src/librustc_ast_lowering/item.rs Show resolved Hide resolved
} else {
// Non return-position impl trait captures all of the lifetimes of
// the parent item.
(&[], &[])
Copy link
Contributor

Choose a reason for hiding this comment

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

Is your intent to patch this code?

src/librustc_typeck/astconv.rs Outdated Show resolved Hide resolved
src/test/ui/impl-trait/negative-reasoning.rs Show resolved Hide resolved
src/librustc_resolve/late/lifetimes.rs Outdated Show resolved Hide resolved
src/librustc_typeck/collect/type_of.rs Show resolved Hide resolved
src/librustc_typeck/collect/type_of.rs Show resolved Hide resolved
@jonhoo
Copy link
Contributor

jonhoo commented Jun 7, 2020

Since this also fixes #73061, it'd be good to add a regression test for that + add it to the "closes" list.

@jonhoo
Copy link
Contributor

jonhoo commented Jun 7, 2020

I wonder if this change is also going to make it easier to fix #65863.

@matthewjasper matthewjasper force-pushed the uniform-impl-trait branch 2 times, most recently from 7245c19 to 51a6550 Compare June 7, 2020 19:42
@matthewjasper
Copy link
Contributor Author

I don't think this helps with #65863, because this doesn't change the AST representation of impl trait types.

@jonhoo
Copy link
Contributor

jonhoo commented Jun 8, 2020

I don't think this helps with #65863, because this doesn't change the AST representation of impl trait types.

Ah, yes, that makes sense. Just a test for #73061 would be good then.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jun 10, 2020

📌 Commit 51a6550 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Jun 10, 2020

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@jonhoo
Copy link
Contributor

jonhoo commented Jun 11, 2020

@matthewjasper Oh, I'm sorry, I scrolled through looking for it, but it must have been collapsed by GitHub somehow! Sorry for the noise ❤️

@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 18'
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: 20200604.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu16/20200604.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.3)
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/c0d787f4-859b-4556-80f4-deef351dcf86.sh

##[section]Finishing: Disable git automatic line ending conversion
##[section]Starting: Checkout rust-lang/rust@refs/pull/72080/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/72080/merge:refs/remotes/pull/72080/merge
---
 ---> f883e675ad62
Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
 ---> Using cache
 ---> c0b156eb069c
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
 ---> 8541bab6b38c
Successfully built 8541bab6b38c
Successfully tagged rust-ci:latest
Built container sha256:8541bab6b38c07f1b7eb787539b9cbe93daa6ac4458d3d7bd8a8921622a14ba1
---
    Checking rustc_span v0.0.0 (/checkout/src/librustc_span)
    Checking rustc_errors v0.0.0 (/checkout/src/librustc_errors)
    Checking rustc_feature v0.0.0 (/checkout/src/librustc_feature)
    Checking rustc_parse_format v0.0.0 (/checkout/src/librustc_parse_format)
    Checking chalk-rust-ir v0.10.0
    Checking rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
    Checking rustc_hir v0.0.0 (/checkout/src/librustc_hir)
    Checking rustc_session v0.0.0 (/checkout/src/librustc_session)
    Checking chalk-solve v0.10.0
    Checking rustc_parse v0.0.0 (/checkout/src/librustc_parse)
---

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:05:11
== clock drift check ==
  local time: Thu Jun 11 15:33:32 UTC 2020
  local time: Thu Jun 11 15:33:32 UTC 2020
  network time: Thu, 11 Jun 2020 15:33:32 GMT
== end clock drift check ==

##[error]Bash exited with code '1'.
##[section]Finishing: Run build
##[section]Starting: Checkout rust-lang/rust@refs/pull/72080/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/72080/merge to s
Cleaning up task key
Start cleaning up orphan processes.
Terminate orphan process: pid (3542) (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)

@matthewjasper
Copy link
Contributor Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jun 11, 2020

📌 Commit 8b10d42 has been approved by nikomatsakis

@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 Jun 11, 2020
@bors
Copy link
Contributor

bors commented Jun 15, 2020

⌛ Testing commit 8b10d42 with merge ce6d3a7...

@RalfJung
Copy link
Member

Somehow Windows x86_64 msvc-2 is almost at 4h now (and will likely timeout) even though it usually takes <3h.

@bors
Copy link
Contributor

bors commented Jun 15, 2020

☀️ Test successful - checks-azure
Approved by: nikomatsakis
Pushing ce6d3a7 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 15, 2020
@bors bors merged commit ce6d3a7 into rust-lang:master Jun 15, 2020
@RalfJung
Copy link
Member

Oh wow, it just barely made it. Nice :D

@matthewjasper matthewjasper deleted the uniform-impl-trait branch June 15, 2020 08:17
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 23, 2020
…ikomatsakis

Clean up type alias impl trait implementation

- Removes special case for top-level impl trait
- Removes associated opaque types
- Forbid lifetime elision in let position impl trait. This is consistent with the behavior for inferred types.
- Handle lifetimes in type alias impl trait more uniformly with other parameters

cc rust-lang#69323
cc rust-lang#63063
Closes rust-lang#57188
Closes rust-lang#62988
Closes rust-lang#69136
Closes rust-lang#73061
Xanewok added a commit to Xanewok/rust-semverver that referenced this pull request Nov 16, 2020
Xanewok added a commit to Xanewok/rust-semverver that referenced this pull request Nov 17, 2020
bors added a commit to rust-lang/rust-semverver that referenced this pull request Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` 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.
10 participants