Skip to content
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

Fix debug_assert in unused lint pass #94353

Merged
merged 1 commit into from
Feb 25, 2022
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
12 changes: 6 additions & 6 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,17 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
}
ty::Tuple(ref tys) => {
let mut has_emitted = false;
let spans = if let hir::ExprKind::Tup(comps) = &expr.kind {
let comps = if let hir::ExprKind::Tup(comps) = expr.kind {
debug_assert_eq!(comps.len(), tys.len());
comps.iter().map(|e| e.span).collect()
comps
} else {
vec![]
&[]
};
for (i, ty) in tys.iter().enumerate() {
let descr_post = &format!(" in tuple element {}", i);
let span = *spans.get(i).unwrap_or(&span);
if check_must_use_ty(cx, ty, expr, span, descr_pre, descr_post, plural_len)
{
let e = comps.get(i).unwrap_or(expr);
let span = e.span;
if check_must_use_ty(cx, ty, e, span, descr_pre, descr_post, plural_len) {
has_emitted = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/unused/must_use-array.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ error: unused array of boxed `T` trait objects in tuple element 1 that must be u
--> $DIR/must_use-array.rs:43:5
|
LL | impl_array();
| ^^^^^^^^^^^^^
| ^^^^^^^^^^^^

error: unused array of arrays of arrays of `S` that must be used
--> $DIR/must_use-array.rs:45:5
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/lint/unused/must_use-trait.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ error: unused boxed `Critical` trait object in tuple element 1 that must be used
--> $DIR/must_use-trait.rs:37:5
|
LL | get_critical_tuple();
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^

error: unused implementer of `Critical` in tuple element 2 that must be used
--> $DIR/must_use-trait.rs:37:5
|
LL | get_critical_tuple();
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^

error: aborting due to 5 previous errors

6 changes: 3 additions & 3 deletions src/test/ui/lint/unused/must_use-tuple.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ error: unused `Result` in tuple element 0 that must be used
--> $DIR/must_use-tuple.rs:14:5
|
LL | foo();
| ^^^^^^
| ^^^^^
|
= note: this `Result` may be an `Err` variant, which should be handled

error: unused `Result` in tuple element 0 that must be used
--> $DIR/must_use-tuple.rs:16:6
--> $DIR/must_use-tuple.rs:16:7
|
LL | ((Err::<(), ()>(()), ()), ());
| ^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^
|
= note: this `Result` may be an `Err` variant, which should be handled

Expand Down