resolve: re-export ambiguity as warning
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:
// lib.rs
mod a {
pub type C = i8;
}
mod b {
pub type C = i16;
}
pub use a::*;
pub use b::*;
// main.rs
extern crate lib;
mod a {
pub type C = i32;
}
use lib::*;
use a::*;
fn main() {
let _: C = 1; // it will throw an ambiguity error but previous it will not.
}
r? @petrochenkov
I will proceed with this PR once https://github.com/rust-lang/rust/pull/115269 is merged, therefore, it is currently marked as a draft.
Our labels are better for tracking this stuff than github's draft status. Blocked on https://github.com/rust-lang/rust/pull/115269. @rustbot blocked
https://github.com/rust-lang/rust/pull/115269 has landed. @rustbot author
I will proceed with this PR once #115269 is merged, therefore, it is currently marked as a draft. this has been merged
@bvanjoi
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
@rustbot ready to switch to S-waiting-on-review so the PR is in the reviewer's backlog.
I nearly overlooked this task, but I intend to continue with it within this week.
ci is green @rustbot ready
:umbrella: The latest upstream changes (presumably #116092) made this pull request unmergeable. Please resolve the merge conflicts.
ci is green. @rustbot ready
r=me after the style/wording fixes. @rustbot author
Should we need to run the regression test?
I forgot about crater, yes. We should run it.
@bors try
:hourglass: Trying commit 135d52265191cbd97f8b10af8c99d93a3da327a2 with merge 785364c7e5e0804473a3fddfb579798ea14e3493...
:sunny: Try build successful - checks-actions
Build commit: 785364c7e5e0804473a3fddfb579798ea14e3493 (785364c7e5e0804473a3fddfb579798ea14e3493)
@craterbot check
:ok_hand: Experiment pr-114682 created and queued.
:robot: Automatically detected try build 785364c7e5e0804473a3fddfb579798ea14e3493
:mag: You can check out the queue and this experiment's details.
:information_source: Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more
:construction: Experiment pr-114682 is now running
:information_source: Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more
:tada: Experiment pr-114682 is completed!
:bar_chart: 360 regressed and 6 fixed (399777 total)
:newspaper: Open the full report.
:warning: If you notice any spurious failure please add them to the blacklist! :information_source: Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more
Many "No space left on device" errors, need a second crater iteration.
@craterbot check p=1 crates=https://crater-reports.s3.amazonaws.com/pr-114682/retry-regressed-list.txt
:ok_hand: Experiment pr-114682-1 created and queued.
:robot: Automatically detected try build 785364c7e5e0804473a3fddfb579798ea14e3493
:mag: You can check out the queue and this experiment's details.
:information_source: Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more
:construction: Experiment pr-114682-1 is now running
:information_source: Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more
:tada: Experiment pr-114682-1 is completed!
:bar_chart: 296 regressed and 0 fixed (360 total)
:newspaper: Open the full report.
:warning: If you notice any spurious failure please add them to the blacklist! :information_source: Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more
Waiting on the author to triage regressions. @rustbot author
I plan to check this over the weekend.
Most of the regressions were caused by [email protected]:
// extern-crate.rs
macro_rules! m {
() => {
pub fn max() {}
pub(crate) mod max {}
};
}
mod d {
m!{}
}
mod e {
pub type max = i32;
}
pub use self::d::*;
pub use self::e::*;
// code.rs
extern crate extern_crate;
use extern_crate::max; // regression error: max is ambigous name
fn main() {};
reduced for wry:
// extern-crate.rs
mod gio {
pub trait SettingsExt {
fn abc(&self) {}
}
impl<T> SettingsExt for T {}
}
mod gtk {
pub trait SettingsExt {
fn efg(&self) {}
}
impl<T> SettingsExt for T {}
}
pub use gtk::*;
pub use gio::*;
// code.rs
extern crate extern_crate;
use extern_crate::*;
mod auto {
pub trait SettingsExt {
fn ext(&self) {}
}
impl<T> SettingsExt for T {}
}
pub use self::auto::*;
pub fn main() {
let a: u8 = 1;
a.ext(); // regression, no method named `ext` found for type `u8` in the current scope
}
reduced for polywrap_xxx
// extern-crate.rs
mod a {
pub type Result<T> = std::result::Result<T, ()>;
}
mod b {
pub type Result<T> = std::result::Result<T, ()>;
}
pub use a::*;
pub use b::*;
// code.rs
extern crate extern_crate;
use extern_crate::*;
fn a() -> Result<i32, ()> { // regression: type alias takes 1 generic argument but 2 generic arguments were supplied
Ok(1)
}
pub fn main() {}
reduced for manage_relay_users:
// extern1.rs
pub struct Url;
// extern2.rs
extern crate extern1;
pub mod p {
pub use crate::types::*;
pub use crate::*;
}
mod types {
pub mod extern1 {}
}
pub use extern1;
// code.rs
extern crate extern1;
extern crate extern2;
use extern2::p::*;
use extern1::Url; // regression: extern1 is ambigous
fn main() {}
reduced for https://github.com/loganstone/playground:
// extern-crate.rs
mod a {
pub fn log() {}
}
mod b {
pub fn log() {}
}
pub use self::a::*;
pub use self::b::*;
// code.rs
extern crate extern_crate;
use extern_crate::*;
fn main() {
let log = 2; // regression: log` is ambiguous
let _ = log;
}
It seems these regressions are within our expectations. Should we add this as a lint?
Yes, these errors should be reported as a deprecation lint for some time.