diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index bca4c6e93eef..3c06a996ff2d 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -124,7 +124,7 @@ jobs: name: Package ${{ matrix.code-target }} runs-on: ${{ matrix.os }} container: - image: rust:1.88.0-bullseye@sha256:b315f988b86912bafa7afd39a6ded0a497bf850ec36578ca9a3bdd6a14d5db4e + image: rust:1.89.0-bullseye@sha256:6dd47db91f6637af2cb581979d1b01164826780591edba9859a6cb24b48da7b8 env: version: ${{ needs.version.outputs.version }} diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 88c0109abae1..0a91e76b94d0 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -116,7 +116,7 @@ jobs: name: Package ${{ matrix.code-target }} runs-on: ${{ matrix.os }} container: - image: rust:1.88.0-bullseye@sha256:b315f988b86912bafa7afd39a6ded0a497bf850ec36578ca9a3bdd6a14d5db4e + image: rust:1.89.0-bullseye@sha256:6dd47db91f6637af2cb581979d1b01164826780591edba9859a6cb24b48da7b8 steps: - name: Checkout repository diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d96a68d5fa25..35c1ff073cb0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -182,7 +182,7 @@ jobs: name: Package ${{ matrix.code-target }} runs-on: ${{ matrix.os }} container: - image: rust:1.88.0-bullseye@sha256:b315f988b86912bafa7afd39a6ded0a497bf850ec36578ca9a3bdd6a14d5db4e + image: rust:1.89.0-bullseye@sha256:6dd47db91f6637af2cb581979d1b01164826780591edba9859a6cb24b48da7b8 steps: - name: Checkout repository diff --git a/Dockerfile.benchmark b/Dockerfile.benchmark index 0023e29bdd78..289e1aef999e 100644 --- a/Dockerfile.benchmark +++ b/Dockerfile.benchmark @@ -1,9 +1,9 @@ # syntax=docker/dockerfile:1@sha256:9857836c9ee4268391bb5b09f9f157f3c91bb15821bb77969642813b0d00518d -FROM rust:1.88.0@sha256:af306cfa71d987911a781c37b59d7d67d934f49684058f96cf72079c3626bfe0 +FROM rust:1.89.0-bookworm@sha256:c50cd6e20c46b0b36730b5eb27289744e4bb8f32abc90d8c64ca09decf4f55ba WORKDIR /usr/src/ # https://github.com/nodesource/distributions -RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs +RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && apt-get install -y nodejs RUN cargo install hyperfine COPY Cargo.toml Cargo.lock ./ diff --git a/crates/biome_analyze/src/matcher.rs b/crates/biome_analyze/src/matcher.rs index 58b12f53380b..81a0df6da6f6 100644 --- a/crates/biome_analyze/src/matcher.rs +++ b/crates/biome_analyze/src/matcher.rs @@ -362,7 +362,7 @@ mod tests { fn parse_suppression_comment( comment: &str, _piece_range: TextRange, - ) -> Vec> { + ) -> Vec, Infallible>> { comment .trim_start_matches("//") .split(' ') diff --git a/crates/biome_cli/src/diagnostics.rs b/crates/biome_cli/src/diagnostics.rs index 418529014638..4e8a7bb9a600 100644 --- a/crates/biome_cli/src/diagnostics.rs +++ b/crates/biome_cli/src/diagnostics.rs @@ -257,17 +257,6 @@ pub struct MigrationDiagnostic { pub reason: String, } -#[derive(Debug, Diagnostic)] -#[diagnostic( - category = "internalError/fs", - severity = Warning, - tags(DEPRECATED_CODE) -)] -pub struct DeprecatedArgument { - #[message] - pub message: MessageAndDescription, -} - #[derive(Debug, Diagnostic)] pub enum ReportDiagnostic { /// Emitted when trying to serialise the report diff --git a/crates/biome_control_flow/src/builder.rs b/crates/biome_control_flow/src/builder.rs index 57f70a1842ac..9669367d5e4c 100644 --- a/crates/biome_control_flow/src/builder.rs +++ b/crates/biome_control_flow/src/builder.rs @@ -109,7 +109,7 @@ impl FunctionBuilder { } /// Insert an instruction at the current position of the cursor - fn append_instruction(&mut self, kind: InstructionKind) -> InstructionBuilder { + fn append_instruction(&mut self, kind: InstructionKind) -> InstructionBuilder<'_, L> { let index = self.block_cursor.index as usize; let block = &mut self.result.blocks[index]; @@ -119,15 +119,15 @@ impl FunctionBuilder { InstructionBuilder(&mut block.instructions[index]) } - pub fn append_statement(&mut self) -> InstructionBuilder { + pub fn append_statement(&mut self) -> InstructionBuilder<'_, L> { self.append_instruction(InstructionKind::Statement) } - pub fn append_return(&mut self) -> InstructionBuilder { + pub fn append_return(&mut self) -> InstructionBuilder<'_, L> { self.append_instruction(InstructionKind::Return) } - pub fn append_jump(&mut self, conditional: bool, block: BlockId) -> InstructionBuilder { + pub fn append_jump(&mut self, conditional: bool, block: BlockId) -> InstructionBuilder<'_, L> { self.append_instruction(InstructionKind::Jump { conditional, block, @@ -135,7 +135,7 @@ impl FunctionBuilder { }) } - pub fn append_finally_fallthrough(&mut self, block: BlockId) -> InstructionBuilder { + pub fn append_finally_fallthrough(&mut self, block: BlockId) -> InstructionBuilder<'_, L> { self.append_instruction(InstructionKind::Jump { conditional: false, block, diff --git a/crates/biome_css_analyze/src/lib.rs b/crates/biome_css_analyze/src/lib.rs index eb1179c7a358..3e51165675ae 100644 --- a/crates/biome_css_analyze/src/lib.rs +++ b/crates/biome_css_analyze/src/lib.rs @@ -70,7 +70,7 @@ where fn parse_linter_suppression_comment( text: &str, piece_range: TextRange, - ) -> Vec> { + ) -> Vec, SuppressionDiagnostic>> { let mut result = Vec::new(); for suppression in parse_suppression_comment(text) { diff --git a/crates/biome_css_formatter/src/trivia.rs b/crates/biome_css_formatter/src/trivia.rs index 5196e8901b74..214d012172c2 100644 --- a/crates/biome_css_formatter/src/trivia.rs +++ b/crates/biome_css_formatter/src/trivia.rs @@ -12,7 +12,7 @@ pub(crate) struct FormatRemoved<'a> { token: &'a CssSyntaxToken, } -pub(crate) fn format_removed(token: &CssSyntaxToken) -> FormatRemoved { +pub(crate) fn format_removed(token: &CssSyntaxToken) -> FormatRemoved<'_> { FormatRemoved { token } } diff --git a/crates/biome_css_formatter/src/utils/string_utils.rs b/crates/biome_css_formatter/src/utils/string_utils.rs index d3d57c9d303c..add691170602 100644 --- a/crates/biome_css_formatter/src/utils/string_utils.rs +++ b/crates/biome_css_formatter/src/utils/string_utils.rs @@ -71,7 +71,7 @@ impl<'token> FormatLiteralStringToken<'token> { self.token } - pub fn clean_text(&self, options: &CssFormatOptions) -> CleanedStringLiteralText { + pub fn clean_text(&self, options: &CssFormatOptions) -> CleanedStringLiteralText<'_> { let token = self.token(); debug_assert!( matches!( diff --git a/crates/biome_css_formatter/src/verbatim.rs b/crates/biome_css_formatter/src/verbatim.rs index 214a0cda9b40..fc0a12e879b5 100644 --- a/crates/biome_css_formatter/src/verbatim.rs +++ b/crates/biome_css_formatter/src/verbatim.rs @@ -20,7 +20,7 @@ use biome_rowan::{AstNode, Direction, SyntaxElement, TextRange}; /// /// These nodes and tokens get tracked as [VerbatimKind::Verbatim], useful to understand /// if these nodes still need to have their own implementation. -pub fn format_css_verbatim_node(node: &CssSyntaxNode) -> FormatCssVerbatimNode { +pub fn format_css_verbatim_node(node: &CssSyntaxNode) -> FormatCssVerbatimNode<'_> { FormatCssVerbatimNode { node, kind: VerbatimKind::Verbatim { @@ -150,7 +150,7 @@ impl Format for FormatCssVerbatimNode<'_> { /// Formats bogus nodes. The difference between this method and `format_verbatim` is that this method /// doesn't track nodes/tokens as [VerbatimKind::Verbatim]. They are just printed as they are. -pub fn format_bogus_node(node: &CssSyntaxNode) -> FormatCssVerbatimNode { +pub fn format_bogus_node(node: &CssSyntaxNode) -> FormatCssVerbatimNode<'_> { FormatCssVerbatimNode { node, kind: VerbatimKind::Bogus, @@ -159,7 +159,7 @@ pub fn format_bogus_node(node: &CssSyntaxNode) -> FormatCssVerbatimNode { } /// Format a node having formatter suppression comment applied to it -pub fn format_suppressed_node(node: &CssSyntaxNode) -> FormatCssVerbatimNode { +pub fn format_suppressed_node(node: &CssSyntaxNode) -> FormatCssVerbatimNode<'_> { FormatCssVerbatimNode { node, kind: VerbatimKind::Suppressed, diff --git a/crates/biome_formatter/src/buffer.rs b/crates/biome_formatter/src/buffer.rs index f20e32aec029..06332fbb234e 100644 --- a/crates/biome_formatter/src/buffer.rs +++ b/crates/biome_formatter/src/buffer.rs @@ -685,7 +685,7 @@ impl Buffer for RemoveSoftLinesBuffer<'_, Context> { pub trait BufferExtensions: Buffer + Sized { /// Returns a new buffer that calls the passed inspector for every element that gets written to the output #[must_use] - fn inspect(&mut self, inspector: F) -> Inspect + fn inspect(&mut self, inspector: F) -> Inspect<'_, Self::Context, F> where F: FnMut(&FormatElement), { @@ -730,7 +730,7 @@ pub trait BufferExtensions: Buffer + Sized { /// # } /// ``` #[must_use] - fn start_recording(&mut self) -> Recording { + fn start_recording(&mut self) -> Recording<'_, Self> { Recording::new(self) } diff --git a/crates/biome_formatter/src/builders.rs b/crates/biome_formatter/src/builders.rs index 808d34c35cbd..802ae824aa10 100644 --- a/crates/biome_formatter/src/builders.rs +++ b/crates/biome_formatter/src/builders.rs @@ -276,7 +276,7 @@ impl std::fmt::Debug for StaticText { } /// Creates a text from a dynamic string and a range of the input source -pub fn dynamic_text(text: &str, position: TextSize) -> DynamicText { +pub fn dynamic_text(text: &str, position: TextSize) -> DynamicText<'_> { debug_assert_no_newlines(text); DynamicText { text, position } @@ -420,7 +420,7 @@ fn debug_assert_no_newlines(text: &str) { /// # } /// ``` #[inline] -pub fn line_suffix(inner: &Content) -> LineSuffix +pub fn line_suffix(inner: &Content) -> LineSuffix<'_, Context> where Content: Format, { @@ -550,7 +550,10 @@ impl Format for LineSuffixBoundary { /// Use `Memoized.inspect(f)?.has_label(LabelId::of(MyLabels::Main)` if you need to know if some content breaks that should /// only be written later. #[inline] -pub fn labelled(label_id: LabelId, content: &Content) -> FormatLabelled +pub fn labelled( + label_id: LabelId, + content: &Content, +) -> FormatLabelled<'_, Context> where Content: Format, { @@ -772,7 +775,7 @@ impl Format for HardSpace { /// # } /// ``` #[inline] -pub fn indent(content: &Content) -> Indent +pub fn indent(content: &Content) -> Indent<'_, Context> where Content: Format, { @@ -929,7 +932,7 @@ impl std::fmt::Debug for Indent<'_, Context> { /// # } /// ``` #[inline] -pub fn dedent(content: &Content) -> Dedent +pub fn dedent(content: &Content) -> Dedent<'_, Context> where Content: Format, { @@ -1002,7 +1005,7 @@ impl std::fmt::Debug for Dedent<'_, Context> { /// /// This resembles the behaviour of Prettier's `align(Number.NEGATIVE_INFINITY, content)` IR element. #[inline] -pub fn dedent_to_root(content: &Content) -> Dedent +pub fn dedent_to_root(content: &Content) -> Dedent<'_, Context> where Content: Format, { @@ -1115,7 +1118,7 @@ where /// /// * tab indention: Printer indents the expression with two tabs because the `align` increases the indention level. /// * space indention: Printer indents the expression by 4 spaces (one indention level) **and** 2 spaces for the align. -pub fn align(count: u8, content: &Content) -> Align +pub fn align(count: u8, content: &Content) -> Align<'_, Context> where Content: Format, { @@ -1183,7 +1186,7 @@ impl std::fmt::Debug for Align<'_, Context> { /// # } /// ``` #[inline] -pub fn block_indent(content: &impl Format) -> BlockIndent { +pub fn block_indent(content: &impl Format) -> BlockIndent<'_, Context> { BlockIndent { content: Argument::new(content), mode: IndentMode::Block, @@ -1254,7 +1257,7 @@ pub fn block_indent(content: &impl Format) -> BlockIndent(content: &impl Format) -> BlockIndent { +pub fn soft_block_indent(content: &impl Format) -> BlockIndent<'_, Context> { BlockIndent { content: Argument::new(content), mode: IndentMode::Soft, @@ -1357,7 +1360,7 @@ pub fn soft_block_indent(content: &impl Format) -> BlockIndent pub fn soft_block_indent_with_maybe_space( content: &impl Format, should_add_space: bool, -) -> BlockIndent { +) -> BlockIndent<'_, Context> { if should_add_space { soft_space_or_block_indent(content) } else { @@ -1432,7 +1435,9 @@ pub fn soft_block_indent_with_maybe_space( /// # } /// ``` #[inline] -pub fn soft_line_indent_or_space(content: &impl Format) -> BlockIndent { +pub fn soft_line_indent_or_space( + content: &impl Format, +) -> BlockIndent<'_, Context> { BlockIndent { content: Argument::new(content), mode: IndentMode::SoftLineOrSpace, @@ -1534,7 +1539,7 @@ pub fn soft_line_indent_or_space(content: &impl Format) -> Blo #[inline] pub fn soft_line_indent_or_hard_space( content: &impl Format, -) -> BlockIndent { +) -> BlockIndent<'_, Context> { BlockIndent { content: Argument::new(content), mode: IndentMode::HardSpace, @@ -1670,7 +1675,9 @@ impl std::fmt::Debug for BlockIndent<'_, Context> { /// # Ok(()) /// # } /// ``` -pub fn soft_space_or_block_indent(content: &impl Format) -> BlockIndent { +pub fn soft_space_or_block_indent( + content: &impl Format, +) -> BlockIndent<'_, Context> { BlockIndent { content: Argument::new(content), mode: IndentMode::SoftSpace, @@ -1750,7 +1757,7 @@ pub fn soft_space_or_block_indent(content: &impl Format) -> Bl /// # } /// ``` #[inline] -pub fn group(content: &impl Format) -> Group { +pub fn group(content: &impl Format) -> Group<'_, Context> { Group { content: Argument::new(content), group_id: None, @@ -1933,7 +1940,7 @@ impl Format for ExpandParent { /// # } /// ``` #[inline] -pub fn if_group_breaks(content: &Content) -> IfGroupBreaks +pub fn if_group_breaks(content: &Content) -> IfGroupBreaks<'_, Context> where Content: Format, { @@ -2014,7 +2021,7 @@ where /// # } /// ``` #[inline] -pub fn if_group_fits_on_line(flat_content: &Content) -> IfGroupBreaks +pub fn if_group_fits_on_line(flat_content: &Content) -> IfGroupBreaks<'_, Context> where Content: Format, { @@ -2200,7 +2207,7 @@ impl std::fmt::Debug for IfGroupBreaks<'_, Context> { pub fn indent_if_group_breaks( content: &Content, group_id: GroupId, -) -> IndentIfGroupBreaks +) -> IndentIfGroupBreaks<'_, Context> where Content: Format, { diff --git a/crates/biome_formatter/src/comments/map.rs b/crates/biome_formatter/src/comments/map.rs index bb1b2fb044f0..da5a50f513f8 100644 --- a/crates/biome_formatter/src/comments/map.rs +++ b/crates/biome_formatter/src/comments/map.rs @@ -240,7 +240,7 @@ impl CommentsMap { } /// Returns an iterator over all leading, dangling, and trailing parts of `key`. - pub fn parts(&self, key: &K) -> PartsIterator { + pub fn parts(&self, key: &K) -> PartsIterator<'_, V> { match self.index.get(key) { None => PartsIterator::Slice([].iter()), Some(entry) => PartsIterator::from_entry(entry, self), diff --git a/crates/biome_formatter/src/format_element.rs b/crates/biome_formatter/src/format_element.rs index 750840547eaf..938003ea845c 100644 --- a/crates/biome_formatter/src/format_element.rs +++ b/crates/biome_formatter/src/format_element.rs @@ -168,7 +168,7 @@ pub const LINE_TERMINATORS: [char; 3] = ['\r', LINE_SEPARATOR, PARAGRAPH_SEPARAT /// Replace the line terminators matching the provided list with "\n" /// since its the only line break type supported by the printer -pub fn normalize_newlines(text: &str, terminators: [char; N]) -> Cow { +pub fn normalize_newlines(text: &str, terminators: [char; N]) -> Cow<'_, str> { let mut result = String::new(); let mut last_end = 0; diff --git a/crates/biome_formatter/src/separated.rs b/crates/biome_formatter/src/separated.rs index 2b22cb56afc0..01cc109e75df 100644 --- a/crates/biome_formatter/src/separated.rs +++ b/crates/biome_formatter/src/separated.rs @@ -22,7 +22,7 @@ where } /// Formats a single element inside a separated list. -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Debug, Clone)] pub struct FormatSeparatedElement where N: AstNode, diff --git a/crates/biome_formatter/src/source_map.rs b/crates/biome_formatter/src/source_map.rs index 4503205e522f..3ef6f2b786c1 100644 --- a/crates/biome_formatter/src/source_map.rs +++ b/crates/biome_formatter/src/source_map.rs @@ -139,7 +139,7 @@ impl TransformSourceMap { } /// Returns an iterator over all deleted ranges in increasing order by their start position. - pub fn deleted_ranges(&self) -> DeletedRanges { + pub fn deleted_ranges(&self) -> DeletedRanges<'_> { DeletedRanges { source_text: self.source(), deleted_ranges: self.deleted_ranges.iter(), diff --git a/crates/biome_formatter/src/token/number.rs b/crates/biome_formatter/src/token/number.rs index cbb8489cbfe4..182923b6aa0f 100644 --- a/crates/biome_formatter/src/token/number.rs +++ b/crates/biome_formatter/src/token/number.rs @@ -37,7 +37,7 @@ struct FormatNumberLiteralExponent { first_non_zero_index: Option, } // Regex-free version of https://github.com/prettier/prettier/blob/ca246afacee8e6d5db508dae01730c9523bbff1d/src/common/util.js#L341-L356 -pub fn format_trimmed_number(text: &str, options: NumberFormatOptions) -> Cow { +pub fn format_trimmed_number(text: &str, options: NumberFormatOptions) -> Cow<'_, str> { use FormatNumberLiteralState::*; let text = text.to_ascii_lowercase_cow(); diff --git a/crates/biome_formatter/src/token/string.rs b/crates/biome_formatter/src/token/string.rs index 9a20da63ba38..82c340e150e2 100644 --- a/crates/biome_formatter/src/token/string.rs +++ b/crates/biome_formatter/src/token/string.rs @@ -48,7 +48,7 @@ pub fn normalize_string( raw_content: &str, preferred_quote: Quote, quotes_will_change: bool, -) -> Cow { +) -> Cow<'_, str> { let alternate_quote = preferred_quote.other().as_byte(); let preferred_quote = preferred_quote.as_byte(); let mut reduced_string = String::new(); diff --git a/crates/biome_formatter/src/trivia.rs b/crates/biome_formatter/src/trivia.rs index ef9f48c7bd9d..f965245b1fd3 100644 --- a/crates/biome_formatter/src/trivia.rs +++ b/crates/biome_formatter/src/trivia.rs @@ -43,7 +43,7 @@ pub fn should_nestle_adjacent_doc_comments( /// Formats the leading comments of `node` pub const fn format_leading_comments( node: &SyntaxNode, -) -> FormatLeadingComments { +) -> FormatLeadingComments<'_, L> { FormatLeadingComments::Node(node) } @@ -108,7 +108,7 @@ where /// Formats the trailing comments of `node`. pub const fn format_trailing_comments( node: &SyntaxNode, -) -> FormatTrailingComments { +) -> FormatTrailingComments<'_, L> { FormatTrailingComments::Node(node) } @@ -207,7 +207,7 @@ where /// Formats the dangling comments of `node`. pub const fn format_dangling_comments( node: &SyntaxNode, -) -> FormatDanglingComments { +) -> FormatDanglingComments<'_, L> { FormatDanglingComments::Node { node, indent: DanglingIndentMode::None, @@ -605,7 +605,7 @@ where /// Formats the skipped token trivia of `token`. pub const fn format_skipped_token_trivia( token: &SyntaxToken, -) -> FormatSkippedTokenTrivia { +) -> FormatSkippedTokenTrivia<'_, L> { FormatSkippedTokenTrivia { token } } diff --git a/crates/biome_formatter_test/src/spec.rs b/crates/biome_formatter_test/src/spec.rs index 18ca78ebb2ac..f85f383fe0a7 100644 --- a/crates/biome_formatter_test/src/spec.rs +++ b/crates/biome_formatter_test/src/spec.rs @@ -292,7 +292,7 @@ where snapshot_builder.finish(self.test_file.relative_file_name()); } - fn test_file(&self) -> &SpecTestFile { + fn test_file(&self) -> &SpecTestFile<'_> { &self.test_file } } diff --git a/crates/biome_formatter_test/src/test_prettier_snapshot.rs b/crates/biome_formatter_test/src/test_prettier_snapshot.rs index 3d2c2e6c5591..6e1f1ae85c17 100644 --- a/crates/biome_formatter_test/src/test_prettier_snapshot.rs +++ b/crates/biome_formatter_test/src/test_prettier_snapshot.rs @@ -206,7 +206,7 @@ where builder.finish(relative_file_name); } - fn test_file(&self) -> &PrettierTestFile { + fn test_file(&self) -> &PrettierTestFile<'_> { &self.test_file } } diff --git a/crates/biome_graphql_analyze/src/lib.rs b/crates/biome_graphql_analyze/src/lib.rs index 0be1bf667516..e7b4d35dc183 100644 --- a/crates/biome_graphql_analyze/src/lib.rs +++ b/crates/biome_graphql_analyze/src/lib.rs @@ -63,7 +63,7 @@ where fn parse_linter_suppression_comment( text: &str, piece_range: TextRange, - ) -> Vec> { + ) -> Vec, SuppressionDiagnostic>> { let mut result = Vec::new(); for suppression in parse_suppression_comment(text) { diff --git a/crates/biome_graphql_formatter/src/trivia.rs b/crates/biome_graphql_formatter/src/trivia.rs index ad2f8a0692ee..f0e977715505 100644 --- a/crates/biome_graphql_formatter/src/trivia.rs +++ b/crates/biome_graphql_formatter/src/trivia.rs @@ -9,7 +9,7 @@ pub(crate) struct FormatRemoved<'a> { token: &'a GraphqlSyntaxToken, } -pub(crate) fn format_removed(token: &GraphqlSyntaxToken) -> FormatRemoved { +pub(crate) fn format_removed(token: &GraphqlSyntaxToken) -> FormatRemoved<'_> { FormatRemoved { token } } diff --git a/crates/biome_graphql_formatter/src/verbatim.rs b/crates/biome_graphql_formatter/src/verbatim.rs index fec0d2614392..23c27b3b0208 100644 --- a/crates/biome_graphql_formatter/src/verbatim.rs +++ b/crates/biome_graphql_formatter/src/verbatim.rs @@ -21,7 +21,7 @@ use biome_rowan::{AstNode, Direction, SyntaxElement, TextRange}; /// These nodes and tokens get tracked as [VerbatimKind::Verbatim], useful to understand /// if these nodes still need to have their own implementation. #[expect(unused)] -pub fn format_graphql_verbatim_node(node: &GraphqlSyntaxNode) -> FormatGraphqlVerbatimNode { +pub fn format_graphql_verbatim_node(node: &GraphqlSyntaxNode) -> FormatGraphqlVerbatimNode<'_> { FormatGraphqlVerbatimNode { node, kind: VerbatimKind::Verbatim { @@ -151,7 +151,7 @@ impl Format for FormatGraphqlVerbatimNode<'_> { /// Formats bogus nodes. The difference between this method and `format_verbatim` is that this method /// doesn't track nodes/tokens as [VerbatimKind::Verbatim]. They are just printed as they are. -pub fn format_bogus_node(node: &GraphqlSyntaxNode) -> FormatGraphqlVerbatimNode { +pub fn format_bogus_node(node: &GraphqlSyntaxNode) -> FormatGraphqlVerbatimNode<'_> { FormatGraphqlVerbatimNode { node, kind: VerbatimKind::Bogus, @@ -160,7 +160,7 @@ pub fn format_bogus_node(node: &GraphqlSyntaxNode) -> FormatGraphqlVerbatimNode } /// Format a node having formatter suppression comment applied to it -pub fn format_suppressed_node(node: &GraphqlSyntaxNode) -> FormatGraphqlVerbatimNode { +pub fn format_suppressed_node(node: &GraphqlSyntaxNode) -> FormatGraphqlVerbatimNode<'_> { FormatGraphqlVerbatimNode { node, kind: VerbatimKind::Suppressed, diff --git a/crates/biome_grit_formatter/src/trivia.rs b/crates/biome_grit_formatter/src/trivia.rs index 1ad304243c86..ea6a401885f4 100644 --- a/crates/biome_grit_formatter/src/trivia.rs +++ b/crates/biome_grit_formatter/src/trivia.rs @@ -9,7 +9,7 @@ pub(crate) struct FormatRemoved<'a> { token: &'a GritSyntaxToken, } -pub(crate) fn format_removed(token: &GritSyntaxToken) -> FormatRemoved { +pub(crate) fn format_removed(token: &GritSyntaxToken) -> FormatRemoved<'_> { FormatRemoved { token } } diff --git a/crates/biome_grit_formatter/src/verbatim.rs b/crates/biome_grit_formatter/src/verbatim.rs index c8b7b85fa3f2..6e6b81c658c1 100644 --- a/crates/biome_grit_formatter/src/verbatim.rs +++ b/crates/biome_grit_formatter/src/verbatim.rs @@ -21,7 +21,7 @@ use biome_rowan::{AstNode, Direction, SyntaxElement, TextRange}; /// These nodes and tokens get tracked as [VerbatimKind::Verbatim], useful to understand /// if these nodes still need to have their own implementation. #[expect(unused)] -pub fn format_graphql_verbatim_node(node: &GritSyntaxNode) -> FormatGraphqlVerbatimNode { +pub fn format_graphql_verbatim_node(node: &GritSyntaxNode) -> FormatGraphqlVerbatimNode<'_> { FormatGraphqlVerbatimNode { node, kind: VerbatimKind::Verbatim { @@ -151,7 +151,7 @@ impl Format for FormatGraphqlVerbatimNode<'_> { /// Formats bogus nodes. The difference between this method and `format_verbatim` is that this method /// doesn't track nodes/tokens as [VerbatimKind::Verbatim]. They are just printed as they are. -pub fn format_bogus_node(node: &GritSyntaxNode) -> FormatGraphqlVerbatimNode { +pub fn format_bogus_node(node: &GritSyntaxNode) -> FormatGraphqlVerbatimNode<'_> { FormatGraphqlVerbatimNode { node, kind: VerbatimKind::Bogus, @@ -160,7 +160,7 @@ pub fn format_bogus_node(node: &GritSyntaxNode) -> FormatGraphqlVerbatimNode { } /// Format a node having formatter suppression comment applied to it -pub fn format_suppressed_node(node: &GritSyntaxNode) -> FormatGraphqlVerbatimNode { +pub fn format_suppressed_node(node: &GritSyntaxNode) -> FormatGraphqlVerbatimNode<'_> { FormatGraphqlVerbatimNode { node, kind: VerbatimKind::Suppressed, diff --git a/crates/biome_grit_patterns/src/grit_built_in_functions.rs b/crates/biome_grit_patterns/src/grit_built_in_functions.rs index 1c4099c3eb49..ef379ba7b9b1 100644 --- a/crates/biome_grit_patterns/src/grit_built_in_functions.rs +++ b/crates/biome_grit_patterns/src/grit_built_in_functions.rs @@ -577,7 +577,7 @@ fn uppercase_fn<'a>( Ok(ResolvedPattern::from_string(string.to_uppercase())) } -fn capitalize(s: &str) -> Cow { +fn capitalize(s: &str) -> Cow<'_, str> { if let Some(first_char) = s.chars().next() && !first_char.is_uppercase() { diff --git a/crates/biome_grit_patterns/src/grit_node.rs b/crates/biome_grit_patterns/src/grit_node.rs index 6031a3c1abac..3af5e32890a9 100644 --- a/crates/biome_grit_patterns/src/grit_node.rs +++ b/crates/biome_grit_patterns/src/grit_node.rs @@ -71,7 +71,7 @@ impl GritAstNode for GritNode { self.0.prev_sibling().map(Into::into) } - fn text(&self) -> GritResult> { + fn text(&self) -> GritResult> { Ok(Cow::Owned(self.0.text_trimmed().to_string())) } diff --git a/crates/biome_grit_patterns/src/grit_node_patterns.rs b/crates/biome_grit_patterns/src/grit_node_patterns.rs index 9b31295178a4..6ad2dd1f94cb 100644 --- a/crates/biome_grit_patterns/src/grit_node_patterns.rs +++ b/crates/biome_grit_patterns/src/grit_node_patterns.rs @@ -62,7 +62,7 @@ impl AstNodePattern for GritNodePattern { fn children( &self, _definitions: &StaticDefinitions, - ) -> Vec> { + ) -> Vec> { self.args .iter() .map(|arg| PatternOrPredicate::Pattern(&arg.pattern)) diff --git a/crates/biome_grit_patterns/src/grit_target_node.rs b/crates/biome_grit_patterns/src/grit_target_node.rs index 4c5915b48c7b..3ddb3d4f7ae0 100644 --- a/crates/biome_grit_patterns/src/grit_target_node.rs +++ b/crates/biome_grit_patterns/src/grit_target_node.rs @@ -102,7 +102,7 @@ macro_rules! generate_target_node { } } - pub fn owned_text(&self) -> Cow { + pub fn owned_text(&self) -> Cow<'_, str> { match self { $(Self::$lang(Node(node)) => Cow::Owned(node.text_with_trivia().to_string())),+, $(Self::$lang(Token(token)) => Cow::Borrowed(token.text())),+ @@ -378,7 +378,7 @@ impl GritAstNode for GritTargetNode<'_> { } } - fn text(&self) -> GritResult> { + fn text(&self) -> GritResult> { Ok(Cow::Borrowed(self.text())) } diff --git a/crates/biome_grit_patterns/src/grit_tree.rs b/crates/biome_grit_patterns/src/grit_tree.rs index d8523ebb8ba4..d1a8bcc5f2be 100644 --- a/crates/biome_grit_patterns/src/grit_tree.rs +++ b/crates/biome_grit_patterns/src/grit_tree.rs @@ -25,11 +25,11 @@ impl Ast for GritTargetTree { where Self: 'a; - fn root_node(&self) -> GritTargetNode { + fn root_node(&self) -> GritTargetNode<'_> { GritTargetNode::new(self.root.clone(), self) } - fn source(&self) -> Cow { + fn source(&self) -> Cow<'_, str> { Cow::Borrowed(&self.source) } } diff --git a/crates/biome_grit_patterns/src/pattern_compiler/snippet_compiler.rs b/crates/biome_grit_patterns/src/pattern_compiler/snippet_compiler.rs index 3569c87729f2..cc03f3fafcd0 100644 --- a/crates/biome_grit_patterns/src/pattern_compiler/snippet_compiler.rs +++ b/crates/biome_grit_patterns/src/pattern_compiler/snippet_compiler.rs @@ -135,7 +135,7 @@ pub(crate) fn dynamic_snippet_from_source( Ok(DynamicSnippet { parts }) } -fn nodes_from_trees(snippets: &[SnippetTree]) -> Vec { +fn nodes_from_trees(snippets: &[SnippetTree]) -> Vec> { snippets.iter().filter_map(node_from_tree).collect() } @@ -148,7 +148,7 @@ fn nodes_from_trees(snippets: &[SnippetTree]) -> Vec) -> Option { +fn node_from_tree(snippet: &SnippetTree) -> Option> { let mut snippet_root = snippet.tree.root_node(); // find the outermost node with the same index as the snippet diff --git a/crates/biome_html_formatter/src/trivia.rs b/crates/biome_html_formatter/src/trivia.rs index ceb4b9213761..79ec427820fb 100644 --- a/crates/biome_html_formatter/src/trivia.rs +++ b/crates/biome_html_formatter/src/trivia.rs @@ -9,7 +9,7 @@ pub(crate) struct FormatRemoved<'a> { token: &'a HtmlSyntaxToken, } -pub(crate) fn format_removed(token: &HtmlSyntaxToken) -> FormatRemoved { +pub(crate) fn format_removed(token: &HtmlSyntaxToken) -> FormatRemoved<'_> { FormatRemoved { token } } diff --git a/crates/biome_html_formatter/src/verbatim.rs b/crates/biome_html_formatter/src/verbatim.rs index 8b4b47c50e82..1bac74b77f7e 100644 --- a/crates/biome_html_formatter/src/verbatim.rs +++ b/crates/biome_html_formatter/src/verbatim.rs @@ -9,11 +9,11 @@ use biome_formatter::prelude::{ }; use biome_formatter::{ - Buffer, CstFormatContext, Format, FormatContext, FormatElement, FormatError, FormatRefWithRule, - FormatResult, FormatWithRule, LINE_TERMINATORS, normalize_newlines, + Buffer, CstFormatContext, Format, FormatContext, FormatElement, FormatRefWithRule, + FormatResult, LINE_TERMINATORS, normalize_newlines, }; use biome_html_syntax::{HtmlLanguage, HtmlSyntaxNode}; -use biome_rowan::{AstNode, Direction, SyntaxElement, TextRange}; +use biome_rowan::{Direction, SyntaxElement, TextRange}; /// "Formats" a node according to its original formatting in the source text. Being able to format /// a node "as is" is useful if a node contains syntax errors. Formatting a node with syntax errors @@ -25,7 +25,7 @@ use biome_rowan::{AstNode, Direction, SyntaxElement, TextRange}; /// /// These nodes and tokens get tracked as [VerbatimKind::Verbatim], useful to understand /// if these nodes still need to have their own implementation. -pub fn format_html_verbatim_node(node: &HtmlSyntaxNode) -> FormatHtmlVerbatimNode { +pub fn format_html_verbatim_node(node: &HtmlSyntaxNode) -> FormatHtmlVerbatimNode<'_> { FormatHtmlVerbatimNode { node, kind: VerbatimKind::Verbatim { @@ -37,7 +37,7 @@ pub fn format_html_verbatim_node(node: &HtmlSyntaxNode) -> FormatHtmlVerbatimNod /// "Formats" a node according to its original formatting in the source text. It's functionally equal to /// [`format_html_verbatim_node`], but it doesn't track the node as [VerbatimKind::Verbatim]. -pub fn format_verbatim_skipped(node: &HtmlSyntaxNode) -> FormatHtmlVerbatimNode { +pub fn format_verbatim_skipped(node: &HtmlSyntaxNode) -> FormatHtmlVerbatimNode<'_> { FormatHtmlVerbatimNode { node, kind: VerbatimKind::Skipped, @@ -178,7 +178,7 @@ impl Format for FormatHtmlVerbatimNode<'_> { /// Formats bogus nodes. The difference between this method and `format_verbatim` is that this method /// doesn't track nodes/tokens as [VerbatimKind::Verbatim]. They are just printed as they are. -pub fn format_bogus_node(node: &HtmlSyntaxNode) -> FormatHtmlVerbatimNode { +pub fn format_bogus_node(node: &HtmlSyntaxNode) -> FormatHtmlVerbatimNode<'_> { FormatHtmlVerbatimNode { node, kind: VerbatimKind::Bogus, @@ -187,7 +187,7 @@ pub fn format_bogus_node(node: &HtmlSyntaxNode) -> FormatHtmlVerbatimNode { } /// Format a node having formatter suppression comment applied to it -pub fn format_suppressed_node(node: &HtmlSyntaxNode) -> FormatHtmlVerbatimNode { +pub fn format_suppressed_node(node: &HtmlSyntaxNode) -> FormatHtmlVerbatimNode<'_> { FormatHtmlVerbatimNode { node, kind: VerbatimKind::Suppressed, @@ -195,37 +195,8 @@ pub fn format_suppressed_node(node: &HtmlSyntaxNode) -> FormatHtmlVerbatimNode { } } -/// Formats a node or falls back to verbatim printing if formating this node fails. -#[derive(Copy, Clone)] -pub struct FormatNodeOrVerbatim { - inner: F, -} - -impl Format for FormatNodeOrVerbatim -where - F: FormatWithRule, - Item: AstNode, -{ - fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { - let snapshot = Formatter::state_snapshot(f); - - match self.inner.fmt(f) { - Ok(result) => Ok(result), - - Err(FormatError::SyntaxError) => { - f.restore_state_snapshot(snapshot); - - // Lists that yield errors are formatted as they were suppressed nodes. - // Doing so, the formatter formats the nodes/tokens as is. - format_suppressed_node(self.inner.item().syntax()).fmt(f) - } - Err(err) => Err(err), - } - } -} - /// Formats the leading comments of `node` -pub const fn format_html_leading_comments(node: &HtmlSyntaxNode) -> FormatLHtmlLeadingComments { +pub const fn format_html_leading_comments(node: &HtmlSyntaxNode) -> FormatLHtmlLeadingComments<'_> { FormatLHtmlLeadingComments::Node(node) } @@ -281,7 +252,9 @@ impl<'a> Format for FormatLHtmlLeadingComments<'a> { } /// Formats the leading comments of `node` -pub const fn format_html_trailing_comments(node: &HtmlSyntaxNode) -> FormatLHtmlTrailingComments { +pub const fn format_html_trailing_comments( + node: &HtmlSyntaxNode, +) -> FormatLHtmlTrailingComments<'_> { FormatLHtmlTrailingComments::Node(node) } diff --git a/crates/biome_js_analyze/src/lib.rs b/crates/biome_js_analyze/src/lib.rs index 269ee054a54f..cbf18fc0fe13 100644 --- a/crates/biome_js_analyze/src/lib.rs +++ b/crates/biome_js_analyze/src/lib.rs @@ -88,7 +88,7 @@ where fn parse_linter_suppression_comment( text: &str, piece_range: TextRange, - ) -> Vec> { + ) -> Vec, SuppressionDiagnostic>> { let mut result = Vec::new(); for comment in parse_suppression_comment(text) { diff --git a/crates/biome_js_analyze/src/lint/nursery/use_explicit_type.rs b/crates/biome_js_analyze/src/lint/nursery/use_explicit_type.rs index ecdb3f110392..d07656d00b23 100644 --- a/crates/biome_js_analyze/src/lint/nursery/use_explicit_type.rs +++ b/crates/biome_js_analyze/src/lint/nursery/use_explicit_type.rs @@ -363,7 +363,7 @@ pub enum ViolationKind { } impl ViolationKind { - fn as_message(&self) -> Markup { + fn as_message(&self) -> Markup<'_> { match self { Self::UntypedParameter => markup! { "The parameter doesn't have a type defined." @@ -386,7 +386,7 @@ impl ViolationKind { } } - fn as_advice(&self) -> Markup { + fn as_advice(&self) -> Markup<'_> { match self { Self::UntypedParameter => markup! { "Add a type to the parameter." diff --git a/crates/biome_js_formatter/src/trivia.rs b/crates/biome_js_formatter/src/trivia.rs index 2096ddcb2527..f8d86a455aa9 100644 --- a/crates/biome_js_formatter/src/trivia.rs +++ b/crates/biome_js_formatter/src/trivia.rs @@ -12,7 +12,7 @@ pub(crate) struct FormatRemoved<'a> { token: &'a JsSyntaxToken, } -pub(crate) fn format_removed(token: &JsSyntaxToken) -> FormatRemoved { +pub(crate) fn format_removed(token: &JsSyntaxToken) -> FormatRemoved<'_> { FormatRemoved { token } } diff --git a/crates/biome_js_formatter/src/utils/assignment_like.rs b/crates/biome_js_formatter/src/utils/assignment_like.rs index 2fab4f80432a..460d01f4fd54 100644 --- a/crates/biome_js_formatter/src/utils/assignment_like.rs +++ b/crates/biome_js_formatter/src/utils/assignment_like.rs @@ -1362,7 +1362,7 @@ pub(crate) struct WithAssignmentLayout<'a> { pub(crate) fn with_assignment_layout( expression: &AnyJsExpression, layout: Option, -) -> WithAssignmentLayout { +) -> WithAssignmentLayout<'_> { WithAssignmentLayout { expression, layout } } diff --git a/crates/biome_js_formatter/src/utils/conditional.rs b/crates/biome_js_formatter/src/utils/conditional.rs index aefccf93ca88..7f459f1c35b2 100644 --- a/crates/biome_js_formatter/src/utils/conditional.rs +++ b/crates/biome_js_formatter/src/utils/conditional.rs @@ -746,14 +746,14 @@ fn is_jsx_conditional_chain(outer_most: &JsConditionalExpression) -> bool { || recurse(outer_most.alternate()) } -fn format_jsx_chain_consequent(expression: &AnyJsExpression) -> FormatJsxChainExpression { +fn format_jsx_chain_consequent(expression: &AnyJsExpression) -> FormatJsxChainExpression<'_> { FormatJsxChainExpression { expression, alternate: false, } } -fn format_jsx_chain_alternate(alternate: &AnyJsExpression) -> FormatJsxChainExpression { +fn format_jsx_chain_alternate(alternate: &AnyJsExpression) -> FormatJsxChainExpression<'_> { FormatJsxChainExpression { expression: alternate, alternate: true, diff --git a/crates/biome_js_formatter/src/utils/string_utils.rs b/crates/biome_js_formatter/src/utils/string_utils.rs index 4a2c3c41fed0..5297653f5f31 100644 --- a/crates/biome_js_formatter/src/utils/string_utils.rs +++ b/crates/biome_js_formatter/src/utils/string_utils.rs @@ -39,7 +39,7 @@ impl<'token> FormatLiteralStringToken<'token> { self.token } - pub fn clean_text(&self, options: &JsFormatOptions) -> CleanedStringLiteralText { + pub fn clean_text(&self, options: &JsFormatOptions) -> CleanedStringLiteralText<'_> { let token = self.token(); debug_assert!( matches!(token.kind(), JS_STRING_LITERAL | JSX_STRING_LITERAL), @@ -400,7 +400,7 @@ mod tests { } impl AsToken { - fn into_token(self, token: &JsSyntaxToken) -> FormatLiteralStringToken { + fn into_token(self, token: &JsSyntaxToken) -> FormatLiteralStringToken<'_> { match self { Self::Directive => { FormatLiteralStringToken::new(token, StringLiteralParentKind::Directive) diff --git a/crates/biome_js_formatter/src/verbatim.rs b/crates/biome_js_formatter/src/verbatim.rs index 8ad8321dc213..de069a04a179 100644 --- a/crates/biome_js_formatter/src/verbatim.rs +++ b/crates/biome_js_formatter/src/verbatim.rs @@ -21,7 +21,7 @@ use biome_text_size::TextRange; /// /// These nodes and tokens get tracked as [VerbatimKind::Verbatim], useful to understand /// if these nodes still need to have their own implementation. -pub fn format_js_verbatim_node(node: &JsSyntaxNode) -> FormatJsVerbatimNode { +pub fn format_js_verbatim_node(node: &JsSyntaxNode) -> FormatJsVerbatimNode<'_> { FormatJsVerbatimNode { node, kind: VerbatimKind::Verbatim { @@ -151,7 +151,7 @@ impl Format for FormatJsVerbatimNode<'_> { /// Formats bogus nodes. The difference between this method and `format_verbatim` is that this method /// doesn't track nodes/tokens as [VerbatimKind::Verbatim]. They are just printed as they are. -pub fn format_bogus_node(node: &JsSyntaxNode) -> FormatJsVerbatimNode { +pub fn format_bogus_node(node: &JsSyntaxNode) -> FormatJsVerbatimNode<'_> { FormatJsVerbatimNode { node, kind: VerbatimKind::Bogus, @@ -160,7 +160,7 @@ pub fn format_bogus_node(node: &JsSyntaxNode) -> FormatJsVerbatimNode { } /// Format a node having formatter suppression comment applied to it -pub fn format_suppressed_node(node: &JsSyntaxNode) -> FormatJsVerbatimNode { +pub fn format_suppressed_node(node: &JsSyntaxNode) -> FormatJsVerbatimNode<'_> { FormatJsVerbatimNode { node, kind: VerbatimKind::Suppressed, @@ -169,7 +169,7 @@ pub fn format_suppressed_node(node: &JsSyntaxNode) -> FormatJsVerbatimNode { } /// Format a node having formatter suppression comment applied to it -pub fn format_suppressed_node_skip_comments(node: &JsSyntaxNode) -> FormatJsVerbatimNode { +pub fn format_suppressed_node_skip_comments(node: &JsSyntaxNode) -> FormatJsVerbatimNode<'_> { FormatJsVerbatimNode { node, kind: VerbatimKind::Suppressed, diff --git a/crates/biome_js_syntax/src/numbers.rs b/crates/biome_js_syntax/src/numbers.rs index 1ccab75f20f5..bf4d8bcb989b 100644 --- a/crates/biome_js_syntax/src/numbers.rs +++ b/crates/biome_js_syntax/src/numbers.rs @@ -5,7 +5,7 @@ use std::{borrow::Cow, str::FromStr}; /// Split given string into radix and number string. /// /// It also removes any underscores. -pub fn split_into_radix_and_number(num: &str) -> (u8, Cow) { +pub fn split_into_radix_and_number(num: &str) -> (u8, Cow<'_, str>) { let (radix, raw) = parse_js_number_prefix(num).unwrap_or((10, num)); let raw = if raw.contains('_') { Cow::Owned(raw.replace('_', "")) diff --git a/crates/biome_js_type_info/src/globals.rs b/crates/biome_js_type_info/src/globals.rs index ae67ab3c19b3..d69bf821e0f7 100644 --- a/crates/biome_js_type_info/src/globals.rs +++ b/crates/biome_js_type_info/src/globals.rs @@ -431,7 +431,7 @@ impl TypeResolver for GlobalsResolver { self.types.get_by_id(id) } - fn get_by_resolved_id(&self, id: ResolvedTypeId) -> Option { + fn get_by_resolved_id(&self, id: ResolvedTypeId) -> Option> { (id.level() == GLOBAL_LEVEL).then(|| (id, self.get_by_id(id.id())).into()) } @@ -471,7 +471,11 @@ impl TypeResolver for GlobalsResolver { } } - fn resolve_expression(&mut self, scope_id: ScopeId, expr: &AnyJsExpression) -> Cow { + fn resolve_expression( + &mut self, + scope_id: ScopeId, + expr: &AnyJsExpression, + ) -> Cow<'_, TypeData> { Cow::Owned(TypeData::from_any_js_expression(self, scope_id, expr)) } diff --git a/crates/biome_js_type_info/src/helpers.rs b/crates/biome_js_type_info/src/helpers.rs index bc0c7be30a47..b3e52189a243 100644 --- a/crates/biome_js_type_info/src/helpers.rs +++ b/crates/biome_js_type_info/src/helpers.rs @@ -242,7 +242,7 @@ impl TypeData { /// This iterator does not return members of [`TypeData::InstanceOf`] or /// [`TypeData::Reference`] variants. If that's what you want, you will need /// to dereference them first. - pub fn own_members(&self) -> OwnTypeMemberIterator { + pub fn own_members(&self) -> OwnTypeMemberIterator<'_> { OwnTypeMemberIterator { owner: TypeMemberOwner::from_type_data(self), index: 0, diff --git a/crates/biome_js_type_info/src/resolver.rs b/crates/biome_js_type_info/src/resolver.rs index 82b2aa8d4635..e884e3ea4dfb 100644 --- a/crates/biome_js_type_info/src/resolver.rs +++ b/crates/biome_js_type_info/src/resolver.rs @@ -60,7 +60,7 @@ impl ResolvedTypeId { /// Applies the module ID of `self` to `reference`. #[inline] - pub fn apply_module_id_to_reference(self, reference: &TypeReference) -> Cow { + pub fn apply_module_id_to_reference(self, reference: &TypeReference) -> Cow<'_, TypeReference> { self.0.apply_module_id_to_reference(reference) } @@ -175,7 +175,7 @@ impl ResolverId { /// Applies the module ID of `self` to the given `reference`. #[inline] - pub fn apply_module_id_to_reference(self, reference: &TypeReference) -> Cow { + pub fn apply_module_id_to_reference(self, reference: &TypeReference) -> Cow<'_, TypeReference> { match reference { TypeReference::Resolved(id) => { Cow::Owned(TypeReference::Resolved(self.apply_module_id(*id))) @@ -349,7 +349,7 @@ impl<'a> ResolvedTypeData<'a> { /// Applies the module ID from the embedded [`ResolverId`] to the given /// `reference`. #[inline] - pub fn apply_module_id_to_reference(self, reference: &TypeReference) -> Cow { + pub fn apply_module_id_to_reference(self, reference: &TypeReference) -> Cow<'_, TypeReference> { self.id.apply_module_id_to_reference(reference) } @@ -449,7 +449,7 @@ impl<'a> ResolvedTypeMember<'a> { /// /// This means if the member represents a getter or setter, it will /// dereference to the type of the property being get or set. - pub fn deref_ty(&self, resolver: &dyn TypeResolver) -> Cow { + pub fn deref_ty(&self, resolver: &dyn TypeResolver) -> Cow<'_, TypeReference> { if self.is_getter() { resolver .resolve_and_get(&self.ty()) @@ -509,7 +509,7 @@ impl<'a> ResolvedTypeMember<'a> { } /// Returns a reference to the type of the member. - pub fn ty(&self) -> Cow { + pub fn ty(&self) -> Cow<'_, TypeReference> { self.apply_module_id_to_reference(&self.member.ty) } } @@ -541,7 +541,7 @@ pub trait TypeResolver { fn get_by_id(&self, id: TypeId) -> &TypeData; /// Returns type data by its resolved ID, if possible. - fn get_by_resolved_id(&self, id: ResolvedTypeId) -> Option; + fn get_by_resolved_id(&self, id: ResolvedTypeId) -> Option>; /// Returns the [`TypeReference`] to refer to a [`TypeId`] belonging to this /// resolver. @@ -627,7 +627,7 @@ pub trait TypeResolver { /// Resolves a type reference and immediately returns the associated /// [`TypeData`] if found. - fn resolve_and_get(&self, ty: &TypeReference) -> Option { + fn resolve_and_get(&self, ty: &TypeReference) -> Option> { match self .resolve_reference(ty) .and_then(|id| self.get_by_resolved_id(id)) @@ -675,7 +675,7 @@ pub trait TypeResolver { &mut self, scope_id: ScopeId, expression: &AnyJsExpression, - ) -> Cow; + ) -> Cow<'_, TypeData>; /// Resolves a type reference. fn resolve_reference(&self, ty: &TypeReference) -> Option; diff --git a/crates/biome_js_type_info/src/type.rs b/crates/biome_js_type_info/src/type.rs index 37fd2da17ead..950e8fea53e9 100644 --- a/crates/biome_js_type_info/src/type.rs +++ b/crates/biome_js_type_info/src/type.rs @@ -208,7 +208,7 @@ impl Type { } #[inline] - pub fn resolved_data(&self) -> Option { + pub fn resolved_data(&self) -> Option> { self.resolver.get_by_resolved_id(self.id) } diff --git a/crates/biome_js_type_info/tests/utils.rs b/crates/biome_js_type_info/tests/utils.rs index e6ae6f5fa518..2356e6358746 100644 --- a/crates/biome_js_type_info/tests/utils.rs +++ b/crates/biome_js_type_info/tests/utils.rs @@ -154,7 +154,7 @@ impl TypeResolver for HardcodedSymbolResolver { &self.types[id.index()] } - fn get_by_resolved_id(&self, id: ResolvedTypeId) -> Option { + fn get_by_resolved_id(&self, id: ResolvedTypeId) -> Option> { match id.level() { TypeResolverLevel::Full => { panic!("Ad-hoc references unsupported by resolver") @@ -204,7 +204,11 @@ impl TypeResolver for HardcodedSymbolResolver { self.globals.resolve_type_of(identifier, scope_id) } - fn resolve_expression(&mut self, scope_id: ScopeId, expr: &AnyJsExpression) -> Cow { + fn resolve_expression( + &mut self, + scope_id: ScopeId, + expr: &AnyJsExpression, + ) -> Cow<'_, TypeData> { Cow::Owned(TypeData::from_any_js_expression(self, scope_id, expr)) } diff --git a/crates/biome_json_analyze/src/lib.rs b/crates/biome_json_analyze/src/lib.rs index 542e2a4fdc3d..15efe8af9dab 100644 --- a/crates/biome_json_analyze/src/lib.rs +++ b/crates/biome_json_analyze/src/lib.rs @@ -67,7 +67,7 @@ where fn parse_linter_suppression_comment( text: &str, piece_range: TextRange, - ) -> Vec> { + ) -> Vec, SuppressionDiagnostic>> { let mut result = Vec::new(); for suppression in parse_suppression_comment(text) { diff --git a/crates/biome_json_formatter/src/trivia.rs b/crates/biome_json_formatter/src/trivia.rs index affae06a6c32..9835df2478e7 100644 --- a/crates/biome_json_formatter/src/trivia.rs +++ b/crates/biome_json_formatter/src/trivia.rs @@ -12,7 +12,7 @@ pub(crate) struct FormatRemoved<'a> { token: &'a JsonSyntaxToken, } -pub(crate) fn format_removed(token: &JsonSyntaxToken) -> FormatRemoved { +pub(crate) fn format_removed(token: &JsonSyntaxToken) -> FormatRemoved<'_> { FormatRemoved { token } } diff --git a/crates/biome_json_formatter/src/verbatim.rs b/crates/biome_json_formatter/src/verbatim.rs index ca84ce2119f8..1afef8d111b3 100644 --- a/crates/biome_json_formatter/src/verbatim.rs +++ b/crates/biome_json_formatter/src/verbatim.rs @@ -20,7 +20,7 @@ use biome_rowan::{AstNode, Direction, SyntaxElement, TextRange}; /// /// These nodes and tokens get tracked as [VerbatimKind::Verbatim], useful to understand /// if these nodes still need to have their own implementation. -pub fn format_json_verbatim_node(node: &JsonSyntaxNode) -> FormatJsonVerbatimNode { +pub fn format_json_verbatim_node(node: &JsonSyntaxNode) -> FormatJsonVerbatimNode<'_> { FormatJsonVerbatimNode { node, kind: VerbatimKind::Verbatim { @@ -150,7 +150,7 @@ impl Format for FormatJsonVerbatimNode<'_> { /// Formats bogus nodes. The difference between this method and `format_verbatim` is that this method /// doesn't track nodes/tokens as [VerbatimKind::Verbatim]. They are just printed as they are. -pub fn format_bogus_node(node: &JsonSyntaxNode) -> FormatJsonVerbatimNode { +pub fn format_bogus_node(node: &JsonSyntaxNode) -> FormatJsonVerbatimNode<'_> { FormatJsonVerbatimNode { node, kind: VerbatimKind::Bogus, @@ -159,7 +159,7 @@ pub fn format_bogus_node(node: &JsonSyntaxNode) -> FormatJsonVerbatimNode { } /// Format a node having formatter suppression comment applied to it -pub fn format_suppressed_node(node: &JsonSyntaxNode) -> FormatJsonVerbatimNode { +pub fn format_suppressed_node(node: &JsonSyntaxNode) -> FormatJsonVerbatimNode<'_> { FormatJsonVerbatimNode { node, kind: VerbatimKind::Suppressed, diff --git a/crates/biome_module_graph/src/js_module_info/collector.rs b/crates/biome_module_graph/src/js_module_info/collector.rs index 365c20495dab..2fa4693960f4 100644 --- a/crates/biome_module_graph/src/js_module_info/collector.rs +++ b/crates/biome_module_graph/src/js_module_info/collector.rs @@ -897,7 +897,7 @@ impl TypeResolver for JsModuleInfoCollector { self.types.get_by_id(id) } - fn get_by_resolved_id(&self, id: ResolvedTypeId) -> Option { + fn get_by_resolved_id(&self, id: ResolvedTypeId) -> Option> { let mut id = id; loop { let resolved_data: ResolvedTypeData = match id.level() { @@ -983,7 +983,11 @@ impl TypeResolver for JsModuleInfoCollector { GLOBAL_RESOLVER.resolve_type_of(identifier, scope_id) } - fn resolve_expression(&mut self, _scope_id: ScopeId, expr: &AnyJsExpression) -> Cow { + fn resolve_expression( + &mut self, + _scope_id: ScopeId, + expr: &AnyJsExpression, + ) -> Cow<'_, TypeData> { match self.parsed_expressions.get(&expr.range()) { Some(resolved_id) => match resolved_id.level() { TypeResolverLevel::Thin => Cow::Borrowed(self.get_by_id(resolved_id.id())), diff --git a/crates/biome_module_graph/src/js_module_info/module_resolver.rs b/crates/biome_module_graph/src/js_module_info/module_resolver.rs index 55f834edbd78..41ce23528250 100644 --- a/crates/biome_module_graph/src/js_module_info/module_resolver.rs +++ b/crates/biome_module_graph/src/js_module_info/module_resolver.rs @@ -318,7 +318,7 @@ impl TypeResolver for ModuleResolver { self.types.get_by_id(id) } - fn get_by_resolved_id(&self, id: ResolvedTypeId) -> Option { + fn get_by_resolved_id(&self, id: ResolvedTypeId) -> Option> { match id.level() { TypeResolverLevel::Full => Some(ResolvedTypeData::from((id, self.get_by_id(id.id())))), TypeResolverLevel::Thin => { @@ -401,7 +401,11 @@ impl TypeResolver for ModuleResolver { } } - fn resolve_expression(&mut self, _scope_id: ScopeId, expr: &AnyJsExpression) -> Cow { + fn resolve_expression( + &mut self, + _scope_id: ScopeId, + expr: &AnyJsExpression, + ) -> Cow<'_, TypeData> { let id = self.resolved_id_for_expression(expr); match self.get_by_resolved_id(id) { Some(resolved) => Cow::Owned(resolved.to_data()), diff --git a/crates/biome_module_graph/src/module_graph.rs b/crates/biome_module_graph/src/module_graph.rs index 0cdd87eb5b76..6a9ef781ee7e 100644 --- a/crates/biome_module_graph/src/module_graph.rs +++ b/crates/biome_module_graph/src/module_graph.rs @@ -57,7 +57,7 @@ impl ModuleGraph { } /// Returns the data of the module graph in test - pub fn data(&self) -> HashMapRef { + pub fn data(&self) -> HashMapRef<'_, Utf8PathBuf, JsModuleInfo, FxBuildHasher, LocalGuard<'_>> { self.data.pin() } diff --git a/crates/biome_rowan/src/cursor.rs b/crates/biome_rowan/src/cursor.rs index b49291ed612c..39bb01ee2e52 100644 --- a/crates/biome_rowan/src/cursor.rs +++ b/crates/biome_rowan/src/cursor.rs @@ -123,7 +123,7 @@ impl WeakGreenElement { } } - fn as_deref(&self) -> GreenElementRef { + fn as_deref(&self) -> GreenElementRef<'_> { match self { Self::Node { ptr } => GreenElementRef::Node(unsafe { ptr.as_ref() }), Self::Token { ptr } => GreenElementRef::Token(unsafe { ptr.as_ref() }), @@ -197,7 +197,7 @@ impl NodeData { /// Returns an iterator over the siblings of this node. The iterator is positioned at the current node. #[inline] - fn green_siblings(&self) -> Option { + fn green_siblings(&self) -> Option> { match &self.parent()?.green() { GreenElementRef::Node(ptr) => Some(Siblings::new(ptr, self.slot())), GreenElementRef::Token(_) => { diff --git a/crates/biome_rowan/src/green/node.rs b/crates/biome_rowan/src/green/node.rs index 81ebfb71bb75..835b35b843a1 100644 --- a/crates/biome_rowan/src/green/node.rs +++ b/crates/biome_rowan/src/green/node.rs @@ -301,7 +301,7 @@ impl GreenNode { impl Slot { #[inline] - pub(crate) fn as_ref(&self) -> Option { + pub(crate) fn as_ref(&self) -> Option> { match self { Self::Node { node, .. } => Some(NodeOrToken::Node(node)), Self::Token { token, .. } => Some(NodeOrToken::Token(token)), diff --git a/crates/biome_rowan/src/green/node_cache.rs b/crates/biome_rowan/src/green/node_cache.rs index f025d7d1e0d3..6d606242058d 100644 --- a/crates/biome_rowan/src/green/node_cache.rs +++ b/crates/biome_rowan/src/green/node_cache.rs @@ -225,7 +225,7 @@ impl NodeCache { &mut self, kind: RawSyntaxKind, children: &[(u64, GreenElement)], - ) -> NodeCacheNodeEntryMut { + ) -> NodeCacheNodeEntryMut<'_> { if children.len() > 3 { return NodeCacheNodeEntryMut::NoCache(Self::UNCACHED_NODE_HASH); } diff --git a/crates/biome_service/src/configuration.rs b/crates/biome_service/src/configuration.rs index 46f2c680db7f..4871bb932fa6 100644 --- a/crates/biome_service/src/configuration.rs +++ b/crates/biome_service/src/configuration.rs @@ -114,7 +114,7 @@ impl LoadedConfiguration { } /// It returns an iterator over the diagnostics emitted during the resolution of the configuration file - pub fn as_diagnostics_iter(&self) -> ConfigurationDiagnosticsIter { + pub fn as_diagnostics_iter(&self) -> ConfigurationDiagnosticsIter<'_> { ConfigurationDiagnosticsIter::new(self.diagnostics.as_slice()) } } diff --git a/crates/biome_service/src/file_handlers/astro.rs b/crates/biome_service/src/file_handlers/astro.rs index c0447e88ac30..cff3065ba1ef 100644 --- a/crates/biome_service/src/file_handlers/astro.rs +++ b/crates/biome_service/src/file_handlers/astro.rs @@ -44,7 +44,7 @@ impl AstroFileHandler { ASTRO_FENCE.find_iter(input).next().map(|m| m.end() as u32) } - fn matches(input: &str) -> Matches { + fn matches(input: &str) -> Matches<'_, '_> { ASTRO_FENCE.find_iter(input) } diff --git a/crates/biome_service/src/file_handlers/svelte.rs b/crates/biome_service/src/file_handlers/svelte.rs index 2e9ae0c914d4..56b470f22f92 100644 --- a/crates/biome_service/src/file_handlers/svelte.rs +++ b/crates/biome_service/src/file_handlers/svelte.rs @@ -57,7 +57,7 @@ impl SvelteFileHandler { Self::matches_script(input).map(|m| m.start() as u32) } - fn matches_script(input: &str) -> Option { + fn matches_script(input: &str) -> Option> { SVELTE_FENCE .captures(input) .and_then(|captures| captures.name("script")) diff --git a/crates/biome_service/src/file_handlers/vue.rs b/crates/biome_service/src/file_handlers/vue.rs index 7a13b0891cea..f51402a45de8 100644 --- a/crates/biome_service/src/file_handlers/vue.rs +++ b/crates/biome_service/src/file_handlers/vue.rs @@ -57,7 +57,7 @@ impl VueFileHandler { Self::matches_script(input).map(|m| m.start() as u32) } - fn matches_script(input: &str) -> Option { + fn matches_script(input: &str) -> Option> { VUE_FENCE .captures(input) .and_then(|captures| captures.name("script")) diff --git a/crates/biome_service/src/settings.rs b/crates/biome_service/src/settings.rs index 881060c54339..d81f81ac3ab3 100644 --- a/crates/biome_service/src/settings.rs +++ b/crates/biome_service/src/settings.rs @@ -195,7 +195,7 @@ impl Settings { } /// Returns linter rules taking overrides into account. - pub fn as_linter_rules(&self, path: &Utf8Path) -> Option> { + pub fn as_linter_rules(&self, path: &Utf8Path) -> Option> { let mut result = self.linter.rules.as_ref().map(Cow::Borrowed); let overrides = &self.override_settings; for pattern in overrides.patterns.iter() { @@ -216,7 +216,7 @@ impl Settings { } /// Extract the domains applied to the given `path`, by looking that the base `domains`, and the once applied by `overrides` - pub fn as_linter_domains(&self, path: &Utf8Path) -> Option> { + pub fn as_linter_domains(&self, path: &Utf8Path) -> Option> { let mut result = self.linter.domains.as_ref().map(Cow::Borrowed); let overrides = &self.override_settings; for pattern in overrides.patterns.iter() { @@ -238,7 +238,7 @@ impl Settings { } /// Returns assists rules taking overrides into account. - pub fn as_assist_actions(&self, path: &Utf8Path) -> Option> { + pub fn as_assist_actions(&self, path: &Utf8Path) -> Option> { let mut result = self.assist.actions.as_ref().map(Cow::Borrowed); let overrides = &self.override_settings; for pattern in overrides.patterns.iter() { @@ -259,7 +259,7 @@ impl Settings { } /// Returns the plugins that should be enabled for the given `path`, taking overrides into account. - pub fn get_plugins_for_path(&self, path: &Utf8Path) -> Cow { + pub fn get_plugins_for_path(&self, path: &Utf8Path) -> Cow<'_, Plugins> { let mut result = Cow::Borrowed(&self.plugins); for pattern in &self.override_settings.patterns { @@ -272,7 +272,7 @@ impl Settings { } /// Return all plugins configured in setting - pub fn as_all_plugins(&self) -> Cow { + pub fn as_all_plugins(&self) -> Cow<'_, Plugins> { let mut result = Cow::Borrowed(&self.plugins); let all_override_plugins = self diff --git a/crates/biome_string_case/src/lib.rs b/crates/biome_string_case/src/lib.rs index 9d537ffecb45..a27456edae95 100644 --- a/crates/biome_string_case/src/lib.rs +++ b/crates/biome_string_case/src/lib.rs @@ -645,7 +645,7 @@ pub trait StrLikeExtension: ToOwned { /// Returns the same value as String::to_lowercase. The only difference /// is that this functions returns ```Cow``` and does not allocate /// if the string is already in lowercase. - fn to_ascii_lowercase_cow(&self) -> Cow; + fn to_ascii_lowercase_cow(&self) -> Cow<'_, Self>; /// Compare two strings using a natural ASCII order. /// @@ -658,11 +658,11 @@ pub trait StrOnlyExtension: ToOwned { /// Returns the same value as String::to_lowercase. The only difference /// is that this functions returns ```Cow``` and does not allocate /// if the string is already in lowercase. - fn to_lowercase_cow(&self) -> Cow; + fn to_lowercase_cow(&self) -> Cow<'_, Self>; } impl StrLikeExtension for str { - fn to_ascii_lowercase_cow(&self) -> Cow { + fn to_ascii_lowercase_cow(&self) -> Cow<'_, Self> { let has_ascii_uppercase = self.bytes().any(|b| b.is_ascii_uppercase()); if has_ascii_uppercase { #[expect(clippy::disallowed_methods)] @@ -678,7 +678,7 @@ impl StrLikeExtension for str { } impl StrOnlyExtension for str { - fn to_lowercase_cow(&self) -> Cow { + fn to_lowercase_cow(&self) -> Cow<'_, Self> { let has_uppercase = self.chars().any(char::is_uppercase); if has_uppercase { #[expect(clippy::disallowed_methods)] @@ -690,7 +690,7 @@ impl StrOnlyExtension for str { } impl StrLikeExtension for std::ffi::OsStr { - fn to_ascii_lowercase_cow(&self) -> Cow { + fn to_ascii_lowercase_cow(&self) -> Cow<'_, Self> { let has_ascii_uppercase = self .as_encoded_bytes() .iter() @@ -710,7 +710,7 @@ impl StrLikeExtension for std::ffi::OsStr { } impl StrLikeExtension for [u8] { - fn to_ascii_lowercase_cow(&self) -> Cow { + fn to_ascii_lowercase_cow(&self) -> Cow<'_, Self> { let has_ascii_uppercase = self.iter().any(|b| b.is_ascii_uppercase()); if has_ascii_uppercase { Cow::Owned(self.to_ascii_lowercase()) diff --git a/crates/biome_suppression/src/lib.rs b/crates/biome_suppression/src/lib.rs index dd985ad1d56a..ebe754b5134b 100644 --- a/crates/biome_suppression/src/lib.rs +++ b/crates/biome_suppression/src/lib.rs @@ -86,7 +86,7 @@ const RANGE_END_PATTERNS: [&str; 2] = ["-END", "-end"]; pub fn parse_suppression_comment( base: &str, -) -> impl Iterator> { +) -> impl Iterator, SuppressionDiagnostic>> { let (head, mut comment) = if base.starts_with('#') { base.split_at(1) } else if base.starts_with("