Skip to content

add scope! and extend! temporary scoping operators - #160297

Draft
dianne wants to merge 6 commits into
rust-lang:mainfrom
dianne:scope-extend-new
Draft

add scope! and extend! temporary scoping operators#160297
dianne wants to merge 6 commits into
rust-lang:mainfrom
dianne:scope-extend-new

Conversation

@dianne

@dianne dianne commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This is my initial take on the scope! and extend! operators proposed by @traviscross. I've done a bit of interpretation; the exact semantics will need to be discussed. Part of rust-lang/rust-project-goals#648, "Redesigning super let".

Diagnostics, tests, documentation, comments, self-review, code cleanup, splitting this PR up, the PR descriptions, and probably other things are all very much unfinished. There's TODOs so tidy will fail. The operators themselves seem to work just fine though, so far. I've included a non-comprehensive demo in the form of a UI test: scope-extend.rs.

This is implemented on top of the (non-semantics-changing) refactor of temporary scoping I did as part of #146098. The first three commits are the tests and the refactor from that PR.

Since this experiment is meant to potentially replace super let statements, I'm piggy-backing off of the super_let feature gate for now. I figure if this works out and we migrate off of super let, we can rename the feature gate, but I could create a separate gate and merge them later if that'd make more sense.

Tracking issue for super let: #139076.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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. labels Jul 31, 2026
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
fmt: checked 7070 files
tidy check
tidy [rustdoc_json (src)]: `rustdoc-json-types` modified, checking format version
tidy: Skipping binary file check, read-only filesystem
tidy [style (tests)]: /checkout/tests/ui/drop/scope-extend.rs:1: 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
tidy [style (tests)]: FAIL
removing old virtual environment
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'venv'
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'virtualenv'
Requirement already satisfied: pip in ./build/venv/lib/python3.10/site-packages (26.1.2)
Collecting pip
---
    ╭▸ compiler/rustc_hir_analysis/src/check/region.rs:289:36
    │
289 │                 // be careful with labled re-scoping operators
    ╰╴                                   ━━━━━━
rerun with `--bless` to fix typos: `./x.py test tidy --extra-checks=spellcheck --bless`
tidy [extra_checks:spellcheck]: checks with external tool 'typos' failed
tidy [extra_checks:spellcheck]: FAIL
yarn install v1.22.22
warning package.json: No license field
warning ../../package.json: License should be a valid SPDX license expression
warning No license field
[1/4] Resolving packages...
---
Running eslint on rustdoc JS files
info: ES-Check: checking 7 files...
info: ✓ ES-Check passed! All files are ES10 compatible.
typechecking javascript files
tidy: The following checks failed: extra_checks:spellcheck, style (tests)
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Currently active steps:
test::Tidy {  } at src/bootstrap/src/core/build_steps/test.rs:1606
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/checkout --cargo-path=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/checkout/obj/build --concurrency=4 --npm-path=/node/bin/yarn --ci=true --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1627:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1684:29

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:02:43
  local time: Fri Jul 31 18:42:56 UTC 2026
  network time: Fri, 31 Jul 2026 18:42:56 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants