-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Switch to in-tree rustc dependencies with a cfg flag #15616
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] | ||
#![allow(rustdoc::private_intra_doc_links)] | ||
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this required? |
||
|
||
mod lexed_str; | ||
mod token_set; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ flycheck.workspace = true | |
hir-def.workspace = true | ||
hir-ty.workspace = true | ||
hir.workspace = true | ||
rustc-dependencies.workspace = true | ||
ide-db.workspace = true | ||
# This should only be used in CLI | ||
ide-ssr.workspace = true | ||
|
@@ -67,6 +68,7 @@ profile.workspace = true | |
project-model.workspace = true | ||
stdx.workspace = true | ||
syntax.workspace = true | ||
parser.workspace = true | ||
toolchain.workspace = true | ||
vfs-notify.workspace = true | ||
vfs.workspace = true | ||
|
@@ -89,4 +91,12 @@ mbe.workspace = true | |
jemalloc = ["jemallocator", "profile/jemalloc"] | ||
force-always-assert = ["always-assert/force"] | ||
sysroot-abi = [] | ||
in-rust-tree = ["sysroot-abi", "ide/in-rust-tree", "syntax/in-rust-tree"] | ||
in-rust-tree = [ | ||
"sysroot-abi", | ||
"ide/in-rust-tree", | ||
"syntax/in-rust-tree", | ||
"parser/in-rust-tree", | ||
"rustc-dependencies/in-rust-tree", | ||
"hir-def/in-rust-tree", | ||
"hir-ty/in-rust-tree", | ||
] | ||
Comment on lines
+94
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a fan of this either, this will ultimately end up with mentioning almost all of our crates at some point There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Me too, maybe a non cargo cfg is a better fit here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think it'd be better if we could make it so that this doesn't thread through all the cargo files if possible |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "rustc-dependencies" | ||
version = "0.0.0" | ||
rust-version.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
authors.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
ra-ap-rustc_lexer = { version = "0.10.0" } | ||
ra-ap-rustc_parse_format = { version = "0.10.0", default-features = false } | ||
|
||
# Upstream broke this for us so we can't update it | ||
hkalbasi-rustc-ap-rustc_abi = { version = "0.0.20221221", default-features = false } | ||
hkalbasi-rustc-ap-rustc_index = { version = "0.0.20221221", default-features = false } | ||
|
||
[features] | ||
in-rust-tree = [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! A wrapper around rustc internal crates, which enables switching between compiler provided | ||
//! ones and stable ones published in crates.io | ||
|
||
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] | ||
|
||
#[cfg(feature = "in-rust-tree")] | ||
extern crate rustc_lexer; | ||
|
||
#[cfg(feature = "in-rust-tree")] | ||
pub mod lexer { | ||
pub use ::rustc_lexer::*; | ||
} | ||
|
||
#[cfg(not(feature = "in-rust-tree"))] | ||
pub mod lexer { | ||
pub use ::ra_ap_rustc_lexer::*; | ||
} | ||
|
||
#[cfg(feature = "in-rust-tree")] | ||
extern crate rustc_parse_format; | ||
|
||
#[cfg(feature = "in-rust-tree")] | ||
pub mod parse_format { | ||
pub use ::rustc_parse_format::*; | ||
} | ||
|
||
#[cfg(not(feature = "in-rust-tree"))] | ||
pub mod parse_format { | ||
pub use ::ra_ap_rustc_parse_format::*; | ||
} | ||
|
||
// Upstream broke this for us so we can't update it | ||
pub mod abi { | ||
pub use ::hkalbasi_rustc_ap_rustc_abi::*; | ||
} | ||
|
||
pub mod index { | ||
pub use ::hkalbasi_rustc_ap_rustc_index::*; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
//! [RFC]: <https://github.com/rust-lang/rfcs/pull/2256> | ||
//! [Swift]: <https://github.com/apple/swift/blob/13d593df6f359d0cb2fc81cfaac273297c539455/lib/Syntax/README.md> | ||
|
||
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] | ||
|
||
#[allow(unused)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature is needed even if you import the rustc private crates indirectly, which I think is unnecessarily too aggressive. Is there any way to depend on the crates in the rustc workspace without this feature? Clippy and Miri use this, but they are fine with nightly and feature flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, since we might mention the items from those crates now. Well that's unfortunate but not much we can do in that case. Would be nice to add a comment regarding that then.