From e3e6fd56a6b66ff1d0f4567ecb41c2c17f54a472 Mon Sep 17 00:00:00 2001 From: Ryan Scheel Date: Fri, 8 Jan 2021 23:08:54 -0800 Subject: [PATCH] Detect `fn main<>()` You can use an empty generics container on any function, including main. Definitely not idiomatic, but also seemingly trivial to support. --- ui/frontend/selectors/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/frontend/selectors/index.ts b/ui/frontend/selectors/index.ts index 70ae36f1a..78b6c5aa2 100644 --- a/ui/frontend/selectors/index.ts +++ b/ui/frontend/selectors/index.ts @@ -10,7 +10,7 @@ const codeSelector = (state: State) => state.code; const HAS_TESTS_RE = /^\s*#\s*\[\s*test\s*([^"]*)]/m; export const hasTestsSelector = createSelector(codeSelector, code => !!code.match(HAS_TESTS_RE)); -const HAS_MAIN_FUNCTION_RE = /^\s*(pub\s+)?\s*(const\s+)?\s*(async\s+)?\s*fn\s+main\s*\(\s*\)/m; +const HAS_MAIN_FUNCTION_RE = /^\s*(pub\s+)?\s*(const\s+)?\s*(async\s+)?\s*fn\s+main\s*(<\s*>)?\(\s*\)/m; export const hasMainFunctionSelector = createSelector(codeSelector, code => !!code.match(HAS_MAIN_FUNCTION_RE)); const CRATE_TYPE_RE = /^\s*#!\s*\[\s*crate_type\s*=\s*"([^"]*)"\s*]/m;