Skip to content

Commit 7f92561

Browse files
bors[bot]taiki-e
andauthored
Merge #274
274: v0.4: Prepare for uplift of drop-bounds lint r=taiki-e a=taiki-e This is the backport of #273 cc #272 Co-authored-by: Taiki Endo <te316e89@gmail.com>
2 parents 72780e4 + fecdd17 commit 7f92561

21 files changed

+50
-27
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ impl<'a> Context<'a> {
10561056
// which will then conflict with the explicit MustNotImplDrop impl below.
10571057
// This will result in a compilation error, which is exactly what we want.
10581058
trait #trait_ident {}
1059-
#[allow(clippy::drop_bounds)]
1059+
#[allow(clippy::drop_bounds, drop_bounds)]
10601060
impl<T: ::pin_project::__private::Drop> #trait_ident for T {}
10611061
impl #impl_generics #trait_ident for #ident #ty_generics #where_clause {}
10621062

tests/expand/tests/expand/default-enum.expanded.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const _: () = {
9898
}
9999
unsafe impl<T, U> ::pin_project::UnsafeUnpin for Enum<T, U> {}
100100
trait EnumMustNotImplDrop {}
101-
#[allow(clippy::drop_bounds)]
101+
#[allow(clippy::drop_bounds, drop_bounds)]
102102
impl<T: ::pin_project::__private::Drop> EnumMustNotImplDrop for T {}
103103
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
104104
impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const _: () = {
7373
}
7474
unsafe impl<T, U> ::pin_project::UnsafeUnpin for Struct<T, U> {}
7575
trait StructMustNotImplDrop {}
76-
#[allow(clippy::drop_bounds)]
76+
#[allow(clippy::drop_bounds, drop_bounds)]
7777
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
7878
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
7979
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const _: () = {
5858
}
5959
unsafe impl<T, U> ::pin_project::UnsafeUnpin for TupleStruct<T, U> {}
6060
trait TupleStructMustNotImplDrop {}
61-
#[allow(clippy::drop_bounds)]
61+
#[allow(clippy::drop_bounds, drop_bounds)]
6262
impl<T: ::pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
6363
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
6464
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const _: () = {
150150
}
151151
unsafe impl<T, U> ::pin_project::UnsafeUnpin for Enum<T, U> {}
152152
trait EnumMustNotImplDrop {}
153-
#[allow(clippy::drop_bounds)]
153+
#[allow(clippy::drop_bounds, drop_bounds)]
154154
impl<T: ::pin_project::__private::Drop> EnumMustNotImplDrop for T {}
155155
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
156156
impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const _: () = {
9797
}
9898
unsafe impl<T, U> ::pin_project::UnsafeUnpin for Struct<T, U> {}
9999
trait StructMustNotImplDrop {}
100-
#[allow(clippy::drop_bounds)]
100+
#[allow(clippy::drop_bounds, drop_bounds)]
101101
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
102102
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
103103
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const _: () = {
7676
}
7777
unsafe impl<T, U> ::pin_project::UnsafeUnpin for TupleStruct<T, U> {}
7878
trait TupleStructMustNotImplDrop {}
79-
#[allow(clippy::drop_bounds)]
79+
#[allow(clippy::drop_bounds, drop_bounds)]
8080
impl<T: ::pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
8181
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
8282
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {

tests/expand/tests/expand/not_unpin-enum.expanded.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const _: () = {
8888
}
8989
unsafe impl<T, U> ::pin_project::UnsafeUnpin for Enum<T, U> {}
9090
trait EnumMustNotImplDrop {}
91-
#[allow(clippy::drop_bounds)]
91+
#[allow(clippy::drop_bounds, drop_bounds)]
9292
impl<T: ::pin_project::__private::Drop> EnumMustNotImplDrop for T {}
9393
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
9494
impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const _: () = {
6464
}
6565
unsafe impl<T, U> ::pin_project::UnsafeUnpin for Struct<T, U> {}
6666
trait StructMustNotImplDrop {}
67-
#[allow(clippy::drop_bounds)]
67+
#[allow(clippy::drop_bounds, drop_bounds)]
6868
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
6969
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
7070
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const _: () = {
4949
}
5050
unsafe impl<T, U> ::pin_project::UnsafeUnpin for TupleStruct<T, U> {}
5151
trait TupleStructMustNotImplDrop {}
52-
#[allow(clippy::drop_bounds)]
52+
#[allow(clippy::drop_bounds, drop_bounds)]
5353
impl<T: ::pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
5454
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
5555
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ const _: () = {
157157
}
158158
unsafe impl<T, U> ::pin_project::UnsafeUnpin for Enum<T, U> {}
159159
trait EnumMustNotImplDrop {}
160-
#[allow(clippy::drop_bounds)]
160+
#[allow(clippy::drop_bounds, drop_bounds)]
161161
impl<T: ::pin_project::__private::Drop> EnumMustNotImplDrop for T {}
162162
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
163163
impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const _: () = {
102102
}
103103
unsafe impl<T, U> ::pin_project::UnsafeUnpin for Struct<T, U> {}
104104
trait StructMustNotImplDrop {}
105-
#[allow(clippy::drop_bounds)]
105+
#[allow(clippy::drop_bounds, drop_bounds)]
106106
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
107107
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
108108
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const _: () = {
8484
}
8585
unsafe impl<T, U> ::pin_project::UnsafeUnpin for TupleStruct<T, U> {}
8686
trait TupleStructMustNotImplDrop {}
87-
#[allow(clippy::drop_bounds)]
87+
#[allow(clippy::drop_bounds, drop_bounds)]
8888
impl<T: ::pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
8989
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
9090
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {

tests/expand/tests/expand/pub-enum.expanded.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const _: () = {
9898
}
9999
unsafe impl<T, U> ::pin_project::UnsafeUnpin for Enum<T, U> {}
100100
trait EnumMustNotImplDrop {}
101-
#[allow(clippy::drop_bounds)]
101+
#[allow(clippy::drop_bounds, drop_bounds)]
102102
impl<T: ::pin_project::__private::Drop> EnumMustNotImplDrop for T {}
103103
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
104104
impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const _: () = {
7373
}
7474
unsafe impl<T, U> ::pin_project::UnsafeUnpin for Struct<T, U> {}
7575
trait StructMustNotImplDrop {}
76-
#[allow(clippy::drop_bounds)]
76+
#[allow(clippy::drop_bounds, drop_bounds)]
7777
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
7878
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
7979
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const _: () = {
6161
}
6262
unsafe impl<T, U> ::pin_project::UnsafeUnpin for TupleStruct<T, U> {}
6363
trait TupleStructMustNotImplDrop {}
64-
#[allow(clippy::drop_bounds)]
64+
#[allow(clippy::drop_bounds, drop_bounds)]
6565
impl<T: ::pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
6666
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
6767
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {

tests/expand/tests/expand/unsafe_unpin-enum.expanded.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const _: () = {
8686
{
8787
}
8888
trait EnumMustNotImplDrop {}
89-
#[allow(clippy::drop_bounds)]
89+
#[allow(clippy::drop_bounds, drop_bounds)]
9090
impl<T: ::pin_project::__private::Drop> EnumMustNotImplDrop for T {}
9191
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
9292
impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const _: () = {
6262
{
6363
}
6464
trait StructMustNotImplDrop {}
65-
#[allow(clippy::drop_bounds)]
65+
#[allow(clippy::drop_bounds, drop_bounds)]
6666
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
6767
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
6868
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const _: () = {
4747
{
4848
}
4949
trait TupleStructMustNotImplDrop {}
50-
#[allow(clippy::drop_bounds)]
50+
#[allow(clippy::drop_bounds, drop_bounds)]
5151
impl<T: ::pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
5252
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
5353
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {

tests/lint.rs

+26-5
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,36 @@ pub mod clippy {
137137
#[rustversion::attr(not(nightly), ignore)]
138138
#[test]
139139
fn check_lint_list() {
140-
use std::{env, process::Command, str};
140+
use std::{env, fs, path::PathBuf, process::Command, str};
141141

142-
(|| -> Result<(), Box<dyn std::error::Error>> {
143-
let current = include_str!("lint.txt");
142+
type Result<T, E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
143+
144+
fn assert_eq(expected_path: &str, actual: &str) -> Result<()> {
145+
let manifest_dir = env::var_os("CARGO_MANIFEST_DIR")
146+
.map(PathBuf::from)
147+
.expect("CARGO_MANIFEST_DIR not set");
148+
let expected_path = manifest_dir.join(expected_path);
149+
let expected = fs::read_to_string(&expected_path)?;
150+
if expected != actual {
151+
if env::var_os("CI").map_or(false, |v| v == "true") {
152+
panic!(
153+
"assertion failed:\n\nEXPECTED:\n{0}\n{1}\n{0}\n\nACTUAL:\n{0}\n{2}\n{0}\n",
154+
"-".repeat(60),
155+
expected,
156+
actual,
157+
);
158+
} else {
159+
fs::write(&expected_path, actual)?;
160+
}
161+
}
162+
Ok(())
163+
}
164+
165+
(|| -> Result<()> {
144166
let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
145167
let output = Command::new(rustc).args(&["-W", "help"]).output()?;
146168
let new = str::from_utf8(&output.stdout)?;
147-
assert_eq!(current, new);
148-
Ok(())
169+
assert_eq("tests/lint.txt", new)
149170
})()
150171
.unwrap_or_else(|e| panic!("{}", e));
151172
}

tests/lint.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Lint checks provided by rustc:
1616
deprecated-in-future allow detects use of items that will be deprecated in a future version
1717
elided-lifetimes-in-paths allow hidden lifetime parameters in types are deprecated
1818
explicit-outlives-requirements allow outlives requirements can be inferred
19-
indirect-structural-match allow pattern with const indirectly referencing non-structural-match type
2019
keyword-idents allow detects edition keywords being used as an identifier
2120
macro-use-extern-crate allow the `#[macro_use]` attribute is now deprecated in favor of using macros via the module system
2221
meta-variable-misuse allow possible meta-variable misuse at macro definition
@@ -26,6 +25,7 @@ Lint checks provided by rustc:
2625
missing-docs allow detects missing documentation for public members
2726
missing-doc-code-examples allow detects publicly-exported items without code samples in their documentation
2827
non-ascii-idents allow detects non-ASCII identifiers
28+
pointer-structural-match allow pointers are not structural-match
2929
private-doc-tests allow detects code samples in docs of private items not documented by rustdoc
3030
single-use-lifetimes allow detects lifetime parameters that are only used once
3131
trivial-casts allow detects trivial casts which could be removed
@@ -61,13 +61,15 @@ Lint checks provided by rustc:
6161
improper-ctypes warn proper use of libc types in foreign modules
6262
improper-ctypes-definitions warn proper use of libc types in foreign item definitions
6363
incomplete-features warn incomplete features that may function improperly in some or all cases
64+
indirect-structural-match warn constant used in pattern contains value of non-structural-match type in a field or a variant
6465
inline-no-sanitize warn detects incompatible use of `#[inline(always)]` and `#[no_sanitize(...)]`
6566
invalid-codeblock-attributes warn codeblock attribute looks a lot like a known one
6667
invalid-value warn an invalid value is being created (such as a NULL reference)
6768
irrefutable-let-patterns warn detects irrefutable patterns in if-let and while-let statements
6869
late-bound-lifetime-arguments warn detects generic lifetime arguments in path segments with late bound lifetime parameters
6970
mixed-script-confusables warn detects Unicode scripts whose mixed script confusables codepoints are solely used
7071
mutable-borrow-reservation-conflict warn reservation of a two-phased borrow conflicts with other shared borrows
72+
nontrivial-structural-match warn constant used in pattern of non-structural-match type and the constant's initializer expression contains values of non-structural-match types
7173
non-camel-case-types warn types, variants, traits and type parameters should have camel case names
7274
non-shorthand-field-patterns warn using `Struct { x: x }` instead of `Struct { x }` in a pattern
7375
non-snake-case warn variables, methods, functions, lifetime parameters and modules should have snake case names
@@ -133,11 +135,11 @@ Lint groups provided by rustc:
133135
name sub-lints
134136
---- ---------
135137
warnings all lints that are set to issue warnings
136-
future-incompatible keyword-idents, anonymous-parameters, illegal-floating-point-literal-pattern, private-in-public, pub-use-of-private-extern-crate, invalid-type-param-default, safe-packed-borrows, patterns-in-fns-without-body, late-bound-lifetime-arguments, order-dependent-trait-objects, coherence-leak-check, tyvar-behind-raw-pointer, absolute-paths-not-starting-with-crate, unstable-name-collisions, where-clauses-object-safety, proc-macro-derive-resolution-fallback, macro-expanded-macro-exports-accessed-by-absolute-paths, ill-formed-attribute-input, conflicting-repr-hints, ambiguous-associated-items, mutable-borrow-reservation-conflict, indirect-structural-match, soft-unstable, cenum-impl-drop-cast, const-evaluatable-unchecked, array-into-iter
138+
future-incompatible keyword-idents, anonymous-parameters, illegal-floating-point-literal-pattern, private-in-public, pub-use-of-private-extern-crate, invalid-type-param-default, safe-packed-borrows, patterns-in-fns-without-body, late-bound-lifetime-arguments, order-dependent-trait-objects, coherence-leak-check, tyvar-behind-raw-pointer, absolute-paths-not-starting-with-crate, unstable-name-collisions, where-clauses-object-safety, proc-macro-derive-resolution-fallback, macro-expanded-macro-exports-accessed-by-absolute-paths, ill-formed-attribute-input, conflicting-repr-hints, ambiguous-associated-items, mutable-borrow-reservation-conflict, indirect-structural-match, pointer-structural-match, nontrivial-structural-match, soft-unstable, cenum-impl-drop-cast, const-evaluatable-unchecked, array-into-iter
137139
nonstandard-style non-camel-case-types, non-snake-case, non-upper-case-globals
138140
rust-2018-compatibility keyword-idents, anonymous-parameters, tyvar-behind-raw-pointer, absolute-paths-not-starting-with-crate
139141
rust-2018-idioms bare-trait-objects, unused-extern-crates, ellipsis-inclusive-range-patterns, elided-lifetimes-in-paths, explicit-outlives-requirements
140-
rustdoc broken-intra-doc-links, invalid-codeblock-attributes, missing-doc-code-examples, private-doc-tests
142+
rustdoc broken-intra-doc-links, private-intra-doc-links, invalid-codeblock-attributes, missing-doc-code-examples, private-doc-tests
141143
unused unused-imports, unused-variables, unused-assignments, dead-code, unused-mut, unreachable-code, unreachable-patterns, overlapping-patterns, unused-must-use, unused-unsafe, path-statements, unused-attributes, unused-macros, unused-allocation, unused-doc-comments, unused-extern-crates, unused-features, unused-labels, unused-parens, unused-braces, redundant-semicolons
142144

143145

0 commit comments

Comments
 (0)