Skip to content

Prevent inlining of foreign items through glob reexports named _ - #165922

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
GuillaumeGomez:foreign-glob-anonymous-reexport
Nov 16, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
GuillaumeGomez:foreign-glob-anonymous-reexport

Conversation

@GuillaumeGomez

@GuillaumeGomez GuillaumeGomez commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #97615.

We didn't apply the _ name check for glob reexports. This PR adds it.

r? @Urgau

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Nov 13, 2026
return;
}
let mut segments = ThinVec::new();
if !module_def_id.is_local() && !module_def_id.is_crate_root() {

@GuillaumeGomez GuillaumeGomez Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Interestingly enough, the paths were incomplete before this change. Basically, if the module_def_id is not the crate root and isn't local, we need to prepend it with the crate's name, otherwise it's just... strange.

View changes since the review

//@ has - '//*[@id="main-content"]//*[@class="item-table reexports"]/dt//code' \
// 'pub use reexport_glob_cross_crate::prelude::TraitA as _;'
//@ has - '//*[@id="main-content"]//*[@class="item-table reexports"]/dt//code' \
// 'pub use reexport_glob_cross_crate::prelude::TraitB as _;'

@GuillaumeGomez GuillaumeGomez Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So without the change I described above, the path here would be prelude::TraitB as _;. Which is invalid/weird.

View changes since the review

Comment thread src/librustdoc/clean/inline.rs Outdated
Comment on lines +754 to +757
args: clean::GenericArgs::AngleBracketed {
args: Default::default(),
constraints: ThinVec::new(),
},

@notriddle notriddle Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You know, maybe we should

impl Default for GenericArgs {
  fn default() -> GenericArgs {
    GenericArgs::AngleBracketed {
      args: Default::default(),
      constraints: Default::default()
    }
  }
}

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

... Yes. 😆

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hum actually no. Sorry didn't pay attention that it's an enum. I'll add an empty_bracketed method though.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Cleaned the code a bit by creating a new builder method.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

@bors r=notriddle

@rust-bors

rust-bors Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

📌 Commit e25642c has been approved by notriddle

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Nov 16, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 16, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #166011 (Clean revert of recent `String::retain` changes)
 - #165475 (Add a `!type` annotation to a vtable for every supertrait that is a prefix of the vtable)
 - #165881 (fix MSVC calling convention byte counts)
 - #165882 (Add a separate feature gate for EIIs with default impls)
 - #165922 (Prevent inlining of foreign items through glob reexports named `_`)
 - #165979 (Improve index inference diagnostics)
 - #165983 (Update `minifier-rs` dependency version to `0.5.0`)
 - #165613 (Handle trait default values in `mir_for_direct_const`)
 - #165677 (Rewrite relaxed bound policy code)
 - #165861 (cg_llvm: Use an invariant lifetime brand for LLVM attributes)
 - #165990 (gca fixed issue regression tests)
 - #165993 (pipe_subprocess test: use libtest harness)
 - #165998 (Cleanup borrowck)
 - #166005 (add ABI compat checks for new float types)
 - #166009 (Improve `String::insert{,_str}` safety comments)
 - #166021 (Correct and expand E0225 error explanation.)
 - #166029 (rustc-dev-guide subtree update)
 - #166031 (Split packed structs out of `const_struct`)
 - #166032 (Normalize the simd field type before reading its length)
 - #166034 (Three LLVM-type-related cleanups)
 - #166047 (Document AltiVec requirement for powerpc64-unknown-linux-gnuelfv2)
@rust-bors
rust-bors Bot merged commit 29a7030 into rust-lang:main Nov 16, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 16, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 16, 2026
Rollup merge of #165922 - GuillaumeGomez:foreign-glob-anonymous-reexport, r=notriddle

Prevent inlining of foreign items through glob reexports named `_`

Fixes #97615.

We didn't apply the `_` name check for glob reexports. This PR adds it.

r? @Urgau
@GuillaumeGomez
GuillaumeGomez deleted the foreign-glob-anonymous-reexport branch November 16, 2026 18:53
sushink70 pushed a commit to sushink70/miri that referenced this pull request Nov 17, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - rust-lang/rust#166011 (Clean revert of recent `String::retain` changes)
 - rust-lang/rust#165475 (Add a `!type` annotation to a vtable for every supertrait that is a prefix of the vtable)
 - rust-lang/rust#165881 (fix MSVC calling convention byte counts)
 - rust-lang/rust#165882 (Add a separate feature gate for EIIs with default impls)
 - rust-lang/rust#165922 (Prevent inlining of foreign items through glob reexports named `_`)
 - rust-lang/rust#165979 (Improve index inference diagnostics)
 - rust-lang/rust#165983 (Update `minifier-rs` dependency version to `0.5.0`)
 - rust-lang/rust#165613 (Handle trait default values in `mir_for_direct_const`)
 - rust-lang/rust#165677 (Rewrite relaxed bound policy code)
 - rust-lang/rust#165861 (cg_llvm: Use an invariant lifetime brand for LLVM attributes)
 - rust-lang/rust#165990 (gca fixed issue regression tests)
 - rust-lang/rust#165993 (pipe_subprocess test: use libtest harness)
 - rust-lang/rust#165998 (Cleanup borrowck)
 - rust-lang/rust#166005 (add ABI compat checks for new float types)
 - rust-lang/rust#166009 (Improve `String::insert{,_str}` safety comments)
 - rust-lang/rust#166021 (Correct and expand E0225 error explanation.)
 - rust-lang/rust#166029 (rustc-dev-guide subtree update)
 - rust-lang/rust#166031 (Split packed structs out of `const_struct`)
 - rust-lang/rust#166032 (Normalize the simd field type before reading its length)
 - rust-lang/rust#166034 (Three LLVM-type-related cleanups)
 - rust-lang/rust#166047 (Document AltiVec requirement for powerpc64-unknown-linux-gnuelfv2)
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Nov 23, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - rust-lang/rust#166011 (Clean revert of recent `String::retain` changes)
 - rust-lang/rust#165475 (Add a `!type` annotation to a vtable for every supertrait that is a prefix of the vtable)
 - rust-lang/rust#165881 (fix MSVC calling convention byte counts)
 - rust-lang/rust#165882 (Add a separate feature gate for EIIs with default impls)
 - rust-lang/rust#165922 (Prevent inlining of foreign items through glob reexports named `_`)
 - rust-lang/rust#165979 (Improve index inference diagnostics)
 - rust-lang/rust#165983 (Update `minifier-rs` dependency version to `0.5.0`)
 - rust-lang/rust#165613 (Handle trait default values in `mir_for_direct_const`)
 - rust-lang/rust#165677 (Rewrite relaxed bound policy code)
 - rust-lang/rust#165861 (cg_llvm: Use an invariant lifetime brand for LLVM attributes)
 - rust-lang/rust#165990 (gca fixed issue regression tests)
 - rust-lang/rust#165993 (pipe_subprocess test: use libtest harness)
 - rust-lang/rust#165998 (Cleanup borrowck)
 - rust-lang/rust#166005 (add ABI compat checks for new float types)
 - rust-lang/rust#166009 (Improve `String::insert{,_str}` safety comments)
 - rust-lang/rust#166021 (Correct and expand E0225 error explanation.)
 - rust-lang/rust#166029 (rustc-dev-guide subtree update)
 - rust-lang/rust#166031 (Split packed structs out of `const_struct`)
 - rust-lang/rust#166032 (Normalize the simd field type before reading its length)
 - rust-lang/rust#166034 (Three LLVM-type-related cleanups)
 - rust-lang/rust#166047 (Document AltiVec requirement for powerpc64-unknown-linux-gnuelfv2)
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-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rustdoc doesn't play well with use ... as _ syntax

4 participants