Skip to content

Commit 4cd52ea

Browse files
committed
Remove Windows dependency on libc
1 parent cbbeb98 commit 4cd52ea

File tree

5 files changed

+8
-146
lines changed

5 files changed

+8
-146
lines changed

library/core/src/primitive_docs.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -537,18 +537,18 @@ impl () {}
537537
/// ## 4. Get it from C.
538538
///
539539
/// ```
540-
/// # #![feature(rustc_private)]
541-
/// #[allow(unused_extern_crates)]
542-
/// extern crate libc;
543-
///
540+
/// # mod libc {
541+
/// # pub unsafe fn malloc(_size: usize) -> *mut u8 { core::ptr::NonNull::dangling().as_ptr() }
542+
/// # pub unsafe fn free(mem: *mut core::ffi::c_void) {}
543+
/// # }
544544
/// use std::mem;
545545
///
546546
/// unsafe {
547547
/// let my_num: *mut i32 = libc::malloc(mem::size_of::<i32>()) as *mut i32;
548548
/// if my_num.is_null() {
549549
/// panic!("failed to allocate memory");
550550
/// }
551-
/// libc::free(my_num as *mut libc::c_void);
551+
/// libc::free(my_num as *mut core::ffi::c_void);
552552
/// }
553553
/// ```
554554
///

library/std/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ addr2line = { version = "0.21.0", optional = true, default-features = false }
3333
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
3434
libc = { version = "0.2.153", default-features = false, features = ['rustc-dep-of-std'], public = true }
3535

36-
[target.'cfg(all(windows, target_env = "msvc"))'.dependencies]
37-
libc = { version = "0.2.153", default-features = false }
38-
3936
[target.'cfg(all(not(target_os = "aix"), not(all(windows, target_env = "msvc", not(target_vendor = "uwp")))))'.dependencies]
4037
object = { version = "0.32.0", default-features = false, optional = true, features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive'] }
4138

library/std/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ extern crate alloc as alloc_crate;
435435
// so include it here even if it's unused.
436436
#[doc(masked)]
437437
#[allow(unused_extern_crates)]
438+
#[cfg(not(all(windows, target_env = "msvc")))]
438439
extern crate libc;
439440

440441
// We always need an unwinder currently for backtraces

library/std/src/os/raw/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(all(windows, target_env = "msvc")))]
2+
13
use crate::any::TypeId;
24

35
macro_rules! ok {

tests/ui-fulldeps/regions-mock-tcx.rs

-138
This file was deleted.

0 commit comments

Comments
 (0)