-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
resolve: re-export ambiguity as warning #114682
Conversation
I will proceed with this PR once #115269 is merged, therefore, it is currently marked as a draft. |
ping from triage - can you post your status on this PR? There hasn't been an update in a few months. Thanks! FYI: when a PR is ready for review, send a message containing |
I nearly overlooked this task, but I intend to continue with it within this week. |
ci is green @rustbot ready |
This comment was marked as resolved.
This comment was marked as resolved.
Yes, these errors should be reported as a deprecation lint for some time. |
I've come across an unusual behavior, though I'm unsure if it's a bug: // extern-crate.rs
mod d {
pub fn max() {}
pub(crate) mod max {}
}
mod e {
pub type max = i32;
}
pub use self::d::*;
pub use self::e::*;
// code.rs
use extern_crate::max; // refer to the fn `extern_crate::d::max`
pub fn main() {} but if I delete the module of // extern-crate.rs
mod d {
pub fn max() {}
}
mod e {
pub type max = i32;
}
pub use self::d::*;
pub use self::e::*;
// code.rs
use extern_crate::max; // refers to `extern_crate::e::max`
pub fn main() {} However, I think they should both refer to |
In both examples The disambiguation between |
I've submitted a patch to convert this issue into a warning. At the moment, I think there are still some regressions:
Do you think it would be viable for us to submit PRs for them, instead of introducing them as lint? |
It appears that the author of diesel is not in favor of applying the patch(diesel-rs/diesel#3898 (comment)), so we need to revisit this issue.. |
Hey, There is some ongoing discussion in Diesel about specifically the design around this. According to the original comment above, this appears to be about conflicting type aliases that resolve to different types. I'm not sure I understand if this PR also considers as conflicts:
Thanks, |
☔ The latest upstream changes (presumably #118947) made this pull request unmergeable. Please resolve the merge conflicts. |
@bvanjoi |
@bvanjoi |
.build_reduced_graph_for_external_crate_res(child, false); | ||
} | ||
let children = self.cstore().ambiguity_module_children_untracked(def_id, self.tcx.sess); | ||
for child in &children { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for child in &children { | |
for child in &self.cstore().ambiguity_module_children_untracked(def_id, self.tcx.sess) { |
} | ||
let children = self.cstore().ambiguity_module_children_untracked(def_id, self.tcx.sess); | ||
for child in &children { | ||
let parent_scope = ParentScope::module(module, self); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is common for both loops and can be moved out of them, if borrow checker allows.
@@ -323,7 +324,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { | |||
// imported from the same glob-import statement. | |||
resolution.binding = Some(binding); | |||
} else if res != old_binding.res() { | |||
let binding = if warn_ambiguity { | |||
let binding = if old_binding.is_ambiguity_in_extern_crate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the new binding is an ambiguity in extern crate?
In that case we should probably report a warning instead of an error too.
|
||
children.push(ModChild { ident, res, vis: binding.vis, reexport_chain }); | ||
let ambiguity = binding.is_ambiguity() && !binding.warn_ambiguity; | ||
if ambiguity { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ambiguity { | |
if binding.is_ambiguity() && !binding.warn_ambiguity { |
It feels like I should explain that a bit more in detail. One major point for not wanting to release another diesel 1.4.x patch release is that it is essentially unsupported since nearly 2 years now. I fear that publishing another release will lead to the impression that it is still supported and might raise questions why certain other fixes/features are not backported. That written: I'm not 100% opposed to provide a patch release, it's just something that I see as last resort if there are really no other possibilities. The other important point to note is: As it is unsupported for nearly two years and it seems likely that most user that continues to use it just not apply updates at all. That means releasing another patch update will likely not address the breakage there as there is little evidence that this patch release will be used by the broken crates. Would it be possible to have this as future-incompatible lint that warns for a few stable releases about that breakage and points to an issue so that we can gather some evidence if someone would actually care? Lib.rs still lists 28k weekly downloads for diesel 1.4.8 so there seem to exist quite a few potential users out there. (Also it would be great to have an answer to #114682 (comment) to be certain that diesel 2.x is not affected by this) |
To be precise, it simply aims to maintain ambiguity for the ambiguous items in the external crate. This won't affect any interactions between different namespaces: for example: // extern-crate.rs
mod a {
pub type A = i32;
}
mod b {
pub type A = u32;
}
pub use a::*;
pub use b::*;
// code.rs
use extern_crate::A;
const C: A = 1;//`A` will become an ambiguous item if the PR is merged. but: // extern-crate.rs
mod a {
pub type A = i32;
}
mod b {
pub const A: u8 = 0;
}
pub use a::*;
pub use b::*;
// code.rs
use extern_crate::A;
const C: A = 1; // this case can still compile successfully. |
I used to consider doing this as well, but the regression report indicated that |
My main concern is that while your PR to diesel fixes this particular regression, it does not fix the underlying issue that |
Yes, I agree that this is a reasonable conclusion. There have always been some scenarios that were not considered.
I don't think this is entirely correct, given that |
Ping from triage: I'm closing this due to inactivity, Please reopen when you are ready to continue with this. @rustbot label: +S-inactive |
Fixes #36837
Expose these ambiguous bindings as warnings instead of simply concealing them. This change introduces potential breaking alterations. For instance, code that previously compiled successfully may now fail to compile as expected:
r? @petrochenkov