aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_assists/src/lib.rs5
-rw-r--r--crates/ra_hir/src/semantics.rs2
-rw-r--r--crates/ra_hir_def/src/lib.rs5
-rw-r--r--crates/ra_hir_ty/src/lib.rs5
-rw-r--r--crates/ra_ide/src/lib.rs5
-rw-r--r--crates/rust-analyzer/src/lib.rs13
-rw-r--r--crates/stdx/src/lib.rs15
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)]
9macro_rules! eprintln {
10 ($($tt:tt)*) => { stdx::eprintln!($($tt)*) };
11}
12
8mod assist_ctx; 13mod assist_ctx;
9mod marks; 14mod 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};
11use hir_expand::ExpansionInfo; 11use hir_expand::ExpansionInfo;
12use itertools::Itertools;
12use ra_db::{FileId, FileRange}; 13use ra_db::{FileId, FileRange};
13use ra_prof::profile; 14use ra_prof::profile;
14use ra_syntax::{ 15use 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)]
11macro_rules! eprintln {
12 ($($tt:tt)*) => { stdx::eprintln!($($tt)*) };
13}
14
10pub mod db; 15pub mod db;
11 16
12pub mod attr; 17pub 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)]
5macro_rules! eprintln {
6 ($($tt:tt)*) => { stdx::eprintln!($($tt)*) };
7}
8
4macro_rules! impl_froms { 9macro_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)]
14macro_rules! eprintln {
15 ($($tt:tt)*) => { stdx::eprintln!($($tt)*) };
16}
17
13pub mod mock_analysis; 18pub mod mock_analysis;
14mod source_change; 19mod 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 @@
13pub mod cli; 13pub mod cli;
14 14
15#[allow(unused)] 15#[allow(unused)]
16macro_rules! println { 16macro_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)]
23macro_rules! print {
24 ($($tt:tt)*) => {
25 compile_error!("stdout is locked, use eprint")
26 };
27} 18}
28 19
29mod vfs_glob; 20mod 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
3use std::{cell::Cell, fmt}; 3use std::{cell::Cell, fmt};
4 4
5#[inline(always)]
6pub fn is_ci() -> bool {
7 option_env!("CI").is_some()
8}
9
10#[macro_export]
11macro_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]
7macro_rules! format_to { 22macro_rules! format_to {