Skip to content

Conversation

@petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Oct 22, 2025

So in cross-crate scenarios they can work in the same way as in crate-local scenarios.

Resurrection of #114682.
One of unblocking steps for #145108.
Fixes #36837.

@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 Oct 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 22, 2025

r? @jdonszelmann

rustbot has assigned @jdonszelmann.
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

@petrochenkov
Copy link
Contributor Author

@bors try

rust-bors bot added a commit that referenced this pull request Oct 22, 2025
resolve: Preserve ambiguous glob reexports in crate metadata
@rust-bors

This comment has been minimized.

@petrochenkov petrochenkov added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 22, 2025
@petrochenkov
Copy link
Contributor Author

cc @LorrensP-2158466 @bvanjoi

@rust-bors
Copy link

rust-bors bot commented Oct 22, 2025

☀️ Try build successful (CI)
Build commit: b4c5508 (b4c55082edd8dec08ce8af276d7054d9c4db20c4, parent: f5e2df741b4a9820a7579f0c8eccc951706a8782)

@petrochenkov
Copy link
Contributor Author

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-147984 created and queued.
🤖 Automatically detected try build b4c5508
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🚧 Experiment pr-147984 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-147984 is completed!
📊 2312 regressed and 2 fixed (721923 total)
📊 1766 spurious results on the retry-regessed-list.txt, consider a retry1 if this is a significant amount.
📰 Open the summary report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

Footnotes

  1. re-run the experiment with crates=https://crater-reports.s3.amazonaws.com/pr-147984/retry-regressed-list.txt

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Oct 24, 2025
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 24, 2025
@petrochenkov
Copy link
Contributor Author

That's a lot of breakage.
Mostly from dependencies, including various version of openssl that we've seen previously.
I'll demote this error to always be reported as a lint in cross-crate scenarios, and then rerun crater.

So in cross-crate scenarios they can work in the same way as in crate-local scenarios.
@rustbot
Copy link
Collaborator

rustbot commented Oct 24, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@petrochenkov
Copy link
Contributor Author

@bors try

@craterbot run mode=check-only p=1 crates=https://crater-reports.s3.amazonaws.com/pr-147984/retry-regressed-list.txt

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 24, 2025
resolve: Preserve ambiguous glob reexports in crate metadata
@petrochenkov petrochenkov added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 24, 2025
@rust-bors
Copy link

rust-bors bot commented Oct 24, 2025

☀️ Try build successful (CI)
Build commit: c6359cd (c6359cd3b4418e8472bae1a89c242796f2b86d56, parent: 75948c8bb3bd37f1e8ee20273a04edea4c1f84f8)

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Oct 25, 2025
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 27, 2025
@petrochenkov
Copy link
Contributor Author

74 regressions are just due to ambiguous_glob_imports being deny-by-default.
We could potentially introduce a separate warn-by-default lint extern_ambiguous_glob_imports to soften the transition.

There are 3 other non-spurious regressions from this change:

  • polywrap_http_plugin-0.1.11 - when resolving to an ambigous glob recovery picks up a different resolution than previously (polywrap_msgpack_serde::Result -> serde_json::Result), it has some chain effects resulting in errors
  • polywrap_logger_plugin-0.1.11 - same as polywrap_http_plugin-0.1.11
  • Dhayson.six-degrees-bot.96f810355aa802b6df7a51f2d5c5cdd3d4aba468 - when resolving to an ambigous glob recovery picks up a different resolution than previously (crate::client::Error -> nostr_relay_pool::prelude::Error), it has some chain effects resulting in errors

I think this amount of breakage is acceptable.
Fixes to polywrap_* crates were already sent (polywrap/rust-wrap-client#259), but ignored.
Dhayson.six-degrees-bot.96f810355aa802b6df7a51f2d5c5cdd3d4aba468 is unpublished, so probably no need to send a fix.

@petrochenkov
Copy link
Contributor Author

Change description for the lang team

This PR implements a long stanging missing piece in cross-crate reexports.

Currently ambiguous glob imports/reexports produce an error like this on local use.

// Crate `mylib`

mod m1 {
    pub struct S {}
}
mod m2 {
    pub struct S {}
}

pub use m1::*;
pub use m2::*;

fn main() {
	let s = self::S {}; // ERROR `S` is ambiguous
}

However, from other crates such reexports are entirely invisible, because they are ignored when encoding rlib metadata.

let s = mylib::S {}; // ERROR cannot resolve `S` in module `mylib`

use mylib::*; // OK, empty glob import, puts no names into the current module

This PR implements the missing metadata encoding and the reexports can now be observed from other crates, so the behavior becomes identical in cross-crate and crate-local scenarios.

let s = mylib::S {}; // ERROR `S` is ambiguous

use mylib::*; // OK, puts one name `S` into the current module, that will produce errors on actual use

// In particular, if we had another glob import importing `S` here, then there will be a new conflict (only on actual use).
// That's why the change is potentially breaking, see the breakage analysis in the comment above.
use thylib::*; // Also imports `S`

@petrochenkov petrochenkov added S-waiting-on-t-lang Status: Awaiting decision from T-lang T-lang Relevant to the language team I-lang-nominated Nominated for discussion during a lang team meeting. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 28, 2025
@traviscross traviscross added the P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang label Oct 29, 2025
@joshtriplett joshtriplett added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Oct 29, 2025
@traviscross traviscross removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 29, 2025
@traviscross
Copy link
Contributor

We talked about this and ended up liking it. This preserves what I might call "ambiguity monotonicity" -- adding ambiguity should never reduce ambiguity warnings.

We'd also like to see a def-site warning about these cases paired with this -- in this PR or otherwise concurrently -- if possible.

@rfcbot fcp merge

@rust-rfcbot
Copy link
Collaborator

rust-rfcbot commented Oct 29, 2025

Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 29, 2025
@nikomatsakis
Copy link
Contributor

@rfcbot reviewed

@traviscross traviscross added I-lang-radar Items that are on lang's radar and will need eventual work or consideration. and removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Oct 29, 2025
@joshtriplett
Copy link
Member

joshtriplett commented Oct 29, 2025

FWIW I'd personally like to see that proposed additional warning be in a separate PR, not mixed into this one. I do want to see that warning too, though.

@tmandry
Copy link
Member

tmandry commented Oct 29, 2025

I think a def-site warning is important to "shift left" failures like this.

We won't be catching cases where the ambiguity comes from a dependency adding an item in a subsequent version. @nikomatsakis made a suggestion to lint anytime we glob export from two different crates, which I liked. Otherwise, we can at least catch cases where there is a known conflict at the time of writing the code.

@rfcbot reviewed

@rust-rfcbot rust-rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Oct 29, 2025
@rust-rfcbot
Copy link
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

@petrochenkov
Copy link
Contributor Author

petrochenkov commented Oct 29, 2025

We'd also like to see a def-site warning about these cases paired with this

I think a def-site warning is important to "shift left" failures like this.

We already have a lint for this - https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#ambiguous-glob-reexports

@petrochenkov
Copy link
Contributor Author

@traviscross

74 regressions are just due to ambiguous_glob_imports being deny-by-default.
We could potentially introduce a separate warn-by-default lint extern_ambiguous_glob_imports to soften the transition.

Is there some decision on this ^^^ ?

@traviscross
Copy link
Contributor

traviscross commented Oct 29, 2025

The FCP, as proposed, is to accept that soft breakage.

(I.e., "soft breakage" due to this being from a deny-by-default lint, that could be allowed and is affected by cap-lints, rather than due to a hard error.)

@traviscross
Copy link
Contributor

We already have a lint for this - https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#ambiguous-glob-reexports

Thanks. Yes, that is the lint we were looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. S-waiting-on-t-lang Status: Awaiting decision from T-lang T-lang Relevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

item_like_imports: Can "ambiguity error" items be reexported?

9 participants