Skip to content

Misc cleanups of generic_arg_infer related HIR logic #142678

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 3 commits into
base: master
Choose a base branch
from

Conversation

BoxyUwU
Copy link
Member

@BoxyUwU BoxyUwU commented Jun 18, 2025

@rustbot
Copy link
Collaborator

rustbot commented Jun 18, 2025

nnethercote is not on the review rotation at the moment.
They may take a while to respond.

@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 Jun 18, 2025
@BoxyUwU BoxyUwU changed the title Misc cleanups of generic_arg_infer related logic Misc cleanups of generic_arg_infer related HIR logic Jun 18, 2025
/// ambiguous context the parameter is instantiated with an uninhabited type making the
/// [`ConstArgKind::Infer`] variant unusable and [`GenericArg::Infer`] is used instead.
/// For an explanation of the `Unambig` generic parameter see the dev-guide:
/// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
Copy link
Member

@fmease fmease Jun 18, 2025

Choose a reason for hiding this comment

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

All these links need to be wrapped in < and >, otherwise they don't get linkified.

E.g.,

Suggested change
/// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
/// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>

(Not sure if CI will catch this but it prolly will (lint: rustdoc::bare_urls))

Copy link
Member Author

Choose a reason for hiding this comment

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

ah...

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
 Documenting rustc_attr_data_structures v0.0.0 (/checkout/compiler/rustc_attr_data_structures)
error: this URL is not a hyperlink
   --> compiler/rustc_hir/src/hir.rs:411:5
    |
411 | /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: bare URLs are not automatically turned into clickable links
    = note: `-D rustdoc::bare-urls` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(rustdoc::bare_urls)]`
help: use an automatic link instead
    |
411 | /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
    |     +                                                                          +

error: this URL is not a hyperlink
   --> compiler/rustc_hir/src/hir.rs:431:9
    |
431 |     /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
    |
431 |     /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
    |         +                                                                          +

error: this URL is not a hyperlink
   --> compiler/rustc_hir/src/hir.rs:450:9
    |
450 |     /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
    |
450 |     /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
    |         +                                                                          +

error: this URL is not a hyperlink
   --> compiler/rustc_hir/src/hir.rs:484:5
    |
484 | /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
    |
484 | /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
    |     +                                                                          +

error: this URL is not a hyperlink
    --> compiler/rustc_hir/src/hir.rs:3313:5
     |
3313 | /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
     |
3313 | /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
     |     +                                                                          +

error: this URL is not a hyperlink
    --> compiler/rustc_hir/src/hir.rs:3332:9
     |
3332 |     /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
     |
3332 |     /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
     |         +                                                                          +

error: this URL is not a hyperlink
    --> compiler/rustc_hir/src/hir.rs:3351:9
     |
3351 |     /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
     |
3351 |     /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
     |         +                                                                          +

error: this URL is not a hyperlink
    --> compiler/rustc_hir/src/hir.rs:3656:5
     |
3656 | /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
     |
3656 | /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
     |     +                                                                          +

error: this URL is not a hyperlink
   --> compiler/rustc_hir/src/intravisit.rs:368:9
    |
368 |     /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
    |
368 |     /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
    |         +                                                                          +

error: this URL is not a hyperlink
   --> compiler/rustc_hir/src/intravisit.rs:379:9
    |
379 |     /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
    |
379 |     /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
    |         +                                                                          +

error: this URL is not a hyperlink
   --> compiler/rustc_hir/src/intravisit.rs:521:9
    |
521 |     /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
    |
521 |     /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
    |         +                                                                          +

error: this URL is not a hyperlink
   --> compiler/rustc_hir/src/intravisit.rs:532:9
    |
532 |     /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
    |
532 |     /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
    |         +                                                                          +

error: this URL is not a hyperlink
   --> compiler/rustc_hir/src/intravisit.rs:985:5
    |
985 | /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
    |
985 | /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
    |     +                                                                          +

error: this URL is not a hyperlink
   --> compiler/rustc_hir/src/intravisit.rs:997:5
    |
997 | /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
    |
997 | /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
    |     +                                                                          +

error: this URL is not a hyperlink
    --> compiler/rustc_hir/src/intravisit.rs:1051:5
     |
1051 | /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
     |
1051 | /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
     |     +                                                                          +

error: this URL is not a hyperlink
    --> compiler/rustc_hir/src/intravisit.rs:1066:5
     |
1066 | /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
     |
1066 | /// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
     |     +                                                                          +

error: could not document `rustc_hir`
warning: build failed, waiting for other jobs to finish...
Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:01:35
  local time: Wed Jun 18 15:52:52 UTC 2025
  network time: Wed, 18 Jun 2025 15:52:52 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

// SAFETY: `repr(u8)` is required so that `TyKind<()>` and `TyKind<!>` are layout compatible
#[repr(u8, C)]
#[derive(Debug, Clone, Copy, HashStable_Generic)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why these new derives?

Copy link
Member Author

Choose a reason for hiding this comment

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

not new I just moved them below all the comments

/// unambiguously a const or ambiguous as to whether it is a type or a const. When in an
/// ambiguous context the parameter is instantiated with an uninhabited type making the
/// [`ConstArgKind::Infer`] variant unusable and [`GenericArg::Infer`] is used instead.
/// For an explanation of the `Unambig` generic parameter see the dev-guide:
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a lot of links to the same guide section. Are they all necessary? Maybe just the ones on types, and cut the ones on methods? Feels like the balance between "thoroughness" and "don't repeat yourself" is off?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I went a bit heavy here on just linking it from everywhere that people might wind up having questions. I don't have a good sense for if people would go looking at the API docs on ConstArg/Ty if they find things confusing in the methods.

Happy to just only link to the dev-guide docs from the types themselves instead of the methods though if you think that would make more sense and still be useful for people

Copy link
Member

@workingjubilee workingjubilee Jun 19, 2025

Choose a reason for hiding this comment

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

Yeah, type-level or trait-level linkage introducing the concepts the type or trait's associated items reference makes more sense to me.

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.

6 participants