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

Check interoperability with all rustc lints allowed by default #240

Merged
merged 2 commits into from
Jun 4, 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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ This project adheres to [Semantic Versioning](https://semver.org).

## [Unreleased]

* Suppress `unreachable_pub` lint in generated code.

## [0.4.19] - 2020-06-04

* [Fix unused_results lint in generated code.][239]
* [Fix `unused_results` lint in generated code.][239]

[239]: https://github.com/taiki-e/pin-project/pull/239

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 @@ -49,9 +49,9 @@ where
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}

#[doc(hidden)]
#[allow(dead_code)]
#[allow(unreachable_pub)]
#[allow(single_use_lifetimes)]
struct __StructProjectionOwned<T, U> {
pinned: ::pin_project::__private::PhantomData<T>,
Expand Down
1 change: 1 addition & 0 deletions pin-project-internal/src/pin_project/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ impl<'a> Context<'a> {
proj_items.extend(quote! {
#doc_proj_own
#[allow(dead_code)] // This lint warns unused fields/variants.
#[allow(unreachable_pub)] // This lint warns `pub` field in private struct.
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
#vis struct #proj_own_ident #orig_generics #where_clause_own_fields
});
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/naming-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ where
unpinned: &'pin (U),
}
#[allow(dead_code)]
#[allow(unreachable_pub)]
#[allow(single_use_lifetimes)]
struct ProjOwn<T, U> {
pinned: ::pin_project::__private::PhantomData<T>,
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/naming-tuple_struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct ProjRef<'pin, T, U>(::pin_project::__private::Pin<&'pin (T)>, &'pin (U))
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(unreachable_pub)]
#[allow(single_use_lifetimes)]
struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U);
#[doc(hidden)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ where
}
#[doc(hidden)]
#[allow(dead_code)]
#[allow(unreachable_pub)]
#[allow(single_use_lifetimes)]
struct __StructProjectionOwned<T, U> {
pinned: ::pin_project::__private::PhantomData<T>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ where
TupleStruct<T, U>: 'pin;
#[doc(hidden)]
#[allow(dead_code)]
#[allow(unreachable_pub)]
#[allow(single_use_lifetimes)]
struct __TupleStructProjectionOwned<T, U>(::pin_project::__private::PhantomData<T>, U);
#[doc(hidden)]
Expand Down
15 changes: 15 additions & 0 deletions tests/include/basic-safe-part.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
// default #[pin_project], PinnedDrop, Replace, !Unpin, and UnsafeUnpin without UnsafeUnpin impl are completely safe.

#[::pin_project::pin_project]
#[derive(Debug)]
pub struct DefaultStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}

#[::pin_project::pin_project]
#[derive(Debug)]
pub struct DefaultTupleStruct<T, U>(#[pin] pub T, pub U);

#[::pin_project::pin_project]
#[derive(Debug)]
pub enum DefaultEnum<T, U> {
Struct {
#[pin]
Expand All @@ -22,6 +25,7 @@ pub enum DefaultEnum<T, U> {
}

#[::pin_project::pin_project(PinnedDrop)]
#[derive(Debug)]
pub struct PinnedDropStruct<T, U> {
#[pin]
pub pinned: T,
Expand All @@ -34,6 +38,7 @@ impl<T, U> PinnedDrop for PinnedDropStruct<T, U> {
}

#[::pin_project::pin_project(PinnedDrop)]
#[derive(Debug)]
pub struct PinnedDropTupleStruct<T, U>(#[pin] pub T, pub U);

#[::pin_project::pinned_drop]
Expand All @@ -42,6 +47,7 @@ impl<T, U> PinnedDrop for PinnedDropTupleStruct<T, U> {
}

#[::pin_project::pin_project(PinnedDrop)]
#[derive(Debug)]
pub enum PinnedDropEnum<T, U> {
Struct {
#[pin]
Expand All @@ -58,16 +64,19 @@ impl<T, U> PinnedDrop for PinnedDropEnum<T, U> {
}

#[::pin_project::pin_project(Replace)]
#[derive(Debug)]
pub struct ReplaceStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}

#[::pin_project::pin_project(Replace)]
#[derive(Debug)]
pub struct ReplaceTupleStruct<T, U>(#[pin] pub T, pub U);

#[::pin_project::pin_project(Replace)]
#[derive(Debug)]
pub enum ReplaceEnum<T, U> {
Struct {
#[pin]
Expand All @@ -79,16 +88,19 @@ pub enum ReplaceEnum<T, U> {
}

#[::pin_project::pin_project(UnsafeUnpin)]
#[derive(Debug)]
pub struct UnsafeUnpinStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}

#[::pin_project::pin_project(UnsafeUnpin)]
#[derive(Debug)]
pub struct UnsafeUnpinTupleStruct<T, U>(#[pin] pub T, pub U);

#[::pin_project::pin_project(UnsafeUnpin)]
#[derive(Debug)]
pub enum UnsafeUnpinEnum<T, U> {
Struct {
#[pin]
Expand All @@ -100,16 +112,19 @@ pub enum UnsafeUnpinEnum<T, U> {
}

#[::pin_project::pin_project(!Unpin)]
#[derive(Debug)]
pub struct NotUnpinStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}

#[::pin_project::pin_project(!Unpin)]
#[derive(Debug)]
pub struct NotUnpinTupleStruct<T, U>(#[pin] pub T, pub U);

#[::pin_project::pin_project(!Unpin)]
#[derive(Debug)]
pub enum NotUnpinEnum<T, U> {
Struct {
#[pin]
Expand Down
53 changes: 52 additions & 1 deletion tests/lint.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,43 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![warn(unused, unused_results, future_incompatible)]
#![warn(future_incompatible, nonstandard_style, rust_2018_compatibility, unused)]
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]

#[allow(unknown_lints)] // for old compilers
#[warn(
absolute_paths_not_starting_with_crate,
anonymous_parameters,
box_pointers,
confusable_idents,
deprecated_in_future,
elided_lifetimes_in_paths,
explicit_outlives_requirements,
indirect_structural_match,
keyword_idents,
macro_use_extern_crate,
meta_variable_misuse,
missing_copy_implementations,
missing_crate_level_docs,
missing_debug_implementations,
missing_docs,
missing_doc_code_examples,
non_ascii_idents,
private_doc_tests,
single_use_lifetimes,
trivial_casts,
trivial_numeric_casts,
unaligned_references,
unreachable_pub,
unstable_features,
unused_extern_crates,
unused_import_braces,
unused_lifetimes,
unused_qualifications,
unused_results,
variant_size_differences
)]
// unused_crate_dependencies: unrelated
// unsafe_code: checked in forbid_unsafe module
// unsafe_block_in_unsafe_fn: unstable
pub mod basic {
include!("include/basic.rs");
}
Expand Down Expand Up @@ -81,3 +117,18 @@ pub mod clippy {
},
}
}

#[rustversion::attr(not(nightly), ignore)]
#[test]
fn check_lint_list() {
use std::{env, process::Command};

(|| -> Result<(), Box<dyn std::error::Error>> {
let current = include_str!("lint.txt");
let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
let new = String::from_utf8(Command::new(rustc).args(&["-W", "help"]).output()?.stdout)?;
assert_eq!(current, &new);
Ok(())
})()
.unwrap_or_else(|e| panic!("{}", e));
}
Loading