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 RFC 3323: restrictions #106074

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open

Conversation

jhpratt
Copy link
Member

@jhpratt jhpratt commented Dec 23, 2022

This PR implements RFC 3323, which proposed impl and mut restrictions. Both are implemented here.

The current state of the PR is insufficient to merge. mut restrictions are implemented without any known bugs. impl restrictions, however, are not currently enforced on external traits — they are only enforced on same-crate traits. I do not know why this is the case, and would appreciate some help in narrowing down what needs to change to fix this. This is the only known issue with the implementation, and is why this PR is currently marked as a draft.

Once the bug is fixed, I'll also need to clean up the commit history. The current history is due to having it implemented while the RFC was still in progress.

CI will fail for a number of reasons. I still have TODO in the code as opposed to FIXME (because it needs to be done before this gets merged). I haven't added the tracking issue yet. And the bug will also cause a few errors by itself.

I am currently refactoring some code and cleaning up the commit history. After that is done, this PR will be ready to merge.

cc #105077

@rustbot
Copy link
Collaborator

rustbot commented Dec 23, 2022

r? @eholk

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

@rustbot rustbot added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 23, 2022
@rustbot
Copy link
Collaborator

rustbot commented Dec 23, 2022

Error: Label B-rfc-approved can only be set by Rust team members

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

@jhpratt jhpratt mentioned this pull request Dec 23, 2022
10 tasks
@jhpratt

This comment was marked as resolved.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 23, 2022
@joshtriplett
Copy link
Member

Reassigning to T-compiler, as this doesn't need further T-lang review yet.

@joshtriplett joshtriplett added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Dec 23, 2022
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Dec 29, 2022

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

@rustbot rustbot added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic labels Jan 5, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-cloud-vms rust-cloud-vms bot force-pushed the restrictions branch 2 times, most recently from 0f88945 to c0c8d21 Compare January 5, 2023 23:53
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check-tidy failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:c85c95e3d7251135ab7dc9ce3241c5835cc595a9)
Download action repository 'actions/upload-artifact@v3' (SHA:0b7f8abb1508181956e8e162db84b466c27e18ce)
Complete job name: PR - mingw-check-tidy
git config --global core.autocrlf false
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
---
  lfs: false
  submodules: false
  set-safe-directory: true
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
---
##[group]Run src/ci/scripts/setup-environment.sh
src/ci/scripts/setup-environment.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  EXTRA_VARIABLES: {}
##[endgroup]
linux builder detected, using docker to run the build
##[group]Run src/ci/scripts/should-skip-this.sh
src/ci/scripts/should-skip-this.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
Executing the job since there is no skip rule preventing the execution
##[group]Run src/ci/scripts/verify-channel.sh
src/ci/scripts/verify-channel.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
##[group]Run src/ci/scripts/collect-cpu-stats.sh
src/ci/scripts/collect-cpu-stats.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
---
##[group]Run src/ci/scripts/install-sccache.sh
src/ci/scripts/install-sccache.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
##[group]Run src/ci/scripts/select-xcode.sh
src/ci/scripts/select-xcode.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
##[group]Run src/ci/scripts/install-clang.sh
src/ci/scripts/install-clang.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
##[group]Run src/ci/scripts/install-wix.sh
src/ci/scripts/install-wix.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
##[group]Run src/ci/scripts/disable-git-crlf-conversion.sh
src/ci/scripts/disable-git-crlf-conversion.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
---
##[group]Run src/ci/scripts/install-msys2.sh
src/ci/scripts/install-msys2.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
##[group]Run src/ci/scripts/install-mingw.sh
src/ci/scripts/install-mingw.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
##[group]Run src/ci/scripts/install-ninja.sh
src/ci/scripts/install-ninja.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
##[group]Run src/ci/scripts/enable-docker-ipv6.sh
src/ci/scripts/enable-docker-ipv6.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
{"ipv6":true,"fixed-cidr-v6":"fd9a:8454:6789:13f7::/64"}
##[group]Run src/ci/scripts/disable-git-crlf-conversion.sh
src/ci/scripts/disable-git-crlf-conversion.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
##[group]Run src/ci/scripts/verify-line-endings.sh
src/ci/scripts/verify-line-endings.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
##[group]Run src/ci/scripts/verify-backported-commits.sh
src/ci/scripts/verify-backported-commits.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
Skipping. This is only run when merging to the beta or stable branches.
##[group]Run src/ci/scripts/verify-stable-version-number.sh
src/ci/scripts/verify-stable-version-number.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  CACHE_DOMAIN: ci-caches.rust-lang.org
  IMAGE: mingw-check-tidy
##[endgroup]
This script only works on the stable channel. Skipping the check.
##[group]Run src/ci/scripts/run-build-from-ci.sh
src/ci/scripts/run-build-from-ci.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  PR_CI_JOB: 1
  CI_JOB_NAME: mingw-check-tidy
  HEAD_SHA: 076a838cb097b68ffb8060c72c1e15eba76d0771
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
---
Building wheels for collected packages: reuse
  Building wheel for reuse (pyproject.toml): started
  Building wheel for reuse (pyproject.toml): finished with status 'done'
  Created wheel for reuse: filename=reuse-1.1.0-cp310-cp310-manylinux_2_35_x86_64.whl size=180116 sha256=351235b2326fb4db7a18e257e13ce7896c5f77339521e2c2612e71e154800a19
  Stored in directory: /tmp/pip-ephem-wheel-cache-7fyv1irp/wheels/c2/3c/b9/1120c2ab4bd82694f7e6f0537dc5b9a085c13e2c69a8d0c76d
Installing collected packages: boolean-py, binaryornot, setuptools, reuse, python-debian, markupsafe, license-expression, jinja2, chardet
  Attempting uninstall: setuptools
    Found existing installation: setuptools 59.6.0
    Not uninstalling setuptools at /usr/lib/python3/dist-packages, outside environment /usr
---
Successfully tagged rust-ci:latest
Built container sha256:cb00e463e62dfffe6a692d63ca0882eebe3252c311db8b59afca061e3098ab11
Uploading finished image to https://ci-caches.rust-lang.org/docker/39289e18f1ac1b1a573d1a3c658528cab0cbfec4029e2def8ed615ecd4b1295e23213ab5b134f4a50a4bd45af0a8a4266b7571ba256dc217696d0f040efcd003

<botocore.awsrequest.AWSRequest object at 0x7f424ea20050>
gzip: stdout: Broken pipe
xargs: docker: terminated by signal 13
[CI_JOB_NAME=mingw-check-tidy]
[CI_JOB_NAME=mingw-check-tidy]
---
curl: (22) The requested URL returned error: 404

error: failed to download llvm from ci

    help: old builds get deleted after a certain time
    help: if trying to compile an old commit of rustc, disable `download-ci-llvm` in config.toml:
    [llvm]
    download-ci-llvm = false
    
Build completed unsuccessfully in 0:00:00

@bors
Copy link
Contributor

bors commented Jul 19, 2023

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

@@ -1,5 +1,5 @@
Visibility is restricted to a module which isn't an ancestor of the current
item.
Visibility or restriction is restricted to a module which isn't an ancestor of
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe

Suggested change
Visibility or restriction is restricted to a module which isn't an ancestor of
Visibility or restriction is limited to a module which isn't an ancestor of

to avoid repetition?

@apiraino
Copy link
Contributor

I'll reassign to author(s) to rebase and address a few comments but tbh I'm not sure about who should have the ball right now. Feel free to request a review with @rustbot ready, thanks!

@rustbot author

@rustbot rustbot 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 Aug 24, 2023
@petrochenkov
Copy link
Contributor

When it gets to actual landing it will be better to split this PR into separate PRs for individual sub-features, it's too large right now.

@WaffleLapkin
Copy link
Member

Agree with @petrochenkov, one of the reasons I'm procrastinating reviewing this (sorry!) is that this PR adds a lot. Maybe an approach closer to what we are doing with the explicit tail calls experiment (a PR per level — one for parsing, one for HIR, ...; maybe a PR "per feature" would make more sense here, I'm not sure) would be a bit easier to manage.

@jhpratt
Copy link
Member Author

jhpratt commented Aug 24, 2023

No worries on the delay — I know it's a large PR. I can definitely split it up into multiple PRs when I get the chance. That may be a little while, unfortunately, as I've got a few different things going on.

@compiler-errors
Copy link
Member

For the record: feel free to follow the new nightly style policy and open a separate formatting PR against rustfmt once this has landed in the compiler.

@Dylan-DPC
Copy link
Member

@jhpratt any updates on this?

@jhpratt
Copy link
Member Author

jhpratt commented Feb 5, 2024

@Dylan-DPC Not at the moment. I have splitting it up on my personal backlog.

@Dylan-DPC
Copy link
Member

@jhpratt any updates on this? It's just collecting conflicts at the moment :D

@WaffleLapkin
Copy link
Member

r? compiler
(I know this is waiting on author, but I do not plan to review anymore, so rerolling)

@rustbot rustbot assigned pnkfelix and unassigned WaffleLapkin Jul 25, 2024
@compiler-errors
Copy link
Member

I can review this but I'd rather we split it as agreed above (not to seem repetitive, and obviously take your time).

@jhpratt
Copy link
Member Author

jhpratt commented Jul 25, 2024

The update would be that I'm quite busy, unfortunately. Believe me when I say this is something that I still want to happen 😄

Between work, RustConf prep, and other open source things, this isn't happening in the next month. However, I hope to get around to it within the next few months. It'll likely be a series of PRs, each being an incremental step towards the full implementation that this PR is.

@alex-semenyuk alex-semenyuk 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 12, 2024
@JohnCSimon JohnCSimon 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic F-impl_restriction `#![feature(impl_restriction)]` F-mut_restriction `#![feature(mut_restriction)]` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.