mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 21:13:37 +00:00
Merge pull request #3867 from matklad/deny-eprintln
Check for eprintlns on CI
This commit is contained in:
commit
109bb1a793
8 changed files with 39 additions and 13 deletions
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
|
@ -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
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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<Item = SyntaxNode> + '_ {
|
||||
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())
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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),*))?),*) => {
|
||||
$(
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue