Skip to content

Rename ModDefId to ModId and use more#159197

Open
camsteffen wants to merge 4 commits into
rust-lang:mainfrom
camsteffen:more-modid
Open

Rename ModDefId to ModId and use more#159197
camsteffen wants to merge 4 commits into
rust-lang:mainfrom
camsteffen:more-modid

Conversation

@camsteffen

Copy link
Copy Markdown
Contributor

Addresses some FIXMEs.

The ModDefId was used pretty sparingly, and honestly I wondered if it should exist at all. After making these changes, I think the type is worth it. Most notably it is now used in Visibility::Restricted.

I first renamed ModDefId to ModId since I think the former is over-specific, and also this is more in line with BodyId or OwnerId.

I'll wait for initial feedback before fixing rustdoc/clippy.

@rustbot

rustbot commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

HIR ty lowering was modified

cc @fmease

Some changes occurred in exhaustiveness checking

cc @Nadrieril

Some changes occurred in match checking

cc @Nadrieril

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 12, 2026
@rustbot

rustbot commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

r? @JonathanBrouwer

rustbot has assigned @JonathanBrouwer.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 19 candidates

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] askama test:false 0.189
error[E0432]: unresolved import `rustc_hir::def_id::LocalModDefId`
 --> src/librustdoc/clean/inline.rs:9:54
  |
9 | use rustc_hir::def_id::{DefId, DefIdSet, LocalDefId, LocalModDefId};
  |                                                      ^^^^^^^^^^^^^ no `LocalModDefId` in `def_id`
  |
help: a similar name exists in the module
  |
9 - use rustc_hir::def_id::{DefId, DefIdSet, LocalDefId, LocalModDefId};
9 + use rustc_hir::def_id::{DefId, DefIdSet, LocalDefId, LocalDefId};
  |

warning: unused import: `ModId`
  --> src/librustdoc/clean/types.rs:28:40
   |
---

error[E0308]: mismatched types
   --> src/librustdoc/clean/types.rs:917:14
    |
917 |         Some(tcx.visibility(def_id))
    |         ---- ^^^^^^^^^^^^^^^^^^^^^^ expected `Visibility<DefId>`, found `Visibility<ModId>`
    |         |
    |         arguments to this enum variant are incorrect
    |
    = note: expected enum `rustc_middle::ty::Visibility<rustc_span::def_id::DefId>`
               found enum `rustc_middle::ty::Visibility<ModId>`
help: the type constructed contains `rustc_middle::ty::Visibility<ModId>` due to the type of the argument passed
   --> src/librustdoc/clean/types.rs:917:9
    |
917 |         Some(tcx.visibility(def_id))
    |         ^^^^^----------------------^
    |              |
    |              this argument influences the type of `Some`
note: tuple variant defined here
   --> /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/core/src/option.rs:605:4
---
 137 | |     /// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`.
 138 | |     /// The key is:
 139 | |     /// - A unique key corresponding to the invocation of a macro.
...    |
2695 | |     query doc_link_resolutions(def_id: ModId) -> &'tcx DocLinkResMap {
     | |           ^^^^^^^^^^^^^^^^^^^^
...    |
2789 | |     non_query Metadata
2790 | | }
     | |_- in this expansion of `rustc_with_all_queries!`
2791 |
2792 |   rustc_with_all_queries! { define_callbacks! }
     |   --------------------------------------------- in this macro invocation

error[E0308]: mismatched types
    --> src/librustdoc/passes/collect_intra_doc_links.rs:848:49
     |
 848 |     for &trait_ in tcx.doc_link_traits_in_scope(module) {
     |                        ------------------------ ^^^^^^ expected `ModId`, found `DefId`
     |                        |
     |                        arguments to this method are incorrect
     |
note: method defined here
    --> compiler/rustc_middle/src/queries.rs:2701:11
     |
 136 | / rustc_queries! {
 137 | |     /// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`.
 138 | |     /// The key is:
 139 | |     /// - A unique key corresponding to the invocation of a macro.
...    |
2701 | |     query doc_link_traits_in_scope(def_id: ModId) -> &'tcx [DefId] {
     | |           ^^^^^^^^^^^^^^^^^^^^^^^^
...    |
2789 | |     non_query Metadata
2790 | | }
     | |_- in this expansion of `rustc_with_all_queries!`
2791 |
2792 |   rustc_with_all_queries! { define_callbacks! }
     |   --------------------------------------------- in this macro invocation

error[E0277]: the trait bound `LocalModId: std::borrow::Borrow<LocalDefId>` is not satisfied
   --> src/librustdoc/passes/lint/redundant_explicit_links.rs:66:57
    |
 66 |         cx.tcx.resolutions(()).doc_link_resolutions.get(&module_id.expect_local())
    |                                                     --- ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::borrow::Borrow<LocalDefId>` is not implemented for `LocalModId`
    |                                                     |
    |                                                     required by a bound introduced by this call
    |
    = note: required for `LocalDefId` to implement `rustc_data_structures::indexmap::Equivalent<LocalModId>`
note: required by a bound in `rustc_data_structures::indexmap::IndexMap::<K, V, S>::get`
   --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/indexmap-2.14.0/src/map.rs:840:28
    |
838 |     pub fn get<Q>(&self, key: &Q) -> Option<&V>
    |            --- required by a bound in this associated function
839 |     where
840 |         Q: ?Sized + Hash + Equivalent<K>,
    |                            ^^^^^^^^^^^^^ required by this bound in `IndexMap::<K, V, S>::get`

Some errors have detailed explanations: E0277, E0308, E0432.
For more information about an error, try `rustc --explain E0277`.
[RUSTC-TIMING] rustdoc test:false 3.920
error: `rustdoc` (lib) generated 1 warning

@rust-bors

rust-bors Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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

@petrochenkov petrochenkov self-assigned this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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. T-rustdoc Relevant to the rustdoc 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