Skip to content

Commit 275de19

Browse files
committed
Auto merge of #7222 - xanderio:master, r=alexcrichton
enable progress bar for FreeBSD As FreeBSD uses a unsigned long for the IOCTL syscall this code would previously fail to compile. Adding a call to into() fixes this problem. This code should still work on other platfroms as into() is able to 'convert' an u32 into a u32. Also change the cfg attributes so that the working code is used. This may also work on other not yet supported platforms, but it was not tested.
2 parents 42a8c0a + c5c7227 commit 275de19

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Diff for: src/cargo/core/shell.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl ColorChoice {
366366
}
367367
}
368368

369-
#[cfg(any(target_os = "linux", target_os = "macos"))]
369+
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
370370
mod imp {
371371
use std::mem;
372372

@@ -377,7 +377,7 @@ mod imp {
377377
pub fn stderr_width() -> Option<usize> {
378378
unsafe {
379379
let mut winsize: libc::winsize = mem::zeroed();
380-
if libc::ioctl(libc::STDERR_FILENO, libc::TIOCGWINSZ, &mut winsize) < 0 {
380+
if libc::ioctl(libc::STDERR_FILENO, libc::TIOCGWINSZ.into(), &mut winsize) < 0 {
381381
return None;
382382
}
383383
if winsize.ws_col > 0 {
@@ -396,7 +396,10 @@ mod imp {
396396
}
397397
}
398398

399-
#[cfg(all(unix, not(any(target_os = "linux", target_os = "macos"))))]
399+
#[cfg(all(
400+
unix,
401+
not(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))
402+
))]
400403
mod imp {
401404
pub(super) use super::default_err_erase_line as err_erase_line;
402405

@@ -461,7 +464,13 @@ mod imp {
461464
}
462465
}
463466

464-
#[cfg(any(all(unix, not(any(target_os = "linux", target_os = "macos"))), windows,))]
467+
#[cfg(any(
468+
all(
469+
unix,
470+
not(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))
471+
),
472+
windows,
473+
))]
465474
fn default_err_erase_line(shell: &mut Shell) {
466475
if let Some(max_width) = imp::stderr_width() {
467476
let blank = " ".repeat(max_width);

0 commit comments

Comments
 (0)