Skip to content

Commit 2eb4b32

Browse files
bors[bot]taiki-e
andauthored
Merge #240
240: Check interoperability with all rustc lints allowed by default r=taiki-e a=taiki-e Co-authored-by: Taiki Endo <te316e89@gmail.com>
2 parents ed5e093 + 10a954b commit 2eb4b32

11 files changed

+216
-5
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ This project adheres to [Semantic Versioning](https://semver.org).
66

77
## [Unreleased]
88

9+
* Suppress `unreachable_pub` lint in generated code.
10+
911
## [0.4.19] - 2020-06-04
1012

11-
* [Fix unused_results lint in generated code.][239]
13+
* [Fix `unused_results` lint in generated code.][239]
1214

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

examples/project_replace-expanded.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ where
4949
pinned: ::pin_project::__private::Pin<&'pin (T)>,
5050
unpinned: &'pin (U),
5151
}
52-
5352
#[doc(hidden)]
5453
#[allow(dead_code)]
54+
#[allow(unreachable_pub)]
5555
#[allow(single_use_lifetimes)]
5656
struct __StructProjectionOwned<T, U> {
5757
pinned: ::pin_project::__private::PhantomData<T>,

pin-project-internal/src/pin_project/derive.rs

+1
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ impl<'a> Context<'a> {
500500
proj_items.extend(quote! {
501501
#doc_proj_own
502502
#[allow(dead_code)] // This lint warns unused fields/variants.
503+
#[allow(unreachable_pub)] // This lint warns `pub` field in private struct.
503504
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
504505
#vis struct #proj_own_ident #orig_generics #where_clause_own_fields
505506
});

tests/expand/tests/expand/naming-struct.expanded.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ where
2727
unpinned: &'pin (U),
2828
}
2929
#[allow(dead_code)]
30+
#[allow(unreachable_pub)]
3031
#[allow(single_use_lifetimes)]
3132
struct ProjOwn<T, U> {
3233
pinned: ::pin_project::__private::PhantomData<T>,

tests/expand/tests/expand/naming-tuple_struct.expanded.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct ProjRef<'pin, T, U>(::pin_project::__private::Pin<&'pin (T)>, &'pin (U))
1515
where
1616
TupleStruct<T, U>: 'pin;
1717
#[allow(dead_code)]
18+
#[allow(unreachable_pub)]
1819
#[allow(single_use_lifetimes)]
1920
struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U);
2021
#[doc(hidden)]

tests/expand/tests/expand/project_replace-struct.expanded.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ where
3030
}
3131
#[doc(hidden)]
3232
#[allow(dead_code)]
33+
#[allow(unreachable_pub)]
3334
#[allow(single_use_lifetimes)]
3435
struct __StructProjectionOwned<T, U> {
3536
pinned: ::pin_project::__private::PhantomData<T>,

tests/expand/tests/expand/project_replace-tuple_struct.expanded.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ where
2121
TupleStruct<T, U>: 'pin;
2222
#[doc(hidden)]
2323
#[allow(dead_code)]
24+
#[allow(unreachable_pub)]
2425
#[allow(single_use_lifetimes)]
2526
struct __TupleStructProjectionOwned<T, U>(::pin_project::__private::PhantomData<T>, U);
2627
#[doc(hidden)]

tests/include/basic-safe-part.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
// default #[pin_project], PinnedDrop, Replace, !Unpin, and UnsafeUnpin without UnsafeUnpin impl are completely safe.
22

33
#[::pin_project::pin_project]
4+
#[derive(Debug)]
45
pub struct DefaultStruct<T, U> {
56
#[pin]
67
pub pinned: T,
78
pub unpinned: U,
89
}
910

1011
#[::pin_project::pin_project]
12+
#[derive(Debug)]
1113
pub struct DefaultTupleStruct<T, U>(#[pin] pub T, pub U);
1214

1315
#[::pin_project::pin_project]
16+
#[derive(Debug)]
1417
pub enum DefaultEnum<T, U> {
1518
Struct {
1619
#[pin]
@@ -22,6 +25,7 @@ pub enum DefaultEnum<T, U> {
2225
}
2326

2427
#[::pin_project::pin_project(PinnedDrop)]
28+
#[derive(Debug)]
2529
pub struct PinnedDropStruct<T, U> {
2630
#[pin]
2731
pub pinned: T,
@@ -34,6 +38,7 @@ impl<T, U> PinnedDrop for PinnedDropStruct<T, U> {
3438
}
3539

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

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

4449
#[::pin_project::pin_project(PinnedDrop)]
50+
#[derive(Debug)]
4551
pub enum PinnedDropEnum<T, U> {
4652
Struct {
4753
#[pin]
@@ -58,16 +64,19 @@ impl<T, U> PinnedDrop for PinnedDropEnum<T, U> {
5864
}
5965

6066
#[::pin_project::pin_project(Replace)]
67+
#[derive(Debug)]
6168
pub struct ReplaceStruct<T, U> {
6269
#[pin]
6370
pub pinned: T,
6471
pub unpinned: U,
6572
}
6673

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

7078
#[::pin_project::pin_project(Replace)]
79+
#[derive(Debug)]
7180
pub enum ReplaceEnum<T, U> {
7281
Struct {
7382
#[pin]
@@ -79,16 +88,19 @@ pub enum ReplaceEnum<T, U> {
7988
}
8089

8190
#[::pin_project::pin_project(UnsafeUnpin)]
91+
#[derive(Debug)]
8292
pub struct UnsafeUnpinStruct<T, U> {
8393
#[pin]
8494
pub pinned: T,
8595
pub unpinned: U,
8696
}
8797

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

91102
#[::pin_project::pin_project(UnsafeUnpin)]
103+
#[derive(Debug)]
92104
pub enum UnsafeUnpinEnum<T, U> {
93105
Struct {
94106
#[pin]
@@ -100,16 +112,19 @@ pub enum UnsafeUnpinEnum<T, U> {
100112
}
101113

102114
#[::pin_project::pin_project(!Unpin)]
115+
#[derive(Debug)]
103116
pub struct NotUnpinStruct<T, U> {
104117
#[pin]
105118
pub pinned: T,
106119
pub unpinned: U,
107120
}
108121

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

112126
#[::pin_project::pin_project(!Unpin)]
127+
#[derive(Debug)]
113128
pub enum NotUnpinEnum<T, U> {
114129
Struct {
115130
#[pin]

tests/lint.rs

+52-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,43 @@
11
#![warn(rust_2018_idioms, single_use_lifetimes)]
2-
#![warn(unused, unused_results, future_incompatible)]
2+
#![warn(future_incompatible, nonstandard_style, rust_2018_compatibility, unused)]
33
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
44

5+
#[allow(unknown_lints)] // for old compilers
6+
#[warn(
7+
absolute_paths_not_starting_with_crate,
8+
anonymous_parameters,
9+
box_pointers,
10+
confusable_idents,
11+
deprecated_in_future,
12+
elided_lifetimes_in_paths,
13+
explicit_outlives_requirements,
14+
indirect_structural_match,
15+
keyword_idents,
16+
macro_use_extern_crate,
17+
meta_variable_misuse,
18+
missing_copy_implementations,
19+
missing_crate_level_docs,
20+
missing_debug_implementations,
21+
missing_docs,
22+
missing_doc_code_examples,
23+
non_ascii_idents,
24+
private_doc_tests,
25+
single_use_lifetimes,
26+
trivial_casts,
27+
trivial_numeric_casts,
28+
unaligned_references,
29+
unreachable_pub,
30+
unstable_features,
31+
unused_extern_crates,
32+
unused_import_braces,
33+
unused_lifetimes,
34+
unused_qualifications,
35+
unused_results,
36+
variant_size_differences
37+
)]
38+
// unused_crate_dependencies: unrelated
39+
// unsafe_code: checked in forbid_unsafe module
40+
// unsafe_block_in_unsafe_fn: unstable
541
pub mod basic {
642
include!("include/basic.rs");
743
}
@@ -81,3 +117,18 @@ pub mod clippy {
81117
},
82118
}
83119
}
120+
121+
#[rustversion::attr(not(nightly), ignore)]
122+
#[test]
123+
fn check_lint_list() {
124+
use std::{env, process::Command};
125+
126+
(|| -> Result<(), Box<dyn std::error::Error>> {
127+
let current = include_str!("lint.txt");
128+
let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
129+
let new = String::from_utf8(Command::new(rustc).args(&["-W", "help"]).output()?.stdout)?;
130+
assert_eq!(current, &new);
131+
Ok(())
132+
})()
133+
.unwrap_or_else(|e| panic!("{}", e));
134+
}

0 commit comments

Comments
 (0)