Upgrade rust/crates/pin-utils to 0.1.0 am: 55182b4e7f am: cb13f040a5 am: dbf7674bba
Change-Id: I5a9d12be3a8dcbfbe36a30858a28ef6fb5fddb67
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 9514de4..cd1e83b 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "9507af15b4fd0c3a78f067664be662844e409efe"
+ "sha1": "cddb4e490757830eff709310b32376420d7f5e93"
}
}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..ba0eb0d
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,41 @@
+language: rust
+rust:
+ - nightly
+sudo: false
+cache: cargo
+
+matrix:
+ include:
+ # This is the minimum Rust version supported by pin-utils.
+ # When updating this, the reminder to update the minimum required version in README.md.
+ - name: cargo test (minimum required version)
+ rust: 1.33.0
+
+ - name: cargo +stable test
+ rust: stable
+
+ - name: cargo test
+ os: osx
+
+ - name: cargo test
+ os: linux
+
+ - name: cargo clippy
+ rust: stable
+ script:
+ - rustup component add clippy
+ - cargo clippy -- -Dwarnings
+
+ - name: cargo doc
+ rust: nightly
+ script:
+ - RUSTDOCFLAGS=-Dwarnings cargo doc
+
+script:
+ - cargo build
+ - cargo test
+ - cargo test --release
+
+notifications:
+ email:
+ on_success: never
diff --git a/Cargo.toml b/Cargo.toml
index 7992a83..5e2f779 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,7 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g. crates.io) dependencies
+# to registry (e.g., crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
@@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "pin-utils"
-version = "0.1.0-alpha.4"
+version = "0.1.0"
authors = ["Josef Brandl <mail@josefbrandl.de>"]
description = "Utilities for pinning\n"
documentation = "https://docs.rs/pin-utils"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index f7687a9..4c0617d 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,7 +1,7 @@
[package]
name = "pin-utils"
edition = "2018"
-version = "0.1.0-alpha.4"
+version = "0.1.0"
authors = ["Josef Brandl <mail@josefbrandl.de>"]
license = "MIT OR Apache-2.0"
readme = "README.md"
diff --git a/METADATA b/METADATA
index c54034e..7f22588 100644
--- a/METADATA
+++ b/METADATA
@@ -1,7 +1,5 @@
name: "pin-utils"
-description:
- "Utilities for pinning"
-
+description: "Utilities for pinning"
third_party {
url {
type: HOMEPAGE
@@ -11,7 +9,11 @@
type: GIT
value: "https://github.com/rust-lang-nursery/pin-utils"
}
- version: "0.1.0-alpha.4"
- last_upgrade_date { year: 2020 month: 3 day: 17 }
+ version: "0.1.0"
license_type: NOTICE
+ last_upgrade_date {
+ year: 2020
+ month: 4
+ day: 22
+ }
}
diff --git a/README.md b/README.md
index b53e195..93fdeb6 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
Utilities for pinning
-[![Build Status](https://travis-ci.org/rust-lang-nursery/pin-utils.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/pin-utils)
+[![Build Status](https://travis-ci.com/rust-lang-nursery/pin-utils.svg?branch=master)](https://travis-ci.com/rust-lang-nursery/pin-utils)
[![Crates.io](https://img.shields.io/crates/v/pin-utils.svg)](https://crates.io/crates/pin-utils)
[Documentation](https://docs.rs/pin-utils)
@@ -13,7 +13,7 @@
```toml
[dependencies]
-pin-utils = "0.1.0-alpha.3"
+pin-utils = "0.1.0-alpha.4"
```
Now, you can use it:
@@ -22,6 +22,8 @@
use pin_utils::pin_mut; // And more...
```
+The current version of pin-utils requires Rust 1.33 or later.
+
# License
This project is licensed under either of
diff --git a/src/lib.rs b/src/lib.rs
index 90434b5..6198e98 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,13 +4,14 @@
#![warn(missing_docs, missing_debug_implementations)]
#![deny(bare_trait_objects)]
#![allow(unknown_lints)]
-
-#![doc(html_root_url = "https://docs.rs/pin-utils/0.1.0-alpha.2")]
+#![doc(html_root_url = "https://docs.rs/pin-utils/0.1.0")]
#[doc(hidden)]
pub mod core_reexport {
pub use core::*;
}
-#[macro_use] mod stack_pin;
-#[macro_use] mod projection;
+#[macro_use]
+mod stack_pin;
+#[macro_use]
+mod projection;
diff --git a/src/projection.rs b/src/projection.rs
index 8abc99b..6af90c5 100644
--- a/src/projection.rs
+++ b/src/projection.rs
@@ -1,5 +1,7 @@
/// A pinned projection of a struct field.
///
+/// # Safety
+///
/// To make using this macro safe, three things need to be ensured:
/// - If the struct implements [`Drop`], the [`drop`] method is not allowed to
/// move the value of the field.
@@ -7,7 +9,9 @@
/// The struct can only implement [`Unpin`] if the field's type is [`Unpin`].
/// - The struct must not be `#[repr(packed)]`.
///
-/// ```
+/// # Example
+///
+/// ```rust
/// use pin_utils::unsafe_pinned;
/// use std::marker::Unpin;
/// use std::pin::Pin;
@@ -27,7 +31,7 @@
/// impl<T: Unpin> Unpin for Foo<T> {} // Conditional Unpin impl
/// ```
///
-/// Note that borrowing the field multiple times requires using `.as_mut()` to
+/// Note: borrowing the field multiple times requires using `.as_mut()` to
/// avoid consuming the `Pin`.
///
/// [`Unpin`]: core::marker::Unpin
@@ -35,6 +39,7 @@
#[macro_export]
macro_rules! unsafe_pinned {
($f:tt: $t:ty) => (
+ #[allow(unsafe_code)]
fn $f<'__a>(
self: $crate::core_reexport::pin::Pin<&'__a mut Self>
) -> $crate::core_reexport::pin::Pin<&'__a mut $t> {
@@ -49,15 +54,16 @@
/// An unpinned projection of a struct field.
///
+/// # Safety
+///
/// This macro is unsafe because it creates a method that returns a normal
/// non-pin reference to the struct field. It is up to the programmer to ensure
/// that the contained value can be considered not pinned in the current
/// context.
///
-/// Note that borrowing the field multiple times requires using `.as_mut()` to
-/// avoid consuming the `Pin`.
+/// # Example
///
-/// ```
+/// ```rust
/// use pin_utils::unsafe_unpinned;
/// use std::pin::Pin;
///
@@ -74,9 +80,15 @@
/// }
/// }
/// ```
+///
+/// Note: borrowing the field multiple times requires using `.as_mut()` to
+/// avoid consuming the [`Pin`].
+///
+/// [`Pin`]: core::pin::Pin
#[macro_export]
macro_rules! unsafe_unpinned {
($f:tt: $t:ty) => (
+ #[allow(unsafe_code)]
fn $f<'__a>(
self: $crate::core_reexport::pin::Pin<&'__a mut Self>
) -> &'__a mut $t {
diff --git a/src/stack_pin.rs b/src/stack_pin.rs
index 997a5b9..8a1ed2c 100644
--- a/src/stack_pin.rs
+++ b/src/stack_pin.rs
@@ -1,6 +1,8 @@
/// Pins a value on the stack.
///
-/// ```
+/// # Example
+///
+/// ```rust
/// # use pin_utils::pin_mut;
/// # use core::pin::Pin;
/// # struct Foo {}
@@ -10,7 +12,7 @@
/// ```
#[macro_export]
macro_rules! pin_mut {
- ($($x:ident),*) => { $(
+ ($($x:ident),* $(,)?) => { $(
// Move the value to ensure that it is owned
let mut $x = $x;
// Shadow the original binding so that it can't be directly accessed
diff --git a/tests/stack_pin.rs b/tests/stack_pin.rs
index 0708a7d..4b6758d 100644
--- a/tests/stack_pin.rs
+++ b/tests/stack_pin.rs
@@ -1,3 +1,5 @@
+#![forbid(unsafe_code)] // pin_mut! is completely safe.
+
use pin_utils::pin_mut;
use core::pin::Pin;
@@ -7,4 +9,13 @@
let foo = Foo {};
pin_mut!(foo);
let _: Pin<&mut Foo> = foo;
+
+ let bar = Foo {};
+ let baz = Foo {};
+ pin_mut!(
+ bar,
+ baz,
+ );
+ let _: Pin<&mut Foo> = bar;
+ let _: Pin<&mut Foo> = baz;
}