diff --git a/crates/parser/src/lexed_str.rs b/crates/parser/src/lexed_str.rs index 7c78ba8faf5f..46d70487170d 100644 --- a/crates/parser/src/lexed_str.rs +++ b/crates/parser/src/lexed_str.rs @@ -35,6 +35,7 @@ struct LexError { impl<'a> LexedStr<'a> { pub fn new(edition: Edition, text: &'a str) -> LexedStr<'a> { + #[cfg(feature = "tracing")] let _p = tracing::info_span!("LexedStr::new").entered(); let mut conv = Converter::new(edition, text); if let Ok(script) = crate::frontmatter::ScriptSource::parse(text) { diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index 53444ef52cff..474372f23361 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -89,6 +89,7 @@ pub enum TopEntryPoint { impl TopEntryPoint { pub fn parse(&self, input: &Input, edition: Edition) -> Output { + #[cfg(feature = "tracing")] let _p = tracing::info_span!("TopEntryPoint::parse", ?self).entered(); let entry_point: fn(&'_ mut parser::Parser<'_>) = match self { TopEntryPoint::SourceFile => grammar::entry::top::source_file, diff --git a/crates/parser/src/shortcuts.rs b/crates/parser/src/shortcuts.rs index d5e513933f7a..cbe29935f4d3 100644 --- a/crates/parser/src/shortcuts.rs +++ b/crates/parser/src/shortcuts.rs @@ -26,6 +26,7 @@ pub enum StrStep<'a> { impl LexedStr<'_> { pub fn to_input(&self, edition: Edition) -> crate::Input { + #[cfg(feature = "tracing")] let _p = tracing::info_span!("LexedStr::to_input").entered(); let mut res = crate::Input::with_capacity(self.len()); let mut was_joint = false; diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index 1ee93013e3e8..06307d0c9329 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml @@ -20,7 +20,7 @@ rustc-hash.workspace = true rustc-literal-escaper.workspace = true smol_str.workspace = true triomphe.workspace = true -tracing.workspace = true +tracing = { workspace = true, optional = true } parser.workspace = true stdx.workspace = true @@ -33,6 +33,7 @@ rustc_apfloat = "0.2.3" test-utils.workspace = true [features] +default = ["tracing"] in-rust-tree = [] [lints] diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs index 7346b9319248..f73ef1b7af7e 100644 --- a/crates/syntax/src/lib.rs +++ b/crates/syntax/src/lib.rs @@ -187,6 +187,7 @@ impl ast::Expr { /// ast::Expr::parse("let fail = true;", Edition::CURRENT).tree(); /// ``` pub fn parse(text: &str, edition: Edition) -> Parse { + #[cfg(feature = "tracing")] let _p = tracing::info_span!("Expr::parse").entered(); let (green, errors) = parsing::parse_text_at(text, parser::TopEntryPoint::Expr, edition); let root = SyntaxNode::new_root(green.clone()); @@ -227,6 +228,7 @@ pub use crate::ast::SourceFile; impl SourceFile { pub fn parse(text: &str, edition: Edition) -> Parse { + #[cfg(feature = "tracing")] let _p = tracing::info_span!("SourceFile::parse").entered(); let (green, errors) = parsing::parse_text(text, edition); let root = SyntaxNode::new_root(green.clone()); diff --git a/crates/syntax/src/parsing.rs b/crates/syntax/src/parsing.rs index 9e286edc5f98..f8fdeea8fc1a 100644 --- a/crates/syntax/src/parsing.rs +++ b/crates/syntax/src/parsing.rs @@ -10,6 +10,7 @@ use crate::{SyntaxError, SyntaxTreeBuilder, syntax_node::GreenNode}; pub(crate) use crate::parsing::reparsing::incremental_reparse; pub(crate) fn parse_text(text: &str, edition: parser::Edition) -> (GreenNode, Vec) { + #[cfg(feature = "tracing")] let _p = tracing::info_span!("parse_text").entered(); let lexed = parser::LexedStr::new(edition, text); let parser_input = lexed.to_input(edition); @@ -23,6 +24,7 @@ pub(crate) fn parse_text_at( entry: parser::TopEntryPoint, edition: parser::Edition, ) -> (GreenNode, Vec) { + #[cfg(feature = "tracing")] let _p = tracing::info_span!("parse_text_at").entered(); let lexed = parser::LexedStr::new(edition, text); let parser_input = lexed.to_input(edition); @@ -35,6 +37,7 @@ pub(crate) fn build_tree( lexed: parser::LexedStr<'_>, parser_output: parser::Output, ) -> (GreenNode, Vec, bool) { + #[cfg(feature = "tracing")] let _p = tracing::info_span!("build_tree").entered(); let mut builder = SyntaxTreeBuilder::default(); diff --git a/crates/syntax/src/validation.rs b/crates/syntax/src/validation.rs index 485140be8f69..42323308ffe1 100644 --- a/crates/syntax/src/validation.rs +++ b/crates/syntax/src/validation.rs @@ -19,6 +19,7 @@ use crate::{ }; pub(crate) fn validate(root: &SyntaxNode, errors: &mut Vec) { + #[cfg(feature = "tracing")] let _p = tracing::info_span!("parser::validate").entered(); // FIXME: // * Add unescape validation of raw string literals and raw byte string literals