about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2022-08-20 21:19:43 -0700
committerEric Huss <eric@huss.org>2022-08-27 21:36:08 -0700
commit4a7e2fbb7bfdb7ddcb65b6fcf23bb5b272e66d42 (patch)
treebb2f39474cc03d3f78f5838297432a2a6a9e301d /src/tools
parent1e978a3627bd65064164af3548c585fb25eef9d2 (diff)
downloadrust-4a7e2fbb7bfdb7ddcb65b6fcf23bb5b272e66d42.tar.gz
rust-4a7e2fbb7bfdb7ddcb65b6fcf23bb5b272e66d42.zip
Sunset RLS
Diffstat (limited to 'src/tools')
-rwxr-xr-xsrc/tools/publish_toolstate.py3
m---------src/tools/rls0
-rw-r--r--src/tools/rls/Cargo.toml13
-rw-r--r--src/tools/rls/README.md6
-rw-r--r--src/tools/rls/src/main.rs101
-rw-r--r--src/tools/rustc-workspace-hack/Cargo.toml11
-rw-r--r--src/tools/rustc-workspace-hack/README.md12
-rw-r--r--src/tools/rustfmt/Processes.md4
-rw-r--r--src/tools/rustfmt/README.md2
-rw-r--r--src/tools/rustfmt/atom.md4
-rw-r--r--src/tools/tidy/src/deps.rs3
11 files changed, 132 insertions, 27 deletions
diff --git a/src/tools/publish_toolstate.py b/src/tools/publish_toolstate.py
index 1c57b731aaa..c0cef8f7b0a 100755
--- a/src/tools/publish_toolstate.py
+++ b/src/tools/publish_toolstate.py
@@ -31,7 +31,6 @@ except ImportError:
 # read privileges on it). CI will fail otherwise.
 MAINTAINERS = {
     'miri': {'oli-obk', 'RalfJung'},
-    'rls': {'Xanewok'},
     'book': {'carols10cents'},
     'nomicon': {'frewsxcv', 'Gankra', 'JohnTitor'},
     'reference': {'Havvy', 'matthewjasper', 'ehuss'},
@@ -43,7 +42,6 @@ MAINTAINERS = {
 
 LABELS = {
     'miri': ['A-miri', 'C-bug'],
-    'rls': ['A-rls', 'C-bug'],
     'book': ['C-bug'],
     'nomicon': ['C-bug'],
     'reference': ['C-bug'],
@@ -55,7 +53,6 @@ LABELS = {
 
 REPOS = {
     'miri': 'https://github.com/rust-lang/miri',
-    'rls': 'https://github.com/rust-lang/rls',
     'book': 'https://github.com/rust-lang/book',
     'nomicon': 'https://github.com/rust-lang/nomicon',
     'reference': 'https://github.com/rust-lang/reference',
diff --git a/src/tools/rls b/src/tools/rls
deleted file mode 160000
-Subproject 4d8b0a19986a4daab37287a5b5fe2da0775d187
diff --git a/src/tools/rls/Cargo.toml b/src/tools/rls/Cargo.toml
new file mode 100644
index 00000000000..92b50bf4cec
--- /dev/null
+++ b/src/tools/rls/Cargo.toml
@@ -0,0 +1,13 @@
+[package]
+name = "rls"
+version = "2.0.0"
+edition = "2021"
+license = "Apache-2.0/MIT"
+
+[dependencies]
+serde = { version = "1.0.143", features = ["derive"] }
+serde_json = "1.0.83"
+# A noop dependency that changes in the Rust repository, it's a bit of a hack.
+# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
+# for more information.
+rustc-workspace-hack = "1.0.0"
diff --git a/src/tools/rls/README.md b/src/tools/rls/README.md
new file mode 100644
index 00000000000..43c331c413f
--- /dev/null
+++ b/src/tools/rls/README.md
@@ -0,0 +1,6 @@
+# RLS Stub
+
+RLS has been replaced with [rust-analyzer](https://rust-analyzer.github.io/).
+
+This directory contains a stub which replaces RLS with a simple LSP server
+which only displays an alert to the user that RLS is no longer available.
diff --git a/src/tools/rls/src/main.rs b/src/tools/rls/src/main.rs
new file mode 100644
index 00000000000..f96f1325d96
--- /dev/null
+++ b/src/tools/rls/src/main.rs
@@ -0,0 +1,101 @@
+//! RLS stub.
+//!
+//! This is a small stub that replaces RLS to alert the user that RLS is no
+//! longer available.
+
+use serde::Deserialize;
+use std::error::Error;
+use std::io::BufRead;
+use std::io::Write;
+
+const ALERT_MSG: &str = "\
+RLS is no longer available as of Rust 1.65.
+Consider migrating to rust-analyzer instead.
+See https://rust-analyzer.github.io/ for installation instructions.
+";
+
+fn main() {
+    if let Err(e) = run() {
+        eprintln!("error: {e}");
+        std::process::exit(1);
+    }
+}
+
+#[derive(Deserialize)]
+struct Message {
+    method: Option<String>,
+}
+
+fn run() -> Result<(), Box<dyn Error>> {
+    let mut stdin = std::io::stdin().lock();
+    let mut stdout = std::io::stdout().lock();
+
+    let init = read_message(&mut stdin)?;
+    if init.method.as_deref() != Some("initialize") {
+        return Err(format!("expected initialize, got {:?}", init.method).into());
+    }
+    // No response, the LSP specification says that `showMessageRequest` may
+    // be posted before during this phase.
+
+    // message_type 1 is "Error"
+    let alert = serde_json::json!({
+        "jsonrpc": "2.0",
+        "id": 1,
+        "method": "window/showMessageRequest",
+        "params": {
+            "message_type": "1",
+            "message": ALERT_MSG
+        }
+    });
+    write_message_raw(&mut stdout, serde_json::to_string(&alert).unwrap())?;
+
+    loop {
+        let message = read_message(&mut stdin)?;
+        if message.method.as_deref() == Some("shutdown") {
+            std::process::exit(0);
+        }
+    }
+}
+
+fn read_message_raw<R: BufRead>(reader: &mut R) -> Result<String, Box<dyn Error>> {
+    let mut content_length: usize = 0;
+
+    // Read headers.
+    loop {
+        let mut line = String::new();
+        reader.read_line(&mut line)?;
+        if line.is_empty() {
+            return Err("remote disconnected".into());
+        }
+        if line == "\r\n" {
+            break;
+        }
+        if line.to_lowercase().starts_with("content-length:") {
+            let value = &line[15..].trim();
+            content_length = usize::from_str_radix(value, 10)?;
+        }
+    }
+    if content_length == 0 {
+        return Err("no content-length".into());
+    }
+
+    let mut buffer = vec![0; content_length];
+    reader.read_exact(&mut buffer)?;
+    let content = String::from_utf8(buffer)?;
+
+    Ok(content)
+}
+
+fn read_message<R: BufRead>(reader: &mut R) -> Result<Message, Box<dyn Error>> {
+    let m = read_message_raw(reader)?;
+    match serde_json::from_str(&m) {
+        Ok(m) => Ok(m),
+        Err(e) => Err(format!("failed to parse message {m}\n{e}").into()),
+    }
+}
+
+fn write_message_raw<W: Write>(mut writer: W, output: String) -> Result<(), Box<dyn Error>> {
+    write!(writer, "Content-Length: {}\r\n\r\n{}", output.len(), output)?;
+    writer.flush()?;
+    Ok(())
+}
diff --git a/src/tools/rustc-workspace-hack/Cargo.toml b/src/tools/rustc-workspace-hack/Cargo.toml
index b1d8b86496a..3c982b26127 100644
--- a/src/tools/rustc-workspace-hack/Cargo.toml
+++ b/src/tools/rustc-workspace-hack/Cargo.toml
@@ -24,6 +24,7 @@ features = [
   "errhandlingapi",
   "evntrace",
   "fibersapi",
+  "handleapi",
   "in6addr",
   "inaddr",
   "ioapiset",
@@ -72,11 +73,8 @@ features = [
 
 [dependencies]
 bstr = { version = "0.2.17", features = ["default"] }
-byteorder = { version = "1", features = ['default', 'std'] }
 clap = { version = "3.1.1", features = ["derive", "clap_derive"]}
 curl-sys = { version = "0.4.13", features = ["http2", "libnghttp2-sys"], optional = true }
-crossbeam-utils = { version = "0.8.0", features = ["nightly"] }
-libc = { version = "0.2.79", features = ["align"] }
 # Ensure default features of libz-sys, which are disabled in some scenarios.
 libz-sys = { version = "1.1.2" }
 # The only user of memchr's deprecated `use_std` feature is `combine`, so this can be
@@ -84,13 +82,8 @@ libz-sys = { version = "1.1.2" }
 memchr = { version = "2.5", features = ["std", "use_std"] }
 # Ensure default features of regex, which are disabled in some scenarios.
 regex = { version = "1.5.6" }
-proc-macro2 = { version = "1", features = ["default"] }
-quote = { version = "1", features = ["default"] }
-rand_core_0_5 = { package = "rand_core", version = "0.5.1", features = ["getrandom", "alloc", "std"] }
-serde = { version = "1.0.82", features = ['derive'] }
 serde_json = { version = "1.0.31", features = ["raw_value", "unbounded_depth"] }
-smallvec = { version = "1.8.1", features = ['union', 'may_dangle'] }
-syn = { version = "1", features = ['fold', 'full', 'extra-traits', 'visit', 'visit-mut'] }
+syn = { version = "1", features = ['full', 'visit'] }
 url = { version = "2.0", features = ['serde'] }
 
 [target.'cfg(not(windows))'.dependencies]
diff --git a/src/tools/rustc-workspace-hack/README.md b/src/tools/rustc-workspace-hack/README.md
index 4a5286fae9c..3c61470358b 100644
--- a/src/tools/rustc-workspace-hack/README.md
+++ b/src/tools/rustc-workspace-hack/README.md
@@ -2,18 +2,18 @@
 
 This crate is a bit of a hack to make workspaces in rustc work a bit better.
 The rationale for this existence is a bit subtle, but the general idea is that
-we want commands like `./x.py build src/tools/{rls,clippy,cargo}` to share as
+we want commands like `./x.py build src/tools/{clippy,cargo}` to share as
 many dependencies as possible.
 
 Each invocation is a different invocation of Cargo, however. Each time Cargo
 runs a build it will re-resolve the dependency graph, notably selecting
 different features sometimes for each build.
 
-For example, let's say there's a very deep dependency like `num-traits` in each
-of these builds. For Cargo the `num-traits`'s `default` feature is turned off.
-In RLS, however, the `default` feature is turned. This means that building Cargo
-and then the RLS will actually build Cargo twice (as a transitive dependency
-changed). This is bad!
+For example, let's say there's a very deep dependency like `winapi` in each of
+these builds. For Cargo, `winapi` has 33 features enabled. In Clippy, however,
+`winapi` has 22 features enabled. This means that building Cargo and then the
+Clippy will actually build winapi twice, which in turn will build duplicates
+of everything that depends on `winapi`. This is bad!
 
 The goal of this crate is to solve this problem and ensure that the resolved
 dependency graph for all of these tools is the same in the various subsets of
diff --git a/src/tools/rustfmt/Processes.md b/src/tools/rustfmt/Processes.md
index 9d86d52b122..f763b5714ce 100644
--- a/src/tools/rustfmt/Processes.md
+++ b/src/tools/rustfmt/Processes.md
@@ -51,7 +51,3 @@ git tag -s v1.2.3 -m "Release 1.2.3"
 `cargo publish`
 
 ## 5. Create a PR to rust-lang/rust to update the rustfmt submodule
-
-Note that if you are updating `rustc-ap-*` crates, then you need to update **every** submodules in the rust-lang/rust repository that depend on the crates to use the same version of those.
-
-As of 2019/05, there are two such crates: `rls` and `racer` (`racer` depends on `rustc-ap-syntax` and `rls` depends on `racer`, and `rls` is one of submodules of the rust-lang/rust repository).
diff --git a/src/tools/rustfmt/README.md b/src/tools/rustfmt/README.md
index b3a968f0c04..0f9652aecf9 100644
--- a/src/tools/rustfmt/README.md
+++ b/src/tools/rustfmt/README.md
@@ -135,7 +135,7 @@ completed without error (whether or not changes were made).
 * [Emacs](https://github.com/rust-lang/rust-mode)
 * [Sublime Text 3](https://packagecontrol.io/packages/RustFmt)
 * [Atom](atom.md)
-* Visual Studio Code using [vscode-rust](https://github.com/editor-rs/vscode-rust), [vsc-rustfmt](https://github.com/Connorcpu/vsc-rustfmt) or [rls_vscode](https://github.com/jonathandturner/rls_vscode) through RLS.
+* [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
 * [IntelliJ or CLion](intellij.md)
 
 
diff --git a/src/tools/rustfmt/atom.md b/src/tools/rustfmt/atom.md
index f77ac149072..c7e3a991a5f 100644
--- a/src/tools/rustfmt/atom.md
+++ b/src/tools/rustfmt/atom.md
@@ -1,8 +1,8 @@
 # Running Rustfmt from Atom
 
-## RLS
+## rust-analyzer
 
-Rustfmt is included with the Rust Language Server, itself provided by [ide-rust](https://atom.io/packages/ide-rust).
+Rustfmt can be utilized from [rust-analyzer](https://rust-analyzer.github.io/) which is provided by [ide-rust](https://atom.io/packages/ide-rust).
 
 `apm install ide-rust`
 
diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs
index 7f8d6ad1288..5770bb7bc33 100644
--- a/src/tools/tidy/src/deps.rs
+++ b/src/tools/tidy/src/deps.rs
@@ -31,8 +31,7 @@ const EXCEPTIONS: &[(&str, &str)] = &[
     ("mdbook", "MPL-2.0"),            // mdbook
     ("openssl", "Apache-2.0"),        // cargo, mdbook
     ("colored", "MPL-2.0"),           // rustfmt
-    ("ordslice", "Apache-2.0"),       // rls
-    ("ryu", "Apache-2.0 OR BSL-1.0"), // rls/cargo/... (because of serde)
+    ("ryu", "Apache-2.0 OR BSL-1.0"), // cargo/... (because of serde)
     ("bytesize", "Apache-2.0"),       // cargo
     ("im-rc", "MPL-2.0+"),            // cargo
     ("sized-chunks", "MPL-2.0+"),     // cargo via im-rc