-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ui-test for enable-raw-pointer-heuristic-for-send config
- Loading branch information
Showing
5 changed files
with
149 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
enable-raw-pointer-heuristic-for-send = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#![warn(clippy::non_send_field_in_send_ty)] | ||
#![feature(extern_types)] | ||
|
||
use std::rc::Rc; | ||
|
||
// Basic tests should not be affected | ||
pub struct NoGeneric { | ||
rc_is_not_send: Rc<String>, | ||
} | ||
|
||
unsafe impl Send for NoGeneric {} | ||
|
||
pub struct MultiField<T> { | ||
field1: T, | ||
field2: T, | ||
field3: T, | ||
} | ||
|
||
unsafe impl<T> Send for MultiField<T> {} | ||
|
||
pub enum MyOption<T> { | ||
MySome(T), | ||
MyNone, | ||
} | ||
|
||
unsafe impl<T> Send for MyOption<T> {} | ||
|
||
// All fields are disallowed when raw pointer heuristic is off | ||
extern "C" { | ||
type NonSend; | ||
} | ||
|
||
pub struct HeuristicTest { | ||
field1: Vec<*const NonSend>, | ||
field2: [*const NonSend; 3], | ||
field3: (*const NonSend, *const NonSend, *const NonSend), | ||
field4: (*const NonSend, Rc<u8>), | ||
field5: Vec<Vec<*const NonSend>>, | ||
} | ||
|
||
unsafe impl Send for HeuristicTest {} | ||
|
||
fn main() {} |
91 changes: 91 additions & 0 deletions
91
tests/ui-toml/strict_non_send_field_in_send_ty/test.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
error: this implementation is unsound, as some fields in `NoGeneric` are `!Send` | ||
--> $DIR/test.rs:11:1 | ||
| | ||
LL | unsafe impl Send for NoGeneric {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::non-send-field-in-send-ty` implied by `-D warnings` | ||
note: the field `rc_is_not_send` has type `std::rc::Rc<std::string::String>` which is `!Send` | ||
--> $DIR/test.rs:8:5 | ||
| | ||
LL | rc_is_not_send: Rc<String>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= help: use a thread-safe type that implements `Send` | ||
|
||
error: this implementation is unsound, as some fields in `MultiField<T>` are `!Send` | ||
--> $DIR/test.rs:19:1 | ||
| | ||
LL | unsafe impl<T> Send for MultiField<T> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the field `field1` has type `T` which is `!Send` | ||
--> $DIR/test.rs:14:5 | ||
| | ||
LL | field1: T, | ||
| ^^^^^^^^^ | ||
= help: add `T: Send` bound in `Send` impl | ||
note: the field `field2` has type `T` which is `!Send` | ||
--> $DIR/test.rs:15:5 | ||
| | ||
LL | field2: T, | ||
| ^^^^^^^^^ | ||
= help: add `T: Send` bound in `Send` impl | ||
note: the field `field3` has type `T` which is `!Send` | ||
--> $DIR/test.rs:16:5 | ||
| | ||
LL | field3: T, | ||
| ^^^^^^^^^ | ||
= help: add `T: Send` bound in `Send` impl | ||
|
||
error: this implementation is unsound, as some fields in `MyOption<T>` are `!Send` | ||
--> $DIR/test.rs:26:1 | ||
| | ||
LL | unsafe impl<T> Send for MyOption<T> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the field `0` has type `T` which is `!Send` | ||
--> $DIR/test.rs:22:12 | ||
| | ||
LL | MySome(T), | ||
| ^ | ||
= help: add `T: Send` bound in `Send` impl | ||
|
||
error: this implementation is unsound, as some fields in `HeuristicTest` are `!Send` | ||
--> $DIR/test.rs:41:1 | ||
| | ||
LL | unsafe impl Send for HeuristicTest {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the field `field1` has type `std::vec::Vec<*const NonSend>` which is `!Send` | ||
--> $DIR/test.rs:34:5 | ||
| | ||
LL | field1: Vec<*const NonSend>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= help: use a thread-safe type that implements `Send` | ||
note: the field `field2` has type `[*const NonSend; 3]` which is `!Send` | ||
--> $DIR/test.rs:35:5 | ||
| | ||
LL | field2: [*const NonSend; 3], | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= help: use a thread-safe type that implements `Send` | ||
note: the field `field3` has type `(*const NonSend, *const NonSend, *const NonSend)` which is `!Send` | ||
--> $DIR/test.rs:36:5 | ||
| | ||
LL | field3: (*const NonSend, *const NonSend, *const NonSend), | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= help: use a thread-safe type that implements `Send` | ||
note: the field `field4` has type `(*const NonSend, std::rc::Rc<u8>)` which is `!Send` | ||
--> $DIR/test.rs:37:5 | ||
| | ||
LL | field4: (*const NonSend, Rc<u8>), | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= help: use a thread-safe type that implements `Send` | ||
note: the field `field5` has type `std::vec::Vec<std::vec::Vec<*const NonSend>>` which is `!Send` | ||
--> $DIR/test.rs:38:5 | ||
| | ||
LL | field5: Vec<Vec<*const NonSend>>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= help: use a thread-safe type that implements `Send` | ||
|
||
error: aborting due to 4 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
error: error reading Clippy's configuration file `$DIR/clippy.toml`: unknown field `foobar`, expected one of `avoid-breaking-exported-api`, `msrv`, `blacklisted-names`, `cognitive-complexity-threshold`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `literal-representation-threshold`, `trivial-copy-size-limit`, `pass-by-value-size-limit`, `too-many-lines-threshold`, `array-size-threshold`, `vec-box-size-threshold`, `max-trait-bounds`, `max-struct-bools`, `max-fn-params-bools`, `warn-on-all-wildcard-imports`, `disallowed-methods`, `disallowed-types`, `unreadable-literal-lint-fractions`, `upper-case-acronyms-aggressive`, `cargo-ignore-publish`, `standard-macro-braces`, `enforced-import-renames`, `allowed-scripts`, `enable-raw-pointer-heuristic`, `third-party` at line 5 column 1 | ||
error: error reading Clippy's configuration file `$DIR/clippy.toml`: unknown field `foobar`, expected one of `avoid-breaking-exported-api`, `msrv`, `blacklisted-names`, `cognitive-complexity-threshold`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `literal-representation-threshold`, `trivial-copy-size-limit`, `pass-by-value-size-limit`, `too-many-lines-threshold`, `array-size-threshold`, `vec-box-size-threshold`, `max-trait-bounds`, `max-struct-bools`, `max-fn-params-bools`, `warn-on-all-wildcard-imports`, `disallowed-methods`, `disallowed-types`, `unreadable-literal-lint-fractions`, `upper-case-acronyms-aggressive`, `cargo-ignore-publish`, `standard-macro-braces`, `enforced-import-renames`, `allowed-scripts`, `enable-raw-pointer-heuristic-for-send`, `third-party` at line 5 column 1 | ||
|
||
error: aborting due to previous error | ||
|