Skip to content

Commit ffedf0c

Browse files
committed
Update path to use the attribute template
1 parent e93bffc commit ffedf0c

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/items/modules.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,29 @@ r[items.mod.outlined.path]
8888
### The `path` attribute
8989

9090
r[items.mod.outlined.path.intro]
91-
The directories and files used for loading external file modules can be influenced with the `path` attribute.
91+
The *`path` [attribute][attributes]* specifies the file to load for a module.
92+
93+
> [!EXAMPLE]
94+
> <!-- ignore: requires external files -->
95+
> ```rust,ignore
96+
> #[path = "other_file.rs"]
97+
> pub mod example;
98+
> ```
99+
100+
r[items.mod.outlined.path.syntax]
101+
The `path` attribute uses the [MetaNameValueStr] syntax to specify the path to the file.
102+
103+
r[items.mod.outlined.path.allowed-positions]
104+
The `path` attribute may only be applied to module declarations.
105+
106+
> [!NOTE]
107+
> `rustc` currently warns in other positions, but this may be rejected in the future.
108+
109+
r[items.mod.outlined.path.duplicates]
110+
Only the first instance of `path` on a module is honored. Subsequent `path` attributes are ignored.
111+
112+
> [!NOTE]
113+
> `rustc` currently warns on following duplicate `path` attributes. This may become an error in the future.
92114
93115
r[items.mod.outlined.path.search]
94116
For `path` attributes on modules not inside inline module blocks, the file path is relative to the directory the source file is located. For example, the following code snippet would use the paths shown based on where it is located:

0 commit comments

Comments
 (0)