Sunset RLS
This commit is contained in:
parent
1e978a3627
commit
4a7e2fbb7b
27 changed files with 162 additions and 593 deletions
|
|
@ -2,7 +2,7 @@ This directory contains the source code of the rust project, including:
|
|||
|
||||
- The test suite
|
||||
- The bootstrapping build system
|
||||
- Various submodules for tools, like rustdoc, rls, etc.
|
||||
- Various submodules for tools, like cargo, miri, etc.
|
||||
|
||||
For more information on how various parts of the compiler work, see the [rustc dev guide].
|
||||
|
||||
|
|
|
|||
|
|
@ -650,7 +650,6 @@ impl<'a> Builder<'a> {
|
|||
test::ReplacePlaceholderTest,
|
||||
test::Cargotest,
|
||||
test::Cargo,
|
||||
test::Rls,
|
||||
test::RustAnalyzer,
|
||||
test::ErrorIndex,
|
||||
test::Distcheck,
|
||||
|
|
@ -737,7 +736,6 @@ impl<'a> Builder<'a> {
|
|||
install::Docs,
|
||||
install::Std,
|
||||
install::Cargo,
|
||||
install::Rls,
|
||||
install::RustAnalyzer,
|
||||
install::Rustfmt,
|
||||
install::RustDemangler,
|
||||
|
|
|
|||
|
|
@ -457,7 +457,7 @@ tool_check_step!(Rustdoc, "src/tools/rustdoc", "src/librustdoc", SourceType::InT
|
|||
// rejected.
|
||||
tool_check_step!(Clippy, "src/tools/clippy", SourceType::InTree);
|
||||
tool_check_step!(Miri, "src/tools/miri", SourceType::Submodule);
|
||||
tool_check_step!(Rls, "src/tools/rls", SourceType::Submodule);
|
||||
tool_check_step!(Rls, "src/tools/rls", SourceType::InTree);
|
||||
tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree);
|
||||
|
||||
tool_check_step!(Bootstrap, "src/bootstrap", SourceType::InTree, false);
|
||||
|
|
|
|||
|
|
@ -1018,10 +1018,7 @@ impl Step for Rls {
|
|||
|
||||
let rls = builder
|
||||
.ensure(tool::Rls { compiler, target, extra_features: Vec::new() })
|
||||
.or_else(|| {
|
||||
missing_tool("RLS", builder.build.config.missing_tools);
|
||||
None
|
||||
})?;
|
||||
.expect("rls expected to build");
|
||||
|
||||
let mut tarball = Tarball::new(builder, "rls", &target.triple);
|
||||
tarball.set_overlay(OverlayKind::RLS);
|
||||
|
|
|
|||
|
|
@ -182,15 +182,6 @@ install!((self, builder, _config),
|
|||
.expect("missing cargo");
|
||||
install_sh(builder, "cargo", self.compiler.stage, Some(self.target), &tarball);
|
||||
};
|
||||
Rls, alias = "rls", Self::should_build(_config), only_hosts: true, {
|
||||
if let Some(tarball) = builder.ensure(dist::Rls { compiler: self.compiler, target: self.target }) {
|
||||
install_sh(builder, "rls", self.compiler.stage, Some(self.target), &tarball);
|
||||
} else {
|
||||
builder.info(
|
||||
&format!("skipping Install RLS stage{} ({})", self.compiler.stage, self.target),
|
||||
);
|
||||
}
|
||||
};
|
||||
RustAnalyzer, alias = "rust-analyzer", Self::should_build(_config), only_hosts: true, {
|
||||
if let Some(tarball) =
|
||||
builder.ensure(dist::RustAnalyzer { compiler: self.compiler, target: self.target })
|
||||
|
|
|
|||
|
|
@ -273,7 +273,6 @@ pub struct Build {
|
|||
bootstrap_out: PathBuf,
|
||||
rust_info: channel::GitInfo,
|
||||
cargo_info: channel::GitInfo,
|
||||
rls_info: channel::GitInfo,
|
||||
rust_analyzer_info: channel::GitInfo,
|
||||
clippy_info: channel::GitInfo,
|
||||
miri_info: channel::GitInfo,
|
||||
|
|
@ -407,7 +406,6 @@ impl Build {
|
|||
let ignore_git = config.ignore_git;
|
||||
let rust_info = channel::GitInfo::new(ignore_git, &src);
|
||||
let cargo_info = channel::GitInfo::new(ignore_git, &src.join("src/tools/cargo"));
|
||||
let rls_info = channel::GitInfo::new(ignore_git, &src.join("src/tools/rls"));
|
||||
let rust_analyzer_info =
|
||||
channel::GitInfo::new(ignore_git, &src.join("src/tools/rust-analyzer"));
|
||||
let clippy_info = channel::GitInfo::new(ignore_git, &src.join("src/tools/clippy"));
|
||||
|
|
@ -485,7 +483,6 @@ impl Build {
|
|||
|
||||
rust_info,
|
||||
cargo_info,
|
||||
rls_info,
|
||||
rust_analyzer_info,
|
||||
clippy_info,
|
||||
miri_info,
|
||||
|
|
|
|||
|
|
@ -50,11 +50,7 @@ impl OverlayKind {
|
|||
OverlayKind::RustDemangler => {
|
||||
&["src/tools/rust-demangler/README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||
}
|
||||
OverlayKind::RLS => &[
|
||||
"src/tools/rls/README.md",
|
||||
"src/tools/rls/LICENSE-APACHE",
|
||||
"src/tools/rls/LICENSE-MIT",
|
||||
],
|
||||
OverlayKind::RLS => &["src/tools/rls/README.md", "LICENSE-APACHE", "LICENSE-MIT"],
|
||||
OverlayKind::RustAnalyzer => &[
|
||||
"src/tools/rust-analyzer/README.md",
|
||||
"src/tools/rust-analyzer/LICENSE-APACHE",
|
||||
|
|
@ -78,7 +74,7 @@ impl OverlayKind {
|
|||
OverlayKind::Rustfmt => {
|
||||
builder.rustfmt_info.version(builder, &builder.release_num("rustfmt"))
|
||||
}
|
||||
OverlayKind::RLS => builder.rls_info.version(builder, &builder.release_num("rls")),
|
||||
OverlayKind::RLS => builder.release(&builder.release_num("rls")),
|
||||
OverlayKind::RustAnalyzer => builder
|
||||
.rust_analyzer_info
|
||||
.version(builder, &builder.release_num("rust-analyzer/crates/rust-analyzer")),
|
||||
|
|
|
|||
|
|
@ -299,57 +299,6 @@ impl Step for Cargo {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Rls {
|
||||
stage: u32,
|
||||
host: TargetSelection,
|
||||
}
|
||||
|
||||
impl Step for Rls {
|
||||
type Output = ();
|
||||
const ONLY_HOSTS: bool = true;
|
||||
|
||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||
run.path("src/tools/rls")
|
||||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
run.builder.ensure(Rls { stage: run.builder.top_stage, host: run.target });
|
||||
}
|
||||
|
||||
/// Runs `cargo test` for the rls.
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
let stage = self.stage;
|
||||
let host = self.host;
|
||||
let compiler = builder.compiler(stage, host);
|
||||
|
||||
let build_result =
|
||||
builder.ensure(tool::Rls { compiler, target: self.host, extra_features: Vec::new() });
|
||||
if build_result.is_none() {
|
||||
eprintln!("failed to test rls: could not build");
|
||||
return;
|
||||
}
|
||||
|
||||
let mut cargo = tool::prepare_tool_cargo(
|
||||
builder,
|
||||
compiler,
|
||||
Mode::ToolRustc,
|
||||
host,
|
||||
"test",
|
||||
"src/tools/rls",
|
||||
SourceType::Submodule,
|
||||
&[],
|
||||
);
|
||||
|
||||
cargo.add_rustc_lib_path(builder, compiler);
|
||||
cargo.arg("--").args(builder.config.cmd.test_args());
|
||||
|
||||
if try_run(builder, &mut cargo.into()) {
|
||||
builder.save_toolstate("rls", ToolState::TestPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct RustAnalyzer {
|
||||
stage: u32,
|
||||
|
|
|
|||
|
|
@ -857,14 +857,7 @@ tool_extended!((self, builder),
|
|||
Clippy, "src/tools/clippy", "clippy-driver", stable=true, in_tree=true, {};
|
||||
Miri, "src/tools/miri", "miri", stable=false, {};
|
||||
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=false, {};
|
||||
Rls, "src/tools/rls", "rls", stable=true, {
|
||||
builder.ensure(Clippy {
|
||||
compiler: self.compiler,
|
||||
target: self.target,
|
||||
extra_features: Vec::new(),
|
||||
});
|
||||
self.extra_features.push("clippy".to_owned());
|
||||
};
|
||||
Rls, "src/tools/rls", "rls", stable=true, {};
|
||||
// FIXME: tool_std is not quite right, we shouldn't allow nightly features.
|
||||
// But `builder.cargo` doesn't know how to handle ToolBootstrap in stages other than 0,
|
||||
// and this is close enough for now.
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ static STABLE_TOOLS: &[(&str, &str)] = &[
|
|||
("reference", "src/doc/reference"),
|
||||
("rust-by-example", "src/doc/rust-by-example"),
|
||||
("edition-guide", "src/doc/edition-guide"),
|
||||
("rls", "src/tools/rls"),
|
||||
];
|
||||
|
||||
// These tools are permitted to not build on the beta/stable channels.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ python3 "$X_PY" test --stage 2 --no-fail-fast \
|
|||
src/doc/rust-by-example \
|
||||
src/doc/embedded-book \
|
||||
src/doc/edition-guide \
|
||||
src/tools/rls \
|
||||
src/tools/miri \
|
||||
|
||||
set -e
|
||||
|
|
|
|||
|
|
@ -676,8 +676,7 @@ jobs:
|
|||
--enable-full-tools
|
||||
--enable-profiler
|
||||
SCRIPT: python x.py dist
|
||||
# RLS does not build for aarch64-pc-windows-msvc. See rust-lang/rls#1693
|
||||
DIST_REQUIRE_ALL_TOOLS: 0
|
||||
DIST_REQUIRE_ALL_TOOLS: 1
|
||||
# Hack around this SDK version, because it doesn't work with clang.
|
||||
# See https://github.com/rust-lang/rust/issues/88796
|
||||
WINDOWS_SDK_20348_HACK: 1
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 4d8b0a19986a4daab37287a5b5fe2da0775d1873
|
||||
13
src/tools/rls/Cargo.toml
Normal file
13
src/tools/rls/Cargo.toml
Normal file
|
|
@ -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"
|
||||
6
src/tools/rls/README.md
Normal file
6
src/tools/rls/README.md
Normal file
|
|
@ -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.
|
||||
101
src/tools/rls/src/main.rs
Normal file
101
src/tools/rls/src/main.rs
Normal file
|
|
@ -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(())
|
||||
}
|
||||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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).
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue