Skip to content

Implement env! macro #3549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 11, 2020
Merged

Implement env! macro #3549

merged 6 commits into from
Mar 11, 2020

Conversation

edwin0cheng
Copy link
Member

@edwin0cheng edwin0cheng commented Mar 10, 2020

This PR implements env! macro by adding following things:

  1. Added additional_outdirs settings in vscode. (naming to be bikeshed)
  2. Added ExternSourceId which is a wrapping for SourceRootId but only used in extern sources. It is because OUT_DIR is not belonged to any crate and we have to access it behind an AstDatabase.
  3. This PR does not implement the OUT_DIR parsing from cargo check. I don't have general design about this, @kiljacken could we reuse some cargo watch code for that ?

Block on [#3536]

PS: After this PR , we (kind of) completed the include!(concat!(env!('OUT_DIR'), "foo.rs") macro call combo. Exodia Obliterate!

@edwin0cheng
Copy link
Member Author

env_concat_inclue

@edwin0cheng edwin0cheng changed the title [Draft] Implement env! macro Implement env! macro Mar 10, 2020
@edwin0cheng edwin0cheng requested a review from matklad March 10, 2020 17:09

// Note: Some env variables (e.g. OUT_DIR) are located outside of the
// crate. We store a map to allow remap it to ExternSourceId
extern_paths: FxHashMap<String, ExternSourceId>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it's ... less then ideal that we need to single out OUT_DIR this way, but I guess that's the only way given current VFS API...

Copy link
Member Author

@edwin0cheng edwin0cheng Mar 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is the only solution I came up without altering too much code. But after some thoughts, I think I should separate this part to a new struct ExternPaths ExternSource and put it in CrateGraph instead.

[Edit] change to ExternSource

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@kiljacken
Copy link
Contributor

kiljacken commented Mar 11, 2020 via email

@matklad
Copy link
Member

matklad commented Mar 11, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 11, 2020

@bors bors bot merged commit c48dcf7 into rust-lang:master Mar 11, 2020
@edwin0cheng edwin0cheng deleted the impl-env branch March 11, 2020 11:52
sdbondi added a commit to sdbondi/tari that referenced this pull request Jan 29, 2021
Cleans up the code a bit in tari_core::proto by removing the `generated`
module. Instead of including the generated files directly, protos are
generated to the OUT_DIR and included using the `include!` macro. This
is the intended way that generated files are included, however
this would break intellisense in IDEs.

IDE and rust analyser support for OUT_DIR has greatly improved.
see:
https://blog.jetbrains.com/clion/2019/12/recent-updates-in-rust/
rust-lang/rust-analyzer#3549
sdbondi added a commit to sdbondi/tari that referenced this pull request Jan 29, 2021
Cleans up the code a bit in tari_core::proto by removing the `generated`
module. Instead of including the generated files directly, protos are
generated to the OUT_DIR and included using the `include!` macro. This
is the intended way that generated files are included, however
this would break intellisense in IDEs.

IDE and rust analyser support for OUT_DIR has greatly improved.
see:
https://blog.jetbrains.com/clion/2019/12/recent-updates-in-rust/
rust-lang/rust-analyzer#3549
sdbondi added a commit to sdbondi/tari that referenced this pull request Jan 29, 2021
Cleans up the code a bit in tari_core::proto by removing the `generated`
module. Instead of including the generated files directly, protos are
generated to the OUT_DIR and included using the `include!` macro. This
is the intended way that generated files are included, however
this would break intellisense in IDEs.

IDE and rust analyser support for OUT_DIR has greatly improved.
see:
https://blog.jetbrains.com/clion/2019/12/recent-updates-in-rust/
rust-lang/rust-analyzer#3549
sdbondi added a commit to sdbondi/tari that referenced this pull request Jan 29, 2021
Cleans up the code a bit in tari_core::proto by removing the `generated`
module. Instead of including the generated files directly, protos are
generated to the OUT_DIR and included using the `include!` macro. This
is the intended way that generated files are included, however
this would break intellisense in IDEs.

IDE and rust analyser support for OUT_DIR has greatly improved.
see:
https://blog.jetbrains.com/clion/2019/12/recent-updates-in-rust/
rust-lang/rust-analyzer#3549
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants