diff options
| author | Zack M. Davis <code@zackmdavis.net> | 2018-01-31 20:56:01 -0800 |
|---|---|---|
| committer | Zack M. Davis <code@zackmdavis.net> | 2018-01-31 21:27:16 -0800 |
| commit | e4b1a7971d7b4ed61d27af44e3169cb26595ae13 (patch) | |
| tree | c098bbf8f2ecc5d4ca8fecf2d9b6332b03633f46 /src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs | |
| parent | 8f9d91587fa1d2595405f8a1cc1c43e7b044be1a (diff) | |
| download | rust-e4b1a7971d7b4ed61d27af44e3169cb26595ae13.tar.gz rust-e4b1a7971d7b4ed61d27af44e3169cb26595ae13.zip | |
concerning well-formed suggestions for unused shorthand field patterns
Previously, unused variables would get a note that the warning could be silenced by prefixing the variable with an underscore, but that doesn't work for field shorthand patterns, which the liveness analysis didn't know about. The "to avoid this warning" verbiage seemed unnecessary. Resolves #47390.
Diffstat (limited to 'src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs')
| -rw-r--r-- | src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs b/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs new file mode 100644 index 00000000000..a68b4f76352 --- /dev/null +++ b/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs @@ -0,0 +1,34 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// must-compile-successfully + +#![warn(unused)] // UI tests pass `-A unused` (#43896) + +struct SoulHistory { + corridors_of_light: usize, + hours_are_suns: bool, + endless_and_singing: bool +} + +fn main() { + let i_think_continually = 2; + let who_from_the_womb_remembered = SoulHistory { + corridors_of_light: 5, + hours_are_suns: true, + endless_and_singing: true + }; + + if let SoulHistory { corridors_of_light, + mut hours_are_suns, + endless_and_singing: true } = who_from_the_womb_remembered { + hours_are_suns = false; + } +} |
