mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Remove salsa doc compile tests
This commit is contained in:
parent
dba59970bc
commit
1443d49b72
4 changed files with 23 additions and 140 deletions
|
@ -11,7 +11,7 @@ extern crate rustc_driver as _;
|
|||
|
||||
mod rustc_wrapper;
|
||||
|
||||
use std::{env, fs, path::PathBuf, process, sync::Arc};
|
||||
use std::{env, fs, path::PathBuf, process::ExitCode, sync::Arc};
|
||||
|
||||
use anyhow::Context;
|
||||
use lsp_server::Connection;
|
||||
|
@ -27,21 +27,15 @@ static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
|||
#[global_allocator]
|
||||
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
fn main() -> anyhow::Result<ExitCode> {
|
||||
if std::env::var("RA_RUSTC_WRAPPER").is_ok() {
|
||||
let mut args = std::env::args_os();
|
||||
let _me = args.next().unwrap();
|
||||
let rustc = args.next().unwrap();
|
||||
let code = match rustc_wrapper::run_rustc_skipping_cargo_checking(rustc, args.collect()) {
|
||||
Ok(rustc_wrapper::ExitCode(code)) => code.unwrap_or(102),
|
||||
Err(err) => {
|
||||
eprintln!("{err}");
|
||||
101
|
||||
}
|
||||
};
|
||||
process::exit(code);
|
||||
rustc_wrapper::main().map_err(Into::into)
|
||||
} else {
|
||||
actual_main()
|
||||
}
|
||||
}
|
||||
|
||||
fn actual_main() -> anyhow::Result<ExitCode> {
|
||||
let flags = flags::RustAnalyzer::from_env_or_exit();
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
|
@ -58,14 +52,14 @@ fn main() -> anyhow::Result<()> {
|
|||
let verbosity = flags.verbosity();
|
||||
|
||||
match flags.subcommand {
|
||||
flags::RustAnalyzerCmd::LspServer(cmd) => {
|
||||
flags::RustAnalyzerCmd::LspServer(cmd) => 'lsp_server: {
|
||||
if cmd.print_config_schema {
|
||||
println!("{:#}", Config::json_schema());
|
||||
return Ok(());
|
||||
break 'lsp_server;
|
||||
}
|
||||
if cmd.version {
|
||||
println!("rust-analyzer {}", rust_analyzer::version());
|
||||
return Ok(());
|
||||
break 'lsp_server;
|
||||
}
|
||||
|
||||
// rust-analyzer’s “main thread” is actually
|
||||
|
@ -90,7 +84,7 @@ fn main() -> anyhow::Result<()> {
|
|||
flags::RustAnalyzerCmd::RunTests(cmd) => cmd.run()?,
|
||||
flags::RustAnalyzerCmd::RustcTests(cmd) => cmd.run()?,
|
||||
}
|
||||
Ok(())
|
||||
Ok(ExitCode::SUCCESS)
|
||||
}
|
||||
|
||||
fn setup_logging(log_file_flag: Option<PathBuf>) -> anyhow::Result<()> {
|
||||
|
|
|
@ -7,13 +7,17 @@
|
|||
use std::{
|
||||
ffi::OsString,
|
||||
io,
|
||||
process::{Command, Stdio},
|
||||
process::{Command, ExitCode, Stdio},
|
||||
};
|
||||
|
||||
/// ExitCode/ExitStatus are impossible to create :(.
|
||||
pub(crate) struct ExitCode(pub(crate) Option<i32>);
|
||||
pub(crate) fn main() -> io::Result<ExitCode> {
|
||||
let mut args = std::env::args_os();
|
||||
let _me = args.next().unwrap();
|
||||
let rustc = args.next().unwrap();
|
||||
run_rustc_skipping_cargo_checking(rustc, args.collect())
|
||||
}
|
||||
|
||||
pub(crate) fn run_rustc_skipping_cargo_checking(
|
||||
fn run_rustc_skipping_cargo_checking(
|
||||
rustc_executable: OsString,
|
||||
args: Vec<OsString>,
|
||||
) -> io::Result<ExitCode> {
|
||||
|
@ -35,9 +39,10 @@ pub(crate) fn run_rustc_skipping_cargo_checking(
|
|||
arg.starts_with("--emit=") && arg.contains("metadata") && !arg.contains("link")
|
||||
});
|
||||
if not_invoked_by_build_script && is_cargo_check {
|
||||
return Ok(ExitCode(Some(0)));
|
||||
Ok(ExitCode::from(0))
|
||||
} else {
|
||||
run_rustc(rustc_executable, args)
|
||||
}
|
||||
run_rustc(rustc_executable, args)
|
||||
}
|
||||
|
||||
fn run_rustc(rustc_executable: OsString, args: Vec<OsString>) -> io::Result<ExitCode> {
|
||||
|
@ -47,5 +52,5 @@ fn run_rustc(rustc_executable: OsString, args: Vec<OsString>) -> io::Result<Exit
|
|||
.stdout(Stdio::inherit())
|
||||
.stderr(Stdio::inherit())
|
||||
.spawn()?;
|
||||
Ok(ExitCode(child.wait()?.code()))
|
||||
Ok(ExitCode::from(child.wait()?.code().unwrap_or(102) as u8))
|
||||
}
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
//!
|
||||
#![allow(dead_code)]
|
||||
|
||||
/// Test that a database with a key/value that is not `Send` will,
|
||||
/// indeed, not be `Send`.
|
||||
///
|
||||
/// ```compile_fail,E0277
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// #[salsa::query_group(NoSendSyncStorage)]
|
||||
/// trait NoSendSyncDatabase: salsa::Database {
|
||||
/// fn no_send_sync_value(&self, key: bool) -> Rc<bool>;
|
||||
/// fn no_send_sync_key(&self, key: Rc<bool>) -> bool;
|
||||
/// }
|
||||
///
|
||||
/// fn no_send_sync_value(_db: &dyn NoSendSyncDatabase, key: bool) -> Rc<bool> {
|
||||
/// Rc::new(key)
|
||||
/// }
|
||||
///
|
||||
/// fn no_send_sync_key(_db: &dyn NoSendSyncDatabase, key: Rc<bool>) -> bool {
|
||||
/// *key
|
||||
/// }
|
||||
///
|
||||
/// #[salsa::database(NoSendSyncStorage)]
|
||||
/// #[derive(Default)]
|
||||
/// struct DatabaseImpl {
|
||||
/// storage: salsa::Storage<Self>,
|
||||
/// }
|
||||
///
|
||||
/// impl salsa::Database for DatabaseImpl {
|
||||
/// }
|
||||
///
|
||||
/// fn is_send<T: Send>(_: T) { }
|
||||
///
|
||||
/// fn assert_send() {
|
||||
/// is_send(DatabaseImpl::default());
|
||||
/// }
|
||||
/// ```
|
||||
fn test_key_not_send_db_not_send() {}
|
||||
|
||||
/// Test that a database with a key/value that is not `Sync` will not
|
||||
/// be `Send`.
|
||||
///
|
||||
/// ```compile_fail,E0277
|
||||
/// use std::rc::Rc;
|
||||
/// use std::cell::Cell;
|
||||
///
|
||||
/// #[salsa::query_group(NoSendSyncStorage)]
|
||||
/// trait NoSendSyncDatabase: salsa::Database {
|
||||
/// fn no_send_sync_value(&self, key: bool) -> Cell<bool>;
|
||||
/// fn no_send_sync_key(&self, key: Cell<bool>) -> bool;
|
||||
/// }
|
||||
///
|
||||
/// fn no_send_sync_value(_db: &dyn NoSendSyncDatabase, key: bool) -> Cell<bool> {
|
||||
/// Cell::new(key)
|
||||
/// }
|
||||
///
|
||||
/// fn no_send_sync_key(_db: &dyn NoSendSyncDatabase, key: Cell<bool>) -> bool {
|
||||
/// *key
|
||||
/// }
|
||||
///
|
||||
/// #[salsa::database(NoSendSyncStorage)]
|
||||
/// #[derive(Default)]
|
||||
/// struct DatabaseImpl {
|
||||
/// runtime: salsa::Storage<Self>,
|
||||
/// }
|
||||
///
|
||||
/// impl salsa::Database for DatabaseImpl {
|
||||
/// }
|
||||
///
|
||||
/// fn is_send<T: Send>(_: T) { }
|
||||
///
|
||||
/// fn assert_send() {
|
||||
/// is_send(DatabaseImpl::default());
|
||||
/// }
|
||||
/// ```
|
||||
fn test_key_not_sync_db_not_send() {}
|
||||
|
||||
/// Test that a database with a key/value that is not `Sync` will
|
||||
/// not be `Sync`.
|
||||
///
|
||||
/// ```compile_fail,E0277
|
||||
/// use std::cell::Cell;
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// #[salsa::query_group(NoSendSyncStorage)]
|
||||
/// trait NoSendSyncDatabase: salsa::Database {
|
||||
/// fn no_send_sync_value(&self, key: bool) -> Cell<bool>;
|
||||
/// fn no_send_sync_key(&self, key: Cell<bool>) -> bool;
|
||||
/// }
|
||||
///
|
||||
/// fn no_send_sync_value(_db: &dyn NoSendSyncDatabase, key: bool) -> Cell<bool> {
|
||||
/// Cell::new(key)
|
||||
/// }
|
||||
///
|
||||
/// fn no_send_sync_key(_db: &dyn NoSendSyncDatabase, key: Cell<bool>) -> bool {
|
||||
/// *key
|
||||
/// }
|
||||
///
|
||||
/// #[salsa::database(NoSendSyncStorage)]
|
||||
/// #[derive(Default)]
|
||||
/// struct DatabaseImpl {
|
||||
/// runtime: salsa::Storage<Self>,
|
||||
/// }
|
||||
///
|
||||
/// impl salsa::Database for DatabaseImpl {
|
||||
/// }
|
||||
///
|
||||
/// fn is_sync<T: Sync>(_: T) { }
|
||||
///
|
||||
/// fn assert_send() {
|
||||
/// is_sync(DatabaseImpl::default());
|
||||
/// }
|
||||
/// ```
|
||||
fn test_key_not_sync_db_not_sync() {}
|
|
@ -11,7 +11,6 @@
|
|||
//! from previous invocations as appropriate.
|
||||
|
||||
mod derived;
|
||||
mod doctest;
|
||||
mod durability;
|
||||
mod hash;
|
||||
mod input;
|
||||
|
|
Loading…
Reference in a new issue