- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
resolve: Preserve ambiguous glob reexports in crate metadata #147984
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
base: master
Are you sure you want to change the base?
Conversation
| rustbot has assigned @jdonszelmann. Use  | 
| @bors try | 
resolve: Preserve ambiguous glob reexports in crate metadata
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
| @craterbot check | 
| 👌 Experiment  ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more | 
| 🚧 Experiment  ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more | 
| 🎉 Experiment  
 Footnotes
 | 
| That's a lot of breakage. | 
So in cross-crate scenarios they can work in the same way as in crate-local scenarios.
aa2fb6e    to
    e388d62      
    Compare
  
    | 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. | 
| @bors try 
 | 
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
resolve: Preserve ambiguous glob reexports in crate metadata
| 74 regressions are just due to  There are 3 other non-spurious regressions from this change: 
 I think this amount of breakage is acceptable. | 
| Change description for the lang teamThis 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 moduleThis 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` | 
| 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 | 
| 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. | 
| @rfcbot reviewed | 
| 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. | 
| 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 | 
| 🔔 This is now entering its final comment period, as per the review above. 🔔 | 
| 
 
 We already have a lint for this - https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#ambiguous-glob-reexports | 
| 
 Is there some decision on this ^^^ ? | 
| 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  | 
| 
 Thanks. Yes, that is the lint we were looking for. | 
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.