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

Specify that packed types must derive, not implement, Copy #51143

Merged
merged 1 commit into from
Jun 3, 2018
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: 2 additions & 2 deletions src/librustc_mir/transform/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D
format!("#[derive] can't be used on a #[repr(packed)] struct with \
type parameters (error E0133)")
} else {
format!("#[derive] can't be used on a non-Copy #[repr(packed)] struct \
(error E0133)")
format!("#[derive] can't be used on a #[repr(packed)] struct that \
does not derive Copy (error E0133)")
};
tcx.lint_node(SAFE_PACKED_BORROWS,
lint_node_id,
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/deriving-with-repr-packed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct Bar(u32, u32, u32);
struct Y(usize);

#[derive(PartialEq)]
//~^ ERROR #[derive] can't be used on a non-Copy #[repr(packed)]
//~^ ERROR #[derive] can't be used
//~| hard error
#[repr(packed)]
struct X(Y);
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/deriving-with-repr-packed.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LL | #[derive(Copy, Clone, PartialEq, Eq)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>

error: #[derive] can't be used on a non-Copy #[repr(packed)] struct (error E0133)
error: #[derive] can't be used on a #[repr(packed)] struct that does not derive Copy (error E0133)
--> $DIR/deriving-with-repr-packed.rs:26:10
|
LL | #[derive(PartialEq, Eq)]
Expand All @@ -30,7 +30,7 @@ LL | #[derive(PartialEq, Eq)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>

error: #[derive] can't be used on a non-Copy #[repr(packed)] struct (error E0133)
error: #[derive] can't be used on a #[repr(packed)] struct that does not derive Copy (error E0133)
--> $DIR/deriving-with-repr-packed.rs:35:10
|
LL | #[derive(PartialEq)]
Expand Down