Do not implement unsafe auto traits for types with unsafe fields#133934
Do not implement unsafe auto traits for types with unsafe fields#133934bors merged 1 commit intorust-lang:masterfrom
Conversation
compiler-errors
left a comment
There was a problem hiding this comment.
Please adjust this logic in the new trait solver too. Also, there's no test as far as I can tell.
|
Also make sure the test exercises the behavior in both the old and new solvers. You can do something like: |
e6e322f to
baec50e
Compare
|
Whoops, somehow failed to push the test I wrote. It's here: https://github.com/rust-lang/rust/compare/e6e322f79713b156d43d77be6135463ec2d4b6e7..baec50ee0b8afc7433c3bd2f2b862a21addd2f57 |
|
|
||
| #![feature(auto_traits)] | ||
| #![feature(unsafe_fields)] | ||
| #![allow(dead_code, incomplete_features, unconditional_recursion)] |
There was a problem hiding this comment.
Please remove the unconditional_recursion. No reason not to just split this out into a fn main() {} or something that just calls both of the functions.
There was a problem hiding this comment.
No need for dead_code, that's enabled in the UI test suite unconditionally.
baec50e to
9d604ce
Compare
This comment has been minimized.
This comment has been minimized.
|
|
9d604ce to
9ccf285
Compare
| matches!(self.kind(), ty::FnPtr(..)) | ||
| } | ||
|
|
||
| /// Checks whether this type directly contains unsafe fields. |
There was a problem hiding this comment.
| /// Checks whether this type directly contains unsafe fields. | |
| /// Checks whether this type is an ADT that has unsafe fields. |
|
@bors r+ |
If a type has unsafe fields, its safety invariants are not simply the conjunction of its field types' safety invariants. Consequently, it's invalid to reason about the safety properties of these types in a purely structural manner — i.e., the manner in which `auto` traits are implemented. Makes progress towards rust-lang#132922.
9ccf285 to
a122dde
Compare
|
@bors r+ |
|
@bors r=compiler-errors |
|
💡 This pull request was already approved, no need to approve it again.
|
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#130209 (Stabilize `std::io::ErrorKind::CrossesDevices`) - rust-lang#130254 (Stabilize `std::io::ErrorKind::QuotaExceeded`) - rust-lang#132187 (Add Extend impls for tuples of arity 1 through 12) - rust-lang#133875 (handle `--json-output` properly) - rust-lang#133934 (Do not implement unsafe auto traits for types with unsafe fields) - rust-lang#133954 (Hide errors whose suggestions would contain error constants or types) - rust-lang#133960 (rustdoc: remove eq for clean::Attributes) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#130209 (Stabilize `std::io::ErrorKind::CrossesDevices`) - rust-lang#130254 (Stabilize `std::io::ErrorKind::QuotaExceeded`) - rust-lang#132187 (Add Extend impls for tuples of arity 1 through 12) - rust-lang#133875 (handle `--json-output` properly) - rust-lang#133934 (Do not implement unsafe auto traits for types with unsafe fields) - rust-lang#133954 (Hide errors whose suggestions would contain error constants or types) - rust-lang#133960 (rustdoc: remove eq for clean::Attributes) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#130209 (Stabilize `std::io::ErrorKind::CrossesDevices`) - rust-lang#130254 (Stabilize `std::io::ErrorKind::QuotaExceeded`) - rust-lang#132187 (Add Extend impls for tuples of arity 1 through 12) - rust-lang#133875 (handle `--json-output` properly) - rust-lang#133934 (Do not implement unsafe auto traits for types with unsafe fields) - rust-lang#133954 (Hide errors whose suggestions would contain error constants or types) - rust-lang#133960 (rustdoc: remove eq for clean::Attributes) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#133934 - jswrenn:unsafe-fields-auto-traits, r=compiler-errors Do not implement unsafe auto traits for types with unsafe fields If a type has unsafe fields, its safety invariants are not simply the conjunction of its field types' safety invariants. Consequently, it's invalid to reason about the safety properties of these types in a purely structural manner — i.e., the manner in which `auto` traits are implemented. Consequently, auto implementations of unsafe auto traits should not be generated for types with unsafe fields. Tracking: rust-lang#132922 r? `@compiler-errors`
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#130209 (Stabilize `std::io::ErrorKind::CrossesDevices`) - rust-lang#130254 (Stabilize `std::io::ErrorKind::QuotaExceeded`) - rust-lang#132187 (Add Extend impls for tuples of arity 1 through 12) - rust-lang#133875 (handle `--json-output` properly) - rust-lang#133934 (Do not implement unsafe auto traits for types with unsafe fields) - rust-lang#133954 (Hide errors whose suggestions would contain error constants or types) - rust-lang#133960 (rustdoc: remove eq for clean::Attributes) r? `@ghost` `@rustbot` modify labels: rollup
If a type has unsafe fields, its safety invariants are not simply the conjunction of its field types' safety invariants. Consequently, it's invalid to reason about the safety properties of these types in a purely structural manner — i.e., the manner in which
autotraits are implemented. Consequently, auto implementations of unsafe auto traits should not be generated for types with unsafe fields.Tracking: #132922
r? @compiler-errors