Commit Graph

10435 Commits

Author SHA1 Message Date
Kiran Shila
f5c45ad284
Fix typo in HashMap::with_capacity 2023-02-05 10:13:30 -08:00
Michael Goulet
13bd75f425
Rollup merge of #107632 - ameknite:issue-107622-fix, r=jyn514
Clarifying that .map() returns None if None.

Fix #107622
2023-02-03 14:15:24 -08:00
Michael Goulet
e99e05d135
Rollup merge of #107551 - fee1-dead-contrib:rm_const_fnmut_helper, r=oli-obk
Replace `ConstFnMutClosure` with const closures

Also fixes a parser bug. cc `@oli-obk` for compiler changes
2023-02-03 14:15:22 -08:00
Michael Goulet
beb5cc9cf7
Rollup merge of #107519 - joboet:raw_os_error_ty, r=Amanieu
Add type alias for raw OS errors

Implement rust-lang/libs-team#173.

`@rustbot` label +S-waiting-on-ACP +T-libs-api
2023-02-03 14:15:21 -08:00
Ame
b384692f4c nit fixed 2023-02-03 13:57:53 -06:00
Ame
c2b65ffe29 Clarifying that .map() returns None if None. 2023-02-03 13:57:53 -06:00
Deadbeef
b886a4de15 Replace ConstFnMutClosure with const closures 2023-02-03 14:43:13 +00:00
Matthias Krüger
86015515b5
Rollup merge of #107598 - chenyukang:yukang/fix-core-bench, r=thomcc
Fix benchmarks in library/core with black_box

Fixes #107590
2023-02-03 06:30:24 +01:00
yukang
fe84cecf60 fix #107590, Fix benchmarks in library/core with black_box 2023-02-03 00:33:36 +08:00
Matthias Krüger
1dbb5efff3
Rollup merge of #107442 - lukas-code:slice-panics, r=cuviper
improve panic message for slice windows and chunks

before:
```text
thread 'main' panicked at 'size is zero', /rustc/1e225413a21fa69570bd3fefea9eb05e33f8b917/library/core/src/slice/mod.rs:809:44
```
```text
thread 'main' panicked at 'assertion failed: `(left != right)`
  left: `0`,
 right: `0`: chunks cannot have a size of zero', /rustc/1e225413a21fa69570bd3fefea9eb05e33f8b917/library/core/src/slice/mod.rs:843:9
```

after:
```text
thread 'main' panicked at 'chunk size must be non-zero', src/main.rs:4:22
```

fixes https://github.com/rust-lang/rust/issues/107437
2023-02-01 05:54:38 +01:00
Matthias Krüger
0d2ab67742
Rollup merge of #107389 - zvavybir:master, r=estebank
Fixing confusion between mod and remainder

Like many programming languages, rust too confuses remainder and modulus.  The `%` operator and the associated `Rem` trait is (as the trait name suggests) the remainder, but since most people are linguistically more familiar with the modulus the documentation sometimes claims otherwise.  This PR tries to fix this problem in rustc.
2023-02-01 05:54:37 +01:00
Lukas Markeffsky
2fbe9274aa improve panic message for slice windows and chunks 2023-01-31 23:49:42 +01:00
Guillaume Gomez
adc3f8a44b
Rollup merge of #107535 - dcompoze:tcp-doc-unwrap, r=cuviper
Replace unwrap with ? in TcpListener doc

The example in TcpListener doc returns `std::io::Result<()>` but the code inside the function uses `unwrap()` instead of `?`.
2023-01-31 23:38:55 +01:00
Daniel Chmielewski
943f833314
Replace unwrap with ? in TcpListener doc 2023-01-31 21:04:49 +00:00
bors
dc1d9d50fb Auto merge of #107297 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini
Bump bootstrap compiler to 1.68

This also changes our stage0.json to include the rustc component for the rustfmt pinned nightly toolchain, which is currently necessary due to rustfmt dynamically linking to that toolchain's librustc_driver and libstd.

r? `@pietroalbini`
2023-01-31 19:24:29 +00:00
joboet
42cc28ac8b
std: add type alias for raw OS errors
Implement rust-lang/libs-team#173.
2023-01-31 17:23:35 +01:00
Yuki Okushi
150340bafd
Rollup merge of #107494 - lebensterben:patch-1, r=JohnTitor
fix link in std::path::Path::display()

The link `Debug` points to should be the trait `Debug`, not the macro `Debug`.
2023-01-31 11:46:26 +09:00
Yuki Okushi
39d2639f81
Rollup merge of #107445 - Swatinem:rm-genfuture, r=cuviper
Remove `GenFuture` from core

The handling of async constructs in the compiler does not rely on `GenFuture` anymore since `1.67`, so this code can now be removed from `core`.
2023-01-31 11:46:23 +09:00
Lucius Hu
3c408d82a3
fix link in std::path::Path::display()
The link `Debug` points to should be the trait `Debug`, not the macro `Debug`.
2023-01-31 00:20:27 +00:00
Matthias Kaak
8d7b092a11
Improved wording of error messages of missing remainder implementations 2023-01-30 19:54:33 +00:00
Mark Rousskov
5b08c9f397 stage-step cfgs 2023-01-30 13:09:09 -05:00
Matthias Krüger
b3b9383f8d
Rollup merge of #107424 - bpeel:clone-into-from-share-code, r=scottmcm
Make Vec::clone_from and slice::clone_into share the same code

In the past, `Vec::clone_from` was implemented using `slice::clone_into`. The code from `clone_into` was later duplicated into `clone_from` in 8725e4c337, which is the commit that adds custom allocator support to Vec. Presumably this was done because the `slice::clone_into` method only works for vecs with the default allocator so it would have the wrong type to clone into `Vec<T, A>`.

Later on in 361398009b the code for the two methods diverged because the `Vec::clone_from` version gained a specialization to optimize the case when T is Copy. In order to reduce code duplication and make them both be able to take advantage of this specialization, this PR moves the specialization into the slice module and makes vec use it again.
2023-01-30 17:50:10 +01:00
bors
006ca9b14d Auto merge of #107080 - Urgau:cleanup-bootstrap-extra-check-cfgs, r=Mark-Simulacrum
bootstrap: cleanup the list of extra check cfgs

This PR performs some cleanups on the `EXTRA_CHECK_CFGS` list in bootstrap.

- `target_os=watchos`: no longer relevant because there are now proper targets `*-apple-watchos`
 - `target_arch=nvptx64`: target `nvptx64-nvidia-cuda` makes it useless
 - `target_arch=le32`: target was removed (https://github.com/rust-lang/rust/pull/45041)
 - `release`: was removed from rustfmt (https://github.com/rust-lang/rustfmt/pull/5375 and https://github.com/rust-lang/rustfmt/pull/5449)
 - `dont_compile_me`: was removed from stdarch (https://github.com/rust-lang/stdarch/pull/1308)

Also made some external cfg exception mode clear and only activated for rustc and rustc tools (as to not have the Standard Library unintentionally depend on them).
2023-01-30 13:56:40 +00:00
Dylan DPC
da56c44ba2
Rollup merge of #107459 - tshepang:cosistency, r=WaffleLapkin
end entry paragraph with a period (.)
2023-01-30 15:11:47 +05:30
Dylan DPC
f01b8f5cf4
Rollup merge of #107452 - y21:get-mut-unchecked-typo, r=Mark-Simulacrum
Fix typo in `{Rc, Arc}::get_mut_unchecked` docs

Just a correction in the documentation of `{Rc, Arc}::get_mut_unchecked`.
2023-01-30 15:11:46 +05:30
Dylan DPC
28340bab88
Rollup merge of #101569 - m-ou-se:alloc-no-rexport-argumentv1, r=thomcc
Don't re-export private/unstable ArgumentV1 from `alloc`.

The `alloc::fmt::ArgumentV1` re-export was marked as `#[stable]` even though the original `core::fmt::ArgumentV1` is `#[unstable]` (and `#[doc(hidden)]`).

(It wasn't usable though:

```
error[E0658]: use of unstable library feature 'fmt_internals': internal to format_args!
 --> src/main.rs:4:12
  |
4 |     let _: alloc::fmt::ArgumentV1 = todo!();
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: add `#![feature(fmt_internals)]` to the crate attributes to enable
```
)

Part of #99012
2023-01-30 15:11:44 +05:30
Tshepang Mbambo
72360191f1 end entry paragraph with a period (.) 2023-01-30 07:37:02 +02:00
Mara Bos
67bb7ba3ea Don't re-export private/unstable ArgumentV1 from alloc. 2023-01-29 20:15:02 +01:00
y21
61b18b58ab fix typo in {Rc, Arc}::get_mut_unchecked docs 2023-01-29 20:11:36 +01:00
Matthias Krüger
392265419a
Rollup merge of #107431 - notriddle:notriddle/colon, r=thomcc
docs: remove colon from time header

It's not used anywhere else; the inconsistency is weird.
2023-01-29 20:03:38 +01:00
Matthias Krüger
782da867c8
Rollup merge of #106798 - scottmcm:signum-via-cmp, r=Mark-Simulacrum
Implement `signum` with `Ord`

Rather than needing to do things like #105840 for `signum` too, might as well just implement that method using `Ord`, since it's doing the same "I need `-1`/`0`/`+1`" behaviour that `cmp` is already doing.

This also seems to slightly improve the assembly: <https://rust.godbolt.org/z/5oEEqbxK1>
2023-01-29 20:03:36 +01:00
Matthias Krüger
192eecd53a
Rollup merge of #106769 - lenko-d:libtest-print_why_a_test_was_ignored_if_its_the_only_test_specified, r=Mark-Simulacrum
libtest: Print why a test was ignored if it's the only test specified.

Fixes [#106659](https://github.com/rust-lang/rust/issues/106659)
Needed by [106763](https://github.com/rust-lang/rust/pull/106763)
2023-01-29 20:03:36 +01:00
Arpad Borsos
5372e66884
Remove GenFuture from core
The handling of async constructs in the compiler does not rely on `GenFuture`
anymore since `1.67`, so this code can now be removed from `core`.
2023-01-29 15:20:03 +01:00
bors
d117135f5a Auto merge of #106253 - nbdd0121:upcast, r=compiler-errors
Skip possible where_clause_object_safety lints when checking `multiple_supertrait_upcastable`

Fix #106247

To achieve this, I lifted the `WhereClauseReferencesSelf` out from `object_safety_violations` and move it into `is_object_safe` (which is changed to a new query).

cc `@dtolnay`
r? `@compiler-errors`
2023-01-29 10:20:25 +00:00
Matthias Krüger
33da3c3df0
Rollup merge of #107154 - glaubitz:m68k-alloc, r=JohnTitor
library/std/sys_common: Define MIN_ALIGN for m68k-unknown-linux-gnu

This PR adds the missing definition of MIN_ALIGN for the m68k-unknown-linux target.
2023-01-29 06:14:17 +01:00
Matthias Krüger
0f86ada9d8
Rollup merge of #106618 - jmillikin:os-net-rustdoc-wasm32, r=JohnTitor
Disable `linux_ext` in wasm32 and fortanix rustdoc builds.

The `std::os::unix` module is stubbed out when building docs for these target platforms. The introduction of Linux-specific extension traits caused `std::os::net` to depend on sub-modules of `std::os::unix`, which broke rustdoc for the `wasm32-unknown-unknown` target.

Adding an additional `#[cfg]` guard solves that rustdoc failure by not declaring `linux_ext` on targets with a stubbed `std::os::unix`.

Fixes #105467
2023-01-29 06:14:16 +01:00
Michael Howell
2cdec46275 docs: remove colon from time header
It's not used anywhere else; the inconsistency is weird.
2023-01-28 16:07:34 -07:00
Neil Roberts
a34f11c006 vec: Use SpecCloneIntoVec::clone_into to implement Vec::clone_from
In the past, Vec::clone_from was implemented using slice::clone_into.
The code from clone_into was later duplicated into clone_from in
8725e4c337, which is the commit that adds custom allocator support to
Vec. Presumably this was done because the slice::clone_into only works
for vecs with the default allocator so it would have the wrong type to
clone into Vec<T, A>.

Now that the clone_into implementation is moved out into a specializable
trait anyway we might as well use that to share the code between the two
methods.
2023-01-28 20:37:01 +01:00
Neil Roberts
ba80c662f4 slice: Add a specialization for clone_into when T is Copy
The implementation for the ToOwned::clone_into method on [T] is a copy
of the code for vec::clone_from. In 361398009b the code for
vec::clone_from gained a specialization for when T is Copy. This commit
copies that specialization over to the clone_into implementation.
2023-01-28 20:37:01 +01:00
Gary Guo
66f3ab90a1 Reintroduce multiple_supertrait_upcastable lint 2023-01-28 15:08:07 +00:00
Matthias Krüger
c95707a29b
Rollup merge of #107398 - scottmcm:its-their-funeral, r=dtolnay
Remove `ControlFlow::{BREAK, CONTINUE}`

Libs-API decided to remove these in #102697.

Follow-up to #107023, which removed them from `compiler/`, but a couple new ones showed up since that was merged.

r? libs
2023-01-28 11:11:09 +01:00
Matthias Krüger
45430a5351
Rollup merge of #105524 - Ayush1325:libc-free, r=ChrisDenton
Replace libc::{type} with crate::ffi::{type}

Replace libc::{type} imports with crate::ffi::{type} outside of `std::sys` and `std::os`.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-01-28 11:11:06 +01:00
Matthias Krüger
36ef4f15d3
Rollup merge of #104252 - faern:stabilize-const_socketaddr, r=JohnTitor
Stabilize the const_socketaddr feature

Stabilizes `#![feature(const_socketaddr)]`. Tracking issue: #82485
Closes #82485

This has been unstably const for over a year now. And the code change simplifying the constness of the `new` constructors has been in stable Rust since 1.64 (a bit over a full release cycle). I'm not aware of any blockers to this stabilization.
2023-01-28 11:11:06 +01:00
Ayush Singh
c50d3e28ab
Replace libc::{type} with crate::ffi::{type}
Replace libc::{type} imports with crate::ffi::{type} outside of
`std::sys` and `std::os`.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-01-28 11:24:13 +05:30
Matthias Krüger
7b78b6a78d
Rollup merge of #107022 - scottmcm:ordering-option-eq, r=m-ou-se
Implement `SpecOptionPartialEq` for `cmp::Ordering`

Noticed as I continue to explore options for having code using `partial_cmp` optimize better.

Before:
```llvm
; Function Attrs: mustprogress nofree nosync nounwind willreturn uwtable
define noundef zeroext i1 `@ordering_eq(i8` noundef %0, i8 noundef %1) unnamed_addr #0 {
start:
  %2 = icmp eq i8 %0, 2
  br i1 %2, label %bb1.i, label %bb3.i

bb1.i:                                            ; preds = %start
  %3 = icmp eq i8 %1, 2
  br label %"_ZN55_$LT$T$u20$as$u20$core..option..SpecOptionPartialEq$GT$2eq17hb7e7beacecde585fE.exit"

bb3.i:                                            ; preds = %start
  %.not.i = icmp ne i8 %1, 2
  %4 = icmp eq i8 %0, %1
  %spec.select.i = and i1 %.not.i, %4
  br label %"_ZN55_$LT$T$u20$as$u20$core..option..SpecOptionPartialEq$GT$2eq17hb7e7beacecde585fE.exit"

"_ZN55_$LT$T$u20$as$u20$core..option..SpecOptionPartialEq$GT$2eq17hb7e7beacecde585fE.exit": ; preds = %bb1.i, %bb3.i
  %.0.i = phi i1 [ %3, %bb1.i ], [ %spec.select.i, %bb3.i ]
  ret i1 %.0.i
}
```

After:
```llvm
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable
define noundef zeroext i1 `@ordering_eq(i8` noundef %0, i8 noundef %1) unnamed_addr #1 {
start:
  %2 = icmp eq i8 %0, %1
  ret i1 %2
}
```

(Which <https://alive2.llvm.org/ce/z/-rop5r> says LLVM *could* just do itself, but there's probably an issue already open for that problem from when this was originally looked at for `Option<NonZeroU8>` and friends.)
2023-01-28 05:20:15 +01:00
Scott McMurray
868d099a72 Remove ControlFlow::{BREAK, CONTINUE}
Libs-API decided to remove these in #102697.

Follow-up to #107023, which removed them from `compiler/`, but a couple new ones showed up since that was merged.
2023-01-27 19:46:42 -08:00
Scott McMurray
3e9d1e40cb Link to the LLVM issue from a comment on SpecOptionPartialEq 2023-01-27 19:09:52 -08:00
Matthias Kaak
e02517d753
Fixed confusement between mod and remainder 2023-01-27 21:01:07 +00:00
Yuki Okushi
bf321ece1e
Rollup merge of #106856 - vadorovsky:fix-atomic-annotations, r=joshtriplett
core: Support variety of atomic widths in width-agnostic functions

Before this change, the following functions and macros were annotated with `#[cfg(target_has_atomic = "8")]` or
`#[cfg(target_has_atomic_load_store = "8")]`:

* `atomic_int`
* `strongest_failure_ordering`
* `atomic_swap`
* `atomic_add`
* `atomic_sub`
* `atomic_compare_exchange`
* `atomic_compare_exchange_weak`
* `atomic_and`
* `atomic_nand`
* `atomic_or`
* `atomic_xor`
* `atomic_max`
* `atomic_min`
* `atomic_umax`
* `atomic_umin`

However, none of those functions and macros actually depend on 8-bit width and they are needed for all atomic widths (16-bit, 32-bit, 64-bit etc.). Some targets might not support 8-bit atomics (i.e. BPF, if we would enable atomic CAS for it).

This change fixes that by removing the `"8"` argument from annotations, which results in accepting the whole variety of widths.

Fixes #106845
Fixes #106795

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2023-01-27 12:57:54 +09:00
Yuki Okushi
4b4aeae359
Rollup merge of #105784 - yanns:update_stdarch, r=Amanieu
update stdarch

This will allow using miri on simd instructions
https://github.com/rust-lang/stdarch/issues/1347#issuecomment-1353664361
2023-01-27 12:57:53 +09:00