Commit 35719fe1 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Use byte-compile-initial-macro-environment to avoid intermediary function

parent b68f207b
Pipeline #1948 failed with stage
in 3 seconds
......@@ -494,17 +494,11 @@ is enabled."
;; The implementation for the interpreter is basically trivial.
(car (last body)))
(defmacro with-suppressed-warnings (warnings &rest body)
"Like `progn', but prevents compiler warnings in the body."
(declare (indent 1))
(defmacro with-suppressed-warnings (_warnings &rest body)
"Like `progn', but prevents compiler WARNINGS in BODY."
(declare (debug (sexp &optional body)) (indent 1))
;; The implementation for the interpreter is basically trivial.
`(with-suppressed-warnings-1 ',warnings (progn ,@body)))
(defun with-suppressed-warnings-1 (_ &rest body)
"Like `progn', but prevents compiler warnings in the body."
(declare (indent 1))
;; The implementation for the interpreter is basically trivial.
(car (last body)))
`(progn ,@body))
(defun byte-run--unescaped-character-literals-warning ()
......
......@@ -510,7 +510,12 @@ Return the compile-time value of FORM."
form
macroexpand-all-environment)))
(eval expanded lexical-binding)
expanded))))))
expanded)))))
(with-suppressed-warnings
. (lambda (warnings &rest body)
(macroexpand-all `(internal--with-suppressed-warnings
',warnings ,@body)
macroexpand-all-environment))))
"The default macro-environment passed to macroexpand by the compiler.
Placing a macro here will cause a macro to have different semantics when
expanded by the compiler as when expanded by the interpreter.")
......@@ -2528,7 +2533,15 @@ list that represents a doc string reference.
(mapc 'byte-compile-file-form (cdr form))
nil))
(put 'with-suppressed-warnings-1 'byte-hunk-handler
(defun internal--with-suppressed-warnings (_ &rest body)
"Placeholder function used to connect between macro and byte compilation.
`byte-compile-initial-macro-environment' maps
`with-suppressed-warnings' to
`internal--with-suppressed-warnings', and the `byte-hunk-handler'
for that function basically turns it into a `progn'."
(car (last body)))
(put 'internal--with-suppressed-warnings 'byte-hunk-handler
'byte-compile-file-form-with-suppressed-warnings)
(defun byte-compile-file-form-with-suppressed-warnings (form)
;; cf byte-compile-file-form-progn.
......@@ -4783,7 +4796,7 @@ binding slots have been popped."
(let (byte-compile-warnings)
(byte-compile-form (cons 'progn (cdr form)))))
(byte-defop-compiler-1 with-suppressed-warnings-1
(byte-defop-compiler-1 internal--with-suppressed-warnings
byte-compile-suppressed-warnings)
(defun byte-compile-suppressed-warnings (form)
(let ((byte-compile-suppressed-warnings
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment