Skip to content

Remove unnecessary check code in unused_delims #137029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2025
Merged
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
24 changes: 0 additions & 24 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::iter;
use std::ops::ControlFlow;

use rustc_ast as ast;
use rustc_ast::util::{classify, parser};
Expand Down Expand Up @@ -781,29 +780,6 @@ trait UnusedDelimLint {
right_pos: Option<BytePos>,
is_kw: bool,
) {
// If `value` has `ExprKind::Err`, unused delim lint can be broken.
// For example, the following code caused ICE.
// This is because the `ExprKind::Call` in `value` has `ExprKind::Err` as its argument
// and this leads to wrong spans. #104897
//
// ```
// fn f(){(print!(á
// ```
use rustc_ast::visit::{Visitor, walk_expr};
struct ErrExprVisitor;
impl<'ast> Visitor<'ast> for ErrExprVisitor {
type Result = ControlFlow<()>;
fn visit_expr(&mut self, expr: &'ast ast::Expr) -> ControlFlow<()> {
if let ExprKind::Err(_) = expr.kind {
ControlFlow::Break(())
} else {
walk_expr(self, expr)
}
}
}
if ErrExprVisitor.visit_expr(value).is_break() {
return;
}
let spans = match value.kind {
ast::ExprKind::Block(ref block, None) if let [stmt] = block.stmts.as_slice() => stmt
.span
Expand Down
Loading