Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid rust-analyzer recursion bug #734

Merged
merged 2 commits into from
Aug 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions relay-general/src/pii/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ use crate::processor::{
use crate::protocol::{AsPair, IpAddr, NativeImagePath, PairList, User};
use crate::types::{Meta, ProcessingAction, ProcessingResult, Remark, RemarkType};

// The Regex initializer needs a scope to avoid an endless loop/recursion in RustAnalyzer:
// https://github.com/rust-analyzer/rust-analyzer/issues/5896. Note that outside of lazy_static,
// this would require the unstable `stmt_expr_attributes` feature.
lazy_static! {
static ref NULL_SPLIT_RE: Regex = #[allow(clippy::trivial_regex)]
Regex::new("\x00").unwrap();
static ref NULL_SPLIT_RE: Regex = {
Copy link
Member

@untitaker untitaker Aug 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a code comment here if we're going to merge this. it's not obvious why formatting matters here and it's easy to regress when updating rustfmt

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is even invalid syntax in Rust. Without lazy_static, this would not compile as statement and expression attributes aren't stable.

#[allow(clippy::trivial_regex)]
Regex::new("\x00").unwrap()
};
}

/// A processor that performs PII stripping.
Expand Down