diff options
| author | Zack M. Davis <code@zackmdavis.net> | 2018-04-02 19:34:52 -0700 |
|---|---|---|
| committer | Zack M. Davis <code@zackmdavis.net> | 2018-04-09 08:53:30 -0700 |
| commit | a1d90a2a2a2d3ff6843d8fca17be4819dba9ab6b (patch) | |
| tree | 8a1fcba08ab73212011884d72dc1d156ef548772 /src/test/run-pass | |
| parent | 4b9b70c394e7f341b4016fce4cbf763d404b26f9 (diff) | |
| download | rust-a1d90a2a2a2d3ff6843d8fca17be4819dba9ab6b.tar.gz rust-a1d90a2a2a2d3ff6843d8fca17be4819dba9ab6b.zip | |
in which the non-shorthand patterns lint keeps its own counsel in macros
In issue #49588, Michael Lamparski pointed out a scenario in which the non-shorthand-field-patterns lint could be triggered by a macro-expanded pattern, in a way which was direly unwieldy for the macro author to guard against and unreasonable to expect the macro user to take into account. We can avoid this by not linting patterns that come from macro-expansions. Although this entails accepting "false negatives" where the lint could genuinely improve macro-templated code, avoiding the reported "true-but-super-annoying positive" may be worth the trade? (Some precedent for these relative priorities exists as no. 47775 (5985b0b0).) Resolves #49588.
Diffstat (limited to 'src/test/run-pass')
| -rw-r--r-- | src/test/run-pass/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/run-pass/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs b/src/test/run-pass/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs new file mode 100644 index 00000000000..51b2b5a4f7c --- /dev/null +++ b/src/test/run-pass/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs @@ -0,0 +1,24 @@ +// 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. + +#![deny(non_shorthand_field_patterns)] + +pub struct Value<A> { pub value: A } + +#[macro_export] +macro_rules! pat { + ($a:pat) => { + Value { value: $a } + }; +} + +fn main() { + let pat!(value) = Value { value: () }; +} |
