Skip to content

Commit 36da99b

Browse files
committed
More docs in Macro.Env
1 parent 494a018 commit 36da99b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lib/elixir/lib/macro/env.ex

+19-1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ defmodule Macro.Env do
299299
300300
It does not check or assert the module is available.
301301
This is used by tools which need to mimic the Elixir compiler.
302+
The appropriate `:require` compiler tracing event will be emitted.
302303
303304
## Additional options
304305
@@ -337,7 +338,8 @@ defmodule Macro.Env do
337338
Defines the given `module` as imported in the environment.
338339
339340
It assumes `module` is available. This is used by tools which
340-
need to mimic the Elixir compiler.
341+
need to mimic the Elixir compiler. The appropriate `:import`
342+
compiler tracing event will be emitted.
341343
342344
## Additional options
343345
@@ -381,6 +383,7 @@ defmodule Macro.Env do
381383
Defines the given `as` an alias to `module` in the environment.
382384
383385
This is used by tools which need to mimic the Elixir compiler.
386+
The appropriate `:alias` compiler tracing event will be emitted.
384387
385388
## Additional options
386389
@@ -484,6 +487,9 @@ defmodule Macro.Env do
484487
If the import points to a function, it returns a tuple
485488
with the module and the function name.
486489
490+
If any import is found, the appropriate compiler tracing
491+
event will be emitted.
492+
487493
Otherwise returns `:error`.
488494
489495
## Options
@@ -533,6 +539,9 @@ defmodule Macro.Env do
533539
required, it returns a tuple with the module and a function
534540
that expands the macro. The function expects the metadata
535541
to be attached to the expansion and the arguments of the macro.
542+
The appropriate `:remote_macro` compiler tracing event will
543+
be emitted if a macro is found (note a `:remote_function`
544+
event is not emitted in `:error` cases).
536545
537546
Otherwise returns `:error`.
538547
@@ -579,6 +588,15 @@ defmodule Macro.Env do
579588
end
580589
end
581590

591+
@doc """
592+
Returns an environment in the guard context.
593+
"""
594+
@doc since: "1.17.0"
595+
@spec to_guard(t) :: t
596+
def to_guard(%{__struct__: Macro.Env} = env) do
597+
%{env | context: :guard}
598+
end
599+
582600
@doc """
583601
Returns an environment in the match context.
584602
"""

0 commit comments

Comments
 (0)