| Age | Commit message (Collapse) | Author | Lines |
|
Implement `Hash` for `core::alloc::Layout`
This was brought up on [reddit](https://www.reddit.com/r/rust/comments/uoypui/the_standard_library_types_are_good_except_when/), and I don't see why Layout shouldn't implement `Hash`. Feel free to comment if I am wrong though :)
|
|
r=yaahc
Partially stabilize `(const_)slice_ptr_len` feature by stabilizing `NonNull::len`
This PR partially stabilizes features `const_slice_ptr_len` and `slice_ptr_len` by only stabilizing `NonNull::len`. This partial stabilization is tracked under features `slice_ptr_len_nonnull` and `const_slice_ptr_len_nonnull`, for which this PR can serve as the tracking issue.
To summarize the discussion from #71146 leading up to this partial stabilization request:
It's currently a bit footgunny to obtain the length of a raw slice pointer, stabilization of `NonNull:len` will help with removing these footguns. Some example footguns are:
```rust
/// # Safety
/// The caller must ensure that `ptr`:
/// 1. does not point to memory that was previously allocated but is now deallocated;
/// 2. is within the bounds of a single allocated object;
/// 3. does not to point to a slice for which the length exceeds `isize::MAX` bytes;
/// 4. points to a properly aligned address;
/// 5. does not point to uninitialized memory;
/// 6. does not point to a mutably borrowed memory location.
pub unsafe fn ptr_len<T>(ptr: core::ptr::NonNull<[T]>) -> usize {
(&*ptr.as_ptr()).len()
}
```
A slightly less complicated version (but still more complicated than it needs to be):
```rust
/// # Safety
/// The caller must ensure that the start of `ptr`:
/// 1. does not point to memory that was previously allocated but is now deallocated;
/// 2. must be within the bounds of a single allocated object.
pub unsafe fn ptr_len<T>(ptr: NonNull<[T]>) -> usize {
(&*(ptr.as_ptr() as *const [()])).len()
}
```
This PR does not stabilize `<*const [T]>::len` and `<*mut [T]>::len` because the tracking issue #71146 list a potential blocker for these methods, but this blocker [does not apply](https://github.com/rust-lang/rust/issues/71146#issuecomment-808735714) to `NonNull::len`.
We should probably also ping the [Constant Evaluation WG](https://github.com/rust-lang/const-eval) since this PR includes a `#[rustc_allow_const_fn_unstable(const_slice_ptr_len)]`. My instinct here is that this will probably be okay because the pointer is not actually dereferenced and `len()` does not touch the address component of the pointer, but would be best to double check :)
One potential down-side was raised that stabilizing `NonNull::len` could lead to encouragement of coding patterns like:
```
pub fn ptr_len<T>(ptr: *mut [T]) -> usize {
NonNull::new(ptr).unwrap().len()
}
```
which unnecessarily assert non-nullness. However, these are much less of a footgun than the above examples and this should be resolved when `slice_ptr_len` fully stabilizes eventually.
|
|
Add suggestion for relaxing static lifetime bounds on dyn trait impls in NLL
This PR introduces suggestions for relaxing static lifetime bounds on impls of dyn trait items for NLL similar to what is already available in lexical region diagnostics.
Fixes https://github.com/rust-lang/rust/issues/95701
r? `@estebank`
|
|
Pass Context as a &mut to allow to remove RefCell fields
Fixes #90323.
r? `@notriddle`
|
|
Rollup of 6 pull requests
Successful merges:
- #95214 (Remove impossible panic note from `Vec::append`)
- #97411 (Print stderr consistently)
- #97453 (rename `TyKind` to `RegionKind` in comment in rustc_middle)
- #97457 (Add regression test for #81899)
- #97458 (Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error)
- #97462 (Add more eslint rules)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Add more eslint rules
The last one is the most useful of this batch. :)
Here are the links for the eslint rules:
* [arrow-parens](https://eslint.org/docs/rules/arrow-parens)
* [no-unused-vars](https://eslint.org/docs/rules/no-unused-vars)
* [eqeqeq](https://eslint.org/docs/rules/eqeqeq)
r? `@notriddle`
|
|
Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error
Reduce verbosity in #97343.
|
|
Add regression test for #81899
Closes #81899
r? `@compiler-errors`
|
|
rename `TyKind` to `RegionKind` in comment in rustc_middle
|
|
r=Mark-Simulacrum
Print stderr consistently
Solves https://github.com/rust-lang/rust/issues/96712
I tried to follow what I perceived as the general consensus for error messages in boostrap i.e messages that were ..
* resulting from an Err(...) =>
* literally called as "Error: ...."
* by the end of the block scope forced to run a panic! or process::exit with a guaranteed non-zero error code.
|
|
Remove impossible panic note from `Vec::append`
Neither the number of elements in a vector can overflow a `usize`, nor
can the amount of elements in two vectors.
|
|
|
|
|
|
|
|
|
|
Update jemalloc to v5.3
Now that `jemalloc` version 5.3 has been released, this PR updates `tikv-jemalloc-sys` to the corresponding release.
The crates.io publishing issue seems to have been resolved for the `jemalloc-sys` package, and version 5.3.0 is now also available under the historical name (and should become the preferred crate to be used). Therefore, this PR also switches back to using `jemalloc-sys` instead of `tikv-jemalloc-sys`.
|
|
#97343
|
|
|
|
|
|
|
|
Move various checks to typeck so them failing causes the typeck result to get tainted
Fixes #69487
fixes #79047
cc `@RalfJung` this gets rid of the `Transmute` invalid program error variant
|
|
|
|
Fix multiline attributes processing in doctest
Fixes #97440.
It seems like the call to `check_if_attr_is_complete` is not provided with the correct argument: the pending attribute should be passed, while the current line is actually being passed. This causes any attribute with more than 2 lines to fail and produces ICE when running through doctest.
|
|
Proc macro tweaks
Various improvements I spotted while looking through the proc macro code.
r? `@eddyb`
|
|
The part of it dealing with types obfuscates and makes the code less
concise. This commit removes that part.
|
|
|
|
Because it's easy to confuse with `bridge`.
|
|
There is some non-obvious information required to understand them.
|
|
`reverse_encode` isn't necessary to please the borrow checker, it's to
match the ordering done by `reverse_decode`.
|
|
So it matches the existing `AttrProcMacro` and `BangProcMacro` types.
|
|
Similar to the existing `AttrProcMacro` trait.
|
|
This gives the more obvious derive/attr/bang distinction, and reduces
code size slightly.
|
|
`u8` is the only type that makes sense for `T`, as demonstrated by the
fact that several impls and functions are hardwired to `Buffer<u8>`.
|
|
|
|
|
|
|
|
Rollup of 3 pull requests
Successful merges:
- #96051 (Use rounding in float to Duration conversion methods)
- #97066 (rustdoc: Remove `ItemFragment(Kind)`)
- #97436 (Update `triagebot.toml` for macos ping group)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Update `triagebot.toml` for macos ping group
idk what i'm doing but i saw https://github.com/rust-lang/rust/pull/96392#issuecomment-1138893845
cc: `@thomcc`
|
|
rustdoc: Remove `ItemFragment(Kind)`
And stop using `write!` when rendering URL fragments to avoid impossible errors.
|
|
Use rounding in float to Duration conversion methods
Closes #96045
|
|
|
|
|
|
libcore: Add `iter::from_generator` which is like `iter::from_fn`, but for coroutines instead of functions
An equally useful little helper.
I didn't follow any of the async-wg work, so I don't know why something like this wasn't added before.
|
|
|
|
coroutines instead of functions
|
|
|
|
|
|
Optimize position adjustments
A small improvement.
r? `@bjorn3`
|
|
|
|
|