diff options
author | Aleksey Kladov <[email protected]> | 2020-04-06 16:21:47 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-06 16:21:47 +0100 |
commit | 109bb1a7935e31d4ee3c036775a89ad0ac0e012b (patch) | |
tree | 28160f40d1cf3127304456ec3d2a171fc7948c61 | |
parent | f6d688d13070a54b288486900a30680d013c66ca (diff) | |
parent | 1b2d255be168333c136677599d2ea8b5a3f5996b (diff) |
Merge pull request #3867 from matklad/deny-eprintln
Check for eprintlns on CI
-rw-r--r-- | .github/workflows/ci.yaml | 2 | ||||
-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 |
8 files changed, 39 insertions, 13 deletions
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: | |||
10 | env: | 10 | env: |
11 | CARGO_INCREMENTAL: 0 | 11 | CARGO_INCREMENTAL: 0 |
12 | CARGO_NET_RETRY: 10 | 12 | CARGO_NET_RETRY: 10 |
13 | RUN_SLOW_TESTS: 1 | 13 | CI: 1 |
14 | RUST_BACKTRACE: short | 14 | RUST_BACKTRACE: short |
15 | RUSTFLAGS: -D warnings | 15 | RUSTFLAGS: -D warnings |
16 | RUSTUP_MAX_RETRIES: 10 | 16 | RUSTUP_MAX_RETRIES: 10 |
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 { |