diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs
index 47d8e5993fd82..876a8df75c518 100644
--- a/compiler/rustc_resolve/src/imports.rs
+++ b/compiler/rustc_resolve/src/imports.rs
@@ -321,6 +321,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                         } else if !old_binding.vis.is_at_least(binding.vis, this.tcx) {
                             // We are glob-importing the same item but with greater visibility.
                             resolution.binding = Some(binding);
+                        } else if binding.is_ambiguity() {
+                            resolution.binding = Some(binding)
                         }
                     }
                     (old_glob @ true, false) | (old_glob @ false, true) => {
@@ -393,7 +395,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
             let t = f(self, resolution);
 
             match resolution.binding() {
-                _ if old_binding.is_some() => return t,
                 None => return t,
                 Some(binding) => match old_binding {
                     Some(old_binding) if ptr::eq(old_binding, binding) => return t,
@@ -402,7 +403,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
             }
         };
 
-        // Define `binding` in `module`s glob importers.
+        // Define or update `binding` in `module`s glob importers.
         for import in module.glob_importers.borrow_mut().iter() {
             let mut ident = key.ident;
             let scope = match ident.span.reverse_glob_adjust(module.expansion, import.span) {
diff --git a/tests/ui/imports/duplicate.rs b/tests/ui/imports/duplicate.rs
index db6538969ec71..0977bfef9aaa1 100644
--- a/tests/ui/imports/duplicate.rs
+++ b/tests/ui/imports/duplicate.rs
@@ -33,7 +33,7 @@ mod g {
 fn main() {
     e::foo();
     f::foo(); //~ ERROR `foo` is ambiguous
-    g::foo();
+    g::foo(); //~ ERROR `foo` is ambiguous
 }
 
 mod ambiguous_module_errors {
diff --git a/tests/ui/imports/duplicate.stderr b/tests/ui/imports/duplicate.stderr
index 997a2741b382c..33db11e3379c5 100644
--- a/tests/ui/imports/duplicate.stderr
+++ b/tests/ui/imports/duplicate.stderr
@@ -48,6 +48,26 @@ LL |     pub use b::*;
    |             ^^^^
    = help: consider adding an explicit import of `foo` to disambiguate
 
+error[E0659]: `foo` is ambiguous
+  --> $DIR/duplicate.rs:36:8
+   |
+LL |     g::foo();
+   |        ^^^ ambiguous name
+   |
+   = note: ambiguous because of multiple glob imports of a name in the same module
+note: `foo` could refer to the function imported here
+  --> $DIR/duplicate.rs:24:13
+   |
+LL |     pub use a::*;
+   |             ^^^^
+   = help: consider adding an explicit import of `foo` to disambiguate
+note: `foo` could also refer to the function imported here
+  --> $DIR/duplicate.rs:25:13
+   |
+LL |     pub use b::*;
+   |             ^^^^
+   = help: consider adding an explicit import of `foo` to disambiguate
+
 error[E0659]: `foo` is ambiguous
   --> $DIR/duplicate.rs:49:9
    |
@@ -68,7 +88,7 @@ LL |     use self::m2::*;
    |         ^^^^^^^^^^^
    = help: consider adding an explicit import of `foo` to disambiguate
 
-error: aborting due to 4 previous errors
+error: aborting due to 5 previous errors
 
 Some errors have detailed explanations: E0252, E0659.
 For more information about an error, try `rustc --explain E0252`.
diff --git a/tests/ui/resolve/issue-105235.rs b/tests/ui/resolve/issue-105235.rs
new file mode 100644
index 0000000000000..41053addc0479
--- /dev/null
+++ b/tests/ui/resolve/issue-105235.rs
@@ -0,0 +1,30 @@
+// edition: 2021
+// check-pass
+
+mod abc {
+    pub struct Beeblebrox;
+    pub struct Zaphod;
+}
+
+mod foo {
+    pub mod bar {
+        use crate::abc::*;
+
+        #[derive(Debug)]
+        pub enum Zaphod {
+            Whale,
+            President,
+        }
+    }
+    pub use bar::*;
+}
+
+mod baz {
+    pub fn do_something() {
+        println!("{:?}", crate::foo::Zaphod::Whale);
+    }
+}
+
+fn main() {
+    baz::do_something();
+}
diff --git a/tests/ui/resolve/issue-112713.rs b/tests/ui/resolve/issue-112713.rs
new file mode 100644
index 0000000000000..a1824054d542d
--- /dev/null
+++ b/tests/ui/resolve/issue-112713.rs
@@ -0,0 +1,16 @@
+// edition: 2021
+
+pub fn foo() -> u32 {
+    use sub::*;
+    C //~ERROR `C` is ambiguous
+}
+
+mod sub {
+    mod mod1 { pub const C: u32 = 1; }
+    mod mod2 { pub const C: u32 = 2; }
+
+    pub use mod1::*;
+    pub use mod2::*;
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-112713.stderr b/tests/ui/resolve/issue-112713.stderr
new file mode 100644
index 0000000000000..7fc965b546a1f
--- /dev/null
+++ b/tests/ui/resolve/issue-112713.stderr
@@ -0,0 +1,23 @@
+error[E0659]: `C` is ambiguous
+  --> $DIR/issue-112713.rs:5:5
+   |
+LL |     C
+   |     ^ ambiguous name
+   |
+   = note: ambiguous because of multiple glob imports of a name in the same module
+note: `C` could refer to the constant imported here
+  --> $DIR/issue-112713.rs:12:13
+   |
+LL |     pub use mod1::*;
+   |             ^^^^^^^
+   = help: consider adding an explicit import of `C` to disambiguate
+note: `C` could also refer to the constant imported here
+  --> $DIR/issue-112713.rs:13:13
+   |
+LL |     pub use mod2::*;
+   |             ^^^^^^^
+   = help: consider adding an explicit import of `C` to disambiguate
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/tests/ui/resolve/issue-112743.rs b/tests/ui/resolve/issue-112743.rs
new file mode 100644
index 0000000000000..89585f30cbab6
--- /dev/null
+++ b/tests/ui/resolve/issue-112743.rs
@@ -0,0 +1,25 @@
+// https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883
+
+macro_rules! m {
+    () => {
+      pub fn EVP_PKEY_id() {}
+    };
+}
+
+mod openssl {
+    pub use self::evp::*;
+    pub use self::handwritten::*;
+
+    mod evp {
+      m!();
+    }
+
+    mod handwritten {
+      m!();
+    }
+}
+use openssl::*;
+
+fn main() {
+    EVP_PKEY_id(); //~ ERROR `EVP_PKEY_id` is ambiguous
+}
diff --git a/tests/ui/resolve/issue-112743.stderr b/tests/ui/resolve/issue-112743.stderr
new file mode 100644
index 0000000000000..1cc0ea8a7594b
--- /dev/null
+++ b/tests/ui/resolve/issue-112743.stderr
@@ -0,0 +1,23 @@
+error[E0659]: `EVP_PKEY_id` is ambiguous
+  --> $DIR/issue-112743.rs:24:5
+   |
+LL |     EVP_PKEY_id();
+   |     ^^^^^^^^^^^ ambiguous name
+   |
+   = note: ambiguous because of multiple glob imports of a name in the same module
+note: `EVP_PKEY_id` could refer to the function imported here
+  --> $DIR/issue-112743.rs:10:13
+   |
+LL |     pub use self::evp::*;
+   |             ^^^^^^^^^^^^
+   = help: consider adding an explicit import of `EVP_PKEY_id` to disambiguate
+note: `EVP_PKEY_id` could also refer to the function imported here
+  --> $DIR/issue-112743.rs:11:13
+   |
+LL |     pub use self::handwritten::*;
+   |             ^^^^^^^^^^^^^^^^^^^^
+   = help: consider adding an explicit import of `EVP_PKEY_id` to disambiguate
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/tests/ui/resolve/issue-56593-0.rs b/tests/ui/resolve/issue-56593-0.rs
new file mode 100644
index 0000000000000..67b6f22e5321b
--- /dev/null
+++ b/tests/ui/resolve/issue-56593-0.rs
@@ -0,0 +1,21 @@
+// check-pass
+
+mod a {
+    pub trait P {}
+}
+pub use a::*;
+
+mod b {
+    #[derive(Clone)]
+    pub enum P {
+        A
+    }
+}
+pub use b::P;
+
+mod c {
+    use crate::*;
+    pub struct S(Vec<P>);
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-56593-1.rs b/tests/ui/resolve/issue-56593-1.rs
new file mode 100644
index 0000000000000..d7308624ef7fe
--- /dev/null
+++ b/tests/ui/resolve/issue-56593-1.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+struct Foo;
+
+mod foo {
+    use super::*;
+
+    #[derive(Debug)]
+    pub struct Foo;
+}
+
+mod bar {
+    use super::foo::*;
+
+    fn bar(_: Foo) {}
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-56593-2.rs b/tests/ui/resolve/issue-56593-2.rs
new file mode 100644
index 0000000000000..b90c22f0aba37
--- /dev/null
+++ b/tests/ui/resolve/issue-56593-2.rs
@@ -0,0 +1,26 @@
+// check-pass
+
+use thing::*;
+
+#[derive(Debug)]
+pub enum Thing {
+    Foo,
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn test_thing() {
+        let thing = Thing::Foo;
+    }
+}
+
+mod thing {
+    pub enum Thing {
+        Bar,
+    }
+}
+
+fn main() {}