From d1d4fb3294316150a9823f3d02d59c3510e0a984 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 29 Jul 2024 08:13:50 +1000 Subject: [PATCH] Reformat `use` declarations. The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options. --- alloc/benches/btree/map.rs | 3 +- alloc/benches/linked_list.rs | 1 + alloc/benches/string.rs | 1 + alloc/benches/vec.rs | 3 +- alloc/benches/vec_deque.rs | 7 +- alloc/benches/vec_deque_append.rs | 3 +- alloc/src/alloc.rs | 8 +- alloc/src/alloc/tests.rs | 3 +- alloc/src/borrow.rs | 7 +- alloc/src/boxed.rs | 17 ++-- alloc/src/boxed/thin.rs | 6 +- alloc/src/collections/binary_heap/mod.rs | 3 +- alloc/src/collections/binary_heap/tests.rs | 6 +- alloc/src/collections/btree/append.rs | 5 +- alloc/src/collections/btree/fix.rs | 7 +- alloc/src/collections/btree/map.rs | 12 +-- alloc/src/collections/btree/map/entry.rs | 5 +- alloc/src/collections/btree/map/tests.rs | 12 +-- alloc/src/collections/btree/mem.rs | 4 +- alloc/src/collections/btree/navigate.rs | 7 +- alloc/src/collections/btree/remove.rs | 7 +- alloc/src/collections/btree/search.rs | 5 +- alloc/src/collections/btree/set.rs | 3 +- alloc/src/collections/btree/set/tests.rs | 5 +- alloc/src/collections/btree/split.rs | 6 +- alloc/src/collections/linked_list.rs | 3 +- alloc/src/collections/linked_list/tests.rs | 12 ++- alloc/src/collections/mod.rs | 7 +- alloc/src/collections/vec_deque/drain.rs | 3 +- alloc/src/collections/vec_deque/into_iter.rs | 7 +- alloc/src/collections/vec_deque/mod.rs | 12 +-- .../src/collections/vec_deque/spec_extend.rs | 4 +- alloc/src/ffi/c_str.rs | 18 ++-- alloc/src/ffi/c_str/tests.rs | 6 +- alloc/src/ffi/mod.rs | 7 +- alloc/src/raw_vec.rs | 3 +- alloc/src/raw_vec/tests.rs | 3 +- alloc/src/rc.rs | 13 ++- alloc/src/rc/tests.rs | 4 +- alloc/src/slice.rs | 1 - alloc/src/slice/tests.rs | 21 +++-- alloc/src/str.rs | 20 ++--- alloc/src/string.rs | 5 +- alloc/src/sync.rs | 4 +- alloc/src/sync/tests.rs | 4 +- alloc/src/task.rs | 6 +- alloc/src/testing/crash_test.rs | 6 +- alloc/src/tests.rs | 1 - alloc/src/vec/cow.rs | 3 +- alloc/src/vec/drain.rs | 2 +- alloc/src/vec/extract_if.rs | 5 +- alloc/src/vec/in_place_collect.rs | 5 +- alloc/src/vec/in_place_drop.rs | 3 +- alloc/src/vec/into_iter.rs | 16 ++-- alloc/src/vec/mod.rs | 5 +- alloc/src/vec/partial_eq.rs | 3 +- alloc/src/vec/spec_extend.rs | 2 +- alloc/src/vec/spec_from_elem.rs | 3 +- alloc/src/vec/spec_from_iter_nested.rs | 6 +- alloc/src/vec/splice.rs | 2 +- alloc/tests/btree_set_hash.rs | 3 +- alloc/tests/slice.rs | 7 +- alloc/tests/str.rs | 3 +- alloc/tests/string.rs | 6 +- alloc/tests/vec.rs | 6 +- alloc/tests/vec_deque.rs | 7 +- alloc/tests/vec_deque_alloc_error.rs | 10 +-- core/benches/any.rs | 1 + core/benches/array.rs | 3 +- core/benches/ascii.rs | 4 +- core/benches/ascii/is_ascii.rs | 4 +- core/benches/fmt.rs | 1 + core/benches/hash/sip.rs | 1 + core/benches/iter.rs | 1 + core/benches/num/flt2dec/mod.rs | 4 +- core/benches/num/flt2dec/strategy/dragon.rs | 3 +- core/benches/num/flt2dec/strategy/grisu.rs | 3 +- core/benches/num/mod.rs | 1 + core/benches/ops.rs | 1 + core/benches/pattern.rs | 3 +- core/benches/slice.rs | 4 +- core/benches/str.rs | 1 + core/benches/str/char_count.rs | 3 +- core/benches/str/debug.rs | 1 + core/benches/str/iter.rs | 3 +- core/src/alloc/global.rs | 3 +- core/src/alloc/layout.rs | 4 +- core/src/alloc/mod.rs | 2 - core/src/any.rs | 4 +- core/src/array/iter.rs | 13 ++- core/src/array/mod.rs | 1 - core/src/ascii.rs | 3 +- core/src/asserting.rs | 6 +- core/src/async_iter/from_iter.rs | 3 +- core/src/cell/lazy.rs | 3 +- core/src/cell/once.rs | 3 +- core/src/char/methods.rs | 3 +- core/src/char/mod.rs | 3 +- core/src/ffi/c_str.rs | 9 +- core/src/ffi/mod.rs | 13 ++- core/src/ffi/va_list.rs | 1 - core/src/fmt/float.rs | 3 +- core/src/fmt/mod.rs | 10 +-- core/src/fmt/num.rs | 5 +- core/src/future/mod.rs | 20 ++--- core/src/hash/mod.rs | 9 +- core/src/hash/sip.rs | 4 +- core/src/hint.rs | 3 +- core/src/intrinsics.rs | 6 +- core/src/intrinsics/mir.rs | 3 +- core/src/iter/adapters/cloned.rs | 8 +- core/src/iter/adapters/copied.rs | 8 +- core/src/iter/adapters/cycle.rs | 3 +- core/src/iter/adapters/enumerate.rs | 5 +- core/src/iter/adapters/filter.rs | 10 ++- core/src/iter/adapters/filter_map.rs | 3 +- core/src/iter/adapters/flatten.rs | 8 +- core/src/iter/adapters/inspect.rs | 3 +- core/src/iter/adapters/map.rs | 5 +- core/src/iter/adapters/map_while.rs | 3 +- core/src/iter/adapters/map_windows.rs | 9 +- core/src/iter/adapters/mod.rs | 37 +++----- core/src/iter/adapters/peekable.rs | 3 +- core/src/iter/adapters/scan.rs | 3 +- core/src/iter/adapters/skip.rs | 4 +- core/src/iter/adapters/skip_while.rs | 3 +- core/src/iter/adapters/step_by.rs | 10 +-- core/src/iter/adapters/take.rs | 6 +- core/src/iter/adapters/take_while.rs | 3 +- core/src/iter/adapters/zip.rs | 5 +- core/src/iter/mod.rs | 77 ++++++++--------- core/src/iter/range.rs | 7 +- core/src/iter/sources.rs | 32 +++---- core/src/iter/sources/empty.rs | 3 +- core/src/iter/sources/successors.rs | 3 +- core/src/iter/traits/iterator.rs | 17 ++-- core/src/iter/traits/mod.rs | 16 ++-- core/src/marker.rs | 3 +- core/src/mem/maybe_uninit.rs | 5 +- core/src/mem/mod.rs | 7 +- core/src/net/display_buffer.rs | 3 +- core/src/net/ip_addr.rs | 3 +- core/src/net/socket_addr.rs | 3 +- core/src/num/bignum.rs | 6 +- core/src/num/dec2flt/mod.rs | 7 +- core/src/num/flt2dec/mod.rs | 1 - core/src/num/flt2dec/strategy/dragon.rs | 4 +- core/src/num/mod.rs | 32 +++---- core/src/num/nonzero.rs | 9 +- core/src/num/saturating.rs | 8 +- core/src/num/wrapping.rs | 8 +- core/src/ops/mod.rs | 55 ++++-------- core/src/option.rs | 7 +- core/src/panic.rs | 3 +- core/src/pin.rs | 4 +- core/src/ptr/metadata.rs | 3 +- core/src/ptr/mod.rs | 12 +-- core/src/ptr/non_null.rs | 5 +- core/src/range.rs | 6 +- core/src/range/iter.rs | 5 +- core/src/slice/ascii.rs | 8 +- core/src/slice/cmp.rs | 4 +- core/src/slice/index.rs | 3 +- core/src/slice/iter.rs | 6 +- core/src/slice/mod.rs | 59 +++++-------- core/src/slice/raw.rs | 4 +- core/src/slice/rotate.rs | 3 +- core/src/slice/sort/select.rs | 1 - core/src/slice/sort/shared/smallsort.rs | 5 +- core/src/slice/sort/stable/drift.rs | 4 +- core/src/slice/sort/stable/merge.rs | 3 +- core/src/slice/sort/stable/mod.rs | 4 +- core/src/slice/sort/stable/quicksort.rs | 4 +- core/src/slice/sort/unstable/heapsort.rs | 3 +- core/src/slice/sort/unstable/mod.rs | 1 - core/src/slice/sort/unstable/quicksort.rs | 4 +- core/src/str/converts.rs | 3 +- core/src/str/iter.rs | 25 +++--- core/src/str/lossy.rs | 8 +- core/src/str/mod.rs | 68 +++++---------- core/src/str/pattern.rs | 6 +- core/src/str/traits.rs | 7 +- core/src/str/validations.rs | 3 +- core/src/sync/atomic.rs | 5 +- core/src/task/wake.rs | 3 +- core/src/tuple.rs | 4 +- core/src/ub_checks.rs | 1 - core/tests/array.rs | 3 +- core/tests/clone.rs | 3 +- core/tests/cmp.rs | 6 +- core/tests/hash/sip.rs | 3 +- core/tests/iter/adapters/chain.rs | 3 +- core/tests/iter/adapters/flatten.rs | 3 +- core/tests/iter/adapters/map_windows.rs | 6 +- core/tests/iter/adapters/peekable.rs | 3 +- core/tests/iter/adapters/zip.rs | 6 +- core/tests/iter/range.rs | 3 +- core/tests/iter/sources.rs | 3 +- core/tests/lazy.rs | 7 +- core/tests/mem.rs | 1 - core/tests/net/ip_addr.rs | 3 +- core/tests/num/flt2dec/mod.rs | 10 +-- core/tests/num/flt2dec/random.rs | 7 +- core/tests/num/flt2dec/strategy/dragon.rs | 3 +- core/tests/num/flt2dec/strategy/grisu.rs | 3 +- core/tests/ops.rs | 5 +- core/tests/pin_macro.rs | 8 +- core/tests/result.rs | 3 +- core/tests/slice.rs | 1 + core/tests/waker.rs | 8 +- panic_unwind/src/emcc.rs | 5 +- proc_macro/src/bridge/arena.rs | 5 +- proc_macro/src/bridge/client.rs | 7 +- proc_macro/src/bridge/fxhash.rs | 3 +- proc_macro/src/bridge/mod.rs | 12 +-- proc_macro/src/bridge/server.rs | 4 +- proc_macro/src/lib.rs | 9 +- std/benches/hash/map.rs | 1 + std/benches/hash/set_ops.rs | 1 + std/src/alloc.rs | 3 +- std/src/ascii.rs | 5 +- std/src/backtrace.rs | 6 +- std/src/collections/hash/map.rs | 6 +- std/src/collections/hash/map/tests.rs | 6 +- std/src/collections/hash/set.rs | 3 +- std/src/collections/hash/set/tests.rs | 1 - std/src/collections/mod.rs | 29 +++---- std/src/env.rs | 4 +- std/src/error.rs | 6 +- std/src/error/tests.rs | 3 +- std/src/f128.rs | 6 +- std/src/f128/tests.rs | 3 +- std/src/f16.rs | 6 +- std/src/f16/tests.rs | 3 +- std/src/f32.rs | 10 +-- std/src/f32/tests.rs | 3 +- std/src/f64.rs | 10 +-- std/src/f64/tests.rs | 3 +- std/src/ffi/c_str.rs | 21 ++--- std/src/ffi/mod.rs | 52 +++++------- std/src/ffi/os_str.rs | 5 +- std/src/fs/tests.rs | 26 +++--- std/src/hash/random.rs | 3 +- std/src/io/buffered/bufreader.rs | 3 +- std/src/io/buffered/bufwriter.rs | 4 +- std/src/io/buffered/linewriter.rs | 3 +- std/src/io/buffered/linewritershim.rs | 3 +- std/src/io/buffered/mod.rs | 12 ++- std/src/io/buffered/tests.rs | 3 +- std/src/io/copy/tests.rs | 7 +- std/src/io/cursor.rs | 3 +- std/src/io/error.rs | 5 +- std/src/io/error/repr_bitpacked.rs | 3 +- std/src/io/error/tests.rs | 6 +- std/src/io/impls.rs | 5 +- std/src/io/mod.rs | 18 ++-- std/src/io/stdio.rs | 3 +- std/src/io/tests.rs | 5 +- std/src/io/util/tests.rs | 1 - std/src/lib.rs | 85 +++++++++---------- std/src/net/ip_addr.rs | 10 +-- std/src/net/mod.rs | 6 +- std/src/net/socket_addr.rs | 13 +-- std/src/net/tcp.rs | 6 +- std/src/net/tcp/tests.rs | 3 +- std/src/net/udp.rs | 3 +- std/src/num.rs | 17 ++-- std/src/os/aix/raw.rs | 1 - std/src/os/android/fs.rs | 3 +- std/src/os/android/net.rs | 2 - std/src/os/darwin/fs.rs | 5 +- std/src/os/dragonfly/fs.rs | 3 +- std/src/os/emscripten/fs.rs | 3 +- std/src/os/espidf/fs.rs | 3 +- std/src/os/fd/owned.rs | 4 +- std/src/os/fd/raw.rs | 8 +- std/src/os/fortanix_sgx/arch.rs | 3 +- std/src/os/fortanix_sgx/mod.rs | 20 ++--- std/src/os/freebsd/fs.rs | 3 +- std/src/os/haiku/fs.rs | 3 +- std/src/os/hermit/io/net.rs | 3 +- std/src/os/illumos/fs.rs | 3 +- std/src/os/ios/mod.rs | 1 - std/src/os/l4re/fs.rs | 3 +- std/src/os/linux/fs.rs | 3 +- std/src/os/linux/net.rs | 2 - std/src/os/macos/mod.rs | 1 - std/src/os/net/linux_ext/tcp.rs | 3 +- std/src/os/net/linux_ext/tests.rs | 14 ++- std/src/os/netbsd/fs.rs | 3 +- std/src/os/openbsd/fs.rs | 3 +- std/src/os/redox/fs.rs | 3 +- std/src/os/solaris/fs.rs | 3 +- std/src/os/solid/io.rs | 4 +- std/src/os/uefi/env.rs | 3 +- std/src/os/unix/fs.rs | 14 +-- std/src/os/unix/net/datagram.rs | 28 +++--- std/src/os/unix/net/tests.rs | 10 +-- std/src/os/unix/net/ucred.rs | 16 ++-- std/src/os/unix/net/ucred/tests.rs | 3 +- std/src/os/unix/process.rs | 8 +- std/src/os/wasi/fs.rs | 7 +- std/src/os/wasi/net/mod.rs | 3 +- std/src/os/windows/ffi.rs | 5 +- std/src/os/windows/fs.rs | 3 +- std/src/os/windows/io/handle.rs | 6 +- std/src/os/windows/io/raw.rs | 6 +- std/src/os/windows/io/socket.rs | 4 +- std/src/os/windows/process.rs | 3 +- std/src/os/xous/services.rs | 3 +- std/src/os/xous/services/dns.rs | 3 +- std/src/os/xous/services/log.rs | 3 +- std/src/os/xous/services/net.rs | 3 +- std/src/os/xous/services/systime.rs | 3 +- std/src/os/xous/services/ticktimer.rs | 3 +- std/src/panic.rs | 15 ++-- std/src/panicking.rs | 21 ++--- std/src/path.rs | 9 +- std/src/path/tests.rs | 4 +- std/src/pipe.rs | 6 +- std/src/process.rs | 7 +- std/src/process/tests.rs | 3 +- std/src/sync/lazy_lock.rs | 3 +- std/src/sync/lazy_lock/tests.rs | 15 ++-- std/src/sync/mod.rs | 19 ++--- std/src/sync/mpmc/array.rs | 1 - std/src/sync/mpmc/context.rs | 1 - std/src/sync/mpmc/counter.rs | 3 +- std/src/sync/mpmc/error.rs | 4 +- std/src/sync/mpmc/list.rs | 1 - std/src/sync/mpmc/mod.rs | 3 +- std/src/sync/mpmc/waker.rs | 1 - std/src/sync/mpmc/zero.rs | 1 - std/src/sync/mpsc/mod.rs | 3 +- std/src/sync/mpsc/sync_tests.rs | 3 +- std/src/sync/mpsc/tests.rs | 3 +- std/src/sync/once/tests.rs | 3 +- std/src/sync/once_lock/tests.rs | 14 ++- std/src/sync/poison.rs | 1 - std/src/sync/rwlock/tests.rs | 3 +- std/src/sys/anonymous_pipe/tests.rs | 6 +- std/src/sys/anonymous_pipe/unix.rs | 15 ++-- std/src/sys/anonymous_pipe/unsupported.rs | 9 +- std/src/sys/anonymous_pipe/windows.rs | 17 ++-- std/src/sys/backtrace.rs | 4 +- std/src/sys/os_str/bytes.rs | 4 +- std/src/sys/os_str/wtf8.rs | 3 +- std/src/sys/pal/common/alloc.rs | 3 +- std/src/sys/pal/common/small_c_string.rs | 3 +- std/src/sys/pal/common/tests.rs | 3 +- std/src/sys/pal/hermit/args.rs | 10 +-- std/src/sys/pal/hermit/fd.rs | 7 +- std/src/sys/pal/hermit/fs.rs | 12 +-- std/src/sys/pal/hermit/io.rs | 4 +- std/src/sys/pal/hermit/net.rs | 7 +- std/src/sys/pal/hermit/os.rs | 8 +- std/src/sys/pal/hermit/thread.rs | 3 +- std/src/sys/pal/hermit/time.rs | 3 +- std/src/sys/pal/itron/error.rs | 4 +- std/src/sys/pal/itron/spin.rs | 8 +- std/src/sys/pal/itron/task.rs | 7 +- std/src/sys/pal/itron/thread.rs | 27 +++--- std/src/sys/pal/itron/time.rs | 6 +- std/src/sys/pal/sgx/abi/mod.rs | 3 +- std/src/sys/pal/sgx/abi/panic.rs | 3 +- std/src/sys/pal/sgx/abi/tls/mod.rs | 3 +- std/src/sys/pal/sgx/abi/usercalls/alloc.rs | 10 +-- std/src/sys/pal/sgx/abi/usercalls/tests.rs | 3 +- std/src/sys/pal/sgx/alloc.rs | 4 +- std/src/sys/pal/sgx/args.rs | 6 +- std/src/sys/pal/sgx/net.rs | 6 +- std/src/sys/pal/sgx/os.rs | 8 +- std/src/sys/pal/sgx/thread.rs | 3 +- std/src/sys/pal/sgx/thread_parking.rs | 3 +- std/src/sys/pal/sgx/waitqueue/mod.rs | 12 ++- std/src/sys/pal/solid/abi/fs.rs | 3 +- std/src/sys/pal/solid/abi/mod.rs | 1 - std/src/sys/pal/solid/abi/sockets.rs | 3 +- std/src/sys/pal/solid/alloc.rs | 6 +- std/src/sys/pal/solid/error.rs | 3 +- std/src/sys/pal/solid/fs.rs | 23 +++-- std/src/sys/pal/solid/io.rs | 6 +- std/src/sys/pal/solid/mod.rs | 3 +- std/src/sys/pal/solid/net.rs | 24 +++--- std/src/sys/pal/solid/os.rs | 18 ++-- std/src/sys/pal/solid/time.rs | 7 +- std/src/sys/pal/teeos/os.rs | 7 +- std/src/sys/pal/teeos/stdio.rs | 3 +- std/src/sys/pal/teeos/thread.rs | 4 +- std/src/sys/pal/uefi/args.rs | 3 +- std/src/sys/pal/uefi/helpers.rs | 4 +- std/src/sys/pal/uefi/mod.rs | 3 +- std/src/sys/pal/uefi/os.rs | 8 +- std/src/sys/pal/uefi/process.rs | 15 ++-- std/src/sys/pal/uefi/time.rs | 6 +- std/src/sys/pal/unix/args.rs | 3 +- std/src/sys/pal/unix/fd.rs | 12 +-- std/src/sys/pal/unix/fd/tests.rs | 3 +- std/src/sys/pal/unix/fs.rs | 51 +++++------ std/src/sys/pal/unix/io.rs | 4 +- std/src/sys/pal/unix/kernel_copy.rs | 11 +-- std/src/sys/pal/unix/kernel_copy/tests.rs | 4 +- std/src/sys/pal/unix/mod.rs | 14 +-- std/src/sys/pal/unix/net.rs | 7 +- std/src/sys/pal/unix/os.rs | 27 ++---- .../sys/pal/unix/process/process_common.rs | 14 ++- .../pal/unix/process/process_common/tests.rs | 4 +- .../sys/pal/unix/process/process_fuchsia.rs | 10 +-- std/src/sys/pal/unix/process/process_unix.rs | 36 ++++---- .../pal/unix/process/process_unsupported.rs | 4 +- .../process_unsupported/wait_status.rs | 3 +- .../sys/pal/unix/process/process_vxworks.rs | 7 +- std/src/sys/pal/unix/process/zircon.rs | 4 +- std/src/sys/pal/unix/rand.rs | 8 +- std/src/sys/pal/unix/stack_overflow.rs | 27 +++--- std/src/sys/pal/unix/thread.rs | 15 ++-- std/src/sys/pal/unix/thread_parking.rs | 3 +- std/src/sys/pal/unix/weak.rs | 3 +- std/src/sys/pal/unsupported/os.rs | 3 +- std/src/sys/pal/unsupported/pipe.rs | 6 +- std/src/sys/pal/unsupported/process.rs | 6 +- std/src/sys/pal/wasi/args.rs | 3 +- std/src/sys/pal/wasi/fs.rs | 7 +- std/src/sys/pal/wasi/helpers.rs | 3 +- std/src/sys/pal/wasi/mod.rs | 5 +- std/src/sys/pal/wasi/os.rs | 8 +- std/src/sys/pal/wasi/thread.rs | 3 +- std/src/sys/pal/wasip2/mod.rs | 5 +- std/src/sys/pal/wasm/alloc.rs | 6 +- std/src/sys/pal/windows/alloc.rs | 3 +- std/src/sys/pal/windows/args.rs | 6 +- std/src/sys/pal/windows/c.rs | 3 +- std/src/sys/pal/windows/fs.rs | 15 ++-- std/src/sys/pal/windows/futex.rs | 9 +- std/src/sys/pal/windows/handle.rs | 10 +-- std/src/sys/pal/windows/io.rs | 3 +- std/src/sys/pal/windows/mod.rs | 3 +- std/src/sys/pal/windows/net.rs | 14 ++- std/src/sys/pal/windows/os.rs | 13 +-- std/src/sys/pal/windows/pipe.rs | 9 +- std/src/sys/pal/windows/process.rs | 17 ++-- std/src/sys/pal/windows/process/tests.rs | 3 +- std/src/sys/pal/windows/stdio.rs | 11 +-- std/src/sys/pal/windows/thread.rs | 17 ++-- std/src/sys/pal/windows/time.rs | 12 ++- std/src/sys/pal/xous/alloc.rs | 6 +- std/src/sys/pal/xous/net/dns.rs | 3 +- std/src/sys/pal/xous/net/tcplistener.rs | 8 +- std/src/sys/pal/xous/net/tcpstream.rs | 3 +- std/src/sys/pal/xous/net/udp.rs | 8 +- std/src/sys/pal/xous/os.rs | 3 +- std/src/sys/pal/xous/thread.rs | 3 +- std/src/sys/pal/xous/time.rs | 6 +- std/src/sys/pal/zkvm/os.rs | 3 +- std/src/sys/pal/zkvm/stdio.rs | 3 +- std/src/sys/path/unix.rs | 3 +- std/src/sys/path/windows.rs | 3 +- std/src/sys/personality/dwarf/eh.rs | 4 +- std/src/sys/personality/emcc.rs | 3 +- std/src/sys/personality/gcc.rs | 3 +- std/src/sys/sync/condvar/futex.rs | 3 +- std/src/sys/sync/condvar/itron.rs | 12 ++- std/src/sys/sync/condvar/pthread.rs | 3 +- std/src/sys/sync/condvar/teeos.rs | 3 +- std/src/sys/sync/condvar/windows7.rs | 3 +- std/src/sys/sync/condvar/xous.rs | 3 +- std/src/sys/sync/mutex/fuchsia.rs | 6 +- std/src/sys/sync/mutex/itron.rs | 8 +- std/src/sys/sync/mutex/xous.rs | 6 +- std/src/sys/sync/once/futex.rs | 6 +- std/src/sys/sync/once/queue.rs | 4 +- std/src/sys/sync/rwlock/futex.rs | 6 +- std/src/sys/sync/rwlock/queue.rs | 6 +- std/src/sys/sync/rwlock/solid.rs | 10 +-- std/src/sys/sync/thread_parking/darwin.rs | 6 +- std/src/sys/sync/thread_parking/id.rs | 6 +- std/src/sys/sync/thread_parking/windows7.rs | 20 ++--- std/src/sys/sync/thread_parking/xous.rs | 6 +- std/src/sys/thread_local/guard/solid.rs | 3 +- std/src/sys/thread_local/guard/windows.rs | 3 +- std/src/sys/thread_local/key/windows.rs | 6 +- std/src/sys/thread_local/key/xous.rs | 9 +- std/src/sys/thread_local/native/eager.rs | 3 +- std/src/sys/thread_local/native/lazy.rs | 3 +- std/src/sys_common/io.rs | 7 +- std/src/sys_common/lazy_box.rs | 6 +- std/src/sys_common/net.rs | 11 +-- std/src/sys_common/process.rs | 4 +- std/src/sys_common/wtf8.rs | 6 +- std/src/thread/mod.rs | 10 +-- std/src/thread/scoped.rs | 3 +- std/src/thread/tests.rs | 14 ++- std/src/time.rs | 11 ++- std/src/time/tests.rs | 4 +- std/tests/common/mod.rs | 7 +- std/tests/create_dir_all_bare.rs | 3 +- std/tests/env.rs | 3 +- std/tests/pipe_subprocess.rs | 4 +- std/tests/process_spawning.rs | 5 +- std/tests/switch-stdout.rs | 5 +- std/tests/windows.rs | 4 +- test/src/bench.rs | 19 ++--- test/src/cli.rs | 2 +- test/src/console.rs | 24 +++--- test/src/formatters/json.rs | 14 +-- test/src/formatters/junit.rs | 13 ++- test/src/formatters/mod.rs | 13 ++- test/src/formatters/pretty.rs | 16 ++-- test/src/formatters/terse.rs | 17 ++-- test/src/helpers/concurrency.rs | 3 +- test/src/helpers/shuffle.rs | 5 +- test/src/lib.rs | 49 +++++------ test/src/stats/tests.rs | 3 +- test/src/term.rs | 3 +- test/src/term/terminfo/mod.rs | 12 ++- test/src/term/terminfo/parm.rs | 4 +- test/src/term/terminfo/parser/compiled.rs | 3 +- test/src/term/terminfo/searcher.rs | 3 +- test/src/term/win.rs | 3 +- test/src/test_result.rs | 6 +- test/src/tests.rs | 4 +- test/src/time.rs | 6 +- test/src/types.rs | 9 +- unwind/src/unwinding.rs | 4 +- 524 files changed, 1546 insertions(+), 2192 deletions(-) diff --git a/alloc/benches/btree/map.rs b/alloc/benches/btree/map.rs index 4fe07eb02139f..3bddef5045a00 100644 --- a/alloc/benches/btree/map.rs +++ b/alloc/benches/btree/map.rs @@ -1,7 +1,8 @@ use std::collections::BTreeMap; use std::ops::RangeBounds; -use rand::{seq::SliceRandom, Rng}; +use rand::seq::SliceRandom; +use rand::Rng; use test::{black_box, Bencher}; macro_rules! map_insert_rand_bench { diff --git a/alloc/benches/linked_list.rs b/alloc/benches/linked_list.rs index 29c5ad2bc6eb2..b9322b6d4c3ea 100644 --- a/alloc/benches/linked_list.rs +++ b/alloc/benches/linked_list.rs @@ -1,4 +1,5 @@ use std::collections::LinkedList; + use test::Bencher; #[bench] diff --git a/alloc/benches/string.rs b/alloc/benches/string.rs index 5c95160ba2d14..e0dbe80d28896 100644 --- a/alloc/benches/string.rs +++ b/alloc/benches/string.rs @@ -1,4 +1,5 @@ use std::iter::repeat; + use test::{black_box, Bencher}; #[bench] diff --git a/alloc/benches/vec.rs b/alloc/benches/vec.rs index 8ebfe313dc5d5..13d784d3fd40e 100644 --- a/alloc/benches/vec.rs +++ b/alloc/benches/vec.rs @@ -1,5 +1,6 @@ -use rand::RngCore; use std::iter::repeat; + +use rand::RngCore; use test::{black_box, Bencher}; #[bench] diff --git a/alloc/benches/vec_deque.rs b/alloc/benches/vec_deque.rs index 35939f489b45d..fb1e2685cc333 100644 --- a/alloc/benches/vec_deque.rs +++ b/alloc/benches/vec_deque.rs @@ -1,7 +1,6 @@ -use std::{ - collections::{vec_deque, VecDeque}, - mem, -}; +use std::collections::{vec_deque, VecDeque}; +use std::mem; + use test::{black_box, Bencher}; #[bench] diff --git a/alloc/benches/vec_deque_append.rs b/alloc/benches/vec_deque_append.rs index 30b6e600e5adc..7c805da973763 100644 --- a/alloc/benches/vec_deque_append.rs +++ b/alloc/benches/vec_deque_append.rs @@ -1,4 +1,5 @@ -use std::{collections::VecDeque, time::Instant}; +use std::collections::VecDeque; +use std::time::Instant; const VECDEQUE_LEN: i32 = 100000; const WARMUP_N: usize = 100; diff --git a/alloc/src/alloc.rs b/alloc/src/alloc.rs index f7d103396898a..db2d752cfde1c 100644 --- a/alloc/src/alloc.rs +++ b/alloc/src/alloc.rs @@ -2,16 +2,14 @@ #![stable(feature = "alloc_module", since = "1.28.0")] +#[stable(feature = "alloc_module", since = "1.28.0")] +#[doc(inline)] +pub use core::alloc::*; #[cfg(not(test))] use core::hint; - #[cfg(not(test))] use core::ptr::{self, NonNull}; -#[stable(feature = "alloc_module", since = "1.28.0")] -#[doc(inline)] -pub use core::alloc::*; - #[cfg(test)] mod tests; diff --git a/alloc/src/alloc/tests.rs b/alloc/src/alloc/tests.rs index 1a5938fd34cf1..5d6077f057a2c 100644 --- a/alloc/src/alloc/tests.rs +++ b/alloc/src/alloc/tests.rs @@ -1,9 +1,10 @@ use super::*; extern crate test; -use crate::boxed::Box; use test::Bencher; +use crate::boxed::Box; + #[test] fn allocate_zeroed() { unsafe { diff --git a/alloc/src/borrow.rs b/alloc/src/borrow.rs index 42f8a08a9e4ee..f86face3f90cb 100644 --- a/alloc/src/borrow.rs +++ b/alloc/src/borrow.rs @@ -2,21 +2,20 @@ #![stable(feature = "rust1", since = "1.0.0")] +#[stable(feature = "rust1", since = "1.0.0")] +pub use core::borrow::{Borrow, BorrowMut}; use core::cmp::Ordering; use core::hash::{Hash, Hasher}; #[cfg(not(no_global_oom_handling))] use core::ops::{Add, AddAssign}; use core::ops::{Deref, DerefPure}; -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::borrow::{Borrow, BorrowMut}; +use Cow::*; use crate::fmt; #[cfg(not(no_global_oom_handling))] use crate::string::String; -use Cow::*; - #[stable(feature = "rust1", since = "1.0.0")] impl<'a, B: ?Sized> Borrow for Cow<'a, B> where diff --git a/alloc/src/boxed.rs b/alloc/src/boxed.rs index 0fc016aa32bd3..ef40d3b203f48 100644 --- a/alloc/src/boxed.rs +++ b/alloc/src/boxed.rs @@ -187,26 +187,26 @@ use core::any::Any; use core::async_iter::AsyncIterator; -use core::borrow; #[cfg(not(no_global_oom_handling))] use core::clone::CloneToUninit; use core::cmp::Ordering; use core::error::Error; -use core::fmt; use core::future::Future; use core::hash::{Hash, Hasher}; use core::iter::FusedIterator; -use core::marker::Tuple; -use core::marker::Unsize; +use core::marker::{Tuple, Unsize}; use core::mem::{self, SizedTypeProperties}; -use core::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce}; use core::ops::{ - CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver, + AsyncFn, AsyncFnMut, AsyncFnOnce, CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut, + DerefPure, DispatchFromDyn, Receiver, }; use core::pin::Pin; use core::ptr::{self, addr_of_mut, NonNull, Unique}; -use core::slice; use core::task::{Context, Poll}; +use core::{borrow, fmt, slice}; + +#[unstable(feature = "thin_box", issue = "92791")] +pub use thin::ThinBox; #[cfg(not(no_global_oom_handling))] use crate::alloc::handle_alloc_error; @@ -222,9 +222,6 @@ use crate::vec; #[cfg(not(no_global_oom_handling))] use crate::vec::Vec; -#[unstable(feature = "thin_box", issue = "92791")] -pub use thin::ThinBox; - mod thin; /// A pointer type that uniquely owns a heap allocation of type `T`. diff --git a/alloc/src/boxed/thin.rs b/alloc/src/boxed/thin.rs index e9bfecba160a0..9baded3a52141 100644 --- a/alloc/src/boxed/thin.rs +++ b/alloc/src/boxed/thin.rs @@ -2,7 +2,6 @@ //! //! by matthieu-m -use crate::alloc::{self, Layout, LayoutError}; use core::error::Error; use core::fmt::{self, Debug, Display, Formatter}; #[cfg(not(no_global_oom_handling))] @@ -14,8 +13,9 @@ use core::mem; #[cfg(not(no_global_oom_handling))] use core::mem::SizedTypeProperties; use core::ops::{Deref, DerefMut}; -use core::ptr::Pointee; -use core::ptr::{self, NonNull}; +use core::ptr::{self, NonNull, Pointee}; + +use crate::alloc::{self, Layout, LayoutError}; /// ThinBox. /// diff --git a/alloc/src/collections/binary_heap/mod.rs b/alloc/src/collections/binary_heap/mod.rs index 11aef5f913e4f..cc5f33c368542 100644 --- a/alloc/src/collections/binary_heap/mod.rs +++ b/alloc/src/collections/binary_heap/mod.rs @@ -144,12 +144,11 @@ #![stable(feature = "rust1", since = "1.0.0")] use core::alloc::Allocator; -use core::fmt; use core::iter::{FusedIterator, InPlaceIterable, SourceIter, TrustedFused, TrustedLen}; use core::mem::{self, swap, ManuallyDrop}; use core::num::NonZero; use core::ops::{Deref, DerefMut}; -use core::ptr; +use core::{fmt, ptr}; use crate::alloc::Global; use crate::collections::TryReserveError; diff --git a/alloc/src/collections/binary_heap/tests.rs b/alloc/src/collections/binary_heap/tests.rs index d4bc6226a14a8..1cb07c6214953 100644 --- a/alloc/src/collections/binary_heap/tests.rs +++ b/alloc/src/collections/binary_heap/tests.rs @@ -1,7 +1,8 @@ +use std::panic::{catch_unwind, AssertUnwindSafe}; + use super::*; use crate::boxed::Box; use crate::testing::crash_test::{CrashTestDummy, Panic}; -use std::panic::{catch_unwind, AssertUnwindSafe}; #[test] fn test_iterator() { @@ -504,11 +505,12 @@ fn test_retain_catch_unwind() { #[cfg(not(target_os = "emscripten"))] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn panic_safe() { - use rand::seq::SliceRandom; use std::cmp; use std::panic::{self, AssertUnwindSafe}; use std::sync::atomic::{AtomicUsize, Ordering}; + use rand::seq::SliceRandom; + static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0); #[derive(Eq, PartialEq, Ord, Clone, Debug)] diff --git a/alloc/src/collections/btree/append.rs b/alloc/src/collections/btree/append.rs index b6989afb6255d..47372938fbeda 100644 --- a/alloc/src/collections/btree/append.rs +++ b/alloc/src/collections/btree/append.rs @@ -1,8 +1,9 @@ -use super::merge_iter::MergeIterInner; -use super::node::{self, Root}; use core::alloc::Allocator; use core::iter::FusedIterator; +use super::merge_iter::MergeIterInner; +use super::node::{self, Root}; + impl Root { /// Appends all key-value pairs from the union of two ascending iterators, /// incrementing a `length` variable along the way. The latter makes it diff --git a/alloc/src/collections/btree/fix.rs b/alloc/src/collections/btree/fix.rs index 91b61218005a6..4c1e19ead4031 100644 --- a/alloc/src/collections/btree/fix.rs +++ b/alloc/src/collections/btree/fix.rs @@ -1,7 +1,10 @@ -use super::map::MIN_LEN; -use super::node::{marker, ForceResult::*, Handle, LeftOrRight::*, NodeRef, Root}; use core::alloc::Allocator; +use super::map::MIN_LEN; +use super::node::ForceResult::*; +use super::node::LeftOrRight::*; +use super::node::{marker, Handle, NodeRef, Root}; + impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> { /// Stocks up a possibly underfull node by merging with or stealing from a /// sibling. If successful but at the cost of shrinking the parent node, diff --git a/alloc/src/collections/btree/map.rs b/alloc/src/collections/btree/map.rs index 3875f61efafdf..8fe4cd7144bf1 100644 --- a/alloc/src/collections/btree/map.rs +++ b/alloc/src/collections/btree/map.rs @@ -1,4 +1,3 @@ -use crate::vec::Vec; use core::borrow::Borrow; use core::cmp::Ordering; use core::error::Error; @@ -10,20 +9,21 @@ use core::mem::{self, ManuallyDrop}; use core::ops::{Bound, Index, RangeBounds}; use core::ptr; -use crate::alloc::{Allocator, Global}; - use super::borrow::DormantMutRef; use super::dedup_sorted_iter::DedupSortedIter; use super::navigate::{LazyLeafRange, LeafRange}; -use super::node::{self, marker, ForceResult::*, Handle, NodeRef, Root}; -use super::search::{SearchBound, SearchResult::*}; +use super::node::ForceResult::*; +use super::node::{self, marker, Handle, NodeRef, Root}; +use super::search::SearchBound; +use super::search::SearchResult::*; use super::set_val::SetValZST; +use crate::alloc::{Allocator, Global}; +use crate::vec::Vec; mod entry; #[stable(feature = "rust1", since = "1.0.0")] pub use entry::{Entry, OccupiedEntry, OccupiedError, VacantEntry}; - use Entry::*; /// Minimum number of elements in a node that is not a root. diff --git a/alloc/src/collections/btree/map/entry.rs b/alloc/src/collections/btree/map/entry.rs index b5b389bbd25b7..d128ad8ee5f6d 100644 --- a/alloc/src/collections/btree/map/entry.rs +++ b/alloc/src/collections/btree/map/entry.rs @@ -2,13 +2,12 @@ use core::fmt::{self, Debug}; use core::marker::PhantomData; use core::mem; -use crate::alloc::{Allocator, Global}; +use Entry::*; use super::super::borrow::DormantMutRef; use super::super::node::{marker, Handle, NodeRef}; use super::BTreeMap; - -use Entry::*; +use crate::alloc::{Allocator, Global}; /// A view into a single entry in a map, which may either be vacant or occupied. /// diff --git a/alloc/src/collections/btree/map/tests.rs b/alloc/src/collections/btree/map/tests.rs index ba1f38dcc3e52..ff1254a5a0c42 100644 --- a/alloc/src/collections/btree/map/tests.rs +++ b/alloc/src/collections/btree/map/tests.rs @@ -1,3 +1,10 @@ +use core::assert_matches::assert_matches; +use std::iter; +use std::ops::Bound::{Excluded, Included, Unbounded}; +use std::panic::{catch_unwind, AssertUnwindSafe}; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::SeqCst; + use super::*; use crate::boxed::Box; use crate::fmt::Debug; @@ -6,11 +13,6 @@ use crate::string::{String, ToString}; use crate::testing::crash_test::{CrashTestDummy, Panic}; use crate::testing::ord_chaos::{Cyclic3, Governed, Governor}; use crate::testing::rng::DeterministicRng; -use core::assert_matches::assert_matches; -use std::iter; -use std::ops::Bound::{Excluded, Included, Unbounded}; -use std::panic::{catch_unwind, AssertUnwindSafe}; -use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; // Minimum number of elements to insert, to guarantee a tree with 2 levels, // i.e., a tree who's root is an internal node at height 1, with edges to leaf nodes. diff --git a/alloc/src/collections/btree/mem.rs b/alloc/src/collections/btree/mem.rs index e1363d1ae1f6b..d738c5c47b4cc 100644 --- a/alloc/src/collections/btree/mem.rs +++ b/alloc/src/collections/btree/mem.rs @@ -1,6 +1,4 @@ -use core::intrinsics; -use core::mem; -use core::ptr; +use core::{intrinsics, mem, ptr}; /// This replaces the value behind the `v` unique reference by calling the /// relevant function. diff --git a/alloc/src/collections/btree/navigate.rs b/alloc/src/collections/btree/navigate.rs index 5e6a26f65c41e..f5c621e2c1759 100644 --- a/alloc/src/collections/btree/navigate.rs +++ b/alloc/src/collections/btree/navigate.rs @@ -1,11 +1,10 @@ use core::borrow::Borrow; -use core::hint; use core::ops::RangeBounds; -use core::ptr; +use core::{hint, ptr}; -use super::node::{marker, ForceResult::*, Handle, NodeRef}; +use super::node::ForceResult::*; +use super::node::{marker, Handle, NodeRef}; use super::search::SearchBound; - use crate::alloc::Allocator; // `front` and `back` are always both `None` or both `Some`. pub struct LeafRange { diff --git a/alloc/src/collections/btree/remove.rs b/alloc/src/collections/btree/remove.rs index 0904299254f0a..c46422c2f1d45 100644 --- a/alloc/src/collections/btree/remove.rs +++ b/alloc/src/collections/btree/remove.rs @@ -1,7 +1,10 @@ -use super::map::MIN_LEN; -use super::node::{marker, ForceResult::*, Handle, LeftOrRight::*, NodeRef}; use core::alloc::Allocator; +use super::map::MIN_LEN; +use super::node::ForceResult::*; +use super::node::LeftOrRight::*; +use super::node::{marker, Handle, NodeRef}; + impl<'a, K: 'a, V: 'a> Handle, K, V, marker::LeafOrInternal>, marker::KV> { /// Removes a key-value pair from the tree, and returns that pair, as well as /// the leaf edge corresponding to that former pair. It's possible this empties diff --git a/alloc/src/collections/btree/search.rs b/alloc/src/collections/btree/search.rs index ad3522b4e0418..1d5c927175ea6 100644 --- a/alloc/src/collections/btree/search.rs +++ b/alloc/src/collections/btree/search.rs @@ -2,11 +2,12 @@ use core::borrow::Borrow; use core::cmp::Ordering; use core::ops::{Bound, RangeBounds}; -use super::node::{marker, ForceResult::*, Handle, NodeRef}; - use SearchBound::*; use SearchResult::*; +use super::node::ForceResult::*; +use super::node::{marker, Handle, NodeRef}; + pub enum SearchBound { /// An inclusive bound to look for, just like `Bound::Included(T)`. Included(T), diff --git a/alloc/src/collections/btree/set.rs b/alloc/src/collections/btree/set.rs index b0bd6ef2d3c63..74b000fd1c40b 100644 --- a/alloc/src/collections/btree/set.rs +++ b/alloc/src/collections/btree/set.rs @@ -1,4 +1,3 @@ -use crate::vec::Vec; use core::borrow::Borrow; use core::cmp::Ordering::{self, Equal, Greater, Less}; use core::cmp::{max, min}; @@ -12,8 +11,8 @@ use super::map::{BTreeMap, Keys}; use super::merge_iter::MergeIterInner; use super::set_val::SetValZST; use super::Recover; - use crate::alloc::{Allocator, Global}; +use crate::vec::Vec; /// An ordered set based on a B-Tree. /// diff --git a/alloc/src/collections/btree/set/tests.rs b/alloc/src/collections/btree/set/tests.rs index 48bf767413835..f947b6108c9a7 100644 --- a/alloc/src/collections/btree/set/tests.rs +++ b/alloc/src/collections/btree/set/tests.rs @@ -1,8 +1,9 @@ +use std::ops::Bound::{Excluded, Included}; +use std::panic::{catch_unwind, AssertUnwindSafe}; + use super::*; use crate::testing::crash_test::{CrashTestDummy, Panic}; use crate::testing::rng::DeterministicRng; -use std::ops::Bound::{Excluded, Included}; -use std::panic::{catch_unwind, AssertUnwindSafe}; #[test] fn test_clone_eq() { diff --git a/alloc/src/collections/btree/split.rs b/alloc/src/collections/btree/split.rs index 638dc98fc3e41..c188ed1da6113 100644 --- a/alloc/src/collections/btree/split.rs +++ b/alloc/src/collections/btree/split.rs @@ -1,8 +1,10 @@ -use super::node::{ForceResult::*, Root}; -use super::search::SearchResult::*; use core::alloc::Allocator; use core::borrow::Borrow; +use super::node::ForceResult::*; +use super::node::Root; +use super::search::SearchResult::*; + impl Root { /// Calculates the length of both trees that result from splitting up /// a given number of distinct key-value pairs. diff --git a/alloc/src/collections/linked_list.rs b/alloc/src/collections/linked_list.rs index 077483a174b10..0cd410c0fb7c1 100644 --- a/alloc/src/collections/linked_list.rs +++ b/alloc/src/collections/linked_list.rs @@ -13,12 +13,11 @@ #![stable(feature = "rust1", since = "1.0.0")] use core::cmp::Ordering; -use core::fmt; use core::hash::{Hash, Hasher}; use core::iter::FusedIterator; use core::marker::PhantomData; -use core::mem; use core::ptr::NonNull; +use core::{fmt, mem}; use super::SpecExtend; use crate::alloc::{Allocator, Global}; diff --git a/alloc/src/collections/linked_list/tests.rs b/alloc/src/collections/linked_list/tests.rs index d3744c5a9d0c9..9b3c9ac5ce52e 100644 --- a/alloc/src/collections/linked_list/tests.rs +++ b/alloc/src/collections/linked_list/tests.rs @@ -1,12 +1,12 @@ -use super::*; -use crate::testing::crash_test::{CrashTestDummy, Panic}; -use crate::vec::Vec; - use std::panic::{catch_unwind, AssertUnwindSafe}; use std::thread; use rand::RngCore; +use super::*; +use crate::testing::crash_test::{CrashTestDummy, Panic}; +use crate::vec::Vec; + #[test] fn test_basic() { let mut m = LinkedList::>::new(); @@ -1167,9 +1167,7 @@ fn test_drop_panic() { #[test] fn test_allocator() { - use core::alloc::AllocError; - use core::alloc::Allocator; - use core::alloc::Layout; + use core::alloc::{AllocError, Allocator, Layout}; use core::cell::Cell; struct A { diff --git a/alloc/src/collections/mod.rs b/alloc/src/collections/mod.rs index 705b81535c279..020cf4d736510 100644 --- a/alloc/src/collections/mod.rs +++ b/alloc/src/collections/mod.rs @@ -27,33 +27,30 @@ pub mod btree_set { pub use super::btree::set::*; } +use core::fmt::Display; + #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use binary_heap::BinaryHeap; - #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use btree_map::BTreeMap; - #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use btree_set::BTreeSet; - #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use linked_list::LinkedList; - #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use vec_deque::VecDeque; use crate::alloc::{Layout, LayoutError}; -use core::fmt::Display; /// The error type for `try_reserve` methods. #[derive(Clone, PartialEq, Eq, Debug)] diff --git a/alloc/src/collections/vec_deque/drain.rs b/alloc/src/collections/vec_deque/drain.rs index 1373e60149274..44fcef4ed7dc4 100644 --- a/alloc/src/collections/vec_deque/drain.rs +++ b/alloc/src/collections/vec_deque/drain.rs @@ -4,9 +4,8 @@ use core::mem::{self, SizedTypeProperties}; use core::ptr::NonNull; use core::{fmt, ptr}; -use crate::alloc::{Allocator, Global}; - use super::VecDeque; +use crate::alloc::{Allocator, Global}; /// A draining iterator over the elements of a `VecDeque`. /// diff --git a/alloc/src/collections/vec_deque/into_iter.rs b/alloc/src/collections/vec_deque/into_iter.rs index 4747517393c66..2d283dac9a97a 100644 --- a/alloc/src/collections/vec_deque/into_iter.rs +++ b/alloc/src/collections/vec_deque/into_iter.rs @@ -1,10 +1,11 @@ use core::iter::{FusedIterator, TrustedLen}; +use core::mem::MaybeUninit; use core::num::NonZero; -use core::{array, fmt, mem::MaybeUninit, ops::Try, ptr}; - -use crate::alloc::{Allocator, Global}; +use core::ops::Try; +use core::{array, fmt, ptr}; use super::VecDeque; +use crate::alloc::{Allocator, Global}; /// An owning iterator over the elements of a `VecDeque`. /// diff --git a/alloc/src/collections/vec_deque/mod.rs b/alloc/src/collections/vec_deque/mod.rs index a07f250d7d88c..dc725ec0f56e4 100644 --- a/alloc/src/collections/vec_deque/mod.rs +++ b/alloc/src/collections/vec_deque/mod.rs @@ -8,23 +8,19 @@ #![stable(feature = "rust1", since = "1.0.0")] use core::cmp::{self, Ordering}; -use core::fmt; use core::hash::{Hash, Hasher}; use core::iter::{repeat_n, repeat_with, ByRefSized}; -use core::mem::{ManuallyDrop, SizedTypeProperties}; -use core::ops::{Index, IndexMut, Range, RangeBounds}; -use core::ptr; -use core::slice; - // This is used in a bunch of intra-doc links. // FIXME: For some reason, `#[cfg(doc)]` wasn't sufficient, resulting in // failures in linkchecker even though rustdoc built the docs just fine. #[allow(unused_imports)] use core::mem; +use core::mem::{ManuallyDrop, SizedTypeProperties}; +use core::ops::{Index, IndexMut, Range, RangeBounds}; +use core::{fmt, ptr, slice}; use crate::alloc::{Allocator, Global}; -use crate::collections::TryReserveError; -use crate::collections::TryReserveErrorKind; +use crate::collections::{TryReserveError, TryReserveErrorKind}; use crate::raw_vec::RawVec; use crate::vec::Vec; diff --git a/alloc/src/collections/vec_deque/spec_extend.rs b/alloc/src/collections/vec_deque/spec_extend.rs index 6a89abc3ef9b6..a9b0fd073b548 100644 --- a/alloc/src/collections/vec_deque/spec_extend.rs +++ b/alloc/src/collections/vec_deque/spec_extend.rs @@ -1,9 +1,9 @@ -use crate::alloc::Allocator; -use crate::vec; use core::iter::TrustedLen; use core::slice; use super::VecDeque; +use crate::alloc::Allocator; +use crate::vec; // Specialization trait used for VecDeque::extend pub(super) trait SpecExtend { diff --git a/alloc/src/ffi/c_str.rs b/alloc/src/ffi/c_str.rs index f1eb195b88462..e32676a65432b 100644 --- a/alloc/src/ffi/c_str.rs +++ b/alloc/src/ffi/c_str.rs @@ -3,25 +3,21 @@ #[cfg(test)] mod tests; -use crate::borrow::{Cow, ToOwned}; -use crate::boxed::Box; -use crate::rc::Rc; -use crate::slice::hack::into_vec; -use crate::string::String; -use crate::vec::Vec; use core::borrow::Borrow; use core::ffi::{c_char, CStr}; -use core::fmt; -use core::mem; use core::num::NonZero; -use core::ops; -use core::ptr; -use core::slice; use core::slice::memchr; use core::str::{self, Utf8Error}; +use core::{fmt, mem, ops, ptr, slice}; +use crate::borrow::{Cow, ToOwned}; +use crate::boxed::Box; +use crate::rc::Rc; +use crate::slice::hack::into_vec; +use crate::string::String; #[cfg(target_has_atomic = "ptr")] use crate::sync::Arc; +use crate::vec::Vec; /// A type representing an owned, C-compatible, nul-terminated string with no nul bytes in the /// middle. diff --git a/alloc/src/ffi/c_str/tests.rs b/alloc/src/ffi/c_str/tests.rs index 9f51e17a427f5..8b7172b3f20a9 100644 --- a/alloc/src/ffi/c_str/tests.rs +++ b/alloc/src/ffi/c_str/tests.rs @@ -1,10 +1,10 @@ -use super::*; use core::assert_matches::assert_matches; use core::ffi::FromBytesUntilNulError; -use core::hash::{Hash, Hasher}; - #[allow(deprecated)] use core::hash::SipHasher13 as DefaultHasher; +use core::hash::{Hash, Hasher}; + +use super::*; #[test] fn c_to_rust() { diff --git a/alloc/src/ffi/mod.rs b/alloc/src/ffi/mod.rs index 9fc1acc231bff..4f9dc40a3cfc9 100644 --- a/alloc/src/ffi/mod.rs +++ b/alloc/src/ffi/mod.rs @@ -80,13 +80,12 @@ #![stable(feature = "alloc_ffi", since = "1.64.0")] -#[doc(no_inline)] -#[stable(feature = "alloc_c_string", since = "1.64.0")] -pub use self::c_str::{FromVecWithNulError, IntoStringError, NulError}; - #[doc(inline)] #[stable(feature = "alloc_c_string", since = "1.64.0")] pub use self::c_str::CString; +#[doc(no_inline)] +#[stable(feature = "alloc_c_string", since = "1.64.0")] +pub use self::c_str::{FromVecWithNulError, IntoStringError, NulError}; #[unstable(feature = "c_str_module", issue = "112134")] pub mod c_str; diff --git a/alloc/src/raw_vec.rs b/alloc/src/raw_vec.rs index 2860b88bd83e7..5b84df9ecef30 100644 --- a/alloc/src/raw_vec.rs +++ b/alloc/src/raw_vec.rs @@ -1,10 +1,9 @@ #![unstable(feature = "raw_vec_internals", reason = "unstable const warnings", issue = "none")] use core::alloc::LayoutError; -use core::cmp; -use core::hint; use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties}; use core::ptr::{self, NonNull, Unique}; +use core::{cmp, hint}; #[cfg(not(no_global_oom_handling))] use crate::alloc::handle_alloc_error; diff --git a/alloc/src/raw_vec/tests.rs b/alloc/src/raw_vec/tests.rs index 4194be530612d..48c6e5f46f8db 100644 --- a/alloc/src/raw_vec/tests.rs +++ b/alloc/src/raw_vec/tests.rs @@ -1,7 +1,8 @@ -use super::*; use core::mem::size_of; use std::cell::Cell; +use super::*; + #[test] fn allocator_param() { use crate::alloc::AllocError; diff --git a/alloc/src/rc.rs b/alloc/src/rc.rs index 64233d19c5a90..bc0874fc13f46 100644 --- a/alloc/src/rc.rs +++ b/alloc/src/rc.rs @@ -241,20 +241,12 @@ #![stable(feature = "rust1", since = "1.0.0")] -#[cfg(not(test))] -use crate::boxed::Box; -#[cfg(test)] -use std::boxed::Box; - use core::any::Any; -use core::borrow; use core::cell::Cell; #[cfg(not(no_global_oom_handling))] use core::clone::CloneToUninit; use core::cmp::Ordering; -use core::fmt; use core::hash::{Hash, Hasher}; -use core::hint; use core::intrinsics::abort; #[cfg(not(no_global_oom_handling))] use core::iter; @@ -267,11 +259,16 @@ use core::pin::Pin; use core::ptr::{self, drop_in_place, NonNull}; #[cfg(not(no_global_oom_handling))] use core::slice::from_raw_parts_mut; +use core::{borrow, fmt, hint}; +#[cfg(test)] +use std::boxed::Box; #[cfg(not(no_global_oom_handling))] use crate::alloc::handle_alloc_error; use crate::alloc::{AllocError, Allocator, Global, Layout}; use crate::borrow::{Cow, ToOwned}; +#[cfg(not(test))] +use crate::boxed::Box; #[cfg(not(no_global_oom_handling))] use crate::string::String; #[cfg(not(no_global_oom_handling))] diff --git a/alloc/src/rc/tests.rs b/alloc/src/rc/tests.rs index 5e2e4beb94a2b..84e8b325f71fc 100644 --- a/alloc/src/rc/tests.rs +++ b/alloc/src/rc/tests.rs @@ -1,8 +1,8 @@ -use super::*; - use std::cell::RefCell; use std::clone::Clone; +use super::*; + #[test] fn test_clone() { let x = Rc::new(RefCell::new(5)); diff --git a/alloc/src/slice.rs b/alloc/src/slice.rs index c7960b3fb49c3..7dcf344cdc5e0 100644 --- a/alloc/src/slice.rs +++ b/alloc/src/slice.rs @@ -78,7 +78,6 @@ pub use core::slice::{SplitInclusive, SplitInclusiveMut}; // N.B., see the `hack` module in this file for more details. #[cfg(test)] pub use hack::into_vec; - // HACK(japaric) needed for the implementation of `Vec::clone` during testing // N.B., see the `hack` module in this file for more details. #[cfg(test)] diff --git a/alloc/src/slice/tests.rs b/alloc/src/slice/tests.rs index 0b972a13898eb..786704caeb0ad 100644 --- a/alloc/src/slice/tests.rs +++ b/alloc/src/slice/tests.rs @@ -1,18 +1,21 @@ +use core::cell::Cell; +use core::cmp::Ordering::{self, Equal, Greater, Less}; +use core::convert::identity; +use core::sync::atomic::AtomicUsize; +use core::sync::atomic::Ordering::Relaxed; +use core::{fmt, mem}; +use std::panic; + +use rand::distributions::Standard; +use rand::prelude::*; +use rand::{Rng, RngCore}; + use crate::borrow::ToOwned; use crate::rc::Rc; use crate::string::ToString; use crate::test_helpers::test_rng; use crate::vec::Vec; -use core::cell::Cell; -use core::cmp::Ordering::{self, Equal, Greater, Less}; -use core::convert::identity; -use core::fmt; -use core::mem; -use core::sync::atomic::{AtomicUsize, Ordering::Relaxed}; -use rand::{distributions::Standard, prelude::*, Rng, RngCore}; -use std::panic; - macro_rules! do_test { ($input:ident, $func:ident) => { let len = $input.len(); diff --git a/alloc/src/str.rs b/alloc/src/str.rs index 94053ef83a0e0..d7fba3ae159c6 100644 --- a/alloc/src/str.rs +++ b/alloc/src/str.rs @@ -9,19 +9,9 @@ use core::borrow::{Borrow, BorrowMut}; use core::iter::FusedIterator; -use core::mem; -use core::ptr; -use core::str::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher}; -use core::unicode::conversions; - -use crate::borrow::ToOwned; -use crate::boxed::Box; -use crate::slice::{Concat, Join, SliceIndex}; -use crate::string::String; -use crate::vec::Vec; - #[stable(feature = "rust1", since = "1.0.0")] pub use core::str::pattern; +use core::str::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher}; #[stable(feature = "encode_utf16", since = "1.8.0")] pub use core::str::EncodeUtf16; #[stable(feature = "split_ascii_whitespace", since = "1.34.0")] @@ -55,6 +45,14 @@ pub use core::str::{RSplitN, SplitN}; pub use core::str::{RSplitTerminator, SplitTerminator}; #[stable(feature = "utf8_chunks", since = "1.79.0")] pub use core::str::{Utf8Chunk, Utf8Chunks}; +use core::unicode::conversions; +use core::{mem, ptr}; + +use crate::borrow::ToOwned; +use crate::boxed::Box; +use crate::slice::{Concat, Join, SliceIndex}; +use crate::string::String; +use crate::vec::Vec; /// Note: `str` in `Concat` is not meaningful here. /// This type parameter of the trait only exists to enable another impl. diff --git a/alloc/src/string.rs b/alloc/src/string.rs index 0ff66167a46ae..01fe950cf3fdd 100644 --- a/alloc/src/string.rs +++ b/alloc/src/string.rs @@ -43,8 +43,6 @@ #![stable(feature = "rust1", since = "1.0.0")] use core::error::Error; -use core::fmt; -use core::hash; #[cfg(not(no_global_oom_handling))] use core::iter::from_fn; use core::iter::FusedIterator; @@ -55,9 +53,8 @@ use core::ops::AddAssign; #[cfg(not(no_global_oom_handling))] use core::ops::Bound::{Excluded, Included, Unbounded}; use core::ops::{self, Range, RangeBounds}; -use core::ptr; -use core::slice; use core::str::pattern::Pattern; +use core::{fmt, hash, ptr, slice}; #[cfg(not(no_global_oom_handling))] use crate::alloc::Allocator; diff --git a/alloc/src/sync.rs b/alloc/src/sync.rs index f73cd0396cd82..3ad0dae77dbde 100644 --- a/alloc/src/sync.rs +++ b/alloc/src/sync.rs @@ -9,13 +9,10 @@ //! `#[cfg(target_has_atomic = "ptr")]`. use core::any::Any; -use core::borrow; #[cfg(not(no_global_oom_handling))] use core::clone::CloneToUninit; use core::cmp::Ordering; -use core::fmt; use core::hash::{Hash, Hasher}; -use core::hint; use core::intrinsics::abort; #[cfg(not(no_global_oom_handling))] use core::iter; @@ -29,6 +26,7 @@ use core::ptr::{self, NonNull}; use core::slice::from_raw_parts_mut; use core::sync::atomic; use core::sync::atomic::Ordering::{Acquire, Relaxed, Release}; +use core::{borrow, fmt, hint}; #[cfg(not(no_global_oom_handling))] use crate::alloc::handle_alloc_error; diff --git a/alloc/src/sync/tests.rs b/alloc/src/sync/tests.rs index 1b123aa58f205..d6b3de875771e 100644 --- a/alloc/src/sync/tests.rs +++ b/alloc/src/sync/tests.rs @@ -1,5 +1,3 @@ -use super::*; - use std::clone::Clone; use std::mem::MaybeUninit; use std::option::Option::None; @@ -9,6 +7,8 @@ use std::sync::mpsc::channel; use std::sync::Mutex; use std::thread; +use super::*; + struct Canary(*mut AtomicUsize); impl Drop for Canary { diff --git a/alloc/src/task.rs b/alloc/src/task.rs index a3fa6585a37f8..27589aed2f97c 100644 --- a/alloc/src/task.rs +++ b/alloc/src/task.rs @@ -7,14 +7,14 @@ //! This may be detected at compile time using //! `#[cfg(target_has_atomic = "ptr")]`. -use crate::rc::Rc; use core::mem::ManuallyDrop; +#[cfg(target_has_atomic = "ptr")] +use core::task::Waker; use core::task::{LocalWaker, RawWaker, RawWakerVTable}; +use crate::rc::Rc; #[cfg(target_has_atomic = "ptr")] use crate::sync::Arc; -#[cfg(target_has_atomic = "ptr")] -use core::task::Waker; /// The implementation of waking a task on an executor. /// diff --git a/alloc/src/testing/crash_test.rs b/alloc/src/testing/crash_test.rs index ff72f99b2cbed..684bac60d9a86 100644 --- a/alloc/src/testing/crash_test.rs +++ b/alloc/src/testing/crash_test.rs @@ -1,6 +1,8 @@ -use crate::fmt::Debug; // the `Debug` trait is the only thing we use from `crate::fmt` use std::cmp::Ordering; -use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::SeqCst; + +use crate::fmt::Debug; // the `Debug` trait is the only thing we use from `crate::fmt` /// A blueprint for crash test dummy instances that monitor particular events. /// Some instances may be configured to panic at some point. diff --git a/alloc/src/tests.rs b/alloc/src/tests.rs index ab256ceaec353..b95d11cb07ec8 100644 --- a/alloc/src/tests.rs +++ b/alloc/src/tests.rs @@ -2,7 +2,6 @@ use core::any::Any; use core::ops::Deref; - use std::boxed::Box; #[test] diff --git a/alloc/src/vec/cow.rs b/alloc/src/vec/cow.rs index 3fe83242a30ad..c18091705a636 100644 --- a/alloc/src/vec/cow.rs +++ b/alloc/src/vec/cow.rs @@ -1,6 +1,5 @@ -use crate::borrow::Cow; - use super::Vec; +use crate::borrow::Cow; #[stable(feature = "cow_from_vec", since = "1.8.0")] impl<'a, T: Clone> From<&'a [T]> for Cow<'a, [T]> { diff --git a/alloc/src/vec/drain.rs b/alloc/src/vec/drain.rs index f0b63759ac70f..9362cef2a1b00 100644 --- a/alloc/src/vec/drain.rs +++ b/alloc/src/vec/drain.rs @@ -1,4 +1,3 @@ -use crate::alloc::{Allocator, Global}; use core::fmt; use core::iter::{FusedIterator, TrustedLen}; use core::mem::{self, ManuallyDrop, SizedTypeProperties}; @@ -6,6 +5,7 @@ use core::ptr::{self, NonNull}; use core::slice::{self}; use super::Vec; +use crate::alloc::{Allocator, Global}; /// A draining iterator for `Vec`. /// diff --git a/alloc/src/vec/extract_if.rs b/alloc/src/vec/extract_if.rs index 118cfdb36b9c2..72d51e8904488 100644 --- a/alloc/src/vec/extract_if.rs +++ b/alloc/src/vec/extract_if.rs @@ -1,8 +1,7 @@ -use crate::alloc::{Allocator, Global}; -use core::ptr; -use core::slice; +use core::{ptr, slice}; use super::Vec; +use crate::alloc::{Allocator, Global}; /// An iterator which uses a closure to determine if an element should be removed. /// diff --git a/alloc/src/vec/in_place_collect.rs b/alloc/src/vec/in_place_collect.rs index 0dc193d82c535..d119e6ca397c5 100644 --- a/alloc/src/vec/in_place_collect.rs +++ b/alloc/src/vec/in_place_collect.rs @@ -155,9 +155,7 @@ //! vec.truncate(write_idx); //! ``` -use crate::alloc::{handle_alloc_error, Global}; -use core::alloc::Allocator; -use core::alloc::Layout; +use core::alloc::{Allocator, Layout}; use core::iter::{InPlaceIterable, SourceIter, TrustedRandomAccessNoCoerce}; use core::marker::PhantomData; use core::mem::{self, ManuallyDrop, SizedTypeProperties}; @@ -165,6 +163,7 @@ use core::num::NonZero; use core::ptr; use super::{InPlaceDrop, InPlaceDstDataSrcBufDrop, SpecFromIter, SpecFromIterNested, Vec}; +use crate::alloc::{handle_alloc_error, Global}; const fn in_place_collectible( step_merge: Option>, diff --git a/alloc/src/vec/in_place_drop.rs b/alloc/src/vec/in_place_drop.rs index 4050c250130bb..27f7597931045 100644 --- a/alloc/src/vec/in_place_drop.rs +++ b/alloc/src/vec/in_place_drop.rs @@ -1,6 +1,5 @@ use core::marker::PhantomData; -use core::ptr::NonNull; -use core::ptr::{self, drop_in_place}; +use core::ptr::{self, drop_in_place, NonNull}; use core::slice::{self}; use crate::alloc::Global; diff --git a/alloc/src/vec/into_iter.rs b/alloc/src/vec/into_iter.rs index c3a8660383dbc..fad8abad49353 100644 --- a/alloc/src/vec/into_iter.rs +++ b/alloc/src/vec/into_iter.rs @@ -1,11 +1,3 @@ -#[cfg(not(no_global_oom_handling))] -use super::AsVecIntoIter; -use crate::alloc::{Allocator, Global}; -#[cfg(not(no_global_oom_handling))] -use crate::collections::VecDeque; -use crate::raw_vec::RawVec; -use core::array; -use core::fmt; use core::iter::{ FusedIterator, InPlaceIterable, SourceIter, TrustedFused, TrustedLen, TrustedRandomAccessNoCoerce, @@ -17,6 +9,14 @@ use core::num::NonZero; use core::ops::Deref; use core::ptr::{self, NonNull}; use core::slice::{self}; +use core::{array, fmt}; + +#[cfg(not(no_global_oom_handling))] +use super::AsVecIntoIter; +use crate::alloc::{Allocator, Global}; +#[cfg(not(no_global_oom_handling))] +use crate::collections::VecDeque; +use crate::raw_vec::RawVec; macro non_null { (mut $place:expr, $t:ident) => {{ diff --git a/alloc/src/vec/mod.rs b/alloc/src/vec/mod.rs index db81fc05c34bb..5306c5074879f 100644 --- a/alloc/src/vec/mod.rs +++ b/alloc/src/vec/mod.rs @@ -66,15 +66,14 @@ use core::ops::{self, Index, IndexMut, Range, RangeBounds}; use core::ptr::{self, NonNull}; use core::slice::{self, SliceIndex}; +#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +pub use self::extract_if::ExtractIf; use crate::alloc::{Allocator, Global}; use crate::borrow::{Cow, ToOwned}; use crate::boxed::Box; use crate::collections::TryReserveError; use crate::raw_vec::RawVec; -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] -pub use self::extract_if::ExtractIf; - mod extract_if; #[cfg(not(no_global_oom_handling))] diff --git a/alloc/src/vec/partial_eq.rs b/alloc/src/vec/partial_eq.rs index b0cf72577a1be..5e620c4b2efe7 100644 --- a/alloc/src/vec/partial_eq.rs +++ b/alloc/src/vec/partial_eq.rs @@ -1,9 +1,8 @@ +use super::Vec; use crate::alloc::Allocator; #[cfg(not(no_global_oom_handling))] use crate::borrow::Cow; -use super::Vec; - macro_rules! __impl_slice_eq1 { ([$($vars:tt)*] $lhs:ty, $rhs:ty $(where $ty:ty: $bound:ident)?, #[$stability:meta]) => { #[$stability] diff --git a/alloc/src/vec/spec_extend.rs b/alloc/src/vec/spec_extend.rs index e2f865d0f7167..7085bceef5baa 100644 --- a/alloc/src/vec/spec_extend.rs +++ b/alloc/src/vec/spec_extend.rs @@ -1,8 +1,8 @@ -use crate::alloc::Allocator; use core::iter::TrustedLen; use core::slice::{self}; use super::{IntoIter, Vec}; +use crate::alloc::Allocator; // Specialization trait used for Vec::extend pub(super) trait SpecExtend { diff --git a/alloc/src/vec/spec_from_elem.rs b/alloc/src/vec/spec_from_elem.rs index 01a6db14474bb..96d701e15d487 100644 --- a/alloc/src/vec/spec_from_elem.rs +++ b/alloc/src/vec/spec_from_elem.rs @@ -1,10 +1,9 @@ use core::ptr; +use super::{IsZero, Vec}; use crate::alloc::Allocator; use crate::raw_vec::RawVec; -use super::{IsZero, Vec}; - // Specialization trait used for Vec::from_elem pub(super) trait SpecFromElem: Sized { fn from_elem(elem: Self, n: usize, alloc: A) -> Vec; diff --git a/alloc/src/vec/spec_from_iter_nested.rs b/alloc/src/vec/spec_from_iter_nested.rs index f915ebb86e5a5..77f7761d22f95 100644 --- a/alloc/src/vec/spec_from_iter_nested.rs +++ b/alloc/src/vec/spec_from_iter_nested.rs @@ -1,10 +1,8 @@ -use core::cmp; use core::iter::TrustedLen; -use core::ptr; - -use crate::raw_vec::RawVec; +use core::{cmp, ptr}; use super::{SpecExtend, Vec}; +use crate::raw_vec::RawVec; /// Another specialization trait for Vec::from_iter /// necessary to manually prioritize overlapping specializations diff --git a/alloc/src/vec/splice.rs b/alloc/src/vec/splice.rs index 852fdcc3f5ce7..9e36377c148d2 100644 --- a/alloc/src/vec/splice.rs +++ b/alloc/src/vec/splice.rs @@ -1,8 +1,8 @@ -use crate::alloc::{Allocator, Global}; use core::ptr::{self}; use core::slice::{self}; use super::{Drain, Vec}; +use crate::alloc::{Allocator, Global}; /// A splicing iterator for `Vec`. /// diff --git a/alloc/tests/btree_set_hash.rs b/alloc/tests/btree_set_hash.rs index ab275ac4353ac..71a3a143209ff 100644 --- a/alloc/tests/btree_set_hash.rs +++ b/alloc/tests/btree_set_hash.rs @@ -1,6 +1,7 @@ -use crate::hash; use std::collections::BTreeSet; +use crate::hash; + #[test] fn test_hash() { let mut x = BTreeSet::new(); diff --git a/alloc/tests/slice.rs b/alloc/tests/slice.rs index c0f7a11a93e12..df5a8af16fd70 100644 --- a/alloc/tests/slice.rs +++ b/alloc/tests/slice.rs @@ -1,9 +1,7 @@ use std::cmp::Ordering::{Equal, Greater, Less}; use std::convert::identity; -use std::fmt; -use std::mem; -use std::panic; use std::rc::Rc; +use std::{fmt, mem, panic}; fn square(n: usize) -> usize { n * n @@ -911,8 +909,7 @@ fn test_split_iterators_size_hint() { // become maximally long, so the size_hint upper bounds are tight ((|_| true) as fn(&_) -> _, Bounds::Upper), ] { - use assert_tight_size_hints as a; - use format_args as f; + use {assert_tight_size_hints as a, format_args as f}; a(v.split(p), b, "split"); a(v.split_mut(p), b, "split_mut"); diff --git a/alloc/tests/str.rs b/alloc/tests/str.rs index de5d3991c9143..a6b1fe5b97945 100644 --- a/alloc/tests/str.rs +++ b/alloc/tests/str.rs @@ -165,7 +165,8 @@ fn test_join_for_different_lengths_with_long_separator() { #[test] fn test_join_issue_80335() { - use core::{borrow::Borrow, cell::Cell}; + use core::borrow::Borrow; + use core::cell::Cell; struct WeirdBorrow { state: Cell, diff --git a/alloc/tests/string.rs b/alloc/tests/string.rs index e20ceae87b0d5..c5bc4185a3670 100644 --- a/alloc/tests/string.rs +++ b/alloc/tests/string.rs @@ -2,11 +2,9 @@ use std::assert_matches::assert_matches; use std::borrow::Cow; use std::cell::Cell; use std::collections::TryReserveErrorKind::*; -use std::ops::Bound; use std::ops::Bound::*; -use std::ops::RangeBounds; -use std::panic; -use std::str; +use std::ops::{Bound, RangeBounds}; +use std::{panic, str}; pub trait IntoCow<'a, B: ?Sized> where diff --git a/alloc/tests/vec.rs b/alloc/tests/vec.rs index 71d79893e01d7..fd2ddbf59e42d 100644 --- a/alloc/tests/vec.rs +++ b/alloc/tests/vec.rs @@ -8,15 +8,14 @@ use std::borrow::Cow; use std::cell::Cell; use std::collections::TryReserveErrorKind::*; use std::fmt::Debug; -use std::hint; use std::iter::InPlaceIterable; -use std::mem; use std::mem::{size_of, swap}; use std::ops::Bound::*; use std::panic::{catch_unwind, AssertUnwindSafe}; use std::rc::Rc; use std::sync::atomic::{AtomicU32, Ordering}; use std::vec::{Drain, IntoIter}; +use std::{hint, mem}; struct DropCounter<'a> { count: &'a mut u32, @@ -2572,7 +2571,8 @@ fn test_into_flattened_size_overflow() { #[test] fn test_box_zero_allocator() { - use core::{alloc::AllocError, cell::RefCell}; + use core::alloc::AllocError; + use core::cell::RefCell; use std::collections::HashSet; // Track ZST allocations and ensure that they all have a matching free. diff --git a/alloc/tests/vec_deque.rs b/alloc/tests/vec_deque.rs index cea5de4dd5984..db972122fef2a 100644 --- a/alloc/tests/vec_deque.rs +++ b/alloc/tests/vec_deque.rs @@ -1,16 +1,17 @@ use core::num::NonZero; use std::assert_matches::assert_matches; +use std::collections::vec_deque::Drain; use std::collections::TryReserveErrorKind::*; -use std::collections::{vec_deque::Drain, VecDeque}; +use std::collections::VecDeque; use std::fmt::Debug; use std::ops::Bound::*; use std::panic::{catch_unwind, AssertUnwindSafe}; -use crate::hash; - use Taggy::*; use Taggypar::*; +use crate::hash; + #[test] fn test_simple() { let mut d = VecDeque::new(); diff --git a/alloc/tests/vec_deque_alloc_error.rs b/alloc/tests/vec_deque_alloc_error.rs index 8b516ddbc5c55..c41d8266eb457 100644 --- a/alloc/tests/vec_deque_alloc_error.rs +++ b/alloc/tests/vec_deque_alloc_error.rs @@ -1,11 +1,9 @@ #![feature(alloc_error_hook, allocator_api)] -use std::{ - alloc::{set_alloc_error_hook, AllocError, Allocator, Layout, System}, - collections::VecDeque, - panic::{catch_unwind, AssertUnwindSafe}, - ptr::NonNull, -}; +use std::alloc::{set_alloc_error_hook, AllocError, Allocator, Layout, System}; +use std::collections::VecDeque; +use std::panic::{catch_unwind, AssertUnwindSafe}; +use std::ptr::NonNull; #[test] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] diff --git a/core/benches/any.rs b/core/benches/any.rs index 53099b78266f8..f6be41bcdbfa7 100644 --- a/core/benches/any.rs +++ b/core/benches/any.rs @@ -1,4 +1,5 @@ use core::any::*; + use test::{black_box, Bencher}; #[bench] diff --git a/core/benches/array.rs b/core/benches/array.rs index d8cc44d05c4ba..b1a41a088c493 100644 --- a/core/benches/array.rs +++ b/core/benches/array.rs @@ -1,5 +1,4 @@ -use test::black_box; -use test::Bencher; +use test::{black_box, Bencher}; macro_rules! map_array { ($func_name:ident, $start_item: expr, $map_item: expr, $arr_size: expr) => { diff --git a/core/benches/ascii.rs b/core/benches/ascii.rs index 71ec9fed2fe75..61bf8bbf411d5 100644 --- a/core/benches/ascii.rs +++ b/core/benches/ascii.rs @@ -64,8 +64,8 @@ macro_rules! benches { } use std::fmt::Write; -use test::black_box; -use test::Bencher; + +use test::{black_box, Bencher}; const ASCII_CASE_MASK: u8 = 0b0010_0000; diff --git a/core/benches/ascii/is_ascii.rs b/core/benches/ascii/is_ascii.rs index a42a1dcfe3988..05f60a46f8be2 100644 --- a/core/benches/ascii/is_ascii.rs +++ b/core/benches/ascii/is_ascii.rs @@ -1,6 +1,6 @@ +use test::{black_box, Bencher}; + use super::{LONG, MEDIUM, SHORT}; -use test::black_box; -use test::Bencher; macro_rules! benches { ($( fn $name: ident($arg: ident: &[u8]) $body: block )+) => { diff --git a/core/benches/fmt.rs b/core/benches/fmt.rs index d1cdb12e50f8c..906d7ac3eef28 100644 --- a/core/benches/fmt.rs +++ b/core/benches/fmt.rs @@ -1,5 +1,6 @@ use std::fmt::{self, Write as FmtWrite}; use std::io::{self, Write as IoWrite}; + use test::{black_box, Bencher}; #[bench] diff --git a/core/benches/hash/sip.rs b/core/benches/hash/sip.rs index 725c864dce9f1..8e8c07b6ee4c3 100644 --- a/core/benches/hash/sip.rs +++ b/core/benches/hash/sip.rs @@ -1,6 +1,7 @@ #![allow(deprecated)] use core::hash::*; + use test::{black_box, Bencher}; fn hash_bytes(mut s: H, x: &[u8]) -> u64 { diff --git a/core/benches/iter.rs b/core/benches/iter.rs index c1cec5e6d3c8c..24469ba0c4262 100644 --- a/core/benches/iter.rs +++ b/core/benches/iter.rs @@ -3,6 +3,7 @@ use core::iter::*; use core::mem; use core::num::Wrapping; use core::ops::Range; + use test::{black_box, Bencher}; #[bench] diff --git a/core/benches/num/flt2dec/mod.rs b/core/benches/num/flt2dec/mod.rs index b1a9fc56bae54..6c7de5dcd2286 100644 --- a/core/benches/num/flt2dec/mod.rs +++ b/core/benches/num/flt2dec/mod.rs @@ -3,9 +3,9 @@ mod strategy { mod grisu; } -use core::num::flt2dec::MAX_SIG_DIGITS; -use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded}; +use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded, MAX_SIG_DIGITS}; use std::io::Write; + use test::{black_box, Bencher}; pub fn decode_finite(v: T) -> Decoded { diff --git a/core/benches/num/flt2dec/strategy/dragon.rs b/core/benches/num/flt2dec/strategy/dragon.rs index babedc6c0ec80..4526697140365 100644 --- a/core/benches/num/flt2dec/strategy/dragon.rs +++ b/core/benches/num/flt2dec/strategy/dragon.rs @@ -1,7 +1,8 @@ -use super::super::*; use core::num::flt2dec::strategy::dragon::*; use std::mem::MaybeUninit; +use super::super::*; + #[bench] fn bench_small_shortest(b: &mut Bencher) { let decoded = decode_finite(3.141592f64); diff --git a/core/benches/num/flt2dec/strategy/grisu.rs b/core/benches/num/flt2dec/strategy/grisu.rs index b5bddb2c7c746..d20f9b02f7e74 100644 --- a/core/benches/num/flt2dec/strategy/grisu.rs +++ b/core/benches/num/flt2dec/strategy/grisu.rs @@ -1,7 +1,8 @@ -use super::super::*; use core::num::flt2dec::strategy::grisu::*; use std::mem::MaybeUninit; +use super::super::*; + pub fn decode_finite(v: T) -> Decoded { match decode(v).1 { FullDecoded::Finite(decoded) => decoded, diff --git a/core/benches/num/mod.rs b/core/benches/num/mod.rs index 4922ee150d95f..c1dc3a3062256 100644 --- a/core/benches/num/mod.rs +++ b/core/benches/num/mod.rs @@ -4,6 +4,7 @@ mod int_log; mod int_pow; use std::str::FromStr; + use test::{black_box, Bencher}; const ASCII_NUMBERS: [&str; 19] = [ diff --git a/core/benches/ops.rs b/core/benches/ops.rs index 0a2be8a28819f..3d0b3302957bf 100644 --- a/core/benches/ops.rs +++ b/core/benches/ops.rs @@ -1,4 +1,5 @@ use core::ops::*; + use test::Bencher; // Overhead of dtors diff --git a/core/benches/pattern.rs b/core/benches/pattern.rs index 480ac6f36d202..0d60b005feb32 100644 --- a/core/benches/pattern.rs +++ b/core/benches/pattern.rs @@ -1,5 +1,4 @@ -use test::black_box; -use test::Bencher; +use test::{black_box, Bencher}; #[bench] fn starts_with_char(b: &mut Bencher) { diff --git a/core/benches/slice.rs b/core/benches/slice.rs index 8f87a211449c0..2741dbd53f14c 100644 --- a/core/benches/slice.rs +++ b/core/benches/slice.rs @@ -1,6 +1,6 @@ use core::ptr::NonNull; -use test::black_box; -use test::Bencher; + +use test::{black_box, Bencher}; enum Cache { L1, diff --git a/core/benches/str.rs b/core/benches/str.rs index 0f14809444bc5..a8178f9c18752 100644 --- a/core/benches/str.rs +++ b/core/benches/str.rs @@ -1,4 +1,5 @@ use std::str; + use test::{black_box, Bencher}; mod char_count; diff --git a/core/benches/str/char_count.rs b/core/benches/str/char_count.rs index 25d9b2e299223..b87ad0f6adf24 100644 --- a/core/benches/str/char_count.rs +++ b/core/benches/str/char_count.rs @@ -1,6 +1,7 @@ -use super::corpora::*; use test::{black_box, Bencher}; +use super::corpora::*; + macro_rules! define_benches { ($( fn $name: ident($arg: ident: &str) $body: block )+) => { define_benches!(mod en_tiny, en::TINY, $($name $arg $body)+); diff --git a/core/benches/str/debug.rs b/core/benches/str/debug.rs index cb91169eed8eb..6dbf4e92c084b 100644 --- a/core/benches/str/debug.rs +++ b/core/benches/str/debug.rs @@ -4,6 +4,7 @@ //! we should still try to minimize those calls over time rather than regress them. use std::fmt::{self, Write}; + use test::{black_box, Bencher}; #[derive(Default)] diff --git a/core/benches/str/iter.rs b/core/benches/str/iter.rs index 58ae71fc10f12..f6e73e48d8e7d 100644 --- a/core/benches/str/iter.rs +++ b/core/benches/str/iter.rs @@ -1,6 +1,7 @@ -use super::corpora; use test::{black_box, Bencher}; +use super::corpora; + #[bench] fn chars_advance_by_1000(b: &mut Bencher) { b.iter(|| black_box(corpora::ru::LARGE).chars().advance_by(1000)); diff --git a/core/src/alloc/global.rs b/core/src/alloc/global.rs index cf25deacb572e..a6f799c4a7deb 100644 --- a/core/src/alloc/global.rs +++ b/core/src/alloc/global.rs @@ -1,6 +1,5 @@ use crate::alloc::Layout; -use crate::cmp; -use crate::ptr; +use crate::{cmp, ptr}; /// A memory allocator that can be registered as the standard library’s default /// through the `#[global_allocator]` attribute. diff --git a/core/src/alloc/layout.rs b/core/src/alloc/layout.rs index 431b07035c3c3..549a4bc6727fc 100644 --- a/core/src/alloc/layout.rs +++ b/core/src/alloc/layout.rs @@ -4,11 +4,9 @@ // collections, resulting in having to optimize down excess IR multiple times. // Your performance intuition is useless. Run perf. -use crate::cmp; use crate::error::Error; -use crate::fmt; -use crate::mem; use crate::ptr::{Alignment, NonNull}; +use crate::{cmp, fmt, mem}; // While this function is used in one place and its implementation // could be inlined, the previous attempts to do so made rustc diff --git a/core/src/alloc/mod.rs b/core/src/alloc/mod.rs index 1c8e667654469..aa841db045ce7 100644 --- a/core/src/alloc/mod.rs +++ b/core/src/alloc/mod.rs @@ -17,10 +17,8 @@ pub use self::layout::Layout; )] #[allow(deprecated, deprecated_in_future)] pub use self::layout::LayoutErr; - #[stable(feature = "alloc_layout_error", since = "1.50.0")] pub use self::layout::LayoutError; - use crate::error::Error; use crate::fmt; use crate::ptr::{self, NonNull}; diff --git a/core/src/any.rs b/core/src/any.rs index 59f3b6841d531..58107b1e7d074 100644 --- a/core/src/any.rs +++ b/core/src/any.rs @@ -86,9 +86,7 @@ #![stable(feature = "rust1", since = "1.0.0")] -use crate::fmt; -use crate::hash; -use crate::intrinsics; +use crate::{fmt, hash, intrinsics}; /////////////////////////////////////////////////////////////////////////////// // Any trait diff --git a/core/src/array/iter.rs b/core/src/array/iter.rs index 617fd627c9285..2d19e4876f680 100644 --- a/core/src/array/iter.rs +++ b/core/src/array/iter.rs @@ -1,14 +1,11 @@ //! Defines the `IntoIter` owned iterator for arrays. +use crate::intrinsics::transmute_unchecked; +use crate::iter::{self, FusedIterator, TrustedLen, TrustedRandomAccessNoCoerce}; +use crate::mem::MaybeUninit; use crate::num::NonZero; -use crate::{ - fmt, - intrinsics::transmute_unchecked, - iter::{self, FusedIterator, TrustedLen, TrustedRandomAccessNoCoerce}, - mem::MaybeUninit, - ops::{IndexRange, Range}, - ptr, -}; +use crate::ops::{IndexRange, Range}; +use crate::{fmt, ptr}; /// A by-value [array] iterator. #[stable(feature = "array_value_iter", since = "1.51.0")] diff --git a/core/src/array/mod.rs b/core/src/array/mod.rs index 8285c64ed2966..5c826b9993f86 100644 --- a/core/src/array/mod.rs +++ b/core/src/array/mod.rs @@ -23,7 +23,6 @@ mod equality; mod iter; pub(crate) use drain::drain_array_with; - #[stable(feature = "array_value_iter", since = "1.51.0")] pub use iter::IntoIter; diff --git a/core/src/ascii.rs b/core/src/ascii.rs index e9f4d0f93ed49..5b3711b4071ab 100644 --- a/core/src/ascii.rs +++ b/core/src/ascii.rs @@ -9,10 +9,9 @@ #![stable(feature = "core_ascii", since = "1.26.0")] -use crate::escape; -use crate::fmt; use crate::iter::FusedIterator; use crate::num::NonZero; +use crate::{escape, fmt}; mod ascii_char; #[unstable(feature = "ascii_char", issue = "110998")] diff --git a/core/src/asserting.rs b/core/src/asserting.rs index 212b637d34365..3015aa562e6c0 100644 --- a/core/src/asserting.rs +++ b/core/src/asserting.rs @@ -9,10 +9,8 @@ #![doc(hidden)] #![unstable(feature = "generic_assert_internals", issue = "44838")] -use crate::{ - fmt::{Debug, Formatter}, - marker::PhantomData, -}; +use crate::fmt::{Debug, Formatter}; +use crate::marker::PhantomData; // ***** TryCapture - Generic ***** diff --git a/core/src/async_iter/from_iter.rs b/core/src/async_iter/from_iter.rs index 3180187afc8c9..f4e10bdffea2f 100644 --- a/core/src/async_iter/from_iter.rs +++ b/core/src/async_iter/from_iter.rs @@ -1,6 +1,5 @@ -use crate::pin::Pin; - use crate::async_iter::AsyncIterator; +use crate::pin::Pin; use crate::task::{Context, Poll}; /// An async iterator that was created from iterator. diff --git a/core/src/cell/lazy.rs b/core/src/cell/lazy.rs index 21452d40f9ded..6ec1d2a33bef5 100644 --- a/core/src/cell/lazy.rs +++ b/core/src/cell/lazy.rs @@ -1,8 +1,7 @@ +use super::UnsafeCell; use crate::ops::Deref; use crate::{fmt, mem}; -use super::UnsafeCell; - enum State { Uninit(F), Init(T), diff --git a/core/src/cell/once.rs b/core/src/cell/once.rs index 872b4da4dbfda..097fa86c93814 100644 --- a/core/src/cell/once.rs +++ b/core/src/cell/once.rs @@ -1,6 +1,5 @@ use crate::cell::UnsafeCell; -use crate::fmt; -use crate::mem; +use crate::{fmt, mem}; /// A cell which can nominally be written to only once. /// diff --git a/core/src/char/methods.rs b/core/src/char/methods.rs index 4186565c131ed..cece00c9c0807 100644 --- a/core/src/char/methods.rs +++ b/core/src/char/methods.rs @@ -1,12 +1,11 @@ //! impl char {} +use super::*; use crate::slice; use crate::str::from_utf8_unchecked_mut; use crate::unicode::printable::is_printable; use crate::unicode::{self, conversions}; -use super::*; - impl char { /// The lowest valid code point a `char` can have, `'\0'`. /// diff --git a/core/src/char/mod.rs b/core/src/char/mod.rs index 37c27ecb8c4d6..625ac5ae2b45e 100644 --- a/core/src/char/mod.rs +++ b/core/src/char/mod.rs @@ -42,14 +42,13 @@ pub use self::methods::encode_utf8_raw; // perma-unstable #[rustfmt::skip] use crate::ascii; +pub(crate) use self::methods::EscapeDebugExtArgs; use crate::error::Error; use crate::escape; use crate::fmt::{self, Write}; use crate::iter::{FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; use crate::num::NonZero; -pub(crate) use self::methods::EscapeDebugExtArgs; - // UTF-8 ranges and tags for encoding characters const TAG_CONT: u8 = 0b1000_0000; const TAG_TWO_B: u8 = 0b1100_0000; diff --git a/core/src/ffi/c_str.rs b/core/src/ffi/c_str.rs index ae42ae3baf418..b1f731c5fe097 100644 --- a/core/src/ffi/c_str.rs +++ b/core/src/ffi/c_str.rs @@ -3,16 +3,11 @@ use crate::cmp::Ordering; use crate::error::Error; use crate::ffi::c_char; -use crate::fmt; -use crate::intrinsics; use crate::iter::FusedIterator; use crate::marker::PhantomData; -use crate::ops; -use crate::ptr::addr_of; -use crate::ptr::NonNull; -use crate::slice; +use crate::ptr::{addr_of, NonNull}; use crate::slice::memchr; -use crate::str; +use crate::{fmt, intrinsics, ops, slice, str}; // FIXME: because this is doc(inline)d, we *have* to use intra-doc links because the actual link // depends on where the item is being documented. however, since this is libcore, we can't diff --git a/core/src/ffi/mod.rs b/core/src/ffi/mod.rs index 93426b90c706a..ec1f9052a1564 100644 --- a/core/src/ffi/mod.rs +++ b/core/src/ffi/mod.rs @@ -9,19 +9,16 @@ #![stable(feature = "core_ffi", since = "1.30.0")] #![allow(non_camel_case_types)] -use crate::fmt; - -#[doc(no_inline)] +#[doc(inline)] #[stable(feature = "core_c_str", since = "1.64.0")] -pub use self::c_str::FromBytesWithNulError; - +pub use self::c_str::CStr; #[doc(no_inline)] #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] pub use self::c_str::FromBytesUntilNulError; - -#[doc(inline)] +#[doc(no_inline)] #[stable(feature = "core_c_str", since = "1.64.0")] -pub use self::c_str::CStr; +pub use self::c_str::FromBytesWithNulError; +use crate::fmt; #[unstable(feature = "c_str_module", issue = "112134")] pub mod c_str; diff --git a/core/src/ffi/va_list.rs b/core/src/ffi/va_list.rs index dda9e30c24b32..3a224e4d8fe5f 100644 --- a/core/src/ffi/va_list.rs +++ b/core/src/ffi/va_list.rs @@ -3,7 +3,6 @@ //! Better known as "varargs". use crate::ffi::c_void; - #[allow(unused_imports)] use crate::fmt; use crate::marker::PhantomData; diff --git a/core/src/fmt/float.rs b/core/src/fmt/float.rs index 80c45fce2f0a0..20ea0352c2dce 100644 --- a/core/src/fmt/float.rs +++ b/core/src/fmt/float.rs @@ -1,7 +1,6 @@ use crate::fmt::{Debug, Display, Formatter, LowerExp, Result, UpperExp}; use crate::mem::MaybeUninit; -use crate::num::flt2dec; -use crate::num::fmt as numfmt; +use crate::num::{flt2dec, fmt as numfmt}; #[doc(hidden)] trait GeneralFormat: PartialOrd { diff --git a/core/src/fmt/mod.rs b/core/src/fmt/mod.rs index 594f26e978ac0..60c0dc7685253 100644 --- a/core/src/fmt/mod.rs +++ b/core/src/fmt/mod.rs @@ -4,13 +4,10 @@ use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell}; use crate::char::EscapeDebugExtArgs; -use crate::iter; use crate::marker::PhantomData; -use crate::mem; use crate::num::fmt as numfmt; use crate::ops::Deref; -use crate::result; -use crate::str; +use crate::{iter, mem, result, str}; mod builders; #[cfg(not(no_fp_fmt_parse))] @@ -36,11 +33,10 @@ pub enum Alignment { Center, } -#[stable(feature = "debug_builders", since = "1.2.0")] -pub use self::builders::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple}; - #[unstable(feature = "debug_closure_helpers", issue = "117729")] pub use self::builders::FormatterFn; +#[stable(feature = "debug_builders", since = "1.2.0")] +pub use self::builders::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple}; /// The type returned by formatter methods. /// diff --git a/core/src/fmt/num.rs b/core/src/fmt/num.rs index 3a5a5af8bf5d3..e7726da8d91f2 100644 --- a/core/src/fmt/num.rs +++ b/core/src/fmt/num.rs @@ -1,12 +1,9 @@ //! Integer and floating-point number formatting -use crate::fmt; use crate::mem::MaybeUninit; use crate::num::fmt as numfmt; use crate::ops::{Div, Rem, Sub}; -use crate::ptr; -use crate::slice; -use crate::str; +use crate::{fmt, ptr, slice, str}; #[doc(hidden)] trait DisplayInt: diff --git a/core/src/future/mod.rs b/core/src/future/mod.rs index 3a1451abfa40b..d188f1c713079 100644 --- a/core/src/future/mod.rs +++ b/core/src/future/mod.rs @@ -20,25 +20,21 @@ mod pending; mod poll_fn; mod ready; -#[stable(feature = "futures_api", since = "1.36.0")] -pub use self::future::Future; - -#[unstable(feature = "future_join", issue = "91642")] -pub use self::join::join; - +#[unstable(feature = "async_drop", issue = "126482")] +pub use async_drop::{async_drop, async_drop_in_place, AsyncDrop, AsyncDropInPlace}; #[stable(feature = "into_future", since = "1.64.0")] pub use into_future::IntoFuture; - #[stable(feature = "future_readiness_fns", since = "1.48.0")] pub use pending::{pending, Pending}; -#[stable(feature = "future_readiness_fns", since = "1.48.0")] -pub use ready::{ready, Ready}; - #[stable(feature = "future_poll_fn", since = "1.64.0")] pub use poll_fn::{poll_fn, PollFn}; +#[stable(feature = "future_readiness_fns", since = "1.48.0")] +pub use ready::{ready, Ready}; -#[unstable(feature = "async_drop", issue = "126482")] -pub use async_drop::{async_drop, async_drop_in_place, AsyncDrop, AsyncDropInPlace}; +#[stable(feature = "futures_api", since = "1.36.0")] +pub use self::future::Future; +#[unstable(feature = "future_join", issue = "91642")] +pub use self::join::join; /// This type is needed because: /// diff --git a/core/src/hash/mod.rs b/core/src/hash/mod.rs index da734466263ab..061690e88ddf8 100644 --- a/core/src/hash/mod.rs +++ b/core/src/hash/mod.rs @@ -83,17 +83,14 @@ #![stable(feature = "rust1", since = "1.0.0")] -use crate::fmt; -use crate::marker; - #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)] pub use self::sip::SipHasher; - #[unstable(feature = "hashmap_internals", issue = "none")] #[allow(deprecated)] #[doc(hidden)] pub use self::sip::SipHasher13; +use crate::{fmt, marker}; mod sip; @@ -806,10 +803,8 @@ impl PartialEq for BuildHasherDefault { impl Eq for BuildHasherDefault {} mod impls { - use crate::mem; - use crate::slice; - use super::*; + use crate::{mem, slice}; macro_rules! impl_write { ($(($ty:ident, $meth:ident),)*) => {$( diff --git a/core/src/hash/sip.rs b/core/src/hash/sip.rs index 0d1ac64aa56cf..17f2caaa0c083 100644 --- a/core/src/hash/sip.rs +++ b/core/src/hash/sip.rs @@ -2,10 +2,8 @@ #![allow(deprecated)] // the types in this module are deprecated -use crate::cmp; use crate::marker::PhantomData; -use crate::mem; -use crate::ptr; +use crate::{cmp, mem, ptr}; /// An implementation of SipHash 1-3. /// diff --git a/core/src/hint.rs b/core/src/hint.rs index b3e36e6fbc4ac..bb969cf71c57e 100644 --- a/core/src/hint.rs +++ b/core/src/hint.rs @@ -3,8 +3,7 @@ //! Hints to compiler that affects how code should be emitted or optimized. //! Hints may be compile time or runtime. -use crate::intrinsics; -use crate::ub_checks; +use crate::{intrinsics, ub_checks}; /// Informs the compiler that the site which is calling this function is not /// reachable, possibly enabling further optimizations. diff --git a/core/src/intrinsics.rs b/core/src/intrinsics.rs index 878ab5ad27d7f..a455a15d9a980 100644 --- a/core/src/intrinsics.rs +++ b/core/src/intrinsics.rs @@ -63,10 +63,8 @@ )] #![allow(missing_docs)] -use crate::marker::DiscriminantKind; -use crate::marker::Tuple; -use crate::ptr; -use crate::ub_checks; +use crate::marker::{DiscriminantKind, Tuple}; +use crate::{ptr, ub_checks}; pub mod mir; pub mod simd; diff --git a/core/src/intrinsics/mir.rs b/core/src/intrinsics/mir.rs index 1daf1d723fb95..fd49a96eaa049 100644 --- a/core/src/intrinsics/mir.rs +++ b/core/src/intrinsics/mir.rs @@ -276,8 +276,7 @@ pub enum UnwindTerminateReason { InCleanup, } -pub use UnwindTerminateReason::Abi as ReasonAbi; -pub use UnwindTerminateReason::InCleanup as ReasonInCleanup; +pub use UnwindTerminateReason::{Abi as ReasonAbi, InCleanup as ReasonInCleanup}; macro_rules! define { ($name:literal, $( #[ $meta:meta ] )* fn $($sig:tt)*) => { diff --git a/core/src/iter/adapters/cloned.rs b/core/src/iter/adapters/cloned.rs index 1a106ef97942b..aea6d64281aec 100644 --- a/core/src/iter/adapters/cloned.rs +++ b/core/src/iter/adapters/cloned.rs @@ -1,9 +1,9 @@ -use crate::iter::adapters::{ - zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce, -}; +use core::num::NonZero; + +use crate::iter::adapters::zip::try_get_unchecked; +use crate::iter::adapters::{SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen, UncheckedIterator}; use crate::ops::Try; -use core::num::NonZero; /// An iterator that clones the elements of an underlying iterator. /// diff --git a/core/src/iter/adapters/copied.rs b/core/src/iter/adapters/copied.rs index d772e7b36e09e..23e4e25ab5388 100644 --- a/core/src/iter/adapters/copied.rs +++ b/core/src/iter/adapters/copied.rs @@ -1,9 +1,7 @@ -use crate::iter::adapters::{ - zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce, -}; +use crate::iter::adapters::zip::try_get_unchecked; +use crate::iter::adapters::{SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen}; -use crate::mem::MaybeUninit; -use crate::mem::SizedTypeProperties; +use crate::mem::{MaybeUninit, SizedTypeProperties}; use crate::num::NonZero; use crate::ops::Try; use crate::{array, ptr}; diff --git a/core/src/iter/adapters/cycle.rs b/core/src/iter/adapters/cycle.rs index b35ed8442032d..6cb1a3a46763e 100644 --- a/core/src/iter/adapters/cycle.rs +++ b/core/src/iter/adapters/cycle.rs @@ -1,5 +1,6 @@ +use crate::iter::FusedIterator; use crate::num::NonZero; -use crate::{iter::FusedIterator, ops::Try}; +use crate::ops::Try; /// An iterator that repeats endlessly. /// diff --git a/core/src/iter/adapters/enumerate.rs b/core/src/iter/adapters/enumerate.rs index 7adbabf69e490..ac15e3767fc09 100644 --- a/core/src/iter/adapters/enumerate.rs +++ b/core/src/iter/adapters/enumerate.rs @@ -1,6 +1,5 @@ -use crate::iter::adapters::{ - zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce, -}; +use crate::iter::adapters::zip::try_get_unchecked; +use crate::iter::adapters::{SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused, TrustedLen}; use crate::num::NonZero; use crate::ops::Try; diff --git a/core/src/iter/adapters/filter.rs b/core/src/iter/adapters/filter.rs index ba49070329c22..dd08cd6f61c4c 100644 --- a/core/src/iter/adapters/filter.rs +++ b/core/src/iter/adapters/filter.rs @@ -1,11 +1,13 @@ -use crate::fmt; -use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused}; -use crate::num::NonZero; -use crate::ops::Try; use core::array; use core::mem::MaybeUninit; use core::ops::ControlFlow; +use crate::fmt; +use crate::iter::adapters::SourceIter; +use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused}; +use crate::num::NonZero; +use crate::ops::Try; + /// An iterator that filters the elements of `iter` with `predicate`. /// /// This `struct` is created by the [`filter`] method on [`Iterator`]. See its diff --git a/core/src/iter/adapters/filter_map.rs b/core/src/iter/adapters/filter_map.rs index 2126619a58a87..914ef6131771f 100644 --- a/core/src/iter/adapters/filter_map.rs +++ b/core/src/iter/adapters/filter_map.rs @@ -1,4 +1,5 @@ -use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused}; +use crate::iter::adapters::SourceIter; +use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused}; use crate::mem::{ManuallyDrop, MaybeUninit}; use crate::num::NonZero; use crate::ops::{ControlFlow, Try}; diff --git a/core/src/iter/adapters/flatten.rs b/core/src/iter/adapters/flatten.rs index 145c9d3dacc84..0023b46031f12 100644 --- a/core/src/iter/adapters/flatten.rs +++ b/core/src/iter/adapters/flatten.rs @@ -1,13 +1,11 @@ use crate::iter::adapters::SourceIter; use crate::iter::{ - Cloned, Copied, Filter, FilterMap, Fuse, FusedIterator, InPlaceIterable, Map, TrustedFused, - TrustedLen, + Cloned, Copied, Empty, Filter, FilterMap, Fuse, FusedIterator, InPlaceIterable, Map, Once, + OnceWith, TrustedFused, TrustedLen, }; -use crate::iter::{Empty, Once, OnceWith}; use crate::num::NonZero; use crate::ops::{ControlFlow, Try}; -use crate::result; -use crate::{array, fmt, option}; +use crate::{array, fmt, option, result}; /// An iterator that maps each element to an iterator, and yields the elements /// of the produced iterators. diff --git a/core/src/iter/adapters/inspect.rs b/core/src/iter/adapters/inspect.rs index 1c4656a649a37..0e2a68a503e44 100644 --- a/core/src/iter/adapters/inspect.rs +++ b/core/src/iter/adapters/inspect.rs @@ -1,5 +1,6 @@ use crate::fmt; -use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused}; +use crate::iter::adapters::SourceIter; +use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused}; use crate::num::NonZero; use crate::ops::Try; diff --git a/core/src/iter/adapters/map.rs b/core/src/iter/adapters/map.rs index 6e163e20d8ec4..007c2d5acc2d0 100644 --- a/core/src/iter/adapters/map.rs +++ b/core/src/iter/adapters/map.rs @@ -1,7 +1,6 @@ use crate::fmt; -use crate::iter::adapters::{ - zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce, -}; +use crate::iter::adapters::zip::try_get_unchecked; +use crate::iter::adapters::{SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused, TrustedLen, UncheckedIterator}; use crate::num::NonZero; use crate::ops::Try; diff --git a/core/src/iter/adapters/map_while.rs b/core/src/iter/adapters/map_while.rs index 9ad50048c25ea..4e7327938d72a 100644 --- a/core/src/iter/adapters/map_while.rs +++ b/core/src/iter/adapters/map_while.rs @@ -1,5 +1,6 @@ use crate::fmt; -use crate::iter::{adapters::SourceIter, InPlaceIterable}; +use crate::iter::adapters::SourceIter; +use crate::iter::InPlaceIterable; use crate::num::NonZero; use crate::ops::{ControlFlow, Try}; diff --git a/core/src/iter/adapters/map_windows.rs b/core/src/iter/adapters/map_windows.rs index 182775121369e..cb13023c85c41 100644 --- a/core/src/iter/adapters/map_windows.rs +++ b/core/src/iter/adapters/map_windows.rs @@ -1,9 +1,6 @@ -use crate::{ - fmt, - iter::FusedIterator, - mem::{self, MaybeUninit}, - ptr, -}; +use crate::iter::FusedIterator; +use crate::mem::{self, MaybeUninit}; +use crate::{fmt, ptr}; /// An iterator over the mapped windows of another iterator. /// diff --git a/core/src/iter/adapters/mod.rs b/core/src/iter/adapters/mod.rs index 1bde4488cc9de..96158c43318ea 100644 --- a/core/src/iter/adapters/mod.rs +++ b/core/src/iter/adapters/mod.rs @@ -28,51 +28,38 @@ mod take; mod take_while; mod zip; -#[stable(feature = "rust1", since = "1.0.0")] -pub use self::{ - chain::Chain, cycle::Cycle, enumerate::Enumerate, filter::Filter, filter_map::FilterMap, - flatten::FlatMap, fuse::Fuse, inspect::Inspect, map::Map, peekable::Peekable, rev::Rev, - scan::Scan, skip::Skip, skip_while::SkipWhile, take::Take, take_while::TakeWhile, zip::Zip, -}; - #[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")] pub use self::array_chunks::ArrayChunks; - #[unstable(feature = "std_internals", issue = "none")] pub use self::by_ref_sized::ByRefSized; - #[unstable(feature = "iter_chain", reason = "recently added", issue = "125964")] pub use self::chain::chain; - #[stable(feature = "iter_cloned", since = "1.1.0")] pub use self::cloned::Cloned; - -#[stable(feature = "iterator_step_by", since = "1.28.0")] -pub use self::step_by::StepBy; - -#[stable(feature = "iterator_flatten", since = "1.29.0")] -pub use self::flatten::Flatten; - #[stable(feature = "iter_copied", since = "1.36.0")] pub use self::copied::Copied; - +#[stable(feature = "iterator_flatten", since = "1.29.0")] +pub use self::flatten::Flatten; #[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] pub use self::intersperse::{Intersperse, IntersperseWith}; - #[stable(feature = "iter_map_while", since = "1.57.0")] pub use self::map_while::MapWhile; - #[unstable(feature = "iter_map_windows", reason = "recently added", issue = "87155")] pub use self::map_windows::MapWindows; - +#[stable(feature = "iterator_step_by", since = "1.28.0")] +pub use self::step_by::StepBy; +#[stable(feature = "iter_zip", since = "1.59.0")] +pub use self::zip::zip; #[unstable(feature = "trusted_random_access", issue = "none")] pub use self::zip::TrustedRandomAccess; - #[unstable(feature = "trusted_random_access", issue = "none")] pub use self::zip::TrustedRandomAccessNoCoerce; - -#[stable(feature = "iter_zip", since = "1.59.0")] -pub use self::zip::zip; +#[stable(feature = "rust1", since = "1.0.0")] +pub use self::{ + chain::Chain, cycle::Cycle, enumerate::Enumerate, filter::Filter, filter_map::FilterMap, + flatten::FlatMap, fuse::Fuse, inspect::Inspect, map::Map, peekable::Peekable, rev::Rev, + scan::Scan, skip::Skip, skip_while::SkipWhile, take::Take, take_while::TakeWhile, zip::Zip, +}; /// This trait provides transitive access to source-stage in an iterator-adapter pipeline /// under the conditions that diff --git a/core/src/iter/adapters/peekable.rs b/core/src/iter/adapters/peekable.rs index 65ba42920c93d..a11b73cbe8e2d 100644 --- a/core/src/iter/adapters/peekable.rs +++ b/core/src/iter/adapters/peekable.rs @@ -1,4 +1,5 @@ -use crate::iter::{adapters::SourceIter, FusedIterator, TrustedLen}; +use crate::iter::adapters::SourceIter; +use crate::iter::{FusedIterator, TrustedLen}; use crate::ops::{ControlFlow, Try}; /// An iterator with a `peek()` that returns an optional reference to the next diff --git a/core/src/iter/adapters/scan.rs b/core/src/iter/adapters/scan.rs index d261a535b183a..7ba7ed2fdd0d5 100644 --- a/core/src/iter/adapters/scan.rs +++ b/core/src/iter/adapters/scan.rs @@ -1,5 +1,6 @@ use crate::fmt; -use crate::iter::{adapters::SourceIter, InPlaceIterable}; +use crate::iter::adapters::SourceIter; +use crate::iter::InPlaceIterable; use crate::num::NonZero; use crate::ops::{ControlFlow, Try}; diff --git a/core/src/iter/adapters/skip.rs b/core/src/iter/adapters/skip.rs index f51a2c39b8e28..8ba2e2a8f2dd7 100644 --- a/core/src/iter/adapters/skip.rs +++ b/core/src/iter/adapters/skip.rs @@ -1,8 +1,8 @@ use crate::intrinsics::unlikely; use crate::iter::adapters::zip::try_get_unchecked; -use crate::iter::TrustedFused; +use crate::iter::adapters::SourceIter; use crate::iter::{ - adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedLen, TrustedRandomAccess, + FusedIterator, InPlaceIterable, TrustedFused, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, }; use crate::num::NonZero; diff --git a/core/src/iter/adapters/skip_while.rs b/core/src/iter/adapters/skip_while.rs index 8001e6e64713a..8ae453e76fa0d 100644 --- a/core/src/iter/adapters/skip_while.rs +++ b/core/src/iter/adapters/skip_while.rs @@ -1,5 +1,6 @@ use crate::fmt; -use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused}; +use crate::iter::adapters::SourceIter; +use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused}; use crate::num::NonZero; use crate::ops::Try; diff --git a/core/src/iter/adapters/step_by.rs b/core/src/iter/adapters/step_by.rs index d3105e7d88c33..72eb72a76c66c 100644 --- a/core/src/iter/adapters/step_by.rs +++ b/core/src/iter/adapters/step_by.rs @@ -1,9 +1,7 @@ -use crate::{ - intrinsics, - iter::{from_fn, TrustedLen, TrustedRandomAccess}, - num::NonZero, - ops::{Range, Try}, -}; +use crate::intrinsics; +use crate::iter::{from_fn, TrustedLen, TrustedRandomAccess}; +use crate::num::NonZero; +use crate::ops::{Range, Try}; /// An iterator for stepping iterators by a custom amount. /// diff --git a/core/src/iter/adapters/take.rs b/core/src/iter/adapters/take.rs index 6870c677b1e07..297dd0acaddc1 100644 --- a/core/src/iter/adapters/take.rs +++ b/core/src/iter/adapters/take.rs @@ -1,8 +1,6 @@ use crate::cmp; -use crate::iter::{ - adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused, TrustedLen, - TrustedRandomAccess, -}; +use crate::iter::adapters::SourceIter; +use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused, TrustedLen, TrustedRandomAccess}; use crate::num::NonZero; use crate::ops::{ControlFlow, Try}; diff --git a/core/src/iter/adapters/take_while.rs b/core/src/iter/adapters/take_while.rs index d3f09ab356ad8..06028ea98e7fd 100644 --- a/core/src/iter/adapters/take_while.rs +++ b/core/src/iter/adapters/take_while.rs @@ -1,5 +1,6 @@ use crate::fmt; -use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused}; +use crate::iter::adapters::SourceIter; +use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused}; use crate::num::NonZero; use crate::ops::{ControlFlow, Try}; diff --git a/core/src/iter/adapters/zip.rs b/core/src/iter/adapters/zip.rs index 2e885f06b5272..0c38811590877 100644 --- a/core/src/iter/adapters/zip.rs +++ b/core/src/iter/adapters/zip.rs @@ -1,7 +1,8 @@ use crate::cmp; use crate::fmt::{self, Debug}; -use crate::iter::{FusedIterator, TrustedFused}; -use crate::iter::{InPlaceIterable, SourceIter, TrustedLen, UncheckedIterator}; +use crate::iter::{ + FusedIterator, InPlaceIterable, SourceIter, TrustedFused, TrustedLen, UncheckedIterator, +}; use crate::num::NonZero; /// An iterator that iterates two other iterators simultaneously. diff --git a/core/src/iter/mod.rs b/core/src/iter/mod.rs index 921c75c85f161..1f2bf49d2b729 100644 --- a/core/src/iter/mod.rs +++ b/core/src/iter/mod.rs @@ -380,16 +380,46 @@ macro_rules! impl_fold_via_try_fold { }; } +#[unstable(feature = "iter_chain", reason = "recently added", issue = "125964")] +pub use self::adapters::chain; +pub(crate) use self::adapters::try_process; +#[stable(feature = "iter_zip", since = "1.59.0")] +pub use self::adapters::zip; +#[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")] +pub use self::adapters::ArrayChunks; +#[unstable(feature = "std_internals", issue = "none")] +pub use self::adapters::ByRefSized; +#[stable(feature = "iter_cloned", since = "1.1.0")] +pub use self::adapters::Cloned; +#[stable(feature = "iter_copied", since = "1.36.0")] +pub use self::adapters::Copied; +#[stable(feature = "iterator_flatten", since = "1.29.0")] +pub use self::adapters::Flatten; +#[stable(feature = "iter_map_while", since = "1.57.0")] +pub use self::adapters::MapWhile; +#[unstable(feature = "iter_map_windows", reason = "recently added", issue = "87155")] +pub use self::adapters::MapWindows; +#[unstable(feature = "inplace_iteration", issue = "none")] +pub use self::adapters::SourceIter; +#[stable(feature = "iterator_step_by", since = "1.28.0")] +pub use self::adapters::StepBy; +#[unstable(feature = "trusted_random_access", issue = "none")] +pub use self::adapters::TrustedRandomAccess; +#[unstable(feature = "trusted_random_access", issue = "none")] +pub use self::adapters::TrustedRandomAccessNoCoerce; #[stable(feature = "rust1", since = "1.0.0")] -pub use self::traits::Iterator; - +pub use self::adapters::{ + Chain, Cycle, Enumerate, Filter, FilterMap, FlatMap, Fuse, Inspect, Map, Peekable, Rev, Scan, + Skip, SkipWhile, Take, TakeWhile, Zip, +}; +#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] +pub use self::adapters::{Intersperse, IntersperseWith}; #[unstable( feature = "step_trait", reason = "likely to be replaced by finer-grained traits", issue = "42168" )] pub use self::range::Step; - #[unstable( feature = "iter_from_coroutine", issue = "43122", @@ -412,59 +442,24 @@ pub use self::sources::{repeat_n, RepeatN}; pub use self::sources::{repeat_with, RepeatWith}; #[stable(feature = "iter_successors", since = "1.34.0")] pub use self::sources::{successors, Successors}; - #[stable(feature = "fused", since = "1.26.0")] pub use self::traits::FusedIterator; #[unstable(issue = "none", feature = "inplace_iteration")] pub use self::traits::InPlaceIterable; +#[stable(feature = "rust1", since = "1.0.0")] +pub use self::traits::Iterator; #[unstable(issue = "none", feature = "trusted_fused")] pub use self::traits::TrustedFused; #[unstable(feature = "trusted_len", issue = "37572")] pub use self::traits::TrustedLen; #[unstable(feature = "trusted_step", issue = "85731")] pub use self::traits::TrustedStep; +pub(crate) use self::traits::UncheckedIterator; #[stable(feature = "rust1", since = "1.0.0")] pub use self::traits::{ DoubleEndedIterator, ExactSizeIterator, Extend, FromIterator, IntoIterator, Product, Sum, }; -#[unstable(feature = "iter_chain", reason = "recently added", issue = "125964")] -pub use self::adapters::chain; -#[stable(feature = "iter_zip", since = "1.59.0")] -pub use self::adapters::zip; -#[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")] -pub use self::adapters::ArrayChunks; -#[unstable(feature = "std_internals", issue = "none")] -pub use self::adapters::ByRefSized; -#[stable(feature = "iter_cloned", since = "1.1.0")] -pub use self::adapters::Cloned; -#[stable(feature = "iter_copied", since = "1.36.0")] -pub use self::adapters::Copied; -#[stable(feature = "iterator_flatten", since = "1.29.0")] -pub use self::adapters::Flatten; -#[stable(feature = "iter_map_while", since = "1.57.0")] -pub use self::adapters::MapWhile; -#[unstable(feature = "iter_map_windows", reason = "recently added", issue = "87155")] -pub use self::adapters::MapWindows; -#[unstable(feature = "inplace_iteration", issue = "none")] -pub use self::adapters::SourceIter; -#[stable(feature = "iterator_step_by", since = "1.28.0")] -pub use self::adapters::StepBy; -#[unstable(feature = "trusted_random_access", issue = "none")] -pub use self::adapters::TrustedRandomAccess; -#[unstable(feature = "trusted_random_access", issue = "none")] -pub use self::adapters::TrustedRandomAccessNoCoerce; -#[stable(feature = "rust1", since = "1.0.0")] -pub use self::adapters::{ - Chain, Cycle, Enumerate, Filter, FilterMap, FlatMap, Fuse, Inspect, Map, Peekable, Rev, Scan, - Skip, SkipWhile, Take, TakeWhile, Zip, -}; -#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] -pub use self::adapters::{Intersperse, IntersperseWith}; - -pub(crate) use self::adapters::try_process; -pub(crate) use self::traits::UncheckedIterator; - mod adapters; mod range; mod sources; diff --git a/core/src/iter/range.rs b/core/src/iter/range.rs index 644a169294396..da4f68a0de4fb 100644 --- a/core/src/iter/range.rs +++ b/core/src/iter/range.rs @@ -1,13 +1,12 @@ +use super::{ + FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, TrustedStep, +}; use crate::ascii::Char as AsciiChar; use crate::mem; use crate::net::{Ipv4Addr, Ipv6Addr}; use crate::num::NonZero; use crate::ops::{self, Try}; -use super::{ - FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, TrustedStep, -}; - // Safety: All invariants are upheld. macro_rules! unsafe_impl_trusted_step { ($($type:ty)*) => {$( diff --git a/core/src/iter/sources.rs b/core/src/iter/sources.rs index 56c1f86079a3a..6a94051b7c7b8 100644 --- a/core/src/iter/sources.rs +++ b/core/src/iter/sources.rs @@ -8,33 +8,25 @@ mod repeat_n; mod repeat_with; mod successors; -#[stable(feature = "rust1", since = "1.0.0")] -pub use self::repeat::{repeat, Repeat}; - #[stable(feature = "iter_empty", since = "1.2.0")] pub use self::empty::{empty, Empty}; - -#[stable(feature = "iter_once", since = "1.2.0")] -pub use self::once::{once, Once}; - -#[unstable(feature = "iter_repeat_n", issue = "104434")] -pub use self::repeat_n::{repeat_n, RepeatN}; - -#[stable(feature = "iterator_repeat_with", since = "1.28.0")] -pub use self::repeat_with::{repeat_with, RepeatWith}; - -#[stable(feature = "iter_from_fn", since = "1.34.0")] -pub use self::from_fn::{from_fn, FromFn}; - #[unstable( feature = "iter_from_coroutine", issue = "43122", reason = "coroutines are unstable" )] pub use self::from_coroutine::from_coroutine; - -#[stable(feature = "iter_successors", since = "1.34.0")] -pub use self::successors::{successors, Successors}; - +#[stable(feature = "iter_from_fn", since = "1.34.0")] +pub use self::from_fn::{from_fn, FromFn}; +#[stable(feature = "iter_once", since = "1.2.0")] +pub use self::once::{once, Once}; #[stable(feature = "iter_once_with", since = "1.43.0")] pub use self::once_with::{once_with, OnceWith}; +#[stable(feature = "rust1", since = "1.0.0")] +pub use self::repeat::{repeat, Repeat}; +#[unstable(feature = "iter_repeat_n", issue = "104434")] +pub use self::repeat_n::{repeat_n, RepeatN}; +#[stable(feature = "iterator_repeat_with", since = "1.28.0")] +pub use self::repeat_with::{repeat_with, RepeatWith}; +#[stable(feature = "iter_successors", since = "1.34.0")] +pub use self::successors::{successors, Successors}; diff --git a/core/src/iter/sources/empty.rs b/core/src/iter/sources/empty.rs index 438e046a4dfdc..3c3acceded889 100644 --- a/core/src/iter/sources/empty.rs +++ b/core/src/iter/sources/empty.rs @@ -1,6 +1,5 @@ -use crate::fmt; use crate::iter::{FusedIterator, TrustedLen}; -use crate::marker; +use crate::{fmt, marker}; /// Creates an iterator that yields nothing. /// diff --git a/core/src/iter/sources/successors.rs b/core/src/iter/sources/successors.rs index 7f7b2c7756628..36bc4035039e6 100644 --- a/core/src/iter/sources/successors.rs +++ b/core/src/iter/sources/successors.rs @@ -1,4 +1,5 @@ -use crate::{fmt, iter::FusedIterator}; +use crate::fmt; +use crate::iter::FusedIterator; /// Creates a new iterator where each successive item is computed based on the preceding one. /// diff --git a/core/src/iter/traits/iterator.rs b/core/src/iter/traits/iterator.rs index c85a61ada3d69..50a2d952e5b36 100644 --- a/core/src/iter/traits/iterator.rs +++ b/core/src/iter/traits/iterator.rs @@ -1,19 +1,14 @@ +use super::super::{ + try_process, ArrayChunks, ByRefSized, Chain, Cloned, Copied, Cycle, Enumerate, Filter, + FilterMap, FlatMap, Flatten, Fuse, Inspect, Intersperse, IntersperseWith, Map, MapWhile, + MapWindows, Peekable, Product, Rev, Scan, Skip, SkipWhile, StepBy, Sum, Take, TakeWhile, + TrustedRandomAccessNoCoerce, Zip, +}; use crate::array; use crate::cmp::{self, Ordering}; use crate::num::NonZero; use crate::ops::{ChangeOutputType, ControlFlow, FromResidual, Residual, Try}; -use super::super::try_process; -use super::super::ByRefSized; -use super::super::TrustedRandomAccessNoCoerce; -use super::super::{ArrayChunks, Chain, Cloned, Copied, Cycle, Enumerate, Filter, FilterMap, Fuse}; -use super::super::{FlatMap, Flatten}; -use super::super::{ - Inspect, Map, MapWhile, MapWindows, Peekable, Rev, Scan, Skip, SkipWhile, StepBy, Take, - TakeWhile, -}; -use super::super::{Intersperse, IntersperseWith, Product, Sum, Zip}; - fn _assert_is_object_safe(_: &dyn Iterator) {} /// A trait for dealing with iterators. diff --git a/core/src/iter/traits/mod.rs b/core/src/iter/traits/mod.rs index d4c9cc4b16037..b330e9ffe21ac 100644 --- a/core/src/iter/traits/mod.rs +++ b/core/src/iter/traits/mod.rs @@ -6,6 +6,13 @@ mod iterator; mod marker; mod unchecked_iterator; +#[unstable(issue = "none", feature = "inplace_iteration")] +pub use self::marker::InPlaceIterable; +#[unstable(issue = "none", feature = "trusted_fused")] +pub use self::marker::TrustedFused; +#[unstable(feature = "trusted_step", issue = "85731")] +pub use self::marker::TrustedStep; +pub(crate) use self::unchecked_iterator::UncheckedIterator; #[stable(feature = "rust1", since = "1.0.0")] pub use self::{ accum::{Product, Sum}, @@ -15,12 +22,3 @@ pub use self::{ iterator::Iterator, marker::{FusedIterator, TrustedLen}, }; - -#[unstable(issue = "none", feature = "inplace_iteration")] -pub use self::marker::InPlaceIterable; -#[unstable(issue = "none", feature = "trusted_fused")] -pub use self::marker::TrustedFused; -#[unstable(feature = "trusted_step", issue = "85731")] -pub use self::marker::TrustedStep; - -pub(crate) use self::unchecked_iterator::UncheckedIterator; diff --git a/core/src/marker.rs b/core/src/marker.rs index ac630df805a57..082768ea9f26d 100644 --- a/core/src/marker.rs +++ b/core/src/marker.rs @@ -9,8 +9,7 @@ use crate::cell::UnsafeCell; use crate::cmp; use crate::fmt::Debug; -use crate::hash::Hash; -use crate::hash::Hasher; +use crate::hash::{Hash, Hasher}; /// Implements a given marker trait for multiple types at the same time. /// diff --git a/core/src/mem/maybe_uninit.rs b/core/src/mem/maybe_uninit.rs index a3f433fd5ac99..f920ab1792daf 100644 --- a/core/src/mem/maybe_uninit.rs +++ b/core/src/mem/maybe_uninit.rs @@ -1,9 +1,6 @@ use crate::any::type_name; -use crate::fmt; -use crate::intrinsics; use crate::mem::{self, ManuallyDrop}; -use crate::ptr; -use crate::slice; +use crate::{fmt, intrinsics, ptr, slice}; /// A wrapper type to construct uninitialized instances of `T`. /// diff --git a/core/src/mem/mod.rs b/core/src/mem/mod.rs index 9bb4ba922cd44..b8e9f606a9ad6 100644 --- a/core/src/mem/mod.rs +++ b/core/src/mem/mod.rs @@ -5,13 +5,8 @@ #![stable(feature = "rust1", since = "1.0.0")] -use crate::clone; -use crate::cmp; -use crate::fmt; -use crate::hash; -use crate::intrinsics; use crate::marker::DiscriminantKind; -use crate::ptr; +use crate::{clone, cmp, fmt, hash, intrinsics, ptr}; mod manually_drop; #[stable(feature = "manually_drop", since = "1.20.0")] diff --git a/core/src/net/display_buffer.rs b/core/src/net/display_buffer.rs index 6619c85f483ef..bab84a97308b3 100644 --- a/core/src/net/display_buffer.rs +++ b/core/src/net/display_buffer.rs @@ -1,6 +1,5 @@ -use crate::fmt; use crate::mem::MaybeUninit; -use crate::str; +use crate::{fmt, str}; /// Used for slow path in `Display` implementations when alignment is required. pub struct DisplayBuffer { diff --git a/core/src/net/ip_addr.rs b/core/src/net/ip_addr.rs index e9abd57b858bc..3e036b88128c7 100644 --- a/core/src/net/ip_addr.rs +++ b/core/src/net/ip_addr.rs @@ -1,11 +1,10 @@ +use super::display_buffer::DisplayBuffer; use crate::cmp::Ordering; use crate::fmt::{self, Write}; use crate::iter; use crate::mem::transmute; use crate::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Not}; -use super::display_buffer::DisplayBuffer; - /// An IP address, either IPv4 or IPv6. /// /// This enum can contain either an [`Ipv4Addr`] or an [`Ipv6Addr`], see their diff --git a/core/src/net/socket_addr.rs b/core/src/net/socket_addr.rs index c24d8f5519504..4e339172b682f 100644 --- a/core/src/net/socket_addr.rs +++ b/core/src/net/socket_addr.rs @@ -1,8 +1,7 @@ +use super::display_buffer::DisplayBuffer; use crate::fmt::{self, Write}; use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr}; -use super::display_buffer::DisplayBuffer; - /// An internet socket address, either IPv4 or IPv6. /// /// Internet socket addresses consist of an [IP address], a 16-bit port number, as well diff --git a/core/src/num/bignum.rs b/core/src/num/bignum.rs index d2a21b6b38260..2a47c89e2aee2 100644 --- a/core/src/num/bignum.rs +++ b/core/src/num/bignum.rs @@ -145,8 +145,7 @@ macro_rules! define_bignum { /// Adds `other` to itself and returns its own mutable reference. pub fn add<'a>(&'a mut self, other: &$name) -> &'a mut $name { - use crate::cmp; - use crate::iter; + use crate::{cmp, iter}; let mut sz = cmp::max(self.size, other.size); let mut carry = false; @@ -181,8 +180,7 @@ macro_rules! define_bignum { /// Subtracts `other` from itself and returns its own mutable reference. pub fn sub<'a>(&'a mut self, other: &$name) -> &'a mut $name { - use crate::cmp; - use crate::iter; + use crate::{cmp, iter}; let sz = cmp::max(self.size, other.size); let mut noborrow = true; diff --git a/core/src/num/dec2flt/mod.rs b/core/src/num/dec2flt/mod.rs index 9aac2332dce0d..87bfd0d256634 100644 --- a/core/src/num/dec2flt/mod.rs +++ b/core/src/num/dec2flt/mod.rs @@ -75,15 +75,14 @@ issue = "none" )] -use crate::error::Error; -use crate::fmt; -use crate::str::FromStr; - use self::common::BiasedFp; use self::float::RawFloat; use self::lemire::compute_float; use self::parse::{parse_inf_nan, parse_number}; use self::slow::parse_long_mantissa; +use crate::error::Error; +use crate::fmt; +use crate::str::FromStr; mod common; mod decimal; diff --git a/core/src/num/flt2dec/mod.rs b/core/src/num/flt2dec/mod.rs index 1ff2e8c8228c9..7d923a2652f28 100644 --- a/core/src/num/flt2dec/mod.rs +++ b/core/src/num/flt2dec/mod.rs @@ -123,7 +123,6 @@ functions. )] pub use self::decoder::{decode, DecodableFloat, Decoded, FullDecoded}; - use super::fmt::{Formatted, Part}; use crate::mem::MaybeUninit; diff --git a/core/src/num/flt2dec/strategy/dragon.rs b/core/src/num/flt2dec/strategy/dragon.rs index 71b14d0ae3f4c..751edd3c79383 100644 --- a/core/src/num/flt2dec/strategy/dragon.rs +++ b/core/src/num/flt2dec/strategy/dragon.rs @@ -6,9 +6,7 @@ use crate::cmp::Ordering; use crate::mem::MaybeUninit; - -use crate::num::bignum::Big32x40 as Big; -use crate::num::bignum::Digit32 as Digit; +use crate::num::bignum::{Big32x40 as Big, Digit32 as Digit}; use crate::num::flt2dec::estimator::estimate_scaling_factor; use crate::num::flt2dec::{round_up, Decoded, MAX_SIG_DIGITS}; diff --git a/core/src/num/mod.rs b/core/src/num/mod.rs index e342a73d1aee4..309e1ba958aee 100644 --- a/core/src/num/mod.rs +++ b/core/src/num/mod.rs @@ -2,11 +2,9 @@ #![stable(feature = "rust1", since = "1.0.0")] -use crate::ascii; -use crate::intrinsics; -use crate::mem; use crate::str::FromStr; use crate::ub_checks::assert_unsafe_precondition; +use crate::{ascii, intrinsics, mem}; // Used because the `?` operator is not allowed in a const context. macro_rules! try_opt { @@ -48,39 +46,31 @@ mod overflow_panic; mod saturating; mod wrapping; -#[stable(feature = "saturating_int_impl", since = "1.74.0")] -pub use saturating::Saturating; -#[stable(feature = "rust1", since = "1.0.0")] -pub use wrapping::Wrapping; - #[stable(feature = "rust1", since = "1.0.0")] #[cfg(not(no_fp_fmt_parse))] pub use dec2flt::ParseFloatError; - +#[stable(feature = "int_error_matching", since = "1.55.0")] +pub use error::IntErrorKind; #[stable(feature = "rust1", since = "1.0.0")] pub use error::ParseIntError; - +#[stable(feature = "try_from", since = "1.34.0")] +pub use error::TryFromIntError; +#[stable(feature = "generic_nonzero", since = "1.79.0")] +pub use nonzero::NonZero; #[unstable( feature = "nonzero_internals", reason = "implementation detail which may disappear or be replaced at any time", issue = "none" )] pub use nonzero::ZeroablePrimitive; - -#[stable(feature = "generic_nonzero", since = "1.79.0")] -pub use nonzero::NonZero; - #[stable(feature = "signed_nonzero", since = "1.34.0")] pub use nonzero::{NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize}; - #[stable(feature = "nonzero", since = "1.28.0")] pub use nonzero::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; - -#[stable(feature = "try_from", since = "1.34.0")] -pub use error::TryFromIntError; - -#[stable(feature = "int_error_matching", since = "1.55.0")] -pub use error::IntErrorKind; +#[stable(feature = "saturating_int_impl", since = "1.74.0")] +pub use saturating::Saturating; +#[stable(feature = "rust1", since = "1.0.0")] +pub use wrapping::Wrapping; macro_rules! usize_isize_to_xe_bytes_doc { () => { diff --git a/core/src/num/nonzero.rs b/core/src/num/nonzero.rs index 64985e216c451..c6e9c249048a7 100644 --- a/core/src/num/nonzero.rs +++ b/core/src/num/nonzero.rs @@ -1,18 +1,13 @@ //! Definitions of integer that is known not to equal zero. +use super::{IntErrorKind, ParseIntError}; use crate::cmp::Ordering; -use crate::fmt; use crate::hash::{Hash, Hasher}; -use crate::hint; -use crate::intrinsics; use crate::marker::{Freeze, StructuralPartialEq}; use crate::ops::{BitOr, BitOrAssign, Div, DivAssign, Neg, Rem, RemAssign}; use crate::panic::{RefUnwindSafe, UnwindSafe}; -use crate::ptr; use crate::str::FromStr; -use crate::ub_checks; - -use super::{IntErrorKind, ParseIntError}; +use crate::{fmt, hint, intrinsics, ptr, ub_checks}; /// A marker trait for primitive types which can be zero. /// diff --git a/core/src/num/saturating.rs b/core/src/num/saturating.rs index d040539ebe556..3f4791e163e69 100644 --- a/core/src/num/saturating.rs +++ b/core/src/num/saturating.rs @@ -1,10 +1,10 @@ //! Definitions of `Saturating`. use crate::fmt; -use crate::ops::{Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign}; -use crate::ops::{BitXor, BitXorAssign, Div, DivAssign}; -use crate::ops::{Mul, MulAssign, Neg, Not, Rem, RemAssign}; -use crate::ops::{Sub, SubAssign}; +use crate::ops::{ + Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign, + Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign, +}; /// Provides intentionally-saturating arithmetic on `T`. /// diff --git a/core/src/num/wrapping.rs b/core/src/num/wrapping.rs index 16f0b6d913dfb..1ac6d3161c2f9 100644 --- a/core/src/num/wrapping.rs +++ b/core/src/num/wrapping.rs @@ -1,10 +1,10 @@ //! Definitions of `Wrapping`. use crate::fmt; -use crate::ops::{Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign}; -use crate::ops::{BitXor, BitXorAssign, Div, DivAssign}; -use crate::ops::{Mul, MulAssign, Neg, Not, Rem, RemAssign}; -use crate::ops::{Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign}; +use crate::ops::{ + Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign, + Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign, +}; /// Provides intentionally-wrapped arithmetic on `T`. /// diff --git a/core/src/ops/mod.rs b/core/src/ops/mod.rs index 7bcfaadbe372b..98d41b71e8eb8 100644 --- a/core/src/ops/mod.rs +++ b/core/src/ops/mod.rs @@ -156,65 +156,44 @@ mod unsize; pub use self::arith::{Add, Div, Mul, Neg, Rem, Sub}; #[stable(feature = "op_assign_traits", since = "1.8.0")] pub use self::arith::{AddAssign, DivAssign, MulAssign, RemAssign, SubAssign}; - +#[unstable(feature = "async_fn_traits", issue = "none")] +pub use self::async_function::{AsyncFn, AsyncFnMut, AsyncFnOnce}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::bit::{BitAnd, BitOr, BitXor, Not, Shl, Shr}; #[stable(feature = "op_assign_traits", since = "1.8.0")] pub use self::bit::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign}; - -#[stable(feature = "rust1", since = "1.0.0")] -pub use self::deref::{Deref, DerefMut}; - +#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")] +pub use self::control_flow::ControlFlow; +#[unstable(feature = "coroutine_trait", issue = "43122")] +pub use self::coroutine::{Coroutine, CoroutineState}; #[unstable(feature = "deref_pure_trait", issue = "87121")] pub use self::deref::DerefPure; - #[unstable(feature = "receiver_trait", issue = "none")] pub use self::deref::Receiver; - #[stable(feature = "rust1", since = "1.0.0")] -pub use self::drop::Drop; - +pub use self::deref::{Deref, DerefMut}; pub(crate) use self::drop::fallback_surface_drop; - +#[stable(feature = "rust1", since = "1.0.0")] +pub use self::drop::Drop; #[stable(feature = "rust1", since = "1.0.0")] pub use self::function::{Fn, FnMut, FnOnce}; - -#[unstable(feature = "async_fn_traits", issue = "none")] -pub use self::async_function::{AsyncFn, AsyncFnMut, AsyncFnOnce}; - #[stable(feature = "rust1", since = "1.0.0")] pub use self::index::{Index, IndexMut}; - -#[stable(feature = "rust1", since = "1.0.0")] -pub use self::range::{Range, RangeFrom, RangeFull, RangeTo}; - pub(crate) use self::index_range::IndexRange; - -#[stable(feature = "inclusive_range", since = "1.26.0")] -pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive}; - #[unstable(feature = "one_sided_range", issue = "69780")] pub use self::range::OneSidedRange; - -#[unstable(feature = "try_trait_v2", issue = "84277")] -pub use self::try_trait::{FromResidual, Try}; - -#[unstable(feature = "try_trait_v2_yeet", issue = "96374")] -pub use self::try_trait::Yeet; - +#[stable(feature = "inclusive_range", since = "1.26.0")] +pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive}; +#[stable(feature = "rust1", since = "1.0.0")] +pub use self::range::{Range, RangeFrom, RangeFull, RangeTo}; #[unstable(feature = "try_trait_v2_residual", issue = "91285")] pub use self::try_trait::Residual; - +#[unstable(feature = "try_trait_v2_yeet", issue = "96374")] +pub use self::try_trait::Yeet; pub(crate) use self::try_trait::{ChangeOutputType, NeverShortCircuit}; - -#[unstable(feature = "coroutine_trait", issue = "43122")] -pub use self::coroutine::{Coroutine, CoroutineState}; - +#[unstable(feature = "try_trait_v2", issue = "84277")] +pub use self::try_trait::{FromResidual, Try}; #[unstable(feature = "coerce_unsized", issue = "18598")] pub use self::unsize::CoerceUnsized; - #[unstable(feature = "dispatch_from_dyn", issue = "none")] pub use self::unsize::DispatchFromDyn; - -#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")] -pub use self::control_flow::ControlFlow; diff --git a/core/src/option.rs b/core/src/option.rs index d93cb8d10e607..6c89c81018038 100644 --- a/core/src/option.rs +++ b/core/src/option.rs @@ -557,13 +557,10 @@ #![stable(feature = "rust1", since = "1.0.0")] use crate::iter::{self, FusedIterator, TrustedLen}; +use crate::ops::{self, ControlFlow, Deref, DerefMut}; use crate::panicking::{panic, panic_display}; use crate::pin::Pin; -use crate::{ - cmp, convert, hint, mem, - ops::{self, ControlFlow, Deref, DerefMut}, - slice, -}; +use crate::{cmp, convert, hint, mem, slice}; /// The `Option` type. See [the module level documentation](self) for more. #[derive(Copy, Eq, Debug, Hash)] diff --git a/core/src/panic.rs b/core/src/panic.rs index 03123450f766e..8e641e515fb75 100644 --- a/core/src/panic.rs +++ b/core/src/panic.rs @@ -6,8 +6,6 @@ mod location; mod panic_info; mod unwind_safe; -use crate::any::Any; - #[stable(feature = "panic_hooks", since = "1.10.0")] pub use self::location::Location; #[stable(feature = "panic_hooks", since = "1.10.0")] @@ -16,6 +14,7 @@ pub use self::panic_info::PanicInfo; pub use self::panic_info::PanicMessage; #[stable(feature = "catch_unwind", since = "1.9.0")] pub use self::unwind_safe::{AssertUnwindSafe, RefUnwindSafe, UnwindSafe}; +use crate::any::Any; #[doc(hidden)] #[unstable(feature = "edition_panic", issue = "none", reason = "use panic!() instead")] diff --git a/core/src/pin.rs b/core/src/pin.rs index 18e1f753defae..d752151d10cc8 100644 --- a/core/src/pin.rs +++ b/core/src/pin.rs @@ -920,11 +920,8 @@ #![stable(feature = "pin", since = "1.33.0")] -use crate::cmp; -use crate::fmt; use crate::hash::{Hash, Hasher}; use crate::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver}; - #[allow(unused_imports)] use crate::{ cell::{RefCell, UnsafeCell}, @@ -932,6 +929,7 @@ use crate::{ marker::PhantomPinned, mem, ptr, }; +use crate::{cmp, fmt}; /// A pointer which pins its pointee in place. /// diff --git a/core/src/ptr/metadata.rs b/core/src/ptr/metadata.rs index 84accc3e466d5..ccc9f8754f00c 100644 --- a/core/src/ptr/metadata.rs +++ b/core/src/ptr/metadata.rs @@ -2,8 +2,7 @@ use crate::fmt; use crate::hash::{Hash, Hasher}; -use crate::intrinsics::aggregate_raw_ptr; -use crate::intrinsics::ptr_metadata; +use crate::intrinsics::{aggregate_raw_ptr, ptr_metadata}; use crate::marker::Freeze; use crate::ptr::NonNull; diff --git a/core/src/ptr/mod.rs b/core/src/ptr/mod.rs index da6b541a98700..9921f5d70c048 100644 --- a/core/src/ptr/mod.rs +++ b/core/src/ptr/mod.rs @@ -409,13 +409,9 @@ #![allow(clippy::not_unsafe_ptr_arg_deref)] use crate::cmp::Ordering; -use crate::fmt; -use crate::hash; -use crate::intrinsics; use crate::marker::FnPtr; -use crate::ub_checks; - use crate::mem::{self, MaybeUninit}; +use crate::{fmt, hash, intrinsics, ub_checks}; mod alignment; #[unstable(feature = "ptr_alignment_type", issue = "102070")] @@ -423,12 +419,10 @@ pub use alignment::Alignment; #[stable(feature = "rust1", since = "1.0.0")] #[doc(inline)] -pub use crate::intrinsics::copy_nonoverlapping; - +pub use crate::intrinsics::copy; #[stable(feature = "rust1", since = "1.0.0")] #[doc(inline)] -pub use crate::intrinsics::copy; - +pub use crate::intrinsics::copy_nonoverlapping; #[stable(feature = "rust1", since = "1.0.0")] #[doc(inline)] pub use crate::intrinsics::write_bytes; diff --git a/core/src/ptr/non_null.rs b/core/src/ptr/non_null.rs index 796c85d0cacc7..4a716a7503964 100644 --- a/core/src/ptr/non_null.rs +++ b/core/src/ptr/non_null.rs @@ -1,15 +1,12 @@ use crate::cmp::Ordering; -use crate::fmt; -use crate::hash; -use crate::intrinsics; use crate::marker::Unsize; use crate::mem::{MaybeUninit, SizedTypeProperties}; use crate::num::NonZero; use crate::ops::{CoerceUnsized, DispatchFromDyn}; -use crate::ptr; use crate::ptr::Unique; use crate::slice::{self, SliceIndex}; use crate::ub_checks::assert_unsafe_precondition; +use crate::{fmt, hash, intrinsics, ptr}; /// `*mut T` but non-zero and [covariant]. /// diff --git a/core/src/range.rs b/core/src/range.rs index 93400e9b9f071..408972c267f1a 100644 --- a/core/src/range.rs +++ b/core/src/range.rs @@ -25,15 +25,13 @@ mod iter; pub mod legacy; #[doc(inline)] -pub use crate::ops::{Bound, OneSidedRange, RangeBounds, RangeFull, RangeTo, RangeToInclusive}; - +pub use iter::{IterRange, IterRangeFrom, IterRangeInclusive}; use Bound::{Excluded, Included, Unbounded}; #[doc(inline)] pub use crate::iter::Step; - #[doc(inline)] -pub use iter::{IterRange, IterRangeFrom, IterRangeInclusive}; +pub use crate::ops::{Bound, OneSidedRange, RangeBounds, RangeFull, RangeTo, RangeToInclusive}; /// A (half-open) range bounded inclusively below and exclusively above /// (`start..end` in a future edition). diff --git a/core/src/range/iter.rs b/core/src/range/iter.rs index 2b7db475ffb2c..4935280df60bc 100644 --- a/core/src/range/iter.rs +++ b/core/src/range/iter.rs @@ -1,9 +1,8 @@ -use crate::num::NonZero; -use crate::range::{legacy, Range, RangeFrom, RangeInclusive}; - use crate::iter::{ FusedIterator, Step, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, TrustedStep, }; +use crate::num::NonZero; +use crate::range::{legacy, Range, RangeFrom, RangeInclusive}; /// By-value [`Range`] iterator. #[unstable(feature = "new_range_api", issue = "125687")] diff --git a/core/src/slice/ascii.rs b/core/src/slice/ascii.rs index bf444d2f68af8..d1ea52fab6b87 100644 --- a/core/src/slice/ascii.rs +++ b/core/src/slice/ascii.rs @@ -1,12 +1,10 @@ //! Operations on ASCII `[u8]`. -use crate::ascii; -use crate::fmt::{self, Write}; -use crate::iter; -use crate::mem; -use crate::ops; use core::ascii::EscapeDefault; +use crate::fmt::{self, Write}; +use crate::{ascii, iter, mem, ops}; + #[cfg(not(test))] impl [u8] { /// Checks if all bytes in this slice are within the ASCII range. diff --git a/core/src/slice/cmp.rs b/core/src/slice/cmp.rs index 5bee4d551352e..d19d0eae16671 100644 --- a/core/src/slice/cmp.rs +++ b/core/src/slice/cmp.rs @@ -1,12 +1,10 @@ //! Comparison traits for `[T]`. +use super::{from_raw_parts, memchr}; use crate::cmp::{self, BytewiseEq, Ordering}; use crate::intrinsics::compare_bytes; use crate::mem; -use super::from_raw_parts; -use super::memchr; - #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq<[U]> for [T] where diff --git a/core/src/slice/index.rs b/core/src/slice/index.rs index 1591aaf52e592..de1492e82ce7d 100644 --- a/core/src/slice/index.rs +++ b/core/src/slice/index.rs @@ -1,9 +1,8 @@ //! Indexing implementations for `[T]`. use crate::intrinsics::const_eval_select; -use crate::ops; -use crate::range; use crate::ub_checks::assert_unsafe_precondition; +use crate::{ops, range}; #[stable(feature = "rust1", since = "1.0.0")] impl ops::Index for [T] diff --git a/core/src/slice/iter.rs b/core/src/slice/iter.rs index 504676ce187a8..62b170a87d445 100644 --- a/core/src/slice/iter.rs +++ b/core/src/slice/iter.rs @@ -3,8 +3,7 @@ #[macro_use] // import iterator! and forward_iterator! mod macros; -use crate::cmp; -use crate::fmt; +use super::{from_raw_parts, from_raw_parts_mut}; use crate::hint::assert_unchecked; use crate::iter::{ FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, UncheckedIterator, @@ -13,8 +12,7 @@ use crate::marker::PhantomData; use crate::mem::{self, SizedTypeProperties}; use crate::num::NonZero; use crate::ptr::{self, without_provenance, without_provenance_mut, NonNull}; - -use super::{from_raw_parts, from_raw_parts_mut}; +use crate::{cmp, fmt}; #[stable(feature = "boxed_slice_into_iter", since = "1.80.0")] impl !Iterator for [T] {} diff --git a/core/src/slice/mod.rs b/core/src/slice/mod.rs index 5f75e1944122d..64edaa2f034a1 100644 --- a/core/src/slice/mod.rs +++ b/core/src/slice/mod.rs @@ -7,16 +7,13 @@ #![stable(feature = "rust1", since = "1.0.0")] use crate::cmp::Ordering::{self, Equal, Greater, Less}; -use crate::fmt; -use crate::hint; use crate::intrinsics::{exact_div, unchecked_sub}; use crate::mem::{self, SizedTypeProperties}; use crate::num::NonZero; use crate::ops::{Bound, OneSidedRange, Range, RangeBounds}; -use crate::ptr; use crate::simd::{self, Simd}; -use crate::slice; use crate::ub_checks::assert_unsafe_precondition; +use crate::{fmt, hint, ptr, slice}; #[unstable( feature = "slice_internals", @@ -44,52 +41,38 @@ mod specialize; #[unstable(feature = "str_internals", issue = "none")] #[doc(hidden)] pub use ascii::is_ascii_simple; - +#[stable(feature = "inherent_ascii_escape", since = "1.60.0")] +pub use ascii::EscapeAscii; +#[stable(feature = "slice_get_slice", since = "1.28.0")] +pub use index::SliceIndex; +#[unstable(feature = "slice_range", issue = "76393")] +pub use index::{range, try_range}; +#[unstable(feature = "array_windows", issue = "75027")] +pub use iter::ArrayWindows; +#[unstable(feature = "array_chunks", issue = "74985")] +pub use iter::{ArrayChunks, ArrayChunksMut}; +#[stable(feature = "slice_group_by", since = "1.77.0")] +pub use iter::{ChunkBy, ChunkByMut}; #[stable(feature = "rust1", since = "1.0.0")] pub use iter::{Chunks, ChunksMut, Windows}; -#[stable(feature = "rust1", since = "1.0.0")] -pub use iter::{Iter, IterMut}; -#[stable(feature = "rust1", since = "1.0.0")] -pub use iter::{RSplitN, RSplitNMut, Split, SplitMut, SplitN, SplitNMut}; - -#[stable(feature = "slice_rsplit", since = "1.27.0")] -pub use iter::{RSplit, RSplitMut}; - #[stable(feature = "chunks_exact", since = "1.31.0")] pub use iter::{ChunksExact, ChunksExactMut}; - +#[stable(feature = "rust1", since = "1.0.0")] +pub use iter::{Iter, IterMut}; #[stable(feature = "rchunks", since = "1.31.0")] pub use iter::{RChunks, RChunksExact, RChunksExactMut, RChunksMut}; - -#[unstable(feature = "array_chunks", issue = "74985")] -pub use iter::{ArrayChunks, ArrayChunksMut}; - -#[unstable(feature = "array_windows", issue = "75027")] -pub use iter::ArrayWindows; - -#[stable(feature = "slice_group_by", since = "1.77.0")] -pub use iter::{ChunkBy, ChunkByMut}; - +#[stable(feature = "slice_rsplit", since = "1.27.0")] +pub use iter::{RSplit, RSplitMut}; +#[stable(feature = "rust1", since = "1.0.0")] +pub use iter::{RSplitN, RSplitNMut, Split, SplitMut, SplitN, SplitNMut}; #[stable(feature = "split_inclusive", since = "1.51.0")] pub use iter::{SplitInclusive, SplitInclusiveMut}; - -#[stable(feature = "rust1", since = "1.0.0")] -pub use raw::{from_raw_parts, from_raw_parts_mut}; - #[stable(feature = "from_ref", since = "1.28.0")] pub use raw::{from_mut, from_ref}; - #[unstable(feature = "slice_from_ptr_range", issue = "89792")] pub use raw::{from_mut_ptr_range, from_ptr_range}; - -#[stable(feature = "slice_get_slice", since = "1.28.0")] -pub use index::SliceIndex; - -#[unstable(feature = "slice_range", issue = "76393")] -pub use index::{range, try_range}; - -#[stable(feature = "inherent_ascii_escape", since = "1.60.0")] -pub use ascii::EscapeAscii; +#[stable(feature = "rust1", since = "1.0.0")] +pub use raw::{from_raw_parts, from_raw_parts_mut}; /// Calculates the direction and split point of a one-sided range. /// diff --git a/core/src/slice/raw.rs b/core/src/slice/raw.rs index 280aead270e76..85507eb8a7381 100644 --- a/core/src/slice/raw.rs +++ b/core/src/slice/raw.rs @@ -1,9 +1,7 @@ //! Free functions to create `&[T]` and `&mut [T]`. -use crate::array; use crate::ops::Range; -use crate::ptr; -use crate::ub_checks; +use crate::{array, ptr, ub_checks}; /// Forms a slice from a pointer and a length. /// diff --git a/core/src/slice/rotate.rs b/core/src/slice/rotate.rs index 1d7b86339799b..1e4865a7caad9 100644 --- a/core/src/slice/rotate.rs +++ b/core/src/slice/rotate.rs @@ -1,6 +1,5 @@ -use crate::cmp; use crate::mem::{self, MaybeUninit, SizedTypeProperties}; -use crate::ptr; +use crate::{cmp, ptr}; /// Rotates the range `[mid-left, mid+right)` such that the element at `mid` becomes the first /// element. Equivalently, rotates the range `left` elements to the left or `right` elements to the diff --git a/core/src/slice/sort/select.rs b/core/src/slice/sort/select.rs index efda993a10353..f6529f23bcb3f 100644 --- a/core/src/slice/sort/select.rs +++ b/core/src/slice/sort/select.rs @@ -7,7 +7,6 @@ //! better performance than one would get using heapsort as fallback. use crate::mem::{self, SizedTypeProperties}; - use crate::slice::sort::shared::pivot::choose_pivot; use crate::slice::sort::shared::smallsort::insertion_sort_shift_left; use crate::slice::sort::unstable::quicksort::partition; diff --git a/core/src/slice/sort/shared/smallsort.rs b/core/src/slice/sort/shared/smallsort.rs index 5111ed8756bf1..5064c5a0ae55a 100644 --- a/core/src/slice/sort/shared/smallsort.rs +++ b/core/src/slice/sort/shared/smallsort.rs @@ -1,11 +1,8 @@ //! This module contains a variety of sort implementations that are optimized for small lengths. -use crate::intrinsics; use crate::mem::{self, ManuallyDrop, MaybeUninit}; -use crate::ptr; -use crate::slice; - use crate::slice::sort::shared::FreezeMarker; +use crate::{intrinsics, ptr, slice}; // It's important to differentiate between SMALL_SORT_THRESHOLD performance for // small slices and small-sort performance sorting small sub-slices as part of diff --git a/core/src/slice/sort/stable/drift.rs b/core/src/slice/sort/stable/drift.rs index 73dc40cafcf83..644e75a4581e9 100644 --- a/core/src/slice/sort/stable/drift.rs +++ b/core/src/slice/sort/stable/drift.rs @@ -1,14 +1,12 @@ //! This module contains the hybrid top-level loop combining bottom-up Mergesort with top-down //! Quicksort. -use crate::cmp; -use crate::intrinsics; use crate::mem::MaybeUninit; - use crate::slice::sort::shared::find_existing_run; use crate::slice::sort::shared::smallsort::StableSmallSortTypeImpl; use crate::slice::sort::stable::merge::merge; use crate::slice::sort::stable::quicksort::quicksort; +use crate::{cmp, intrinsics}; /// Sorts `v` based on comparison function `is_less`. If `eager_sort` is true, /// it will only do small-sorts and physical merges, ensuring O(N * log(N)) diff --git a/core/src/slice/sort/stable/merge.rs b/core/src/slice/sort/stable/merge.rs index 6739e114b130a..0cb21740795b7 100644 --- a/core/src/slice/sort/stable/merge.rs +++ b/core/src/slice/sort/stable/merge.rs @@ -1,8 +1,7 @@ //! This module contains logic for performing a merge of two sorted sub-slices. -use crate::cmp; use crate::mem::MaybeUninit; -use crate::ptr; +use crate::{cmp, ptr}; /// Merges non-decreasing runs `v[..mid]` and `v[mid..]` using `scratch` as /// temporary storage, and stores the result into `v[..]`. diff --git a/core/src/slice/sort/stable/mod.rs b/core/src/slice/sort/stable/mod.rs index 18f7b2ac54af5..a383b0f589ccf 100644 --- a/core/src/slice/sort/stable/mod.rs +++ b/core/src/slice/sort/stable/mod.rs @@ -1,12 +1,10 @@ //! This module contains the entry points for `slice::sort`. -use crate::cmp; -use crate::intrinsics; use crate::mem::{self, MaybeUninit, SizedTypeProperties}; - use crate::slice::sort::shared::smallsort::{ insertion_sort_shift_left, StableSmallSortTypeImpl, SMALL_SORT_GENERAL_SCRATCH_LEN, }; +use crate::{cmp, intrinsics}; pub(crate) mod drift; pub(crate) mod merge; diff --git a/core/src/slice/sort/stable/quicksort.rs b/core/src/slice/sort/stable/quicksort.rs index 164314991d0f3..3319d67ab52fa 100644 --- a/core/src/slice/sort/stable/quicksort.rs +++ b/core/src/slice/sort/stable/quicksort.rs @@ -1,12 +1,10 @@ //! This module contains a stable quicksort and partition implementation. -use crate::intrinsics; use crate::mem::{self, ManuallyDrop, MaybeUninit}; -use crate::ptr; - use crate::slice::sort::shared::pivot::choose_pivot; use crate::slice::sort::shared::smallsort::StableSmallSortTypeImpl; use crate::slice::sort::shared::FreezeMarker; +use crate::{intrinsics, ptr}; /// Sorts `v` recursively using quicksort. /// diff --git a/core/src/slice/sort/unstable/heapsort.rs b/core/src/slice/sort/unstable/heapsort.rs index 559605ef4b6b3..27e2ad588ea09 100644 --- a/core/src/slice/sort/unstable/heapsort.rs +++ b/core/src/slice/sort/unstable/heapsort.rs @@ -1,7 +1,6 @@ //! This module contains a branchless heapsort as fallback for unstable quicksort. -use crate::intrinsics; -use crate::ptr; +use crate::{intrinsics, ptr}; /// Sorts `v` using heapsort, which guarantees *O*(*n* \* log(*n*)) worst-case. /// diff --git a/core/src/slice/sort/unstable/mod.rs b/core/src/slice/sort/unstable/mod.rs index 692c2d8f7c7ba..ed735e1ebfbc0 100644 --- a/core/src/slice/sort/unstable/mod.rs +++ b/core/src/slice/sort/unstable/mod.rs @@ -2,7 +2,6 @@ use crate::intrinsics; use crate::mem::SizedTypeProperties; - use crate::slice::sort::shared::find_existing_run; use crate::slice::sort::shared::smallsort::insertion_sort_shift_left; diff --git a/core/src/slice/sort/unstable/quicksort.rs b/core/src/slice/sort/unstable/quicksort.rs index 533b5b0eec767..cd53656e9b4b8 100644 --- a/core/src/slice/sort/unstable/quicksort.rs +++ b/core/src/slice/sort/unstable/quicksort.rs @@ -1,11 +1,9 @@ //! This module contains an unstable quicksort and two partition implementations. -use crate::intrinsics; use crate::mem::{self, ManuallyDrop}; -use crate::ptr; - use crate::slice::sort::shared::pivot::choose_pivot; use crate::slice::sort::shared::smallsort::UnstableSmallSortTypeImpl; +use crate::{intrinsics, ptr}; /// Sorts `v` recursively. /// diff --git a/core/src/str/converts.rs b/core/src/str/converts.rs index b35216eee7b7f..1956a04829d1d 100644 --- a/core/src/str/converts.rs +++ b/core/src/str/converts.rs @@ -1,9 +1,8 @@ //! Ways to create a `str` from bytes slice. -use crate::{mem, ptr}; - use super::validations::run_utf8_validation; use super::Utf8Error; +use crate::{mem, ptr}; /// Converts a slice of bytes to a string slice. /// diff --git a/core/src/str/iter.rs b/core/src/str/iter.rs index 5845e3b5481ad..06f796f9f3ad8 100644 --- a/core/src/str/iter.rs +++ b/core/src/str/iter.rs @@ -1,23 +1,20 @@ //! Iterators for `str` methods. -use crate::char as char_mod; +use super::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher}; +use super::validations::{next_code_point, next_code_point_reverse}; +use super::{ + from_utf8_unchecked, BytesIsNotEmpty, CharEscapeDebugContinue, CharEscapeDefault, + CharEscapeUnicode, IsAsciiWhitespace, IsNotEmpty, IsWhitespace, LinesMap, UnsafeBytesToStr, +}; use crate::fmt::{self, Write}; -use crate::iter::{Chain, FlatMap, Flatten}; -use crate::iter::{Copied, Filter, FusedIterator, Map, TrustedLen}; -use crate::iter::{TrustedRandomAccess, TrustedRandomAccessNoCoerce}; +use crate::iter::{ + Chain, Copied, Filter, FlatMap, Flatten, FusedIterator, Map, TrustedLen, TrustedRandomAccess, + TrustedRandomAccessNoCoerce, +}; use crate::num::NonZero; use crate::ops::Try; -use crate::option; use crate::slice::{self, Split as SliceSplit}; - -use super::from_utf8_unchecked; -use super::pattern::Pattern; -use super::pattern::{DoubleEndedSearcher, ReverseSearcher, Searcher}; -use super::validations::{next_code_point, next_code_point_reverse}; -use super::LinesMap; -use super::{BytesIsNotEmpty, UnsafeBytesToStr}; -use super::{CharEscapeDebugContinue, CharEscapeDefault, CharEscapeUnicode}; -use super::{IsAsciiWhitespace, IsNotEmpty, IsWhitespace}; +use crate::{char as char_mod, option}; /// An iterator over the [`char`]s of a string slice. /// diff --git a/core/src/str/lossy.rs b/core/src/str/lossy.rs index 51a0777c2d613..3f31107acf050 100644 --- a/core/src/str/lossy.rs +++ b/core/src/str/lossy.rs @@ -1,10 +1,8 @@ -use crate::fmt; -use crate::fmt::Formatter; -use crate::fmt::Write; -use crate::iter::FusedIterator; - use super::from_utf8_unchecked; use super::validations::utf8_char_width; +use crate::fmt; +use crate::fmt::{Formatter, Write}; +use crate::iter::FusedIterator; impl [u8] { /// Creates an iterator over the contiguous valid UTF-8 ranges of this diff --git a/core/src/str/mod.rs b/core/src/str/mod.rs index d861fb2075f53..56517348dc7d2 100644 --- a/core/src/str/mod.rs +++ b/core/src/str/mod.rs @@ -13,74 +13,52 @@ mod iter; mod traits; mod validations; -use self::pattern::Pattern; -use self::pattern::{DoubleEndedSearcher, ReverseSearcher, Searcher}; - -use crate::ascii; +use self::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher}; use crate::char::{self, EscapeDebugExtArgs}; -use crate::mem; use crate::ops::Range; use crate::slice::{self, SliceIndex}; +use crate::{ascii, mem}; pub mod pattern; mod lossy; -#[stable(feature = "utf8_chunks", since = "1.79.0")] -pub use lossy::{Utf8Chunk, Utf8Chunks}; - +#[unstable(feature = "str_from_raw_parts", issue = "119206")] +pub use converts::{from_raw_parts, from_raw_parts_mut}; #[stable(feature = "rust1", since = "1.0.0")] pub use converts::{from_utf8, from_utf8_unchecked}; - #[stable(feature = "str_mut_extras", since = "1.20.0")] pub use converts::{from_utf8_mut, from_utf8_unchecked_mut}; - -#[unstable(feature = "str_from_raw_parts", issue = "119206")] -pub use converts::{from_raw_parts, from_raw_parts_mut}; - #[stable(feature = "rust1", since = "1.0.0")] pub use error::{ParseBoolError, Utf8Error}; - -#[stable(feature = "rust1", since = "1.0.0")] -pub use traits::FromStr; - -#[stable(feature = "rust1", since = "1.0.0")] -pub use iter::{Bytes, CharIndices, Chars, Lines, SplitWhitespace}; - +#[stable(feature = "encode_utf16", since = "1.8.0")] +pub use iter::EncodeUtf16; #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)] pub use iter::LinesAny; - -#[stable(feature = "rust1", since = "1.0.0")] -pub use iter::{RSplit, RSplitTerminator, Split, SplitTerminator}; - -#[stable(feature = "rust1", since = "1.0.0")] -pub use iter::{RSplitN, SplitN}; - -#[stable(feature = "str_matches", since = "1.2.0")] -pub use iter::{Matches, RMatches}; - -#[stable(feature = "str_match_indices", since = "1.5.0")] -pub use iter::{MatchIndices, RMatchIndices}; - -#[stable(feature = "encode_utf16", since = "1.8.0")] -pub use iter::EncodeUtf16; - -#[stable(feature = "str_escape", since = "1.34.0")] -pub use iter::{EscapeDebug, EscapeDefault, EscapeUnicode}; - #[stable(feature = "split_ascii_whitespace", since = "1.34.0")] pub use iter::SplitAsciiWhitespace; - #[stable(feature = "split_inclusive", since = "1.51.0")] pub use iter::SplitInclusive; - +#[stable(feature = "rust1", since = "1.0.0")] +pub use iter::{Bytes, CharIndices, Chars, Lines, SplitWhitespace}; +#[stable(feature = "str_escape", since = "1.34.0")] +pub use iter::{EscapeDebug, EscapeDefault, EscapeUnicode}; +#[stable(feature = "str_match_indices", since = "1.5.0")] +pub use iter::{MatchIndices, RMatchIndices}; +use iter::{MatchIndicesInternal, MatchesInternal, SplitInternal, SplitNInternal}; +#[stable(feature = "str_matches", since = "1.2.0")] +pub use iter::{Matches, RMatches}; +#[stable(feature = "rust1", since = "1.0.0")] +pub use iter::{RSplit, RSplitTerminator, Split, SplitTerminator}; +#[stable(feature = "rust1", since = "1.0.0")] +pub use iter::{RSplitN, SplitN}; +#[stable(feature = "utf8_chunks", since = "1.79.0")] +pub use lossy::{Utf8Chunk, Utf8Chunks}; +#[stable(feature = "rust1", since = "1.0.0")] +pub use traits::FromStr; #[unstable(feature = "str_internals", issue = "none")] pub use validations::{next_code_point, utf8_char_width}; -use iter::MatchIndicesInternal; -use iter::SplitInternal; -use iter::{MatchesInternal, SplitNInternal}; - #[inline(never)] #[cold] #[track_caller] diff --git a/core/src/str/pattern.rs b/core/src/str/pattern.rs index 33a5d45e445d7..2f1096db8f00c 100644 --- a/core/src/str/pattern.rs +++ b/core/src/str/pattern.rs @@ -38,11 +38,10 @@ issue = "27721" )] -use crate::cmp; use crate::cmp::Ordering; use crate::convert::TryInto as _; -use crate::fmt; use crate::slice::memchr; +use crate::{cmp, fmt}; // Pattern @@ -1759,8 +1758,7 @@ fn simd_contains(needle: &str, haystack: &str) -> Option { use crate::ops::BitAnd; use crate::simd::cmp::SimdPartialEq; - use crate::simd::mask8x16 as Mask; - use crate::simd::u8x16 as Block; + use crate::simd::{mask8x16 as Mask, u8x16 as Block}; let first_probe = needle[0]; let last_byte_offset = needle.len() - 1; diff --git a/core/src/str/traits.rs b/core/src/str/traits.rs index 3de5546c4d4e3..b69c476ae5e53 100644 --- a/core/src/str/traits.rs +++ b/core/src/str/traits.rs @@ -1,14 +1,11 @@ //! Trait implementations for `str`. +use super::ParseBoolError; use crate::cmp::Ordering; use crate::intrinsics::unchecked_sub; -use crate::ops; -use crate::ptr; -use crate::range; use crate::slice::SliceIndex; use crate::ub_checks::assert_unsafe_precondition; - -use super::ParseBoolError; +use crate::{ops, ptr, range}; /// Implements ordering of strings. /// diff --git a/core/src/str/validations.rs b/core/src/str/validations.rs index a11d7fee8af0c..cca8ff74dda8b 100644 --- a/core/src/str/validations.rs +++ b/core/src/str/validations.rs @@ -1,8 +1,7 @@ //! Operations related to UTF-8 validation. -use crate::mem; - use super::Utf8Error; +use crate::mem; /// Returns the initial codepoint accumulator for the first byte. /// The first byte is special, only want bottom 5 bits for width 2, 4 bits diff --git a/core/src/sync/atomic.rs b/core/src/sync/atomic.rs index 1769a6dc1012c..912f164bcbd14 100644 --- a/core/src/sync/atomic.rs +++ b/core/src/sync/atomic.rs @@ -223,12 +223,9 @@ #![allow(clippy::not_unsafe_ptr_arg_deref)] use self::Ordering::*; - use crate::cell::UnsafeCell; -use crate::fmt; -use crate::intrinsics; - use crate::hint::spin_loop; +use crate::{fmt, intrinsics}; // Some architectures don't have byte-sized atomics, which results in LLVM // emulating them using a LL/SC loop. However for AtomicBool we can take diff --git a/core/src/task/wake.rs b/core/src/task/wake.rs index 3342fedd926ff..8ce3eb2ea3921 100644 --- a/core/src/task/wake.rs +++ b/core/src/task/wake.rs @@ -1,11 +1,10 @@ #![stable(feature = "futures_api", since = "1.36.0")] use crate::any::Any; -use crate::fmt; use crate::marker::PhantomData; use crate::mem::{transmute, ManuallyDrop}; use crate::panic::AssertUnwindSafe; -use crate::ptr; +use crate::{fmt, ptr}; /// A `RawWaker` allows the implementor of a task executor to create a [`Waker`] /// or a [`LocalWaker`] which provides customized wakeup behavior. diff --git a/core/src/tuple.rs b/core/src/tuple.rs index bc376b13f64d9..65d4d5cf2ce41 100644 --- a/core/src/tuple.rs +++ b/core/src/tuple.rs @@ -1,9 +1,7 @@ // See core/src/primitive_docs.rs for documentation. use crate::cmp::Ordering::{self, *}; -use crate::marker::ConstParamTy_; -use crate::marker::StructuralPartialEq; -use crate::marker::UnsizedConstParamTy; +use crate::marker::{ConstParamTy_, StructuralPartialEq, UnsizedConstParamTy}; // Recursive macro for implementing n-ary tuple functions and operations // diff --git a/core/src/ub_checks.rs b/core/src/ub_checks.rs index cce0665b37d36..b65b48c162d9c 100644 --- a/core/src/ub_checks.rs +++ b/core/src/ub_checks.rs @@ -81,7 +81,6 @@ macro_rules! assert_unsafe_precondition { } #[unstable(feature = "ub_checks", issue = "none")] pub use assert_unsafe_precondition; - /// Checking library UB is always enabled when UB-checking is done /// (and we use a reexport so that there is no unnecessary wrapper function). #[unstable(feature = "ub_checks", issue = "none")] diff --git a/core/tests/array.rs b/core/tests/array.rs index e7773d138c255..b6d18f1ec3822 100644 --- a/core/tests/array.rs +++ b/core/tests/array.rs @@ -259,7 +259,8 @@ fn iterator_drops() { #[test] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn array_default_impl_avoids_leaks_on_panic() { - use core::sync::atomic::{AtomicUsize, Ordering::Relaxed}; + use core::sync::atomic::AtomicUsize; + use core::sync::atomic::Ordering::Relaxed; static COUNTER: AtomicUsize = AtomicUsize::new(0); #[derive(Debug)] struct Bomb(#[allow(dead_code)] usize); diff --git a/core/tests/clone.rs b/core/tests/clone.rs index 23efab2f1b598..b7130f16f8795 100644 --- a/core/tests/clone.rs +++ b/core/tests/clone.rs @@ -36,7 +36,8 @@ fn test_clone_to_uninit_slice_success() { #[test] #[cfg(panic = "unwind")] fn test_clone_to_uninit_slice_drops_on_panic() { - use core::sync::atomic::{AtomicUsize, Ordering::Relaxed}; + use core::sync::atomic::AtomicUsize; + use core::sync::atomic::Ordering::Relaxed; /// A static counter is OK to use as long as _this one test_ isn't run several times in /// multiple threads. diff --git a/core/tests/cmp.rs b/core/tests/cmp.rs index 72fdd490da152..6c4e2146f9148 100644 --- a/core/tests/cmp.rs +++ b/core/tests/cmp.rs @@ -1,7 +1,5 @@ -use core::cmp::{ - self, - Ordering::{self, *}, -}; +use core::cmp::Ordering::{self, *}; +use core::cmp::{self}; #[test] fn test_int_totalord() { diff --git a/core/tests/hash/sip.rs b/core/tests/hash/sip.rs index 0a67c485c98bb..f79954f916b77 100644 --- a/core/tests/hash/sip.rs +++ b/core/tests/hash/sip.rs @@ -1,7 +1,6 @@ #![allow(deprecated)] -use core::hash::{Hash, Hasher}; -use core::hash::{SipHasher, SipHasher13}; +use core::hash::{Hash, Hasher, SipHasher, SipHasher13}; use core::{mem, slice}; // Hash just the bytes of the slice, without length prefix diff --git a/core/tests/iter/adapters/chain.rs b/core/tests/iter/adapters/chain.rs index c93510df524cf..1b2c026ee1eb4 100644 --- a/core/tests/iter/adapters/chain.rs +++ b/core/tests/iter/adapters/chain.rs @@ -1,7 +1,8 @@ -use super::*; use core::iter::*; use core::num::NonZero; +use super::*; + #[test] fn test_chain() { let xs = [0, 1, 2, 3, 4, 5]; diff --git a/core/tests/iter/adapters/flatten.rs b/core/tests/iter/adapters/flatten.rs index 1f953f2aa0110..66b7b6cb563e9 100644 --- a/core/tests/iter/adapters/flatten.rs +++ b/core/tests/iter/adapters/flatten.rs @@ -1,8 +1,9 @@ -use super::*; use core::assert_eq; use core::iter::*; use core::num::NonZero; +use super::*; + #[test] fn test_iterator_flatten() { let xs = [0, 3, 6]; diff --git a/core/tests/iter/adapters/map_windows.rs b/core/tests/iter/adapters/map_windows.rs index 6744eff3fa26f..01cebc9b27fd8 100644 --- a/core/tests/iter/adapters/map_windows.rs +++ b/core/tests/iter/adapters/map_windows.rs @@ -1,10 +1,12 @@ -use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::SeqCst; #[cfg(not(panic = "abort"))] mod drop_checks { //! These tests mainly make sure the elements are correctly dropped. - use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst}; + use std::sync::atomic::Ordering::SeqCst; + use std::sync::atomic::{AtomicBool, AtomicUsize}; #[derive(Debug)] struct DropInfo { diff --git a/core/tests/iter/adapters/peekable.rs b/core/tests/iter/adapters/peekable.rs index c1a1c29b609b7..7f4341b8902c8 100644 --- a/core/tests/iter/adapters/peekable.rs +++ b/core/tests/iter/adapters/peekable.rs @@ -1,6 +1,7 @@ -use super::*; use core::iter::*; +use super::*; + #[test] fn test_iterator_peekable() { let xs = vec![0, 1, 2, 3, 4, 5]; diff --git a/core/tests/iter/adapters/zip.rs b/core/tests/iter/adapters/zip.rs index ba54de5822bf7..94b49bac45337 100644 --- a/core/tests/iter/adapters/zip.rs +++ b/core/tests/iter/adapters/zip.rs @@ -1,6 +1,7 @@ -use super::*; use core::iter::*; +use super::*; + #[test] fn test_zip_nth() { let xs = [0, 1, 2, 4, 5]; @@ -239,8 +240,7 @@ fn test_zip_trusted_random_access_composition() { #[test] #[cfg(panic = "unwind")] fn test_zip_trusted_random_access_next_back_drop() { - use std::panic::catch_unwind; - use std::panic::AssertUnwindSafe; + use std::panic::{catch_unwind, AssertUnwindSafe}; let mut counter = 0; diff --git a/core/tests/iter/range.rs b/core/tests/iter/range.rs index e31db0732e094..d5d2b8bf2b047 100644 --- a/core/tests/iter/range.rs +++ b/core/tests/iter/range.rs @@ -1,7 +1,8 @@ -use super::*; use core::ascii::Char as AsciiChar; use core::num::NonZero; +use super::*; + #[test] fn test_range() { assert_eq!((0..5).collect::>(), [0, 1, 2, 3, 4]); diff --git a/core/tests/iter/sources.rs b/core/tests/iter/sources.rs index a15f3a5148f0a..eb8c80dd08724 100644 --- a/core/tests/iter/sources.rs +++ b/core/tests/iter/sources.rs @@ -1,6 +1,7 @@ -use super::*; use core::iter::*; +use super::*; + #[test] fn test_repeat() { let mut it = repeat(42); diff --git a/core/tests/lazy.rs b/core/tests/lazy.rs index 7f7f1f0058801..a3b89f15b3f81 100644 --- a/core/tests/lazy.rs +++ b/core/tests/lazy.rs @@ -1,7 +1,6 @@ -use core::{ - cell::{Cell, LazyCell, OnceCell}, - sync::atomic::{AtomicUsize, Ordering::SeqCst}, -}; +use core::cell::{Cell, LazyCell, OnceCell}; +use core::sync::atomic::AtomicUsize; +use core::sync::atomic::Ordering::SeqCst; #[test] fn once_cell() { diff --git a/core/tests/mem.rs b/core/tests/mem.rs index cc73391630760..b7eee10ec3f9c 100644 --- a/core/tests/mem.rs +++ b/core/tests/mem.rs @@ -1,6 +1,5 @@ use core::mem::*; use core::ptr; - #[cfg(panic = "unwind")] use std::rc::Rc; diff --git a/core/tests/net/ip_addr.rs b/core/tests/net/ip_addr.rs index f9b351ef1980b..a10b51c550d5b 100644 --- a/core/tests/net/ip_addr.rs +++ b/core/tests/net/ip_addr.rs @@ -1,9 +1,10 @@ -use super::{sa4, sa6}; use core::net::{ IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope, SocketAddr, SocketAddrV4, SocketAddrV6, }; use core::str::FromStr; +use super::{sa4, sa6}; + #[test] fn test_from_str_ipv4() { assert_eq!(Ok(Ipv4Addr::new(127, 0, 0, 1)), "127.0.0.1".parse()); diff --git a/core/tests/num/flt2dec/mod.rs b/core/tests/num/flt2dec/mod.rs index 83e2707b57e8b..070a53edc2e0f 100644 --- a/core/tests/num/flt2dec/mod.rs +++ b/core/tests/num/flt2dec/mod.rs @@ -1,12 +1,10 @@ -use std::mem::MaybeUninit; -use std::{fmt, str}; - -use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded}; -use core::num::flt2dec::{round_up, Sign, MAX_SIG_DIGITS}; use core::num::flt2dec::{ - to_exact_exp_str, to_exact_fixed_str, to_shortest_exp_str, to_shortest_str, + decode, round_up, to_exact_exp_str, to_exact_fixed_str, to_shortest_exp_str, to_shortest_str, + DecodableFloat, Decoded, FullDecoded, Sign, MAX_SIG_DIGITS, }; use core::num::fmt::{Formatted, Part}; +use std::mem::MaybeUninit; +use std::{fmt, str}; mod estimator; mod strategy { diff --git a/core/tests/num/flt2dec/random.rs b/core/tests/num/flt2dec/random.rs index 0084c1c814e2d..4817a66638391 100644 --- a/core/tests/num/flt2dec/random.rs +++ b/core/tests/num/flt2dec/random.rs @@ -1,13 +1,10 @@ #![cfg(not(target_arch = "wasm32"))] +use core::num::flt2dec::strategy::grisu::{format_exact_opt, format_shortest_opt}; +use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded, MAX_SIG_DIGITS}; use std::mem::MaybeUninit; use std::str; -use core::num::flt2dec::strategy::grisu::format_exact_opt; -use core::num::flt2dec::strategy::grisu::format_shortest_opt; -use core::num::flt2dec::MAX_SIG_DIGITS; -use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded}; - use rand::distributions::{Distribution, Uniform}; pub fn decode_finite(v: T) -> Decoded { diff --git a/core/tests/num/flt2dec/strategy/dragon.rs b/core/tests/num/flt2dec/strategy/dragon.rs index fc2e724a20c7c..be25fee3f6c71 100644 --- a/core/tests/num/flt2dec/strategy/dragon.rs +++ b/core/tests/num/flt2dec/strategy/dragon.rs @@ -1,7 +1,8 @@ -use super::super::*; use core::num::bignum::Big32x40 as Big; use core::num::flt2dec::strategy::dragon::*; +use super::super::*; + #[test] fn test_mul_pow10() { let mut prevpow10 = Big::from_small(1); diff --git a/core/tests/num/flt2dec/strategy/grisu.rs b/core/tests/num/flt2dec/strategy/grisu.rs index b59a3b9b72d3b..9b2f0453de73e 100644 --- a/core/tests/num/flt2dec/strategy/grisu.rs +++ b/core/tests/num/flt2dec/strategy/grisu.rs @@ -1,6 +1,7 @@ -use super::super::*; use core::num::flt2dec::strategy::grisu::*; +use super::super::*; + #[test] #[cfg_attr(miri, ignore)] // Miri is too slow fn test_cached_power() { diff --git a/core/tests/ops.rs b/core/tests/ops.rs index 0c81cba35b3df..2ee0abd399bb6 100644 --- a/core/tests/ops.rs +++ b/core/tests/ops.rs @@ -1,7 +1,8 @@ mod control_flow; -use core::ops::{Bound, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive}; -use core::ops::{Deref, DerefMut}; +use core::ops::{ + Bound, Deref, DerefMut, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive, +}; // Test the Range structs and syntax. diff --git a/core/tests/pin_macro.rs b/core/tests/pin_macro.rs index 57485ef3974cc..36c6972515a96 100644 --- a/core/tests/pin_macro.rs +++ b/core/tests/pin_macro.rs @@ -1,10 +1,8 @@ // edition:2021 -use core::{ - marker::PhantomPinned, - mem::{drop as stuff, transmute}, - pin::{pin, Pin}, -}; +use core::marker::PhantomPinned; +use core::mem::{drop as stuff, transmute}; +use core::pin::{pin, Pin}; #[test] fn basic() { diff --git a/core/tests/result.rs b/core/tests/result.rs index 00a6fd75b4f46..90ec844bc5771 100644 --- a/core/tests/result.rs +++ b/core/tests/result.rs @@ -410,7 +410,8 @@ fn result_opt_conversions() { #[test] fn result_try_trait_v2_branch() { use core::num::NonZero; - use core::ops::{ControlFlow::*, Try}; + use core::ops::ControlFlow::*; + use core::ops::Try; assert_eq!(Ok::(4).branch(), Continue(4)); assert_eq!(Err::(4).branch(), Break(Err(4))); diff --git a/core/tests/slice.rs b/core/tests/slice.rs index 4cbbabb672ba0..acabedcdc2668 100644 --- a/core/tests/slice.rs +++ b/core/tests/slice.rs @@ -1856,6 +1856,7 @@ fn sort_unstable() { #[cfg_attr(miri, ignore)] // Miri is too slow fn select_nth_unstable() { use core::cmp::Ordering::{Equal, Greater, Less}; + use rand::seq::SliceRandom; use rand::Rng; diff --git a/core/tests/waker.rs b/core/tests/waker.rs index f8c91a72593f0..361e900e69562 100644 --- a/core/tests/waker.rs +++ b/core/tests/waker.rs @@ -23,11 +23,9 @@ static WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new( // https://github.com/rust-lang/rust/issues/102012#issuecomment-1915282956 mod nop_waker { - use core::{ - future::{ready, Future}, - pin::Pin, - task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - }; + use core::future::{ready, Future}; + use core::pin::Pin; + use core::task::{Context, Poll, RawWaker, RawWakerVTable, Waker}; const NOP_RAWWAKER: RawWaker = { fn nop(_: *const ()) {} diff --git a/panic_unwind/src/emcc.rs b/panic_unwind/src/emcc.rs index fed4c52e83c5f..86a43184fb529 100644 --- a/panic_unwind/src/emcc.rs +++ b/panic_unwind/src/emcc.rs @@ -8,10 +8,9 @@ use alloc::boxed::Box; use core::any::Any; -use core::intrinsics; -use core::mem; -use core::ptr; use core::sync::atomic::{AtomicBool, Ordering}; +use core::{intrinsics, mem, ptr}; + use unwind as uw; // This matches the layout of std::type_info in C++ diff --git a/proc_macro/src/bridge/arena.rs b/proc_macro/src/bridge/arena.rs index f81f2152cd046..1d5986093c8a4 100644 --- a/proc_macro/src/bridge/arena.rs +++ b/proc_macro/src/bridge/arena.rs @@ -5,12 +5,9 @@ //! being built at the same time as `std`. use std::cell::{Cell, RefCell}; -use std::cmp; use std::mem::MaybeUninit; use std::ops::Range; -use std::ptr; -use std::slice; -use std::str; +use std::{cmp, ptr, slice, str}; // The arenas start with PAGE-sized chunks, and then each new chunk is twice as // big as its predecessor, up until we reach HUGE_PAGE-sized chunks, whereupon diff --git a/proc_macro/src/bridge/client.rs b/proc_macro/src/bridge/client.rs index 9658fc4840f67..5a1086527a127 100644 --- a/proc_macro/src/bridge/client.rs +++ b/proc_macro/src/bridge/client.rs @@ -1,11 +1,11 @@ //! Client-side types. -use super::*; - use std::cell::RefCell; use std::marker::PhantomData; use std::sync::atomic::AtomicU32; +use super::*; + macro_rules! define_client_handles { ( 'owned: $($oty:ident,)* @@ -190,10 +190,11 @@ impl<'a> !Sync for Bridge<'a> {} #[allow(unsafe_code)] mod state { - use super::Bridge; use std::cell::{Cell, RefCell}; use std::ptr; + use super::Bridge; + thread_local! { static BRIDGE_STATE: Cell<*const ()> = const { Cell::new(ptr::null()) }; } diff --git a/proc_macro/src/bridge/fxhash.rs b/proc_macro/src/bridge/fxhash.rs index 9fb79eabd0556..74a41451825ff 100644 --- a/proc_macro/src/bridge/fxhash.rs +++ b/proc_macro/src/bridge/fxhash.rs @@ -5,8 +5,7 @@ //! on the `rustc_hash` crate. use std::collections::HashMap; -use std::hash::BuildHasherDefault; -use std::hash::Hasher; +use std::hash::{BuildHasherDefault, Hasher}; use std::ops::BitXor; /// Type alias for a hashmap using the `fx` hash algorithm. diff --git a/proc_macro/src/bridge/mod.rs b/proc_macro/src/bridge/mod.rs index 8553e8d5e4fd6..03c3e697cfe2b 100644 --- a/proc_macro/src/bridge/mod.rs +++ b/proc_macro/src/bridge/mod.rs @@ -8,16 +8,12 @@ #![deny(unsafe_code)] -use crate::{Delimiter, Level, Spacing}; -use std::fmt; use std::hash::Hash; -use std::marker; -use std::mem; -use std::ops::Bound; -use std::ops::Range; -use std::panic; +use std::ops::{Bound, Range}; use std::sync::Once; -use std::thread; +use std::{fmt, marker, mem, panic, thread}; + +use crate::{Delimiter, Level, Spacing}; /// Higher-order macro describing the server RPC API, allowing automatic /// generation of type-safe Rust APIs, both client-side and server-side. diff --git a/proc_macro/src/bridge/server.rs b/proc_macro/src/bridge/server.rs index 140519bcb236e..692b6038a3872 100644 --- a/proc_macro/src/bridge/server.rs +++ b/proc_macro/src/bridge/server.rs @@ -1,10 +1,10 @@ //! Server-side traits. -use super::*; - use std::cell::Cell; use std::marker::PhantomData; +use super::*; + macro_rules! define_server_handles { ( 'owned: $($oty:ident,)* diff --git a/proc_macro/src/lib.rs b/proc_macro/src/lib.rs index 57247359fbf29..06db4837adf70 100644 --- a/proc_macro/src/lib.rs +++ b/proc_macro/src/lib.rs @@ -45,16 +45,17 @@ pub mod bridge; mod diagnostic; mod escape; -#[unstable(feature = "proc_macro_diagnostic", issue = "54140")] -pub use diagnostic::{Diagnostic, Level, MultiSpan}; - -use crate::escape::{escape_bytes, EscapeOptions}; use std::ffi::CStr; use std::ops::{Range, RangeBounds}; use std::path::PathBuf; use std::str::FromStr; use std::{error, fmt}; +#[unstable(feature = "proc_macro_diagnostic", issue = "54140")] +pub use diagnostic::{Diagnostic, Level, MultiSpan}; + +use crate::escape::{escape_bytes, EscapeOptions}; + /// Determines whether proc_macro has been made accessible to the currently /// running program. /// diff --git a/std/benches/hash/map.rs b/std/benches/hash/map.rs index bf646cbae47db..d6023c8212b89 100644 --- a/std/benches/hash/map.rs +++ b/std/benches/hash/map.rs @@ -1,6 +1,7 @@ #![cfg(test)] use std::collections::HashMap; + use test::Bencher; #[bench] diff --git a/std/benches/hash/set_ops.rs b/std/benches/hash/set_ops.rs index 1a4c4a66ee9e0..b97e3b450850e 100644 --- a/std/benches/hash/set_ops.rs +++ b/std/benches/hash/set_ops.rs @@ -1,4 +1,5 @@ use std::collections::HashSet; + use test::Bencher; #[bench] diff --git a/std/src/alloc.rs b/std/src/alloc.rs index dc4924cdf581d..5d51d6a0c78a8 100644 --- a/std/src/alloc.rs +++ b/std/src/alloc.rs @@ -56,10 +56,9 @@ #![deny(unsafe_op_in_unsafe_fn)] #![stable(feature = "alloc_module", since = "1.28.0")] -use core::hint; use core::ptr::NonNull; use core::sync::atomic::{AtomicPtr, Ordering}; -use core::{mem, ptr}; +use core::{hint, mem, ptr}; #[stable(feature = "alloc_module", since = "1.28.0")] #[doc(inline)] diff --git a/std/src/ascii.rs b/std/src/ascii.rs index b18ab50de123e..3a2880fd50904 100644 --- a/std/src/ascii.rs +++ b/std/src/ascii.rs @@ -13,11 +13,10 @@ #![stable(feature = "rust1", since = "1.0.0")] -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::ascii::{escape_default, EscapeDefault}; - #[unstable(feature = "ascii_char", issue = "110998")] pub use core::ascii::Char; +#[stable(feature = "rust1", since = "1.0.0")] +pub use core::ascii::{escape_default, EscapeDefault}; /// Extension methods for ASCII-subset only operations. /// diff --git a/std/src/backtrace.rs b/std/src/backtrace.rs index 4266da04f9918..7df9a8a14b00c 100644 --- a/std/src/backtrace.rs +++ b/std/src/backtrace.rs @@ -89,13 +89,13 @@ mod tests; // a backtrace or actually symbolizing it. use crate::backtrace_rs::{self, BytesOrWideString}; -use crate::env; use crate::ffi::c_void; -use crate::fmt; use crate::panic::UnwindSafe; -use crate::sync::atomic::{AtomicU8, Ordering::Relaxed}; +use crate::sync::atomic::AtomicU8; +use crate::sync::atomic::Ordering::Relaxed; use crate::sync::LazyLock; use crate::sys::backtrace::{lock, output_filename, set_image_base}; +use crate::{env, fmt}; /// A captured OS thread stack backtrace. /// diff --git a/std/src/collections/hash/map.rs b/std/src/collections/hash/map.rs index 1f6a3e904795a..822fa5791e300 100644 --- a/std/src/collections/hash/map.rs +++ b/std/src/collections/hash/map.rs @@ -1,13 +1,11 @@ #[cfg(test)] mod tests; -use self::Entry::*; - use hashbrown::hash_map as base; +use self::Entry::*; use crate::borrow::Borrow; -use crate::collections::TryReserveError; -use crate::collections::TryReserveErrorKind; +use crate::collections::{TryReserveError, TryReserveErrorKind}; use crate::error::Error; use crate::fmt::{self, Debug}; use crate::hash::{BuildHasher, Hash, RandomState}; diff --git a/std/src/collections/hash/map/tests.rs b/std/src/collections/hash/map/tests.rs index 8585376abc18b..6641197c3724a 100644 --- a/std/src/collections/hash/map/tests.rs +++ b/std/src/collections/hash/map/tests.rs @@ -1,11 +1,12 @@ +use rand::Rng; +use realstd::collections::TryReserveErrorKind::*; + use super::Entry::{Occupied, Vacant}; use super::HashMap; use crate::assert_matches::assert_matches; use crate::cell::RefCell; use crate::hash::RandomState; use crate::test_helpers::test_rng; -use rand::Rng; -use realstd::collections::TryReserveErrorKind::*; // https://github.com/rust-lang/rust/issues/62301 fn _assert_hashmap_is_unwind_safe() { @@ -946,7 +947,6 @@ fn test_raw_entry() { mod test_extract_if { use super::*; - use crate::panic::{catch_unwind, AssertUnwindSafe}; use crate::sync::atomic::{AtomicUsize, Ordering}; diff --git a/std/src/collections/hash/set.rs b/std/src/collections/hash/set.rs index f0a498fc7bbca..d611353b0d3f2 100644 --- a/std/src/collections/hash/set.rs +++ b/std/src/collections/hash/set.rs @@ -3,6 +3,7 @@ mod tests; use hashbrown::hash_set as base; +use super::map::map_try_reserve_error; use crate::borrow::Borrow; use crate::collections::TryReserveError; use crate::fmt; @@ -10,8 +11,6 @@ use crate::hash::{BuildHasher, Hash, RandomState}; use crate::iter::{Chain, FusedIterator}; use crate::ops::{BitAnd, BitOr, BitXor, Sub}; -use super::map::map_try_reserve_error; - /// A [hash set] implemented as a `HashMap` where the value is `()`. /// /// As with the [`HashMap`] type, a `HashSet` requires that the elements diff --git a/std/src/collections/hash/set/tests.rs b/std/src/collections/hash/set/tests.rs index a188409004305..4e6351652721f 100644 --- a/std/src/collections/hash/set/tests.rs +++ b/std/src/collections/hash/set/tests.rs @@ -1,5 +1,4 @@ use super::HashSet; - use crate::hash::RandomState; use crate::panic::{catch_unwind, AssertUnwindSafe}; use crate::sync::atomic::{AtomicU32, Ordering}; diff --git a/std/src/collections/mod.rs b/std/src/collections/mod.rs index 1389d24a8c519..3b04412e76630 100644 --- a/std/src/collections/mod.rs +++ b/std/src/collections/mod.rs @@ -401,12 +401,14 @@ #![stable(feature = "rust1", since = "1.0.0")] -#[stable(feature = "rust1", since = "1.0.0")] -// FIXME(#82080) The deprecation here is only theoretical, and does not actually produce a warning. -#[deprecated(note = "moved to `std::ops::Bound`", since = "1.26.0")] -#[doc(hidden)] -pub use crate::ops::Bound; - +#[stable(feature = "try_reserve", since = "1.57.0")] +pub use alloc_crate::collections::TryReserveError; +#[unstable( + feature = "try_reserve_kind", + reason = "Uncertain how much info should be exposed", + issue = "48043" +)] +pub use alloc_crate::collections::TryReserveErrorKind; #[stable(feature = "rust1", since = "1.0.0")] pub use alloc_crate::collections::{binary_heap, btree_map, btree_set}; #[stable(feature = "rust1", since = "1.0.0")] @@ -422,15 +424,11 @@ pub use self::hash_map::HashMap; #[stable(feature = "rust1", since = "1.0.0")] #[doc(inline)] pub use self::hash_set::HashSet; - -#[stable(feature = "try_reserve", since = "1.57.0")] -pub use alloc_crate::collections::TryReserveError; -#[unstable( - feature = "try_reserve_kind", - reason = "Uncertain how much info should be exposed", - issue = "48043" -)] -pub use alloc_crate::collections::TryReserveErrorKind; +#[stable(feature = "rust1", since = "1.0.0")] +// FIXME(#82080) The deprecation here is only theoretical, and does not actually produce a warning. +#[deprecated(note = "moved to `std::ops::Bound`", since = "1.26.0")] +#[doc(hidden)] +pub use crate::ops::Bound; mod hash; @@ -439,7 +437,6 @@ pub mod hash_map { //! A hash map implemented with quadratic probing and SIMD lookup. #[stable(feature = "rust1", since = "1.0.0")] pub use super::hash::map::*; - #[stable(feature = "hashmap_build_hasher", since = "1.7.0")] pub use crate::hash::random::DefaultHasher; #[stable(feature = "hashmap_build_hasher", since = "1.7.0")] diff --git a/std/src/env.rs b/std/src/env.rs index fc9b8cfd46d65..50ae83090c7e1 100644 --- a/std/src/env.rs +++ b/std/src/env.rs @@ -15,11 +15,9 @@ mod tests; use crate::error::Error; use crate::ffi::{OsStr, OsString}; -use crate::fmt; -use crate::io; use crate::path::{Path, PathBuf}; -use crate::sys; use crate::sys::os as os_imp; +use crate::{fmt, io, sys}; /// Returns the current working directory as a [`PathBuf`]. /// diff --git a/std/src/error.rs b/std/src/error.rs index 7d10cbec26d80..f5905605e7887 100644 --- a/std/src/error.rs +++ b/std/src/error.rs @@ -4,14 +4,14 @@ #[cfg(test)] mod tests; -use crate::backtrace::Backtrace; -use crate::fmt::{self, Write}; - #[stable(feature = "rust1", since = "1.0.0")] pub use core::error::Error; #[unstable(feature = "error_generic_member_access", issue = "99301")] pub use core::error::{request_ref, request_value, Request}; +use crate::backtrace::Backtrace; +use crate::fmt::{self, Write}; + /// An error reporter that prints an error and its sources. /// /// Report also exposes configuration options for formatting the error sources, either entirely on a diff --git a/std/src/error/tests.rs b/std/src/error/tests.rs index ed070a26b0cf0..88a9f33c07908 100644 --- a/std/src/error/tests.rs +++ b/std/src/error/tests.rs @@ -1,6 +1,7 @@ +use core::error::Request; + use super::Error; use crate::fmt; -use core::error::Request; #[derive(Debug, PartialEq)] struct A; diff --git a/std/src/f128.rs b/std/src/f128.rs index 0591c6f517b44..34817fe6ae583 100644 --- a/std/src/f128.rs +++ b/std/src/f128.rs @@ -7,12 +7,12 @@ #[cfg(test)] mod tests; -#[cfg(not(test))] -use crate::intrinsics; - #[unstable(feature = "f128", issue = "116909")] pub use core::f128::consts; +#[cfg(not(test))] +use crate::intrinsics; + #[cfg(not(test))] impl f128 { /// Raises a number to an integer power. diff --git a/std/src/f128/tests.rs b/std/src/f128/tests.rs index 0b3e485b0e735..dd42da8db300d 100644 --- a/std/src/f128/tests.rs +++ b/std/src/f128/tests.rs @@ -3,8 +3,7 @@ #![cfg(reliable_f128)] use crate::f128::consts; -use crate::num::FpCategory as Fp; -use crate::num::*; +use crate::num::{FpCategory as Fp, *}; /// Smallest number const TINY_BITS: u128 = 0x1; diff --git a/std/src/f16.rs b/std/src/f16.rs index d48518622999a..bd5328d335640 100644 --- a/std/src/f16.rs +++ b/std/src/f16.rs @@ -7,12 +7,12 @@ #[cfg(test)] mod tests; -#[cfg(not(test))] -use crate::intrinsics; - #[unstable(feature = "f16", issue = "116909")] pub use core::f16::consts; +#[cfg(not(test))] +use crate::intrinsics; + #[cfg(not(test))] impl f16 { /// Raises a number to an integer power. diff --git a/std/src/f16/tests.rs b/std/src/f16/tests.rs index 26658a0be87bc..d9b9d99bf04b3 100644 --- a/std/src/f16/tests.rs +++ b/std/src/f16/tests.rs @@ -3,8 +3,7 @@ #![cfg(reliable_f16)] use crate::f16::consts; -use crate::num::FpCategory as Fp; -use crate::num::*; +use crate::num::{FpCategory as Fp, *}; // We run out of precision pretty quickly with f16 // const F16_APPROX_L1: f16 = 0.001; diff --git a/std/src/f32.rs b/std/src/f32.rs index 4fc82fec0adbc..b3afeca1ed855 100644 --- a/std/src/f32.rs +++ b/std/src/f32.rs @@ -15,11 +15,6 @@ #[cfg(test)] mod tests; -#[cfg(not(test))] -use crate::intrinsics; -#[cfg(not(test))] -use crate::sys::cmath; - #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated, deprecated_in_future)] pub use core::f32::{ @@ -27,6 +22,11 @@ pub use core::f32::{ MIN_EXP, MIN_POSITIVE, NAN, NEG_INFINITY, RADIX, }; +#[cfg(not(test))] +use crate::intrinsics; +#[cfg(not(test))] +use crate::sys::cmath; + #[cfg(not(test))] impl f32 { /// Returns the largest integer less than or equal to `self`. diff --git a/std/src/f32/tests.rs b/std/src/f32/tests.rs index 63e65698374c8..3a4c1c120a495 100644 --- a/std/src/f32/tests.rs +++ b/std/src/f32/tests.rs @@ -1,6 +1,5 @@ use crate::f32::consts; -use crate::num::FpCategory as Fp; -use crate::num::*; +use crate::num::{FpCategory as Fp, *}; /// Smallest number #[allow(dead_code)] // unused on x86 diff --git a/std/src/f64.rs b/std/src/f64.rs index 1ca2b32e241c9..c8a709c7768db 100644 --- a/std/src/f64.rs +++ b/std/src/f64.rs @@ -15,11 +15,6 @@ #[cfg(test)] mod tests; -#[cfg(not(test))] -use crate::intrinsics; -#[cfg(not(test))] -use crate::sys::cmath; - #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated, deprecated_in_future)] pub use core::f64::{ @@ -27,6 +22,11 @@ pub use core::f64::{ MIN_EXP, MIN_POSITIVE, NAN, NEG_INFINITY, RADIX, }; +#[cfg(not(test))] +use crate::intrinsics; +#[cfg(not(test))] +use crate::sys::cmath; + #[cfg(not(test))] impl f64 { /// Returns the largest integer less than or equal to `self`. diff --git a/std/src/f64/tests.rs b/std/src/f64/tests.rs index d9e17fd601d2d..bac8405f97361 100644 --- a/std/src/f64/tests.rs +++ b/std/src/f64/tests.rs @@ -1,6 +1,5 @@ use crate::f64::consts; -use crate::num::FpCategory as Fp; -use crate::num::*; +use crate::num::{FpCategory as Fp, *}; /// Smallest number #[allow(dead_code)] // unused on x86 diff --git a/std/src/ffi/c_str.rs b/std/src/ffi/c_str.rs index b59b0c5bba65a..cb0ca5d1376ea 100644 --- a/std/src/ffi/c_str.rs +++ b/std/src/ffi/c_str.rs @@ -1,19 +1,14 @@ //! [`CStr`], [`CString`], and related types. -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::ffi::c_str::CStr; - -#[stable(feature = "cstr_from_bytes", since = "1.10.0")] -pub use core::ffi::c_str::FromBytesWithNulError; - -#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] -pub use core::ffi::c_str::FromBytesUntilNulError; - -#[stable(feature = "rust1", since = "1.0.0")] -pub use alloc::ffi::c_str::{CString, NulError}; - #[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")] pub use alloc::ffi::c_str::FromVecWithNulError; - #[stable(feature = "cstring_into", since = "1.7.0")] pub use alloc::ffi::c_str::IntoStringError; +#[stable(feature = "rust1", since = "1.0.0")] +pub use alloc::ffi::c_str::{CString, NulError}; +#[stable(feature = "rust1", since = "1.0.0")] +pub use core::ffi::c_str::CStr; +#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] +pub use core::ffi::c_str::FromBytesUntilNulError; +#[stable(feature = "cstr_from_bytes", since = "1.10.0")] +pub use core::ffi::c_str::FromBytesWithNulError; diff --git a/std/src/ffi/mod.rs b/std/src/ffi/mod.rs index f45fd77e8b167..2b67750c2f0a9 100644 --- a/std/src/ffi/mod.rs +++ b/std/src/ffi/mod.rs @@ -164,50 +164,42 @@ #[unstable(feature = "c_str_module", issue = "112134")] pub mod c_str; -#[doc(inline)] -#[stable(feature = "rust1", since = "1.0.0")] -pub use self::c_str::{CStr, CString}; - -#[doc(no_inline)] -#[stable(feature = "cstr_from_bytes", since = "1.10.0")] -pub use self::c_str::FromBytesWithNulError; +#[stable(feature = "core_c_void", since = "1.30.0")] +pub use core::ffi::c_void; +#[stable(feature = "core_ffi_c", since = "1.64.0")] +pub use core::ffi::{ + c_char, c_double, c_float, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, + c_ulong, c_ulonglong, c_ushort, +}; +#[unstable( + feature = "c_variadic", + reason = "the `c_variadic` feature has not been properly tested on \ + all supported platforms", + issue = "44930" +)] +pub use core::ffi::{VaList, VaListImpl}; #[doc(no_inline)] #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] pub use self::c_str::FromBytesUntilNulError; - #[doc(no_inline)] -#[stable(feature = "rust1", since = "1.0.0")] -pub use self::c_str::NulError; - +#[stable(feature = "cstr_from_bytes", since = "1.10.0")] +pub use self::c_str::FromBytesWithNulError; #[doc(no_inline)] #[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")] pub use self::c_str::FromVecWithNulError; - #[doc(no_inline)] #[stable(feature = "cstring_into", since = "1.7.0")] pub use self::c_str::IntoStringError; - +#[doc(no_inline)] +#[stable(feature = "rust1", since = "1.0.0")] +pub use self::c_str::NulError; +#[doc(inline)] +#[stable(feature = "rust1", since = "1.0.0")] +pub use self::c_str::{CStr, CString}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(inline)] pub use self::os_str::{OsStr, OsString}; -#[stable(feature = "core_ffi_c", since = "1.64.0")] -pub use core::ffi::{ - c_char, c_double, c_float, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, - c_ulong, c_ulonglong, c_ushort, -}; - -#[stable(feature = "core_c_void", since = "1.30.0")] -pub use core::ffi::c_void; - -#[unstable( - feature = "c_variadic", - reason = "the `c_variadic` feature has not been properly tested on \ - all supported platforms", - issue = "44930" -)] -pub use core::ffi::{VaList, VaListImpl}; - #[unstable(feature = "os_str_display", issue = "120048")] pub mod os_str; diff --git a/std/src/ffi/os_str.rs b/std/src/ffi/os_str.rs index 0fb3964c9a9b4..a501bcc98cf38 100644 --- a/std/src/ffi/os_str.rs +++ b/std/src/ffi/os_str.rs @@ -4,18 +4,15 @@ mod tests; use crate::borrow::{Borrow, Cow}; -use crate::cmp; use crate::collections::TryReserveError; -use crate::fmt; use crate::hash::{Hash, Hasher}; use crate::ops::{self, Range}; use crate::rc::Rc; -use crate::slice; use crate::str::FromStr; use crate::sync::Arc; - use crate::sys::os_str::{Buf, Slice}; use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::{cmp, fmt, slice}; /// A type that can represent owned, mutable platform-native strings, but is /// cheaply inter-convertible with Rust strings. diff --git a/std/src/fs/tests.rs b/std/src/fs/tests.rs index c1fc2e5488d0c..13028c4c3b57e 100644 --- a/std/src/fs/tests.rs +++ b/std/src/fs/tests.rs @@ -1,20 +1,11 @@ -use crate::io::prelude::*; - -use crate::env; -use crate::fs::{self, File, FileTimes, OpenOptions}; -use crate::io::{BorrowedBuf, ErrorKind, SeekFrom}; -use crate::mem::MaybeUninit; -use crate::path::Path; -use crate::str; -use crate::sync::Arc; -use crate::sys_common::io::test::{tmpdir, TempDir}; -use crate::thread; -use crate::time::{Duration, Instant, SystemTime}; - use rand::RngCore; #[cfg(target_os = "macos")] use crate::ffi::{c_char, c_int}; +use crate::fs::{self, File, FileTimes, OpenOptions}; +use crate::io::prelude::*; +use crate::io::{BorrowedBuf, ErrorKind, SeekFrom}; +use crate::mem::MaybeUninit; #[cfg(unix)] use crate::os::unix::fs::symlink as symlink_dir; #[cfg(unix)] @@ -23,8 +14,13 @@ use crate::os::unix::fs::symlink as symlink_file; use crate::os::unix::fs::symlink as junction_point; #[cfg(windows)] use crate::os::windows::fs::{junction_point, symlink_dir, symlink_file, OpenOptionsExt}; +use crate::path::Path; +use crate::sync::Arc; #[cfg(target_os = "macos")] use crate::sys::weak::weak; +use crate::sys_common::io::test::{tmpdir, TempDir}; +use crate::time::{Duration, Instant, SystemTime}; +use crate::{env, str, thread}; macro_rules! check { ($e:expr) => { @@ -1514,7 +1510,9 @@ fn symlink_hard_link() { #[test] #[cfg(windows)] fn create_dir_long_paths() { - use crate::{ffi::OsStr, iter, os::windows::ffi::OsStrExt}; + use crate::ffi::OsStr; + use crate::iter; + use crate::os::windows::ffi::OsStrExt; const PATH_LEN: usize = 247; let tmpdir = tmpdir(); diff --git a/std/src/hash/random.rs b/std/src/hash/random.rs index 0adf91e14ac6e..8ef45172eac40 100644 --- a/std/src/hash/random.rs +++ b/std/src/hash/random.rs @@ -10,8 +10,7 @@ #[allow(deprecated)] use super::{BuildHasher, Hasher, SipHasher13}; use crate::cell::Cell; -use crate::fmt; -use crate::sys; +use crate::{fmt, sys}; /// `RandomState` is the default state for [`HashMap`] types. /// diff --git a/std/src/io/buffered/bufreader.rs b/std/src/io/buffered/bufreader.rs index 0cdc49c87d8fc..f11dd50c5e2b7 100644 --- a/std/src/io/buffered/bufreader.rs +++ b/std/src/io/buffered/bufreader.rs @@ -1,11 +1,12 @@ mod buffer; +use buffer::Buffer; + use crate::fmt; use crate::io::{ self, uninlined_slow_read_byte, BorrowedCursor, BufRead, IoSliceMut, Read, Seek, SeekFrom, SizeHint, SpecReadByte, DEFAULT_BUF_SIZE, }; -use buffer::Buffer; /// The `BufReader` struct adds buffering to any reader. /// diff --git a/std/src/io/buffered/bufwriter.rs b/std/src/io/buffered/bufwriter.rs index a8680e9b6ead1..21650d467446e 100644 --- a/std/src/io/buffered/bufwriter.rs +++ b/std/src/io/buffered/bufwriter.rs @@ -1,10 +1,8 @@ -use crate::error; -use crate::fmt; use crate::io::{ self, ErrorKind, IntoInnerError, IoSlice, Seek, SeekFrom, Write, DEFAULT_BUF_SIZE, }; use crate::mem::{self, ManuallyDrop}; -use crate::ptr; +use crate::{error, fmt, ptr}; /// Wraps a writer and buffers its output. /// diff --git a/std/src/io/buffered/linewriter.rs b/std/src/io/buffered/linewriter.rs index 3d4ae70419322..cc6921b86dd0b 100644 --- a/std/src/io/buffered/linewriter.rs +++ b/std/src/io/buffered/linewriter.rs @@ -1,5 +1,6 @@ use crate::fmt; -use crate::io::{self, buffered::LineWriterShim, BufWriter, IntoInnerError, IoSlice, Write}; +use crate::io::buffered::LineWriterShim; +use crate::io::{self, BufWriter, IntoInnerError, IoSlice, Write}; /// Wraps a writer and buffers output to it, flushing whenever a newline /// (`0x0a`, `'\n'`) is detected. diff --git a/std/src/io/buffered/linewritershim.rs b/std/src/io/buffered/linewritershim.rs index a1f3317bdd806..3d04ccd1c7d81 100644 --- a/std/src/io/buffered/linewritershim.rs +++ b/std/src/io/buffered/linewritershim.rs @@ -1,6 +1,7 @@ -use crate::io::{self, BufWriter, IoSlice, Write}; use core::slice::memchr; +use crate::io::{self, BufWriter, IoSlice, Write}; + /// Private helper struct for implementing the line-buffered writing logic. /// /// This shim temporarily wraps a BufWriter, and uses its internals to diff --git a/std/src/io/buffered/mod.rs b/std/src/io/buffered/mod.rs index d4dc8291131df..475d877528f7f 100644 --- a/std/src/io/buffered/mod.rs +++ b/std/src/io/buffered/mod.rs @@ -8,16 +8,14 @@ mod linewritershim; #[cfg(test)] mod tests; -use crate::error; -use crate::fmt; -use crate::io::Error; +#[stable(feature = "bufwriter_into_parts", since = "1.56.0")] +pub use bufwriter::WriterPanicked; +use linewritershim::LineWriterShim; #[stable(feature = "rust1", since = "1.0.0")] pub use self::{bufreader::BufReader, bufwriter::BufWriter, linewriter::LineWriter}; -use linewritershim::LineWriterShim; - -#[stable(feature = "bufwriter_into_parts", since = "1.56.0")] -pub use bufwriter::WriterPanicked; +use crate::io::Error; +use crate::{error, fmt}; /// An error returned by [`BufWriter::into_inner`] which combines an error that /// happened while writing out the buffer, and the buffered writer object diff --git a/std/src/io/buffered/tests.rs b/std/src/io/buffered/tests.rs index ab66deaf31d22..d89ecd317d6ee 100644 --- a/std/src/io/buffered/tests.rs +++ b/std/src/io/buffered/tests.rs @@ -3,9 +3,8 @@ use crate::io::{ self, BorrowedBuf, BufReader, BufWriter, ErrorKind, IoSlice, LineWriter, SeekFrom, }; use crate::mem::MaybeUninit; -use crate::panic; use crate::sync::atomic::{AtomicUsize, Ordering}; -use crate::thread; +use crate::{panic, thread}; /// A dummy reader intended at testing short-reads propagation. pub struct ShortReader { diff --git a/std/src/io/copy/tests.rs b/std/src/io/copy/tests.rs index a1f909a3c5386..7e08826a7e1d8 100644 --- a/std/src/io/copy/tests.rs +++ b/std/src/io/copy/tests.rs @@ -119,13 +119,12 @@ fn copy_specializes_from_slice() { #[cfg(unix)] mod io_benches { - use crate::fs::File; - use crate::fs::OpenOptions; + use test::Bencher; + + use crate::fs::{File, OpenOptions}; use crate::io::prelude::*; use crate::io::BufReader; - use test::Bencher; - #[bench] fn bench_copy_buf_reader(b: &mut Bencher) { let mut file_in = File::open("/dev/zero").expect("opening /dev/zero failed"); diff --git a/std/src/io/cursor.rs b/std/src/io/cursor.rs index 2ed64a40495ef..dd32d77934a07 100644 --- a/std/src/io/cursor.rs +++ b/std/src/io/cursor.rs @@ -1,10 +1,9 @@ #[cfg(test)] mod tests; -use crate::io::prelude::*; - use crate::alloc::Allocator; use crate::cmp; +use crate::io::prelude::*; use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut, SeekFrom}; /// A `Cursor` wraps an in-memory buffer and provides it with a diff --git a/std/src/io/error.rs b/std/src/io/error.rs index 32c0ec53ff25c..e8ae1d99fbf37 100644 --- a/std/src/io/error.rs +++ b/std/src/io/error.rs @@ -11,10 +11,7 @@ mod repr_unpacked; #[cfg(any(not(target_pointer_width = "64"), target_os = "uefi"))] use repr_unpacked::Repr; -use crate::error; -use crate::fmt; -use crate::result; -use crate::sys; +use crate::{error, fmt, result, sys}; /// A specialized [`Result`] type for I/O operations. /// diff --git a/std/src/io/error/repr_bitpacked.rs b/std/src/io/error/repr_bitpacked.rs index fbb74967df3f1..9d3ade46bd929 100644 --- a/std/src/io/error/repr_bitpacked.rs +++ b/std/src/io/error/repr_bitpacked.rs @@ -102,10 +102,11 @@ //! to use a pointer type to store something that may hold an integer, some of //! the time. -use super::{Custom, ErrorData, ErrorKind, RawOsError, SimpleMessage}; use core::marker::PhantomData; use core::ptr::{self, NonNull}; +use super::{Custom, ErrorData, ErrorKind, RawOsError, SimpleMessage}; + // The 2 least-significant bits are used as tag. const TAG_MASK: usize = 0b11; const TAG_SIMPLE_MESSAGE: usize = 0b00; diff --git a/std/src/io/error/tests.rs b/std/src/io/error/tests.rs index fc6db2825e811..064e2e36b7a1d 100644 --- a/std/src/io/error/tests.rs +++ b/std/src/io/error/tests.rs @@ -1,10 +1,9 @@ use super::{const_io_error, Custom, Error, ErrorData, ErrorKind, Repr, SimpleMessage}; use crate::assert_matches::assert_matches; -use crate::error; -use crate::fmt; use crate::mem::size_of; use crate::sys::decode_error_kind; use crate::sys::os::error_string; +use crate::{error, fmt}; #[test] fn test_size() { @@ -95,7 +94,8 @@ fn test_errorkind_packing() { #[test] fn test_simple_message_packing() { - use super::{ErrorKind::*, SimpleMessage}; + use super::ErrorKind::*; + use super::SimpleMessage; macro_rules! check_simple_msg { ($err:expr, $kind:ident, $msg:literal) => {{ let e = &$err; diff --git a/std/src/io/impls.rs b/std/src/io/impls.rs index a8a2e9413e11c..85023540a816f 100644 --- a/std/src/io/impls.rs +++ b/std/src/io/impls.rs @@ -2,12 +2,9 @@ mod tests; use crate::alloc::Allocator; -use crate::cmp; use crate::collections::VecDeque; -use crate::fmt; use crate::io::{self, BorrowedCursor, BufRead, IoSlice, IoSliceMut, Read, Seek, SeekFrom, Write}; -use crate::mem; -use crate::str; +use crate::{cmp, fmt, mem, str}; // ============================================================================= // Forwarding implementations diff --git a/std/src/io/mod.rs b/std/src/io/mod.rs index beb88106f1cad..63338c934b505 100644 --- a/std/src/io/mod.rs +++ b/std/src/io/mod.rs @@ -297,15 +297,12 @@ #[cfg(test)] mod tests; -use crate::cmp; -use crate::fmt; -use crate::mem::take; -use crate::ops::{Deref, DerefMut}; -use crate::slice; -use crate::str; -use crate::sys; +#[unstable(feature = "read_buf", issue = "78485")] +pub use core::io::{BorrowedBuf, BorrowedCursor}; use core::slice::memchr; +pub(crate) use error::const_io_error; + #[stable(feature = "bufwriter_into_parts", since = "1.56.0")] pub use self::buffered::WriterPanicked; #[unstable(feature = "raw_os_error_ty", issue = "107792")] @@ -328,10 +325,9 @@ pub use self::{ stdio::{stderr, stdin, stdout, Stderr, StderrLock, Stdin, StdinLock, Stdout, StdoutLock}, util::{empty, repeat, sink, Empty, Repeat, Sink}, }; - -#[unstable(feature = "read_buf", issue = "78485")] -pub use core::io::{BorrowedBuf, BorrowedCursor}; -pub(crate) use error::const_io_error; +use crate::mem::take; +use crate::ops::{Deref, DerefMut}; +use crate::{cmp, fmt, slice, str, sys}; mod buffered; pub(crate) mod copy; diff --git a/std/src/io/stdio.rs b/std/src/io/stdio.rs index 10eb8dae48ef4..6de069a518e3d 100644 --- a/std/src/io/stdio.rs +++ b/std/src/io/stdio.rs @@ -3,11 +3,10 @@ #[cfg(test)] mod tests; -use crate::io::prelude::*; - use crate::cell::{Cell, RefCell}; use crate::fmt; use crate::fs::File; +use crate::io::prelude::*; use crate::io::{ self, BorrowedCursor, BufReader, IoSlice, IoSliceMut, LineWriter, Lines, SpecReadByte, }; diff --git a/std/src/io/tests.rs b/std/src/io/tests.rs index f613626bca843..9a1cbb2627fdb 100644 --- a/std/src/io/tests.rs +++ b/std/src/io/tests.rs @@ -1,7 +1,8 @@ use super::{repeat, BorrowedBuf, Cursor, SeekFrom}; use crate::cmp::{self, min}; -use crate::io::{self, IoSlice, IoSliceMut, DEFAULT_BUF_SIZE}; -use crate::io::{BufRead, BufReader, Read, Seek, Write}; +use crate::io::{ + self, BufRead, BufReader, IoSlice, IoSliceMut, Read, Seek, Write, DEFAULT_BUF_SIZE, +}; use crate::mem::MaybeUninit; use crate::ops::Deref; diff --git a/std/src/io/util/tests.rs b/std/src/io/util/tests.rs index 6de91e29c7707..1dff3f3832bd7 100644 --- a/std/src/io/util/tests.rs +++ b/std/src/io/util/tests.rs @@ -1,6 +1,5 @@ use crate::io::prelude::*; use crate::io::{empty, repeat, sink, BorrowedBuf, Empty, Repeat, SeekFrom, Sink}; - use crate::mem::MaybeUninit; #[test] diff --git a/std/src/lib.rs b/std/src/lib.rs index 353fd8d2de8c0..6dc74728dfd06 100644 --- a/std/src/lib.rs +++ b/std/src/lib.rs @@ -470,24 +470,6 @@ pub mod rt; // The Rust prelude pub mod prelude; -#[stable(feature = "rust1", since = "1.0.0")] -pub use alloc_crate::borrow; -#[stable(feature = "rust1", since = "1.0.0")] -pub use alloc_crate::boxed; -#[stable(feature = "rust1", since = "1.0.0")] -pub use alloc_crate::fmt; -#[stable(feature = "rust1", since = "1.0.0")] -pub use alloc_crate::format; -#[stable(feature = "rust1", since = "1.0.0")] -pub use alloc_crate::rc; -#[stable(feature = "rust1", since = "1.0.0")] -pub use alloc_crate::slice; -#[stable(feature = "rust1", since = "1.0.0")] -pub use alloc_crate::str; -#[stable(feature = "rust1", since = "1.0.0")] -pub use alloc_crate::string; -#[stable(feature = "rust1", since = "1.0.0")] -pub use alloc_crate::vec; #[stable(feature = "rust1", since = "1.0.0")] pub use core::any; #[stable(feature = "core_array", since = "1.36.0")] @@ -565,6 +547,25 @@ pub use core::u8; #[allow(deprecated, deprecated_in_future)] pub use core::usize; +#[stable(feature = "rust1", since = "1.0.0")] +pub use alloc_crate::borrow; +#[stable(feature = "rust1", since = "1.0.0")] +pub use alloc_crate::boxed; +#[stable(feature = "rust1", since = "1.0.0")] +pub use alloc_crate::fmt; +#[stable(feature = "rust1", since = "1.0.0")] +pub use alloc_crate::format; +#[stable(feature = "rust1", since = "1.0.0")] +pub use alloc_crate::rc; +#[stable(feature = "rust1", since = "1.0.0")] +pub use alloc_crate::slice; +#[stable(feature = "rust1", since = "1.0.0")] +pub use alloc_crate::str; +#[stable(feature = "rust1", since = "1.0.0")] +pub use alloc_crate::string; +#[stable(feature = "rust1", since = "1.0.0")] +pub use alloc_crate::vec; + #[unstable(feature = "f128", issue = "116909")] pub mod f128; #[unstable(feature = "f16", issue = "116909")] @@ -608,23 +609,23 @@ mod std_float; pub mod simd { #![doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")] - #[doc(inline)] - pub use crate::std_float::StdFloat; #[doc(inline)] pub use core::simd::*; + + #[doc(inline)] + pub use crate::std_float::StdFloat; } #[stable(feature = "futures_api", since = "1.36.0")] pub mod task { //! Types and Traits for working with asynchronous tasks. - #[doc(inline)] - #[stable(feature = "futures_api", since = "1.36.0")] - pub use core::task::*; - #[doc(inline)] #[stable(feature = "wake_trait", since = "1.51.0")] pub use alloc::task::*; + #[doc(inline)] + #[stable(feature = "futures_api", since = "1.36.0")] + pub use core::task::*; } #[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")] @@ -670,34 +671,30 @@ mod panicking; mod backtrace_rs; // Re-export macros defined in core. -#[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated, deprecated_in_future)] -pub use core::{ - assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, todo, r#try, - unimplemented, unreachable, write, writeln, -}; - -// Re-export built-in macros defined through core. -#[stable(feature = "builtin_macro_prelude", since = "1.38.0")] -#[allow(deprecated)] -pub use core::{ - assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args, - env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax, - module_path, option_env, stringify, trace_macros, -}; - +#[unstable(feature = "cfg_match", issue = "115585")] +pub use core::cfg_match; #[unstable( feature = "concat_bytes", issue = "87555", reason = "`concat_bytes` is not stable enough for use and is subject to change" )] pub use core::concat_bytes; - -#[unstable(feature = "cfg_match", issue = "115585")] -pub use core::cfg_match; - #[stable(feature = "core_primitive", since = "1.43.0")] pub use core::primitive; +// Re-export built-in macros defined through core. +#[stable(feature = "builtin_macro_prelude", since = "1.38.0")] +#[allow(deprecated)] +pub use core::{ + assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args, + env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax, + module_path, option_env, stringify, trace_macros, +}; +#[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated, deprecated_in_future)] +pub use core::{ + assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, todo, r#try, + unimplemented, unreachable, write, writeln, +}; // Include a number of private modules that exist solely to provide // the rustdoc documentation for primitive types. Using `include!` diff --git a/std/src/net/ip_addr.rs b/std/src/net/ip_addr.rs index e167fbd1b9cf8..8a9426b61f999 100644 --- a/std/src/net/ip_addr.rs +++ b/std/src/net/ip_addr.rs @@ -2,17 +2,15 @@ #[cfg(all(test, not(target_os = "emscripten")))] mod tests; -use crate::sys::net::netc as c; -use crate::sys_common::{FromInner, IntoInner}; - #[stable(feature = "ip_addr", since = "1.7.0")] pub use core::net::IpAddr; - +#[unstable(feature = "ip", issue = "27709")] +pub use core::net::Ipv6MulticastScope; #[stable(feature = "rust1", since = "1.0.0")] pub use core::net::{Ipv4Addr, Ipv6Addr}; -#[unstable(feature = "ip", issue = "27709")] -pub use core::net::Ipv6MulticastScope; +use crate::sys::net::netc as c; +use crate::sys_common::{FromInner, IntoInner}; impl IntoInner for Ipv4Addr { #[inline] diff --git a/std/src/net/mod.rs b/std/src/net/mod.rs index 858776f14466a..3b19c743b1e24 100644 --- a/std/src/net/mod.rs +++ b/std/src/net/mod.rs @@ -21,7 +21,8 @@ #![stable(feature = "rust1", since = "1.0.0")] -use crate::io::{self, ErrorKind}; +#[stable(feature = "rust1", since = "1.0.0")] +pub use core::net::AddrParseError; #[stable(feature = "rust1", since = "1.0.0")] pub use self::ip_addr::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope}; @@ -33,8 +34,7 @@ pub use self::tcp::IntoIncoming; pub use self::tcp::{Incoming, TcpListener, TcpStream}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::udp::UdpSocket; -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::net::AddrParseError; +use crate::io::{self, ErrorKind}; mod ip_addr; mod socket_addr; diff --git a/std/src/net/socket_addr.rs b/std/src/net/socket_addr.rs index 421fed9077c5b..84922aabdb569 100644 --- a/std/src/net/socket_addr.rs +++ b/std/src/net/socket_addr.rs @@ -2,19 +2,14 @@ #[cfg(all(test, not(target_os = "emscripten")))] mod tests; -use crate::io; -use crate::iter; -use crate::mem; +#[stable(feature = "rust1", since = "1.0.0")] +pub use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6}; + use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr}; -use crate::option; -use crate::slice; use crate::sys::net::netc as c; use crate::sys_common::net::LookupHost; use crate::sys_common::{FromInner, IntoInner}; -use crate::vec; - -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6}; +use crate::{io, iter, mem, option, slice, vec}; impl FromInner for SocketAddrV4 { fn from_inner(addr: c::sockaddr_in) -> SocketAddrV4 { diff --git a/std/src/net/tcp.rs b/std/src/net/tcp.rs index 6336354239b02..22d2dfe65a249 100644 --- a/std/src/net/tcp.rs +++ b/std/src/net/tcp.rs @@ -3,14 +3,12 @@ #[cfg(all(test, not(any(target_os = "emscripten", target_os = "xous"))))] mod tests; -use crate::io::prelude::*; - use crate::fmt; +use crate::io::prelude::*; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; use crate::iter::FusedIterator; use crate::net::{Shutdown, SocketAddr, ToSocketAddrs}; -use crate::sys_common::net as net_imp; -use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::sys_common::{net as net_imp, AsInner, FromInner, IntoInner}; use crate::time::Duration; /// A TCP stream between a local and a remote socket. diff --git a/std/src/net/tcp/tests.rs b/std/src/net/tcp/tests.rs index 3ad046733a634..d26517d74e492 100644 --- a/std/src/net/tcp/tests.rs +++ b/std/src/net/tcp/tests.rs @@ -1,12 +1,11 @@ -use crate::fmt; use crate::io::prelude::*; use crate::io::{BorrowedBuf, IoSlice, IoSliceMut}; use crate::mem::MaybeUninit; use crate::net::test::{next_test_ip4, next_test_ip6}; use crate::net::*; use crate::sync::mpsc::channel; -use crate::thread; use crate::time::{Duration, Instant}; +use crate::{fmt, thread}; fn each_ip(f: &mut dyn FnMut(SocketAddr)) { f(next_test_ip4()); diff --git a/std/src/net/udp.rs b/std/src/net/udp.rs index 60347a11da9c5..32e9086003d6b 100644 --- a/std/src/net/udp.rs +++ b/std/src/net/udp.rs @@ -4,8 +4,7 @@ mod tests; use crate::fmt; use crate::io::{self, ErrorKind}; use crate::net::{Ipv4Addr, Ipv6Addr, SocketAddr, ToSocketAddrs}; -use crate::sys_common::net as net_imp; -use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::sys_common::{net as net_imp, AsInner, FromInner, IntoInner}; use crate::time::Duration; /// A UDP socket. diff --git a/std/src/num.rs b/std/src/num.rs index 8910cdea7c0c9..c1e6e7e628c83 100644 --- a/std/src/num.rs +++ b/std/src/num.rs @@ -9,32 +9,27 @@ #[cfg(test)] mod tests; +#[stable(feature = "int_error_matching", since = "1.55.0")] +pub use core::num::IntErrorKind; +#[stable(feature = "generic_nonzero", since = "1.79.0")] +pub use core::num::NonZero; #[stable(feature = "saturating_int_impl", since = "1.74.0")] pub use core::num::Saturating; #[stable(feature = "rust1", since = "1.0.0")] pub use core::num::Wrapping; -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::num::{FpCategory, ParseFloatError, ParseIntError, TryFromIntError}; - #[unstable( feature = "nonzero_internals", reason = "implementation detail which may disappear or be replaced at any time", issue = "none" )] pub use core::num::ZeroablePrimitive; - -#[stable(feature = "generic_nonzero", since = "1.79.0")] -pub use core::num::NonZero; - +#[stable(feature = "rust1", since = "1.0.0")] +pub use core::num::{FpCategory, ParseFloatError, ParseIntError, TryFromIntError}; #[stable(feature = "signed_nonzero", since = "1.34.0")] pub use core::num::{NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize}; - #[stable(feature = "nonzero", since = "1.28.0")] pub use core::num::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; -#[stable(feature = "int_error_matching", since = "1.55.0")] -pub use core::num::IntErrorKind; - #[cfg(test)] use crate::fmt; #[cfg(test)] diff --git a/std/src/os/aix/raw.rs b/std/src/os/aix/raw.rs index b4c8dc72cfe5b..13f61fc97226b 100644 --- a/std/src/os/aix/raw.rs +++ b/std/src/os/aix/raw.rs @@ -4,6 +4,5 @@ #[stable(feature = "pthread_t", since = "1.8.0")] pub use libc::pthread_t; - #[stable(feature = "raw_ext", since = "1.1.0")] pub use libc::{blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, off_t, stat, time_t}; diff --git a/std/src/os/android/fs.rs b/std/src/os/android/fs.rs index 1beb3cf6e84b5..6b931e3816950 100644 --- a/std/src/os/android/fs.rs +++ b/std/src/os/android/fs.rs @@ -1,10 +1,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::android::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/android/net.rs b/std/src/os/android/net.rs index 349e73eaabdaf..960a304fd0c8d 100644 --- a/std/src/os/android/net.rs +++ b/std/src/os/android/net.rs @@ -4,9 +4,7 @@ #[stable(feature = "unix_socket_abstract", since = "1.70.0")] pub use crate::os::net::linux_ext::addr::SocketAddrExt; - #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] pub use crate::os::net::linux_ext::socket::UnixSocketExt; - #[unstable(feature = "tcp_quickack", issue = "96256")] pub use crate::os::net::linux_ext::tcp::TcpStreamExt; diff --git a/std/src/os/darwin/fs.rs b/std/src/os/darwin/fs.rs index 2032cca311a15..2d154b214b5f0 100644 --- a/std/src/os/darwin/fs.rs +++ b/std/src/os/darwin/fs.rs @@ -1,13 +1,12 @@ #![allow(dead_code)] +#[allow(deprecated)] +use super::raw; use crate::fs::{self, Metadata}; use crate::sealed::Sealed; use crate::sys_common::{AsInner, AsInnerMut, IntoInner}; use crate::time::SystemTime; -#[allow(deprecated)] -use super::raw; - /// OS-specific extensions to [`fs::Metadata`]. /// /// [`fs::Metadata`]: crate::fs::Metadata diff --git a/std/src/os/dragonfly/fs.rs b/std/src/os/dragonfly/fs.rs index 1424fc4c69880..0cd543b2ab97d 100644 --- a/std/src/os/dragonfly/fs.rs +++ b/std/src/os/dragonfly/fs.rs @@ -1,10 +1,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::dragonfly::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/emscripten/fs.rs b/std/src/os/emscripten/fs.rs index d5ec8e03c00d1..3282b79ac1c81 100644 --- a/std/src/os/emscripten/fs.rs +++ b/std/src/os/emscripten/fs.rs @@ -1,10 +1,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::emscripten::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/espidf/fs.rs b/std/src/os/espidf/fs.rs index 88701dafe20ce..ffff584cda02a 100644 --- a/std/src/os/espidf/fs.rs +++ b/std/src/os/espidf/fs.rs @@ -1,10 +1,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::espidf::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/fd/owned.rs b/std/src/os/fd/owned.rs index 3baba14f75e2f..2d087c03b04b4 100644 --- a/std/src/os/fd/owned.rs +++ b/std/src/os/fd/owned.rs @@ -4,14 +4,12 @@ #![deny(unsafe_op_in_unsafe_fn)] use super::raw::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; -use crate::fmt; -use crate::fs; -use crate::io; use crate::marker::PhantomData; use crate::mem::ManuallyDrop; #[cfg(not(any(target_arch = "wasm32", target_env = "sgx", target_os = "hermit")))] use crate::sys::cvt; use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::{fmt, fs, io}; /// A borrowed file descriptor. /// diff --git a/std/src/os/fd/raw.rs b/std/src/os/fd/raw.rs index ef896ea95c9c9..1e6ecd7d7a67a 100644 --- a/std/src/os/fd/raw.rs +++ b/std/src/os/fd/raw.rs @@ -2,8 +2,9 @@ #![stable(feature = "rust1", since = "1.0.0")] -use crate::fs; -use crate::io; +#[cfg(target_os = "hermit")] +use hermit_abi as libc; + #[cfg(target_os = "hermit")] use crate::os::hermit::io::OwnedFd; #[cfg(not(target_os = "hermit"))] @@ -15,8 +16,7 @@ use crate::os::unix::io::OwnedFd; #[cfg(target_os = "wasi")] use crate::os::wasi::io::OwnedFd; use crate::sys_common::{AsInner, IntoInner}; -#[cfg(target_os = "hermit")] -use hermit_abi as libc; +use crate::{fs, io}; /// Raw file descriptors. #[rustc_allowed_through_unstable_modules] diff --git a/std/src/os/fortanix_sgx/arch.rs b/std/src/os/fortanix_sgx/arch.rs index 8358cb9e81b65..4c8048e7152e2 100644 --- a/std/src/os/fortanix_sgx/arch.rs +++ b/std/src/os/fortanix_sgx/arch.rs @@ -4,9 +4,10 @@ //! Software Developer's Manual, Volume 3, Chapter 40. #![unstable(feature = "sgx_platform", issue = "56975")] -use crate::mem::MaybeUninit; use core::arch::asm; +use crate::mem::MaybeUninit; + /// Wrapper struct to force 16-byte alignment. #[repr(align(16))] #[unstable(feature = "sgx_platform", issue = "56975")] diff --git a/std/src/os/fortanix_sgx/mod.rs b/std/src/os/fortanix_sgx/mod.rs index b31dc06f8dfbd..64f4d97ca95e2 100644 --- a/std/src/os/fortanix_sgx/mod.rs +++ b/std/src/os/fortanix_sgx/mod.rs @@ -22,20 +22,12 @@ pub mod usercalls { /// Lowest-level interfaces to usercalls and usercall ABI type definitions. pub mod raw { pub use crate::sys::abi::usercalls::raw::{ - accept_stream, alloc, async_queues, bind_stream, close, connect_stream, exit, flush, - free, insecure_time, launch_thread, read, read_alloc, send, wait, write, - }; - pub use crate::sys::abi::usercalls::raw::{do_usercall, Usercalls as UsercallNrs}; - pub use crate::sys::abi::usercalls::raw::{Register, RegisterArgument, ReturnValue}; - - pub use crate::sys::abi::usercalls::raw::Error; - pub use crate::sys::abi::usercalls::raw::{ - ByteBuffer, Cancel, FifoDescriptor, Return, Usercall, - }; - pub use crate::sys::abi::usercalls::raw::{Fd, Result, Tcs}; - pub use crate::sys::abi::usercalls::raw::{ - EV_RETURNQ_NOT_EMPTY, EV_UNPARK, EV_USERCALLQ_NOT_FULL, FD_STDERR, FD_STDIN, FD_STDOUT, - RESULT_SUCCESS, USERCALL_USER_DEFINED, WAIT_INDEFINITE, WAIT_NO, + accept_stream, alloc, async_queues, bind_stream, close, connect_stream, do_usercall, + exit, flush, free, insecure_time, launch_thread, read, read_alloc, send, wait, write, + ByteBuffer, Cancel, Error, Fd, FifoDescriptor, Register, RegisterArgument, Result, + Return, ReturnValue, Tcs, Usercall, Usercalls as UsercallNrs, EV_RETURNQ_NOT_EMPTY, + EV_UNPARK, EV_USERCALLQ_NOT_FULL, FD_STDERR, FD_STDIN, FD_STDOUT, RESULT_SUCCESS, + USERCALL_USER_DEFINED, WAIT_INDEFINITE, WAIT_NO, }; } } diff --git a/std/src/os/freebsd/fs.rs b/std/src/os/freebsd/fs.rs index 5689a82e00a34..34384a4bcb505 100644 --- a/std/src/os/freebsd/fs.rs +++ b/std/src/os/freebsd/fs.rs @@ -1,10 +1,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::freebsd::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/haiku/fs.rs b/std/src/os/haiku/fs.rs index a23a2af8f6e7b..23f6493180b76 100644 --- a/std/src/os/haiku/fs.rs +++ b/std/src/os/haiku/fs.rs @@ -1,10 +1,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::haiku::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/hermit/io/net.rs b/std/src/os/hermit/io/net.rs index 8f3802d7873dc..7a774345b231a 100644 --- a/std/src/os/hermit/io/net.rs +++ b/std/src/os/hermit/io/net.rs @@ -1,5 +1,4 @@ -use crate::os::hermit::io::OwnedFd; -use crate::os::hermit::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; +use crate::os::hermit::io::{AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; use crate::sys_common::{self, AsInner, FromInner, IntoInner}; use crate::{net, sys}; diff --git a/std/src/os/illumos/fs.rs b/std/src/os/illumos/fs.rs index 63be48b8131b2..75dbe167785db 100644 --- a/std/src/os/illumos/fs.rs +++ b/std/src/os/illumos/fs.rs @@ -1,10 +1,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::illumos::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/ios/mod.rs b/std/src/os/ios/mod.rs index 5e130d77b7bfd..52d592ed95afa 100644 --- a/std/src/os/ios/mod.rs +++ b/std/src/os/ios/mod.rs @@ -7,7 +7,6 @@ pub mod fs { #[doc(inline)] #[stable(feature = "file_set_times", since = "1.75.0")] pub use crate::os::darwin::fs::FileTimesExt; - #[doc(inline)] #[stable(feature = "metadata_ext", since = "1.1.0")] pub use crate::os::darwin::fs::MetadataExt; diff --git a/std/src/os/l4re/fs.rs b/std/src/os/l4re/fs.rs index 6d6a535b1e831..0511ddcf19af6 100644 --- a/std/src/os/l4re/fs.rs +++ b/std/src/os/l4re/fs.rs @@ -5,10 +5,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::l4re::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/linux/fs.rs b/std/src/os/linux/fs.rs index ab0b2a3eda3f5..20a7a161a2628 100644 --- a/std/src/os/linux/fs.rs +++ b/std/src/os/linux/fs.rs @@ -5,10 +5,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::linux::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/linux/net.rs b/std/src/os/linux/net.rs index f898e70548706..1de120c8fd366 100644 --- a/std/src/os/linux/net.rs +++ b/std/src/os/linux/net.rs @@ -4,9 +4,7 @@ #[stable(feature = "unix_socket_abstract", since = "1.70.0")] pub use crate::os::net::linux_ext::addr::SocketAddrExt; - #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] pub use crate::os::net::linux_ext::socket::UnixSocketExt; - #[unstable(feature = "tcp_quickack", issue = "96256")] pub use crate::os::net::linux_ext::tcp::TcpStreamExt; diff --git a/std/src/os/macos/mod.rs b/std/src/os/macos/mod.rs index 3638406b1807d..59fe90834c2b4 100644 --- a/std/src/os/macos/mod.rs +++ b/std/src/os/macos/mod.rs @@ -7,7 +7,6 @@ pub mod fs { #[doc(inline)] #[stable(feature = "file_set_times", since = "1.75.0")] pub use crate::os::darwin::fs::FileTimesExt; - #[doc(inline)] #[stable(feature = "metadata_ext", since = "1.1.0")] pub use crate::os::darwin::fs::MetadataExt; diff --git a/std/src/os/net/linux_ext/tcp.rs b/std/src/os/net/linux_ext/tcp.rs index ff29afe7ed311..c8d012962d45a 100644 --- a/std/src/os/net/linux_ext/tcp.rs +++ b/std/src/os/net/linux_ext/tcp.rs @@ -2,10 +2,9 @@ //! //! [`std::net`]: crate::net -use crate::io; -use crate::net; use crate::sealed::Sealed; use crate::sys_common::AsInner; +use crate::{io, net}; /// Os-specific extensions for [`TcpStream`] /// diff --git a/std/src/os/net/linux_ext/tests.rs b/std/src/os/net/linux_ext/tests.rs index f8dbbfc18e28e..12f35696abc5c 100644 --- a/std/src/os/net/linux_ext/tests.rs +++ b/std/src/os/net/linux_ext/tests.rs @@ -1,9 +1,8 @@ #[test] fn quickack() { - use crate::{ - net::{test::next_test_ip4, TcpListener, TcpStream}, - os::net::linux_ext::tcp::TcpStreamExt, - }; + use crate::net::test::next_test_ip4; + use crate::net::{TcpListener, TcpStream}; + use crate::os::net::linux_ext::tcp::TcpStreamExt; macro_rules! t { ($e:expr) => { @@ -30,10 +29,9 @@ fn quickack() { #[test] #[cfg(target_os = "linux")] fn deferaccept() { - use crate::{ - net::{test::next_test_ip4, TcpListener, TcpStream}, - os::net::linux_ext::tcp::TcpStreamExt, - }; + use crate::net::test::next_test_ip4; + use crate::net::{TcpListener, TcpStream}; + use crate::os::net::linux_ext::tcp::TcpStreamExt; macro_rules! t { ($e:expr) => { diff --git a/std/src/os/netbsd/fs.rs b/std/src/os/netbsd/fs.rs index fe0be069e5e3f..74fbbabb17a5d 100644 --- a/std/src/os/netbsd/fs.rs +++ b/std/src/os/netbsd/fs.rs @@ -1,10 +1,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::netbsd::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/openbsd/fs.rs b/std/src/os/openbsd/fs.rs index b8d8d31c5b8cf..e584098476a7b 100644 --- a/std/src/os/openbsd/fs.rs +++ b/std/src/os/openbsd/fs.rs @@ -1,10 +1,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::openbsd::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/redox/fs.rs b/std/src/os/redox/fs.rs index 682ca6a2c0309..c6b813f0cc6ce 100644 --- a/std/src/os/redox/fs.rs +++ b/std/src/os/redox/fs.rs @@ -1,10 +1,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::redox::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/solaris/fs.rs b/std/src/os/solaris/fs.rs index 0931437370429..9b0527d713891 100644 --- a/std/src/os/solaris/fs.rs +++ b/std/src/os/solaris/fs.rs @@ -1,10 +1,9 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] use crate::fs::Metadata; -use crate::sys_common::AsInner; - #[allow(deprecated)] use crate::os::solaris::raw; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/std/src/os/solid/io.rs b/std/src/os/solid/io.rs index 9834ff6073540..9e89d9fbc1b81 100644 --- a/std/src/os/solid/io.rs +++ b/std/src/os/solid/io.rs @@ -46,12 +46,10 @@ #![unstable(feature = "solid_ext", issue = "none")] -use crate::fmt; use crate::marker::PhantomData; use crate::mem::ManuallyDrop; -use crate::net; -use crate::sys; use crate::sys_common::{self, AsInner, FromInner, IntoInner}; +use crate::{fmt, net, sys}; /// Raw file descriptors. pub type RawFd = i32; diff --git a/std/src/os/uefi/env.rs b/std/src/os/uefi/env.rs index 3248ff98ff2b9..cf8ae697e389d 100644 --- a/std/src/os/uefi/env.rs +++ b/std/src/os/uefi/env.rs @@ -2,8 +2,9 @@ #![unstable(feature = "uefi_std", issue = "100499")] +use crate::ffi::c_void; +use crate::ptr::NonNull; use crate::sync::atomic::{AtomicBool, AtomicPtr, Ordering}; -use crate::{ffi::c_void, ptr::NonNull}; static SYSTEM_TABLE: AtomicPtr = AtomicPtr::new(crate::ptr::null_mut()); static IMAGE_HANDLE: AtomicPtr = AtomicPtr::new(crate::ptr::null_mut()); diff --git a/std/src/os/unix/fs.rs b/std/src/os/unix/fs.rs index 20c472040fadb..caf6980afd91b 100644 --- a/std/src/os/unix/fs.rs +++ b/std/src/os/unix/fs.rs @@ -4,18 +4,18 @@ #![stable(feature = "rust1", since = "1.0.0")] +#[allow(unused_imports)] +use io::{Read, Write}; + use super::platform::fs::MetadataExt as _; +// Used for `File::read` on intra-doc links +use crate::ffi::OsStr; use crate::fs::{self, OpenOptions, Permissions}; -use crate::io; use crate::os::unix::io::{AsFd, AsRawFd}; use crate::path::Path; -use crate::sys; -use crate::sys_common::{AsInner, AsInnerMut, FromInner}; -// Used for `File::read` on intra-doc links -use crate::ffi::OsStr; use crate::sealed::Sealed; -#[allow(unused_imports)] -use io::{Read, Write}; +use crate::sys_common::{AsInner, AsInnerMut, FromInner}; +use crate::{io, sys}; // Tests for this module #[cfg(test)] diff --git a/std/src/os/unix/net/datagram.rs b/std/src/os/unix/net/datagram.rs index f58f9b4d9ab85..a605c3d4a2602 100644 --- a/std/src/os/unix/net/datagram.rs +++ b/std/src/os/unix/net/datagram.rs @@ -1,3 +1,17 @@ +#[cfg(any( + target_os = "linux", + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "openbsd", + target_os = "netbsd", + target_os = "solaris", + target_os = "illumos", + target_os = "haiku", + target_os = "nto", +))] +use libc::MSG_NOSIGNAL; + #[cfg(any(doc, target_os = "android", target_os = "linux"))] use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary}; use super::{sockaddr_un, SocketAddr}; @@ -12,20 +26,6 @@ use crate::sys::net::Socket; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::Duration; use crate::{fmt, io}; - -#[cfg(any( - target_os = "linux", - target_os = "android", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "openbsd", - target_os = "netbsd", - target_os = "solaris", - target_os = "illumos", - target_os = "haiku", - target_os = "nto", -))] -use libc::MSG_NOSIGNAL; #[cfg(not(any( target_os = "linux", target_os = "android", diff --git a/std/src/os/unix/net/tests.rs b/std/src/os/unix/net/tests.rs index e456e41b21c88..21e2176185d25 100644 --- a/std/src/os/unix/net/tests.rs +++ b/std/src/os/unix/net/tests.rs @@ -1,18 +1,16 @@ use super::*; use crate::io::prelude::*; use crate::io::{self, ErrorKind, IoSlice, IoSliceMut}; +#[cfg(target_os = "android")] +use crate::os::android::net::{SocketAddrExt, UnixSocketExt}; +#[cfg(target_os = "linux")] +use crate::os::linux::net::{SocketAddrExt, UnixSocketExt}; #[cfg(any(target_os = "android", target_os = "linux"))] use crate::os::unix::io::AsRawFd; use crate::sys_common::io::test::tmpdir; use crate::thread; use crate::time::Duration; -#[cfg(target_os = "android")] -use crate::os::android::net::{SocketAddrExt, UnixSocketExt}; - -#[cfg(target_os = "linux")] -use crate::os::linux::net::{SocketAddrExt, UnixSocketExt}; - macro_rules! or_panic { ($e:expr) => { match $e { diff --git a/std/src/os/unix/net/ucred.rs b/std/src/os/unix/net/ucred.rs index 1497e730bbf15..b96e373ad0ae3 100644 --- a/std/src/os/unix/net/ucred.rs +++ b/std/src/os/unix/net/ucred.rs @@ -23,9 +23,8 @@ pub struct UCred { pub pid: Option, } -#[cfg(any(target_os = "android", target_os = "linux"))] -pub(super) use self::impl_linux::peer_cred; - +#[cfg(target_vendor = "apple")] +pub(super) use self::impl_apple::peer_cred; #[cfg(any( target_os = "dragonfly", target_os = "freebsd", @@ -34,17 +33,17 @@ pub(super) use self::impl_linux::peer_cred; target_os = "nto" ))] pub(super) use self::impl_bsd::peer_cred; - -#[cfg(target_vendor = "apple")] -pub(super) use self::impl_apple::peer_cred; +#[cfg(any(target_os = "android", target_os = "linux"))] +pub(super) use self::impl_linux::peer_cred; #[cfg(any(target_os = "linux", target_os = "android"))] mod impl_linux { + use libc::{c_void, getsockopt, socklen_t, ucred, SOL_SOCKET, SO_PEERCRED}; + use super::UCred; use crate::os::unix::io::AsRawFd; use crate::os::unix::net::UnixStream; use crate::{io, mem}; - use libc::{c_void, getsockopt, socklen_t, ucred, SOL_SOCKET, SO_PEERCRED}; pub fn peer_cred(socket: &UnixStream) -> io::Result { let ucred_size = mem::size_of::(); @@ -99,11 +98,12 @@ mod impl_bsd { #[cfg(target_vendor = "apple")] mod impl_apple { + use libc::{c_void, getpeereid, getsockopt, pid_t, socklen_t, LOCAL_PEERPID, SOL_LOCAL}; + use super::UCred; use crate::os::unix::io::AsRawFd; use crate::os::unix::net::UnixStream; use crate::{io, mem}; - use libc::{c_void, getpeereid, getsockopt, pid_t, socklen_t, LOCAL_PEERPID, SOL_LOCAL}; pub fn peer_cred(socket: &UnixStream) -> io::Result { let mut cred = UCred { uid: 1, gid: 1, pid: None }; diff --git a/std/src/os/unix/net/ucred/tests.rs b/std/src/os/unix/net/ucred/tests.rs index a6cc81318fc08..59414f4dcae13 100644 --- a/std/src/os/unix/net/ucred/tests.rs +++ b/std/src/os/unix/net/ucred/tests.rs @@ -1,6 +1,7 @@ -use crate::os::unix::net::UnixStream; use libc::{getegid, geteuid, getpid}; +use crate::os::unix::net::UnixStream; + #[test] #[cfg(any( target_os = "android", diff --git a/std/src/os/unix/process.rs b/std/src/os/unix/process.rs index d4a35ad3f8642..c53423675bd00 100644 --- a/std/src/os/unix/process.rs +++ b/std/src/os/unix/process.rs @@ -4,15 +4,13 @@ #![stable(feature = "rust1", since = "1.0.0")] +use cfg_if::cfg_if; + use crate::ffi::OsStr; -use crate::io; use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; -use crate::process; use crate::sealed::Sealed; -use crate::sys; use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; - -use cfg_if::cfg_if; +use crate::{io, process, sys}; cfg_if! { if #[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon", target_os = "vita"))] { diff --git a/std/src/os/wasi/fs.rs b/std/src/os/wasi/fs.rs index a0920a281990a..a58ca543d6777 100644 --- a/std/src/os/wasi/fs.rs +++ b/std/src/os/wasi/fs.rs @@ -5,14 +5,15 @@ #![deny(unsafe_op_in_unsafe_fn)] #![unstable(feature = "wasi_ext", issue = "71213")] +// Used for `File::read` on intra-doc links +#[allow(unused_imports)] +use io::{Read, Write}; + use crate::ffi::OsStr; use crate::fs::{self, File, Metadata, OpenOptions}; use crate::io::{self, IoSlice, IoSliceMut}; use crate::path::{Path, PathBuf}; use crate::sys_common::{AsInner, AsInnerMut, FromInner}; -// Used for `File::read` on intra-doc links -#[allow(unused_imports)] -use io::{Read, Write}; /// WASI-specific extensions to [`File`]. pub trait FileExt { diff --git a/std/src/os/wasi/net/mod.rs b/std/src/os/wasi/net/mod.rs index 73c097d4a50ab..4704dd574517a 100644 --- a/std/src/os/wasi/net/mod.rs +++ b/std/src/os/wasi/net/mod.rs @@ -2,9 +2,8 @@ #![unstable(feature = "wasi_ext", issue = "71213")] -use crate::io; -use crate::net; use crate::sys_common::AsInner; +use crate::{io, net}; /// WASI-specific extensions to [`std::net::TcpListener`]. /// diff --git a/std/src/os/windows/ffi.rs b/std/src/os/windows/ffi.rs index 96bab59d3f8d7..496443dbbc3ac 100644 --- a/std/src/os/windows/ffi.rs +++ b/std/src/os/windows/ffi.rs @@ -56,11 +56,10 @@ use crate::ffi::{OsStr, OsString}; use crate::sealed::Sealed; use crate::sys::os_str::Buf; -use crate::sys_common::wtf8::Wtf8Buf; -use crate::sys_common::{AsInner, FromInner}; - #[stable(feature = "rust1", since = "1.0.0")] pub use crate::sys_common::wtf8::EncodeWide; +use crate::sys_common::wtf8::Wtf8Buf; +use crate::sys_common::{AsInner, FromInner}; /// Windows-specific extensions to [`OsString`]. /// diff --git a/std/src/os/windows/fs.rs b/std/src/os/windows/fs.rs index 8bddeb7310a4d..3dcde43cfec78 100644 --- a/std/src/os/windows/fs.rs +++ b/std/src/os/windows/fs.rs @@ -5,12 +5,11 @@ #![stable(feature = "rust1", since = "1.0.0")] use crate::fs::{self, Metadata, OpenOptions}; -use crate::io; use crate::path::Path; use crate::sealed::Sealed; -use crate::sys; use crate::sys_common::{AsInner, AsInnerMut, IntoInner}; use crate::time::SystemTime; +use crate::{io, sys}; /// Windows-specific extensions to [`fs::File`]. #[stable(feature = "file_offset", since = "1.15.0")] diff --git a/std/src/os/windows/io/handle.rs b/std/src/os/windows/io/handle.rs index 21c0f27c5bb91..a4fa94e2b96a4 100644 --- a/std/src/os/windows/io/handle.rs +++ b/std/src/os/windows/io/handle.rs @@ -3,15 +3,11 @@ #![stable(feature = "io_safety", since = "1.63.0")] use super::raw::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; -use crate::fmt; -use crate::fs; -use crate::io; use crate::marker::PhantomData; use crate::mem::ManuallyDrop; -use crate::ptr; -use crate::sys; use crate::sys::cvt; use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::{fmt, fs, io, ptr, sys}; /// A borrowed handle. /// diff --git a/std/src/os/windows/io/raw.rs b/std/src/os/windows/io/raw.rs index a1888be5f1d90..4ba07e3d2afa5 100644 --- a/std/src/os/windows/io/raw.rs +++ b/std/src/os/windows/io/raw.rs @@ -2,16 +2,12 @@ #![stable(feature = "rust1", since = "1.0.0")] -use crate::fs; -use crate::io; -use crate::net; #[cfg(doc)] use crate::os::windows::io::{AsHandle, AsSocket}; use crate::os::windows::io::{OwnedHandle, OwnedSocket}; use crate::os::windows::raw; -use crate::ptr; -use crate::sys; use crate::sys_common::{self, AsInner, FromInner, IntoInner}; +use crate::{fs, io, net, ptr, sys}; /// Raw HANDLEs. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/std/src/os/windows/io/socket.rs b/std/src/os/windows/io/socket.rs index 5a62177e901bc..1fcfb6e73ad03 100644 --- a/std/src/os/windows/io/socket.rs +++ b/std/src/os/windows/io/socket.rs @@ -3,13 +3,11 @@ #![stable(feature = "io_safety", since = "1.63.0")] use super::raw::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket}; -use crate::fmt; -use crate::io; use crate::marker::PhantomData; use crate::mem::{self, ManuallyDrop}; -use crate::sys; #[cfg(not(target_vendor = "uwp"))] use crate::sys::cvt; +use crate::{fmt, io, sys}; /// A borrowed socket. /// diff --git a/std/src/os/windows/process.rs b/std/src/os/windows/process.rs index af5c13b99e742..c2830d2eb61d1 100644 --- a/std/src/os/windows/process.rs +++ b/std/src/os/windows/process.rs @@ -8,10 +8,9 @@ use crate::ffi::OsStr; use crate::os::windows::io::{ AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle, }; -use crate::process; use crate::sealed::Sealed; -use crate::sys; use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; +use crate::{process, sys}; #[stable(feature = "process_extensions", since = "1.2.0")] impl FromRawHandle for process::Stdio { diff --git a/std/src/os/xous/services.rs b/std/src/os/xous/services.rs index bc4558d9981be..ddf0236f5ad74 100644 --- a/std/src/os/xous/services.rs +++ b/std/src/os/xous/services.rs @@ -1,6 +1,7 @@ -use crate::os::xous::ffi::Connection; use core::sync::atomic::{AtomicU32, Ordering}; +use crate::os::xous::ffi::Connection; + mod dns; pub(crate) use dns::*; diff --git a/std/src/os/xous/services/dns.rs b/std/src/os/xous/services/dns.rs index 6ea453e06360b..0288164839360 100644 --- a/std/src/os/xous/services/dns.rs +++ b/std/src/os/xous/services/dns.rs @@ -1,6 +1,7 @@ +use core::sync::atomic::{AtomicU32, Ordering}; + use crate::os::xous::ffi::Connection; use crate::os::xous::services::connect; -use core::sync::atomic::{AtomicU32, Ordering}; #[repr(usize)] pub(crate) enum DnsLendMut { diff --git a/std/src/os/xous/services/log.rs b/std/src/os/xous/services/log.rs index 0ecc4bcfd146e..1661011ca64b1 100644 --- a/std/src/os/xous/services/log.rs +++ b/std/src/os/xous/services/log.rs @@ -1,6 +1,7 @@ -use crate::os::xous::ffi::Connection; use core::sync::atomic::{AtomicU32, Ordering}; +use crate::os::xous::ffi::Connection; + /// Group a `usize` worth of bytes into a `usize` and return it, beginning from /// `offset` * sizeof(usize) bytes from the start. For example, /// `group_or_null([1,2,3,4,5,6,7,8], 1)` on a 32-bit system will return a diff --git a/std/src/os/xous/services/net.rs b/std/src/os/xous/services/net.rs index c7b9ac9f5d59b..83acc7961b377 100644 --- a/std/src/os/xous/services/net.rs +++ b/std/src/os/xous/services/net.rs @@ -1,6 +1,7 @@ +use core::sync::atomic::{AtomicU32, Ordering}; + use crate::os::xous::ffi::Connection; use crate::os::xous::services::connect; -use core::sync::atomic::{AtomicU32, Ordering}; pub(crate) enum NetBlockingScalar { StdGetTtlUdp(u16 /* fd */), /* 36 */ diff --git a/std/src/os/xous/services/systime.rs b/std/src/os/xous/services/systime.rs index 40f70b4db819b..079ede7aa86c7 100644 --- a/std/src/os/xous/services/systime.rs +++ b/std/src/os/xous/services/systime.rs @@ -1,6 +1,7 @@ -use crate::os::xous::ffi::{connect, Connection}; use core::sync::atomic::{AtomicU32, Ordering}; +use crate::os::xous::ffi::{connect, Connection}; + pub(crate) enum SystimeScalar { GetUtcTimeMs, } diff --git a/std/src/os/xous/services/ticktimer.rs b/std/src/os/xous/services/ticktimer.rs index c94e7710fabd8..66ade6da65cd3 100644 --- a/std/src/os/xous/services/ticktimer.rs +++ b/std/src/os/xous/services/ticktimer.rs @@ -1,6 +1,7 @@ -use crate::os::xous::ffi::Connection; use core::sync::atomic::{AtomicU32, Ordering}; +use crate::os::xous::ffi::Connection; + pub(crate) enum TicktimerScalar { ElapsedMs, SleepMs(usize), diff --git a/std/src/panic.rs b/std/src/panic.rs index b0c7804fd2bed..57ba7c6d407fc 100644 --- a/std/src/panic.rs +++ b/std/src/panic.rs @@ -3,12 +3,10 @@ #![stable(feature = "std_panic", since = "1.9.0")] use crate::any::Any; -use crate::collections; -use crate::fmt; -use crate::panicking; use crate::sync::atomic::{AtomicU8, Ordering}; use crate::sync::{Condvar, Mutex, RwLock}; use crate::thread::Result; +use crate::{collections, fmt, panicking}; #[stable(feature = "panic_hooks", since = "1.10.0")] #[deprecated( @@ -236,18 +234,15 @@ pub macro panic_2015 { #[doc(hidden)] #[unstable(feature = "edition_panic", issue = "none", reason = "use panic!() instead")] pub use core::panic::panic_2021; - #[stable(feature = "panic_hooks", since = "1.10.0")] -pub use crate::panicking::{set_hook, take_hook}; +pub use core::panic::Location; +#[stable(feature = "catch_unwind", since = "1.9.0")] +pub use core::panic::{AssertUnwindSafe, RefUnwindSafe, UnwindSafe}; #[unstable(feature = "panic_update_hook", issue = "92649")] pub use crate::panicking::update_hook; - #[stable(feature = "panic_hooks", since = "1.10.0")] -pub use core::panic::Location; - -#[stable(feature = "catch_unwind", since = "1.9.0")] -pub use core::panic::{AssertUnwindSafe, RefUnwindSafe, UnwindSafe}; +pub use crate::panicking::{set_hook, take_hook}; /// Panics the current thread with the given message as the panic payload. /// diff --git a/std/src/panicking.rs b/std/src/panicking.rs index 418a855fb728e..e818b448270dd 100644 --- a/std/src/panicking.rs +++ b/std/src/panicking.rs @@ -9,26 +9,23 @@ #![deny(unsafe_op_in_unsafe_fn)] -use crate::panic::{BacktraceStyle, PanicHookInfo}; use core::panic::{Location, PanicPayload}; +// make sure to use the stderr output configured +// by libtest in the real copy of std +#[cfg(test)] +use realstd::io::try_set_output_capture; + use crate::any::Any; -use crate::fmt; -use crate::intrinsics; +#[cfg(not(test))] +use crate::io::try_set_output_capture; use crate::mem::{self, ManuallyDrop}; -use crate::process; +use crate::panic::{BacktraceStyle, PanicHookInfo}; use crate::sync::atomic::{AtomicBool, Ordering}; use crate::sync::{PoisonError, RwLock}; use crate::sys::backtrace; use crate::sys::stdio::panic_output; -use crate::thread; - -#[cfg(not(test))] -use crate::io::try_set_output_capture; -// make sure to use the stderr output configured -// by libtest in the real copy of std -#[cfg(test)] -use realstd::io::try_set_output_capture; +use crate::{fmt, intrinsics, process, thread}; // Binary interface to the panic runtime that the standard library depends on. // diff --git a/std/src/path.rs b/std/src/path.rs index 46a1953743ffa..80163667636ae 100644 --- a/std/src/path.rs +++ b/std/src/path.rs @@ -71,22 +71,17 @@ mod tests; use crate::borrow::{Borrow, Cow}; -use crate::cmp; use crate::collections::TryReserveError; use crate::error::Error; -use crate::fmt; -use crate::fs; +use crate::ffi::{os_str, OsStr, OsString}; use crate::hash::{Hash, Hasher}; -use crate::io; use crate::iter::FusedIterator; use crate::ops::{self, Deref}; use crate::rc::Rc; use crate::str::FromStr; use crate::sync::Arc; - -use crate::ffi::{os_str, OsStr, OsString}; -use crate::sys; use crate::sys::path::{is_sep_byte, is_verbatim_sep, parse_prefix, MAIN_SEP_STR}; +use crate::{cmp, fmt, fs, io, sys}; //////////////////////////////////////////////////////////////////////////////// // GENERAL NOTES diff --git a/std/src/path/tests.rs b/std/src/path/tests.rs index 3ade4fb892f5e..a12e42cba0c5c 100644 --- a/std/src/path/tests.rs +++ b/std/src/path/tests.rs @@ -1,8 +1,8 @@ -use super::*; +use core::hint::black_box; +use super::*; use crate::collections::{BTreeSet, HashSet}; use crate::hash::DefaultHasher; -use core::hint::black_box; #[allow(unknown_lints, unused_macro_rules)] macro_rules! t ( diff --git a/std/src/pipe.rs b/std/src/pipe.rs index f251b57a7cca6..aa4c7014fe918 100644 --- a/std/src/pipe.rs +++ b/std/src/pipe.rs @@ -11,10 +11,8 @@ //! # } //! ``` -use crate::{ - io, - sys::anonymous_pipe::{pipe as pipe_inner, AnonPipe}, -}; +use crate::io; +use crate::sys::anonymous_pipe::{pipe as pipe_inner, AnonPipe}; /// Create anonymous pipe that is close-on-exec and blocking. #[unstable(feature = "anonymous_pipe", issue = "127154")] diff --git a/std/src/process.rs b/std/src/process.rs index a2222bd11b1d0..9ffdebe1b6ffe 100644 --- a/std/src/process.rs +++ b/std/src/process.rs @@ -151,21 +151,18 @@ #[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx", target_os = "xous"))))] mod tests; -use crate::io::prelude::*; - use crate::convert::Infallible; use crate::ffi::OsStr; -use crate::fmt; -use crate::fs; +use crate::io::prelude::*; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; use crate::num::NonZero; use crate::path::Path; -use crate::str; use crate::sys::pipe::{read2, AnonPipe}; use crate::sys::process as imp; #[stable(feature = "command_access", since = "1.57.0")] pub use crate::sys_common::process::CommandEnvs; use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; +use crate::{fmt, fs, str}; /// Representation of a running or exited child process. /// diff --git a/std/src/process/tests.rs b/std/src/process/tests.rs index 055601d030799..f8e8e0dea553b 100644 --- a/std/src/process/tests.rs +++ b/std/src/process/tests.rs @@ -1,6 +1,5 @@ -use crate::io::prelude::*; - use super::{Command, Output, Stdio}; +use crate::io::prelude::*; use crate::io::{BorrowedBuf, ErrorKind}; use crate::mem::MaybeUninit; use crate::str; diff --git a/std/src/sync/lazy_lock.rs b/std/src/sync/lazy_lock.rs index 9fe9ccab4a9f7..953aef40e7b76 100644 --- a/std/src/sync/lazy_lock.rs +++ b/std/src/sync/lazy_lock.rs @@ -1,3 +1,4 @@ +use super::once::ExclusiveState; use crate::cell::UnsafeCell; use crate::mem::ManuallyDrop; use crate::ops::Deref; @@ -5,8 +6,6 @@ use crate::panic::{RefUnwindSafe, UnwindSafe}; use crate::sync::Once; use crate::{fmt, ptr}; -use super::once::ExclusiveState; - // We use the state of a Once as discriminant value. Upon creation, the state is // "incomplete" and `f` contains the initialization closure. In the first call to // `call_once`, `f` is taken and run. If it succeeds, `value` is set and the state diff --git a/std/src/sync/lazy_lock/tests.rs b/std/src/sync/lazy_lock/tests.rs index a5d4e25c5962a..8a6ab4ac4fd99 100644 --- a/std/src/sync/lazy_lock/tests.rs +++ b/std/src/sync/lazy_lock/tests.rs @@ -1,13 +1,8 @@ -use crate::{ - cell::LazyCell, - panic, - sync::{ - atomic::{AtomicUsize, Ordering::SeqCst}, - Mutex, - }, - sync::{LazyLock, OnceLock}, - thread, -}; +use crate::cell::LazyCell; +use crate::sync::atomic::AtomicUsize; +use crate::sync::atomic::Ordering::SeqCst; +use crate::sync::{LazyLock, Mutex, OnceLock}; +use crate::{panic, thread}; fn spawn_and_wait(f: impl FnOnce() -> R + Send + 'static) -> R { thread::spawn(f).join().unwrap() diff --git a/std/src/sync/mod.rs b/std/src/sync/mod.rs index 9a38c42f43a02..d0ba8cc3b47df 100644 --- a/std/src/sync/mod.rs +++ b/std/src/sync/mod.rs @@ -158,17 +158,20 @@ #![stable(feature = "rust1", since = "1.0.0")] -#[stable(feature = "rust1", since = "1.0.0")] -pub use alloc_crate::sync::{Arc, Weak}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::sync::atomic; #[unstable(feature = "exclusive_wrapper", issue = "98407")] pub use core::sync::Exclusive; +#[stable(feature = "rust1", since = "1.0.0")] +pub use alloc_crate::sync::{Arc, Weak}; + #[stable(feature = "rust1", since = "1.0.0")] pub use self::barrier::{Barrier, BarrierWaitResult}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::condvar::{Condvar, WaitTimeoutResult}; +#[stable(feature = "lazy_cell", since = "1.80.0")] +pub use self::lazy_lock::LazyLock; #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub use self::mutex::MappedMutexGuard; #[stable(feature = "rust1", since = "1.0.0")] @@ -176,21 +179,17 @@ pub use self::mutex::{Mutex, MutexGuard}; #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)] pub use self::once::{Once, OnceState, ONCE_INIT}; +#[stable(feature = "once_cell", since = "1.70.0")] +pub use self::once_lock::OnceLock; #[stable(feature = "rust1", since = "1.0.0")] pub use self::poison::{LockResult, PoisonError, TryLockError, TryLockResult}; +#[unstable(feature = "reentrant_lock", issue = "121440")] +pub use self::reentrant_lock::{ReentrantLock, ReentrantLockGuard}; #[unstable(feature = "mapped_lock_guards", issue = "117108")] pub use self::rwlock::{MappedRwLockReadGuard, MappedRwLockWriteGuard}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard}; -#[stable(feature = "lazy_cell", since = "1.80.0")] -pub use self::lazy_lock::LazyLock; -#[stable(feature = "once_cell", since = "1.70.0")] -pub use self::once_lock::OnceLock; - -#[unstable(feature = "reentrant_lock", issue = "121440")] -pub use self::reentrant_lock::{ReentrantLock, ReentrantLockGuard}; - pub mod mpsc; mod barrier; diff --git a/std/src/sync/mpmc/array.rs b/std/src/sync/mpmc/array.rs index 185319add745f..34acd9c9a943b 100644 --- a/std/src/sync/mpmc/array.rs +++ b/std/src/sync/mpmc/array.rs @@ -13,7 +13,6 @@ use super::error::*; use super::select::{Operation, Selected, Token}; use super::utils::{Backoff, CachePadded}; use super::waker::SyncWaker; - use crate::cell::UnsafeCell; use crate::mem::MaybeUninit; use crate::ptr; diff --git a/std/src/sync/mpmc/context.rs b/std/src/sync/mpmc/context.rs index bbfc6ce00ffc2..8db3c9896eb77 100644 --- a/std/src/sync/mpmc/context.rs +++ b/std/src/sync/mpmc/context.rs @@ -2,7 +2,6 @@ use super::select::Selected; use super::waker::current_thread_id; - use crate::cell::Cell; use crate::ptr; use crate::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; diff --git a/std/src/sync/mpmc/counter.rs b/std/src/sync/mpmc/counter.rs index 3478cf41dc9d2..d1bfe612f536f 100644 --- a/std/src/sync/mpmc/counter.rs +++ b/std/src/sync/mpmc/counter.rs @@ -1,6 +1,5 @@ -use crate::ops; -use crate::process; use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; +use crate::{ops, process}; /// Reference counter internals. struct Counter { diff --git a/std/src/sync/mpmc/error.rs b/std/src/sync/mpmc/error.rs index 33b2bff853498..e3aec7e76232f 100644 --- a/std/src/sync/mpmc/error.rs +++ b/std/src/sync/mpmc/error.rs @@ -1,7 +1,5 @@ -use crate::error; -use crate::fmt; - pub use crate::sync::mpsc::{RecvError, RecvTimeoutError, SendError, TryRecvError, TrySendError}; +use crate::{error, fmt}; /// An error returned from the [`send_timeout`] method. /// diff --git a/std/src/sync/mpmc/list.rs b/std/src/sync/mpmc/list.rs index edac7a0cb1835..bbe205cad04e6 100644 --- a/std/src/sync/mpmc/list.rs +++ b/std/src/sync/mpmc/list.rs @@ -5,7 +5,6 @@ use super::error::*; use super::select::{Operation, Selected, Token}; use super::utils::{Backoff, CachePadded}; use super::waker::SyncWaker; - use crate::cell::UnsafeCell; use crate::marker::PhantomData; use crate::mem::MaybeUninit; diff --git a/std/src/sync/mpmc/mod.rs b/std/src/sync/mpmc/mod.rs index 2068dda393a2b..c640e07348ea0 100644 --- a/std/src/sync/mpmc/mod.rs +++ b/std/src/sync/mpmc/mod.rs @@ -40,10 +40,11 @@ mod utils; mod waker; mod zero; +pub use error::*; + use crate::fmt; use crate::panic::{RefUnwindSafe, UnwindSafe}; use crate::time::{Duration, Instant}; -pub use error::*; /// Creates a channel of unbounded capacity. /// diff --git a/std/src/sync/mpmc/waker.rs b/std/src/sync/mpmc/waker.rs index 9aab1b9417edb..fb877887f9c9d 100644 --- a/std/src/sync/mpmc/waker.rs +++ b/std/src/sync/mpmc/waker.rs @@ -2,7 +2,6 @@ use super::context::Context; use super::select::{Operation, Selected}; - use crate::ptr; use crate::sync::atomic::{AtomicBool, Ordering}; use crate::sync::Mutex; diff --git a/std/src/sync/mpmc/zero.rs b/std/src/sync/mpmc/zero.rs index 6d1c9d64e7a7a..2b82eeda3d5fb 100644 --- a/std/src/sync/mpmc/zero.rs +++ b/std/src/sync/mpmc/zero.rs @@ -7,7 +7,6 @@ use super::error::*; use super::select::{Operation, Selected, Token}; use super::utils::Backoff; use super::waker::Waker; - use crate::cell::UnsafeCell; use crate::marker::PhantomData; use crate::sync::atomic::{AtomicBool, Ordering}; diff --git a/std/src/sync/mpsc/mod.rs b/std/src/sync/mpsc/mod.rs index feee6948db4fd..26d5b9515a244 100644 --- a/std/src/sync/mpsc/mod.rs +++ b/std/src/sync/mpsc/mod.rs @@ -148,10 +148,9 @@ mod sync_tests; // not exposed publicly, but if you are curious about the implementation, // that's where everything is. -use crate::error; -use crate::fmt; use crate::sync::mpmc; use crate::time::{Duration, Instant}; +use crate::{error, fmt}; /// The receiving half of Rust's [`channel`] (or [`sync_channel`]) type. /// This half can only be owned by one thread. diff --git a/std/src/sync/mpsc/sync_tests.rs b/std/src/sync/mpsc/sync_tests.rs index 945de280f40d8..49b65c8efe692 100644 --- a/std/src/sync/mpsc/sync_tests.rs +++ b/std/src/sync/mpsc/sync_tests.rs @@ -1,8 +1,7 @@ use super::*; -use crate::env; use crate::rc::Rc; use crate::sync::mpmc::SendTimeoutError; -use crate::thread; +use crate::{env, thread}; pub fn stress_factor() -> usize { match env::var("RUST_TEST_STRESS") { diff --git a/std/src/sync/mpsc/tests.rs b/std/src/sync/mpsc/tests.rs index ac1a804cf9c84..13892fa0d18e4 100644 --- a/std/src/sync/mpsc/tests.rs +++ b/std/src/sync/mpsc/tests.rs @@ -1,6 +1,5 @@ use super::*; -use crate::env; -use crate::thread; +use crate::{env, thread}; pub fn stress_factor() -> usize { match env::var("RUST_TEST_STRESS") { diff --git a/std/src/sync/once/tests.rs b/std/src/sync/once/tests.rs index 0c35597e11c51..d43dabc1cf137 100644 --- a/std/src/sync/once/tests.rs +++ b/std/src/sync/once/tests.rs @@ -1,7 +1,6 @@ use super::Once; -use crate::panic; use crate::sync::mpsc::channel; -use crate::thread; +use crate::{panic, thread}; #[test] fn smoke_once() { diff --git a/std/src/sync/once_lock/tests.rs b/std/src/sync/once_lock/tests.rs index d5d32e73d8880..176830c6748b2 100644 --- a/std/src/sync/once_lock/tests.rs +++ b/std/src/sync/once_lock/tests.rs @@ -1,12 +1,8 @@ -use crate::{ - panic, - sync::OnceLock, - sync::{ - atomic::{AtomicUsize, Ordering::SeqCst}, - mpsc::channel, - }, - thread, -}; +use crate::sync::atomic::AtomicUsize; +use crate::sync::atomic::Ordering::SeqCst; +use crate::sync::mpsc::channel; +use crate::sync::OnceLock; +use crate::{panic, thread}; fn spawn_and_wait(f: impl FnOnce() -> R + Send + 'static) -> R { thread::spawn(f).join().unwrap() diff --git a/std/src/sync/poison.rs b/std/src/sync/poison.rs index d71643b500073..da66a088e51b1 100644 --- a/std/src/sync/poison.rs +++ b/std/src/sync/poison.rs @@ -1,6 +1,5 @@ use crate::error::Error; use crate::fmt; - #[cfg(panic = "unwind")] use crate::sync::atomic::{AtomicBool, Ordering}; #[cfg(panic = "unwind")] diff --git a/std/src/sync/rwlock/tests.rs b/std/src/sync/rwlock/tests.rs index 9cc5e7a3a60f1..12bb0fbf0503b 100644 --- a/std/src/sync/rwlock/tests.rs +++ b/std/src/sync/rwlock/tests.rs @@ -1,3 +1,5 @@ +use rand::Rng; + use crate::sync::atomic::{AtomicUsize, Ordering}; use crate::sync::mpsc::channel; use crate::sync::{ @@ -5,7 +7,6 @@ use crate::sync::{ TryLockError, }; use crate::thread; -use rand::Rng; #[derive(Eq, PartialEq, Debug)] struct NonCopy(i32); diff --git a/std/src/sys/anonymous_pipe/tests.rs b/std/src/sys/anonymous_pipe/tests.rs index f5ea583eefe0d..865d24ec85596 100644 --- a/std/src/sys/anonymous_pipe/tests.rs +++ b/std/src/sys/anonymous_pipe/tests.rs @@ -1,7 +1,5 @@ -use crate::{ - io::{Read, Write}, - pipe::pipe, -}; +use crate::io::{Read, Write}; +use crate::pipe::pipe; #[test] fn pipe_creation_clone_and_rw() { diff --git a/std/src/sys/anonymous_pipe/unix.rs b/std/src/sys/anonymous_pipe/unix.rs index ddbf1d7334fe0..7c0e75208c43c 100644 --- a/std/src/sys/anonymous_pipe/unix.rs +++ b/std/src/sys/anonymous_pipe/unix.rs @@ -1,11 +1,10 @@ -use crate::{ - io, - os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}, - pipe::{PipeReader, PipeWriter}, - process::Stdio, - sys::{fd::FileDesc, pipe::anon_pipe}, - sys_common::{FromInner, IntoInner}, -}; +use crate::io; +use crate::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; +use crate::pipe::{PipeReader, PipeWriter}; +use crate::process::Stdio; +use crate::sys::fd::FileDesc; +use crate::sys::pipe::anon_pipe; +use crate::sys_common::{FromInner, IntoInner}; pub(crate) type AnonPipe = FileDesc; diff --git a/std/src/sys/anonymous_pipe/unsupported.rs b/std/src/sys/anonymous_pipe/unsupported.rs index 5962b69203ee2..f3c826d2f8dfb 100644 --- a/std/src/sys/anonymous_pipe/unsupported.rs +++ b/std/src/sys/anonymous_pipe/unsupported.rs @@ -1,9 +1,6 @@ -use crate::{ - io, - pipe::{PipeReader, PipeWriter}, - process::Stdio, -}; - +use crate::io; +use crate::pipe::{PipeReader, PipeWriter}; +use crate::process::Stdio; pub(crate) use crate::sys::pipe::AnonPipe; #[inline] diff --git a/std/src/sys/anonymous_pipe/windows.rs b/std/src/sys/anonymous_pipe/windows.rs index 81f95aa286a9c..0f746b1082baf 100644 --- a/std/src/sys/anonymous_pipe/windows.rs +++ b/std/src/sys/anonymous_pipe/windows.rs @@ -1,13 +1,12 @@ -use crate::{ - io, - os::windows::io::{ - AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle, - }, - pipe::{PipeReader, PipeWriter}, - process::Stdio, - sys::{handle::Handle, pipe::unnamed_anon_pipe}, - sys_common::{FromInner, IntoInner}, +use crate::io; +use crate::os::windows::io::{ + AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle, }; +use crate::pipe::{PipeReader, PipeWriter}; +use crate::process::Stdio; +use crate::sys::handle::Handle; +use crate::sys::pipe::unnamed_anon_pipe; +use crate::sys_common::{FromInner, IntoInner}; pub(crate) type AnonPipe = Handle; diff --git a/std/src/sys/backtrace.rs b/std/src/sys/backtrace.rs index 133ea520e30c7..4d939e175cf2e 100644 --- a/std/src/sys/backtrace.rs +++ b/std/src/sys/backtrace.rs @@ -3,12 +3,10 @@ use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt}; use crate::borrow::Cow; -use crate::env; -use crate::fmt; -use crate::io; use crate::io::prelude::*; use crate::path::{self, Path, PathBuf}; use crate::sync::{Mutex, MutexGuard, PoisonError}; +use crate::{env, fmt, io}; /// Max number of frames to print. const MAX_NB_FRAMES: usize = 100; diff --git a/std/src/sys/os_str/bytes.rs b/std/src/sys/os_str/bytes.rs index 2a7477e3afc20..0f8bd6453528e 100644 --- a/std/src/sys/os_str/bytes.rs +++ b/std/src/sys/os_str/bytes.rs @@ -3,13 +3,11 @@ use crate::borrow::Cow; use crate::collections::TryReserveError; -use crate::fmt; use crate::fmt::Write; -use crate::mem; use crate::rc::Rc; -use crate::str; use crate::sync::Arc; use crate::sys_common::{AsInner, IntoInner}; +use crate::{fmt, mem, str}; #[cfg(test)] mod tests; diff --git a/std/src/sys/os_str/wtf8.rs b/std/src/sys/os_str/wtf8.rs index 806bf033dbc94..ed975ba58b5e2 100644 --- a/std/src/sys/os_str/wtf8.rs +++ b/std/src/sys/os_str/wtf8.rs @@ -2,12 +2,11 @@ //! wrapper around the "WTF-8" encoding; see the `wtf8` module for more. use crate::borrow::Cow; use crate::collections::TryReserveError; -use crate::fmt; -use crate::mem; use crate::rc::Rc; use crate::sync::Arc; use crate::sys_common::wtf8::{check_utf8_boundary, Wtf8, Wtf8Buf}; use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::{fmt, mem}; #[derive(Clone, Hash)] pub struct Buf { diff --git a/std/src/sys/pal/common/alloc.rs b/std/src/sys/pal/common/alloc.rs index 54506c3229675..1b465f95d1bc3 100644 --- a/std/src/sys/pal/common/alloc.rs +++ b/std/src/sys/pal/common/alloc.rs @@ -1,7 +1,6 @@ #![forbid(unsafe_op_in_unsafe_fn)] use crate::alloc::{GlobalAlloc, Layout, System}; -use crate::cmp; -use crate::ptr; +use crate::{cmp, ptr}; // The minimum alignment guaranteed by the architecture. This value is used to // add fast paths for low alignment values. diff --git a/std/src/sys/pal/common/small_c_string.rs b/std/src/sys/pal/common/small_c_string.rs index 37812fc0659a2..3c96714b5c58c 100644 --- a/std/src/sys/pal/common/small_c_string.rs +++ b/std/src/sys/pal/common/small_c_string.rs @@ -1,8 +1,7 @@ use crate::ffi::{CStr, CString}; use crate::mem::MaybeUninit; use crate::path::Path; -use crate::slice; -use crate::{io, ptr}; +use crate::{io, ptr, slice}; // Make sure to stay under 4096 so the compiler doesn't insert a probe frame: // https://docs.rs/compiler_builtins/latest/compiler_builtins/probestack/index.html diff --git a/std/src/sys/pal/common/tests.rs b/std/src/sys/pal/common/tests.rs index e72d02203da10..b7698907070c7 100644 --- a/std/src/sys/pal/common/tests.rs +++ b/std/src/sys/pal/common/tests.rs @@ -1,8 +1,9 @@ +use core::iter::repeat; + use crate::ffi::CString; use crate::hint::black_box; use crate::path::Path; use crate::sys::common::small_c_string::run_path_with_cstr; -use core::iter::repeat; #[test] fn stack_allocation_works() { diff --git a/std/src/sys/pal/hermit/args.rs b/std/src/sys/pal/hermit/args.rs index 220a76e4b1237..51afe3434aedc 100644 --- a/std/src/sys/pal/hermit/args.rs +++ b/std/src/sys/pal/hermit/args.rs @@ -1,12 +1,8 @@ use crate::ffi::{c_char, CStr, OsString}; -use crate::fmt; use crate::os::hermit::ffi::OsStringExt; -use crate::ptr; -use crate::sync::atomic::{ - AtomicIsize, AtomicPtr, - Ordering::{Acquire, Relaxed, Release}, -}; -use crate::vec; +use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; +use crate::sync::atomic::{AtomicIsize, AtomicPtr}; +use crate::{fmt, ptr, vec}; static ARGC: AtomicIsize = AtomicIsize::new(0); static ARGV: AtomicPtr<*const u8> = AtomicPtr::new(ptr::null_mut()); diff --git a/std/src/sys/pal/hermit/fd.rs b/std/src/sys/pal/hermit/fd.rs index 3c52b85de23a2..bdcf880484dfc 100644 --- a/std/src/sys/pal/hermit/fd.rs +++ b/std/src/sys/pal/hermit/fd.rs @@ -3,13 +3,10 @@ use super::hermit_abi; use crate::cmp; use crate::io::{self, IoSlice, IoSliceMut, Read}; -use crate::os::hermit::io::{FromRawFd, OwnedFd, RawFd}; -use crate::sys::cvt; -use crate::sys::unsupported; +use crate::os::hermit::io::{FromRawFd, OwnedFd, RawFd, *}; +use crate::sys::{cvt, unsupported}; use crate::sys_common::{AsInner, FromInner, IntoInner}; -use crate::os::hermit::io::*; - const fn max_iov() -> usize { hermit_abi::IOV_MAX } diff --git a/std/src/sys/pal/hermit/fs.rs b/std/src/sys/pal/hermit/fs.rs index e4e9eee044efa..cbdb942ac58ef 100644 --- a/std/src/sys/pal/hermit/fs.rs +++ b/std/src/sys/pal/hermit/fs.rs @@ -4,21 +4,17 @@ use super::hermit_abi::{ O_DIRECTORY, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, }; use crate::ffi::{CStr, OsStr, OsString}; -use crate::fmt; -use crate::io::{self, Error, ErrorKind}; -use crate::io::{BorrowedCursor, IoSlice, IoSliceMut, SeekFrom}; -use crate::mem; +use crate::io::{self, BorrowedCursor, Error, ErrorKind, IoSlice, IoSliceMut, SeekFrom}; use crate::os::hermit::ffi::OsStringExt; use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use crate::path::{Path, PathBuf}; use crate::sync::Arc; use crate::sys::common::small_c_string::run_path_with_cstr; -use crate::sys::cvt; use crate::sys::time::SystemTime; -use crate::sys::unsupported; -use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; - +use crate::sys::{cvt, unsupported}; pub use crate::sys_common::fs::{copy, exists}; +use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; +use crate::{fmt, mem}; #[derive(Debug)] pub struct File(FileDesc); diff --git a/std/src/sys/pal/hermit/io.rs b/std/src/sys/pal/hermit/io.rs index 9de7b53e53c03..aad1eef71e9b0 100644 --- a/std/src/sys/pal/hermit/io.rs +++ b/std/src/sys/pal/hermit/io.rs @@ -1,9 +1,9 @@ +use hermit_abi::{c_void, iovec}; + use crate::marker::PhantomData; use crate::os::hermit::io::{AsFd, AsRawFd}; use crate::slice; -use hermit_abi::{c_void, iovec}; - #[derive(Copy, Clone)] #[repr(transparent)] pub struct IoSlice<'a> { diff --git a/std/src/sys/pal/hermit/net.rs b/std/src/sys/pal/hermit/net.rs index 6016d50eba085..416469c003738 100644 --- a/std/src/sys/pal/hermit/net.rs +++ b/std/src/sys/pal/hermit/net.rs @@ -1,17 +1,16 @@ #![allow(dead_code)] +use core::ffi::c_int; + use super::fd::FileDesc; -use crate::cmp; use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; -use crate::mem; use crate::net::{Shutdown, SocketAddr}; use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd}; use crate::sys::time::Instant; use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::Duration; - -use core::ffi::c_int; +use crate::{cmp, mem}; #[allow(unused_extern_crates)] pub extern crate hermit_abi as netc; diff --git a/std/src/sys/pal/hermit/os.rs b/std/src/sys/pal/hermit/os.rs index a7a73c756f216..9631dac658c9c 100644 --- a/std/src/sys/pal/hermit/os.rs +++ b/std/src/sys/pal/hermit/os.rs @@ -1,17 +1,15 @@ +use core::slice::memchr; + use super::hermit_abi; use crate::collections::HashMap; use crate::error::Error as StdError; use crate::ffi::{CStr, OsStr, OsString}; -use crate::fmt; -use crate::io; use crate::marker::PhantomData; use crate::os::hermit::ffi::OsStringExt; use crate::path::{self, PathBuf}; -use crate::str; use crate::sync::Mutex; use crate::sys::unsupported; -use crate::vec; -use core::slice::memchr; +use crate::{fmt, io, str, vec}; pub fn errno() -> i32 { unsafe { hermit_abi::get_errno() } diff --git a/std/src/sys/pal/hermit/thread.rs b/std/src/sys/pal/hermit/thread.rs index 3723f03081c17..95c13e53b470b 100644 --- a/std/src/sys/pal/hermit/thread.rs +++ b/std/src/sys/pal/hermit/thread.rs @@ -2,11 +2,10 @@ use super::hermit_abi; use crate::ffi::CStr; -use crate::io; use crate::mem::ManuallyDrop; use crate::num::NonZero; -use crate::ptr; use crate::time::Duration; +use crate::{io, ptr}; pub type Tid = hermit_abi::Tid; diff --git a/std/src/sys/pal/hermit/time.rs b/std/src/sys/pal/hermit/time.rs index e0cb7c2aa98a5..2c87c4860a27a 100644 --- a/std/src/sys/pal/hermit/time.rs +++ b/std/src/sys/pal/hermit/time.rs @@ -1,10 +1,11 @@ #![allow(dead_code)] +use core::hash::{Hash, Hasher}; + use super::hermit_abi::{self, timespec, CLOCK_MONOTONIC, CLOCK_REALTIME}; use crate::cmp::Ordering; use crate::ops::{Add, AddAssign, Sub, SubAssign}; use crate::time::Duration; -use core::hash::{Hash, Hasher}; const NSEC_PER_SEC: i32 = 1_000_000_000; diff --git a/std/src/sys/pal/itron/error.rs b/std/src/sys/pal/itron/error.rs index dab0aa7b92de3..8ff3017c61471 100644 --- a/std/src/sys/pal/itron/error.rs +++ b/std/src/sys/pal/itron/error.rs @@ -1,6 +1,6 @@ -use crate::{fmt, io::ErrorKind}; - use super::abi; +use crate::fmt; +use crate::io::ErrorKind; /// Wraps a μITRON error code. #[derive(Debug, Copy, Clone)] diff --git a/std/src/sys/pal/itron/spin.rs b/std/src/sys/pal/itron/spin.rs index 44d409444bca4..6a9a7c72deb7d 100644 --- a/std/src/sys/pal/itron/spin.rs +++ b/std/src/sys/pal/itron/spin.rs @@ -1,9 +1,7 @@ use super::abi; -use crate::{ - cell::UnsafeCell, - mem::MaybeUninit, - sync::atomic::{AtomicBool, AtomicUsize, Ordering}, -}; +use crate::cell::UnsafeCell; +use crate::mem::MaybeUninit; +use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; /// A mutex implemented by `dis_dsp` (for intra-core synchronization) and a /// spinlock (for inter-core synchronization). diff --git a/std/src/sys/pal/itron/task.rs b/std/src/sys/pal/itron/task.rs index 82b9b9bfd3ae4..5da0c5917885f 100644 --- a/std/src/sys/pal/itron/task.rs +++ b/std/src/sys/pal/itron/task.rs @@ -1,8 +1,5 @@ -use super::{ - abi, - error::{fail, fail_aborting, ItronError}, -}; - +use super::abi; +use super::error::{fail, fail_aborting, ItronError}; use crate::mem::MaybeUninit; /// Gets the ID of the task in Running state. Panics on failure. diff --git a/std/src/sys/pal/itron/thread.rs b/std/src/sys/pal/itron/thread.rs index 83581037706d6..01e69afa99e13 100644 --- a/std/src/sys/pal/itron/thread.rs +++ b/std/src/sys/pal/itron/thread.rs @@ -1,22 +1,17 @@ //! Thread implementation backed by μITRON tasks. Assumes `acre_tsk` and //! `exd_tsk` are available. -use super::{ - abi, - error::{expect_success, expect_success_aborting, ItronError}, - task, - time::dur2reltims, -}; -use crate::{ - cell::UnsafeCell, - ffi::CStr, - hint, io, - mem::ManuallyDrop, - num::NonZero, - ptr::NonNull, - sync::atomic::{AtomicUsize, Ordering}, - time::Duration, -}; +use super::error::{expect_success, expect_success_aborting, ItronError}; +use super::time::dur2reltims; +use super::{abi, task}; +use crate::cell::UnsafeCell; +use crate::ffi::CStr; +use crate::mem::ManuallyDrop; +use crate::num::NonZero; +use crate::ptr::NonNull; +use crate::sync::atomic::{AtomicUsize, Ordering}; +use crate::time::Duration; +use crate::{hint, io}; pub struct Thread { p_inner: NonNull, diff --git a/std/src/sys/pal/itron/time.rs b/std/src/sys/pal/itron/time.rs index 427ea0d80e107..7976c27f4952b 100644 --- a/std/src/sys/pal/itron/time.rs +++ b/std/src/sys/pal/itron/time.rs @@ -1,5 +1,7 @@ -use super::{abi, error::expect_success}; -use crate::{mem::MaybeUninit, time::Duration}; +use super::abi; +use super::error::expect_success; +use crate::mem::MaybeUninit; +use crate::time::Duration; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] pub struct Instant(abi::SYSTIM); diff --git a/std/src/sys/pal/sgx/abi/mod.rs b/std/src/sys/pal/sgx/abi/mod.rs index 9508c38741551..d8836452e7555 100644 --- a/std/src/sys/pal/sgx/abi/mod.rs +++ b/std/src/sys/pal/sgx/abi/mod.rs @@ -1,9 +1,10 @@ #![cfg_attr(test, allow(unused))] // RT initialization logic is not compiled for test -use crate::io::Write; use core::arch::global_asm; use core::sync::atomic::{AtomicUsize, Ordering}; +use crate::io::Write; + // runtime features pub(super) mod panic; mod reloc; diff --git a/std/src/sys/pal/sgx/abi/panic.rs b/std/src/sys/pal/sgx/abi/panic.rs index 229b3b3291f63..c06b97ee3674a 100644 --- a/std/src/sys/pal/sgx/abi/panic.rs +++ b/std/src/sys/pal/sgx/abi/panic.rs @@ -1,7 +1,6 @@ use super::usercalls::alloc::UserRef; -use crate::cmp; use crate::io::{self, Write}; -use crate::mem; +use crate::{cmp, mem}; extern "C" { fn take_debug_panic_buf_ptr() -> *mut u8; diff --git a/std/src/sys/pal/sgx/abi/tls/mod.rs b/std/src/sys/pal/sgx/abi/tls/mod.rs index bab59a3422d15..34fc2f20d2214 100644 --- a/std/src/sys/pal/sgx/abi/tls/mod.rs +++ b/std/src/sys/pal/sgx/abi/tls/mod.rs @@ -2,10 +2,9 @@ mod sync_bitset; use self::sync_bitset::*; use crate::cell::Cell; -use crate::mem; use crate::num::NonZero; -use crate::ptr; use crate::sync::atomic::{AtomicUsize, Ordering}; +use crate::{mem, ptr}; #[cfg(target_pointer_width = "64")] const USIZE_BITS: usize = 64; diff --git a/std/src/sys/pal/sgx/abi/usercalls/alloc.rs b/std/src/sys/pal/sgx/abi/usercalls/alloc.rs index cf3ce60dc3d3c..298095257396a 100644 --- a/std/src/sys/pal/sgx/abi/usercalls/alloc.rs +++ b/std/src/sys/pal/sgx/abi/usercalls/alloc.rs @@ -1,18 +1,16 @@ #![allow(unused)] +use fortanix_sgx_abi::*; + +use super::super::mem::{is_enclave_range, is_user_range}; use crate::arch::asm; use crate::cell::UnsafeCell; -use crate::cmp; use crate::convert::TryInto; -use crate::intrinsics; use crate::mem::{self, ManuallyDrop}; use crate::ops::{CoerceUnsized, Deref, DerefMut, Index, IndexMut}; use crate::ptr::{self, NonNull}; -use crate::slice; use crate::slice::SliceIndex; - -use super::super::mem::{is_enclave_range, is_user_range}; -use fortanix_sgx_abi::*; +use crate::{cmp, intrinsics, slice}; /// A type that can be safely read from or written to userspace. /// diff --git a/std/src/sys/pal/sgx/abi/usercalls/tests.rs b/std/src/sys/pal/sgx/abi/usercalls/tests.rs index 58b8eb215d73c..ef824d35f4a16 100644 --- a/std/src/sys/pal/sgx/abi/usercalls/tests.rs +++ b/std/src/sys/pal/sgx/abi/usercalls/tests.rs @@ -1,5 +1,4 @@ -use super::alloc::User; -use super::alloc::{copy_from_userspace, copy_to_userspace}; +use super::alloc::{copy_from_userspace, copy_to_userspace, User}; #[test] fn test_copy_to_userspace_function() { diff --git a/std/src/sys/pal/sgx/alloc.rs b/std/src/sys/pal/sgx/alloc.rs index 0c7bf9a9201f2..f68ede9fcf012 100644 --- a/std/src/sys/pal/sgx/alloc.rs +++ b/std/src/sys/pal/sgx/alloc.rs @@ -1,9 +1,9 @@ -use crate::alloc::{GlobalAlloc, Layout, System}; -use crate::ptr; use core::sync::atomic::{AtomicBool, Ordering}; use super::abi::mem as sgx_mem; use super::waitqueue::SpinMutex; +use crate::alloc::{GlobalAlloc, Layout, System}; +use crate::ptr; // Using a SpinMutex because we never want to exit the enclave waiting for the // allocator. diff --git a/std/src/sys/pal/sgx/args.rs b/std/src/sys/pal/sgx/args.rs index ef4176c4ac0f0..a72a041da6cc9 100644 --- a/std/src/sys/pal/sgx/args.rs +++ b/std/src/sys/pal/sgx/args.rs @@ -1,10 +1,10 @@ -use super::abi::usercalls::{alloc, raw::ByteBuffer}; +use super::abi::usercalls::alloc; +use super::abi::usercalls::raw::ByteBuffer; use crate::ffi::OsString; -use crate::fmt; -use crate::slice; use crate::sync::atomic::{AtomicUsize, Ordering}; use crate::sys::os_str::Buf; use crate::sys_common::FromInner; +use crate::{fmt, slice}; #[cfg_attr(test, linkage = "available_externally")] #[export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE"] diff --git a/std/src/sys/pal/sgx/net.rs b/std/src/sys/pal/sgx/net.rs index 68a2d5eded2da..f2e751c51194d 100644 --- a/std/src/sys/pal/sgx/net.rs +++ b/std/src/sys/pal/sgx/net.rs @@ -1,13 +1,11 @@ -use crate::error; -use crate::fmt; +use super::abi::usercalls; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, ToSocketAddrs}; use crate::sync::Arc; use crate::sys::fd::FileDesc; use crate::sys::{sgx_ineffective, unsupported, AsInner, FromInner, IntoInner, TryIntoInner}; use crate::time::Duration; - -use super::abi::usercalls; +use crate::{error, fmt}; const DEFAULT_FAKE_TTL: u32 = 64; diff --git a/std/src/sys/pal/sgx/os.rs b/std/src/sys/pal/sgx/os.rs index c021300d4ae33..46af710aa396c 100644 --- a/std/src/sys/pal/sgx/os.rs +++ b/std/src/sys/pal/sgx/os.rs @@ -3,16 +3,12 @@ use fortanix_sgx_abi::{Error, RESULT_SUCCESS}; use crate::collections::HashMap; use crate::error::Error as StdError; use crate::ffi::{OsStr, OsString}; -use crate::fmt; -use crate::io; use crate::marker::PhantomData; use crate::path::{self, PathBuf}; -use crate::str; use crate::sync::atomic::{AtomicUsize, Ordering}; -use crate::sync::Mutex; -use crate::sync::Once; +use crate::sync::{Mutex, Once}; use crate::sys::{decode_error_kind, sgx_ineffective, unsupported}; -use crate::vec; +use crate::{fmt, io, str, vec}; pub fn errno() -> i32 { RESULT_SUCCESS diff --git a/std/src/sys/pal/sgx/thread.rs b/std/src/sys/pal/sgx/thread.rs index 446cdd18b7e42..df65d1cc8fc48 100644 --- a/std/src/sys/pal/sgx/thread.rs +++ b/std/src/sys/pal/sgx/thread.rs @@ -1,12 +1,11 @@ #![cfg_attr(test, allow(dead_code))] // why is this necessary? +use super::abi::usercalls; use super::unsupported; use crate::ffi::CStr; use crate::io; use crate::num::NonZero; use crate::time::Duration; -use super::abi::usercalls; - pub struct Thread(task_queue::JoinHandle); pub const DEFAULT_MIN_STACK_SIZE: usize = 4096; diff --git a/std/src/sys/pal/sgx/thread_parking.rs b/std/src/sys/pal/sgx/thread_parking.rs index 0006cd4f1be25..660624ea9c3b8 100644 --- a/std/src/sys/pal/sgx/thread_parking.rs +++ b/std/src/sys/pal/sgx/thread_parking.rs @@ -1,7 +1,8 @@ +use fortanix_sgx_abi::{EV_UNPARK, WAIT_INDEFINITE}; + use super::abi::usercalls; use crate::io::ErrorKind; use crate::time::Duration; -use fortanix_sgx_abi::{EV_UNPARK, WAIT_INDEFINITE}; pub type ThreadId = fortanix_sgx_abi::Tcs; diff --git a/std/src/sys/pal/sgx/waitqueue/mod.rs b/std/src/sys/pal/sgx/waitqueue/mod.rs index f5668a9493fb5..bd114523fe80b 100644 --- a/std/src/sys/pal/sgx/waitqueue/mod.rs +++ b/std/src/sys/pal/sgx/waitqueue/mod.rs @@ -16,17 +16,15 @@ mod tests; mod spin_mutex; mod unsafe_list; -use crate::num::NonZero; -use crate::ops::{Deref, DerefMut}; -use crate::panic::{self, AssertUnwindSafe}; -use crate::time::Duration; - -use super::abi::thread; -use super::abi::usercalls; use fortanix_sgx_abi::{Tcs, EV_UNPARK, WAIT_INDEFINITE}; pub use self::spin_mutex::{try_lock_or_false, SpinMutex, SpinMutexGuard}; use self::unsafe_list::{UnsafeList, UnsafeListEntry}; +use super::abi::{thread, usercalls}; +use crate::num::NonZero; +use crate::ops::{Deref, DerefMut}; +use crate::panic::{self, AssertUnwindSafe}; +use crate::time::Duration; /// An queue entry in a `WaitQueue`. struct WaitEntry { diff --git a/std/src/sys/pal/solid/abi/fs.rs b/std/src/sys/pal/solid/abi/fs.rs index 75efaaac2a948..394be15b0064b 100644 --- a/std/src/sys/pal/solid/abi/fs.rs +++ b/std/src/sys/pal/solid/abi/fs.rs @@ -1,11 +1,12 @@ //! `solid_fs.h` -use crate::os::raw::{c_char, c_int, c_uchar}; pub use libc::{ ino_t, off_t, stat, time_t, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY, SEEK_CUR, SEEK_END, SEEK_SET, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFMT, S_IFREG, S_IWRITE, }; +use crate::os::raw::{c_char, c_int, c_uchar}; + pub const O_ACCMODE: c_int = 0x3; pub const SOLID_MAX_PATH: usize = 256; diff --git a/std/src/sys/pal/solid/abi/mod.rs b/std/src/sys/pal/solid/abi/mod.rs index 8440d572cfbd3..62cd86236bbd3 100644 --- a/std/src/sys/pal/solid/abi/mod.rs +++ b/std/src/sys/pal/solid/abi/mod.rs @@ -3,7 +3,6 @@ use crate::os::raw::c_int; mod fs; pub mod sockets; pub use self::fs::*; - // `solid_types.h` pub use super::itron::abi::{ER, ER_ID, E_TMOUT, ID}; diff --git a/std/src/sys/pal/solid/abi/sockets.rs b/std/src/sys/pal/solid/abi/sockets.rs index 11c430360ce88..3c9e3f9ffb95d 100644 --- a/std/src/sys/pal/solid/abi/sockets.rs +++ b/std/src/sys/pal/solid/abi/sockets.rs @@ -1,6 +1,7 @@ -use crate::os::raw::{c_char, c_uint, c_void}; pub use libc::{c_int, c_long, size_t, ssize_t, timeval}; +use crate::os::raw::{c_char, c_uint, c_void}; + pub const SOLID_NET_ERR_BASE: c_int = -2000; pub const EINPROGRESS: c_int = SOLID_NET_ERR_BASE - libc::EINPROGRESS; diff --git a/std/src/sys/pal/solid/alloc.rs b/std/src/sys/pal/solid/alloc.rs index d013bd8761003..4cf60ac9b2e23 100644 --- a/std/src/sys/pal/solid/alloc.rs +++ b/std/src/sys/pal/solid/alloc.rs @@ -1,7 +1,5 @@ -use crate::{ - alloc::{GlobalAlloc, Layout, System}, - sys::common::alloc::{realloc_fallback, MIN_ALIGN}, -}; +use crate::alloc::{GlobalAlloc, Layout, System}; +use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN}; #[stable(feature = "alloc_system_type", since = "1.28.0")] unsafe impl GlobalAlloc for System { diff --git a/std/src/sys/pal/solid/error.rs b/std/src/sys/pal/solid/error.rs index 547b4f3a9840e..66c4d8a0ea27a 100644 --- a/std/src/sys/pal/solid/error.rs +++ b/std/src/sys/pal/solid/error.rs @@ -1,8 +1,7 @@ +pub use self::itron::error::{expect_success, ItronError as SolidError}; use super::{abi, itron, net}; use crate::io::ErrorKind; -pub use self::itron::error::{expect_success, ItronError as SolidError}; - /// Describe the specified SOLID error code. Returns `None` if it's an /// undefined error code. /// diff --git a/std/src/sys/pal/solid/fs.rs b/std/src/sys/pal/solid/fs.rs index dc83e4f4b4999..8179ec8821a38 100644 --- a/std/src/sys/pal/solid/fs.rs +++ b/std/src/sys/pal/solid/fs.rs @@ -1,17 +1,14 @@ use super::{abi, error}; -use crate::{ - ffi::{CStr, CString, OsStr, OsString}, - fmt, - io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom}, - mem::MaybeUninit, - os::raw::{c_int, c_short}, - os::solid::ffi::OsStrExt, - path::{Path, PathBuf}, - sync::Arc, - sys::time::SystemTime, - sys::unsupported, -}; - +use crate::ffi::{CStr, CString, OsStr, OsString}; +use crate::fmt; +use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom}; +use crate::mem::MaybeUninit; +use crate::os::raw::{c_int, c_short}; +use crate::os::solid::ffi::OsStrExt; +use crate::path::{Path, PathBuf}; +use crate::sync::Arc; +use crate::sys::time::SystemTime; +use crate::sys::unsupported; pub use crate::sys_common::fs::exists; /// A file descriptor. diff --git a/std/src/sys/pal/solid/io.rs b/std/src/sys/pal/solid/io.rs index a862bb7870264..4b1f788a492c5 100644 --- a/std/src/sys/pal/solid/io.rs +++ b/std/src/sys/pal/solid/io.rs @@ -1,8 +1,8 @@ -use crate::marker::PhantomData; -use crate::slice; +use libc::c_void; use super::abi::sockets::iovec; -use libc::c_void; +use crate::marker::PhantomData; +use crate::slice; #[derive(Copy, Clone)] #[repr(transparent)] diff --git a/std/src/sys/pal/solid/mod.rs b/std/src/sys/pal/solid/mod.rs index 0b158fb63df70..cbf34286878fe 100644 --- a/std/src/sys/pal/solid/mod.rs +++ b/std/src/sys/pal/solid/mod.rs @@ -32,8 +32,7 @@ pub mod pipe; #[path = "../unsupported/process.rs"] pub mod process; pub mod stdio; -pub use self::itron::thread; -pub use self::itron::thread_parking; +pub use self::itron::{thread, thread_parking}; pub mod time; // SAFETY: must be called only once during runtime initialization. diff --git a/std/src/sys/pal/solid/net.rs b/std/src/sys/pal/solid/net.rs index 5bd339849e9dc..b6a31395095d9 100644 --- a/std/src/sys/pal/solid/net.rs +++ b/std/src/sys/pal/solid/net.rs @@ -1,19 +1,15 @@ -use super::abi; -use crate::{ - cmp, - ffi::CStr, - io::{self, BorrowedBuf, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}, - mem, - net::{Shutdown, SocketAddr}, - os::solid::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd}, - ptr, str, - sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}, - sys_common::{FromInner, IntoInner}, - time::Duration, -}; +use libc::{c_int, c_void, size_t}; use self::netc::{sockaddr, socklen_t, MSG_PEEK}; -use libc::{c_int, c_void, size_t}; +use super::abi; +use crate::ffi::CStr; +use crate::io::{self, BorrowedBuf, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}; +use crate::net::{Shutdown, SocketAddr}; +use crate::os::solid::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd}; +use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; +use crate::sys_common::{FromInner, IntoInner}; +use crate::time::Duration; +use crate::{cmp, mem, ptr, str}; pub mod netc { pub use super::super::abi::sockets::*; diff --git a/std/src/sys/pal/solid/os.rs b/std/src/sys/pal/solid/os.rs index ac90aae4ebe46..d8afcb91f67f2 100644 --- a/std/src/sys/pal/solid/os.rs +++ b/std/src/sys/pal/solid/os.rs @@ -1,20 +1,14 @@ -use super::unsupported; +use core::slice::memchr; + +use super::{error, itron, unsupported}; use crate::error::Error as StdError; use crate::ffi::{CStr, OsStr, OsString}; -use crate::fmt; -use crate::io; -use crate::os::{ - raw::{c_char, c_int}, - solid::ffi::{OsStrExt, OsStringExt}, -}; +use crate::os::raw::{c_char, c_int}; +use crate::os::solid::ffi::{OsStrExt, OsStringExt}; use crate::path::{self, PathBuf}; use crate::sync::{PoisonError, RwLock}; use crate::sys::common::small_c_string::run_with_cstr; -use crate::vec; - -use super::{error, itron}; - -use core::slice::memchr; +use crate::{fmt, io, vec}; // `solid` directly maps `errno`s to μITRON error codes. impl itron::error::ItronError { diff --git a/std/src/sys/pal/solid/time.rs b/std/src/sys/pal/solid/time.rs index f83f1644fe854..3f9bbb0b63cdb 100644 --- a/std/src/sys/pal/solid/time.rs +++ b/std/src/sys/pal/solid/time.rs @@ -1,7 +1,8 @@ -use super::{abi, error::expect_success}; -use crate::{mem::MaybeUninit, time::Duration}; - +use super::abi; +use super::error::expect_success; pub use super::itron::time::Instant; +use crate::mem::MaybeUninit; +use crate::time::Duration; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] pub struct SystemTime(abi::time_t); diff --git a/std/src/sys/pal/teeos/os.rs b/std/src/sys/pal/teeos/os.rs index 3be0846a6dd4d..82cade771b513 100644 --- a/std/src/sys/pal/teeos/os.rs +++ b/std/src/sys/pal/teeos/os.rs @@ -2,14 +2,11 @@ use core::marker::PhantomData; +use super::unsupported; use crate::error::Error as StdError; use crate::ffi::{OsStr, OsString}; -use crate::fmt; -use crate::io; -use crate::path; use crate::path::PathBuf; - -use super::unsupported; +use crate::{fmt, io, path}; pub fn errno() -> i32 { unsafe { (*libc::__errno_location()) as i32 } diff --git a/std/src/sys/pal/teeos/stdio.rs b/std/src/sys/pal/teeos/stdio.rs index 9ca04f2927323..67e251812da7f 100644 --- a/std/src/sys/pal/teeos/stdio.rs +++ b/std/src/sys/pal/teeos/stdio.rs @@ -1,8 +1,9 @@ #![deny(unsafe_op_in_unsafe_fn)] -use crate::io; use core::arch::asm; +use crate::io; + pub struct Stdin; pub struct Stdout; pub struct Stderr; diff --git a/std/src/sys/pal/teeos/thread.rs b/std/src/sys/pal/teeos/thread.rs index b821e98f9cb89..15c65240ddd2a 100644 --- a/std/src/sys/pal/teeos/thread.rs +++ b/std/src/sys/pal/teeos/thread.rs @@ -1,11 +1,9 @@ -use crate::cmp; use crate::ffi::CStr; -use crate::io; use crate::mem::{self, ManuallyDrop}; use crate::num::NonZero; -use crate::ptr; use crate::sys::os; use crate::time::Duration; +use crate::{cmp, io, ptr}; pub const DEFAULT_MIN_STACK_SIZE: usize = 8 * 1024; diff --git a/std/src/sys/pal/uefi/args.rs b/std/src/sys/pal/uefi/args.rs index ca6bdfc55eb66..bdf6f5a0c1c34 100644 --- a/std/src/sys/pal/uefi/args.rs +++ b/std/src/sys/pal/uefi/args.rs @@ -3,10 +3,9 @@ use r_efi::protocols::loaded_image; use super::helpers; use crate::env::current_exe; use crate::ffi::OsString; -use crate::fmt; use crate::iter::Iterator; use crate::mem::size_of; -use crate::vec; +use crate::{fmt, vec}; pub struct Args { parsed_args_list: vec::IntoIter, diff --git a/std/src/sys/pal/uefi/helpers.rs b/std/src/sys/pal/uefi/helpers.rs index 586dbd84af2d4..4031d33ba8066 100644 --- a/std/src/sys/pal/uefi/helpers.rs +++ b/std/src/sys/pal/uefi/helpers.rs @@ -15,7 +15,9 @@ use r_efi::protocols::{device_path, device_path_to_text}; use crate::ffi::{OsStr, OsString}; use crate::io::{self, const_io_error}; use crate::mem::{size_of, MaybeUninit}; -use crate::os::uefi::{self, env::boot_services, ffi::OsStrExt, ffi::OsStringExt}; +use crate::os::uefi::env::boot_services; +use crate::os::uefi::ffi::{OsStrExt, OsStringExt}; +use crate::os::uefi::{self}; use crate::ptr::NonNull; use crate::slice; use crate::sync::atomic::{AtomicPtr, Ordering}; diff --git a/std/src/sys/pal/uefi/mod.rs b/std/src/sys/pal/uefi/mod.rs index c54e9477bfc1f..851bcea4c1e43 100644 --- a/std/src/sys/pal/uefi/mod.rs +++ b/std/src/sys/pal/uefi/mod.rs @@ -101,9 +101,10 @@ pub const fn unsupported_err() -> std_io::Error { } pub fn decode_error_kind(code: RawOsError) -> crate::io::ErrorKind { - use crate::io::ErrorKind; use r_efi::efi::Status; + use crate::io::ErrorKind; + match r_efi::efi::Status::from_usize(code) { Status::ALREADY_STARTED | Status::COMPROMISED_DATA diff --git a/std/src/sys/pal/uefi/os.rs b/std/src/sys/pal/uefi/os.rs index 0b27977df2fde..4d2d7264704b2 100644 --- a/std/src/sys/pal/uefi/os.rs +++ b/std/src/sys/pal/uefi/os.rs @@ -1,14 +1,14 @@ +use r_efi::efi::protocols::{device_path, loaded_image_device_path}; +use r_efi::efi::Status; + use super::{helpers, unsupported, RawOsError}; use crate::error::Error as StdError; use crate::ffi::{OsStr, OsString}; -use crate::fmt; -use crate::io; use crate::marker::PhantomData; use crate::os::uefi; use crate::path::{self, PathBuf}; use crate::ptr::NonNull; -use r_efi::efi::protocols::{device_path, loaded_image_device_path}; -use r_efi::efi::Status; +use crate::{fmt, io}; pub fn errno() -> RawOsError { 0 diff --git a/std/src/sys/pal/uefi/process.rs b/std/src/sys/pal/uefi/process.rs index 5c7c8415ee295..fdc5f5d7e4fea 100644 --- a/std/src/sys/pal/uefi/process.rs +++ b/std/src/sys/pal/uefi/process.rs @@ -1,20 +1,15 @@ use r_efi::protocols::simple_text_output; -use crate::ffi::OsStr; -use crate::ffi::OsString; -use crate::fmt; -use crate::io; -use crate::num::NonZero; -use crate::num::NonZeroI32; +use super::helpers; +pub use crate::ffi::OsString as EnvKey; +use crate::ffi::{OsStr, OsString}; +use crate::num::{NonZero, NonZeroI32}; use crate::path::Path; use crate::sys::fs::File; use crate::sys::pipe::AnonPipe; use crate::sys::unsupported; use crate::sys_common::process::{CommandEnv, CommandEnvs}; - -pub use crate::ffi::OsString as EnvKey; - -use super::helpers; +use crate::{fmt, io}; //////////////////////////////////////////////////////////////////////////////// // Command diff --git a/std/src/sys/pal/uefi/time.rs b/std/src/sys/pal/uefi/time.rs index 76562cf9f51c0..a97d69f997bf9 100644 --- a/std/src/sys/pal/uefi/time.rs +++ b/std/src/sys/pal/uefi/time.rs @@ -59,11 +59,12 @@ impl SystemTime { } pub(crate) mod system_time_internal { + use r_efi::efi::{RuntimeServices, Time}; + use super::super::helpers; use super::*; use crate::mem::MaybeUninit; use crate::ptr::NonNull; - use r_efi::efi::{RuntimeServices, Time}; pub fn now() -> Option { let runtime_services: NonNull = helpers::runtime_services()?; @@ -114,13 +115,14 @@ pub(crate) mod system_time_internal { } pub(crate) mod instant_internal { + use r_efi::protocols::timestamp; + use super::super::helpers; use super::*; use crate::mem::MaybeUninit; use crate::ptr::NonNull; use crate::sync::atomic::{AtomicPtr, Ordering}; use crate::sys_common::mul_div_u64; - use r_efi::protocols::timestamp; const NS_PER_SEC: u64 = 1_000_000_000; diff --git a/std/src/sys/pal/unix/args.rs b/std/src/sys/pal/unix/args.rs index e2ec838b740cb..9a37e1a0346d7 100644 --- a/std/src/sys/pal/unix/args.rs +++ b/std/src/sys/pal/unix/args.rs @@ -6,9 +6,8 @@ #![allow(dead_code)] // runtime init functions not used during testing use crate::ffi::{CStr, OsString}; -use crate::fmt; use crate::os::unix::ffi::OsStringExt; -use crate::vec; +use crate::{fmt, vec}; /// One-time global initialization. pub unsafe fn init(argc: isize, argv: *const *const u8) { diff --git a/std/src/sys/pal/unix/fd.rs b/std/src/sys/pal/unix/fd.rs index f705bd614422a..d8e239ee23ed5 100644 --- a/std/src/sys/pal/unix/fd.rs +++ b/std/src/sys/pal/unix/fd.rs @@ -3,12 +3,6 @@ #[cfg(test)] mod tests; -use crate::cmp; -use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, Read}; -use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; -use crate::sys::cvt; -use crate::sys_common::{AsInner, FromInner, IntoInner}; - #[cfg(any( target_os = "android", target_os = "linux", @@ -26,6 +20,12 @@ use libc::off64_t; )))] use libc::off_t as off64_t; +use crate::cmp; +use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, Read}; +use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; +use crate::sys::cvt; +use crate::sys_common::{AsInner, FromInner, IntoInner}; + #[derive(Debug)] pub struct FileDesc(OwnedFd); diff --git a/std/src/sys/pal/unix/fd/tests.rs b/std/src/sys/pal/unix/fd/tests.rs index 5d17e46786c79..c5301ce655787 100644 --- a/std/src/sys/pal/unix/fd/tests.rs +++ b/std/src/sys/pal/unix/fd/tests.rs @@ -1,6 +1,7 @@ +use core::mem::ManuallyDrop; + use super::{FileDesc, IoSlice}; use crate::os::unix::io::FromRawFd; -use core::mem::ManuallyDrop; #[test] fn limit_vector_count() { diff --git a/std/src/sys/pal/unix/fs.rs b/std/src/sys/pal/unix/fs.rs index c7915e26e3f0a..bdb83f0785784 100644 --- a/std/src/sys/pal/unix/fs.rs +++ b/std/src/sys/pal/unix/fs.rs @@ -4,29 +4,6 @@ #[cfg(test)] mod tests; -use crate::os::unix::prelude::*; - -use crate::ffi::{CStr, OsStr, OsString}; -use crate::fmt::{self, Write as _}; -use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom}; -use crate::mem; -use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd}; -use crate::path::{Path, PathBuf}; -use crate::ptr; -use crate::sync::Arc; -use crate::sys::common::small_c_string::run_path_with_cstr; -use crate::sys::fd::FileDesc; -use crate::sys::time::SystemTime; -use crate::sys::{cvt, cvt_r}; -use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; - -#[cfg(all(target_os = "linux", target_env = "gnu"))] -use crate::sys::weak::syscall; -#[cfg(target_os = "android")] -use crate::sys::weak::weak; - -use libc::{c_int, mode_t}; - #[cfg(all(target_os = "linux", target_env = "gnu"))] use libc::c_char; #[cfg(any( @@ -73,6 +50,7 @@ use libc::readdir64_r; target_os = "hurd", )))] use libc::readdir_r as readdir64_r; +use libc::{c_int, mode_t}; #[cfg(target_os = "android")] use libc::{ dirent as dirent64, fstat as fstat64, fstatat as fstatat64, ftruncate64, lseek64, @@ -97,7 +75,24 @@ use libc::{ ))] use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64}; +use crate::ffi::{CStr, OsStr, OsString}; +use crate::fmt::{self, Write as _}; +use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom}; +use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd}; +use crate::os::unix::prelude::*; +use crate::path::{Path, PathBuf}; +use crate::sync::Arc; +use crate::sys::common::small_c_string::run_path_with_cstr; +use crate::sys::fd::FileDesc; +use crate::sys::time::SystemTime; +#[cfg(all(target_os = "linux", target_env = "gnu"))] +use crate::sys::weak::syscall; +#[cfg(target_os = "android")] +use crate::sys::weak::weak; +use crate::sys::{cvt, cvt_r}; pub use crate::sys_common::fs::exists; +use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; +use crate::{mem, ptr}; pub struct File(FileDesc); @@ -2021,6 +2016,11 @@ mod remove_dir_impl { miri )))] mod remove_dir_impl { + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] + use libc::{fdopendir, openat, unlinkat}; + #[cfg(all(target_os = "linux", target_env = "gnu"))] + use libc::{fdopendir, openat64 as openat, unlinkat}; + use super::{lstat, Dir, DirEntry, InnerReadDir, ReadDir}; use crate::ffi::CStr; use crate::io; @@ -2030,11 +2030,6 @@ mod remove_dir_impl { use crate::sys::common::small_c_string::run_path_with_cstr; use crate::sys::{cvt, cvt_r}; - #[cfg(not(all(target_os = "linux", target_env = "gnu")))] - use libc::{fdopendir, openat, unlinkat}; - #[cfg(all(target_os = "linux", target_env = "gnu"))] - use libc::{fdopendir, openat64 as openat, unlinkat}; - pub fn openat_nofollow_dironly(parent_fd: Option, p: &CStr) -> io::Result { let fd = cvt_r(|| unsafe { openat( diff --git a/std/src/sys/pal/unix/io.rs b/std/src/sys/pal/unix/io.rs index 29c340dd34942..181c35a971eca 100644 --- a/std/src/sys/pal/unix/io.rs +++ b/std/src/sys/pal/unix/io.rs @@ -1,9 +1,9 @@ +use libc::{c_void, iovec}; + use crate::marker::PhantomData; use crate::os::fd::{AsFd, AsRawFd}; use crate::slice; -use libc::{c_void, iovec}; - #[derive(Copy, Clone)] #[repr(transparent)] pub struct IoSlice<'a> { diff --git a/std/src/sys/pal/unix/kernel_copy.rs b/std/src/sys/pal/unix/kernel_copy.rs index cd38b7c07e2b1..652b2e1feb7ad 100644 --- a/std/src/sys/pal/unix/kernel_copy.rs +++ b/std/src/sys/pal/unix/kernel_copy.rs @@ -42,6 +42,12 @@ //! progress, they can hit a performance cliff. //! * complexity +#[cfg(not(any(all(target_os = "linux", target_env = "gnu"), target_os = "hurd")))] +use libc::sendfile as sendfile64; +#[cfg(any(all(target_os = "linux", target_env = "gnu"), target_os = "hurd"))] +use libc::sendfile64; +use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV}; + use crate::cmp::min; use crate::fs::{File, Metadata}; use crate::io::copy::generic_copy; @@ -59,11 +65,6 @@ use crate::ptr; use crate::sync::atomic::{AtomicBool, AtomicU8, Ordering}; use crate::sys::cvt; use crate::sys::weak::syscall; -#[cfg(not(any(all(target_os = "linux", target_env = "gnu"), target_os = "hurd")))] -use libc::sendfile as sendfile64; -#[cfg(any(all(target_os = "linux", target_env = "gnu"), target_os = "hurd"))] -use libc::sendfile64; -use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV}; #[cfg(test)] mod tests; diff --git a/std/src/sys/pal/unix/kernel_copy/tests.rs b/std/src/sys/pal/unix/kernel_copy/tests.rs index a524270e3fb85..1350d743ff6f3 100644 --- a/std/src/sys/pal/unix/kernel_copy/tests.rs +++ b/std/src/sys/pal/unix/kernel_copy/tests.rs @@ -1,8 +1,6 @@ use crate::fs::OpenOptions; use crate::io; -use crate::io::Result; -use crate::io::SeekFrom; -use crate::io::{BufRead, Read, Seek, Write}; +use crate::io::{BufRead, Read, Result, Seek, SeekFrom, Write}; use crate::os::unix::io::AsRawFd; use crate::sys_common::io::test::tmpdir; diff --git a/std/src/sys/pal/unix/mod.rs b/std/src/sys/pal/unix/mod.rs index 7f5a8d0ce852b..4898bdd2fa392 100644 --- a/std/src/sys/pal/unix/mod.rs +++ b/std/src/sys/pal/unix/mod.rs @@ -1,8 +1,7 @@ #![allow(missing_docs, nonstandard_style)] -use crate::io::ErrorKind; - pub use self::rand::hashmap_random_keys; +use crate::io::ErrorKind; #[cfg(not(target_os = "espidf"))] #[macro_use] @@ -86,11 +85,12 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { target_vendor = "apple", )))] 'poll: { - use crate::sys::os::errno; #[cfg(not(all(target_os = "linux", target_env = "gnu")))] use libc::open as open64; #[cfg(all(target_os = "linux", target_env = "gnu"))] use libc::open64; + + use crate::sys::os::errno; let pfds: &mut [_] = &mut [ libc::pollfd { fd: 0, events: 0, revents: 0 }, libc::pollfd { fd: 1, events: 0, revents: 0 }, @@ -140,11 +140,12 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { target_os = "vita", )))] { - use crate::sys::os::errno; #[cfg(not(all(target_os = "linux", target_env = "gnu")))] use libc::open as open64; #[cfg(all(target_os = "linux", target_env = "gnu"))] use libc::open64; + + use crate::sys::os::errno; for fd in 0..3 { if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF { if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 { @@ -232,12 +233,13 @@ pub unsafe fn cleanup() { stack_overflow::cleanup(); } -#[cfg(target_os = "android")] -pub use crate::sys::android::signal; #[allow(unused_imports)] #[cfg(not(target_os = "android"))] pub use libc::signal; +#[cfg(target_os = "android")] +pub use crate::sys::android::signal; + #[inline] pub(crate) fn is_interrupted(errno: i32) -> bool { errno == libc::EINTR diff --git a/std/src/sys/pal/unix/net.rs b/std/src/sys/pal/unix/net.rs index eafde51c6088b..bc0e3f4eeeac8 100644 --- a/std/src/sys/pal/unix/net.rs +++ b/std/src/sys/pal/unix/net.rs @@ -1,7 +1,7 @@ -use crate::cmp; +use libc::{c_int, c_void, size_t, sockaddr, socklen_t, MSG_PEEK}; + use crate::ffi::CStr; use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; -use crate::mem; use crate::net::{Shutdown, SocketAddr}; use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use crate::sys::fd::FileDesc; @@ -9,8 +9,7 @@ use crate::sys::pal::unix::IsMinusOne; use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::{Duration, Instant}; - -use libc::{c_int, c_void, size_t, sockaddr, socklen_t, MSG_PEEK}; +use crate::{cmp, mem}; cfg_if::cfg_if! { if #[cfg(target_vendor = "apple")] { diff --git a/std/src/sys/pal/unix/os.rs b/std/src/sys/pal/unix/os.rs index 9adc2b94e599e..a785b97ac8dc5 100644 --- a/std/src/sys/pal/unix/os.rs +++ b/std/src/sys/pal/unix/os.rs @@ -5,29 +5,20 @@ #[cfg(test)] mod tests; -use crate::os::unix::prelude::*; +use core::slice::memchr; + +use libc::{c_char, c_int, c_void}; use crate::error::Error as StdError; use crate::ffi::{CStr, CString, OsStr, OsString}; -use crate::fmt; -use crate::io; -use crate::iter; -use crate::mem; +use crate::os::unix::prelude::*; use crate::path::{self, PathBuf}; -use crate::ptr; -use crate::slice; -use crate::str; use crate::sync::{PoisonError, RwLock}; use crate::sys::common::small_c_string::{run_path_with_cstr, run_with_cstr}; -use crate::sys::cvt; -use crate::sys::fd; -use crate::vec; -use core::slice::memchr; - #[cfg(all(target_env = "gnu", not(target_os = "vxworks")))] use crate::sys::weak::weak; - -use libc::{c_char, c_int, c_void}; +use crate::sys::{cvt, fd}; +use crate::{fmt, io, iter, mem, ptr, slice, str, vec}; const TMPBUF_SZ: usize = 128; @@ -248,13 +239,12 @@ impl StdError for JoinPathsError { #[cfg(target_os = "aix")] pub fn current_exe() -> io::Result { - use crate::io::ErrorKind; - #[cfg(test)] use realstd::env; #[cfg(not(test))] use crate::env; + use crate::io::ErrorKind; let exe_path = env::args().next().ok_or(io::const_io_error!( ErrorKind::NotFound, @@ -513,13 +503,12 @@ pub fn current_exe() -> io::Result { #[cfg(target_os = "fuchsia")] pub fn current_exe() -> io::Result { - use crate::io::ErrorKind; - #[cfg(test)] use realstd::env; #[cfg(not(test))] use crate::env; + use crate::io::ErrorKind; let exe_path = env::args().next().ok_or(io::const_io_error!( ErrorKind::Uncategorized, diff --git a/std/src/sys/pal/unix/process/process_common.rs b/std/src/sys/pal/unix/process/process_common.rs index f615e8086dccf..ecb5ca58db692 100644 --- a/std/src/sys/pal/unix/process/process_common.rs +++ b/std/src/sys/pal/unix/process/process_common.rs @@ -1,24 +1,20 @@ #[cfg(all(test, not(target_os = "emscripten")))] mod tests; -use crate::os::unix::prelude::*; +use libc::{c_char, c_int, gid_t, pid_t, uid_t, EXIT_FAILURE, EXIT_SUCCESS}; use crate::collections::BTreeMap; use crate::ffi::{CStr, CString, OsStr, OsString}; -use crate::fmt; -use crate::io; +use crate::os::unix::prelude::*; use crate::path::Path; -use crate::ptr; use crate::sys::fd::FileDesc; use crate::sys::fs::File; +#[cfg(not(target_os = "fuchsia"))] +use crate::sys::fs::OpenOptions; use crate::sys::pipe::{self, AnonPipe}; use crate::sys_common::process::{CommandEnv, CommandEnvs}; use crate::sys_common::{FromInner, IntoInner}; - -#[cfg(not(target_os = "fuchsia"))] -use crate::sys::fs::OpenOptions; - -use libc::{c_char, c_int, gid_t, pid_t, uid_t, EXIT_FAILURE, EXIT_SUCCESS}; +use crate::{fmt, io, ptr}; cfg_if::cfg_if! { if #[cfg(target_os = "fuchsia")] { diff --git a/std/src/sys/pal/unix/process/process_common/tests.rs b/std/src/sys/pal/unix/process/process_common/tests.rs index 823b4a5633629..e5c8dd6e341e1 100644 --- a/std/src/sys/pal/unix/process/process_common/tests.rs +++ b/std/src/sys/pal/unix/process/process_common/tests.rs @@ -1,9 +1,7 @@ use super::*; - use crate::ffi::OsStr; -use crate::mem; -use crate::ptr; use crate::sys::{cvt, cvt_nz}; +use crate::{mem, ptr}; macro_rules! t { ($e:expr) => { diff --git a/std/src/sys/pal/unix/process/process_fuchsia.rs b/std/src/sys/pal/unix/process/process_fuchsia.rs index 23c2be6adf9ee..f3d5fdec4c291 100644 --- a/std/src/sys/pal/unix/process/process_fuchsia.rs +++ b/std/src/sys/pal/unix/process/process_fuchsia.rs @@ -1,13 +1,9 @@ -use crate::fmt; -use crate::io; -use crate::mem; -use crate::num::NonZero; -use crate::ptr; +use libc::{c_int, size_t}; +use crate::num::NonZero; use crate::sys::process::process_common::*; use crate::sys::process::zircon::{zx_handle_t, Handle}; - -use libc::{c_int, size_t}; +use crate::{fmt, io, mem, ptr}; //////////////////////////////////////////////////////////////////////////////// // Command diff --git a/std/src/sys/pal/unix/process/process_unix.rs b/std/src/sys/pal/unix/process/process_unix.rs index 4e4dd3040feeb..5552e9ac97753 100644 --- a/std/src/sys/pal/unix/process/process_unix.rs +++ b/std/src/sys/pal/unix/process/process_unix.rs @@ -1,20 +1,7 @@ -use crate::fmt; -use crate::io::{self, Error, ErrorKind}; -use crate::mem; -use crate::num::NonZero; -use crate::sys; -use crate::sys::cvt; -use crate::sys::process::process_common::*; - -#[cfg(target_os = "linux")] -use crate::sys::pal::unix::linux::pidfd::PidFd; - #[cfg(target_os = "vxworks")] use libc::RTP_ID as pid_t; - #[cfg(not(target_os = "vxworks"))] use libc::{c_int, pid_t}; - #[cfg(not(any( target_os = "vxworks", target_os = "l4re", @@ -23,6 +10,14 @@ use libc::{c_int, pid_t}; )))] use libc::{gid_t, uid_t}; +use crate::io::{self, Error, ErrorKind}; +use crate::num::NonZero; +use crate::sys::cvt; +#[cfg(target_os = "linux")] +use crate::sys::pal::unix::linux::pidfd::PidFd; +use crate::sys::process::process_common::*; +use crate::{fmt, mem, sys}; + cfg_if::cfg_if! { if #[cfg(all(target_os = "nto", target_env = "nto71"))] { use crate::thread; @@ -446,11 +441,12 @@ impl Command { stdio: &ChildPipes, envp: Option<&CStringArray>, ) -> io::Result> { + #[cfg(target_os = "linux")] + use core::sync::atomic::{AtomicU8, Ordering}; + use crate::mem::MaybeUninit; use crate::sys::weak::weak; use crate::sys::{self, cvt_nz, on_broken_pipe_flag_used}; - #[cfg(target_os = "linux")] - use core::sync::atomic::{AtomicU8, Ordering}; if self.get_gid().is_some() || self.get_uid().is_some() @@ -762,10 +758,11 @@ impl Command { #[cfg(target_os = "linux")] fn send_pidfd(&self, sock: &crate::sys::net::Socket) { + use libc::{CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_SPACE, SCM_RIGHTS, SOL_SOCKET}; + use crate::io::IoSlice; use crate::os::fd::RawFd; use crate::sys::cvt_r; - use libc::{CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_SPACE, SCM_RIGHTS, SOL_SOCKET}; unsafe { let child_pid = libc::getpid(); @@ -819,11 +816,11 @@ impl Command { #[cfg(target_os = "linux")] fn recv_pidfd(&self, sock: &crate::sys::net::Socket) -> pid_t { + use libc::{CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_SPACE, SCM_RIGHTS, SOL_SOCKET}; + use crate::io::IoSliceMut; use crate::sys::cvt_r; - use libc::{CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_SPACE, SCM_RIGHTS, SOL_SOCKET}; - unsafe { const SCM_MSG_LEN: usize = mem::size_of::<[c_int; 1]>(); @@ -1189,12 +1186,11 @@ impl ExitStatusError { #[cfg(target_os = "linux")] mod linux_child_ext { - use crate::io; - use crate::mem; use crate::os::linux::process as os; use crate::sys::pal::unix::linux::pidfd as imp; use crate::sys::pal::unix::ErrorKind; use crate::sys_common::FromInner; + use crate::{io, mem}; #[unstable(feature = "linux_pidfd", issue = "82971")] impl crate::os::linux::process::ChildExt for crate::process::Child { diff --git a/std/src/sys/pal/unix/process/process_unsupported.rs b/std/src/sys/pal/unix/process/process_unsupported.rs index 90d53464c83f1..c58548835ff3d 100644 --- a/std/src/sys/pal/unix/process/process_unsupported.rs +++ b/std/src/sys/pal/unix/process/process_unsupported.rs @@ -1,10 +1,10 @@ +use libc::{c_int, pid_t}; + use crate::io; use crate::num::NonZero; use crate::sys::pal::unix::unsupported::*; use crate::sys::process::process_common::*; -use libc::{c_int, pid_t}; - //////////////////////////////////////////////////////////////////////////////// // Command //////////////////////////////////////////////////////////////////////////////// diff --git a/std/src/sys/pal/unix/process/process_unsupported/wait_status.rs b/std/src/sys/pal/unix/process/process_unsupported/wait_status.rs index 973188b1f2b27..f04036bde4922 100644 --- a/std/src/sys/pal/unix/process/process_unsupported/wait_status.rs +++ b/std/src/sys/pal/unix/process/process_unsupported/wait_status.rs @@ -2,12 +2,11 @@ //! //! Separate module to facilitate testing against a real Unix implementation. +use super::ExitStatusError; use crate::ffi::c_int; use crate::fmt; use crate::num::NonZero; -use super::ExitStatusError; - /// Emulated wait status for use by `process_unsupported.rs` /// /// Uses the "traditional unix" encoding. For use on platfors which are `#[cfg(unix)]` diff --git a/std/src/sys/pal/unix/process/process_vxworks.rs b/std/src/sys/pal/unix/process/process_vxworks.rs index 26b8a0a39dc44..6a9d8fab1d412 100644 --- a/std/src/sys/pal/unix/process/process_vxworks.rs +++ b/std/src/sys/pal/unix/process/process_vxworks.rs @@ -1,12 +1,11 @@ -use crate::fmt; +use libc::{self, c_char, c_int, RTP_ID}; + use crate::io::{self, ErrorKind}; use crate::num::NonZero; -use crate::sys; use crate::sys::cvt; use crate::sys::pal::unix::thread; use crate::sys::process::process_common::*; -use libc::RTP_ID; -use libc::{self, c_char, c_int}; +use crate::{fmt, sys}; //////////////////////////////////////////////////////////////////////////////// // Command diff --git a/std/src/sys/pal/unix/process/zircon.rs b/std/src/sys/pal/unix/process/zircon.rs index 2e596486f9c86..4035e2370a3c6 100644 --- a/std/src/sys/pal/unix/process/zircon.rs +++ b/std/src/sys/pal/unix/process/zircon.rs @@ -1,11 +1,11 @@ #![allow(non_camel_case_types, unused)] +use libc::{c_int, c_void, size_t}; + use crate::io; use crate::mem::MaybeUninit; use crate::os::raw::c_char; -use libc::{c_int, c_void, size_t}; - pub type zx_handle_t = u32; pub type zx_vaddr_t = usize; pub type zx_rights_t = u32; diff --git a/std/src/sys/pal/unix/rand.rs b/std/src/sys/pal/unix/rand.rs index e6df109a6b8f2..8a78ea8e7ccc7 100644 --- a/std/src/sys/pal/unix/rand.rs +++ b/std/src/sys/pal/unix/rand.rs @@ -24,7 +24,6 @@ pub fn hashmap_random_keys() -> (u64, u64) { mod imp { use crate::fs::File; use crate::io::Read; - #[cfg(any(target_os = "linux", target_os = "android"))] use crate::sys::weak::syscall; @@ -178,9 +177,10 @@ mod imp { #[cfg(target_vendor = "apple")] mod imp { - use crate::io; use libc::{c_int, c_void, size_t}; + use crate::io; + #[inline(always)] fn random_failure() -> ! { panic!("unexpected random generation error: {}", io::Error::last_os_error()); @@ -311,8 +311,10 @@ mod imp { #[cfg(target_os = "vxworks")] mod imp { + use core::sync::atomic::AtomicBool; + use core::sync::atomic::Ordering::Relaxed; + use crate::io; - use core::sync::atomic::{AtomicBool, Ordering::Relaxed}; pub fn fill_bytes(v: &mut [u8]) { static RNG_INIT: AtomicBool = AtomicBool::new(false); diff --git a/std/src/sys/pal/unix/stack_overflow.rs b/std/src/sys/pal/unix/stack_overflow.rs index 6eeec48bf5eaf..9ff44b54c41a1 100644 --- a/std/src/sys/pal/unix/stack_overflow.rs +++ b/std/src/sys/pal/unix/stack_overflow.rs @@ -1,10 +1,8 @@ #![cfg_attr(test, allow(dead_code))] +pub use self::imp::{cleanup, init}; use self::imp::{drop_handler, make_handler}; -pub use self::imp::cleanup; -pub use self::imp::init; - pub struct Handler { data: *mut libc::c_void, } @@ -37,24 +35,23 @@ impl Drop for Handler { target_os = "solaris" ))] mod imp { + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] + use libc::{mmap as mmap64, mprotect, munmap}; + #[cfg(all(target_os = "linux", target_env = "gnu"))] + use libc::{mmap64, mprotect, munmap}; + use libc::{ + sigaction, sigaltstack, sighandler_t, MAP_ANON, MAP_FAILED, MAP_FIXED, MAP_PRIVATE, + PROT_NONE, PROT_READ, PROT_WRITE, SA_ONSTACK, SA_SIGINFO, SIGBUS, SIGSEGV, SIG_DFL, + SS_DISABLE, + }; + use super::Handler; use crate::cell::Cell; - use crate::io; - use crate::mem; use crate::ops::Range; - use crate::ptr; use crate::sync::atomic::{AtomicBool, AtomicPtr, AtomicUsize, Ordering}; use crate::sync::OnceLock; use crate::sys::pal::unix::os; - use crate::thread; - - #[cfg(not(all(target_os = "linux", target_env = "gnu")))] - use libc::{mmap as mmap64, mprotect, munmap}; - #[cfg(all(target_os = "linux", target_env = "gnu"))] - use libc::{mmap64, mprotect, munmap}; - use libc::{sigaction, sighandler_t, SA_ONSTACK, SA_SIGINFO, SIGBUS, SIGSEGV, SIG_DFL}; - use libc::{sigaltstack, SS_DISABLE}; - use libc::{MAP_ANON, MAP_FAILED, MAP_FIXED, MAP_PRIVATE, PROT_NONE, PROT_READ, PROT_WRITE}; + use crate::{io, mem, ptr, thread}; // We use a TLS variable to store the address of the guard page. While TLS // variables are not guaranteed to be signal-safe, this works out in practice diff --git a/std/src/sys/pal/unix/thread.rs b/std/src/sys/pal/unix/thread.rs index 483697b8597f8..83034761f3d16 100644 --- a/std/src/sys/pal/unix/thread.rs +++ b/std/src/sys/pal/unix/thread.rs @@ -1,16 +1,13 @@ -use crate::cmp; use crate::ffi::CStr; -use crate::io; use crate::mem::{self, ManuallyDrop}; use crate::num::NonZero; -use crate::ptr; -use crate::sys::{os, stack_overflow}; -use crate::time::Duration; - #[cfg(all(target_os = "linux", target_env = "gnu"))] use crate::sys::weak::dlsym; #[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto"))] use crate::sys::weak::weak; +use crate::sys::{os, stack_overflow}; +use crate::time::Duration; +use crate::{cmp, io, ptr}; #[cfg(not(any(target_os = "l4re", target_os = "vxworks", target_os = "espidf")))] pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024; #[cfg(target_os = "l4re")] @@ -475,11 +472,9 @@ mod cgroups { use crate::borrow::Cow; use crate::ffi::OsString; use crate::fs::{exists, File}; - use crate::io::Read; - use crate::io::{BufRead, BufReader}; + use crate::io::{BufRead, BufReader, Read}; use crate::os::unix::ffi::OsStringExt; - use crate::path::Path; - use crate::path::PathBuf; + use crate::path::{Path, PathBuf}; use crate::str::from_utf8; #[derive(PartialEq)] diff --git a/std/src/sys/pal/unix/thread_parking.rs b/std/src/sys/pal/unix/thread_parking.rs index 1366410b71edc..1da5fce3cd30f 100644 --- a/std/src/sys/pal/unix/thread_parking.rs +++ b/std/src/sys/pal/unix/thread_parking.rs @@ -2,10 +2,11 @@ // separate modules for each platform. #![cfg(target_os = "netbsd")] +use libc::{_lwp_self, c_long, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC}; + use crate::ffi::{c_int, c_void}; use crate::ptr; use crate::time::Duration; -use libc::{_lwp_self, c_long, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC}; extern "C" { fn ___lwp_park60( diff --git a/std/src/sys/pal/unix/weak.rs b/std/src/sys/pal/unix/weak.rs index 4765a286e6b9e..b1b6aae757c51 100644 --- a/std/src/sys/pal/unix/weak.rs +++ b/std/src/sys/pal/unix/weak.rs @@ -23,9 +23,8 @@ use crate::ffi::CStr; use crate::marker::PhantomData; -use crate::mem; -use crate::ptr; use crate::sync::atomic::{self, AtomicPtr, Ordering}; +use crate::{mem, ptr}; // We can use true weak linkage on ELF targets. #[cfg(all(unix, not(target_vendor = "apple")))] diff --git a/std/src/sys/pal/unsupported/os.rs b/std/src/sys/pal/unsupported/os.rs index 3be98898bbeb9..481fd62c04fe8 100644 --- a/std/src/sys/pal/unsupported/os.rs +++ b/std/src/sys/pal/unsupported/os.rs @@ -1,10 +1,9 @@ use super::unsupported; use crate::error::Error as StdError; use crate::ffi::{OsStr, OsString}; -use crate::fmt; -use crate::io; use crate::marker::PhantomData; use crate::path::{self, PathBuf}; +use crate::{fmt, io}; pub fn errno() -> i32 { 0 diff --git a/std/src/sys/pal/unsupported/pipe.rs b/std/src/sys/pal/unsupported/pipe.rs index 781eafe2f1a6b..6799d21a1ff75 100644 --- a/std/src/sys/pal/unsupported/pipe.rs +++ b/std/src/sys/pal/unsupported/pipe.rs @@ -1,7 +1,5 @@ -use crate::{ - fmt, - io::{self, BorrowedCursor, IoSlice, IoSliceMut}, -}; +use crate::fmt; +use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; pub struct AnonPipe(!); diff --git a/std/src/sys/pal/unsupported/process.rs b/std/src/sys/pal/unsupported/process.rs index 2445d9073dbb9..40231bfc90b1e 100644 --- a/std/src/sys/pal/unsupported/process.rs +++ b/std/src/sys/pal/unsupported/process.rs @@ -1,14 +1,12 @@ +pub use crate::ffi::OsString as EnvKey; use crate::ffi::{OsStr, OsString}; -use crate::fmt; -use crate::io; use crate::num::NonZero; use crate::path::Path; use crate::sys::fs::File; use crate::sys::pipe::AnonPipe; use crate::sys::unsupported; use crate::sys_common::process::{CommandEnv, CommandEnvs}; - -pub use crate::ffi::OsString as EnvKey; +use crate::{fmt, io}; //////////////////////////////////////////////////////////////////////////////// // Command diff --git a/std/src/sys/pal/wasi/args.rs b/std/src/sys/pal/wasi/args.rs index c42c310e3a254..6b6d1b8ff4e2e 100644 --- a/std/src/sys/pal/wasi/args.rs +++ b/std/src/sys/pal/wasi/args.rs @@ -1,9 +1,8 @@ #![deny(unsafe_op_in_unsafe_fn)] use crate::ffi::{CStr, OsStr, OsString}; -use crate::fmt; use crate::os::wasi::ffi::OsStrExt; -use crate::vec; +use crate::{fmt, vec}; pub struct Args { iter: vec::IntoIter, diff --git a/std/src/sys/pal/wasi/fs.rs b/std/src/sys/pal/wasi/fs.rs index c58e6a08b374e..11900886f0b5c 100644 --- a/std/src/sys/pal/wasi/fs.rs +++ b/std/src/sys/pal/wasi/fs.rs @@ -2,22 +2,19 @@ use super::fd::WasiFd; use crate::ffi::{CStr, OsStr, OsString}; -use crate::fmt; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom}; -use crate::iter; use crate::mem::{self, ManuallyDrop}; use crate::os::raw::c_int; use crate::os::wasi::ffi::{OsStrExt, OsStringExt}; use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use crate::path::{Path, PathBuf}; -use crate::ptr; use crate::sync::Arc; use crate::sys::common::small_c_string::run_path_with_cstr; use crate::sys::time::SystemTime; use crate::sys::unsupported; -use crate::sys_common::{AsInner, FromInner, IntoInner}; - pub use crate::sys_common::fs::exists; +use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::{fmt, iter, ptr}; pub struct File { fd: WasiFd, diff --git a/std/src/sys/pal/wasi/helpers.rs b/std/src/sys/pal/wasi/helpers.rs index 82149cef8fad1..4b770ee23bc5d 100644 --- a/std/src/sys/pal/wasi/helpers.rs +++ b/std/src/sys/pal/wasi/helpers.rs @@ -1,5 +1,4 @@ -use crate::io as std_io; -use crate::mem; +use crate::{io as std_io, mem}; #[inline] pub fn is_interrupted(errno: i32) -> bool { diff --git a/std/src/sys/pal/wasi/mod.rs b/std/src/sys/pal/wasi/mod.rs index d8fe06d1973c9..f4dc3ebd4140b 100644 --- a/std/src/sys/pal/wasi/mod.rs +++ b/std/src/sys/pal/wasi/mod.rs @@ -48,8 +48,5 @@ mod helpers; // import conflict rules. If we glob export `helpers` and `common` together, // then the compiler complains about conflicts. -pub use helpers::abort_internal; -pub use helpers::decode_error_kind; use helpers::err2io; -pub use helpers::hashmap_random_keys; -pub use helpers::is_interrupted; +pub use helpers::{abort_internal, decode_error_kind, hashmap_random_keys, is_interrupted}; diff --git a/std/src/sys/pal/wasi/os.rs b/std/src/sys/pal/wasi/os.rs index e96296997e6a9..f5b17d9df94b4 100644 --- a/std/src/sys/pal/wasi/os.rs +++ b/std/src/sys/pal/wasi/os.rs @@ -1,18 +1,16 @@ #![deny(unsafe_op_in_unsafe_fn)] +use core::slice::memchr; + use crate::error::Error as StdError; use crate::ffi::{CStr, OsStr, OsString}; -use crate::fmt; -use crate::io; use crate::marker::PhantomData; use crate::ops::Drop; use crate::os::wasi::prelude::*; use crate::path::{self, PathBuf}; -use crate::str; use crate::sys::common::small_c_string::{run_path_with_cstr, run_with_cstr}; use crate::sys::unsupported; -use crate::vec; -use core::slice::memchr; +use crate::{fmt, io, str, vec}; // Add a few symbols not in upstream `libc` just yet. mod libc { diff --git a/std/src/sys/pal/wasi/thread.rs b/std/src/sys/pal/wasi/thread.rs index 2a3a39aafa704..c37acd8dfeeb7 100644 --- a/std/src/sys/pal/wasi/thread.rs +++ b/std/src/sys/pal/wasi/thread.rs @@ -1,9 +1,8 @@ use crate::ffi::CStr; -use crate::io; -use crate::mem; use crate::num::NonZero; use crate::sys::unsupported; use crate::time::Duration; +use crate::{io, mem}; cfg_if::cfg_if! { if #[cfg(target_feature = "atomics")] { diff --git a/std/src/sys/pal/wasip2/mod.rs b/std/src/sys/pal/wasip2/mod.rs index 0930d2e22fa8d..f20630e10cff9 100644 --- a/std/src/sys/pal/wasip2/mod.rs +++ b/std/src/sys/pal/wasip2/mod.rs @@ -51,10 +51,7 @@ mod helpers; // import conflict rules. If we glob export `helpers` and `common` together, // then the compiler complains about conflicts. -pub use helpers::abort_internal; -pub use helpers::decode_error_kind; use helpers::err2io; -pub use helpers::hashmap_random_keys; -pub use helpers::is_interrupted; +pub use helpers::{abort_internal, decode_error_kind, hashmap_random_keys, is_interrupted}; mod cabi_realloc; diff --git a/std/src/sys/pal/wasm/alloc.rs b/std/src/sys/pal/wasm/alloc.rs index b74ce0d47425a..ef9d753d7f86c 100644 --- a/std/src/sys/pal/wasm/alloc.rs +++ b/std/src/sys/pal/wasm/alloc.rs @@ -57,10 +57,8 @@ unsafe impl GlobalAlloc for System { #[cfg(target_feature = "atomics")] mod lock { - use crate::sync::atomic::{ - AtomicI32, - Ordering::{Acquire, Release}, - }; + use crate::sync::atomic::AtomicI32; + use crate::sync::atomic::Ordering::{Acquire, Release}; static LOCKED: AtomicI32 = AtomicI32::new(0); diff --git a/std/src/sys/pal/windows/alloc.rs b/std/src/sys/pal/windows/alloc.rs index 020a2a4f3a28f..92b68b26032c6 100644 --- a/std/src/sys/pal/windows/alloc.rs +++ b/std/src/sys/pal/windows/alloc.rs @@ -1,10 +1,11 @@ +use core::mem::MaybeUninit; + use crate::alloc::{GlobalAlloc, Layout, System}; use crate::ffi::c_void; use crate::ptr; use crate::sync::atomic::{AtomicPtr, Ordering}; use crate::sys::c::{self, windows_targets}; use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN}; -use core::mem::MaybeUninit; #[cfg(test)] mod tests; diff --git a/std/src/sys/pal/windows/args.rs b/std/src/sys/pal/windows/args.rs index 5098c05196e25..66e75a8357149 100644 --- a/std/src/sys/pal/windows/args.rs +++ b/std/src/sys/pal/windows/args.rs @@ -8,8 +8,6 @@ mod tests; use super::os::current_exe; use crate::ffi::{OsStr, OsString}; -use crate::fmt; -use crate::io; use crate::num::NonZero; use crate::os::windows::prelude::*; use crate::path::{Path, PathBuf}; @@ -18,9 +16,7 @@ use crate::sys::process::ensure_no_nuls; use crate::sys::{c, to_u16s}; use crate::sys_common::wstr::WStrUnits; use crate::sys_common::AsInner; -use crate::vec; - -use crate::iter; +use crate::{fmt, io, iter, vec}; /// This is the const equivalent to `NonZero::new(n).unwrap()` /// diff --git a/std/src/sys/pal/windows/c.rs b/std/src/sys/pal/windows/c.rs index f7ec17fde22ea..08b75186aef90 100644 --- a/std/src/sys/pal/windows/c.rs +++ b/std/src/sys/pal/windows/c.rs @@ -6,8 +6,7 @@ #![allow(clippy::style)] use core::ffi::{c_uint, c_ulong, c_ushort, c_void, CStr}; -use core::mem; -use core::ptr; +use core::{mem, ptr}; pub(super) mod windows_targets; diff --git a/std/src/sys/pal/windows/fs.rs b/std/src/sys/pal/windows/fs.rs index a0a48fe759042..d99d4931de40f 100644 --- a/std/src/sys/pal/windows/fs.rs +++ b/std/src/sys/pal/windows/fs.rs @@ -1,26 +1,21 @@ use core::ptr::addr_of; -use crate::os::windows::prelude::*; - +use super::api::{self, WinError}; +use super::{to_u16s, IoResult}; use crate::borrow::Cow; use crate::ffi::{c_void, OsStr, OsString}; -use crate::fmt; use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom}; use crate::mem::{self, MaybeUninit}; use crate::os::windows::io::{AsHandle, BorrowedHandle}; +use crate::os::windows::prelude::*; use crate::path::{Path, PathBuf}; -use crate::ptr; -use crate::slice; use crate::sync::Arc; use crate::sys::handle::Handle; +use crate::sys::path::maybe_verbatim; use crate::sys::time::SystemTime; use crate::sys::{c, cvt, Align8}; use crate::sys_common::{AsInner, FromInner, IntoInner}; -use crate::thread; - -use super::api::{self, WinError}; -use super::{to_u16s, IoResult}; -use crate::sys::path::maybe_verbatim; +use crate::{fmt, ptr, slice, thread}; pub struct File { handle: Handle, diff --git a/std/src/sys/pal/windows/futex.rs b/std/src/sys/pal/windows/futex.rs index c54810e06cdd6..8c5081a607aa3 100644 --- a/std/src/sys/pal/windows/futex.rs +++ b/std/src/sys/pal/windows/futex.rs @@ -1,14 +1,13 @@ -use super::api::{self, WinError}; -use crate::sys::c; -use crate::sys::dur2timeout; use core::ffi::c_void; -use core::mem; -use core::ptr; use core::sync::atomic::{ AtomicBool, AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicIsize, AtomicPtr, AtomicU16, AtomicU32, AtomicU64, AtomicU8, AtomicUsize, }; use core::time::Duration; +use core::{mem, ptr}; + +use super::api::{self, WinError}; +use crate::sys::{c, dur2timeout}; /// An atomic for use as a futex that is at least 8-bits but may be larger. pub type SmallAtomic = AtomicU8; diff --git a/std/src/sys/pal/windows/handle.rs b/std/src/sys/pal/windows/handle.rs index e5b2da697821e..82a880faf5fa7 100644 --- a/std/src/sys/pal/windows/handle.rs +++ b/std/src/sys/pal/windows/handle.rs @@ -3,17 +3,15 @@ #[cfg(test)] mod tests; +use core::ffi::c_void; +use core::{cmp, mem, ptr}; + use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut, Read}; use crate::os::windows::io::{ AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle, }; -use crate::sys::c; -use crate::sys::cvt; +use crate::sys::{c, cvt}; use crate::sys_common::{AsInner, FromInner, IntoInner}; -use core::cmp; -use core::ffi::c_void; -use core::mem; -use core::ptr; /// An owned container for `HANDLE` object, closing them on Drop. /// diff --git a/std/src/sys/pal/windows/io.rs b/std/src/sys/pal/windows/io.rs index bf3dfdfdd3e7d..785a3f6768b70 100644 --- a/std/src/sys/pal/windows/io.rs +++ b/std/src/sys/pal/windows/io.rs @@ -1,9 +1,10 @@ +use core::ffi::c_void; + use crate::marker::PhantomData; use crate::mem::size_of; use crate::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle}; use crate::slice; use crate::sys::c; -use core::ffi::c_void; #[derive(Copy, Clone)] #[repr(transparent)] diff --git a/std/src/sys/pal/windows/mod.rs b/std/src/sys/pal/windows/mod.rs index 881ca17936d31..6ed77fbc3d445 100644 --- a/std/src/sys/pal/windows/mod.rs +++ b/std/src/sys/pal/windows/mod.rs @@ -1,6 +1,7 @@ #![allow(missing_docs, nonstandard_style)] #![forbid(unsafe_op_in_unsafe_fn)] +pub use self::rand::hashmap_random_keys; use crate::ffi::{OsStr, OsString}; use crate::io::ErrorKind; use crate::mem::MaybeUninit; @@ -9,8 +10,6 @@ use crate::path::PathBuf; use crate::sys::pal::windows::api::wide_str; use crate::time::Duration; -pub use self::rand::hashmap_random_keys; - #[macro_use] pub mod compat; diff --git a/std/src/sys/pal/windows/net.rs b/std/src/sys/pal/windows/net.rs index b7ecff032e4af..e27fdb72256f4 100644 --- a/std/src/sys/pal/windows/net.rs +++ b/std/src/sys/pal/windows/net.rs @@ -1,21 +1,17 @@ #![unstable(issue = "none", feature = "windows_net")] -use crate::cmp; +use core::ffi::{c_int, c_long, c_ulong, c_ushort}; + use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut, Read}; -use crate::mem; use crate::net::{Shutdown, SocketAddr}; use crate::os::windows::io::{ AsRawSocket, AsSocket, BorrowedSocket, FromRawSocket, IntoRawSocket, OwnedSocket, RawSocket, }; -use crate::ptr; use crate::sync::OnceLock; -use crate::sys; use crate::sys::c; -use crate::sys_common::net; -use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::sys_common::{net, AsInner, FromInner, IntoInner}; use crate::time::Duration; - -use core::ffi::{c_int, c_long, c_ulong, c_ushort}; +use crate::{cmp, mem, ptr, sys}; #[allow(non_camel_case_types)] pub type wrlen_t = i32; @@ -25,9 +21,9 @@ pub mod netc { //! //! Some Windows API types are not quite what's expected by our cross-platform //! net code. E.g. naming differences or different pointer types. - use crate::sys::c::{self, ADDRESS_FAMILY, ADDRINFOA, SOCKADDR, SOCKET}; use core::ffi::{c_char, c_int, c_uint, c_ulong, c_ushort, c_void}; + use crate::sys::c::{self, ADDRESS_FAMILY, ADDRINFOA, SOCKADDR, SOCKET}; // re-exports from Windows API bindings. pub use crate::sys::c::{ bind, connect, freeaddrinfo, getpeername, getsockname, getsockopt, listen, setsockopt, diff --git a/std/src/sys/pal/windows/os.rs b/std/src/sys/pal/windows/os.rs index f1f4d3a5d26ef..5242bc9da31fe 100644 --- a/std/src/sys/pal/windows/os.rs +++ b/std/src/sys/pal/windows/os.rs @@ -5,20 +5,15 @@ #[cfg(test)] mod tests; -use crate::os::windows::prelude::*; - +use super::api::{self, WinError}; +use super::to_u16s; use crate::error::Error as StdError; use crate::ffi::{OsStr, OsString}; -use crate::fmt; -use crate::io; use crate::os::windows::ffi::EncodeWide; +use crate::os::windows::prelude::*; use crate::path::{self, PathBuf}; -use crate::ptr; -use crate::slice; use crate::sys::{c, cvt}; - -use super::api::{self, WinError}; -use super::to_u16s; +use crate::{fmt, io, ptr, slice}; pub fn errno() -> i32 { api::get_last_error().code as i32 diff --git a/std/src/sys/pal/windows/pipe.rs b/std/src/sys/pal/windows/pipe.rs index 01433d68b695b..9eb19fcf2d7a2 100644 --- a/std/src/sys/pal/windows/pipe.rs +++ b/std/src/sys/pal/windows/pipe.rs @@ -1,18 +1,15 @@ -use crate::os::windows::prelude::*; - use crate::ffi::OsStr; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; -use crate::mem; +use crate::os::windows::prelude::*; use crate::path::Path; -use crate::ptr; use crate::sync::atomic::AtomicUsize; use crate::sync::atomic::Ordering::Relaxed; -use crate::sys::c; use crate::sys::fs::{File, OpenOptions}; use crate::sys::handle::Handle; -use crate::sys::hashmap_random_keys; use crate::sys::pal::windows::api::{self, WinError}; +use crate::sys::{c, hashmap_random_keys}; use crate::sys_common::{FromInner, IntoInner}; +use crate::{mem, ptr}; //////////////////////////////////////////////////////////////////////////////// // Anonymous pipes diff --git a/std/src/sys/pal/windows/process.rs b/std/src/sys/pal/windows/process.rs index 288ddb3e8011f..c285e1530a521 100644 --- a/std/src/sys/pal/windows/process.rs +++ b/std/src/sys/pal/windows/process.rs @@ -3,35 +3,28 @@ #[cfg(test)] mod tests; -use crate::cmp; +use core::ffi::c_void; + +use super::api::{self, WinError}; use crate::collections::BTreeMap; -use crate::env; use crate::env::consts::{EXE_EXTENSION, EXE_SUFFIX}; use crate::ffi::{OsStr, OsString}; -use crate::fmt; use crate::io::{self, Error, ErrorKind}; -use crate::mem; use crate::mem::MaybeUninit; use crate::num::NonZero; use crate::os::windows::ffi::{OsStrExt, OsStringExt}; use crate::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle}; use crate::path::{Path, PathBuf}; -use crate::ptr; use crate::sync::Mutex; use crate::sys::args::{self, Arg}; use crate::sys::c::{self, EXIT_FAILURE, EXIT_SUCCESS}; -use crate::sys::cvt; use crate::sys::fs::{File, OpenOptions}; use crate::sys::handle::Handle; -use crate::sys::path; use crate::sys::pipe::{self, AnonPipe}; -use crate::sys::stdio; +use crate::sys::{cvt, path, stdio}; use crate::sys_common::process::{CommandEnv, CommandEnvs}; use crate::sys_common::IntoInner; - -use core::ffi::c_void; - -use super::api::{self, WinError}; +use crate::{cmp, env, fmt, mem, ptr}; //////////////////////////////////////////////////////////////////////////////// // Command diff --git a/std/src/sys/pal/windows/process/tests.rs b/std/src/sys/pal/windows/process/tests.rs index 3fc0c75240c33..65325fa64a077 100644 --- a/std/src/sys/pal/windows/process/tests.rs +++ b/std/src/sys/pal/windows/process/tests.rs @@ -1,5 +1,4 @@ -use super::make_command_line; -use super::Arg; +use super::{make_command_line, Arg}; use crate::env; use crate::ffi::{OsStr, OsString}; use crate::process::Command; diff --git a/std/src/sys/pal/windows/stdio.rs b/std/src/sys/pal/windows/stdio.rs index c6a21665157d7..dc63a2219c315 100644 --- a/std/src/sys/pal/windows/stdio.rs +++ b/std/src/sys/pal/windows/stdio.rs @@ -1,16 +1,13 @@ #![unstable(issue = "none", feature = "windows_stdio")] +use core::str::utf8_char_width; + use super::api::{self, WinError}; -use crate::cmp; -use crate::io; use crate::mem::MaybeUninit; use crate::os::windows::io::{FromRawHandle, IntoRawHandle}; -use crate::ptr; -use crate::str; -use crate::sys::c; -use crate::sys::cvt; use crate::sys::handle::Handle; -use core::str::utf8_char_width; +use crate::sys::{c, cvt}; +use crate::{cmp, io, ptr, str}; #[cfg(test)] mod tests; diff --git a/std/src/sys/pal/windows/thread.rs b/std/src/sys/pal/windows/thread.rs index 668a3c05e20be..28bce529cd991 100644 --- a/std/src/sys/pal/windows/thread.rs +++ b/std/src/sys/pal/windows/thread.rs @@ -1,18 +1,15 @@ +use core::ffi::c_void; + +use super::time::WaitableTimer; +use super::to_u16s; use crate::ffi::CStr; -use crate::io; use crate::num::NonZero; -use crate::os::windows::io::AsRawHandle; -use crate::os::windows::io::HandleOrNull; -use crate::ptr; -use crate::sys::c; +use crate::os::windows::io::{AsRawHandle, HandleOrNull}; use crate::sys::handle::Handle; -use crate::sys::stack_overflow; +use crate::sys::{c, stack_overflow}; use crate::sys_common::FromInner; use crate::time::Duration; -use core::ffi::c_void; - -use super::time::WaitableTimer; -use super::to_u16s; +use crate::{io, ptr}; pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024; diff --git a/std/src/sys/pal/windows/time.rs b/std/src/sys/pal/windows/time.rs index 55ff233521acc..d9010e3996109 100644 --- a/std/src/sys/pal/windows/time.rs +++ b/std/src/sys/pal/windows/time.rs @@ -1,13 +1,12 @@ +use core::hash::{Hash, Hasher}; +use core::ops::Neg; + use crate::cmp::Ordering; -use crate::fmt; -use crate::mem; use crate::ptr::null; use crate::sys::c; use crate::sys_common::IntoInner; use crate::time::Duration; - -use core::hash::{Hash, Hasher}; -use core::ops::Neg; +use crate::{fmt, mem}; const NANOS_PER_SEC: u64 = 1_000_000_000; const INTERVALS_PER_SEC: u64 = NANOS_PER_SEC / 100; @@ -166,8 +165,7 @@ fn intervals2dur(intervals: u64) -> Duration { mod perf_counter { use super::NANOS_PER_SEC; use crate::sync::atomic::{AtomicU64, Ordering}; - use crate::sys::c; - use crate::sys::cvt; + use crate::sys::{c, cvt}; use crate::sys_common::mul_div_u64; use crate::time::Duration; diff --git a/std/src/sys/pal/xous/alloc.rs b/std/src/sys/pal/xous/alloc.rs index 601411173aacb..9ea43445d0206 100644 --- a/std/src/sys/pal/xous/alloc.rs +++ b/std/src/sys/pal/xous/alloc.rs @@ -46,10 +46,8 @@ unsafe impl GlobalAlloc for System { } mod lock { - use crate::sync::atomic::{ - AtomicI32, - Ordering::{Acquire, Release}, - }; + use crate::sync::atomic::AtomicI32; + use crate::sync::atomic::Ordering::{Acquire, Release}; static LOCKED: AtomicI32 = AtomicI32::new(0); diff --git a/std/src/sys/pal/xous/net/dns.rs b/std/src/sys/pal/xous/net/dns.rs index 63056324bfbd9..50efe978c4a83 100644 --- a/std/src/sys/pal/xous/net/dns.rs +++ b/std/src/sys/pal/xous/net/dns.rs @@ -1,8 +1,9 @@ +use core::convert::{TryFrom, TryInto}; + use crate::io; use crate::net::{Ipv4Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; use crate::os::xous::ffi::lend_mut; use crate::os::xous::services::{dns_server, DnsLendMut}; -use core::convert::{TryFrom, TryInto}; pub struct DnsError { pub code: u8, diff --git a/std/src/sys/pal/xous/net/tcplistener.rs b/std/src/sys/pal/xous/net/tcplistener.rs index 47305013083c8..ddfb289162b69 100644 --- a/std/src/sys/pal/xous/net/tcplistener.rs +++ b/std/src/sys/pal/xous/net/tcplistener.rs @@ -1,11 +1,11 @@ +use core::convert::TryInto; +use core::sync::atomic::{AtomicBool, AtomicU16, AtomicUsize, Ordering}; + use super::*; -use crate::fmt; -use crate::io; use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; use crate::os::xous::services; use crate::sync::Arc; -use core::convert::TryInto; -use core::sync::atomic::{AtomicBool, AtomicU16, AtomicUsize, Ordering}; +use crate::{fmt, io}; macro_rules! unimpl { () => { diff --git a/std/src/sys/pal/xous/net/tcpstream.rs b/std/src/sys/pal/xous/net/tcpstream.rs index 0ad8811071111..03442cf2fcdfd 100644 --- a/std/src/sys/pal/xous/net/tcpstream.rs +++ b/std/src/sys/pal/xous/net/tcpstream.rs @@ -1,3 +1,5 @@ +use core::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}; + use super::*; use crate::fmt; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; @@ -5,7 +7,6 @@ use crate::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, SocketAddrV4, SocketAdd use crate::os::xous::services; use crate::sync::Arc; use crate::time::Duration; -use core::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}; macro_rules! unimpl { () => { diff --git a/std/src/sys/pal/xous/net/udp.rs b/std/src/sys/pal/xous/net/udp.rs index 3d0522b25f3fb..de5133280ba9d 100644 --- a/std/src/sys/pal/xous/net/udp.rs +++ b/std/src/sys/pal/xous/net/udp.rs @@ -1,13 +1,13 @@ +use core::convert::TryInto; +use core::sync::atomic::{AtomicUsize, Ordering}; + use super::*; use crate::cell::Cell; -use crate::fmt; -use crate::io; use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; use crate::os::xous::services; use crate::sync::Arc; use crate::time::Duration; -use core::convert::TryInto; -use core::sync::atomic::{AtomicUsize, Ordering}; +use crate::{fmt, io}; macro_rules! unimpl { () => { diff --git a/std/src/sys/pal/xous/os.rs b/std/src/sys/pal/xous/os.rs index 9be09eed62989..8f8f35428c487 100644 --- a/std/src/sys/pal/xous/os.rs +++ b/std/src/sys/pal/xous/os.rs @@ -1,11 +1,10 @@ use super::unsupported; use crate::error::Error as StdError; use crate::ffi::{OsStr, OsString}; -use crate::fmt; -use crate::io; use crate::marker::PhantomData; use crate::os::xous::ffi::Error as XousError; use crate::path::{self, PathBuf}; +use crate::{fmt, io}; #[cfg(not(test))] #[cfg(feature = "panic_unwind")] diff --git a/std/src/sys/pal/xous/thread.rs b/std/src/sys/pal/xous/thread.rs index 279f24f9ee8e4..a95b0aa14d255 100644 --- a/std/src/sys/pal/xous/thread.rs +++ b/std/src/sys/pal/xous/thread.rs @@ -1,3 +1,5 @@ +use core::arch::asm; + use crate::ffi::CStr; use crate::io; use crate::num::NonZero; @@ -7,7 +9,6 @@ use crate::os::xous::ffi::{ }; use crate::os::xous::services::{ticktimer_server, TicktimerScalar}; use crate::time::Duration; -use core::arch::asm; pub struct Thread { tid: ThreadId, diff --git a/std/src/sys/pal/xous/time.rs b/std/src/sys/pal/xous/time.rs index 4e4ae67efffa2..ae8be81c0b7c5 100644 --- a/std/src/sys/pal/xous/time.rs +++ b/std/src/sys/pal/xous/time.rs @@ -1,7 +1,7 @@ use crate::os::xous::ffi::blocking_scalar; -use crate::os::xous::services::{ - systime_server, ticktimer_server, SystimeScalar::GetUtcTimeMs, TicktimerScalar::ElapsedMs, -}; +use crate::os::xous::services::SystimeScalar::GetUtcTimeMs; +use crate::os::xous::services::TicktimerScalar::ElapsedMs; +use crate::os::xous::services::{systime_server, ticktimer_server}; use crate::time::Duration; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] diff --git a/std/src/sys/pal/zkvm/os.rs b/std/src/sys/pal/zkvm/os.rs index e7d6cd52a258e..68d91a123acd4 100644 --- a/std/src/sys/pal/zkvm/os.rs +++ b/std/src/sys/pal/zkvm/os.rs @@ -1,12 +1,11 @@ use super::{abi, unsupported, WORD_SIZE}; use crate::error::Error as StdError; use crate::ffi::{OsStr, OsString}; -use crate::fmt; -use crate::io; use crate::marker::PhantomData; use crate::path::{self, PathBuf}; use crate::sys::os_str; use crate::sys_common::FromInner; +use crate::{fmt, io}; pub fn errno() -> i32 { 0 diff --git a/std/src/sys/pal/zkvm/stdio.rs b/std/src/sys/pal/zkvm/stdio.rs index e771ed0de28db..dd218c8894ca5 100644 --- a/std/src/sys/pal/zkvm/stdio.rs +++ b/std/src/sys/pal/zkvm/stdio.rs @@ -1,4 +1,5 @@ -use super::{abi, abi::fileno}; +use super::abi; +use super::abi::fileno; use crate::io; pub struct Stdin; diff --git a/std/src/sys/path/unix.rs b/std/src/sys/path/unix.rs index 837f68d3eaff7..2a7c025c3c46a 100644 --- a/std/src/sys/path/unix.rs +++ b/std/src/sys/path/unix.rs @@ -1,7 +1,6 @@ -use crate::env; use crate::ffi::OsStr; -use crate::io; use crate::path::{Path, PathBuf, Prefix}; +use crate::{env, io}; #[inline] pub fn is_sep_byte(b: u8) -> bool { diff --git a/std/src/sys/path/windows.rs b/std/src/sys/path/windows.rs index 9bd206ae1bf6e..21841eb18cc0e 100644 --- a/std/src/sys/path/windows.rs +++ b/std/src/sys/path/windows.rs @@ -1,8 +1,7 @@ use crate::ffi::{OsStr, OsString}; -use crate::io; use crate::path::{Path, PathBuf, Prefix}; -use crate::ptr; use crate::sys::pal::{c, fill_utf16_buf, os2path, to_u16s}; +use crate::{io, ptr}; #[cfg(test)] mod tests; diff --git a/std/src/sys/personality/dwarf/eh.rs b/std/src/sys/personality/dwarf/eh.rs index 0b81ea9e3d21e..89172ecf16bf9 100644 --- a/std/src/sys/personality/dwarf/eh.rs +++ b/std/src/sys/personality/dwarf/eh.rs @@ -12,9 +12,9 @@ #![allow(non_upper_case_globals)] #![allow(unused)] +use core::{mem, ptr}; + use super::DwarfReader; -use core::mem; -use core::ptr; pub const DW_EH_PE_omit: u8 = 0xFF; pub const DW_EH_PE_absptr: u8 = 0x00; diff --git a/std/src/sys/personality/emcc.rs b/std/src/sys/personality/emcc.rs index cb52ae89b1911..d374e3ad4c8f6 100644 --- a/std/src/sys/personality/emcc.rs +++ b/std/src/sys/personality/emcc.rs @@ -1,9 +1,10 @@ //! On Emscripten Rust panics are wrapped in C++ exceptions, so we just forward //! to `__gxx_personality_v0` which is provided by Emscripten. -use crate::ffi::c_int; use unwind as uw; +use crate::ffi::c_int; + // This is required by the compiler to exist (e.g., it's a lang item), but it's // never actually called by the compiler. Emscripten EH doesn't use a // personality function at all, it instead uses __cxa_find_matching_catch. diff --git a/std/src/sys/personality/gcc.rs b/std/src/sys/personality/gcc.rs index 1fb85a10179c5..f6b1844e153fd 100644 --- a/std/src/sys/personality/gcc.rs +++ b/std/src/sys/personality/gcc.rs @@ -37,9 +37,10 @@ //! and the last personality routine transfers control to the catch block. #![forbid(unsafe_op_in_unsafe_fn)] +use unwind as uw; + use super::dwarf::eh::{self, EHAction, EHContext}; use crate::ffi::c_int; -use unwind as uw; // Register ids were lifted from LLVM's TargetLowering::getExceptionPointerRegister() // and TargetLowering::getExceptionSelectorRegister() for each architecture, diff --git a/std/src/sys/sync/condvar/futex.rs b/std/src/sys/sync/condvar/futex.rs index 4586d0fd941a7..39cd97c01ea32 100644 --- a/std/src/sys/sync/condvar/futex.rs +++ b/std/src/sys/sync/condvar/futex.rs @@ -1,4 +1,5 @@ -use crate::sync::atomic::{AtomicU32, Ordering::Relaxed}; +use crate::sync::atomic::AtomicU32; +use crate::sync::atomic::Ordering::Relaxed; use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all}; use crate::sys::sync::Mutex; use crate::time::Duration; diff --git a/std/src/sys/sync/condvar/itron.rs b/std/src/sys/sync/condvar/itron.rs index 3a3039889e98b..f6f2b698e4945 100644 --- a/std/src/sys/sync/condvar/itron.rs +++ b/std/src/sys/sync/condvar/itron.rs @@ -1,9 +1,13 @@ //! POSIX conditional variable implementation based on user-space wait queues. -use crate::sys::pal::itron::{ - abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong, -}; -use crate::{mem::replace, ptr::NonNull, sys::sync::Mutex, time::Duration}; +use crate::mem::replace; +use crate::ptr::NonNull; +use crate::sys::pal::itron::error::expect_success_aborting; +use crate::sys::pal::itron::spin::SpinMutex; +use crate::sys::pal::itron::time::with_tmos_strong; +use crate::sys::pal::itron::{abi, task}; +use crate::sys::sync::Mutex; +use crate::time::Duration; // The implementation is inspired by the queue-based implementation shown in // Andrew D. Birrell's paper "Implementing Condition Variables with Semaphores" diff --git a/std/src/sys/sync/condvar/pthread.rs b/std/src/sys/sync/condvar/pthread.rs index a2a96410d932c..2b4bdfe415c80 100644 --- a/std/src/sys/sync/condvar/pthread.rs +++ b/std/src/sys/sync/condvar/pthread.rs @@ -1,6 +1,7 @@ use crate::cell::UnsafeCell; use crate::ptr; -use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed}; +use crate::sync::atomic::AtomicPtr; +use crate::sync::atomic::Ordering::Relaxed; use crate::sys::sync::{mutex, Mutex}; #[cfg(not(target_os = "nto"))] use crate::sys::time::TIMESPEC_MAX; diff --git a/std/src/sys/sync/condvar/teeos.rs b/std/src/sys/sync/condvar/teeos.rs index 6457da91c2a5d..943867cd76169 100644 --- a/std/src/sys/sync/condvar/teeos.rs +++ b/std/src/sys/sync/condvar/teeos.rs @@ -1,6 +1,7 @@ use crate::cell::UnsafeCell; use crate::ptr; -use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed}; +use crate::sync::atomic::AtomicPtr; +use crate::sync::atomic::Ordering::Relaxed; use crate::sys::sync::mutex::{self, Mutex}; use crate::sys::time::TIMESPEC_MAX; use crate::sys_common::lazy_box::{LazyBox, LazyInit}; diff --git a/std/src/sys/sync/condvar/windows7.rs b/std/src/sys/sync/condvar/windows7.rs index 07fa5fdd698ee..56eeeda551ebb 100644 --- a/std/src/sys/sync/condvar/windows7.rs +++ b/std/src/sys/sync/condvar/windows7.rs @@ -1,7 +1,6 @@ use crate::cell::UnsafeCell; -use crate::sys::c; -use crate::sys::os; use crate::sys::sync::{mutex, Mutex}; +use crate::sys::{c, os}; use crate::time::Duration; pub struct Condvar { diff --git a/std/src/sys/sync/condvar/xous.rs b/std/src/sys/sync/condvar/xous.rs index 7b218818ef8ef..007383479a100 100644 --- a/std/src/sys/sync/condvar/xous.rs +++ b/std/src/sys/sync/condvar/xous.rs @@ -1,8 +1,9 @@ +use core::sync::atomic::{AtomicUsize, Ordering}; + use crate::os::xous::ffi::{blocking_scalar, scalar}; use crate::os::xous::services::{ticktimer_server, TicktimerScalar}; use crate::sys::sync::Mutex; use crate::time::Duration; -use core::sync::atomic::{AtomicUsize, Ordering}; // The implementation is inspired by Andrew D. Birrell's paper // "Implementing Condition Variables with Semaphores" diff --git a/std/src/sys/sync/mutex/fuchsia.rs b/std/src/sys/sync/mutex/fuchsia.rs index 5d89e5a13fd36..81a6361a83a49 100644 --- a/std/src/sys/sync/mutex/fuchsia.rs +++ b/std/src/sys/sync/mutex/fuchsia.rs @@ -37,10 +37,8 @@ //! //! [mutex in Fuchsia's libsync]: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/system/ulib/sync/mutex.c -use crate::sync::atomic::{ - AtomicU32, - Ordering::{Acquire, Relaxed, Release}, -}; +use crate::sync::atomic::AtomicU32; +use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; use crate::sys::futex::zircon::{ zx_futex_wait, zx_futex_wake_single_owner, zx_handle_t, zx_thread_self, ZX_ERR_BAD_HANDLE, ZX_ERR_BAD_STATE, ZX_ERR_INVALID_ARGS, ZX_ERR_TIMED_OUT, ZX_ERR_WRONG_TYPE, ZX_OK, diff --git a/std/src/sys/sync/mutex/itron.rs b/std/src/sys/sync/mutex/itron.rs index a72c30d1fe373..8440ffdd33772 100644 --- a/std/src/sys/sync/mutex/itron.rs +++ b/std/src/sys/sync/mutex/itron.rs @@ -2,11 +2,9 @@ //! `TA_INHERIT` are available. #![forbid(unsafe_op_in_unsafe_fn)] -use crate::sys::pal::itron::{ - abi, - error::{expect_success, expect_success_aborting, fail, ItronError}, - spin::SpinIdOnceCell, -}; +use crate::sys::pal::itron::abi; +use crate::sys::pal::itron::error::{expect_success, expect_success_aborting, fail, ItronError}; +use crate::sys::pal::itron::spin::SpinIdOnceCell; pub struct Mutex { /// The ID of the underlying mutex object diff --git a/std/src/sys/sync/mutex/xous.rs b/std/src/sys/sync/mutex/xous.rs index 1426e48f8b7af..63efa5a0210ab 100644 --- a/std/src/sys/sync/mutex/xous.rs +++ b/std/src/sys/sync/mutex/xous.rs @@ -1,9 +1,7 @@ use crate::os::xous::ffi::{blocking_scalar, do_yield}; use crate::os::xous::services::{ticktimer_server, TicktimerScalar}; -use crate::sync::atomic::{ - AtomicBool, AtomicUsize, - Ordering::{Acquire, Relaxed, Release}, -}; +use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; +use crate::sync::atomic::{AtomicBool, AtomicUsize}; pub struct Mutex { /// The "locked" value indicates how many threads are waiting on this diff --git a/std/src/sys/sync/once/futex.rs b/std/src/sys/sync/once/futex.rs index 8a231e65ad134..e683777803f02 100644 --- a/std/src/sys/sync/once/futex.rs +++ b/std/src/sys/sync/once/futex.rs @@ -1,9 +1,7 @@ use crate::cell::Cell; use crate::sync as public; -use crate::sync::atomic::{ - AtomicU32, - Ordering::{Acquire, Relaxed, Release}, -}; +use crate::sync::atomic::AtomicU32; +use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; use crate::sync::once::ExclusiveState; use crate::sys::futex::{futex_wait, futex_wake_all}; diff --git a/std/src/sys/sync/once/queue.rs b/std/src/sys/sync/once/queue.rs index 730cdb768bd27..b04d252f8b91f 100644 --- a/std/src/sys/sync/once/queue.rs +++ b/std/src/sys/sync/once/queue.rs @@ -56,12 +56,10 @@ // allowed, so no need for `SeqCst`. use crate::cell::Cell; -use crate::fmt; -use crate::ptr; -use crate::sync as public; use crate::sync::atomic::{AtomicBool, AtomicPtr, Ordering}; use crate::sync::once::ExclusiveState; use crate::thread::{self, Thread}; +use crate::{fmt, ptr, sync as public}; type Masked = (); diff --git a/std/src/sys/sync/rwlock/futex.rs b/std/src/sys/sync/rwlock/futex.rs index b05c50951ac27..75ecc2ab5c52f 100644 --- a/std/src/sys/sync/rwlock/futex.rs +++ b/std/src/sys/sync/rwlock/futex.rs @@ -1,7 +1,5 @@ -use crate::sync::atomic::{ - AtomicU32, - Ordering::{Acquire, Relaxed, Release}, -}; +use crate::sync::atomic::AtomicU32; +use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all}; pub struct RwLock { diff --git a/std/src/sys/sync/rwlock/queue.rs b/std/src/sys/sync/rwlock/queue.rs index 9c59ee53654f8..458c16516bbe1 100644 --- a/std/src/sys/sync/rwlock/queue.rs +++ b/std/src/sys/sync/rwlock/queue.rs @@ -111,10 +111,8 @@ use crate::cell::OnceCell; use crate::hint::spin_loop; use crate::mem; use crate::ptr::{self, null_mut, without_provenance_mut, NonNull}; -use crate::sync::atomic::{ - AtomicBool, AtomicPtr, - Ordering::{AcqRel, Acquire, Relaxed, Release}, -}; +use crate::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release}; +use crate::sync::atomic::{AtomicBool, AtomicPtr}; use crate::thread::{self, Thread}; // Locking uses exponential backoff. `SPIN_COUNT` indicates how many times the diff --git a/std/src/sys/sync/rwlock/solid.rs b/std/src/sys/sync/rwlock/solid.rs index f18831c0692bd..0537140202091 100644 --- a/std/src/sys/sync/rwlock/solid.rs +++ b/std/src/sys/sync/rwlock/solid.rs @@ -1,13 +1,9 @@ //! A readers-writer lock implementation backed by the SOLID kernel extension. #![forbid(unsafe_op_in_unsafe_fn)] -use crate::sys::pal::{ - abi, - itron::{ - error::{expect_success, expect_success_aborting, fail, ItronError}, - spin::SpinIdOnceCell, - }, -}; +use crate::sys::pal::abi; +use crate::sys::pal::itron::error::{expect_success, expect_success_aborting, fail, ItronError}; +use crate::sys::pal::itron::spin::SpinIdOnceCell; pub struct RwLock { /// The ID of the underlying mutex object diff --git a/std/src/sys/sync/thread_parking/darwin.rs b/std/src/sys/sync/thread_parking/darwin.rs index 973c08f03171e..96e3d23c332c4 100644 --- a/std/src/sys/sync/thread_parking/darwin.rs +++ b/std/src/sys/sync/thread_parking/darwin.rs @@ -13,10 +13,8 @@ #![allow(non_camel_case_types)] use crate::pin::Pin; -use crate::sync::atomic::{ - AtomicI8, - Ordering::{Acquire, Release}, -}; +use crate::sync::atomic::AtomicI8; +use crate::sync::atomic::Ordering::{Acquire, Release}; use crate::time::Duration; type dispatch_semaphore_t = *mut crate::ffi::c_void; diff --git a/std/src/sys/sync/thread_parking/id.rs b/std/src/sys/sync/thread_parking/id.rs index 57c4daefd55f8..a7b07b509dfd8 100644 --- a/std/src/sys/sync/thread_parking/id.rs +++ b/std/src/sys/sync/thread_parking/id.rs @@ -9,10 +9,8 @@ use crate::cell::UnsafeCell; use crate::pin::Pin; -use crate::sync::atomic::{ - fence, AtomicI8, - Ordering::{Acquire, Relaxed, Release}, -}; +use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; +use crate::sync::atomic::{fence, AtomicI8}; use crate::sys::thread_parking::{current, park, park_timeout, unpark, ThreadId}; use crate::time::Duration; diff --git a/std/src/sys/sync/thread_parking/windows7.rs b/std/src/sys/sync/thread_parking/windows7.rs index d19df84774647..1000b63b6d01a 100644 --- a/std/src/sys/sync/thread_parking/windows7.rs +++ b/std/src/sys/sync/thread_parking/windows7.rs @@ -57,14 +57,13 @@ // [3]: https://docs.microsoft.com/en-us/archive/msdn-magazine/2012/november/windows-with-c-the-evolution-of-synchronization-in-windows-and-c // [4]: Windows Internals, Part 1, ISBN 9780735671300 +use core::ffi::c_void; + use crate::pin::Pin; -use crate::sync::atomic::{ - AtomicI8, - Ordering::{Acquire, Release}, -}; +use crate::sync::atomic::AtomicI8; +use crate::sync::atomic::Ordering::{Acquire, Release}; use crate::sys::{c, dur2timeout}; use crate::time::Duration; -use core::ffi::c_void; pub struct Parker { state: AtomicI8, @@ -185,16 +184,15 @@ impl Parker { #[cfg(target_vendor = "win7")] mod keyed_events { - use super::{Parker, EMPTY, NOTIFIED}; - use crate::sys::c; use core::pin::Pin; use core::ptr; - use core::sync::atomic::{ - AtomicPtr, - Ordering::{Acquire, Relaxed}, - }; + use core::sync::atomic::AtomicPtr; + use core::sync::atomic::Ordering::{Acquire, Relaxed}; use core::time::Duration; + use super::{Parker, EMPTY, NOTIFIED}; + use crate::sys::c; + pub unsafe fn park(parker: Pin<&Parker>) { // Wait for unpark() to produce this event. c::NtWaitForKeyedEvent(keyed_event_handle(), parker.ptr(), 0, ptr::null_mut()); diff --git a/std/src/sys/sync/thread_parking/xous.rs b/std/src/sys/sync/thread_parking/xous.rs index 0bd0462d77d35..64b6f731f2377 100644 --- a/std/src/sys/sync/thread_parking/xous.rs +++ b/std/src/sys/sync/thread_parking/xous.rs @@ -2,10 +2,8 @@ use crate::os::xous::ffi::{blocking_scalar, scalar}; use crate::os::xous::services::{ticktimer_server, TicktimerScalar}; use crate::pin::Pin; use crate::ptr; -use crate::sync::atomic::{ - AtomicI8, - Ordering::{Acquire, Release}, -}; +use crate::sync::atomic::AtomicI8; +use crate::sync::atomic::Ordering::{Acquire, Release}; use crate::time::Duration; const NOTIFIED: i8 = 1; diff --git a/std/src/sys/thread_local/guard/solid.rs b/std/src/sys/thread_local/guard/solid.rs index b65d00c5b5fb7..054b2d561c8b4 100644 --- a/std/src/sys/thread_local/guard/solid.rs +++ b/std/src/sys/thread_local/guard/solid.rs @@ -3,7 +3,8 @@ //! destructors for terminated tasks, we still keep our own list. use crate::cell::Cell; -use crate::sys::pal::{abi, itron::task}; +use crate::sys::pal::abi; +use crate::sys::pal::itron::task; use crate::sys::thread_local::destructors; pub fn enable() { diff --git a/std/src/sys/thread_local/guard/windows.rs b/std/src/sys/thread_local/guard/windows.rs index e08ac44e1af88..bf94f7d6e3d13 100644 --- a/std/src/sys/thread_local/guard/windows.rs +++ b/std/src/sys/thread_local/guard/windows.rs @@ -63,9 +63,10 @@ //! [1]: https://www.codeproject.com/Articles/8113/Thread-Local-Storage-The-C-Way //! [2]: https://github.com/ChromiumWebApps/chromium/blob/master/base/threading/thread_local_storage_win.cc#L42 +use core::ffi::c_void; + use crate::ptr; use crate::sys::c; -use core::ffi::c_void; pub fn enable() { // When destructors are used, we don't want LLVM eliminating CALLBACK for any diff --git a/std/src/sys/thread_local/key/windows.rs b/std/src/sys/thread_local/key/windows.rs index 8b43e558d5d98..f4e0f25a476ee 100644 --- a/std/src/sys/thread_local/key/windows.rs +++ b/std/src/sys/thread_local/key/windows.rs @@ -26,10 +26,8 @@ use crate::cell::UnsafeCell; use crate::ptr; -use crate::sync::atomic::{ - AtomicPtr, AtomicU32, - Ordering::{AcqRel, Acquire, Relaxed, Release}, -}; +use crate::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release}; +use crate::sync::atomic::{AtomicPtr, AtomicU32}; use crate::sys::c; use crate::sys::thread_local::guard; diff --git a/std/src/sys/thread_local/key/xous.rs b/std/src/sys/thread_local/key/xous.rs index db6dd5a87bac6..4fb2fdcc61925 100644 --- a/std/src/sys/thread_local/key/xous.rs +++ b/std/src/sys/thread_local/key/xous.rs @@ -36,14 +36,13 @@ // FIXME(joboet): implement support for native TLS instead. -use crate::mem::ManuallyDrop; -use crate::ptr; -use crate::sync::atomic::AtomicPtr; -use crate::sync::atomic::AtomicUsize; -use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; use core::arch::asm; +use crate::mem::ManuallyDrop; use crate::os::xous::ffi::{map_memory, unmap_memory, MemoryFlags}; +use crate::ptr; +use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; +use crate::sync::atomic::{AtomicPtr, AtomicUsize}; pub type Key = usize; pub type Dtor = unsafe extern "C" fn(*mut u8); diff --git a/std/src/sys/thread_local/native/eager.rs b/std/src/sys/thread_local/native/eager.rs index f8cd31613adad..fd48c4f720216 100644 --- a/std/src/sys/thread_local/native/eager.rs +++ b/std/src/sys/thread_local/native/eager.rs @@ -1,7 +1,6 @@ use crate::cell::{Cell, UnsafeCell}; use crate::ptr::{self, drop_in_place}; -use crate::sys::thread_local::abort_on_dtor_unwind; -use crate::sys::thread_local::destructors; +use crate::sys::thread_local::{abort_on_dtor_unwind, destructors}; #[derive(Clone, Copy)] enum State { diff --git a/std/src/sys/thread_local/native/lazy.rs b/std/src/sys/thread_local/native/lazy.rs index 9c914834d6e07..51294285ba013 100644 --- a/std/src/sys/thread_local/native/lazy.rs +++ b/std/src/sys/thread_local/native/lazy.rs @@ -1,8 +1,7 @@ use crate::cell::UnsafeCell; use crate::hint::unreachable_unchecked; use crate::ptr; -use crate::sys::thread_local::abort_on_dtor_unwind; -use crate::sys::thread_local::destructors; +use crate::sys::thread_local::{abort_on_dtor_unwind, destructors}; pub unsafe trait DestroyedState: Sized { fn register_dtor(s: &Storage); diff --git a/std/src/sys_common/io.rs b/std/src/sys_common/io.rs index 4a42ff3c618ce..e386c955f3767 100644 --- a/std/src/sys_common/io.rs +++ b/std/src/sys_common/io.rs @@ -5,12 +5,11 @@ pub const DEFAULT_BUF_SIZE: usize = if cfg!(target_os = "espidf") { 512 } else { #[cfg(test)] #[allow(dead_code)] // not used on emscripten pub mod test { - use crate::env; - use crate::fs; - use crate::path::{Path, PathBuf}; - use crate::thread; use rand::RngCore; + use crate::path::{Path, PathBuf}; + use crate::{env, fs, thread}; + pub struct TempDir(PathBuf); impl TempDir { diff --git a/std/src/sys_common/lazy_box.rs b/std/src/sys_common/lazy_box.rs index 63c3316bdeb28..b45b05f63baaa 100644 --- a/std/src/sys_common/lazy_box.rs +++ b/std/src/sys_common/lazy_box.rs @@ -5,10 +5,8 @@ use crate::marker::PhantomData; use crate::ops::{Deref, DerefMut}; use crate::ptr::null_mut; -use crate::sync::atomic::{ - AtomicPtr, - Ordering::{AcqRel, Acquire}, -}; +use crate::sync::atomic::AtomicPtr; +use crate::sync::atomic::Ordering::{AcqRel, Acquire}; pub(crate) struct LazyBox { ptr: AtomicPtr, diff --git a/std/src/sys_common/net.rs b/std/src/sys_common/net.rs index 0a82b50ae1ab6..25ebeb3502d20 100644 --- a/std/src/sys_common/net.rs +++ b/std/src/sys_common/net.rs @@ -1,19 +1,14 @@ #[cfg(test)] mod tests; -use crate::cmp; -use crate::fmt; +use crate::ffi::{c_int, c_void}; use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}; -use crate::mem; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; -use crate::ptr; use crate::sys::common::small_c_string::run_with_cstr; -use crate::sys::net::netc as c; -use crate::sys::net::{cvt, cvt_gai, cvt_r, init, wrlen_t, Socket}; +use crate::sys::net::{cvt, cvt_gai, cvt_r, init, netc as c, wrlen_t, Socket}; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::Duration; - -use crate::ffi::{c_int, c_void}; +use crate::{cmp, fmt, mem, ptr}; cfg_if::cfg_if! { if #[cfg(any( diff --git a/std/src/sys_common/process.rs b/std/src/sys_common/process.rs index 4d295cf0f09d5..5333ee146f7d6 100644 --- a/std/src/sys_common/process.rs +++ b/std/src/sys_common/process.rs @@ -2,12 +2,10 @@ #![unstable(feature = "process_internals", issue = "none")] use crate::collections::BTreeMap; -use crate::env; use crate::ffi::{OsStr, OsString}; -use crate::fmt; -use crate::io; use crate::sys::pipe::read2; use crate::sys::process::{EnvKey, ExitStatus, Process, StdioPipes}; +use crate::{env, fmt, io}; // Stores a set of changes to an environment #[derive(Clone)] diff --git a/std/src/sys_common/wtf8.rs b/std/src/sys_common/wtf8.rs index 6aeeb6259285d..277c9506febbb 100644 --- a/std/src/sys_common/wtf8.rs +++ b/std/src/sys_common/wtf8.rs @@ -23,16 +23,12 @@ use core::str::next_code_point; use crate::borrow::Cow; use crate::collections::TryReserveError; -use crate::fmt; use crate::hash::{Hash, Hasher}; use crate::iter::FusedIterator; -use crate::mem; -use crate::ops; use crate::rc::Rc; -use crate::slice; -use crate::str; use crate::sync::Arc; use crate::sys_common::AsInner; +use crate::{fmt, mem, ops, slice, str}; const UTF8_REPLACEMENT_CHARACTER: &str = "\u{FFFD}"; diff --git a/std/src/thread/mod.rs b/std/src/thread/mod.rs index ce6a6afdc1914..59720f77465e1 100644 --- a/std/src/thread/mod.rs +++ b/std/src/thread/mod.rs @@ -160,24 +160,19 @@ mod tests; use crate::any::Any; use crate::cell::{Cell, OnceCell, UnsafeCell}; -use crate::env; use crate::ffi::CStr; -use crate::fmt; -use crate::io; use crate::marker::PhantomData; use crate::mem::{self, forget, ManuallyDrop}; use crate::num::NonZero; -use crate::panic; -use crate::panicking; use crate::pin::Pin; use crate::ptr::addr_of_mut; -use crate::str; use crate::sync::atomic::{AtomicUsize, Ordering}; use crate::sync::Arc; use crate::sys::sync::Parker; use crate::sys::thread as imp; use crate::sys_common::{AsInner, IntoInner}; use crate::time::{Duration, Instant}; +use crate::{env, fmt, io, panic, panicking, str}; #[stable(feature = "scoped_threads", since = "1.63.0")] mod scoped; @@ -1292,9 +1287,10 @@ enum ThreadName { // This module ensures private fields are kept private, which is necessary to enforce the safety requirements. mod thread_name_string { + use core::str; + use super::ThreadName; use crate::ffi::{CStr, CString}; - use core::str; /// Like a `String` it's guaranteed UTF-8 and like a `CString` it's null terminated. pub(crate) struct ThreadNameString { diff --git a/std/src/thread/scoped.rs b/std/src/thread/scoped.rs index fbd6f8feecfe7..ba27c9220aea5 100644 --- a/std/src/thread/scoped.rs +++ b/std/src/thread/scoped.rs @@ -1,10 +1,9 @@ use super::{current, park, Builder, JoinInner, Result, Thread}; -use crate::fmt; -use crate::io; use crate::marker::PhantomData; use crate::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use crate::sync::Arc; +use crate::{fmt, io}; /// A scope to spawn scoped threads in. /// diff --git a/std/src/thread/tests.rs b/std/src/thread/tests.rs index 1fb1333be0e45..aa464d56f95b2 100644 --- a/std/src/thread/tests.rs +++ b/std/src/thread/tests.rs @@ -1,16 +1,12 @@ use super::Builder; use crate::any::Any; -use crate::mem; use crate::panic::panic_any; -use crate::result; -use crate::sync::{ - atomic::{AtomicBool, Ordering}, - mpsc::{channel, Sender}, - Arc, Barrier, -}; +use crate::sync::atomic::{AtomicBool, Ordering}; +use crate::sync::mpsc::{channel, Sender}; +use crate::sync::{Arc, Barrier}; use crate::thread::{self, Scope, ThreadId}; -use crate::time::Duration; -use crate::time::Instant; +use crate::time::{Duration, Instant}; +use crate::{mem, result}; // !!! These tests are dangerous. If something is buggy, they will hang, !!! // !!! instead of exiting cleanly. This might wedge the buildbots. !!! diff --git a/std/src/time.rs b/std/src/time.rs index 6f1a354d28a85..ae46670c25e61 100644 --- a/std/src/time.rs +++ b/std/src/time.rs @@ -34,18 +34,17 @@ #[cfg(test)] mod tests; +#[stable(feature = "time", since = "1.3.0")] +pub use core::time::Duration; +#[stable(feature = "duration_checked_float", since = "1.66.0")] +pub use core::time::TryFromFloatSecsError; + use crate::error::Error; use crate::fmt; use crate::ops::{Add, AddAssign, Sub, SubAssign}; use crate::sys::time; use crate::sys_common::{FromInner, IntoInner}; -#[stable(feature = "time", since = "1.3.0")] -pub use core::time::Duration; - -#[stable(feature = "duration_checked_float", since = "1.66.0")] -pub use core::time::TryFromFloatSecsError; - /// A measurement of a monotonically nondecreasing clock. /// Opaque and useful only with [`Duration`]. /// diff --git a/std/src/time/tests.rs b/std/src/time/tests.rs index 6ed84806e6d37..de36dc4c9fd16 100644 --- a/std/src/time/tests.rs +++ b/std/src/time/tests.rs @@ -1,8 +1,10 @@ -use super::{Duration, Instant, SystemTime, UNIX_EPOCH}; use core::fmt::Debug; + #[cfg(not(target_arch = "wasm32"))] use test::{black_box, Bencher}; +use super::{Duration, Instant, SystemTime, UNIX_EPOCH}; + macro_rules! assert_almost_eq { ($a:expr, $b:expr) => {{ let (a, b) = ($a, $b); diff --git a/std/tests/common/mod.rs b/std/tests/common/mod.rs index 1aad6549e76c3..7cf70c725e411 100644 --- a/std/tests/common/mod.rs +++ b/std/tests/common/mod.rs @@ -1,10 +1,9 @@ #![allow(unused)] -use rand::RngCore; -use std::env; -use std::fs; use std::path::{Path, PathBuf}; -use std::thread; +use std::{env, fs, thread}; + +use rand::RngCore; /// Copied from `std::test_helpers::test_rng`, since these tests rely on the /// seed not being the same for every RNG invocation too. diff --git a/std/tests/create_dir_all_bare.rs b/std/tests/create_dir_all_bare.rs index 79c3c8f528efa..8becf713205ee 100644 --- a/std/tests/create_dir_all_bare.rs +++ b/std/tests/create_dir_all_bare.rs @@ -3,9 +3,8 @@ //! Note that this test changes the current directory so //! should not be in the same process as other tests. -use std::env; -use std::fs; use std::path::{Path, PathBuf}; +use std::{env, fs}; mod common; diff --git a/std/tests/env.rs b/std/tests/env.rs index a1ca85c2145f5..4e472b4ce9953 100644 --- a/std/tests/env.rs +++ b/std/tests/env.rs @@ -4,9 +4,10 @@ use std::ffi::{OsStr, OsString}; use rand::distributions::{Alphanumeric, DistString}; mod common; -use common::test_rng; use std::thread; +use common::test_rng; + #[track_caller] fn make_rand_name() -> OsString { let n = format!("TEST{}", Alphanumeric.sample_string(&mut test_rng(), 10)); diff --git a/std/tests/pipe_subprocess.rs b/std/tests/pipe_subprocess.rs index c2278098b9b3f..1535742a83a21 100644 --- a/std/tests/pipe_subprocess.rs +++ b/std/tests/pipe_subprocess.rs @@ -3,7 +3,9 @@ fn main() { #[cfg(all(not(miri), any(unix, windows)))] { - use std::{env, io::Read, pipe::pipe, process}; + use std::io::Read; + use std::pipe::pipe; + use std::{env, process}; if env::var("I_AM_THE_CHILD").is_ok() { child(); diff --git a/std/tests/process_spawning.rs b/std/tests/process_spawning.rs index c56c111c37ded..d249eb7d50aa5 100644 --- a/std/tests/process_spawning.rs +++ b/std/tests/process_spawning.rs @@ -1,9 +1,6 @@ #![cfg(not(target_env = "sgx"))] -use std::env; -use std::fs; -use std::process; -use std::str; +use std::{env, fs, process, str}; mod common; diff --git a/std/tests/switch-stdout.rs b/std/tests/switch-stdout.rs index 0afe18088fa5f..42011a9b3da62 100644 --- a/std/tests/switch-stdout.rs +++ b/std/tests/switch-stdout.rs @@ -5,11 +5,10 @@ use std::io::{Read, Write}; mod common; -#[cfg(windows)] -use std::os::windows::io::OwnedHandle; - #[cfg(unix)] use std::os::fd::OwnedFd; +#[cfg(windows)] +use std::os::windows::io::OwnedHandle; #[cfg(unix)] fn switch_stdout_to(file: OwnedFd) -> OwnedFd { diff --git a/std/tests/windows.rs b/std/tests/windows.rs index 9f7596f1bc2c0..dab3182b81872 100644 --- a/std/tests/windows.rs +++ b/std/tests/windows.rs @@ -1,7 +1,9 @@ #![cfg(windows)] //! An external tests -use std::{ffi::OsString, os::windows::ffi::OsStringExt, path::PathBuf}; +use std::ffi::OsString; +use std::os::windows::ffi::OsStringExt; +use std::path::PathBuf; #[test] #[should_panic] diff --git a/test/src/bench.rs b/test/src/bench.rs index 9f34f54c3d60a..b71def3b03223 100644 --- a/test/src/bench.rs +++ b/test/src/bench.rs @@ -1,19 +1,16 @@ //! Benchmarking module. -use super::{ - event::CompletedTest, - options::BenchMode, - test_result::TestResult, - types::{TestDesc, TestId}, - Sender, -}; - -use crate::stats; -use std::cmp; -use std::io; use std::panic::{catch_unwind, AssertUnwindSafe}; use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; +use std::{cmp, io}; + +use super::event::CompletedTest; +use super::options::BenchMode; +use super::test_result::TestResult; +use super::types::{TestDesc, TestId}; +use super::Sender; +use crate::stats; /// An identity function that *__hints__* to the compiler to be maximally pessimistic about what /// `black_box` could do. diff --git a/test/src/cli.rs b/test/src/cli.rs index b7d24405b775e..4ccd825bf8dd3 100644 --- a/test/src/cli.rs +++ b/test/src/cli.rs @@ -1,11 +1,11 @@ //! Module converting command-line arguments into test configuration. use std::env; +use std::io::{self, IsTerminal}; use std::path::PathBuf; use super::options::{ColorConfig, Options, OutputFormat, RunIgnored}; use super::time::TestTimeOptions; -use std::io::{self, IsTerminal}; #[derive(Debug)] pub struct TestOpts { diff --git a/test/src/console.rs b/test/src/console.rs index 7e224d60d9dc5..4d4cdcf4d7b6c 100644 --- a/test/src/console.rs +++ b/test/src/console.rs @@ -5,19 +5,19 @@ use std::io; use std::io::prelude::Write; use std::time::Instant; -use super::{ - bench::fmt_bench_samples, - cli::TestOpts, - event::{CompletedTest, TestEvent}, - filter_tests, - formatters::{JsonFormatter, JunitFormatter, OutputFormatter, PrettyFormatter, TerseFormatter}, - helpers::{concurrency::get_concurrency, metrics::MetricMap}, - options::{Options, OutputFormat}, - run_tests, term, - test_result::TestResult, - time::{TestExecTime, TestSuiteExecTime}, - types::{NamePadding, TestDesc, TestDescAndFn}, +use super::bench::fmt_bench_samples; +use super::cli::TestOpts; +use super::event::{CompletedTest, TestEvent}; +use super::formatters::{ + JsonFormatter, JunitFormatter, OutputFormatter, PrettyFormatter, TerseFormatter, }; +use super::helpers::concurrency::get_concurrency; +use super::helpers::metrics::MetricMap; +use super::options::{Options, OutputFormat}; +use super::test_result::TestResult; +use super::time::{TestExecTime, TestSuiteExecTime}; +use super::types::{NamePadding, TestDesc, TestDescAndFn}; +use super::{filter_tests, run_tests, term}; /// Generic wrapper over stdout. pub enum OutputLocation { diff --git a/test/src/formatters/json.rs b/test/src/formatters/json.rs index 6245aae17c4d7..aa1c50641cb54 100644 --- a/test/src/formatters/json.rs +++ b/test/src/formatters/json.rs @@ -1,12 +1,12 @@ -use std::{borrow::Cow, io, io::prelude::Write}; +use std::borrow::Cow; +use std::io; +use std::io::prelude::Write; use super::OutputFormatter; -use crate::{ - console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}, - test_result::TestResult, - time, - types::TestDesc, -}; +use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}; +use crate::test_result::TestResult; +use crate::time; +use crate::types::TestDesc; pub(crate) struct JsonFormatter { out: OutputLocation, diff --git a/test/src/formatters/junit.rs b/test/src/formatters/junit.rs index a211ebf1ded16..96b432008404b 100644 --- a/test/src/formatters/junit.rs +++ b/test/src/formatters/junit.rs @@ -1,13 +1,12 @@ -use std::io::{self, prelude::Write}; +use std::io::prelude::Write; +use std::io::{self}; use std::time::Duration; use super::OutputFormatter; -use crate::{ - console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}, - test_result::TestResult, - time, - types::{TestDesc, TestType}, -}; +use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}; +use crate::test_result::TestResult; +use crate::time; +use crate::types::{TestDesc, TestType}; pub struct JunitFormatter { out: OutputLocation, diff --git a/test/src/formatters/mod.rs b/test/src/formatters/mod.rs index bc6ffebc1d3b2..f1225fecfef1a 100644 --- a/test/src/formatters/mod.rs +++ b/test/src/formatters/mod.rs @@ -1,11 +1,10 @@ -use std::{io, io::prelude::Write}; +use std::io; +use std::io::prelude::Write; -use crate::{ - console::{ConsoleTestDiscoveryState, ConsoleTestState}, - test_result::TestResult, - time, - types::{TestDesc, TestName}, -}; +use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState}; +use crate::test_result::TestResult; +use crate::time; +use crate::types::{TestDesc, TestName}; mod json; mod junit; diff --git a/test/src/formatters/pretty.rs b/test/src/formatters/pretty.rs index 22654a3400b44..7089eae4330a0 100644 --- a/test/src/formatters/pretty.rs +++ b/test/src/formatters/pretty.rs @@ -1,14 +1,12 @@ -use std::{io, io::prelude::Write}; +use std::io; +use std::io::prelude::Write; use super::OutputFormatter; -use crate::{ - bench::fmt_bench_samples, - console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}, - term, - test_result::TestResult, - time, - types::TestDesc, -}; +use crate::bench::fmt_bench_samples; +use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}; +use crate::test_result::TestResult; +use crate::types::TestDesc; +use crate::{term, time}; pub(crate) struct PrettyFormatter { out: OutputLocation, diff --git a/test/src/formatters/terse.rs b/test/src/formatters/terse.rs index 875c66e5fa32c..534aa2f33110c 100644 --- a/test/src/formatters/terse.rs +++ b/test/src/formatters/terse.rs @@ -1,15 +1,12 @@ -use std::{io, io::prelude::Write}; +use std::io; +use std::io::prelude::Write; use super::OutputFormatter; -use crate::{ - bench::fmt_bench_samples, - console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}, - term, - test_result::TestResult, - time, - types::NamePadding, - types::TestDesc, -}; +use crate::bench::fmt_bench_samples; +use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}; +use crate::test_result::TestResult; +use crate::types::{NamePadding, TestDesc}; +use crate::{term, time}; // We insert a '\n' when the output hits 100 columns in quiet mode. 88 test // result chars leaves 12 chars for a progress count like " 11704/12853". diff --git a/test/src/helpers/concurrency.rs b/test/src/helpers/concurrency.rs index 1854c6a76524d..b1545cbec438a 100644 --- a/test/src/helpers/concurrency.rs +++ b/test/src/helpers/concurrency.rs @@ -1,7 +1,8 @@ //! Helper module which helps to determine amount of threads to be used //! during tests execution. -use std::{env, num::NonZero, thread}; +use std::num::NonZero; +use std::{env, thread}; pub fn get_concurrency() -> usize { if let Ok(value) = env::var("RUST_TEST_THREADS") { diff --git a/test/src/helpers/shuffle.rs b/test/src/helpers/shuffle.rs index 2ac3bfbd4d6f2..14389eb0e37af 100644 --- a/test/src/helpers/shuffle.rs +++ b/test/src/helpers/shuffle.rs @@ -1,8 +1,9 @@ -use crate::cli::TestOpts; -use crate::types::{TestDescAndFn, TestId, TestName}; use std::hash::{DefaultHasher, Hasher}; use std::time::{SystemTime, UNIX_EPOCH}; +use crate::cli::TestOpts; +use crate::types::{TestDescAndFn, TestId, TestName}; + pub fn get_shuffle_seed(opts: &TestOpts) -> Option { opts.shuffle_seed.or_else(|| { if opts.shuffle { diff --git a/test/src/lib.rs b/test/src/lib.rs index 71cb796b93705..516e3f1300e24 100644 --- a/test/src/lib.rs +++ b/test/src/lib.rs @@ -25,45 +25,39 @@ #![feature(test)] #![allow(internal_features)] +pub use cli::TestOpts; + pub use self::bench::{black_box, Bencher}; pub use self::console::run_tests_console; pub use self::options::{ColorConfig, Options, OutputFormat, RunIgnored, ShouldPanic}; pub use self::types::TestName::*; pub use self::types::*; pub use self::ColorConfig::*; -pub use cli::TestOpts; // Module to be used by rustc to compile tests in libtest pub mod test { - pub use crate::{ - assert_test_result, - bench::Bencher, - cli::{parse_opts, TestOpts}, - filter_tests, - helpers::metrics::{Metric, MetricMap}, - options::{Options, RunIgnored, RunStrategy, ShouldPanic}, - run_test, test_main, test_main_static, - test_result::{TestResult, TrFailed, TrFailedMsg, TrIgnored, TrOk}, - time::{TestExecTime, TestTimeOptions}, - types::{ - DynTestFn, DynTestName, StaticBenchFn, StaticTestFn, StaticTestName, TestDesc, - TestDescAndFn, TestId, TestName, TestType, - }, + pub use crate::bench::Bencher; + pub use crate::cli::{parse_opts, TestOpts}; + pub use crate::helpers::metrics::{Metric, MetricMap}; + pub use crate::options::{Options, RunIgnored, RunStrategy, ShouldPanic}; + pub use crate::test_result::{TestResult, TrFailed, TrFailedMsg, TrIgnored, TrOk}; + pub use crate::time::{TestExecTime, TestTimeOptions}; + pub use crate::types::{ + DynTestFn, DynTestName, StaticBenchFn, StaticTestFn, StaticTestName, TestDesc, + TestDescAndFn, TestId, TestName, TestType, }; + pub use crate::{assert_test_result, filter_tests, run_test, test_main, test_main_static}; } -use std::{ - collections::VecDeque, - env, io, - io::prelude::Write, - mem::ManuallyDrop, - panic::{self, catch_unwind, AssertUnwindSafe, PanicHookInfo}, - process::{self, Command, Termination}, - sync::mpsc::{channel, Sender}, - sync::{Arc, Mutex}, - thread, - time::{Duration, Instant}, -}; +use std::collections::VecDeque; +use std::io::prelude::Write; +use std::mem::ManuallyDrop; +use std::panic::{self, catch_unwind, AssertUnwindSafe, PanicHookInfo}; +use std::process::{self, Command, Termination}; +use std::sync::mpsc::{channel, Sender}; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; +use std::{env, io, thread}; pub mod bench; mod cli; @@ -82,6 +76,7 @@ mod types; mod tests; use core::any::Any; + use event::{CompletedTest, TestEvent}; use helpers::concurrency::get_concurrency; use helpers::shuffle::{get_shuffle_seed, shuffle_tests}; diff --git a/test/src/stats/tests.rs b/test/src/stats/tests.rs index 3a6e8401bf1ab..4b209dcf214da 100644 --- a/test/src/stats/tests.rs +++ b/test/src/stats/tests.rs @@ -1,10 +1,11 @@ use super::*; extern crate test; -use self::test::test::Bencher; use std::io; use std::io::prelude::*; +use self::test::test::Bencher; + // Test vectors generated from R, using the script src/etc/stat-test-vectors.r. macro_rules! assert_approx_eq { diff --git a/test/src/term.rs b/test/src/term.rs index a14b0d4f5a962..e736e85d46966 100644 --- a/test/src/term.rs +++ b/test/src/term.rs @@ -12,7 +12,8 @@ #![deny(missing_docs)] -use std::io::{self, prelude::*}; +use std::io::prelude::*; +use std::io::{self}; pub(crate) use terminfo::TerminfoTerminal; #[cfg(windows)] diff --git a/test/src/term/terminfo/mod.rs b/test/src/term/terminfo/mod.rs index 67ba89410cd99..67eec3ca50f48 100644 --- a/test/src/term/terminfo/mod.rs +++ b/test/src/term/terminfo/mod.rs @@ -1,20 +1,18 @@ //! Terminfo database interface. use std::collections::HashMap; -use std::env; -use std::error; -use std::fmt; use std::fs::File; -use std::io::{self, prelude::*, BufReader}; +use std::io::prelude::*; +use std::io::{self, BufReader}; use std::path::Path; - -use super::color; -use super::Terminal; +use std::{env, error, fmt}; use parm::{expand, Param, Variables}; use parser::compiled::{msys_terminfo, parse}; use searcher::get_dbpath_for_term; +use super::{color, Terminal}; + /// A parsed terminfo database entry. #[allow(unused)] #[derive(Debug)] diff --git a/test/src/term/terminfo/parm.rs b/test/src/term/terminfo/parm.rs index c5b4ef01893c2..529ec0c36e4a5 100644 --- a/test/src/term/terminfo/parm.rs +++ b/test/src/term/terminfo/parm.rs @@ -1,10 +1,10 @@ //! Parameterized string expansion +use std::iter::repeat; + use self::Param::*; use self::States::*; -use std::iter::repeat; - #[cfg(test)] mod tests; diff --git a/test/src/term/terminfo/parser/compiled.rs b/test/src/term/terminfo/parser/compiled.rs index 5d40b7988b52d..e687b3be41fbf 100644 --- a/test/src/term/terminfo/parser/compiled.rs +++ b/test/src/term/terminfo/parser/compiled.rs @@ -2,11 +2,12 @@ //! ncurses-compatible compiled terminfo format parsing (term(5)) -use super::super::TermInfo; use std::collections::HashMap; use std::io; use std::io::prelude::*; +use super::super::TermInfo; + #[cfg(test)] mod tests; diff --git a/test/src/term/terminfo/searcher.rs b/test/src/term/terminfo/searcher.rs index 8b8df34b0791e..1b29598cf804e 100644 --- a/test/src/term/terminfo/searcher.rs +++ b/test/src/term/terminfo/searcher.rs @@ -2,9 +2,8 @@ //! //! Does not support hashed database, only filesystem! -use std::env; -use std::fs; use std::path::PathBuf; +use std::{env, fs}; #[cfg(test)] mod tests; diff --git a/test/src/term/win.rs b/test/src/term/win.rs index 65764c0ffc1b9..ce9cad37f306b 100644 --- a/test/src/term/win.rs +++ b/test/src/term/win.rs @@ -5,8 +5,7 @@ use std::io; use std::io::prelude::*; -use super::color; -use super::Terminal; +use super::{color, Terminal}; /// A Terminal implementation that uses the Win32 Console API. pub(crate) struct WinConsole { diff --git a/test/src/test_result.rs b/test/src/test_result.rs index 98c54f038da6c..c5f4b03bfc96c 100644 --- a/test/src/test_result.rs +++ b/test/src/test_result.rs @@ -1,16 +1,14 @@ use std::any::Any; -use std::process::ExitStatus; - #[cfg(unix)] use std::os::unix::process::ExitStatusExt; +use std::process::ExitStatus; +pub use self::TestResult::*; use super::bench::BenchSamples; use super::options::ShouldPanic; use super::time; use super::types::TestDesc; -pub use self::TestResult::*; - // Return code for secondary process. // Start somewhere other than 0 so we know the return code means what we think // it means. diff --git a/test/src/tests.rs b/test/src/tests.rs index 43a906ad298d1..ba2f35362c54f 100644 --- a/test/src/tests.rs +++ b/test/src/tests.rs @@ -1,5 +1,4 @@ use super::*; - use crate::{ console::OutputLocation, formatters::PrettyFormatter, @@ -237,8 +236,9 @@ fn test_should_panic_bad_message() { #[cfg(not(target_os = "emscripten"))] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn test_should_panic_non_string_message_type() { - use crate::tests::TrFailedMsg; use std::any::TypeId; + + use crate::tests::TrFailedMsg; fn f() -> Result<(), String> { std::panic::panic_any(1i32); } diff --git a/test/src/time.rs b/test/src/time.rs index 7fd69d7f7e73c..02ae050db55bd 100644 --- a/test/src/time.rs +++ b/test/src/time.rs @@ -5,10 +5,9 @@ //! - Provide helpers for `report-time` and `measure-time` options. //! - Provide newtypes for executions times. -use std::env; -use std::fmt; use std::str::FromStr; use std::time::{Duration, Instant}; +use std::{env, fmt}; use super::types::{TestDesc, TestType}; @@ -24,9 +23,10 @@ pub const TEST_WARN_TIMEOUT_S: u64 = 60; /// Example of the expected format is `RUST_TEST_TIME_xxx=100,200`, where 100 means /// warn time, and 200 means critical time. pub mod time_constants { - use super::TEST_WARN_TIMEOUT_S; use std::time::Duration; + use super::TEST_WARN_TIMEOUT_S; + /// Environment variable for overriding default threshold for unit-tests. pub const UNIT_ENV_NAME: &str = "RUST_TEST_TIME_UNIT"; diff --git a/test/src/types.rs b/test/src/types.rs index 6a7035a8e2918..c3be3466cb928 100644 --- a/test/src/types.rs +++ b/test/src/types.rs @@ -4,15 +4,14 @@ use std::borrow::Cow; use std::fmt; use std::sync::mpsc::Sender; -use super::__rust_begin_short_backtrace; -use super::bench::Bencher; -use super::event::CompletedTest; -use super::options; - pub use NamePadding::*; pub use TestFn::*; pub use TestName::*; +use super::bench::Bencher; +use super::event::CompletedTest; +use super::{__rust_begin_short_backtrace, options}; + /// Type of the test according to the [Rust book](https://doc.rust-lang.org/cargo/guide/tests.html) /// conventions. #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] diff --git a/unwind/src/unwinding.rs b/unwind/src/unwinding.rs index 083acaeb56af2..b3460791ce5ca 100644 --- a/unwind/src/unwinding.rs +++ b/unwind/src/unwinding.rs @@ -28,9 +28,7 @@ pub enum _Unwind_Reason_Code { _URC_FAILURE = 9, // used only by ARM EHABI } pub use _Unwind_Reason_Code::*; - -pub use unwinding::abi::UnwindContext; -pub use unwinding::abi::UnwindException; +pub use unwinding::abi::{UnwindContext, UnwindException}; pub enum _Unwind_Context {} pub use unwinding::custom_eh_frame_finder::{