| ... | ... | @@ -2795,21 +2795,32 @@ pub fn getErrorValueFromSlice(pt: Zcu.PerThread, name: []const u8) Allocator.Err |
| 2795 | 2795 | /// Removes any entry from `Zcu.failed_files` associated with `file`. Acquires `Compilation.mutex` as needed. |
| 2796 | 2796 | /// `file.zir` must be unchanged from the last update, as it is used to determine if there is such an entry. |
| 2797 | 2797 | fn lockAndClearFileCompileError(pt: Zcu.PerThread, file: *Zcu.File) void { |
| 2798 | | switch (file.getMode()) { |
| 2799 | | .zig => { |
| 2800 | | const zir = file.zir orelse return; |
| 2801 | | if (!zir.hasCompileErrors()) return; |
| 2802 | | }, |
| 2803 | | .zon => { |
| 2804 | | const zoir = file.zoir orelse return; |
| 2805 | | if (!zoir.hasCompileErrors()) return; |
| 2798 | const maybe_has_error = switch (file.status) { |
| 2799 | .never_loaded => false, |
| 2800 | .retryable_failure => true, |
| 2801 | .astgen_failure => true, |
| 2802 | .success => switch (file.getMode()) { |
| 2803 | .zig => has_error: { |
| 2804 | const zir = file.zir orelse break :has_error false; |
| 2805 | break :has_error zir.hasCompileErrors(); |
| 2806 | }, |
| 2807 | .zon => has_error: { |
| 2808 | const zoir = file.zoir orelse break :has_error false; |
| 2809 | break :has_error zoir.hasCompileErrors(); |
| 2810 | }, |
| 2806 | 2811 | }, |
| 2812 | }; |
| 2813 | |
| 2814 | // If runtime safety is on, let's quickly lock the mutex and check anyway. |
| 2815 | if (!maybe_has_error and !std.debug.runtime_safety) { |
| 2816 | return; |
| 2807 | 2817 | } |
| 2808 | 2818 | |
| 2809 | 2819 | pt.zcu.comp.mutex.lock(); |
| 2810 | 2820 | defer pt.zcu.comp.mutex.unlock(); |
| 2811 | 2821 | if (pt.zcu.failed_files.fetchSwapRemove(file)) |kv| { |
| 2812 | | if (kv.value) |msg| msg.destroy(pt.zcu.gpa); // Delete previous error message. |
| 2822 | assert(maybe_has_error); // the runtime safety case above |
| 2823 | if (kv.value) |msg| msg.destroy(pt.zcu.gpa); // delete previous error message |
| 2813 | 2824 | } |
| 2814 | 2825 | } |
| 2815 | 2826 | |