Commit Graph

11044 Commits

Author SHA1 Message Date
Matthias Krüger
33253fa6a4 Revert "Rename -Zoom=panic to -Zoom=unwind"
This reverts commit 4b981c2648.
2023-04-25 00:08:33 +02:00
Matthias Krüger
3ecae2932c
Rollup merge of #110706 - scottmcm:transmute_unchecked, r=oli-obk
Add `intrinsics::transmute_unchecked`

This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.

See also https://github.com/rust-lang/rust/pull/108442#issuecomment-1474777273, where `CastKind::Transmute` was added having exactly these semantics before the lang meeting (which I wasn't in) independently expressed interest.
2023-04-24 07:53:25 +02:00
Matthias Krüger
96acbd8e28
Rollup merge of #110689 - Spartan2909:fix-grammar, r=JohnTitor
Fix grammar in core::hint::unreachable_unchecked() docs

Fixes a minor grammar error in the docs for core::hint::unreachable_unchecked()
2023-04-23 20:06:32 +02:00
bors
9de7d9169c Auto merge of #110655 - ChrisDenton:read-to-end, r=joshtriplett
Limit read size in `File::read_to_end` loop

Fixes #110650.

Windows file reads have perf overhead that's proportional to the buffer size. When we have a reasonable expectation that we know the file size, we can set a reasonable upper bound for the size of the buffer in one read call.
2023-04-23 06:58:28 +00:00
Scott McMurray
1de2257c3f Add intrinsics::transmute_unchecked
This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <https://github.com/rust-lang/rust/pull/106281#issuecomment-1496648190> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.
2023-04-22 17:22:03 -07:00
Caleb Robson
0cc1b86a3a
Fix grammar 2023-04-22 15:58:44 +01:00
bors
39cf520299 Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwco
Report allocation errors as panics

OOM is now reported as a panic but with a custom payload type (`AllocErrorPanicPayload`) which holds the layout that was passed to `handle_alloc_error`.

This should be review one commit at a time:
- The first commit adds `AllocErrorPanicPayload` and changes allocation errors to always be reported as panics.
- The second commit removes `#[alloc_error_handler]` and the `alloc_error_hook` API.

ACP: https://github.com/rust-lang/libs-team/issues/192

Closes #51540
Closes #51245
2023-04-22 12:27:45 +00:00
bors
3128fd8ddf Auto merge of #110666 - JohnTitor:rollup-3pwilte, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #109949 (rustdoc: migrate `document_type_layout` to askama)
 - #110622 (Stable hash tag (discriminant) of `GenericArg`)
 - #110635 (More `IS_ZST` in `library`)
 - #110640 (compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020)
 - #110657 (nit: consistent naming for SimplifyConstCondition)
 - #110659 (rustdoc: clean up JS)
 - #110660 (Print ty placeholders pretty)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-22 05:35:08 +00:00
Yuki Okushi
581e7417ce
Rollup merge of #110635 - scottmcm:zst-checks, r=the8472
More `IS_ZST` in `library`

I noticed that `post_inc_start` and `pre_dec_end` were doing this check in different ways

d19b64fb54/library/core/src/slice/iter/macros.rs (L76-L93)

so started making this PR, then added a few more I found since I was already making changes anyway.
2023-04-22 10:33:57 +09:00
bors
80a2ec49a4 Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin
Add offset_of! macro (RFC 3308)

Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented:

* Nested field accesses (without array indexing)
* DST support (for `Sized` fields)

I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it.

cc `@thomcc` (RFC author)
2023-04-22 00:10:44 +00:00
Scott McMurray
56613f8c38 More IS_ZST in library
I noticed that `post_inc_start` and `pre_dec_end` were doing this check in different ways

d19b64fb54/library/core/src/slice/iter/macros.rs (L76-L93)

so started making this PR, then added a few more I found since I was already making changes anyway.
2023-04-21 16:29:27 -07:00
Chris Denton
f74fe8bf4c
Limit read size in File::read_to_end loop
This works around performance issues on  Windows by limiting reads the size of reads when the expected size is known.
2023-04-21 20:54:12 +01:00
Dylan DPC
482e407a1f
Rollup merge of #110633 - scottmcm:more-take, r=thomcc
More `mem::take` in `library`

A bunch of places were using `replace(…, &mut [])`, but that can just be `take`.
2023-04-21 20:35:29 +05:30
Dylan DPC
f971264fd7
Rollup merge of #110608 - a1phyr:specialize_io_methods, r=thomcc
Specialize some `io::Read` and `io::Write` methods for `VecDeque<u8>` and `&[u8]`

This improves implementation of:
- `<&[u8]>::read_to_string`
- `VecDeque<u8>::read_to_end`
- `VecDeque<u8>::read_to_string`
- `VecDeque<u8>::write_vectored`
2023-04-21 20:35:28 +05:30
bors
1151ea6006 Auto merge of #109002 - michaelvanstraten:master, r=petrochenkov
Added byte position range for `proc_macro::Span`

Currently, the [`Debug`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#impl-Debug-for-Span) implementation for [`proc_macro::Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#) calls the debug function implemented in the trait implementation of `server::Span` for the type `Rustc` in the `rustc-expand` crate.

The current implementation, of the referenced function, looks something like this:
```rust
fn debug(&mut self, span: Self::Span) -> String {
    if self.ecx.ecfg.span_debug {
        format!("{:?}", span)
    } else {
        format!("{:?} bytes({}..{})", span.ctxt(), span.lo().0, span.hi().0)
    }
}
```

It returns the byte position of the [`Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#) as an interpolated string.

Because this is currently the only way to get a spans position in the file, I might lead someone, who is interested in this information, to parsing this interpolated string back into a range of bytes, which I think is a very non-rusty way.

The proposed `position()`, method implemented in this PR, gives the ability to directly get this info.
It returns a [`std::ops::Range`](https://doc.rust-lang.org/std/ops/struct.Range.html#) wrapping the lowest and highest byte of the [`Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#).

I put it behind the `proc_macro_span` feature flag because many of the other functions that have a similar footprint also are annotated with it, I don't actually know if this is right.

It would be great if somebody could take a look at this, thank you very much in advanced.
2023-04-21 10:47:27 +00:00
DrMeepster
a642563d49 major test improvements 2023-04-21 02:45:48 -07:00
DrMeepster
3206960ec6 minor tweaks 2023-04-21 02:14:04 -07:00
DrMeepster
2bcb018253 fmt 2023-04-21 02:14:03 -07:00
DrMeepster
b92c2f792c fix incorrect param env in dead code lint 2023-04-21 02:14:03 -07:00
DrMeepster
b95852b93c test improvements 2023-04-21 02:14:03 -07:00
DrMeepster
511e457c4b offset_of 2023-04-21 02:14:02 -07:00
Scott McMurray
8055bb87c5 More mem::take in library
A bunch of places were using `replace(…, &mut [])`, but that can just be `take`.
2023-04-20 19:54:46 -07:00
Mara Bos
bd917bbcd2
Add reason to #![unstable] tag.
Co-authored-by: jyn <github@jyn.dev>
2023-04-20 19:38:33 +02:00
Mara Bos
687b3fa439 Remove doc link to private item. 2023-04-20 18:47:47 +02:00
Mara Bos
bca80d811c Get rid of core::fmt::FormatSpec. 2023-04-20 18:07:34 +02:00
Mara Bos
938efe6f49 Rename fmt::rt::Argument to Placeholder. 2023-04-20 18:05:35 +02:00
Mara Bos
bc11b459af Turn core::fmt::rt::v1 into a private module. 2023-04-20 18:04:28 +02:00
Mara Bos
a77159341e Use fmt::Alignment instead of fmt::rt::v1::Alignment. 2023-04-20 18:03:47 +02:00
Mara Bos
debf305d9e Don't reexport core::fmt::rt from alloc::fmt. 2023-04-20 18:01:59 +02:00
Benoît du Garreau
1e6a7b4580 Specialize some io::Read and io::Write methods for VecDeque<u8> and &[u8] 2023-04-20 16:33:01 +02:00
Yuki Okushi
9dbd25c705
Rollup merge of #110448 - ripytide:master, r=cuviper
cmp doc examples improvements

Most changes are for stylistic consistency, with some changes to provide more clarity.
2023-04-20 17:03:24 +09:00
John Millikin
4e2797dd76 Implement Neg for signed non-zero integers.
Negating a non-zero integer currently requires unpacking to a
primitive and re-wrapping. Since negation of non-zero signed
integers always produces a non-zero result, it is safe to
implement `Neg` for `NonZeroI{N}`.

The new `impl` is marked as stable because trait implementations
for two stable types can't be marked unstable.
2023-04-20 14:27:29 +09:00
bors
39c6804b92 Auto merge of #106704 - ecnelises:big_archive, r=bjorn3
Support AIX-style archive type

Reading facility of AIX big archive has been supported by `object` since 0.30.0.

Writing facility of AIX big archive has already been supported by `ar_archive_writer`, but we need to bump the version to support the new archive type enum.
2023-04-19 21:21:17 +00:00
bors
3a5c8e91f0 Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obk
Rm const traits in libcore

See [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const.20Trait.60.20removal.20or.20rework)

* [x] Bless ui tests
* [ ] Re constify some unstable functions with workarounds if they are needed
2023-04-19 13:03:40 +00:00
Qiu Chaofan
7c8c9cf470 Bump version of object and related crates 2023-04-19 12:42:20 +08:00
Matthias Krüger
3320b2a59a
Rollup merge of #110432 - compiler-errors:unsatisfied-index-impl, r=cjgillot
Report more detailed reason why `Index` impl is not satisfied

Fixes #110373
2023-04-19 06:35:34 +02:00
Michael Goulet
d84b5f9b3d Use a diagnostic item instead of filtering for Index::Output 2023-04-18 18:55:17 +00:00
Guillaume Gomez
e6b607335a
Rollup merge of #110441 - kadiwa4:typos, r=thomcc
5 little typos
2023-04-18 14:50:51 +02:00
ripytide
f540548fa1
cmp doc examples consistency improvements 2023-04-17 11:14:09 +01:00
Deadbeef
dd025c3b56 fix codegen difference 2023-04-17 09:27:07 +00:00
kadiwa
85653831f7
typos 2023-04-17 09:16:07 +02:00
Matthias Krüger
35e63890bd
Rollup merge of #110433 - ChrisDenton:notfound, r=thomcc
Windows: map a few more error codes to ErrorKind

NotFound errors:

* `ERROR_INVALID_DRIVE`: The system cannot find the drive specified
* `ERROR_BAD_NETPATH`: The network path was not found
* `ERROR_BAD_NET_NAME`: The network name cannot be found.

InvalidFilename:

* `ERROR_BAD_PATHNAME`: The specified path is invalid.

Source: [System Error Codes (0-499)](https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-)
2023-04-17 08:09:42 +02:00
Matthias Krüger
6e9a52cdc0
Rollup merge of #110388 - JohnBobbo96:remove-intrinsic-unwrap, r=the8472
Add a message for if an overflow occurs in `core::intrinsics::is_nonoverlapping`.
2023-04-17 08:09:40 +02:00
Chris Denton
db8dfbdb75
Windows: map a few more error codes to ErrorKind
NotFound errors:

* `ERROR_INVALID_DRIVE`: The system cannot find the drive specified
* `ERROR_BAD_NETPATH`: The network path was not found
* `ERROR_BAD_NET_NAME`: The network name cannot be found.

InvalidFilename:

* `ERROR_BAD_PATHNAME`: The specified path is invalid.
2023-04-16 23:42:59 +01:00
Amanieu d'Antras
4b981c2648 Rename -Zoom=panic to -Zoom=unwind 2023-04-16 11:50:32 -07:00
Amanieu d'Antras
abc0660118 Remove #[alloc_error_handler] from the compiler and library 2023-04-16 08:35:50 -07:00
Amanieu d'Antras
c9a6e41026 Report allocation errors as panics 2023-04-16 08:35:44 -07:00
John Bobbo
3dba5872a3
Add a message indicating overflow in
`core::intrinsics::is_nonoverlapping`.
2023-04-16 07:35:18 -07:00
Deadbeef
4c6ddc036b fix library and rustdoc tests 2023-04-16 11:38:52 +00:00
Deadbeef
eac922e721 readd const_trait to Drop, Destruct, and Fn* 2023-04-16 09:25:23 +00:00