-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
include! docs don't explain how mod is resolved #149810
Copy link
Copy link
Open
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsneeds-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsneeds-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Location (URL)
https://doc.rust-lang.org/std/macro.include.html
Summary
The
include!macro appears to resolve modules before being 'pasted' into the current file. E.g. The following crate fails to compilewith file.rs:
include_src.rs:
and module.rs:
The
include!macro documentation does not mention this behaviour.As an aside:
This behaviour is very unintuitive to me, I expected
include!to behave exactly like pasting the included code into the current file.This also makes writing build scripts whose outputs contain
modproblematic. In my project,include_src.rsis an output of a build script; I've had to replace themods withmod file { include!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/module/file.rs")); }which isn't ideal and also seems to disable r-a's Intellisense forfile.rs.It would be useful to have a macro that does not do any sort of parsing/resolution to allow this pattern.