From be31b6b6cdfd0d614a22214391b91070fe55d89e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 2 Mar 2024 22:48:41 +0100 Subject: Add new `pattern_complexity` attribute to add possibility to limit and check recursion in pattern matching --- compiler/rustc_feature/src/builtin_attrs.rs | 4 ++++ compiler/rustc_feature/src/unstable.rs | 2 ++ 2 files changed, 6 insertions(+) (limited to 'compiler/rustc_feature/src') diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 327c70ede28..10867ae230a 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -929,6 +929,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ omit_gdb_pretty_printer_section, Normal, template!(Word), WarnFollowing, "the `#[omit_gdb_pretty_printer_section]` attribute is just used for the Rust test suite", ), + rustc_attr!( + TEST, pattern_complexity, CrateLevel, template!(NameValueStr: "N"), + ErrorFollowing, @only_local: true, + ), ]; pub fn deprecated_attributes() -> Vec<&'static BuiltinAttribute> { diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 53254d567cc..17c4d81474e 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -213,6 +213,8 @@ declare_features! ( (internal, negative_bounds, "1.71.0", None), /// Allows using `#[omit_gdb_pretty_printer_section]`. (internal, omit_gdb_pretty_printer_section, "1.5.0", None), + /// Set the maximum pattern complexity allowed (not limited by default). + (internal, pattern_complexity, "CURRENT_RUSTC_VERSION", None), /// Allows using `#[prelude_import]` on glob `use` items. (internal, prelude_import, "1.2.0", None), /// Used to identify crates that contain the profiler runtime. -- cgit 1.4.1-3-g733a5