diff --git a/CHANGELOG.md b/CHANGELOG.md index cccf5f07..8ee8849d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Rhai Release Notes Version 0.20.2 ============== +Breaking changes +---------------- + +* `Engine::disable_doc_comments` is removed because doc-comments are now placed under the `metadata` feature flag. + New features ------------ diff --git a/src/engine.rs b/src/engine.rs index 786fe039..29d3e103 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -804,11 +804,6 @@ pub struct Engine { /// Max limits. #[cfg(not(feature = "unchecked"))] pub(crate) limits: Limits, - - /// Disable doc-comments? - #[cfg(not(feature = "no_function"))] - #[cfg(feature = "metadata")] - pub(crate) disable_doc_comments: bool, } impl fmt::Debug for Engine { @@ -926,10 +921,6 @@ impl Engine { #[cfg(not(feature = "no_object"))] max_map_size: None, }, - - #[cfg(not(feature = "no_function"))] - #[cfg(feature = "metadata")] - disable_doc_comments: false, }; engine.global_namespace.set_internal(true); @@ -987,10 +978,6 @@ impl Engine { #[cfg(not(feature = "no_object"))] max_map_size: None, }, - - #[cfg(not(feature = "no_function"))] - #[cfg(feature = "metadata")] - disable_doc_comments: false, }; engine.global_namespace.set_internal(true); diff --git a/src/engine_settings.rs b/src/engine_settings.rs index ce6aa1e3..a995c71b 100644 --- a/src/engine_settings.rs +++ b/src/engine_settings.rs @@ -31,16 +31,6 @@ impl Engine { pub fn optimization_level(&self) -> crate::OptimizationLevel { self.optimization_level } - /// _(METADATA)_ Enable/disable doc-comments for functions. - /// Exported under the `metadata` feature only. - /// Not available under `no_function`. - #[cfg(not(feature = "no_function"))] - #[cfg(feature = "metadata")] - #[inline(always)] - pub fn enable_doc_comments(&mut self, enable: bool) -> &mut Self { - self.disable_doc_comments = !enable; - self - } /// Set the maximum levels of function calls allowed for a script in order to avoid /// infinite recursion and stack overflows. /// diff --git a/src/token.rs b/src/token.rs index ad4d6a44..44826444 100644 --- a/src/token.rs +++ b/src/token.rs @@ -973,10 +973,6 @@ pub struct TokenizeState { pub comment_level: usize, /// Include comments? pub include_comments: bool, - /// Disable doc-comments? - #[cfg(not(feature = "no_function"))] - #[cfg(feature = "metadata")] - pub disable_doc_comments: bool, /// Is the current tokenizer position within the text stream of an interpolated string? pub is_within_text_terminated_by: Option, } @@ -1357,12 +1353,11 @@ fn get_next_token_inner( #[cfg(not(feature = "no_function"))] #[cfg(feature = "metadata")] - let include_comments = - if !state.disable_doc_comments && is_doc_comment(comment.as_ref().unwrap()) { - true - } else { - include_comments - }; + let include_comments = if is_doc_comment(comment.as_ref().unwrap()) { + true + } else { + include_comments + }; if include_comments { return Some((Token::Comment(comment.unwrap()), start_pos)); @@ -1705,7 +1700,7 @@ fn get_next_token_inner( let mut comment = match stream.peek_next() { #[cfg(not(feature = "no_function"))] #[cfg(feature = "metadata")] - Some('/') if !state.disable_doc_comments => { + Some('/') => { eat_next(stream, pos); // Long streams of `///...` are not doc-comments @@ -1740,7 +1735,7 @@ fn get_next_token_inner( let mut comment = match stream.peek_next() { #[cfg(not(feature = "no_function"))] #[cfg(feature = "metadata")] - Some('*') if !state.disable_doc_comments => { + Some('*') => { eat_next(stream, pos); // Long streams of `/****...` are not doc-comments @@ -2239,9 +2234,6 @@ impl Engine { non_unary: false, comment_level: 0, include_comments: false, - #[cfg(not(feature = "no_function"))] - #[cfg(feature = "metadata")] - disable_doc_comments: self.disable_doc_comments, is_within_text_terminated_by: None, }, pos: Position::new(1, 0), diff --git a/tests/comments.rs b/tests/comments.rs index 91d7b200..695c47a4 100644 --- a/tests/comments.rs +++ b/tests/comments.rs @@ -30,7 +30,7 @@ fn test_comments() -> Result<(), Box> { #[cfg(feature = "metadata")] #[test] fn test_comments_doc() -> Result<(), Box> { - let mut engine = Engine::new(); + let engine = Engine::new(); let ast = engine.compile( " @@ -89,17 +89,5 @@ fn test_comments_doc() -> Result<(), Box> { ) .is_err()); - engine.enable_doc_comments(false); - - engine.compile( - " - /// Hello world! - let x = 42; - - /** Hello world! */ - let x = 42; - ", - )?; - Ok(()) }