summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2018-01-28Document that `Index` ops can panic on `HashMap` & `BTreeMap`.Corey Farwell-0/+5
Fixes https://github.com/rust-lang/rust/issues/47011.
2018-01-25Auto merge of #47006 - bitshifter:stabilize-repr-align, r=eddybbors-1/+0
Stabilized `#[repr(align(x))]` attribute (RFC 1358) Stabilzed `#[repr(align(x))]` with attr_literal syntax as proposed by @eddyb https://github.com/rust-lang/rust/issues/33626#issuecomment-348467804
2018-01-24Auto merge of #47299 - cramertj:unsafe-placer, r=alexcrichtonbors-7/+7
Make core::ops::Place an unsafe trait Consumers of `Place` would reasonably expect that the `pointer` function returns a valid pointer to memory that can actually be written to.
2018-01-23Stabilized `#[repr(align(x))]` attribute (RFC 1358)Cameron Hart-1/+0
2018-01-21Rollup merge of #47632 - sdroege:exact-chunks-docs-broken-links, r=kennytmGuillaume Gomez-0/+8
Fix broken links to other slice functions in chunks/chunks_mut/exact_… …chunk/exact_chunks_mut docs See https://github.com/rust-lang/rust/pull/47126#discussion_r162780492
2018-01-21Rollup merge of #47625 - astraw:btreeset-doctest-fix, r=kennytmGuillaume Gomez-12/+12
fix doctests for BTreeSet to use BTreeSet (not BTreeMap) This fixes #47624
2018-01-21Rollup merge of #47595 - PieterPenninckx:master, r=shepmasterGuillaume Gomez-7/+8
Small improvements to the documentation of VecDeque. Some small improvements to the documentation of `VecDeque`.
2018-01-21Revert change to docs in panic section of VecDeque::split_offPieter Penninckx-1/+1
2018-01-21Fix broken links to other slice functions in ↵Sebastian Dröge-0/+8
chunks/chunks_mut/exact_chunk/exact_chunks_mut docs See https://github.com/rust-lang/rust/pull/47126#discussion_r162780492
2018-01-20fix doctests for BTreeSet to use BTreeSet (not BTreeMap)Andrew Straw-12/+12
This fixes #47624
2018-01-20Auto merge of #46980 - ↵bors-1/+1
zackmdavis:and_the_case_of_the_needlessly_parenthesized_arguments, r=petrochenkov in which the unused-parens lint comes to cover function and method args Resolves #46137.
2018-01-20Assign its own tracking issue to Box::into_raw_non_nullSimon Sapin-1/+4
https://github.com/rust-lang/rust/issues/47336
2018-01-20Revert Box::into_raw_non_null to unstableSimon Sapin-1/+1
2018-01-20Rename Box::into_non_null_raw to Box::into_raw_non_nullSimon Sapin-13/+13
2018-01-20Remove `Box::from_non_null_raw`Simon Sapin-35/+3
Per https://github.com/rust-lang/rust/pull/46952#issuecomment-353956225
2018-01-20Rename Box::*_nonnull_raw to *_non_null_rawSimon Sapin-18/+18
2018-01-20Stabilize std::ptr::NonNullSimon Sapin-9/+2
2018-01-20Mark Unique as perma-unstable, with the feature renamed to ptr_internals.Simon Sapin-1/+1
2018-01-20Replace Box::{from,into}_unique with {from,into}_nonnull_rawSimon Sapin-31/+38
Thew `_raw` prefix is included because the fact that `Box`’s ownership semantics are "dissolved" or recreated seem more important than the exact parameter type or return type.
2018-01-20Replace Unique<T> with NonZero<T> in Alloc traitSimon Sapin-11/+11
2018-01-20Rename std::ptr::Shared to NonNullSimon Sapin-43/+43
`Shared` is now a deprecated `type` alias. CC https://github.com/rust-lang/rust/issues/27730#issuecomment-352800629
2018-01-19Small improvements to the documentation of VecDeque.Pieter Penninckx-7/+8
2018-01-18in which the unused-parens lint comes to cover function and method argsZack M. Davis-1/+1
Resolves #46137.
2018-01-15Reexport -> re-export in prose and documentation commentsCarol (Nichols || Goulding)-2/+2
2018-01-15Rollup merge of #47126 - sdroege:exact-chunks, r=blusskennytm-2/+134
Add slice::ExactChunks and ::ExactChunksMut iterators These guarantee that always the requested slice size will be returned and any leftoever elements at the end will be ignored. It allows llvm to get rid of bounds checks in the code using the iterator. This is inspired by the same iterators provided by ndarray. Fixes https://github.com/rust-lang/rust/issues/47115 I'll add unit tests for all this if the general idea and behaviour makes sense for everybody. Also see https://github.com/rust-lang/rust/issues/47115#issuecomment-354715511 for an example what this improves.
2018-01-13Add unit tests for exact_chunks/exact_chunks_mutSebastian Dröge-0/+57
These are basically modified copies of the chunks/chunks_mut tests.
2018-01-13Use assert_eq!() instead of assert!(a == b) in slice chunks_mut() unit testSebastian Dröge-2/+2
This way more useful information is printed if the test ever fails.
2018-01-13Mention in the exact_chunks docs that this can often be optimized better by ↵Sebastian Dröge-0/+15
the compiler And also link from the normal chunks iterator to the exact_chunks one.
2018-01-13Fix doctests for slice::exact_chunks() for realSebastian Dröge-2/+2
2018-01-13Fix assertions in examples of the exact_chunk() documentationSebastian Dröge-2/+1
2018-01-13Add #![feature(exact_chunks)] to the documentation examples to fix the doc testsSebastian Dröge-0/+4
2018-01-13Add slice::ExactChunks and ::ExactChunksMut iteratorsSebastian Dröge-0/+57
These guarantee that always the requested slice size will be returned and any leftoever elements at the end will be ignored. It allows llvm to get rid of bounds checks in the code using the iterator. This is inspired by the same iterators provided by ndarray. See https://github.com/rust-lang/rust/issues/47115
2018-01-13Auto merge of #46461 - zackmdavis:elemental_method_suggestion_jamboree, ↵bors-0/+2
r=estebank type error method suggestions use whitelisted identity-like conversions ![method_jamboree_summit](https://user-images.githubusercontent.com/1076988/33523646-e5c43184-d7c0-11e7-98e5-1bff426ade86.png) Previously, on a type mismatch (and if this wasn't preëmpted by a higher-priority suggestion), we would look for argumentless methods returning the expected type, and list them in a `help` note. This had two major shortcomings: firstly, a lot of the suggestions didn't really make sense (if you used a &str where a String was expected, `.to_ascii_uppercase()` is probably not the solution you were hoping for). Secondly, we weren't generating suggestions from the most useful traits! We address the first problem with an internal `#[rustc_conversion_suggestion]` attribute meant to mark methods that keep the "same value" in the relevant sense, just converting the type. We address the second problem by making `FnCtxt.probe_for_return_type` pass the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe because grep reveals no other callers of `probe_for_return_type`. Also, structured suggestions are pretty and good for RLS and friends. Unfortunately, the trait probing is still not all one would hope for: at a minimum, we don't know how to rule out `into()` in cases where it wouldn't actually work, and we don't know how to rule in `.to_owned()` where it would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME. This is hoped to resolve #42929, #44672, and #45777.
2018-01-09Rollup merge of #46777 - frewsxcv:frewsxcv-rotate, r=alexcrichtonCorey Farwell-44/+108
Deprecate [T]::rotate in favor of [T]::rotate_{left,right}. Background ========== Slices currently have an **unstable** [`rotate`] method which rotates elements in the slice to the _left_ N positions. [Here][tracking] is the tracking issue for this unstable feature. ```rust let mut a = ['a', 'b' ,'c', 'd', 'e', 'f']; a.rotate(2); assert_eq!(a, ['c', 'd', 'e', 'f', 'a', 'b']); ``` Proposal ======== Deprecate the [`rotate`] method and introduce `rotate_left` and `rotate_right` methods. ```rust let mut a = ['a', 'b' ,'c', 'd', 'e', 'f']; a.rotate_left(2); assert_eq!(a, ['c', 'd', 'e', 'f', 'a', 'b']); ``` ```rust let mut a = ['a', 'b' ,'c', 'd', 'e', 'f']; a.rotate_right(2); assert_eq!(a, ['e', 'f', 'a', 'b', 'c', 'd']); ``` Justification ============= I used this method today for my first time and (probably because I’m a naive westerner who reads LTR) was surprised when the docs mentioned that elements get rotated in a left-ward direction. I was in a situation where I needed to shift elements in a right-ward direction and had to context switch from the main problem I was working on and think how much to rotate left in order to accomplish the right-ward rotation I needed. Ruby’s `Array.rotate` shifts left-ward, Python’s `deque.rotate` shifts right-ward. Both of their implementations allow passing negative numbers to shift in the opposite direction respectively. The current `rotate` implementation takes an unsigned integer argument which doesn't allow the negative number behavior. Introducing `rotate_left` and `rotate_right` would: - remove ambiguity about direction (alleviating need to read docs 😉) - make it easier for people who need to rotate right [`rotate`]: https://doc.rust-lang.org/std/primitive.slice.html#method.rotate [tracking]: https://github.com/rust-lang/rust/issues/41891
2018-01-09Make core::ops::Place an unsafe traitTaylor Cramer-7/+7
2018-01-06type error method suggestions use whitelisted identity-like conversionsZack M. Davis-0/+2
Previously, on a type mismatch (and if this wasn't preëmpted by a higher-priority suggestion), we would look for argumentless methods returning the expected type, and list them in a `help` note. This had two major shortcomings. Firstly, a lot of the suggestions didn't really make sense (if you used a &str where a String was expected, `.to_ascii_uppercase()` is probably not the solution you were hoping for). Secondly, we weren't generating suggestions from the most useful traits! We address the first problem with an internal `#[rustc_conversion_suggestion]` attribute meant to mark methods that keep the "same value" in the relevant sense, just converting the type. We address the second problem by making `FnCtxt.probe_for_return_type` pass the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe because grep reveals no other callers of `probe_for_return_type`. Also, structured suggestions are preferred (because they're pretty, but also for RLS and friends). Also also, we make the E0055 autoderef recursion limit error use the one-time-diagnostics set, because we can potentially hit the limit a lot during probing. (Without this, test/ui/did_you_mean/recursion_limit_deref.rs would report "aborting due to 51 errors"). Unfortunately, the trait probing is still not all one would hope for: at a minimum, we don't know how to rule out `into()` in cases where it wouldn't actually work, and we don't know how to rule in `.to_owned()` where it would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME. This is hoped to resolve #42929, #44672, and #45777.
2018-01-05Write examples for {BTree,Hash}Set::{get,replace,take}Stjepan Glavina-0/+33
2018-01-03Remove `T: Ord` bound from `BTreeSet::{is_empty, len}`Stjepan Glavina-72/+68
2018-01-03Rollup merge of #47125 - daboross:patch-3, r=estebankkennytm-0/+8
Mention SliceConcatExt's stability in its docs Just saw someone in IRC mention there being no stable way to join string slices! It isn't entirely clear from the rust documentation that `SliceConcatExt` is usable. While this is mentioned in https://doc.rust-lang.org/std/prelude/, the trait has nothing to indicate that it's currently usable if found via a documentation search. The wording on this could probably be improved, but I'm hoping its better than nothing.
2018-01-03Rollup merge of #47121 - frewsxcv:frewsxcv-vec, r=kennytmkennytm-1/+1
Fix panic condition docs for Vec::insert. Fixes https://github.com/rust-lang/rust/issues/47065.
2018-01-02Mention SliceConcatExt's stability in its docsDavid Ross-0/+8
SliceConcatExt's status as an unstable trait with stable methods is documented in the compiler error for using it, and in https://doc.rust-lang.org/std/prelude/, but it is not mentioned in the trait itself. Mentioning the methods can be used in stable rust today should help users who are looking for a `join` method while working on stable rust.
2018-01-02Consistently use chunk_size as the field name for Chunks and ChunksMutSebastian Dröge-6/+6
Previously Chunks used size and ChunksMut used chunk_size
2018-01-01Fix panic condition docs for Vec::insert.Corey Farwell-1/+1
Fixes https://github.com/rust-lang/rust/issues/47065.
2018-01-01Auto merge of #47064 - kennytm:force-trailing-newlines, r=estebankbors-1/+1
Add a tidy check for missing or too many trailing newlines. I've noticed recently there are lots of review comments requesting to fix trailing newlines. If this is going to be an official style here, it's better to let the CI do this repetitive check.
2017-12-31Auto merge of #47004 - nvzqz:rc-conversions, r=bluss,kennytmbors-2/+4
Remove transmute in From<&str> impls for Arc/Rc Performs conversion via raw pointer casts.
2017-12-30Add trailing newlines to files which have no trailing newlines.kennytm-1/+1
2017-12-28Auto merge of #47036 - QuietMisdreavus:i-like-big-chars, r=frewsxcvbors-2/+6
update char_indices example to highlight big chars There was a comment today in IRC where someone thought `char_indices()` and `chars().enumerate()` were equivalent, so i wanted to put an example in the docs where that wasn't true. r? @rust-lang/docs
2017-12-27update char_indices example to highlight big charsQuietMisdreavus-2/+6
2017-12-26Rollup merge of #46930 - lucis-fluxum:patch-1, r=QuietMisdreavuskennytm-1/+1
Clarify docs for split_at_mut The `&mut` here didn't make immediate sense to me. Keep the docs for this function consistent with the non-mut version.
2017-12-25Remove transmute in From<&str> impls for Arc/RcNikolai Vazquez-2/+4