Mazdak Farrokhzad
379c380a60
libstd: deny(elided_lifetimes_in_paths)
2019-03-31 12:56:51 +02:00
Scott McMurray
df4ea90b39
Use lifetime contravariance to elide more lifetimes in core+alloc+std
2019-03-09 19:10:28 -08:00
Taiki Endo
93b6d9e086
libstd => 2018
2019-02-28 04:06:15 +09:00
kennytm
e3a8f7db47
Rollup merge of #58553 - scottmcm:more-ihle, r=Centril
...
Use more impl header lifetime elision
Inspired by seeing explicit lifetimes on these two:
- https://doc.rust-lang.org/nightly/std/slice/struct.Iter.html#impl-FusedIterator
- https://doc.rust-lang.org/nightly/std/primitive.u32.html#impl-Not
And a follow-up to https://github.com/rust-lang/rust/pull/54687 , that started using IHLE in libcore.
Most of the changes in here fall into two big categories:
- Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop`, `Debug`, and `Clone`)
- Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`)
I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations [where the flipped one cannot elide the lifetime](https://internals.rust-lang.org/t/impl-type-parameter-aliases/9403/2?u=scottmcm ).
I also removed two lifetimes that turned out to be completely unused; see https://github.com/rust-lang/rust/issues/41960#issuecomment-464557423
2019-02-20 11:59:10 +08:00
Scott McMurray
3bea2ca49d
Use more impl header lifetime elision
...
There are two big categories of changes in here
- Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop` & `Debug`)
- Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`)
I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations where the flipped one cannot elide the lifetime.
2019-02-17 19:42:36 -08:00
Alexander Regueiro
99ed06eb88
libs: doc comments
2019-02-10 23:57:25 +00:00
Mark Rousskov
2a663555dd
Remove licenses
2018-12-25 21:08:33 -07:00
Alexander Regueiro
ee89c088b0
Various minor/cosmetic improvements to code
2018-12-07 23:53:34 +00:00
ljedrz
8c4129cd9a
cleanup: remove static lifetimes from consts in libstd
2018-12-04 10:21:42 +01:00
bors
65204a97d4
Auto merge of #55278 - Centril:constification-1, r=alexcrichton
...
Minor standard library constification
This PR makes some bits of the standard library into `const fn`s.
I've tried to be as aggressive as I possibly could in the constification.
The list is rather small due to how restrictive `const fn` is at the moment.
r? @oli-obk cc @rust-lang/libs
Stable public APIs affected:
+ [x] `Cell::as_ptr`
+ [x] `UnsafeCell::get`
+ [x] `char::is_ascii`
+ [x] `iter::empty`
+ [x] `ManuallyDrop::{new, into_inner}`
+ [x] `RangeInclusive::{start, end}`
+ [x] `NonNull::as_ptr`
+ [x] `{[T], str}::as_ptr`
+ [x] `Duration::{as_secs, subsec_millis, subsec_micros, subsec_nanos}`
+ [x] `CStr::as_ptr`
+ [x] `Ipv4Addr::is_unspecified`
+ [x] `Ipv6Addr::new`
+ [x] `Ipv6Addr::octets`
Unstable public APIs affected:
+ [x] `Duration::{as_millis, as_micros, as_nanos, as_float_secs}`
+ [x] `Wrapping::{count_ones, count_zeros, trailing_zeros, rotate_left, rotate_right, swap_bytes, reverse_bits, from_be, from_le, to_be, to_le, leading_zeros, is_positive, is_negative, leading_zeros}`
+ [x] `core::convert::identity`
--------------------------
## Removed from list in first pass:
Stable public APIs affected:
+ [ ] `BTree{Map, Set}::{len, is_empty}`
+ [ ] `VecDeque::is_empty`
+ [ ] `String::{is_empty, len}`
+ [ ] `FromUtf8Error::utf8_error`
+ [ ] `Vec<T>::{is_empty, len}`
+ [ ] `Layout::size`
+ [ ] `DecodeUtf16Error::unpaired_surrogate`
+ [ ] `core::fmt::{fill, width, precision, sign_plus, sign_minus, alternate, sign_aware_zero_pad}`
+ [ ] `panic::Location::{file, line, column}`
+ [ ] `{ChunksExact, RChunksExact}::remainder`
+ [ ] `Utf8Error::valid_up_to`
+ [ ] `VacantEntry::key`
+ [ ] `NulError::nul_position`
+ [ ] `IntoStringError::utf8_error`
+ [ ] `IntoInnerError::error`
+ [ ] `io::Chain::get_ref`
+ [ ] `io::Take::{limit, get_ref}`
+ [ ] `SocketAddrV6::{flowinfo, scope_id}`
+ [ ] `PrefixComponent::{kind, as_os_str}`
+ [ ] `Path::{ancestors, display}`
+ [ ] `WaitTimeoutResult::timed_out`
+ [ ] `Receiver::{iter, try_iter}`
+ [ ] `thread::JoinHandle::thread`
+ [ ] `SystemTimeError::duration`
Unstable public APIs affected:
+ [ ] `core::fmt::Arguments::new_v1`
+ [ ] `core::fmt::Arguments::new_v1_formatted`
+ [ ] `Pin::{get_ref, into_ref}`
+ [ ] `Utf8Lossy::chunks`
+ [ ] `LocalWaker::as_waker`
+ [ ] `panic::PanicInfo::{internal_constructor, message, location}`
+ [ ] `panic::Location::{internal_constructor }`
## Removed from list in 2nd pass:
Stable public APIs affected:
+ [ ] `LinkedList::{new, iter, is_empty, len}`
+ [ ] `mem::forget`
+ [ ] `Cursor::{new, get_ref, position}`
+ [ ] `io::{empty, repeat, sink}`
+ [ ] `PoisonError::new`
+ [ ] `thread::Builder::new`
+ [ ] `process::Stdio::{piped, inherit, null}`
Unstable public APIs affected:
+ [ ] `io::Initializer::{zeroing, should_initialize}`
2018-11-12 18:54:11 +00:00
Bruce Mitchener
9b4d68e53b
Fix documentation typos.
2018-11-10 19:31:49 +07:00
Mazdak Farrokhzad
e15c62d61f
revert making internal APIs const fn.
2018-11-10 01:10:07 +01:00
Mazdak Farrokhzad
d1d2aa22c0
reduce list to functions callable in const ctx.
2018-11-10 01:10:07 +01:00
Mazdak Farrokhzad
f65b630d33
constify parts of libstd.
2018-11-10 01:10:07 +01:00
Austin Bonander
092bf2b500
make CStr::from_bytes_with_nul_unchecked() a const fn
...
closes #54678
2018-10-02 04:25:40 -07:00
kennytm
2882119feb
Rollup merge of #53976 - GuillaumeGomez:expect-world, r=steveklabnik
...
Replace unwrap calls in example by expect
Part of #51668 .
r? @steveklabnik
2018-09-14 00:41:34 +08:00
Simonas Kazlauskas
0ec351d528
&CStr, not CStr, is the counterpart of &str
2018-09-08 20:01:41 +03:00
Guillaume Gomez
72ba0ba3d7
Replace unwrap calls in example by expect
2018-09-05 23:54:07 +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
Pietro Albini
b7ee110ea2
Rollup merge of #52340 - cypher:document-from-trait-in-ffi, r=steveklabnik
...
Document From trait implementations for OsStr, OsString, CString, and CStr
As part of issue #51430 (cc @skade).
The allocation and copy claims should be double-checked.
r? @steveklabnik
2018-08-01 10:12:32 +02:00
Tatsuyuki Ishi
4f1d4e4db6
Merge remote-tracking branches 'ljedrz/dyn_libcore', 'ljedrz/dyn_libstd' and 'ljedrz/dyn_libterm' into dyn-rollup
2018-07-25 10:25:02 +09:00
Markus Wein
ed5edcb318
Seperate summaries from rest of the comment
2018-07-23 15:38:15 +02:00
Markus Wein
b81ee0b370
Document From conversions for CString and CStr
2018-07-16 20:37:28 +02:00
ljedrz
560d8079ec
Deny bare trait objects in src/libstd.
2018-07-10 20:35:36 +02:00
Matt Brubeck
cdff2f3b30
impl Clone for Box<CStr>, Box<OsStr>, Box<Path>
...
Implements #51908 .
2018-07-06 12:57:47 -07:00
kennytm
8366780164
Rollup merge of #50170 - burtonageo:more_cow_from, r=alexcrichton
...
Implement From for more types on Cow
This is basically https://github.com/rust-lang/rust/pull/48191 , except that it should be implemented in a way that doesn't break third party crates.
2018-05-17 05:22:07 +08:00
George Burton
7c0f664f15
Fix typo
2018-05-09 07:32:50 +01:00
George Burton
17e262880c
Update features to 1.28.0
2018-05-09 07:23:02 +01:00
bors
357bf00f1c
Auto merge of #48925 - zackmdavis:fn_must_stabilize, r=nikomatsakis
...
stabilize `#[must_use]` for functions and must-use comparison operators (RFC 1940)
r? @nikomatsakis
2018-04-30 22:02:33 +00:00
Eric Huss
269d279094
Fix some broken links in docs.
2018-04-29 10:15:40 -07:00
Zack M. Davis
3dbdccc6a9
stabilize #[must_use] for functions and must-use operators
...
This is in the matter of RFC 1940 and tracking issue #43302 .
2018-04-28 20:32:49 -07:00
George Burton
f3e858aae7
Update the stable attributes to use the current nightly version number
2018-04-27 20:46:06 +01:00
George Burton
ea8131de53
Add cstring_from_cow_cstr and osstring_from_cow_osstr
2018-04-27 20:27:38 +01:00
George Burton
1133a149f1
Implement From for more types on Cow
2018-04-22 22:57:52 +01:00
Guillaume Gomez
5344b07add
Add new warning for CStr::from_ptr
2018-02-24 16:50:44 +01:00
Corey Farwell
872c782a55
Mark doc examples w/ extern blocks as ignore.
...
Fixes https://github.com/rust-lang/rust/issues/48218 .
2018-02-18 10:27:45 -05:00
Tobias Bucher
6c86da288a
Make wording around 0-cost casts more precise
2018-01-27 17:54:01 +01:00
Oliver Middleton
a8d107be25
Correct a few stability attributes
2017-12-27 14:11:05 +00:00
Murarth
1bbc776446
Implement Rc/Arc conversions for string-like types
...
Provides the following conversion implementations:
* `From<`{`CString`,`&CStr`}`>` for {`Arc`,`Rc`}`<CStr>`
* `From<`{`OsString`,`&OsStr`}`>` for {`Arc`,`Rc`}`<OsStr>`
* `From<`{`PathBuf`,`&Path`}`>` for {`Arc`,`Rc`}`<Path>`
2017-11-25 22:13:11 -07:00
Alex Crichton
5c3fe111d4
std: Avoid use of libc in portable modules
...
This commit removes usage of the `libc` crate in "portable" modules like
those at the top level and `sys_common`. Instead common types like `*mut
u8` or `u32` are used instead of `*mut c_void` or `c_int` as well as
switching to platform-specific functions like `sys::strlen` instead of
`libc::strlen`.
2017-11-09 07:56:44 -08:00
kennytm
6c43bd3c83
Rollup merge of #44855 - federicomenaquintero:master, r=steveklabnik
...
Improved docs for CStr, CString, OsStr, OsString
This expands the documentation for those structs and their corresponding traits, per https://github.com/rust-lang/rust/issues/29354
2017-10-13 23:37:51 +08:00
Federico Mena Quintero
026451093d
ffi/c_str.rs: Use only one space after a period ending a sentence
2017-10-11 17:53:13 -05:00
Federico Mena Quintero
a9a4ce6dcc
ffi/c_str.rs: Fix method/function confusion
...
Per https://github.com/rust-lang/rust/pull/44855#discussion_r144049179
2017-10-11 17:52:39 -05:00
Federico Mena Quintero
d5bdfbced6
ffi/c_str.rs: Make all descriptions have a single-sentence summary at the beginning
...
Per https://github.com/rust-lang/rust/pull/44855#discussion_r144048837
and subsequent ones.
2017-10-11 17:51:37 -05:00
Federico Mena Quintero
9854e836a3
Remove the implication that CString contains UTF-8 data.
2017-10-02 13:53:50 -05:00
Nikolai Vazquez
755fd29b60
Fix mutability error in CString::from_raw
2017-09-28 07:56:35 -04:00
Nikolai Vazquez
6d14512fd9
Remove mem::transmute used in CStr conversions
2017-09-28 00:51:38 -04:00
Federico Mena Quintero
3c5e18f322
Point from the error structs back to the method that created them, like in iterators
2017-09-25 13:51:48 -05:00
Federico Mena Quintero
2cb2a0606a
Overhaul the ffi::CStr documentation.
2017-09-25 13:51:48 -05:00
Federico Mena Quintero
8da694a421
Overhaul the ffi::CString docs
...
Explain the struct's reason for being, and its most common usage
patterns. Add a bunch of links.
Clarify the method docs a bit.
Part of https://github.com/rust-lang/rust/issues/29354
2017-09-25 13:51:48 -05:00