From bf569f8b29d05782597d40ec98ee33bc2574763e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 6 Apr 2020 16:58:16 +0200 Subject: Check for eprintln on CI --- crates/ra_assists/src/lib.rs | 5 +++++ crates/ra_hir/src/semantics.rs | 2 +- crates/ra_hir_def/src/lib.rs | 5 +++++ crates/ra_hir_ty/src/lib.rs | 5 +++++ crates/ra_ide/src/lib.rs | 5 +++++ crates/rust-analyzer/src/lib.rs | 13 ++----------- crates/stdx/src/lib.rs | 15 +++++++++++++++ 7 files changed, 38 insertions(+), 12 deletions(-) diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index fa3d3913f..c698d6e8c 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs @@ -5,6 +5,11 @@ //! certain context. For example, if the cursor is over `,`, a "swap `,`" assist //! becomes available. +#[allow(unused)] +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; +} + mod assist_ctx; mod marks; #[cfg(test)] diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 16a5fe968..2ad231d36 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -9,6 +9,7 @@ use hir_def::{ AsMacroCall, TraitId, }; use hir_expand::ExpansionInfo; +use itertools::Itertools; use ra_db::{FileId, FileRange}; use ra_prof::profile; use ra_syntax::{ @@ -135,7 +136,6 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { node: &SyntaxNode, offset: TextUnit, ) -> impl Iterator + '_ { - use itertools::Itertools; node.token_at_offset(offset) .map(|token| self.ancestors_with_macros(token.parent())) .kmerge_by(|node1, node2| node1.text_range().len() < node2.text_range().len()) diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index bd32ac20a..2d27bbdf8 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -7,6 +7,11 @@ //! Note that `hir_def` is a work in progress, so not all of the above is //! actually true. +#[allow(unused)] +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; +} + pub mod db; pub mod attr; diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index a9022dee7..9d61bba40 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -1,6 +1,11 @@ //! The type system. We currently use this to infer types for completion, hover //! information and various assists. +#[allow(unused)] +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; +} + macro_rules! impl_froms { ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { $( diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 285381086..5599f143f 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -10,6 +10,11 @@ // For proving that RootDatabase is RefUnwindSafe. #![recursion_limit = "128"] +#[allow(unused)] +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; +} + pub mod mock_analysis; mod source_change; diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs index 02953be30..036bf62a7 100644 --- a/crates/rust-analyzer/src/lib.rs +++ b/crates/rust-analyzer/src/lib.rs @@ -13,17 +13,8 @@ pub mod cli; #[allow(unused)] -macro_rules! println { - ($($tt:tt)*) => { - compile_error!("stdout is locked, use eprintln") - }; -} - -#[allow(unused)] -macro_rules! print { - ($($tt:tt)*) => { - compile_error!("stdout is locked, use eprint") - }; +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; } mod vfs_glob; diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index d2efa2236..401a568bd 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs @@ -2,6 +2,21 @@ use std::{cell::Cell, fmt}; +#[inline(always)] +pub fn is_ci() -> bool { + option_env!("CI").is_some() +} + +#[macro_export] +macro_rules! eprintln { + ($($tt:tt)*) => {{ + if $crate::is_ci() { + panic!("Forgot to remove debug-print?") + } + std::eprintln!($($tt)*) + }} +} + /// Appends formatted string to a `String`. #[macro_export] macro_rules! format_to { -- cgit v1.2.3 From 1b2d255be168333c136677599d2ea8b5a3f5996b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 6 Apr 2020 17:01:46 +0200 Subject: More general CI env var --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 217f17975..02a3b6228 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ on: env: CARGO_INCREMENTAL: 0 CARGO_NET_RETRY: 10 - RUN_SLOW_TESTS: 1 + CI: 1 RUST_BACKTRACE: short RUSTFLAGS: -D warnings RUSTUP_MAX_RETRIES: 10 -- cgit v1.2.3