| Age | Commit message (Collapse) | Author | Lines |
|
r=dtolnay
doc(array,vec): add notes about side effects when empty-initializing
Copying some context from a conversation in the Rust discord:
* Both `vec![T; 0]` and `[T; 0]` are syntactically valid, and produce empty containers of their respective types
* Both *also* have side effects:
```rust
fn side_effect() -> String {
println!("side effect!");
"foo".into()
}
fn main() {
println!("before!");
let x = vec![side_effect(); 0];
let y = [side_effect(); 0];
println!("{:?}, {:?}", x, y);
}
```
produces:
```
before!
side effect!
side effect!
[], []
```
This PR just adds two small notes to each's documentation, warning users that side effects can occur.
I've also submitted a clippy proposal: https://github.com/rust-lang/rust-clippy/issues/6439
|
|
|
|
BTreeMap: declare clear_parent_link directly on the root it needs
r? `@Mark-Simulacrum`
|
|
BTreeMap: detect bulk_steal's count-1 underflow in release builds too
r? `@Mark-Simulacrum`
|
|
BTreeMap: clarify comments and panics around choose_parent_kv
Fixes a lie in recent code: `unreachable!("empty non-root node")` should shout "empty internal node", but it might as well be good and keep quiet
r? `@Mark-Simulacrum`
|
|
|
|
|
|
|
|
|
|
|
|
Rollup of 12 pull requests
Successful merges:
- #79360 (std::iter: document iteration over `&T` and `&mut T`)
- #79398 (Link loop/for keyword)
- #79834 (Remove deprecated linked_list_extras methods.)
- #79845 (Fix rustup support in default_build_triple for python3)
- #79940 (fix more clippy::complexity findings)
- #79942 (Add post-init hook for static memory for miri.)
- #79954 (Fix building compiler docs with stage 0)
- #79963 (Fix typo in `DebruijnIndex` documentation)
- #79970 (Misc rustbuild improvements when the LLVM backend isn't used)
- #79973 (rustdoc light theme: Fix CSS for selected buttons)
- #79984 (Remove an unused dependency that made `rustdoc` crash)
- #79985 (Fixes submit event of the search input)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Remove deprecated linked_list_extras methods.
https://github.com/rust-lang/rust/issues/27794#issuecomment-667524201:
> I'd say give it about 2 weeks then remove them.
It's been 18 weeks. Time to remove them. :)
Closes #27794.
|
|
|
|
|
|
|
|
|
|
Clarify that String::split_at takes a byte index.
To someone skimming through the `String` docs and only reads the first line, the person could interpret "index" to be "char index". Later on in the docs it clarifies, but by adding "byte" it removes that ambiguity.
|
|
|
|
|
|
fix soundness issue in `make_contiguous`
fixes #79808
|
|
|
|
|
|
|
|
|
|
Privatize some of libcore unicode_internals
My understanding is that these API are perma unstable, so it doesn't
make sense to pollute docs & IDE completion[1] with them.
[1]: https://github.com/rust-analyzer/rust-analyzer/issues/6738
|
|
|
|
|
|
|
|
We also change the specialization of `SpecFromIterNested::from_iter` for
`TrustedLen` to use `Vec::with_capacity` when the iterator has a proper size
hint, instead of `Vec::new`, avoiding calls to `grow_*` and thus
`finish_grow` in some fully inlinable cases, which would regress with
this change.
Fixes #78471.
|
|
|
|
|
|
My understanding is that these API are perma unstable, so it doesn't
make sense to pollute docs & IDE completion[1] with them.
[1]: https://github.com/rust-analyzer/rust-analyzer/issues/6738
|
|
Don't leak return value after panic in drop
Closes #47949
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BTreeMap: try to enhance various comments
All in internal documentation, propagating the "key-value pair" notation from public documentation.
r? ``@Mark-Simulacrum``
|
|
Require allocator to be static for boxed `Pin`-API
Allocators has to retain their validity until the instance and all of its clones are dropped. When pinning a value, it must live forever, thus, the allocator requires a `'static` lifetime for pinning a value. [Example from reddit](https://www.reddit.com/r/rust/comments/jymzdw/the_story_continues_vec_now_supports_custom/gd7qak2?utm_source=share&utm_medium=web2x&context=3):
```rust
let alloc = MyAlloc(/* ... */);
let pinned = Box::pin_in(42, alloc);
mem::forget(pinned); // Now `value` must live forever
// Otherwise `Pin`'s invariants are violated, storage invalidated
// before Drop was called.
// borrow of `memory` can end here, there is no value keeping it.
drop(alloc); // Oh, value doesn't live forever.
```
|
|
|
|
|
|
|
|
Rename `optin_builtin_traits` to `auto_traits`
They were originally called "opt-in, built-in traits" (OIBITs), but
people realized that the name was too confusing and a mouthful, and so
they were renamed to just "auto traits". The feature flag's name wasn't
updated, though, so that's what this PR does.
There are some other spots in the compiler that still refer to OIBITs,
but I don't think changing those now is worth it since they are internal
and not particularly relevant to this PR.
Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.
r? `@oli-obk` (feel free to re-assign if you're not the right reviewer for this)
|
|
BTreeMap/BTreeSet: make public doc more consistent
Tweaks #72876 and #73667 and propagate them to `BTreeSet`.
|
|
BTreeMap: cut out the ceremony around BoxedNode
The opposite direction of #79093.
r? ``@Mark-Simulacrum``
|
|
They were originally called "opt-in, built-in traits" (OIBITs), but
people realized that the name was too confusing and a mouthful, and so
they were renamed to just "auto traits". The feature flag's name wasn't
updated, though, so that's what this PR does.
There are some other spots in the compiler that still refer to OIBITs,
but I don't think changing those now is worth it since they are internal
and not particularly relevant to this PR.
Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.
|
|
|
|
Rollup of 10 pull requests
Successful merges:
- #76829 (stabilize const_int_pow)
- #79080 (MIR visitor: Don't treat debuginfo field access as a use of the struct)
- #79236 (const_generics: assert resolve hack causes an error)
- #79287 (Allow using generic trait methods in `const fn`)
- #79324 (Use Option::and_then instead of open-coding it)
- #79325 (Reduce boilerplate with the `?` operator)
- #79330 (Fix typo in comment)
- #79333 (doc typo)
- #79337 (Use Option::map instead of open coding it)
- #79343 (Add my (`@flip1995)` work mail to the mailmap)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
|