Commit Graph

8609 Commits

Author SHA1 Message Date
ljedrz
48f46056b7 Simplify slice's first(_mut) and last(_mut) with get 2018-09-21 13:06:44 +02:00
kennytm
a791919a62
Rollup merge of #52813 - newpavlov:duration_mul_div_extras, r=alexcrichton
Duration div mul extras

Successor of #52556.

This PR adds the following `impl`s:
- `impl Mul<Duration> for u32` (to allow `10*SECOND` in addition to `SECOND*10`)
- `impl Mul<f64> for Duration` (to allow `2.5*SECOND` vs `2*SECOND + 500*MILLISECOND`)
- `impl Mul<Duration> for f64`
- `impl MulAssign<f64> for Duration`
- `impl Div<f64> for Duration`
- `impl DivAssign<f64> for Duration`
- `impl Div<Duration> for Duration` (`Output = f64`, can be useful e.g. for `duration/MINUTE`)

`f64` is chosen over `f32` to minimize rounding errors. (52 bits fraction precision vs `Duration`'s ~94 bit)
2018-09-20 21:36:16 +08:00
Jack O'Connor
d0e59f563d add tests for copy_within 2018-09-20 02:35:32 -04:00
Jack O'Connor
b3ffd3344e define copy_within on slices
This is a safe wrapper around ptr::copy, for regions within a single
slice. Previously, safe in-place copying was only available as a side
effect of Vec::drain.
2018-09-20 00:57:05 -04:00
Taylor Cramer
1b00f0b9fa Remove spawning from task::Context 2018-09-19 15:01:19 -07:00
Artyom Pavlov
fd7565b076
Added tracking issue, fixed check, 1.30 -> 1.31 2018-09-19 18:40:33 +03:00
bors
1e21c9a297 Auto merge of #53877 - withoutboats:compositional-pin, r=aturon
Update to a new pinning API.

~~Blocked on #53843 because of method resolution problems with new pin type.~~

@r? @cramertj

cc @RalfJung @pythonesque anyone interested in #49150
2018-09-19 06:56:19 +00:00
Taylor Cramer
574bca7262 Cleanup Deref impls and add ?Sized bound to &mut T impls 2018-09-18 15:42:51 -07:00
Ralf Jung
adcc0d2168 clarify swap 2018-09-18 21:14:31 +02:00
Taylor Cramer
3ec1810e32 Cleanup and fix method resolution issue 2018-09-17 16:31:33 -07:00
Tobias Bucher
ebffb67295 Adjust the docs of from_raw_parts to match the implementation 2018-09-17 18:34:15 +02:00
Tobias Bucher
11c6318380 Use more obvious calculation for slice size check 2018-09-17 18:09:04 +02:00
Ralf Jung
0ec87d0c92 rearrange for clarity 2018-09-17 15:21:20 +02:00
Ralf Jung
2713d36679 tweaks 2018-09-17 15:14:19 +02:00
csmoe
95c1d817ae move from_nonzero test from run-pass to libcore 2018-09-17 18:01:58 +08:00
csmoe
ac61a9ce21 introduce from_nonzero feature 2018-09-17 16:34:24 +08:00
bors
5aac93c8fb Auto merge of #53910 - IsaacWoods:unify_cvoid, r=SimonSapin
Move std::os::raw::c_void into libcore and re-export in libstd

Implements the first part of [RFC 2521](https://github.com/rust-lang/rfcs/pull/2521).

cc #53856
2018-09-16 23:13:30 +00:00
Jorge Aparicio
828289610b remove (more) CAS API from Atomic* types where not natively supported
closes #54276
2018-09-16 23:04:11 +02:00
bors
f4819878cd Auto merge of #53754 - RalfJung:slice_align_to, r=alexcrichton
stabilize slice_align_to

This is very hard to implement correctly, and leads to [serious bugs](https://github.com/llogiq/bytecount/pull/42) when done incorrectly. Moreover, this is needed to be able to run code that opportunistically exploits alignment on miri. So code using `align_to`/`align_to_mut` gets the benefit of a well-tested implementation *and* of being able to run in miri to test for (some kinds of) UB.

This PR also clarifies the guarantee wrt. the middle part being as long as possible.  Should the docs say under which circumstances the middle part could be shorter? Currently, that can only happen when running in miri.
2018-09-16 07:22:24 +00:00
csmoe
d5c1d15d31 implement From<NonZero<Int>> for Int 2018-09-15 09:34:36 +08:00
Isaac Woods
23e345bc0c
Move std::os::raw::c_void into libcore and re-export in libstd 2018-09-14 16:19:59 +01:00
bors
dfabe4b885 Auto merge of #54032 - oli-obk:layout_scalar_ranges, r=eddyb
Add forever unstable attribute to allow specifying arbitrary scalar ranges

r? @eddyb for the first commit and @nikomatsakis for the second one
2018-09-14 09:47:21 +00:00
kennytm
b3303edba6
Rollup merge of #53218 - weiznich:feature/option_ref_into, r=KodrAus
Add a implementation of `From` for converting `&'a Option<T>` into `Option<&'a T>`

I'm not sure if any annotations regarding the stabilization are needed or in general what's the correct process of adding such an impl.

cc @sgrif (We have talked about this)
2018-09-14 14:50:09 +08:00
Artyom Pavlov
2aca69757f
add panics section to method docs 2018-09-13 01:47:08 +00:00
Artyom Pavlov
9e78cb2446
move checks to from_float_secs 2018-09-13 01:40:38 +00:00
Artyom Pavlov
8a0aa9f3ae
remove trailing spaces 2018-09-13 00:52:59 +00:00
Artyom Pavlov
37972ae300
add as_float_secs and from_float_secs methods, refactor float methods 2018-09-13 00:43:53 +00:00
Artyom Pavlov
c11281f188
fix tests 2018-09-12 18:33:48 +03:00
Artyom Pavlov
533c0f0d1f
fix tests 2018-09-12 17:10:38 +03:00
bors
6810f5286b Auto merge of #53793 - toidiu:ak-stabalize, r=nikomatsakis
stabilize outlives requirements

https://github.com/rust-lang/rust/issues/44493

r? @nikomatsakis
2018-09-12 11:27:48 +00:00
Artyom Pavlov
c5cbea69aa
fix doctests 2018-09-12 14:17:36 +03:00
Artyom Pavlov
07c15ea645
more explicit impl 2018-09-12 11:56:39 +03:00
Artyom Pavlov
206ca68ff3
remove newline 2018-09-12 11:52:19 +03:00
Artyom Pavlov
0673417daa
Move float ops to unstable inherent methods 2018-09-12 11:50:46 +03:00
kennytm
4f62077a2c
Rollup merge of #53777 - ivanbakel:result_map_or_else, r=alexcrichton
Implemented map_or_else for Result<T, E>

Fulfills #53268
The example is ripped from `Option::map_or_else`, with the types corrected.
2018-09-12 12:17:25 +08:00
toidiu
731f4efae5 stabalize infer outlives requirements (RFC 2093).
Co-authored-by: nikomatsakis
2018-09-11 11:40:04 -04:00
Tobias Bucher
5d9086f123 Fix overflow in from_raw_parts size check 2018-09-11 11:44:28 +02:00
Oliver Schneider
833dc7e682 Address attribute naming and use Bound enum 2018-09-11 11:25:51 +02:00
Oliver Schneider
d272e2f6e2 Get rid of the non_zero lang item in favour of arbitrary range specifications 2018-09-11 11:19:48 +02:00
Nicole Mazzuca
78f5b6866e fix typos 2018-09-10 22:30:30 -07:00
Tobias Bucher
1aac00fad3 A slice covering exactly half the address space is not OK 2018-09-10 07:53:42 +02:00
Martin Pool
597c06544d Document .0 to unpack the value from Wrapping 2018-09-08 11:35:02 -07:00
bors
06da917b01 Auto merge of #51885 - GuillaumeGomez:trait-impl-show-docs, r=Mark-Simulacrum,QuietMisdreavus
Trait impl show docs

Fixes #51834.

<img width="1440" alt="screen shot 2018-06-29 at 00 14 33" src="https://user-images.githubusercontent.com/3050060/42063323-6e6e8cc8-7b31-11e8-88ef-4dd2229df76c.png">

(You can see both commit changes in the screenshot 😄)

r? @QuietMisdreavus
2018-09-08 04:14:54 +00:00
kennytm
9b70ef7780
Rollup merge of #53979 - alexcrichton:remove-repr-transparent-atomics-master, r=sfackler
Remove `#[repr(transparent)]` from atomics

Added in #52149 the discussion in #53514 is showing how we may not want to
actually add this attribute to the atomic types. While we continue to
debate #53514 this commit reverts the addition of the `transparent` attribute.
This should be a more conservative route which leaves us the ability to tweak
this in the future but in the meantime allows us to continue discussion as well.
2018-09-07 18:13:57 +08:00
kennytm
03de1c44d1
Rollup merge of #53946 - tbu-:pr_doc_manuallydrop, r=cramertj
Clarify `ManuallyDrop` docs

Mention that you can use `into_inner` to drop the contained value.
2018-09-07 18:13:42 +08:00
kennytm
3f2de03daa
Rollup merge of #53455 - llogiq:num-byte-conversion-docs, r=steveklabnik
Individual docs for {from,to}_*_bytes
2018-09-07 15:26:37 +08:00
kennytm
846a0bd1b9
Rollup merge of #53299 - MagnumOpus21:fix-macro-write, r=steveklabnik
Updated core/macros.rs to note it works in a no_std environment.

Fixes #45797
This PR updates the documentation of `write!` to note it works in a `no_std` environment, and adds an
example to showcase this. In a `no_std` environment, the author of the code is responsible for the
implementation of the `Write` trait. This example will work out of the box with `no_std`, but the
implementation of `Write` is expected to be provided by the user.

r? @steveklabnik
2018-09-07 15:26:26 +08:00
Guillaume Gomez
c1ad1b0338 Fix invalid urls 2018-09-06 23:32:30 +02:00
bors
8b7f164eab Auto merge of #52994 - varkor:trim_direction, r=alexcrichton
Add trim_start, trim_end etc.; deprecate trim_left, trim_right, etc. in future

Adds the methods: `trim_start`, `trim_end`, `trim_start_matches` and `trim_end_matches`.
Deprecates `trim_left`, `trim_right`, `trim_left_matches` and `trim_right_matches` starting from Rust 1.33.0, three versions from when they'll initially be marked as being deprecated, using the future deprecation from https://github.com/rust-lang/rust/issues/30785 and https://github.com/rust-lang/rust/pull/51681.

Fixes https://github.com/rust-lang/rust/issues/30459.
2018-09-05 23:45:08 +00:00
Alex Crichton
0338d340c4 Remove #[repr(transparent)] from atomics
Added in #52149 the discussion in #53514 is showing how we may not want to
actually add this attribute to the atomic types. While we continue to
debate #53514 this commit reverts the addition of the `transparent` attribute.
This should be a more conservative route which leaves us the ability to tweak
this in the future but in the meantime allows us to continue discussion as well.
2018-09-05 15:41:44 -07:00
Andre Bogus
90b7c5acbc Individual docs for {from,to}_*_bytes 2018-09-05 19:49:57 +02:00
Siva Prasad
9d440d578d Spacing changes made to the example 2018-09-05 09:09:50 -04:00
MagnumOpus21
5e7039411b Added a missing backtick to no std 2018-09-05 08:56:00 -04:00
MagnumOpus21
94e8a6aa3b Made the requested changes for Note: and no_std within backticks 2018-09-05 08:56:00 -04:00
MagnumOpus21
6c66aeb6c0 Prefixed no_run to the no_std write macro 2018-09-05 08:56:00 -04:00
MagnumOpus21
efb88b40a1 Formatting errors rectified 2018-09-05 08:56:00 -04:00
MagnumOpus21
3ae6d06edb Refined the example 2018-09-05 08:56:00 -04:00
MagnumOpus21
2ae2c628ee Updated libcore/macro.rs to note write macro can work in no_std setups 2018-09-05 08:56:00 -04:00
Mark Rousskov
9ec5ef541a Breaking change upgrades 2018-09-04 13:22:08 -06:00
Tobias Bucher
0e62990760 Clarify ManuallyDrop docs
Mention that you can use `into_inner` to drop the contained value.
2018-09-04 14:43:21 +02:00
Tobias Bucher
7b77508e23 Add debug_assert!s to slice::from_raw_parts
Copy the documentation over to `slice::from_raw_parts_mut`.
2018-09-04 11:39:28 +02:00
Tobias Bucher
1975b8d21b Document that slices cannot be larger than isize::MAX bytes
Fixes #53676.
2018-09-04 11:35:49 +02:00
bors
4efc0a7811 Auto merge of #53928 - tbu-:pr_doc_fromrawmut, r=frewsxcv
Link to more detailed docs in `slice::from_raw_parts_mut`
2018-09-04 07:11:35 +00:00
bors
cd5c26f0eb Auto merge of #53697 - Cyres:const-fn-int-ops, r=oli-obk
Add more const int ops

r? @oli-obk

Tracking Issue: #53718

list of `const fn`s in this PR:

- `feature = const_int_rotate`
  - `rotate_left`
  - `rotate_right`
- `feature = const_int_wrapping`
  - `wrapping_add`
  - `wrapping_sub`
  - `wrapping_mul`
  - `wrapping_shl`
  - `wrapping_shr`
- `feature = const_int_overflowing`
  - `overflowing_add`
  - `overflowing_sub`
  - `overflowing_mul`
  - `overflowing_shl`
  - `overflowing_shr`
- `feature = const_int_sign`
  - `is_positive`
  - `is_negative`
- `feature = const_int_conversion`
  - `reverse_bits`
  - `to_le_bytes`
  - `to_ne_bytes`
  - `from_be_bytes`
  - `from_le_bytes`
  - `from_ne_bytes`
  - `reverse_bits`
2018-09-03 16:31:34 +00:00
Tobias Bucher
fe56878a24 Link to more detailed docs in slice::from_raw_parts_mut 2018-09-03 18:29:08 +02:00
Tim Diekmann
256cf8681e
Add const_unstable flag to overflowing_shr 2018-09-03 14:53:05 +02:00
bors
23ea1b8188 Auto merge of #53599 - matthiaskrgr:split_str__to__split_char, r=frewsxcv
use char pattern for single-character splits: a.split("x") -> a.split('x')
2018-09-02 15:27:56 +00:00
Ralf Jung
bc809e01ee remark on concurrency in validity section 2018-09-01 18:00:10 +02:00
Ralf Jung
755de3c684 Valid raw pointers 2018-09-01 17:50:54 +02:00
bors
839d99c861 Auto merge of #53884 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests

Successful merges:

 - #53076 (set cfg(rustdoc) when rustdoc is running on a crate)
 - #53622 (cleanup: Add main functions to some UI tests)
 - #53769 (Also link Clippy repo in the CONTRIBUTING.md file)
 - #53774 (Add rust-gdbgui script.)
 - #53781 (bench: libcore: fix build failure of any.rs benchmark (use "dyn Any"))
 - #53782 (Make Arc cloning mechanics clearer in module docs)
 - #53790 (Add regression test for issue #52060)
 - #53801 (Prevent duplicated impl on foreign types)
 - #53850 (Nuke the `const_to_allocation` query)
2018-09-01 15:48:21 +00:00
kennytm
d0f8cf32b3
Rollup merge of #53076 - QuietMisdreavus:cfg-rustdoc, r=GuillaumeGomez
set cfg(rustdoc) when rustdoc is running on a crate

When using `#[doc(cfg)]` to document platform-specific items, it's a little cumbersome to get all the platforms' items to appear all at once. For example, the standard library adds `--cfg dox` to rustdoc's command line whenever it builds docs, and the documentation for `#![feature(doc_cfg)]` suggests using a Cargo feature to approximate the same thing. This is a little awkward, because you always need to remember to set `--features dox` whenever you build documentation.

This PR proposes making rustdoc set `#[cfg(rustdoc)]` whenever it runs on a crate, to provide an officially-sanctioned version of this that is set automatically. This way, there's a standardized way to declare that a certain version of an item is specifically when building docs.

To try to prevent the spread of this feature from happening too quickly, this PR also restricts the use of this flag to whenever `#![feature(doc_cfg)]` is active. I'm sure there are other uses for this, but right now i'm tying it to this feature. (If it makes more sense to give this its own feature, i can easily do that.)
2018-09-01 23:18:41 +08:00
kennytm
8d161a6682
Rollup merge of #53781 - matthiaskrgr:fix_any_bench, r=kennytm
bench: libcore: fix build failure of any.rs benchmark (use "dyn Any")

fixes
````
error: trait objects without an explicit `dyn` are deprecated
  --> libcore/../libcore/benches/any.rs:18:36
   |
18 |         let mut y = &mut x as &mut Any;
   |                                    ^^^ help: use `dyn`: `dyn Any`
   |
   = note: requested on the command line with `-D bare-trait-objects`
````
2018-09-01 21:14:11 +08:00
Tim
cdea63058a rebase 2018-09-01 15:05:55 +02:00
bors
fea32f1b77 Auto merge of #53604 - oli-obk:min_const_fn, r=Centril,varkor
Implement the `min_const_fn` feature gate

cc @RalfJung @eddyb

r? @Centril

implements the feature gate for #53555

I added a hack so the `const_fn` feature gate also enables the `min_const_fn` feature gate. This ensures that nightly users of `const_fn` don't have to touch their code at all.

The `min_const_fn` checks are run first, and if they succeeded, the `const_fn` checks are run additionally to ensure we didn't miss anything.
2018-09-01 11:26:24 +00:00
Without Boats
974bdc80fe
Update to a new pinning API. 2018-09-01 06:57:58 +02:00
bors
571a624aa9 Auto merge of #53755 - llogiq:fix-unsound-16bit-range, r=nagisa
fix u32 steps_between for 16-bit systems

This fixes #48006.
2018-08-31 22:44:17 +00:00
QuietMisdreavus
ad2169c095 use cfg(rustdoc) instead of cfg(dox) in std and friends 2018-08-31 13:29:10 -05:00
Ralf Jung
408a6a00c2 fix doctests 2018-08-31 18:47:41 +02:00
Ralf Jung
b463871df5 (un)aligned 2018-08-31 17:02:39 +02:00
Ralf Jung
dc2237c49f apply feedback 2018-08-31 17:01:53 +02:00
Ralf Jung
4ed469c483 turn ptr type method docs into links to docs of free functions, to avoid duplication and inconsistency 2018-08-31 09:54:37 +02:00
Oliver Schneider
472ca71598 Implement the min_const_fn feature gate 2018-08-31 08:39:59 +02:00
Pietro Albini
07fcb0168e
Rollup merge of #53785 - tbu-:pr_comment, r=Mark-Simulacrum
Fix a comment in src/libcore/slice/mod.rs
2018-08-30 20:15:46 +02:00
Pietro Albini
a245d9bbca
Rollup merge of #53476 - GuillaumeGomez:try-from-int-error-partial-eq, r=KodrAus
Add partialeq implementation for TryFromIntError type

Fixes #53458.
2018-08-30 20:15:30 +02:00
Pietro Albini
b7e74a5614
Rollup merge of #51760 - GuillaumeGomez:add-another-partialeq-example, r=QuietMisdreavus
Add another PartialEq example

r? @steveklabnik
2018-08-30 20:15:23 +02:00
Ralf Jung
18a7bdb568 fix example 2018-08-30 18:05:49 +02:00
Ralf Jung
274122426e fix example 2018-08-30 17:48:34 +02:00
Ralf Jung
c06f5517dc improve volatile comments 2018-08-30 17:37:58 +02:00
Ralf Jung
d97f61f10e avoid shadowing; fix examples 2018-08-30 17:28:21 +02:00
Ralf Jung
e869b81b93 address remaining remarks and add example for dropping unaligned data 2018-08-30 17:07:24 +02:00
Ralf Jung
1ec66fb4b2 apply comments 2018-08-30 16:26:48 +02:00
Ralf Jung
fc63113f1f clarify ZST comment 2018-08-30 16:19:05 +02:00
Andre Bogus
9dab56c4a2 fix u32 steps_between for 16-bit systems 2018-08-30 12:35:00 +02:00
Isaac van Bakel
79408c3f32 Added feature attribute to example code in map_or_else doc 2018-08-30 00:51:09 +01:00
Isaac van Bakel
6ff4f7946f Corrected type variable output T -> U in Result::map_or_else 2018-08-29 22:55:21 +01:00
Isaac van Bakel
3eda9058cf Corrected feature status of Result::map_or_else
map_or_else is now correctly labelled unstable and points to the
tracking issue on rust-lang/rust
2018-08-29 22:51:54 +01:00
Isaac van Bakel
71b16d8350 Corrected bad typing in Result::map_or_else doc
The error value now includes the type of the success.
The success value now includes the type of the error.
2018-08-29 22:15:17 +01:00
Ralf Jung
098bec82f6 clarify that these are preliminary guarantees 2018-08-29 19:27:20 +02:00
Tobias Bucher
890d04d00f Fix a comment in src/libcore/slice/mod.rs 2018-08-29 15:23:06 +02:00
Ralf Jung
b0c5dc2cc1 edit docs a little 2018-08-29 14:34:59 +02:00
Isaac van Bakel
5eb679105f Corrected feature name for map_or_else 2018-08-29 13:08:52 +01:00
Matthias Krüger
50057ee3a3 bench: libcore: fix build failure of any.rs benchmark (use "dyn Any") 2018-08-29 12:18:05 +02:00
Dylan MacKenzie
c8da321581 Resolve null/ZST conflict correctly (whoops) 2018-08-29 10:10:58 +02:00
Dylan MacKenzie
7e165d90a6 Add a list of known facts re: validity
Also rewrites the reads/writes section to be less reliant on `*const`,
`*mut`
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
95a9088603 You can't make an omlette without breaking a few links 2018-08-29 10:10:58 +02:00
Dylan MacKenzie
3a55c85c33 Incorporate RalfJung's suggestions
This splits "valid" into "valid for reads" and "valid for writes", and
also adds the concept of operation size to validity. Now functions which
operate on sequences state that e.g. pointer args must be "valid for reads of
size x".
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
ea5570cf27 Redefine range validity
Uses `x.offset(i)` must be valid for all `i` in `0..count`.
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
e40585f248 Remove definiton of valid pointer
The enumerated list of conditions is replaced by an explanation that
rust doesn't have a formal memory model. It does say that pointers
created directly from references are guaranteed to be valid, and links
to both the "Unsafe Code" section of the book and the "Undefined
Behavior" section of the reference.
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
30122e91d9 Fix off-by-one error when specifying a valid range 2018-08-29 10:10:58 +02:00
Dylan MacKenzie
6f7338bb92 Reword module level docs re: alignment 2018-08-29 10:10:58 +02:00
Dylan MacKenzie
7b2ef6bd77 Update docs for swap_nonoverlapping
They closely mirror the docs for `copy_nonoverlapping`
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
04a08c60a1 Fix unused variable warning in doctest 2018-08-29 10:10:58 +02:00
Dylan MacKenzie
9f5a3cccb8 Fix failing doctests 2018-08-29 10:10:58 +02:00
Dylan MacKenzie
da58bebf01 Mention alignment in top-level docs
This also removes the overlong link that failed tidy xD.
2018-08-29 10:10:58 +02:00
Dylan MacKenzie
911d35f0bf Rewrite docs for std::ptr
- Add links to the GNU libc docs for `memmove`, `memcpy`, and
  `memset`, as well as internally linking to other functions in `std::ptr`
- List invariants which, when violated, cause UB for all functions
- Add example to `ptr::drop_in_place` and compares it to `ptr::read`.
- Add examples which more closely mirror real world uses for the
  functions in `std::ptr`. Also, move the reimplementation of `mem::swap`
  to the examples of `ptr::read` and use a more interesting example for
  `copy_nonoverlapping`.
- Change module level description
- Define what constitutes a "valid" pointer.
- Centralize discussion of ownership of bitwise copies in `ptr::read` and
  provide an example.
2018-08-29 10:10:58 +02:00
Isaac van Bakel
b8c60302e7 Implemented map_or_else for Result<T, E> 2018-08-29 02:37:57 +01:00
Guillaume Gomez
da4febd51e Add partialeq implementation for TryFromIntError type 2018-08-28 20:40:14 +02:00
Ralf Jung
f4f114002e stabilize slice_align_to 2018-08-28 10:41:53 +02:00
bors
8c2b371ebc Auto merge of #53227 - nivkner:pin_move, r=RalfJung
move the Pin API into its own module for centralized documentation

This implements the change proposed by @withoutboats in #49150, as suggested by @RalfJung in the review of #53104,
along with the documentation that was originally in it, that was deemed more appropriate in module-level documentation.

r? @RalfJung
2018-08-27 22:56:15 +00:00
bors
70a21e89f1 Auto merge of #53441 - toidiu:ak-fix53419, r=nikomatsakis
fix for late-bound regions

Fix for https://github.com/rust-lang/rust/issues/53419

r? @nikomatsakis
2018-08-27 17:42:45 +00:00
bors
af2be23fd1 Auto merge of #53385 - matklad:stabilize-find-map, r=KodrAus
Stablize Iterator::find_map

Stabilization PR for https://github.com/rust-lang/rust/issues/49602
2018-08-25 08:53:04 +00:00
Niko Matsakis
73fb1622b3 check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
Niv Kaminer
83ca347343 remove copyright headers now that they are not madatory 2018-08-25 00:07:00 +03:00
bors
727eabd681 Auto merge of #53662 - kennytm:rollup, r=kennytm
Rollup of 16 pull requests

Successful merges:

 - #53311 (Window Mutex: Document that we properly initialize the SRWLock)
 - #53503 (Discourage overuse of mem::forget)
 - #53545 (Fix #50865: ICE on impl-trait returning functions reaching private items)
 - #53559 (add macro check for lint)
 - #53562 (Lament the invincibility of the Turbofish)
 - #53563 (use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into())
 - #53592 (docs: minor stylistic changes to str/string docs)
 - #53594 (Update RELEASES.md to include clippy-preview)
 - #53600 (Fix a grammatical mistake in "expected generic arguments" errors)
 - #53614 (update nomicon and book)
 - #53617 (tidy: Stop requiring a license header)
 - #53618 (Add missing fmt examples)
 - #53636 (Prefer `.nth(n)` over `.skip(n).next()`.)
 - #53644 (Use SmallVec for SmallCStr)
 - #53664 (Remove unnecessary closure in rustc_mir/build/mod.rs)
 - #53666 (Added rustc_codegen_llvm to compiler documentation.)
2018-08-24 17:02:23 +00:00
kennytm
9dfb95b11f
Rollup merge of #53636 - frewsxcv:frewsxcv-nth, r=rkruppe
Prefer `.nth(n)` over `.skip(n).next()`.

Found by clippy.
2018-08-24 19:24:44 +08:00
kennytm
a37b69da9f
Rollup merge of #53618 - GuillaumeGomez:fmt-examples, r=QuietMisdreavus
Add missing fmt examples

r? @QuietMisdreavus
2018-08-24 19:24:42 +08:00
Sergio Benitez
ed0bd38cac Stabilize 'attr_literals' feature. 2018-08-23 19:06:07 -07:00
Guillaume Gomez
2cc2e01e04 Add missing fmt examples 2018-08-23 20:20:58 +02:00
Kornel
e7709b3d44 Discourage overuse of mem::forget 2018-08-23 15:01:28 +01:00
Corey Farwell
9e0ff24b6d Prefer .nth(n) over .skip(n).next().
Found by clippy.
2018-08-23 09:35:49 -04:00
Niv Kaminer
b26cce5ec0 link to items in pin module to std docs 2018-08-23 10:16:58 +03:00
Niv Kaminer
3683bf279d adjust PinMut import in Unpin docs 2018-08-23 02:13:02 +03:00
Niv Kaminer
c3fd65ba23 link Unpin to pin module documentation 2018-08-23 02:13:02 +03:00
Niv Kaminer
bfed149020 reexport Unpin into pin module 2018-08-23 02:13:01 +03:00
Niv Kaminer
871e89b351 capitalize and punctuate libcore pin module 2018-08-23 02:13:01 +03:00
Niv Kaminer
1c26be3929 fix broken link to Unpin due to reexport 2018-08-23 02:13:01 +03:00
Niv Kaminer
2f501a1bc4 fix PinMut documentation 2018-08-23 01:37:03 +03:00
Niv Kaminer
c1103885fe fix link to PinMut 2018-08-23 01:37:03 +03:00
Niv Kaminer
30bb4af5d8 add top-level documentation to the std pin module 2018-08-23 01:37:03 +03:00
Niv Kaminer
13da951868 move PinMut into pin module and export through std 2018-08-23 01:37:03 +03:00
Guillaume Gomez
4f78a2d58f
Rollup merge of #53574 - vorner:ptr_as_ref_unchecked, r=Mark-Simulacrum
Suggest direct raw-pointer dereference

People often come looking for some kind of `as_ref_unchecked` method on
raw pointers that would give them `&T` and not `Option<&T>` when they
are sure the pointer is not NULL.

There's no such method, but taking a reference of the dereferenced
pointer accomplishes the same thing. Therefore, suggest using that, at
the `as_ref` site ‒ it's a place people are likely going to look into.
2018-08-22 17:45:41 +02:00
Matthias Krüger
e699076780 use char pattern for single-character splits: a.split("x") -> a.split('x') 2018-08-22 12:56:32 +02:00
Guillaume Gomez
3995bff26c Add another PartialEq example 2018-08-21 23:24:23 +02:00
Michal 'vorner' Vaner
18f41e54d9
Suggest direct raw-pointer dereference
People often come looking for some kind of `as_ref_unchecked` method on
raw pointers that would give them `&T` and not `Option<&T>` when they
are sure the pointer is not NULL.

There's no such method, but taking a reference of the dereferenced
pointer accomplishes the same thing. Therefore, suggest using that, at
the `as_ref` site ‒ it's a place people are likely going to look into.
2018-08-21 20:03:54 +02:00
kennytm
0dd88c9797
Rollup merge of #53329 - frewsxcv:frewsxcv-ptr-add-sub, r=RalfJung
Replace usages of ptr::offset with ptr::{add,sub}.

Rust provides these helper methods – so let's use them!
2018-08-21 22:05:30 +08:00
kennytm
dc8e9fb2b1
Rollup merge of #53104 - nivkner:unpin_doc, r=RalfJung
expand the documentation on the `Unpin` trait

provides an overview of the Pin API which the trait is for,
and show how it can be used in making self referencial structs

part of #49150
2018-08-21 17:52:01 +08:00
kennytm
7896ac3e08
Rollup merge of #53363 - llogiq:num-individual-nonzero-docs, r=steveklabnik
add individual docs to `core::num::NonZero*`
2018-08-21 17:51:54 +08:00
kennytm
b5519db323
Rollup merge of #53496 - matthiaskrgr:codespell_08_2018, r=varkor
Fix typos found by codespell.
2018-08-21 17:51:49 +08:00
kennytm
ffde96c201
Rollup merge of #53296 - estebank:suggest-closure, r=KodrAus
When closure with no arguments was expected, suggest wrapping

Fix #49694.
2018-08-21 01:20:12 +08:00
Corey Farwell
993fb93464 Replace usages of ptr::offset with ptr::{add,sub}. 2018-08-20 07:28:34 -04:00
Mazdak Farrokhzad
86641d97b2
core::convert::identity: fix issue number to #53500 2018-08-20 09:16:56 +02:00
Son
1acec4cbd9 Add doc for impl From in char_convert 2018-08-20 15:46:59 +10:00
Mazdak Farrokhzad
f84ec02bf7 remove feature(convert_id) from lib{core,std}/lib.rs 2018-08-19 19:25:35 +02:00
Mazdak Farrokhzad
71187b7e18
Make core::convert::identity a const fn. 2018-08-19 18:49:31 +02:00
Mazdak Farrokhzad
8208c77782
Drop identity from prelude. 2018-08-19 18:36:18 +02:00
Mazdak Farrokhzad
08b1d83a46
Merge branch 'master' into feature/core_convert_id 2018-08-19 18:34:46 +02:00
Matthias Krüger
71120ef1e5 Fix typos found by codespell. 2018-08-19 17:41:28 +02:00
bors
8928de7439 Auto merge of #52972 - RalfJung:from_raw_parts_align, r=alexcrichton
debug_assert to ensure that from_raw_parts is only used properly aligned

This does not help nearly as much as I would hope because everybody uses the distributed libstd which is compiled without debug assertions. For this reason, I am not sure if this is even worth it. OTOH, this would have caught the misalignment fixed by https://github.com/rust-lang/rust/issues/42789 *if* there had been any tests actually using ZSTs with alignment >1 (we have a CI runner which has debug assertions in libstd enabled), and it seems to currently [fail in the rg testsuite](https://ci.appveyor.com/project/rust-lang/rust/build/1.0.8403/job/v7dfdcgn8ay5j6sb). So maybe it is worth it, after all.

I have seen the attribute `#[rustc_inherit_overflow_checks]` in some places, does that make it so that the *caller's* debug status is relevant? Is there a similar attribute for `debug_assert!`? That could even subsume `rustc_inherit_overflow_checks`: Something like `rustc_inherit_debug_flag` could affect *all* places that change the generated code depending on whether we are in debug or release mode. In fact, given that we have to keep around the MIR for generic functions anyway, is there ever a reason *not* to handle the debug flag that way? I guess currently we apply debug flags like `cfg` so this is dropped early during the MIR pipeline?

EDIT: I learned from @eddyb that because of how `debug_assert!` works, this is not realistic. Well, we could still have it for the rustc CI runs and then maybe, eventually, when libstd gets compiled client-side and there is both a debug and a release build... then this will also benefit users.^^
2018-08-19 09:40:36 +00:00
Niv Kaminer
6ae915b29e clarify use of Unpin and pinning types 2018-08-17 22:28:05 +03:00
Corey Farwell
f0764433f7
Rollup merge of #53358 - SimonSapin:int-bytes, r=shepmaster
`{to,from}_{ne,le,be}_bytes` for unsigned integer types

Same as https://github.com/rust-lang/rust/pull/51919 did for signed integers.

Tracking issue: https://github.com/rust-lang/rust/issues/52963
2018-08-17 08:23:40 -07:00
Simon Sapin
f5556a6a28 Gratuitous at byte boundaries in hex i32 literals in some doc-tests 2018-08-17 14:01:57 +02:00
kennytm
6e98ed9650
Rollup merge of #53395 - varkor:__Nonexhaustive-to-non_exhaustive, r=shepmaster
Use #[non_exhaustive] on internal enums

This replaces `__Nonexhaustive` variants (and variants thereof)  with `#[non_exhaustive]`. These were mostly unstable previously, with the exception of the `cloudabi` enums and `Level` in proc_macro: these were `#[doc(hidden)]`, so clearly intended not to be used directly. It should be safe to replace all of these.
2018-08-17 00:13:26 +08:00
bors
5050349749 Auto merge of #53256 - ollie27:writeln, r=KodrAus
Don't accept non-string literals for the format string in writeln

This is to improve diagnostics.

`println` and `eprintln` were already fixed by #52394.

Fixes #30143
2018-08-16 13:29:40 +00:00
Niv Kaminer
03530fa5e6 add example for moving out of pointer 2018-08-16 13:56:08 +03:00
Esteban Küber
e5e14d307b When closure with no arguments was expected, suggest wrapping 2018-08-15 13:05:01 -07:00
Aleksey Kladov
1a0d3f0979 Fix since of Iterator::flatten to be a proper semver 2018-08-15 19:28:42 +03:00
varkor
bbf0b159b7 Make core::sync::atomic::Ordering #[non_exhaustive] 2018-08-15 17:11:42 +01:00
Aleksey Kladov
057878ac71 Stablize Iterator::find_map 2018-08-15 18:44:44 +03:00
Andre Bogus
687cc989ca add individual docs to core::num::NonZero* 2018-08-14 22:18:18 +02:00
Simon Sapin
8defd152b3 {to,from}_{ne,le,be}_bytes for unsigned integer types
Same as https://github.com/rust-lang/rust/pull/51919 did for signed integers.

Tracking issue: https://github.com/rust-lang/rust/issues/52963
2018-08-14 18:46:04 +02:00
bors
5bb923988f Auto merge of #53033 - RalfJung:manually_dro, r=SimonSapin
unsized ManuallyDrop

I think this matches what @eddyb had in https://github.com/rust-lang/rust/pull/52711 originally.

~~However, I have never added a `CoerceUnsized` before so I am not sure if I did this right. I copied the `unstable` attribute on the `impl` from elsewhere, but AFAIK it is useless because `impl`'s are insta-stable... so shouldn't this rather say "stable since 1.30"?~~

This is insta-stable and hence requires FCP, at least.

Fixes https://github.com/rust-lang/rust/issues/47034
2018-08-14 08:32:59 +00:00
Guillaume Gomez
f618071c46
Rollup merge of #53273 - frewsxcv:frewsxcv-ufffd, r=GuillaumeGomez
Add links to std::char::REPLACEMENT_CHARACTER from docs.

There are a few places where we mention the replacement character in the
docs, and it could be helpful for users to utilize the constant which is
available in the standard library, so let’s link to it!
2018-08-12 23:27:04 +02:00
Guillaume Gomez
b1b5c66e10
Rollup merge of #53240 - llogiq:doc-num-swap-reverse, r=joshtriplett
Add individual documentation for <integer>`.swap_bytes`/.`reverse_bits`
2018-08-12 23:26:58 +02:00
Guillaume Gomez
3e9a1a1b82
Rollup merge of #53230 - memoryruins:nll_bootstrap_4, r=nikomatsakis
[nll] enable feature(nll) on various crates for bootstrap: part 4

#53172

r? @nikomatsakis
2018-08-12 23:26:56 +02:00
Guillaume Gomez
28e1a7ba5e
Rollup merge of #53059 - ljedrz:unneeded_returns, r=kennytm
Remove explicit returns where unnecessary
2018-08-12 23:26:51 +02:00
Corey Farwell
ec18991492 Add links to std::char::REPLACEMENT_CHARACTER from docs.
There are a few places where we mention the replacement character in the
docs, and it could be helpful for users to utilize the constant which is
available in the standard library, so let’s link to it!
2018-08-11 15:42:35 -04:00
Oliver Middleton
7b0bafe749 Don't accept none str literals for the format string in writeln 2018-08-10 19:01:54 +01:00
Georg Semmler
a7a0225a28
Also add a From implementation for &mut Option<T> -> `Option<&mut T>' 2018-08-10 14:21:17 +02:00
Andre Bogus
945f0325e3 Add individual documentation for <integer>.swap_bytes/.reverse_bits 2018-08-10 12:10:07 +02:00
kennytm
9f55705a24
Rollup merge of #53207 - llogiq:num-rotate-docs, r=QuietMisdreavus
Add individual docs for rotate_{left, right}
2018-08-10 01:55:31 +08:00
kennytm
746abc3265
Rollup merge of #53082 - felixrabe:fix-doc-link-again, r=GuillaumeGomez
Fix doc link (again)

Similar to #52404. The link for comparison:

-   https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-sized (broken)

-   https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait (correct, stable 2nd ed)

-   https://doc.rust-lang.org/nightly/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait (correct, nightly 2nd ed)

-   https://doc.rust-lang.org/nightly/book/2018-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait (correct, nightly 2018 ed)

This commit is the result of (first) searching via ripgrep (0.8.1 -SIMD -AVX):

    rg -l dynamically-sized-types-and-sized

and then replacing all relevant occurrences via:

    find src/{libcore,test/ui} -type f -print0 | xargs -0 sed -i.bak \
      s/dynamically-sized-types-and-sized/dynamically-sized-types-and-the-sized-trait/g
    find src/{libcore,test/ui} -type f -name '*.bak' -print0 | xargs -0 rm

(Note: Tested on on macOS 10.13 (BSD). `sed -i.bak` should work on Linux
(GNU sed) as well, but not tested.)
2018-08-10 01:01:28 +08:00
kennytm
410f63dbb7
Rollup merge of #53217 - strake:inline, r=nagisa
inline some short functions

I found these were outline in binaries i link. I think they ought to be inline, considering their size.
2018-08-10 01:01:27 +08:00
kennytm
db74946803
Rollup merge of #53106 - RalfJung:ordering, r=stjepang
atomic ordering docs

Discussion in https://github.com/rust-lang/rfcs/pull/2503 revealed that this could be improved. I hope this helps.
2018-08-10 01:01:24 +08:00
Andre Bogus
cc2503a4f4 Add individual docs for rotate_{left, right} 2018-08-09 17:10:27 +02:00
memoryruins
bf089a1ac1 [nll] libcore: enable feature(nll) for bootstrap 2018-08-09 09:19:53 -04:00
Georg Semmler
0cde1cbb10
Add stability attribute 2018-08-09 12:48:55 +02:00
Ralf Jung
5ee5a7eb55 repr(transparent) 2018-08-09 11:56:01 +02:00
M Farkas-Dyck
b78201aee5 inline some short functions 2018-08-09 01:27:48 -08:00
Georg Semmler
ef519c1de5
Add a implementation of From for converting &'a Option<T> into
`Option<&'a T>`
2018-08-09 11:02:08 +02:00
Niv Kaminer
68e766afab remove general pinning information from Unpin trait 2018-08-07 21:14:57 +03:00
bors
39e9516532 Auto merge of #51990 - oli-obk:unstable_union, r=nikomatsakis
Place unions, pointer casts and pointer derefs behind extra feature gates

To ensure we don't stabilize these things together with const fn stabilization (or any other stabilization)

This PR moves union field accesses inside `const fn` behind a feature gate. It was possible without a feature gate before, but since `const fn` was behind a feature gate we can do this change.

While "dereferencing raw pointers" and "casting raw pointers to usize" were hard errors before this PR, one could work around them by abusing unions:

```rust
// deref
union Foo<T> {
    x: &'static T,
    y: *const T,
}
const FOO: u32 = unsafe { *Foo { y: 42 as *const T }.x };

// as usize cast
union Bar<T> {
    x: usize,
    y: *const T,
}
const BAR: usize = unsafe { Bar { y: &1u8 }.x };
```

r? @eddyb

cc @nikomatsakis
2018-08-07 13:14:37 +00:00
Oliver Schneider
3ef863bfdf Place unions, pointer casts and pointer derefs behind extra feature gates 2018-08-07 14:41:33 +02:00
Ralf Jung
6a018a03df document mode possibilities for all RMW operations 2018-08-07 11:57:43 +02:00
Ralf Jung
1733bd3cbd list possible orderings for load and store 2018-08-07 11:33:20 +02:00
Ralf Jung
110bcc9798 forgot to add comment for some atomic types 2018-08-07 11:26:05 +02:00
Ralf Jung
e9a86a2e1a fix link label; use more https 2018-08-07 11:23:30 +02:00
kennytm
3385cae74a
Rollup merge of #53068 - MajorBreakfast:spawn, r=cramertj
Rename Executor trait to Spawn

Renames the `Executor` trait to `Spawn` and the method on `Context` to `spawner`.

Note: Best only merge this after we've the alpha 3 announcement post ready.

r? @cramertj
2018-08-07 16:55:42 +08:00
kennytm
b1ca710c5d
Rollup merge of #53052 - redroc:master, r=QuietMisdreavus
fixed broken links to char

fixes https://github.com/rust-lang/rust/issues/32129
2018-08-07 16:55:40 +08:00
Niv Kaminer
87bbd2eeef fix style issues in doc comment 2018-08-07 00:00:51 +03:00
Ralf Jung
d865adcf1e unconfuse @eddyb 2018-08-06 15:52:36 +02:00
Ralf Jung
3dcdb8a83e remove unnecessary CoerceUnsized impl 2018-08-06 15:52:27 +02:00
Niv Kaminer
9b7d71067b fix link to PinBox 2018-08-06 14:01:49 +03:00
Josef Reinhard Brandl
60aa11df4c Rename Executor trait to Spawn 2018-08-06 12:18:47 +02:00
Ralf Jung
621d06481d atomic ordering docs 2018-08-06 12:05:59 +02:00
Niv Kaminer
6845dc43cd correct explenation on the usage of NonNull 2018-08-06 12:02:46 +03:00
Niv Kaminer
038ce659e3 expand the documentation on the Unpin trait
provides an overview of the Pin API which the trait is for,
and show how it can be used in making self referencial structs

part of #49150
2018-08-06 10:52:35 +03:00
varkor
3e10ffcb81 Make features stable and clarify examples 2018-08-05 22:48:30 +01:00
varkor
c157ec87ed Fix 2018 edition tests 2018-08-05 15:54:49 +01:00
varkor
319b052357 Fix stage 2 tests 2018-08-05 15:54:49 +01:00
varkor
a00ba4d71e Correct invalid feature attributes 2018-08-05 15:54:49 +01:00
varkor
64185f205d Remove unnecessary or invalid feature attributes 2018-08-05 15:54:48 +01:00
Felix Rabe
c74415872c Fix doc link (again)
Similar to #52404. The link for comparison:

-   https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-sized (broken)

-   https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait (correct, stable 2nd ed)

-   https://doc.rust-lang.org/nightly/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait (correct, nightly 2nd ed)

-   https://doc.rust-lang.org/nightly/book/2018-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait (correct, nightly 2018 ed)

This commit is the result of (first) searching via ripgrep (0.8.1 -SIMD -AVX):

    rg -l dynamically-sized-types-and-sized

and then replacing all relevant occurrences via:

    find src/{libcore,test/ui} -type f -print0 | xargs -0 sed -i.bak \
      s/dynamically-sized-types-and-sized/dynamically-sized-types-and-the-sized-trait/g
    find src/{libcore,test/ui} -type f -name '*.bak' -print0 | xargs -0 rm

(Note: Tested on on macOS 10.13 (BSD). `sed -i.bak` should work on Linux
(GNU sed) as well, but not tested.)
2018-08-05 07:52:29 +02:00
kennytm
396dda0a6a
Rollup merge of #53062 - ljedrz:redundant_field_names, r=Mark-Simulacrum
Remove redundant field names in structs
2018-08-04 23:09:12 +08:00
ljedrz
d46dca66c9 Remove redundant field names in structs 2018-08-04 14:58:20 +02:00
ljedrz
1667950d73 Remove explicit returns where unnecessary 2018-08-04 14:31:03 +02:00
kennytm
52db0ed161
Rollup merge of #51919 - tbu-:pr_num_to_from_bytes2, r=SimonSapin
Provide `{to,from}_{ne,le,be}_bytes` functions on integers

If one doesn't view integers as containers of bytes, converting them to
bytes necessarily needs the specfication of encoding.

I think Rust is a language that wants to be explicit. The `to_bytes`
function is basically the opposite of that – it converts an integer into
the native byte representation, but there's no mention (in the function
name) of it being very much platform dependent. Therefore, I think it
would be better to replace that method by three methods, the explicit
`to_ne_bytes` ("native endian") which does the same thing and
`to_{le,be}_bytes` which return the little- resp. big-endian encoding.
2018-08-04 17:19:38 +08:00
Tobias Bucher
0ddfae5ba2 Change tracking issue from #49792 to #51919
The old issue has already been in FCP, a new issue was opened for the
new API.
2018-08-04 08:36:54 +02:00
redroc
616970758b deleted changed lines 2018-08-04 05:51:02 +02:00
redroc
33483fa0e3 fixed broken links to char 2018-08-04 03:36:58 +02:00
Артём Павлов [Artyom Pavlov]
d48a649a17
1.29.0 -> 1.30.0 2018-08-04 00:47:13 +03:00
Ralf Jung
b3d2346230 unsized ManuallyDrop 2018-08-03 18:09:20 +02:00
Ralf Jung
71460d4d11 volatile operations docs: clarify that this does not help wrt. concurrency 2018-08-03 12:15:00 +02:00
Tobias Bucher
a04b2cda0b Provide {to,from}_{ne,le,be}_bytes functions on integers
If one doesn't view integers as containers of bytes, converting them to
bytes necessarily needs the specfication of encoding.

I think Rust is a language that wants to be explicit. The `to_bytes`
function is basically the opposite of that – it converts an integer into
the native byte representation, but there's no mention (in the function
name) of it being very much platform dependent. Therefore, I think it
would be better to replace that method by three methods, the explicit
`to_ne_bytes` ("native endian") which does the same thing and
`to_{le,be}_bytes` which return the little- resp. big-endian encoding.
2018-08-03 07:55:10 +02:00
varkor
33067ad201 Add #![feature(trim_direction)] to doc comments 2018-08-02 22:00:13 +01:00
varkor
aecf8c2a62 Add trim_start, trim_end, trim_start_matches and trim_end_matches 2018-08-02 20:39:29 +01:00
bors
03da14ba8c Auto merge of #52949 - Mark-Simulacrum:snap, r=alexcrichton
Switch to bootstrapping from 1.29 beta

r? @alexcrichton
2018-08-02 15:34:21 +00:00
Ralf Jung
6fb97a6c86 test that align_of handles alignment properly for the mid part 2018-08-02 17:32:24 +02:00
Ralf Jung
7b24d2bb35 debug_assert to ensure that from_raw_parts is only used properly aligned 2018-08-02 11:33:59 +02:00
bors
1d9405fb6c Auto merge of #52206 - RalfJung:zst-slices, r=alexcrichton
slices: fix ZST slice iterators making up pointers; debug_assert alignment in from_raw_parts

This fixes the problem that we are fabricating pointers out of thin air. I also managed to share more code between the mutable and shared iterators, while reducing the amount of macros.

I am not sure how useful it really is to add a `debug_assert!` in libcore. Everybody gets a release version of that anyway, right? Is there at least a CI job that runs the test suite with a debug version?

Fixes #42789
2018-08-02 00:14:21 +00:00
Ralf Jung
9fcf2c9726 use the same length computation everywhere 2018-08-02 00:33:04 +02:00
Ralf Jung
e1471cf41f Introduce another way to compute the length, to fix position codegen regression 2018-08-02 00:33:04 +02:00
Ralf Jung
b0a82d9314 simplify len macro: No longer require the type
Also use ident, not expr, to avoid accidental side-effects
2018-08-02 00:33:04 +02:00
Ralf Jung
3e3ff4b652 macro-inline len() and is_empty() to fix performance regressions
This also changes the IR for nth(), but the new IR actually looks nicer that the old
(and it is one instruction shorter).
2018-08-02 00:33:03 +02:00
Ralf Jung
1b3c6bac8b make the code for nth closer to what it used to be 2018-08-02 00:33:03 +02:00
Ralf Jung
60b06369ee test nth better 2018-08-02 00:33:03 +02:00
Ralf Jung
cbdba2b4c2 use wrapping_offset; fix logic error in nth 2018-08-02 00:33:03 +02:00
Ralf Jung
c7d90d1a50 comments 2018-08-02 00:33:03 +02:00
Ralf Jung
86369c3ad4 slice iterators: ZST iterators no longer just "make up" addresses 2018-08-02 00:29:12 +02:00
bors
97085f9fb0 Auto merge of #52958 - pietroalbini:rollup, r=pietroalbini
Rollup of 15 pull requests

Successful merges:

 - #52793 (Add test for NLL: unexpected "free region `` does not outlive" error )
 - #52799 (Use BitVector for global sets of AttrId)
 - #52809 (Add test for unexpected region for local data ReStatic)
 - #52834 ([NLL] Allow conflicting borrows of promoted length zero arrays)
 - #52835 (Fix Alias intra doc ICE)
 - #52854 (fix memrchr in miri)
 - #52899 (tests/ui: Add missing mips{64} ignores)
 - #52908 (Use SetLenOnDrop in Vec::truncate())
 - #52915 (Don't count MIR locals as borrowed after StorageDead when finding locals live across a yield terminator)
 - #52926 (rustc: Trim down the `rust_2018_idioms` lint group)
 - #52930 (rustc_resolve: record single-segment extern crate import resolutions.)
 - #52939 (Make io::Read::read_to_end consider io::Take::limit)
 - #52942 (Another SmallVec.extend optimization)
 - #52947 (1.27 actually added the `armv5te-unknown-linux-musleabi` target)
 - #52954 (async can begin expressions)

Failed merges:

r? @ghost
2018-08-01 19:54:06 +00:00
Pietro Albini
e3928ccb2f
Rollup merge of #52854 - RalfJung:memrchr, r=Kimundi
fix memrchr in miri

The previous PR https://github.com/rust-lang/rust/pull/52744 was not enough because it assumed that the split between the `mid` and `end` parts returned by `align_to` was aligned. But really the only guarantee we have is that the `mid` part is aligned, so make use of that.
2018-08-01 21:46:28 +02:00
Mark Rousskov
683a3db01f Switch to bootstrapping from 1.29 beta 2018-08-01 11:59:08 -06:00
bors
c4156768aa Auto merge of #51609 - dscorbett:is_numeric, r=alexcrichton
Treat gc=No characters as numeric

[`char::is_numeric`](https://doc.rust-lang.org/std/primitive.char.html#method.is_numeric) and [`char::is_alphanumeric`](https://doc.rust-lang.org/std/primitive.char.html#method.is_alphanumeric) are documented to be defined “in terms of the Unicode General Categories 'Nd', 'Nl', 'No'”, but unicode.py does not group 'No' with the other 'N' categories. These functions therefore currently return `false` for characters like ⟨¾⟩ and ⟨①⟩.
2018-08-01 17:44:25 +00:00
Pietro Albini
ac2b3c3712
Rollup merge of #52905 - pravic:unsize-typo, r=alexcrichton
Fix a typo in unsize.rs

RfC -> RFC
2018-08-01 10:13:05 +02:00
Pietro Albini
341f882462
Rollup merge of #52870 - cramertj:unpin-futureobj, r=aturon
Implement Unpin for FutureObj and LocalFutureObj

cc @MajorBreakfast

r? @aturon
2018-08-01 10:12:57 +02:00
Pietro Albini
9e43ebda53
Rollup merge of #52822 - MajorBreakfast:fix-from-local-waker, r=cramertj
Fix From<LocalWaker>

This is a follow-up to https://github.com/rust-lang/rust/pull/52640

Fixes `From<LocalWaker>` which is affected by the same accidental drop bug (unless I'm totally mistaken)

r? @cramertj
2018-08-01 10:12:44 +02:00
Pietro Albini
acff794b68
Rollup merge of #52732 - SimonSapin:spring, r=Mark-Simulacrum
Remove unstable and deprecated APIs
2018-08-01 10:12:36 +02:00
pravic
830ac8c87f
Fix a typo in unsize.rs
RfC -> RFC
2018-07-31 16:28:50 +03:00
bors
ed8d14db99 Auto merge of #50267 - humanenginuity:master, r=alexcrichton
Implement inner deref for Option and Result

tracking issue: #50264
2018-07-31 11:20:16 +00:00
Артём Павлов [Artyom Pavlov]
2cab0deb97
don't duplicate impls 2018-07-31 04:07:11 +03:00
Taylor Cramer
cbbcecbee0 Implement Unpin for FutureObj and LocalFutureObj 2018-07-30 09:42:34 -07:00