Skip to content

more strongly dissuade use of skip_binder #144775

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants