Inline some Cursor calls for slices
(Partially) brings back https://github.com/rust-lang/rust/pull/33921
I've noticed in some serialization code I was writing that writes to slices produce much, much, worse code than you'd expect even with optimizations turned on. For example, you'd expect something like this to be zero cost:
```
use std::io::{self, Cursor, Write};
pub fn serialize((a, b): (u64, u64)) -> [u8;8+8] {
let mut r = [0u8;16];
{
let mut w = Cursor::new(&mut r[..]);
w.write(&a.to_le_bytes()).unwrap();
w.write(&b.to_le_bytes()).unwrap();
}
r
}
```
...but it compiles down to [dozens of instructions](https://rust.godbolt.org/z/bdwDzb) because the `slice_write()` calls aren't inlined, which in turn means `unwrap()` can't be optimized away, and so on.
To be clear, this pull-req isn't sufficient by itself: if we want to go down that path we also need to add `#[inline]`'s to the default implementations for functions like `write_all()` in the `Write` trait and so on, or implement them separately in the `Cursor` impls. But I figured I'd start a conversation about what tradeoffs we're expecting here.
cleanup: Remove `DefIndexAddressSpace`
The scheme with two address spaces for `DefIndex` was needed in the past, but apparently not needed anymore (after removing `DefId`s from locals and `HirId`-ification).
Add a `cast` method to raw pointers.
This is similar to `NonNull::cast`.
Compared to the `as` operator (which has a wide range of meanings depending on the input and output types), a call to this method:
* Can only go from a raw pointer to a raw pointer
* Cannot change the pointer’s `const`ness
… even when the pointed types are inferred based on context.
Rollup of 8 pull requests
Successful merges:
- #59979 (to_xe_bytes for isize and usize returns an array of different size)
- #60491 (std: Update compiler-builtins crate)
- #60550 (Add tests for concrete const types)
- #60572 (Add test for #59972)
- #60627 (test for #50518)
- #60634 (Document + Cleanup lang_items.rs)
- #60641 (Instead of ICEing on incorrect pattern, use delay_span_bug)
- #60644 (Use `delay_span_bug` for "Failed to unify obligation")
Failed merges:
r? @ghost
test for #50518
It was fixed somewhere between 1.28.0 and 1.31.1
closes#50518
r? @estebank
Where's the best place to add this test? I *think* we want "compile-pass" for this test (no need to run a binary, and not running saves us a millisecond of process creation) , but there's no compile-pass anymore.
Should this be UI test with empty stdout, stderr and zero return code?
std: Update compiler-builtins crate
Pulls in a fix for ensuring that wasm targets have code in
compiler-builtins for `ldexp` which LLVM can generate references to.
libprofiler_builtins: Set compilation flags more correctly for C code.
In particular, set `COMPILER_RT_HAS_FCNTL_LCK` and `COMPILER_RT_HAS_ATOMICS` as appropriate. This should get rid of the various runtime warnings when executing instrumented binaries.
The build script is using a heuristic here that hopefully is sufficient for the time being.
r? @alexcrichton
Fixes#59531.
conditionally modify darwin targets to macosx targets with versions
We need this behavior so that Rust LLVM IR objects match the target triple for Clang LLVM IR objects. This matching then convinces the linker that yes, you really can do cross-language LTO with objects from different compilers.
The newly-added tests seem to pass locally on x86_64-unknown-linux-gnu. I haven't done a full test run or tried the new compiler in an cross-language LTO setup yet.
Adds support for .await under the existing async_await feature gate.
Moves macro-like await! syntax to the await_macro feature gate.
Removes support for `await` as a non-keyword under the `async_await`
feature.
Rollup of 5 pull requests
Successful merges:
- #60489 (Remove hamburger button from source code page)
- #60535 (Correct handling of arguments in async fn)
- #60579 (Rename `ParamTy::idx` to `ParamTy::index`)
- #60583 (Fix parsing issue with negative literals as const generic arguments)
- #60609 (Be a bit more explicit asserting over the vec rather than the len)
Failed merges:
r? @ghost
This is similar to `NonNull::cast`.
Compared to the `as` operator (which has a wide range of meanings
depending on the input and output types), a call to this method:
* Can only go from a raw pointer to a raw pointer
* Cannot change the pointer’s `const`ness
… even when the pointed types are inferred based on context.