Skip to content

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Aug 1, 2025

People unfortunately encounter Binder and EarlyBinder very early on when starting out. In these cases its often very easy to use skip_binder incorrectly. This makes it more explicit that it should generally not be used and points to the relevant rustc-dev-guide chapters.

r? @BoxyUwU

@rustbot rustbot added 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 Aug 1, 2025
@lcnr lcnr force-pushed the skip_binder-comment branch from 78b4cd0 to fc46354 Compare August 1, 2025 08:46
Comment on lines +159 to +161
/// Please read <https://rustc-dev-guide.rust-lang.org/ty_module/instantiating_binders.html>
/// before using this function. It is usually better to discharge the binder using
/// `no_bound_vars` or `instantiate_bound_regions` or something like that.
Copy link
Member

@fmease fmease Aug 1, 2025

Choose a reason for hiding this comment

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

Consider wrapping this and maybe its following paragraphs in a big warning block by surrounding it with <div class="warning"> </div> (note: there needs to be a blank line between the HTML tags and the Markdown content or else the latter would be interpreted as HTML), similarly for the EarlyBinder case.

These get rendered like so: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.expand_free_alias_tys

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I feel I'd need to already mark the "Accessing generic args in the returned value is generally incorrect." as a warning, but that's part of the first line.

I personally don't know how I'd restructure this to add a warning block and would merge this as is

@BoxyUwU
Copy link
Member

BoxyUwU commented Aug 8, 2025

@bors r+ rollup

I agree it'd be nice to have an actual warning here 🤔 but not sure how to structure this to do that nicely. can always do that in a follow up PR

@bors
Copy link
Collaborator

bors commented Aug 8, 2025

📌 Commit fc46354 has been approved by BoxyUwU

It is now in the queue for this repository.

@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 Aug 8, 2025
bors added a commit that referenced this pull request Aug 8, 2025
Rollup of 8 pull requests

Successful merges:

 - #139451 (Add `target_env = "macabi"` and `target_env = "sim"`)
 - #144039 (Use `tcx.short_string()` in more diagnostics)
 - #144192 (atomicrmw on pointers: move integer-pointer cast hacks into backend)
 - #144545 (In rustc_pattern_analysis, put `true` witnesses before `false` witnesses)
 - #144579 (Implement declarative (`macro_rules!`) attribute macros (RFC 3697))
 - #144649 (Account for bare tuples and `Pin` methods in field searching logic)
 - #144775 (more strongly dissuade use of `skip_binder`)
 - #144987 (Enable f16 and f128 on targets that were fixed in LLVM21)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 063e01b into rust-lang:master Aug 9, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 9, 2025
rust-timer added a commit that referenced this pull request Aug 9, 2025
Rollup merge of #144775 - lcnr:skip_binder-comment, r=BoxyUwU

more strongly dissuade use of `skip_binder`

People unfortunately encounter `Binder` and `EarlyBinder` very early on when starting out. In these cases its often very easy to use `skip_binder` incorrectly. This makes it more explicit that it should generally not be used and points to the relevant `rustc-dev-guide` chapters.

r? `@BoxyUwU`
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Aug 9, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#139451 (Add `target_env = "macabi"` and `target_env = "sim"`)
 - rust-lang/rust#144039 (Use `tcx.short_string()` in more diagnostics)
 - rust-lang/rust#144192 (atomicrmw on pointers: move integer-pointer cast hacks into backend)
 - rust-lang/rust#144545 (In rustc_pattern_analysis, put `true` witnesses before `false` witnesses)
 - rust-lang/rust#144579 (Implement declarative (`macro_rules!`) attribute macros (RFC 3697))
 - rust-lang/rust#144649 (Account for bare tuples and `Pin` methods in field searching logic)
 - rust-lang/rust#144775 (more strongly dissuade use of `skip_binder`)
 - rust-lang/rust#144987 (Enable f16 and f128 on targets that were fixed in LLVM21)

r? `@ghost`
`@rustbot` modify labels: rollup
@lcnr lcnr deleted the skip_binder-comment branch August 11, 2025 07:13
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Aug 12, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang#139451 (Add `target_env = "macabi"` and `target_env = "sim"`)
 - rust-lang#144039 (Use `tcx.short_string()` in more diagnostics)
 - rust-lang#144192 (atomicrmw on pointers: move integer-pointer cast hacks into backend)
 - rust-lang#144545 (In rustc_pattern_analysis, put `true` witnesses before `false` witnesses)
 - rust-lang#144579 (Implement declarative (`macro_rules!`) attribute macros (RFC 3697))
 - rust-lang#144649 (Account for bare tuples and `Pin` methods in field searching logic)
 - rust-lang#144775 (more strongly dissuade use of `skip_binder`)
 - rust-lang#144987 (Enable f16 and f128 on targets that were fixed in LLVM21)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

5 participants