Skip to content

Commit

Permalink
chore: upgrade to rust 1.78 (#2691)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed May 3, 2024
1 parent 26a94cc commit 7656d1b
Show file tree
Hide file tree
Showing 26 changed files with 30 additions and 224 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ unused_macro_rules = "warn"

[workspace.lints.clippy]
cargo_common_metadata = "allow"
empty_docs = "allow" # there are some false positives inside biome_wasm
multiple_crate_versions = "allow"

# pedantic
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_analyze/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ impl AnalyzerOptions {
self.configuration.jsx_runtime
}

pub fn rule_options<R: 'static>(&self) -> Option<R::Options>
pub fn rule_options<R>(&self) -> Option<R::Options>
where
R: Rule,
R: Rule + 'static,
R::Options: Clone,
{
self.configuration
Expand Down
1 change: 1 addition & 0 deletions crates/biome_aria/src/roles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ impl<'a> AriaRoles {
"listitem" => &ListItemRole as &dyn AriaRoleDefinition,
"log" => &LogRole as &dyn AriaRoleDefinition,
"main" => &MainRole as &dyn AriaRoleDefinition,
"mark" => &MarkRole as &dyn AriaRoleDefinition,
"marquee" => &MarqueeRole as &dyn AriaRoleDefinition,
"math" => &MathRole as &dyn AriaRoleDefinition,
"menu" => &MenuRole as &dyn AriaRoleDefinition,
Expand Down
15 changes: 1 addition & 14 deletions crates/biome_cli/src/execute/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use biome_diagnostics::adapters::{IoError, StdError};
use biome_diagnostics::{
Advices, Category, Diagnostic, DiagnosticExt, DiagnosticTags, Error, Severity, Visit,
Advices, Category, Diagnostic, DiagnosticExt, DiagnosticTags, Error, Visit,
};
use biome_text_edit::TextEdit;
use std::io;
Expand Down Expand Up @@ -82,19 +82,6 @@ impl Advices for ContentDiffAdvice {
}
}

#[derive(Debug, Diagnostic)]
pub(crate) struct TraversalDiagnostic<'a> {
#[location(resource)]
pub(crate) file_name: Option<&'a str>,
#[severity]
pub(crate) severity: Severity,
#[category]
pub(crate) category: &'static Category,
#[message]
#[description]
pub(crate) message: &'a str,
}

#[derive(Debug, Diagnostic)]
#[diagnostic(category = "internalError/panic", tags(INTERNAL))]
pub(crate) struct PanicDiagnostic {
Expand Down
1 change: 0 additions & 1 deletion crates/biome_cli/src/execute/traverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use std::{
time::{Duration, Instant},
};

///
pub(crate) fn traverse(
execution: &Execution,
session: &mut CliSession,
Expand Down
5 changes: 0 additions & 5 deletions crates/biome_css_formatter/tests/prettier_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ use biome_css_formatter::context::CssFormatOptions;
use biome_formatter::IndentStyle;
use biome_formatter_test::test_prettier_snapshot::{PrettierSnapshot, PrettierTestFile};

#[derive(serde::Serialize)]
struct TestInfo {
test_file: String,
}

mod language;

tests_macros::gen_tests! {"tests/specs/prettier/{css}/**/*.{css}", crate::test_snapshot, ""}
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_formatter/src/comments/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl<K: std::hash::Hash + Eq, V> CommentsMap<K, V> {

/// Returns `true` if `key` has any leading, dangling, or trailing part.
pub fn has(&self, key: &K) -> bool {
self.index.get(key).is_some()
self.index.contains_key(key)
}

/// Returns an iterator over all leading, dangling, and trailing parts of `key`.
Expand Down
14 changes: 0 additions & 14 deletions crates/biome_formatter/src/printer/call_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ impl<'a> CallStack for FitsCallStack<'a> {
/// When ElementKind is [suffix], push the current indention onto the SuffixStack.
pub(super) trait SuffixStack {
type SuffixStack: Stack<Indention> + Debug;
fn suffix_stack(&self) -> &Self::SuffixStack;
fn suffix_stack_mut(&mut self) -> &mut Self::SuffixStack;
fn push_suffix(&mut self, indention: Indention) {
self.suffix_stack_mut().push(indention);
Expand All @@ -227,14 +226,10 @@ pub(super) trait IndentStack {
type HistoryStack: Stack<Indention> + Debug;

fn current_stack(&self) -> &Self::Stack;
fn history_stack(&self) -> &Self::HistoryStack;

fn current_stack_mut(&mut self) -> &mut Self::Stack;
fn history_stack_mut(&mut self) -> &mut Self::HistoryStack;

fn push(&mut self, indention: Indention) {
self.current_stack_mut().push(indention);
}
fn start_dedent(&mut self) {
if let Some(indent) = self.current_stack_mut().pop() {
self.history_stack_mut().push(indent);
Expand Down Expand Up @@ -292,9 +287,6 @@ impl IndentStack for PrintIndentStack {
fn current_stack(&self) -> &Self::Stack {
&self.indentions
}
fn history_stack(&self) -> &Self::HistoryStack {
&self.history_indentions
}

fn current_stack_mut(&mut self) -> &mut Self::Stack {
&mut self.indentions
Expand All @@ -305,9 +297,6 @@ impl IndentStack for PrintIndentStack {
}
impl SuffixStack for PrintIndentStack {
type SuffixStack = Vec<Indention>;
fn suffix_stack(&self) -> &Self::SuffixStack {
&self.suffix_indentions
}
fn suffix_stack_mut(&mut self) -> &mut Self::SuffixStack {
&mut self.suffix_indentions
}
Expand Down Expand Up @@ -344,9 +333,6 @@ impl<'a> IndentStack for FitsIndentStack<'a> {
fn current_stack(&self) -> &Self::Stack {
&self.indentions
}
fn history_stack(&self) -> &Self::HistoryStack {
&self.history_indentions
}

fn current_stack_mut(&mut self) -> &mut Self::Stack {
&mut self.indentions
Expand Down
21 changes: 0 additions & 21 deletions crates/biome_formatter/src/printer/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,27 +203,6 @@ impl<'a, 'print> Queue<'a> for FitsQueue<'a, 'print> {
}
}

/// Iterator that calls [Queue::pop] until it reaches the end of the document.
///
/// The iterator traverses into the content of any [FormatElement::Interned].
pub(super) struct QueueIterator<'a, 'q, Q: Queue<'a>> {
queue: &'q mut Q,
lifetime: PhantomData<&'a ()>,
}

impl<'a, Q> Iterator for QueueIterator<'a, '_, Q>
where
Q: Queue<'a>,
{
type Item = &'a FormatElement;

fn next(&mut self) -> Option<Self::Item> {
self.queue.pop()
}
}

impl<'a, Q> FusedIterator for QueueIterator<'a, '_, Q> where Q: Queue<'a> {}

pub(super) struct QueueContentIterator<'a, 'q, Q: Queue<'a>> {
queue: &'q mut Q,
kind: TagKind,
Expand Down
11 changes: 0 additions & 11 deletions crates/biome_formatter/src/printer/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ pub(super) trait Stack<T> {

/// Returns the last element if any
fn top(&self) -> Option<&T>;

/// Returns `true` if the stack is empty
fn is_empty(&self) -> bool;
}

impl<T> Stack<T> for Vec<T> {
Expand All @@ -25,10 +22,6 @@ impl<T> Stack<T> for Vec<T> {
fn top(&self) -> Option<&T> {
self.last()
}

fn is_empty(&self) -> bool {
self.is_empty()
}
}

/// A Stack that is stacked on top of another stack. Guarantees that the underlying stack remains unchanged.
Expand Down Expand Up @@ -79,10 +72,6 @@ where
fn top(&self) -> Option<&T> {
self.stack.last().or_else(|| self.original.last())
}

fn is_empty(&self) -> bool {
self.original.is_empty() && self.stack.is_empty()
}
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn get_utility_info(
// regardless of the order in which the targets are defined.
let target_size = target.chars().count();
if target_size > last_size {
layer = &layer_data.name;
layer = layer_data.name;
match_index = index;
last_size = target_size;
}
Expand Down
46 changes: 0 additions & 46 deletions crates/biome_js_parser/src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,6 @@ use std::{fmt::Debug, ops::Range};
/// This is essentially a hack to allow us to use SyntaxElement, SyntaxNode, etc directly
pub trait Span {
fn as_range(&self) -> TextRange;

/// Make a new span which extends to another span
///
/// ```text
/// from to
/// ^^^^^^^^^^^^
/// ```
fn join<T: Span>(&self, other: T) -> TextRange {
TextRange::new(self.as_range().start(), other.as_range().end())
}

/// Make a new span which is between another span
///
/// ```text
/// from to
/// ^^^^^^
/// ```
fn between<T: Span>(&self, other: T) -> TextRange {
TextRange::new(self.as_range().end(), other.as_range().start())
}

/// Make a new span which extends until another span
///
/// ```text
/// from to
/// ^^^^^^^^^^
/// ```
fn until<T: Span>(&self, other: T) -> TextRange {
TextRange::new(self.as_range().start(), other.as_range().start())
}

fn sub_start(&self, amount: TextSize) -> TextRange {
self.as_range().sub_start(amount)
}

fn add_start(&self, amount: TextSize) -> TextRange {
self.as_range().add_start(amount)
}

fn sub_end(&self, amount: TextSize) -> TextRange {
self.as_range().sub_end(amount)
}

fn add_end(&self, amount: TextSize) -> TextRange {
self.as_range().add_end(amount)
}
}

impl<T: Span> Span for &T {
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_js_semantic/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ impl SemanticEventExtractor {
self.stash.push_back(event);
}
} else if references.iter().all(|r| matches!(r, Reference::Export(_)))
&& self.bindings.get(&name.clone().dual()).is_some()
&& self.bindings.contains_key(&name.clone().dual())
{
// Don't report an export that exports at least a binding.
} else if let Some(parent) = self.scopes.last_mut() {
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_js_semantic/src/tests/assertions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,11 +713,11 @@ impl SemanticAssertions {
// Check every no event assertion

for assertion in self.no_events.iter() {
if events_by_pos.get(&assertion.range.start()).is_some() {
if events_by_pos.contains_key(&assertion.range.start()) {
panic!("unexpected event at this position")
}

if events_by_pos.get(&assertion.range.end()).is_some() {
if events_by_pos.contains_key(&assertion.range.end()) {
panic!("unexpected event at this position")
}
}
Expand Down
6 changes: 6 additions & 0 deletions crates/biome_json_formatter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ where
/// Used to convert this object into an object that can be formatted.
///
/// The difference to [AsFormat] is that this trait takes ownership of `self`.
// False positive
#[allow(dead_code)]
pub(crate) trait IntoFormat<Context> {
type Format: biome_formatter::Format<Context>;

Expand Down Expand Up @@ -109,6 +111,8 @@ where
}

/// Formatting specific [Iterator] extensions
// False positive
#[allow(dead_code)]
pub(crate) trait FormattedIterExt {
/// Converts every item to an object that knows how to format it.
fn formatted<Context>(self) -> FormattedIter<Self, Self::Item, Context>
Expand All @@ -125,6 +129,8 @@ pub(crate) trait FormattedIterExt {

impl<I> FormattedIterExt for I where I: std::iter::Iterator {}

// False positive
#[allow(dead_code)]
pub(crate) struct FormattedIter<Iter, Item, Context>
where
Iter: Iterator<Item = Item>,
Expand Down
5 changes: 0 additions & 5 deletions crates/biome_json_formatter/tests/prettier_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ use biome_formatter::IndentStyle;
use biome_formatter_test::test_prettier_snapshot::{PrettierSnapshot, PrettierTestFile};
use biome_json_formatter::context::JsonFormatOptions;

#[derive(serde::Serialize)]
struct TestInfo {
test_file: String,
}

mod language;

tests_macros::gen_tests! {"tests/specs/prettier/{json}/**/*.{json}", crate::test_snapshot, ""}
Expand Down
9 changes: 3 additions & 6 deletions crates/biome_rowan/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,7 @@ mod tests {
type MappedElement = Vec<(Option<f64>, Option<String>)>;

fn map_elements<'a>(
actual: impl Iterator<Item = AstSeparatedElement<RawLanguage, LiteralExpression>>
+ DoubleEndedIterator,
actual: impl DoubleEndedIterator<Item = AstSeparatedElement<RawLanguage, LiteralExpression>>,
expected: impl IntoIterator<Item = (Option<f64>, Option<&'a str>)>,
revert: bool,
) -> (MappedElement, MappedElement) {
Expand Down Expand Up @@ -947,8 +946,7 @@ mod tests {
}

fn assert_elements<'a>(
actual: impl Iterator<Item = AstSeparatedElement<RawLanguage, LiteralExpression>>
+ DoubleEndedIterator,
actual: impl DoubleEndedIterator<Item = AstSeparatedElement<RawLanguage, LiteralExpression>>,
expected: impl IntoIterator<Item = (Option<f64>, Option<&'a str>)>,
) {
let (actual, expected) = map_elements(actual, expected, false);
Expand All @@ -957,8 +955,7 @@ mod tests {
}

fn assert_rev_elements<'a>(
actual: impl Iterator<Item = AstSeparatedElement<RawLanguage, LiteralExpression>>
+ DoubleEndedIterator,
actual: impl DoubleEndedIterator<Item = AstSeparatedElement<RawLanguage, LiteralExpression>>,
expected: impl IntoIterator<Item = (Option<f64>, Option<&'a str>)>,
) {
let (actual, expected) = map_elements(actual, expected, true);
Expand Down
8 changes: 2 additions & 6 deletions crates/biome_service/src/file_handlers/astro.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::file_handlers::{
javascript, AnalyzerCapabilities, Capabilities, CodeActionsParams, DebugCapabilities,
ExtensionHandler, FixAllParams, FormatterCapabilities, LintParams, LintResults, Mime,
ParseResult, ParserCapabilities,
ExtensionHandler, FixAllParams, FormatterCapabilities, LintParams, LintResults, ParseResult,
ParserCapabilities,
};
use crate::settings::SettingsHandle;
use crate::workspace::{
Expand Down Expand Up @@ -66,10 +66,6 @@ impl AstroFileHandler {
}

impl ExtensionHandler for AstroFileHandler {
fn mime(&self) -> Mime {
Mime::Javascript
}

fn capabilities(&self) -> Capabilities {
Capabilities {
parser: ParserCapabilities { parse: Some(parse) },
Expand Down
10 changes: 1 addition & 9 deletions crates/biome_service/src/file_handlers/css.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{ExtensionHandler, Mime, ParseResult};
use super::{ExtensionHandler, ParseResult};
use crate::file_handlers::DebugCapabilities;
use crate::file_handlers::{
AnalyzerCapabilities, Capabilities, FormatterCapabilities, ParserCapabilities,
Expand Down Expand Up @@ -92,14 +92,6 @@ impl ServiceLanguage for CssLanguage {
pub(crate) struct CssFileHandler;

impl ExtensionHandler for CssFileHandler {
fn mime(&self) -> super::Mime {
Mime::Css
}

fn may_use_tabs(&self) -> bool {
true
}

fn capabilities(&self) -> Capabilities {
Capabilities {
parser: ParserCapabilities { parse: Some(parse) },
Expand Down
Loading

0 comments on commit 7656d1b

Please sign in to comment.