-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add trybuild test to ensure deprecated types are derivable. (#1332)
Co-authored-by: Jack Wrenn <[email protected]>
- Loading branch information
1 parent
2bc3566
commit 4ae2dde
Showing
3 changed files
with
44 additions
and
2 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
33 changes: 33 additions & 0 deletions
33
zerocopy-derive/tests/ui-nightly/absence_of_deprecated_warning.rs
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,33 @@ | ||
// Copyright 2024 The Fuchsia Authors | ||
// | ||
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 | ||
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT | ||
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. | ||
// This file may not be copied, modified, or distributed except according to | ||
// those terms. | ||
|
||
//! See: https://github.com/google/zerocopy/issues/553 | ||
//! zerocopy must still allow derives of deprecated types. | ||
//! This test has a hand-written impl of a deprecated type, and should result in a compilation | ||
//! error. If zerocopy does not tack an allow(deprecated) annotation onto its impls, then this | ||
//! test will fail because more than one compile error will be generated. | ||
#![deny(deprecated)] | ||
|
||
extern crate zerocopy; | ||
|
||
use zerocopy::IntoBytes; | ||
|
||
#[deprecated = "Do not use"] | ||
#[derive(IntoBytes)] | ||
#[repr(C)] | ||
struct OldHeader { | ||
field_a: usize, | ||
collection: [u8; 8], | ||
} | ||
|
||
trait T {} | ||
|
||
// Intentionally trigger a deprecation error | ||
impl T for OldHeader {} | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
zerocopy-derive/tests/ui-nightly/absence_of_deprecated_warning.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,11 @@ | ||
error: use of deprecated struct `OldHeader`: Do not use | ||
--> tests/ui-nightly/absence_of_deprecated_warning.rs:31:12 | ||
| | ||
31 | impl T for OldHeader {} | ||
| ^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> tests/ui-nightly/absence_of_deprecated_warning.rs:14:9 | ||
| | ||
14 | #![deny(deprecated)] | ||
| ^^^^^^^^^^ |