]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_infer/src/traits/error_reporting/mod.rs
New upstream version 1.57.0+dfsg1
[rustc.git] / compiler / rustc_infer / src / traits / error_reporting / mod.rs
index d0bd508bc257f2dfd4fd63b71bdd0e65c669a7f2..9dbfa3a850ba848d505e469ac4edf8ee44f33f3b 100644 (file)
@@ -83,10 +83,6 @@ pub fn report_object_safety_error(
                     messages.push(msg.clone());
                 }
             }
-            if trait_span.is_some() {
-                // Only provide the help if its a local trait, otherwise it's not actionable.
-                violation.solution(&mut err);
-            }
         }
     }
     let has_multi_span = !multi_span.is_empty();
@@ -104,5 +100,13 @@ pub fn report_object_safety_error(
          to be resolvable dynamically; for more information visit \
          <https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
     );
+    if trait_span.is_some() {
+        let mut reported_violations: Vec<_> = reported_violations.into_iter().collect();
+        reported_violations.sort();
+        for violation in reported_violations {
+            // Only provide the help if its a local trait, otherwise it's not actionable.
+            violation.solution(&mut err);
+        }
+    }
     err
 }