Skip to content

Commit

Permalink
Auto merge of #16431 - Ar4ys:fix-E0107-error-range-in-proc-macro, r=V…
Browse files Browse the repository at this point in the history
…eykril

Replaced adjusted_display_range with adjusted_display_range_new in mismatched_arg_count

For detailed description - see related issue.

Fixes: #16407
  • Loading branch information
bors committed Jan 26, 2024
2 parents f090205 + 8f05e7c commit 596e5c7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use hir::InFile;
use ide_db::base_db::FileRange;
use syntax::{
ast::{self, HasArgList},
AstNode, SyntaxNodePtr,
AstNode, AstPtr,
};

use crate::{adjusted_display_range, Diagnostic, DiagnosticCode, DiagnosticsContext};
use crate::{adjusted_display_range_new, Diagnostic, DiagnosticCode, DiagnosticsContext};

// Diagnostic: mismatched-tuple-struct-pat-arg-count
//
Expand All @@ -24,7 +24,7 @@ pub(crate) fn mismatched_tuple_struct_pat_arg_count(
Diagnostic::new(
DiagnosticCode::RustcHardError("E0023"),
message,
invalid_args_range(ctx, d.expr_or_pat.map(Into::into), d.expected, d.found),
invalid_args_range(ctx, d.expr_or_pat, d.expected, d.found),
)
}

Expand All @@ -40,17 +40,17 @@ pub(crate) fn mismatched_arg_count(
Diagnostic::new(
DiagnosticCode::RustcHardError("E0107"),
message,
invalid_args_range(ctx, d.call_expr.map(Into::into), d.expected, d.found),
invalid_args_range(ctx, d.call_expr.map(AstPtr::wrap_left), d.expected, d.found),
)
}

fn invalid_args_range(
ctx: &DiagnosticsContext<'_>,
source: InFile<SyntaxNodePtr>,
source: InFile<AstPtr<Either<ast::Expr, ast::Pat>>>,
expected: usize,
found: usize,
) -> FileRange {
adjusted_display_range::<Either<ast::Expr, ast::TupleStructPat>>(ctx, source, &|expr| {
adjusted_display_range_new(ctx, source, &|expr| {
let (text_range, r_paren_token, expected_arg) = match expr {
Either::Left(ast::Expr::CallExpr(call)) => {
let arg_list = call.arg_list()?;
Expand All @@ -68,7 +68,7 @@ fn invalid_args_range(
arg_list.args().nth(expected).map(|it| it.syntax().text_range()),
)
}
Either::Right(pat) => {
Either::Right(ast::Pat::TupleStructPat(pat)) => {
let r_paren = pat.r_paren_token()?;
let l_paren = pat.l_paren_token()?;
(
Expand Down

0 comments on commit 596e5c7

Please sign in to comment.