codemap-diagnostic icon indicating copy to clipboard operation
codemap-diagnostic copied to clipboard

Consider removing `lock.rs` or similar.

Open Lymia opened this issue 6 years ago • 1 comments

This appears to be related to synchronizing multiple processes trying to write output at once, which is likely a rare use case for non-rustc code. At minimum, there should probably be support for renaming the mutex to something other than rustc_errors.

Lymia avatar Jul 14 '19 20:07 Lymia

One could imagine wanting this for a compiler called from a Makefile or a tool like Cargo that runs multiple invocations in parallel.

However, this lock is only relevant on Windows prior to 10 where it needs to make system calls to change colors, otherwise it can rely on the atomicity of write() to dump an ANSI-formatted buffer atomically. This doesn't seem worth having unsafe code for. If a program that uses this library really needs the functionality on older versions of Windows, it can wrap calls to emit with its own lock based on this or other code.

I think we can also get rid of Destination::Terminal and its Windows-specific code because this should be handled by termcolor.

kevinmehall avatar Jul 14 '19 21:07 kevinmehall