-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
13 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
26 changes: 26 additions & 0 deletions
26
src/test/ui/lint/auxiliary/private-nested-unused_must_use.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,26 @@ | ||
#[must_use] | ||
pub struct S; | ||
|
||
pub struct T; | ||
|
||
pub struct B { | ||
s: S, | ||
pub t: T, | ||
} | ||
|
||
pub struct C { | ||
pub s: S, | ||
pub t: T, | ||
} | ||
|
||
impl B { | ||
pub fn new() -> B { | ||
B { s: S, t: T } | ||
} | ||
} | ||
|
||
impl C { | ||
pub fn new() -> C { | ||
C { s: S, t: T } | ||
} | ||
} |
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,12 @@ | ||
// aux-build:private-nested-unused_must_use.rs | ||
|
||
#![deny(unused_must_use)] | ||
|
||
extern crate private_nested_unused_must_use; | ||
|
||
use self::private_nested_unused_must_use::{B, C}; | ||
|
||
fn main() { | ||
B::new(); // ok: ignores private `must_use` type | ||
C::new(); //~ ERROR unused `private_nested_unused_must_use::S` in field `s` that must be used | ||
} |
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,8 @@ | ||
error: unused `private_nested_unused_must_use::S` in field `s` that must be used | ||
--> $DIR/mod-nested-unused_must_use.rs:11:5 | ||
| | ||
LL | C::new(); | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|