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

Proof of Concept: add #[defines] attribute and require it for all type-alias-impl-trait sites that register a hidden type #128440

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jul 31, 2024

This PR is not meant to be merged (I will not be pushing changes in the next 4 months), but serves as a starting point for anyone wanting to make progress on this. It should hopefully be simple to rebase and not require you to edit 200+ tests, as these edits are done here and you can just cherry pick them out (no need for attribution, just squash as you want)

I left TODOs for everything that I think needs to be done.

  • differentiate between no attribute and an empty attribute (#[defines()]), the latter opting out of impl-trait-in-assoc types automatic opaque collection in the signature (or in general, any #[defines(SomeOhterTait)] attribute behaving as an override for the default collection, too).

An interesting follow-up could also be to automatically fill in RPITs into that list in ast lowering, so that opaque_types_defined_by doesn't need to walk for RPITs anymore.

@petrochenkov can you have a look at the resolver changes so that anyone picking this up will know what to change?

@oli-obk oli-obk added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 31, 2024
@rust-log-analyzer

This comment has been minimized.

@petrochenkov petrochenkov self-assigned this Jul 31, 2024
@petrochenkov petrochenkov 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 Jul 31, 2024
@bors
Copy link
Contributor

bors commented Aug 1, 2024

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

@petrochenkov
Copy link
Contributor

Simple paths in attributes are not as bad as rust-lang/rfcs#3659, but still sort of meh, but probably acceptable.

We don't currently have any resolved paths (staying after macro expansion) in attributes in the proper language.
We have links in doc comments though, which are also simple paths processed during late resolution, and they also have to be kept in a separate special side table.

@petrochenkov petrochenkov 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 14, 2024
@petrochenkov petrochenkov removed their assignment Aug 14, 2024
@petrochenkov
Copy link
Contributor

Also, defines is probably a popular enough name, so the chance of regressions like #128888 may be high, if it becomes a built-in attribute.

@traviscross traviscross added the F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` label Aug 23, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 4, 2024
…ler-errors

Avoid `opaque type not constrained` errors in the presence of other errors

pulled out of rust-lang#128440

These errors carry no new information if the opaque type was actually used in a constraining (but erroneous) way somewhere.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 4, 2024
Rollup merge of rust-lang#133850 - oli-obk:push-xryukktpyooq, r=compiler-errors

Avoid `opaque type not constrained` errors in the presence of other errors

pulled out of rust-lang#128440

These errors carry no new information if the opaque type was actually used in a constraining (but erroneous) way somewhere.
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Dec 10, 2024
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Dec 19, 2024

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

@oli-obk oli-obk added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Jan 8, 2025
@oli-obk
Copy link
Contributor Author

oli-obk commented Jan 8, 2025

Blocked on #131229

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

…ng from the signature to the list of opaques that are being defined
@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)

COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/

# NOTE: intentionally uses python2 for x.py so we can test it still works.
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test \
           --stage 0 src/tools/tidy tidyselftest --extra-checks=py,cpp
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
#    pip-compile --allow-unsafe --generate-hashes reuse-requirements.in
---
#13 2.673 Building wheels for collected packages: reuse
#13 2.674   Building wheel for reuse (pyproject.toml): started
#13 2.881   Building wheel for reuse (pyproject.toml): finished with status 'done'
#13 2.882   Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132718 sha256=f1d7d99e2187cfcc743e73878997db8829d4c560719802a1230bd160f7d9cfca
#13 2.882   Stored in directory: /tmp/pip-ephem-wheel-cache-33vqdyrc/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#13 2.885 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#13 3.281 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#13 3.281 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#13 3.810 Collecting virtualenv
#13 3.810 Collecting virtualenv
#13 3.845   Downloading virtualenv-20.28.1-py3-none-any.whl (4.3 MB)
#13 3.915      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 63.0 MB/s eta 0:00:00
#13 3.954 Collecting distlib<1,>=0.3.7
#13 3.957   Downloading distlib-0.3.9-py2.py3-none-any.whl (468 kB)
#13 3.965      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 469.0/469.0 KB 81.6 MB/s eta 0:00:00
#13 3.996 Collecting platformdirs<5,>=3.9.1
#13 3.999   Downloading platformdirs-4.3.6-py3-none-any.whl (18 kB)
#13 4.034 Collecting filelock<4,>=3.12.2
#13 4.037   Downloading filelock-3.16.1-py3-none-any.whl (16 kB)
#13 4.118 Installing collected packages: distlib, platformdirs, filelock, virtualenv
#13 4.299 Successfully installed distlib-0.3.9 filelock-3.16.1 platformdirs-4.3.6 virtualenv-20.28.1
#13 DONE 4.4s

#14 [7/8] COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
#14 DONE 0.0s
---
DirectMap4k:      122816 kB
DirectMap2M:     7217152 kB
DirectMap1G:    11534336 kB
##[endgroup]
Executing TIDY_PRINT_DIFF=1 python2.7 ../x.py test            --stage 0 src/tools/tidy tidyselftest --extra-checks=py,cpp
+ TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py,cpp
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
WARN: currently no CI rustc builds have rustc debug assertions enabled. Please either set `rust.debug-assertions` to `false` if you want to use download CI rustc or set `rust.download-rustc` to `false`.
downloading https://static.rust-lang.org/dist/2025-01-08/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz
---
##[endgroup]
fmt check
fmt: checked 5763 files
tidy check
tidy error: /checkout/compiler/rustc_hir_analysis/messages.ftl: message `hir_analysis_tait_forward_compat` is not used
tidy: Skipping binary file check, read-only filesystem
##[error]tidy error: /checkout/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs:403: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
##[error]tidy error: /checkout/compiler/rustc_trait_selection/src/traits/select/mod.rs:2357: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
##[error]tidy error: /checkout/compiler/rustc_ty_utils/src/opaque_types.rs:179: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
##[error]tidy error: /checkout/compiler/rustc_ty_utils/src/opaque_types.rs:185: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
##[error]tidy error: /checkout/compiler/rustc_ty_utils/src/opaque_types.rs:188: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
##[error]tidy error: /checkout/compiler/rustc_ty_utils/src/opaque_types.rs:214: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
##[error]tidy error: /checkout/compiler/rustc_ty_utils/src/opaque_types.rs:288: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
##[error]tidy error: /checkout/compiler/rustc_ty_utils/src/opaque_types.rs:360: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
##[error]tidy error: /checkout/compiler/rustc_ast_lowering/src/lib.rs:870: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
##[error]tidy error: /checkout/tests/ui/type-alias-impl-trait/type-alias-impl-trait-assoc-impl-trait.rs:16: line longer than 100 chars
##[error]tidy error: /checkout/tests/ui/type-alias-impl-trait/type-alias-impl-trait-assoc-impl-trait.rs:16: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
removing old virtual environment
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10'
Requirement already satisfied: pip in ./build/venv/lib/python3.10/site-packages (24.3.1)
All checks passed!
checking python file formatting
28 files already formatted
checking C++ file formatting
checking C++ file formatting
some tidy checks failed
Command has failed. Rerun with -v to see more details.
  local time: Fri Jan 10 09:06:17 UTC 2025
  network time: Fri, 10 Jan 2025 09:06:17 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@bors
Copy link
Contributor

bors commented Jan 15, 2025

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

@Dylan-DPC Dylan-DPC removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 12, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Development

Successfully merging this pull request may close these issues.

8 participants