Skip to content

std: Stabilize APIs for the 1.10 release - #33699

Merged
bors merged 1 commit into
rust-lang:masterfrom
alexcrichton:stabilize-1.10
May 26, 2016
Merged

std: Stabilize APIs for the 1.10 release#33699
bors merged 1 commit into
rust-lang:masterfrom
alexcrichton:stabilize-1.10

Conversation

@alexcrichton

@alexcrichtonalexcrichton commented May 17, 2016

Copy link
Copy Markdown
Member

This commit applies the FCP decisions made by the libs team for the 1.10 cycle,
including both new stabilizations and deprecations. Specifically, the list of
APIs is:

Stabilized:

  • os::windows::fs::OpenOptionsExt::access_mode
  • os::windows::fs::OpenOptionsExt::share_mode
  • os::windows::fs::OpenOptionsExt::custom_flags
  • os::windows::fs::OpenOptionsExt::attributes
  • os::windows::fs::OpenOptionsExt::security_qos_flags
  • os::unix::fs::OpenOptionsExt::custom_flags
  • sync::Weak::new
  • Default for sync::Weak
  • panic::set_hook
  • panic::take_hook
  • panic::PanicInfo
  • panic::PanicInfo::payload
  • panic::PanicInfo::location
  • panic::Location
  • panic::Location::file
  • panic::Location::line
  • ffi::CStr::from_bytes_with_nul
  • ffi::CStr::from_bytes_with_nul_unchecked
  • ffi::FromBytesWithNulError
  • fs::Metadata::modified
  • fs::Metadata::accessed
  • fs::Metadata::created
  • sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange
  • sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak
  • collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key
  • os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}
  • SocketAddr::is_unnamed
  • SocketAddr::as_pathname
  • UnixStream::connect
  • UnixStream::pair
  • UnixStream::try_clone
  • UnixStream::local_addr
  • UnixStream::peer_addr
  • UnixStream::set_read_timeout
  • UnixStream::set_write_timeout
  • UnixStream::read_timeout
  • UnixStream::write_Timeout
  • UnixStream::set_nonblocking
  • UnixStream::take_error
  • UnixStream::shutdown
  • Read/Write/RawFd impls for UnixStream
  • UnixListener::bind
  • UnixListener::accept
  • UnixListener::try_clone
  • UnixListener::local_addr
  • UnixListener::set_nonblocking
  • UnixListener::take_error
  • UnixListener::incoming
  • RawFd impls for UnixListener
  • UnixDatagram::bind
  • UnixDatagram::unbound
  • UnixDatagram::pair
  • UnixDatagram::connect
  • UnixDatagram::try_clone
  • UnixDatagram::local_addr
  • UnixDatagram::peer_addr
  • UnixDatagram::recv_from
  • UnixDatagram::recv
  • UnixDatagram::send_to
  • UnixDatagram::send
  • UnixDatagram::set_read_timeout
  • UnixDatagram::set_write_timeout
  • UnixDatagram::read_timeout
  • UnixDatagram::write_timeout
  • UnixDatagram::set_nonblocking
  • UnixDatagram::take_error
  • UnixDatagram::shutdown
  • RawFd impls for UnixDatagram
  • {BTree,Hash}Map::values_mut
  • <[_]>::binary_search_by_key

Deprecated:

  • StaticCondvar - this, and all other static synchronization primitives
    below, are usable today through the lazy-static crate on
    stable Rust today. Additionally, we'd like the non-static
    versions to be directly usable in a static context one day,
    so they're unlikely to be the final forms of the APIs in any
    case.
  • CONDVAR_INIT
  • StaticMutex
  • MUTEX_INIT
  • StaticRwLock
  • RWLOCK_INIT
  • iter::Peekable::is_empty

Closes#27717
Closes#27720
Closes#30014
Closes#30425
Closes#30449
Closes#31190
Closes#31399
Closes#31767
Closes#32111
Closes#32281
Closes#32312
Closes#32551
Closes#33018

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton

Copy link
Copy Markdown
MemberAuthor

Still working through the tests, but this should have all the real meat.

r? @aturon
cc @rust-lang/libs

@rust-highfiverust-highfive assigned aturon and unassigned brsonMay 17, 2016
Comment threadsrc/libstd/ffi/mod.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the feature and the version here correct?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@alexcrichton
alexcrichtonforce-pushed the stabilize-1.10 branch 3 times, most recently from 2e3600c to 7c03658CompareMay 18, 2016 23:02
@alexcrichton

Copy link
Copy Markdown
MemberAuthor

@SimonSapinbrings up that write_utf{8,16} could possibly panic instead of returning a result.

@sfackler

Copy link
Copy Markdown
Member

I think I like that approach given that there's an obvious and reasonable upper bound on the buffer size.

@alexcrichton

Copy link
Copy Markdown
MemberAuthor

I personally feel that it's inconsistent with how we handle encoding/decoding everywhere else, which is to use a result instead of panicking

@SimonSapin

Copy link
Copy Markdown
Contributor

@alexcrichton what APIs and errors are you thinking of, specifically? Providing a buffer smaller than four bytes or two 16-bit units is a different kind of error than, for example, the input containing ill-formed byte sequences. It’s easy to use something like [u8; 4] or vec.reserve(4), while many programs deal with unpredictable input.

And, as I argued in #27784 (comment), would callers ever do anything other than .unwrap() that Result?

@alexcrichton

Copy link
Copy Markdown
MemberAuthor

The major examples are str::from_utf8 and String::from_utf16. I could imagine that callers may not be moving into a stack-local buffer (but perhaps a Vec) and they want to optimize a path where something is one byte or less (or something like that).

@SimonSapin

Copy link
Copy Markdown
Contributor

These examples don’t take a caller-provided buffer, so the "buffer too short" kind of error doesn’t happen there.

If the caller of char::write_utf8 / char::write_utf16 wants an exact size rather than an upper bound, they can use char::len_utf8 / char::len_utf16.

@alexcrichton

Copy link
Copy Markdown
MemberAuthor

Yes they're only analogous in the sense that they don't panic, they return results on encoding/decoding operations. The buffer may not always be controlled by the caller, but some utility function would be given a buffer from elsewhere in which case it'd just always have to perform this validation. Essentially you will 100% of the time need this check for length unless you're calling with a buffer you created yourself, and that's probably not 100% of use cases.

@SimonSapin

Copy link
Copy Markdown
Contributor

Outside of tests, rust-lang/rust currently contains 9 uses of encode_utf8 that would be replaced with write_utf8:

  • 3 (in collections::string) extend a Vec<u8>, so they could use either vec.reserve(4) or vec.reserve(c.len_utf8()).
  • 6 (in core::fmt, serialize::json, and std::sys::common::wtf8) then use str::from_utf8_unchecked, they could use a [u8; 4] buffer.

100% would statically ensure they provide a large enough buffer to write_utf8.

(I found zero usage in Servo and its dependencies that I’ve ever checked out. When #[unstable] was introduced we replaced them with write! into a [u8; 4] buffer.)

I really don’t see a scenario where "some utility function given a buffer from elsewhere" would be useful.

@aturon

Copy link
Copy Markdown
Contributor

I agree with @SimonSapin here, a too-short buffer seems reasonable to treat as a contract violation.

@alexcrichton

Copy link
Copy Markdown
MemberAuthor

I'd be pretty uncomfortable stabilizing an API with a brand new name, new semantics, and a new return type all at once. This may also miss the beta branch now and need to be backported. Shall we just leave it out for another round?

@alexcrichton

Copy link
Copy Markdown
MemberAuthor

Ok, I've backed out those API additions, re-r? @aturon

@aturon

Copy link
Copy Markdown
Contributor

@alexcrichton I've reviewed the rest of the PR (LGTM), but I don't see the updates backing out these recent additions.

@alexcrichton

Copy link
Copy Markdown
MemberAuthor

@bors: r=aturon 91e8b4c57eafc0b4dc577bfab6a2685e635c9bed

@bors

bors commented May 23, 2016

Copy link
Copy Markdown
Collaborator

🙀 91e8b4c57eafc0b4dc577bfab6a2685e635c9bed is not a valid commit SHA. Please try again with 7c03658.

@alexcrichton

Copy link
Copy Markdown
MemberAuthor

@bors: r=aturon 91e8b4c57eafc0b4dc577bfab6a2685e635c9bed

@bors

bors commented May 23, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 91e8b4c with merge b07d438...

@bors

bors commented May 23, 2016

Copy link
Copy Markdown
Collaborator

💔 Test failed - auto-mac-64-opt

@alexcrichton

Copy link
Copy Markdown
MemberAuthor

@bors: r=aturon

@bors

bors commented May 24, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit 04eff6c has been approved by aturon

@bors

bors commented May 24, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 04eff6c with merge 05765aa...

@bors

bors commented May 24, 2016

Copy link
Copy Markdown
Collaborator

💔 Test failed - auto-win-gnu-32-opt-rustbuild

This commit applies the FCP decisions made by the libs team for the 1.10 cycle,
including both new stabilizations and deprecations. Specifically, the list of
APIs is:
Stabilized:
* `os::windows::fs::OpenOptionsExt::access_mode`
* `os::windows::fs::OpenOptionsExt::share_mode`
* `os::windows::fs::OpenOptionsExt::custom_flags`
* `os::windows::fs::OpenOptionsExt::attributes`
* `os::windows::fs::OpenOptionsExt::security_qos_flags`
* `os::unix::fs::OpenOptionsExt::custom_flags`
* `sync::Weak::new`
* `Default for sync::Weak`
* `panic::set_hook`
* `panic::take_hook`
* `panic::PanicInfo`
* `panic::PanicInfo::payload`
* `panic::PanicInfo::location`
* `panic::Location`
* `panic::Location::file`
* `panic::Location::line`
* `ffi::CStr::from_bytes_with_nul`
* `ffi::CStr::from_bytes_with_nul_unchecked`
* `ffi::FromBytesWithNulError`
* `fs::Metadata::modified`
* `fs::Metadata::accessed`
* `fs::Metadata::created`
* `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange`
* `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak`
* `collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key`
* `os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}`
* `SocketAddr::is_unnamed`
* `SocketAddr::as_pathname`
* `UnixStream::connect`
* `UnixStream::pair`
* `UnixStream::try_clone`
* `UnixStream::local_addr`
* `UnixStream::peer_addr`
* `UnixStream::set_read_timeout`
* `UnixStream::set_write_timeout`
* `UnixStream::read_timeout`
* `UnixStream::write_Timeout`
* `UnixStream::set_nonblocking`
* `UnixStream::take_error`
* `UnixStream::shutdown`
* Read/Write/RawFd impls for `UnixStream`
* `UnixListener::bind`
* `UnixListener::accept`
* `UnixListener::try_clone`
* `UnixListener::local_addr`
* `UnixListener::set_nonblocking`
* `UnixListener::take_error`
* `UnixListener::incoming`
* RawFd impls for `UnixListener`
* `UnixDatagram::bind`
* `UnixDatagram::unbound`
* `UnixDatagram::pair`
* `UnixDatagram::connect`
* `UnixDatagram::try_clone`
* `UnixDatagram::local_addr`
* `UnixDatagram::peer_addr`
* `UnixDatagram::recv_from`
* `UnixDatagram::recv`
* `UnixDatagram::send_to`
* `UnixDatagram::send`
* `UnixDatagram::set_read_timeout`
* `UnixDatagram::set_write_timeout`
* `UnixDatagram::read_timeout`
* `UnixDatagram::write_timeout`
* `UnixDatagram::set_nonblocking`
* `UnixDatagram::take_error`
* `UnixDatagram::shutdown`
* RawFd impls for `UnixDatagram`
* `{BTree,Hash}Map::values_mut`
* `<[_]>::binary_search_by_key`
Deprecated:
* `StaticCondvar` - this, and all other static synchronization primitives
below, are usable today through the lazy-static crate on
stable Rust today. Additionally, we'd like the non-static
versions to be directly usable in a static context one day,
so they're unlikely to be the final forms of the APIs in any
case.
* `CONDVAR_INIT`
* `StaticMutex`
* `MUTEX_INIT`
* `StaticRwLock`
* `RWLOCK_INIT`
* `iter::Peekable::is_empty`
Closesrust-lang#27717Closesrust-lang#27720
cc rust-lang#27784 (but encode methods still exist)
Closesrust-lang#30014Closesrust-lang#30425Closesrust-lang#30449Closesrust-lang#31190Closesrust-lang#31399Closesrust-lang#31767Closesrust-lang#32111Closesrust-lang#32281Closesrust-lang#32312Closesrust-lang#32551Closesrust-lang#33018
@alexcrichton

Copy link
Copy Markdown
MemberAuthor

@bors: r=aturon

@bors

bors commented May 24, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit cae91d7 has been approved by aturon

@bors

bors commented May 25, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit cae91d7 with merge 07399eb...

@bors

bors commented May 25, 2016

Copy link
Copy Markdown
Collaborator

💔 Test failed - auto-win-gnu-32-opt-rustbuild

@alexcrichton

Copy link
Copy Markdown
MemberAuthor

@bors: retry

Praying that's spurious, I'll open an issue if I see it again

@bors

bors commented May 25, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit cae91d7 with merge 991b0fa...

@bors

bors commented May 25, 2016

Copy link
Copy Markdown
Collaborator

💔 Test failed - auto-win-msvc-64-opt

@alexcrichton

Copy link
Copy Markdown
MemberAuthor

@bors

bors commented May 26, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit cae91d7 with merge d5759a3...

bors added a commit that referenced this pull request May 26, 2016
std: Stabilize APIs for the 1.10 release
This commit applies the FCP decisions made by the libs team for the 1.10 cycle,
including both new stabilizations and deprecations. Specifically, the list of
APIs is:
Stabilized:
* `os::windows::fs::OpenOptionsExt::access_mode`
* `os::windows::fs::OpenOptionsExt::share_mode`
* `os::windows::fs::OpenOptionsExt::custom_flags`
* `os::windows::fs::OpenOptionsExt::attributes`
* `os::windows::fs::OpenOptionsExt::security_qos_flags`
* `os::unix::fs::OpenOptionsExt::custom_flags`
* `sync::Weak::new`
* `Default for sync::Weak`
* `panic::set_hook`
* `panic::take_hook`
* `panic::PanicInfo`
* `panic::PanicInfo::payload`
* `panic::PanicInfo::location`
* `panic::Location`
* `panic::Location::file`
* `panic::Location::line`
* `ffi::CStr::from_bytes_with_nul`
* `ffi::CStr::from_bytes_with_nul_unchecked`
* `ffi::FromBytesWithNulError`
* `fs::Metadata::modified`
* `fs::Metadata::accessed`
* `fs::Metadata::created`
* `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange`
* `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak`
* `collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key`
* `os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}`
* `SocketAddr::is_unnamed`
* `SocketAddr::as_pathname`
* `UnixStream::connect`
* `UnixStream::pair`
* `UnixStream::try_clone`
* `UnixStream::local_addr`
* `UnixStream::peer_addr`
* `UnixStream::set_read_timeout`
* `UnixStream::set_write_timeout`
* `UnixStream::read_timeout`
* `UnixStream::write_Timeout`
* `UnixStream::set_nonblocking`
* `UnixStream::take_error`
* `UnixStream::shutdown`
* Read/Write/RawFd impls for `UnixStream`
* `UnixListener::bind`
* `UnixListener::accept`
* `UnixListener::try_clone`
* `UnixListener::local_addr`
* `UnixListener::set_nonblocking`
* `UnixListener::take_error`
* `UnixListener::incoming`
* RawFd impls for `UnixListener`
* `UnixDatagram::bind`
* `UnixDatagram::unbound`
* `UnixDatagram::pair`
* `UnixDatagram::connect`
* `UnixDatagram::try_clone`
* `UnixDatagram::local_addr`
* `UnixDatagram::peer_addr`
* `UnixDatagram::recv_from`
* `UnixDatagram::recv`
* `UnixDatagram::send_to`
* `UnixDatagram::send`
* `UnixDatagram::set_read_timeout`
* `UnixDatagram::set_write_timeout`
* `UnixDatagram::read_timeout`
* `UnixDatagram::write_timeout`
* `UnixDatagram::set_nonblocking`
* `UnixDatagram::take_error`
* `UnixDatagram::shutdown`
* RawFd impls for `UnixDatagram`
* `{BTree,Hash}Map::values_mut`
* `<[_]>::binary_search_by_key`
Deprecated:
* `StaticCondvar` - this, and all other static synchronization primitives
below, are usable today through the lazy-static crate on
stable Rust today. Additionally, we'd like the non-static
versions to be directly usable in a static context one day,
so they're unlikely to be the final forms of the APIs in any
case.
* `CONDVAR_INIT`
* `StaticMutex`
* `MUTEX_INIT`
* `StaticRwLock`
* `RWLOCK_INIT`
* `iter::Peekable::is_empty`
Closes#27717Closes#27720Closes#30014Closes#30425Closes#30449Closes#31190Closes#31399Closes#31767Closes#32111Closes#32281Closes#32312Closes#32551Closes#33018
@bors
bors merged commit cae91d7 into rust-lang:masterMay 26, 2016
This was referenced May 26, 2016
@alexcrichton
alexcrichton deleted the stabilize-1.10 branch May 26, 2016 16:22
@alexcrichtonalexcrichton added beta-nominated Nominated for backporting to the compiler in the beta channel. beta-accepted Accepted for backporting to the compiler in the beta channel. labels May 26, 2016
@alexcrichton

Copy link
Copy Markdown
MemberAuthor

Tagging beta nominated/accepted to ensure we backport

@alexcrichtonalexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jun 20, 2016
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-acceptedAccepted for backporting to the compiler in the beta channel.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@alexcrichton@rust-highfive@sfackler@SimonSapin@aturon@bors@futile@brson