diff options
author | Aleksey Kladov <[email protected]> | 2020-04-06 15:58:16 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-04-06 16:00:18 +0100 |
commit | bf569f8b29d05782597d40ec98ee33bc2574763e (patch) | |
tree | 68a7af10960f55c5d4c1d2b50fea6a8c9f28e1d3 | |
parent | 2603a9e628d304c8cb8fd08979e2f9c9afeac69e (diff) |
Check for eprintln on CI
-rw-r--r-- | crates/ra_assists/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir/src/semantics.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/ra_ide/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/rust-analyzer/src/lib.rs | 13 | ||||
-rw-r--r-- | 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 @@ | |||
5 | //! certain context. For example, if the cursor is over `,`, a "swap `,`" assist | 5 | //! certain context. For example, if the cursor is over `,`, a "swap `,`" assist |
6 | //! becomes available. | 6 | //! becomes available. |
7 | 7 | ||
8 | #[allow(unused)] | ||
9 | macro_rules! eprintln { | ||
10 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; | ||
11 | } | ||
12 | |||
8 | mod assist_ctx; | 13 | mod assist_ctx; |
9 | mod marks; | 14 | mod marks; |
10 | #[cfg(test)] | 15 | #[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::{ | |||
9 | AsMacroCall, TraitId, | 9 | AsMacroCall, TraitId, |
10 | }; | 10 | }; |
11 | use hir_expand::ExpansionInfo; | 11 | use hir_expand::ExpansionInfo; |
12 | use itertools::Itertools; | ||
12 | use ra_db::{FileId, FileRange}; | 13 | use ra_db::{FileId, FileRange}; |
13 | use ra_prof::profile; | 14 | use ra_prof::profile; |
14 | use ra_syntax::{ | 15 | use ra_syntax::{ |
@@ -135,7 +136,6 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
135 | node: &SyntaxNode, | 136 | node: &SyntaxNode, |
136 | offset: TextUnit, | 137 | offset: TextUnit, |
137 | ) -> impl Iterator<Item = SyntaxNode> + '_ { | 138 | ) -> impl Iterator<Item = SyntaxNode> + '_ { |
138 | use itertools::Itertools; | ||
139 | node.token_at_offset(offset) | 139 | node.token_at_offset(offset) |
140 | .map(|token| self.ancestors_with_macros(token.parent())) | 140 | .map(|token| self.ancestors_with_macros(token.parent())) |
141 | .kmerge_by(|node1, node2| node1.text_range().len() < node2.text_range().len()) | 141 | .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 @@ | |||
7 | //! Note that `hir_def` is a work in progress, so not all of the above is | 7 | //! Note that `hir_def` is a work in progress, so not all of the above is |
8 | //! actually true. | 8 | //! actually true. |
9 | 9 | ||
10 | #[allow(unused)] | ||
11 | macro_rules! eprintln { | ||
12 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; | ||
13 | } | ||
14 | |||
10 | pub mod db; | 15 | pub mod db; |
11 | 16 | ||
12 | pub mod attr; | 17 | 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 @@ | |||
1 | //! The type system. We currently use this to infer types for completion, hover | 1 | //! The type system. We currently use this to infer types for completion, hover |
2 | //! information and various assists. | 2 | //! information and various assists. |
3 | 3 | ||
4 | #[allow(unused)] | ||
5 | macro_rules! eprintln { | ||
6 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; | ||
7 | } | ||
8 | |||
4 | macro_rules! impl_froms { | 9 | macro_rules! impl_froms { |
5 | ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { | 10 | ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { |
6 | $( | 11 | $( |
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 @@ | |||
10 | // For proving that RootDatabase is RefUnwindSafe. | 10 | // For proving that RootDatabase is RefUnwindSafe. |
11 | #![recursion_limit = "128"] | 11 | #![recursion_limit = "128"] |
12 | 12 | ||
13 | #[allow(unused)] | ||
14 | macro_rules! eprintln { | ||
15 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; | ||
16 | } | ||
17 | |||
13 | pub mod mock_analysis; | 18 | pub mod mock_analysis; |
14 | mod source_change; | 19 | mod source_change; |
15 | 20 | ||
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 @@ | |||
13 | pub mod cli; | 13 | pub mod cli; |
14 | 14 | ||
15 | #[allow(unused)] | 15 | #[allow(unused)] |
16 | macro_rules! println { | 16 | macro_rules! eprintln { |
17 | ($($tt:tt)*) => { | 17 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; |
18 | compile_error!("stdout is locked, use eprintln") | ||
19 | }; | ||
20 | } | ||
21 | |||
22 | #[allow(unused)] | ||
23 | macro_rules! print { | ||
24 | ($($tt:tt)*) => { | ||
25 | compile_error!("stdout is locked, use eprint") | ||
26 | }; | ||
27 | } | 18 | } |
28 | 19 | ||
29 | mod vfs_glob; | 20 | 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 @@ | |||
2 | 2 | ||
3 | use std::{cell::Cell, fmt}; | 3 | use std::{cell::Cell, fmt}; |
4 | 4 | ||
5 | #[inline(always)] | ||
6 | pub fn is_ci() -> bool { | ||
7 | option_env!("CI").is_some() | ||
8 | } | ||
9 | |||
10 | #[macro_export] | ||
11 | macro_rules! eprintln { | ||
12 | ($($tt:tt)*) => {{ | ||
13 | if $crate::is_ci() { | ||
14 | panic!("Forgot to remove debug-print?") | ||
15 | } | ||
16 | std::eprintln!($($tt)*) | ||
17 | }} | ||
18 | } | ||
19 | |||
5 | /// Appends formatted string to a `String`. | 20 | /// Appends formatted string to a `String`. |
6 | #[macro_export] | 21 | #[macro_export] |
7 | macro_rules! format_to { | 22 | macro_rules! format_to { |