Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
use rustc shim instead of rustc
Browse files Browse the repository at this point in the history
closes #435
  • Loading branch information
nrc committed Aug 22, 2017
1 parent 25ffb3a commit 515f5f9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ log = "0.3"
racer = "2.0.6"
rls-analysis = "0.6.5"
rls-data = { version = "0.10", features = ["serialize-serde"] }
rls-rustc = "0.1"
rls-span = { version = "0.4", features = ["serialize-serde"] }
rls-vfs = { version = "0.4", features = ["racer-impls"] }
rustfmt-nightly = "0.2"
Expand Down
3 changes: 2 additions & 1 deletion src/build/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ impl Executor for RlsExecutor {
}
}

let rustc_exe = env::var("RUSTC").unwrap_or("rustc".to_owned());
let rustc_exe = env::var("RUSTC").unwrap_or(env::args().next().unwrap());
let mut cmd = Command::new(&rustc_exe);
cmd.env(::RUSTC_SHIM_ENV_VAR_NAME, "1");

// We only want to intercept rustc call targeting current crate to cache
// args/envs generated by cargo so we can run only rustc later ourselves
Expand Down
12 changes: 10 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ extern crate lazy_static;
extern crate log;
extern crate racer;
extern crate rls_analysis as analysis;
extern crate rls_vfs as vfs;
extern crate rls_span as span;
extern crate rls_data as data;
extern crate rls_rustc as rustc_shim;
extern crate rls_span as span;
extern crate rls_vfs as vfs;
extern crate rustfmt_nightly as rustfmt;
extern crate serde;
#[macro_use]
Expand All @@ -39,6 +40,7 @@ extern crate url;
extern crate url_serde;
extern crate jsonrpc_core;

use std::env;
use std::sync::Arc;

mod actions;
Expand All @@ -59,11 +61,17 @@ const CRATE_BLACKLIST: [&'static str; 10] = [
"serde_json", "librustc_serialize", "libunicode_segmentation",
];

const RUSTC_SHIM_ENV_VAR_NAME: &'static str = "RLS_RUSTC_SHIM";

type Span = span::Span<span::ZeroIndexed>;

pub fn main() {
env_logger::init().unwrap();

if env::var(RUSTC_SHIM_ENV_VAR_NAME).map(|v| v != "0").unwrap_or(false) {
rustc_shim::run();
}

if let Some(first_arg) = ::std::env::args().skip(1).next() {
match first_arg.as_str() {
"--version" | "-V" => println!("rls {}", version()),
Expand Down
1 change: 1 addition & 0 deletions src/test/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ pub fn expect_messages(results: LsResultList, expected: &[&ExpectedMessage]) {
// Initialise the environment for a test.
pub fn init_env(project_dir: &str) -> (Cache, TestCleanup) {
let _ = env_logger::init();
env::set_var("RUSTC", "rustc");

let path = &Path::new("test_data").join(project_dir);
let tc = TestCleanup { path: path.to_owned() };
Expand Down

0 comments on commit 515f5f9

Please sign in to comment.