about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFolkert <folkert@folkertdev.nl>2024-07-26 00:08:22 +0200
committerFolkert <folkert@folkertdev.nl>2024-07-26 00:08:22 +0200
commit73fde1701762e82227cd9fe588b06ee15719d252 (patch)
tree9b709d986e689ca780e622eeacf8deccf4faf8d3
parentd3858f7465a711852e162b42e7cb2a2a53cf1e83 (diff)
downloadrust-73fde1701762e82227cd9fe588b06ee15719d252.tar.gz
rust-73fde1701762e82227cd9fe588b06ee15719d252.zip
refactor the `if if`
-rw-r--r--compiler/rustc_builtin_macros/src/asm.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs
index 96fc40ed1eb..218529b9ed7 100644
--- a/compiler/rustc_builtin_macros/src/asm.rs
+++ b/compiler/rustc_builtin_macros/src/asm.rs
@@ -365,10 +365,14 @@ fn parse_options<'a>(
 
         'blk: {
             for (symbol, option) in OPTIONS {
-                let expect =
-                    !is_global_asm || ast::InlineAsmOptions::GLOBAL_OPTIONS.contains(option);
+                let kw_matched =
+                    if !is_global_asm || ast::InlineAsmOptions::GLOBAL_OPTIONS.contains(option) {
+                        p.eat_keyword(symbol)
+                    } else {
+                        p.eat_keyword_noexpect(symbol)
+                    };
 
-                if if expect { p.eat_keyword(symbol) } else { p.eat_keyword_noexpect(symbol) } {
+                if kw_matched {
                     try_set_option(p, args, is_global_asm, symbol, option);
                     break 'blk;
                 }