Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility of generated code with forbid(future_incompatible) #282

Merged
merged 1 commit into from
Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/not_unpin-expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const _: () = {
//
// See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
// for details.
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
2 changes: 1 addition & 1 deletion examples/pinned_drop-expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const _: () = {
//
// See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
// for details.
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<'a, T>(this: &Struct<'a, T>) {
let _ = &this.was_dropped;
let _ = &this.field;
Expand Down
2 changes: 1 addition & 1 deletion examples/project_replace-expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const _: () = {
//
// See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
// for details.
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
4 changes: 2 additions & 2 deletions examples/struct-default-expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const _: () = {
// struct.
//
// Taking a reference to a packed field is unsafe, and applying
// #[deny(safe_packed_borrows)] makes sure that doing this without
// #[forbid(safe_packed_borrows)] makes sure that doing this without
// an 'unsafe' block (which we deliberately do not generate)
// is a hard error.
//
Expand All @@ -166,7 +166,7 @@ const _: () = {
// a much nicer error above.
//
// See https://github.com/taiki-e/pin-project/pull/34 for more details.
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
2 changes: 1 addition & 1 deletion examples/unsafe_unpin-expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const _: () = {
//
// See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
// for details.
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
6 changes: 3 additions & 3 deletions pin-project-internal/src/pin_project/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ impl<'a> Context<'a> {
// struct, we generate code like this:
//
// ```rust
// #[deny(safe_packed_borrows)]
// #[forbid(safe_packed_borrows)]
// fn assert_not_repr_packed(val: &MyStruct) {
// let _field1 = &val.field1;
// let _field2 = &val.field2;
Expand All @@ -1277,7 +1277,7 @@ impl<'a> Context<'a> {
// ```
//
// Taking a reference to a packed field is unsafe, and applying
// `#[deny(safe_packed_borrows)]` makes sure that doing this without
// `#[forbid(safe_packed_borrows)]` makes sure that doing this without
// an `unsafe` block (which we deliberately do not generate)
// is a hard error.
//
Expand Down Expand Up @@ -1318,7 +1318,7 @@ impl<'a> Context<'a> {
let (impl_generics, ty_generics, where_clause) = self.orig.generics.split_for_impl();
let ident = self.orig.ident;
Ok(quote! {
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed #impl_generics (this: &#ident #ty_generics) #where_clause {
#(let _ = #field_refs;)*
}
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/tests/expand/default-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/tests/expand/default-tuple_struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/tests/expand/naming-struct-all.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/tests/expand/naming-struct-mut.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/tests/expand/naming-struct-none.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/tests/expand/naming-struct-own.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/tests/expand/naming-struct-ref.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/tests/expand/not_unpin-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/tests/expand/pinned_drop-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const _: () = {
}
}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const _: () = {
}
}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/tests/expand/pub-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/tests/expand/pub-tuple_struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/tests/expand/unsafe_unpin-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const _: () = {
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[deny(safe_packed_borrows)]
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
Expand Down
5 changes: 4 additions & 1 deletion tests/lint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#![warn(future_incompatible, nonstandard_style, rust_2018_compatibility, rust_2018_idioms, unused)]
#![warn(nonstandard_style, rust_2018_compatibility, rust_2018_idioms, unused)]
// Note: This does not guarantee compatibility with `forbid(future_incompatible)` in the future.
// If rustc adds a new lint, we may not be able to keep this.
#![forbid(future_incompatible)]
#![allow(unknown_lints)] // for old compilers
#![warn(
absolute_paths_not_starting_with_crate,
Expand Down
2 changes: 1 addition & 1 deletion tests/repr_packed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![deny(safe_packed_borrows)]
#![forbid(safe_packed_borrows)]

use std::cell::Cell;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/pin_project/safe_packed_borrows.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(safe_packed_borrows)]
#![forbid(safe_packed_borrows)]

// Refs: https://github.com/rust-lang/rust/issues/46043

Expand Down
6 changes: 3 additions & 3 deletions tests/ui/pin_project/safe_packed_borrows.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ error: borrow of packed field is unsafe and requires unsafe function or block (e
| ^^^^
|
note: the lint level is defined here
--> $DIR/safe_packed_borrows.rs:1:9
--> $DIR/safe_packed_borrows.rs:1:11
|
1 | #![deny(safe_packed_borrows)]
| ^^^^^^^^^^^^^^^^^^^
1 | #![forbid(safe_packed_borrows)]
| ^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
= note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior
Expand Down