diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2020-09-20 17:11:00 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2020-09-20 18:42:15 +0200 |
| commit | aba5ea1430df393eddc90068e838de6b1707c0d8 (patch) | |
| tree | 928e31eed00839be4f11e561811f1a48b45062a5 /compiler/rustc_session/src | |
| parent | 3795886f7e1f3dc5f5dd207ba4a7c092fe929486 (diff) | |
| download | rust-aba5ea1430df393eddc90068e838de6b1707c0d8.tar.gz rust-aba5ea1430df393eddc90068e838de6b1707c0d8.zip | |
Lint on function pointers used in patterns
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/lint/builtin.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/compiler/rustc_session/src/lint/builtin.rs b/compiler/rustc_session/src/lint/builtin.rs index 562df176b14..c72b97fa1ca 100644 --- a/compiler/rustc_session/src/lint/builtin.rs +++ b/compiler/rustc_session/src/lint/builtin.rs @@ -2198,6 +2198,32 @@ declare_lint! { } declare_lint! { + /// The `pointer_structural_match` lint detects pointers used in patterns that do not + /// behave deterministically across optimizations. + /// + /// ### Example + /// + /// ```rust,compile_fail + /// #![deny(pointer_structural_match)] + /// fn foo(a: usize, b: usize) -> usize { a + b } + /// const FOO: fn(usize, usize) -> usize = foo; + /// fn main() { + /// match FOO { + /// FOO => {}, + /// _ => {}, + /// } + /// } + /// ``` + pub POINTER_STRUCTURAL_MATCH, + Allow, + "pointers are not structural-match", + @future_incompatible = FutureIncompatibleInfo { + reference: "issue #62411 <https://github.com/rust-lang/rust/issues/70861>", + edition: None, + }; +} + +declare_lint! { /// The `ambiguous_associated_items` lint detects ambiguity between /// [associated items] and [enum variants]. /// @@ -2630,6 +2656,7 @@ declare_lint_pass! { AMBIGUOUS_ASSOCIATED_ITEMS, MUTABLE_BORROW_RESERVATION_CONFLICT, INDIRECT_STRUCTURAL_MATCH, + POINTER_STRUCTURAL_MATCH, SOFT_UNSTABLE, INLINE_NO_SANITIZE, ASM_SUB_REGISTER, |
