diff options
| author | bors <bors@rust-lang.org> | 2021-09-11 03:30:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-09-11 03:30:55 +0000 |
| commit | 22719efcc570b043f2e519d6025e5f36eab38fe2 (patch) | |
| tree | f7fb4178f9e9964f7a1965b9c13e9c1654cb1cd4 /src/test/ui/derives/clone-debug-dead-code.rs | |
| parent | b69fe57261086e70aea9d5b58819a1794bf7c121 (diff) | |
| parent | f77311bc2b01a2708e5676a9a3bcb3d07d5040e2 (diff) | |
Auto merge of #88824 - Manishearth:rollup-7bzk9h6, r=Manishearth
Rollup of 15 pull requests
Successful merges:
- #85200 (Ignore derived Clone and Debug implementations during dead code analysis)
- #86165 (Add proc_macro::Span::{before, after}.)
- #87088 (Fix stray notes when the source code is not available)
- #87441 (Emit suggestion when passing byte literal to format macro)
- #88546 (Emit proper errors when on missing closure braces)
- #88578 (fix(rustc): suggest `items` be borrowed in `for i in items[x..]`)
- #88632 (Fix issues with Markdown summary options)
- #88639 (rustdoc: Fix ICE with `doc(hidden)` on tuple variant fields)
- #88667 (Tweak `write_fmt` doc.)
- #88720 (Rustdoc coverage fields count)
- #88732 (RustWrapper: avoid deleted unclear attribute methods)
- #88742 (Fix table in docblocks)
- #88776 (Workaround blink/chromium grid layout limitation of 1000 rows)
- #88807 (Fix typo in docs for iterators)
- #88812 (Fix typo `option` -> `options`.)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/test/ui/derives/clone-debug-dead-code.rs')
| -rw-r--r-- | src/test/ui/derives/clone-debug-dead-code.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/ui/derives/clone-debug-dead-code.rs b/src/test/ui/derives/clone-debug-dead-code.rs new file mode 100644 index 00000000000..80e91320939 --- /dev/null +++ b/src/test/ui/derives/clone-debug-dead-code.rs @@ -0,0 +1,45 @@ +// Checks that derived implementations of Clone and Debug do not +// contribute to dead code analysis (issue #84647). + +#![forbid(dead_code)] + +struct A { f: () } +//~^ ERROR: field is never read: `f` + +#[derive(Clone)] +struct B { f: () } +//~^ ERROR: field is never read: `f` + +#[derive(Debug)] +struct C { f: () } +//~^ ERROR: field is never read: `f` + +#[derive(Debug,Clone)] +struct D { f: () } +//~^ ERROR: field is never read: `f` + +struct E { f: () } +//~^ ERROR: field is never read: `f` +// Custom impl, still doesn't read f +impl Clone for E { + fn clone(&self) -> Self { + Self { f: () } + } +} + +struct F { f: () } +// Custom impl that actually reads f +impl Clone for F { + fn clone(&self) -> Self { + Self { f: self.f } + } +} + +fn main() { + let _ = A { f: () }; + let _ = B { f: () }; + let _ = C { f: () }; + let _ = D { f: () }; + let _ = E { f: () }; + let _ = F { f: () }; +} |
