Remove salsa doc compile tests

This commit is contained in:
Lukas Wirth 2024-02-15 17:21:18 +01:00
parent dba59970bc
commit 1443d49b72
4 changed files with 23 additions and 140 deletions

View file

@ -11,7 +11,7 @@ extern crate rustc_driver as _;
mod rustc_wrapper; 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 anyhow::Context;
use lsp_server::Connection; use lsp_server::Connection;
@ -27,21 +27,15 @@ static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
#[global_allocator] #[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<ExitCode> {
if std::env::var("RA_RUSTC_WRAPPER").is_ok() { if std::env::var("RA_RUSTC_WRAPPER").is_ok() {
let mut args = std::env::args_os(); rustc_wrapper::main().map_err(Into::into)
let _me = args.next().unwrap(); } else {
let rustc = args.next().unwrap(); actual_main()
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);
} }
}
fn actual_main() -> anyhow::Result<ExitCode> {
let flags = flags::RustAnalyzer::from_env_or_exit(); let flags = flags::RustAnalyzer::from_env_or_exit();
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
@ -58,14 +52,14 @@ fn main() -> anyhow::Result<()> {
let verbosity = flags.verbosity(); let verbosity = flags.verbosity();
match flags.subcommand { match flags.subcommand {
flags::RustAnalyzerCmd::LspServer(cmd) => { flags::RustAnalyzerCmd::LspServer(cmd) => 'lsp_server: {
if cmd.print_config_schema { if cmd.print_config_schema {
println!("{:#}", Config::json_schema()); println!("{:#}", Config::json_schema());
return Ok(()); break 'lsp_server;
} }
if cmd.version { if cmd.version {
println!("rust-analyzer {}", rust_analyzer::version()); println!("rust-analyzer {}", rust_analyzer::version());
return Ok(()); break 'lsp_server;
} }
// rust-analyzers “main thread” is actually // rust-analyzers “main thread” is actually
@ -90,7 +84,7 @@ fn main() -> anyhow::Result<()> {
flags::RustAnalyzerCmd::RunTests(cmd) => cmd.run()?, flags::RustAnalyzerCmd::RunTests(cmd) => cmd.run()?,
flags::RustAnalyzerCmd::RustcTests(cmd) => cmd.run()?, flags::RustAnalyzerCmd::RustcTests(cmd) => cmd.run()?,
} }
Ok(()) Ok(ExitCode::SUCCESS)
} }
fn setup_logging(log_file_flag: Option<PathBuf>) -> anyhow::Result<()> { fn setup_logging(log_file_flag: Option<PathBuf>) -> anyhow::Result<()> {

View file

@ -7,13 +7,17 @@
use std::{ use std::{
ffi::OsString, ffi::OsString,
io, io,
process::{Command, Stdio}, process::{Command, ExitCode, Stdio},
}; };
/// ExitCode/ExitStatus are impossible to create :(. pub(crate) fn main() -> io::Result<ExitCode> {
pub(crate) struct ExitCode(pub(crate) Option<i32>); 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, rustc_executable: OsString,
args: Vec<OsString>, args: Vec<OsString>,
) -> io::Result<ExitCode> { ) -> 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") arg.starts_with("--emit=") && arg.contains("metadata") && !arg.contains("link")
}); });
if not_invoked_by_build_script && is_cargo_check { 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> { 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()) .stdout(Stdio::inherit())
.stderr(Stdio::inherit()) .stderr(Stdio::inherit())
.spawn()?; .spawn()?;
Ok(ExitCode(child.wait()?.code())) Ok(ExitCode::from(child.wait()?.code().unwrap_or(102) as u8))
} }

View file

@ -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() {}

View file

@ -11,7 +11,6 @@
//! from previous invocations as appropriate. //! from previous invocations as appropriate.
mod derived; mod derived;
mod doctest;
mod durability; mod durability;
mod hash; mod hash;
mod input; mod input;