Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub enum PossibleFixContent {
// we assume that the fix offset will not exceed 2GB in either direction
#[expect(clippy::cast_possible_truncation)]
pub fn message_to_lsp_diagnostic(
message: &Message<'_>,
message: &Message,
uri: &Uri,
source_text: &str,
rope: &Rope,
Expand Down Expand Up @@ -134,7 +134,7 @@ pub fn message_to_lsp_diagnostic(
DiagnosticReport { diagnostic, fixed_content }
}

fn fix_to_fixed_content(fix: &Fix<'_>, rope: &Rope, source_text: &str) -> FixedContent {
fn fix_to_fixed_content(fix: &Fix, rope: &Rope, source_text: &str) -> FixedContent {
let start_position = offset_to_position(rope, fix.span.start, source_text);
let end_position = offset_to_position(rope, fix.span.end, source_text);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl IsolatedLintHandler {
&self,
directives: &DisableDirectives,
severity: AllowWarnDeny,
) -> Vec<Message<'_>> {
) -> Vec<Message> {
let diagnostics = create_unused_directives_diagnostics(directives, severity);
diagnostics
.into_iter()
Expand Down
12 changes: 6 additions & 6 deletions crates/oxc_linter/src/context/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub struct ContextHost<'a> {
/// Diagnostics reported by the linter.
///
/// Contains diagnostics for all rules across a single file.
diagnostics: RefCell<Vec<Message<'a>>>,
diagnostics: RefCell<Vec<Message>>,
/// Whether or not to apply code fixes during linting. Defaults to
/// [`FixKind::None`] (no fixing).
///
Expand Down Expand Up @@ -241,15 +241,15 @@ impl<'a> ContextHost<'a> {
/// Add a diagnostic message to the end of the list of diagnostics. Can be used
/// by any rule to report issues.
#[inline]
pub(crate) fn push_diagnostic(&self, mut diagnostic: Message<'a>) {
pub(crate) fn push_diagnostic(&self, mut diagnostic: Message) {
if self.current_sub_host().source_text_offset != 0 {
diagnostic.move_offset(self.current_sub_host().source_text_offset);
}
self.diagnostics.borrow_mut().push(diagnostic);
}

// Append a list of diagnostics. Only used in report_unused_directives.
fn append_diagnostics(&self, mut diagnostics: Vec<Message<'a>>) {
fn append_diagnostics(&self, mut diagnostics: Vec<Message>) {
if self.current_sub_host().source_text_offset != 0 {
let offset = self.current_sub_host().source_text_offset;
for diagnostic in &mut diagnostics {
Expand Down Expand Up @@ -345,7 +345,7 @@ impl<'a> ContextHost<'a> {
}

/// Take ownership of all diagnostics collected during linting.
pub fn take_diagnostics(&self) -> Vec<Message<'a>> {
pub fn take_diagnostics(&self) -> Vec<Message> {
// NOTE: diagnostics are only ever borrowed here and in push_diagnostic, append_diagnostics.
// The latter drops the reference as soon as the function returns, so
// this should never panic.
Expand All @@ -368,7 +368,7 @@ impl<'a> ContextHost<'a> {
}

#[cfg(debug_assertions)]
pub fn get_diagnostics(&self, cb: impl FnOnce(&mut Vec<Message<'a>>)) {
pub fn get_diagnostics(&self, cb: impl FnOnce(&mut Vec<Message>)) {
cb(self.diagnostics.borrow_mut().as_mut());
}

Expand Down Expand Up @@ -450,7 +450,7 @@ impl<'a> ContextHost<'a> {
}
}

impl<'a> From<ContextHost<'a>> for Vec<Message<'a>> {
impl<'a> From<ContextHost<'a>> for Vec<Message> {
fn from(ctx_host: ContextHost<'a>) -> Self {
ctx_host.diagnostics.into_inner()
}
Expand Down
22 changes: 11 additions & 11 deletions crates/oxc_linter/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl<'a> LintContext<'a> {

/// Add a diagnostic message to the list of diagnostics. Outputs a diagnostic with the current rule
/// name, severity, and a link to the rule's documentation URL.
fn add_diagnostic(&self, mut message: Message<'a>) {
fn add_diagnostic(&self, mut message: Message) {
if self.parent.disable_directives().contains(self.current_rule_name, message.span()) {
return;
}
Expand Down Expand Up @@ -272,7 +272,7 @@ impl<'a> LintContext<'a> {
#[inline]
pub fn diagnostic_with_fix<C, F>(&self, diagnostic: OxcDiagnostic, fix: F)
where
C: Into<RuleFix<'a>>,
C: Into<RuleFix>,
F: FnOnce(RuleFixer<'_, 'a>) -> C,
{
self.diagnostic_with_fix_of_kind(diagnostic, FixKind::SafeFix, fix);
Expand All @@ -293,7 +293,7 @@ impl<'a> LintContext<'a> {
#[inline]
pub fn diagnostic_with_suggestion<C, F>(&self, diagnostic: OxcDiagnostic, fix: F)
where
C: Into<RuleFix<'a>>,
C: Into<RuleFix>,
F: FnOnce(RuleFixer<'_, 'a>) -> C,
{
self.diagnostic_with_fix_of_kind(diagnostic, FixKind::Suggestion, fix);
Expand All @@ -314,7 +314,7 @@ impl<'a> LintContext<'a> {
#[inline]
pub fn diagnostic_with_dangerous_suggestion<C, F>(&self, diagnostic: OxcDiagnostic, fix: F)
where
C: Into<RuleFix<'a>>,
C: Into<RuleFix>,
F: FnOnce(RuleFixer<'_, 'a>) -> C,
{
self.diagnostic_with_fix_of_kind(diagnostic, FixKind::DangerousSuggestion, fix);
Expand Down Expand Up @@ -342,7 +342,7 @@ impl<'a> LintContext<'a> {
#[inline]
pub fn diagnostic_with_dangerous_fix<C, F>(&self, diagnostic: OxcDiagnostic, fix: F)
where
C: Into<RuleFix<'a>>,
C: Into<RuleFix>,
F: FnOnce(RuleFixer<'_, 'a>) -> C,
{
self.diagnostic_with_fix_of_kind(diagnostic, FixKind::DangerousFix, fix);
Expand All @@ -360,7 +360,7 @@ impl<'a> LintContext<'a> {
fix_kind: FixKind,
fix: F,
) where
C: Into<RuleFix<'a>>,
C: Into<RuleFix>,
F: FnOnce(RuleFixer<'_, 'a>) -> C,
{
let (diagnostic, fix) = self.create_fix(fix_kind, fix, diagnostic);
Expand All @@ -386,11 +386,11 @@ impl<'a> LintContext<'a> {
fix_one: (FixKind, F1),
fix_two: (FixKind, F2),
) where
C: Into<RuleFix<'a>>,
C: Into<RuleFix>,
F1: FnOnce(RuleFixer<'_, 'a>) -> C,
F2: FnOnce(RuleFixer<'_, 'a>) -> C,
{
let fixes_result: Vec<Fix<'a>> = vec![
let fixes_result: Vec<Fix> = vec![
self.create_fix(fix_one.0, fix_one.1, diagnostic.clone()).1,
self.create_fix(fix_two.0, fix_two.1, diagnostic.clone()).1,
]
Expand All @@ -417,13 +417,13 @@ impl<'a> LintContext<'a> {
fix_kind: FixKind,
fix: F,
diagnostic: OxcDiagnostic,
) -> (OxcDiagnostic, Option<Fix<'a>>)
) -> (OxcDiagnostic, Option<Fix>)
where
C: Into<RuleFix<'a>>,
C: Into<RuleFix>,
F: FnOnce(RuleFixer<'_, 'a>) -> C,
{
let fixer = RuleFixer::new(fix_kind, self);
let rule_fix: RuleFix<'a> = fix(fixer).into();
let rule_fix: RuleFix = fix(fixer).into();
#[cfg(debug_assertions)]
debug_assert!(
self.current_rule_fix_capabilities.supports_fix(fix_kind),
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/disable_directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct RuleCommentRule {

impl RuleCommentRule {
#[expect(clippy::cast_possible_truncation)] // for `as u32`
pub fn create_fix<'a>(&self, source_text: &'a str, comment_span: Span) -> Fix<'a> {
pub fn create_fix(&self, source_text: &str, comment_span: Span) -> Fix {
let before_source =
&source_text[comment_span.start as usize..self.name_span.start as usize];

Expand Down
Loading
Loading