-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Description
Summary
Reproducer:
#![allow(unused)]
#![warn(clippy::elidable_lifetime_names)]
struct UnitVariantAccess<'a, 'b, 's>(&'a &'b &'s ());
trait Trait<'de> {}
impl<'de, 'a, 's> Trait<'de> for UnitVariantAccess<'a, 'de, 's> {}
The lint wants to suggest removing both 'a
and 's
on the left, but the spans overlap:
impl<'de, 'a, 's> Trait<'de> for UnitVariantAccess<'a, 'de, 's> {}
// ^^^^ span for `'a`
// ^^^^ span for `'s`
That's because here, the span is either expanded forward or backwards:
rust-clippy/clippy_lints/src/lifetimes.rs
Lines 876 to 888 in af7fa53
let span = if let Some(next) = explicit_params.get(pos + 1) { | |
// fn x<'prev, 'a, 'next>() {} | |
// ^^^^ | |
param.span.until(next.span) | |
} else { | |
// `pos` should be at least 1 here, because the param in position 0 would either have a `next` | |
// param or would have taken the `elidable_lts.len() == explicit_params.len()` branch. | |
let prev = explicit_params.get(pos - 1)?; | |
// fn x<'prev, 'a>() {} | |
// ^^^^ | |
param.span.with_lo(prev.span.hi()) | |
}; |
I think it should just always be expanded backwards.
Version
(playground, nightly 1.91.0, 2025-09-11)
Error output
Backtrace
thread 'rustc' (26) panicked at compiler/rustc_errors/src/lib.rs:385:17:
assertion `left == right` failed: all spans must be disjoint
left: Some([SubstitutionPart { span: src/lib.rs:6:11: 6:15 (#0), snippet: "" }, SubstitutionPart { span: src/lib.rs:6:13: 6:17 (#0), snippet: "" }])
right: None
stack backtrace:
0: 0x79c25e5b42f3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h45293323ac201b23
1: 0x79c25ec01b58 - core::fmt::write::hd12b7fb25f530f3f
2: 0x79c25e569111 - std::io::Write::write_fmt::h3e7d45459e0c1c45
3: 0x79c25e57a222 - std::sys::backtrace::BacktraceLock::print::h61ed712f1468d59e
4: 0x79c25e580169 - std::panicking::default_hook::{{closure}}::he68c7f167941e4bd
5: 0x79c25e57fc93 - std::panicking::default_hook::hec7f8fa388ce973c
6: 0x79c25d5c8907 - std[1ae240f8297d0d6c]::panicking::update_hook::<alloc[73dd91e0cc1c5a1a]::boxed::Box<rustc_driver_impl[78e3243580736ecc]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x79c25e58058f - std::panicking::panic_with_hook::h61973874e117c0ff
8: 0x79c25e58034a - std::panicking::panic_handler::{{closure}}::h36a6fb0038e5da7f
9: 0x79c25e57a359 - std::sys::backtrace::__rust_end_short_backtrace::h1d93851e041118c6
10: 0x79c25e55ab4d - __rustc[7cda223a5263d337]::rust_begin_unwind
11: 0x79c25acc41b0 - core::panicking::panic_fmt::hcbd1e8cc2091fa74
12: 0x79c25cfbcaa3 - core::panicking::assert_failed_inner::ha7d07530d960d657
13: 0x79c25d5f87f8 - core[da588fff69c04809]::panicking::assert_failed::<core[da588fff69c04809]::option::Option<&[rustc_errors[b8067015f8202f5a]::SubstitutionPart; 2usize]>, core[da588fff69c04809]::option::Option<&[rustc_errors[b8067015f8202f5a]::SubstitutionPart; 2usize]>>
14: 0x79c26001f475 - <core[da588fff69c04809]::iter::adapters::filter_map::FilterMap<core[da588fff69c04809]::iter::adapters::cloned::Cloned<core[da588fff69c04809]::iter::adapters::filter::Filter<core[da588fff69c04809]::slice::iter::Iter<rustc_errors[b8067015f8202f5a]::Substitution>, <rustc_errors[b8067015f8202f5a]::CodeSuggestion>::splice_lines::{closure#0}>>, <rustc_errors[b8067015f8202f5a]::CodeSuggestion>::splice_lines::{closure#1}> as core[da588fff69c04809]::iter::traits::iterator::Iterator>::next
15: 0x79c26002119d - <rustc_errors[b8067015f8202f5a]::emitter::HumanEmitter>::emit_suggestion_default
16: 0x79c26013de93 - <rustc_errors[b8067015f8202f5a]::emitter::HumanEmitter as rustc_errors[b8067015f8202f5a]::emitter::Emitter>::emit_diagnostic
17: 0x79c26014353a - <rustc_errors[b8067015f8202f5a]::json::Diagnostic>::from_errors_diagnostic
18: 0x79c260142c38 - <rustc_errors[b8067015f8202f5a]::json::JsonEmitter as rustc_errors[b8067015f8202f5a]::emitter::Emitter>::emit_diagnostic
19: 0x79c26014c4d8 - <rustc_errors[b8067015f8202f5a]::DiagCtxtInner>::emit_diagnostic::{closure#3}
20: 0x79c260149e9a - rustc_interface[62b49246b63c578b]::callbacks::track_diagnostic::<core[da588fff69c04809]::option::Option<rustc_span[f43c50832aa820f8]::ErrorGuaranteed>>
21: 0x79c260148eb6 - <rustc_errors[b8067015f8202f5a]::DiagCtxtInner>::emit_diagnostic
22: 0x79c260148d7f - <rustc_errors[b8067015f8202f5a]::DiagCtxtHandle>::emit_diagnostic
23: 0x79c260148c15 - <() as rustc_errors[b8067015f8202f5a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
24: 0x79c25f4287b0 - rustc_middle[2a025faa3cb08f3a]::lint::lint_level::lint_level_impl
25: 0x5d04e22efcb2 - clippy_lints[7e96a47f247200b6]::lifetimes::report_elidable_lifetimes
26: 0x5d04e247a85b - <clippy_lints[7e96a47f247200b6]::lifetimes::Lifetimes as rustc_lint[7585ae1db7a60665]::passes::LateLintPass>::check_item
27: 0x79c25db305a7 - <rustc_lint[7585ae1db7a60665]::late::LateContextAndPass<rustc_lint[7585ae1db7a60665]::late::RuntimeCombinedLateLintPass> as rustc_hir[4374c6b2d46088c0]::intravisit::Visitor>::visit_nested_item
28: 0x79c25dab10a9 - <rustc_lint[7585ae1db7a60665]::late::LateContextAndPass<rustc_lint[7585ae1db7a60665]::late::RuntimeCombinedLateLintPass>>::process_mod
29: 0x79c25fc3d0f6 - rustc_lint[7585ae1db7a60665]::late::check_crate::{closure#0}
30: 0x79c25fc3c283 - rustc_lint[7585ae1db7a60665]::late::check_crate
31: 0x79c25ee060c4 - rustc_interface[62b49246b63c578b]::passes::analysis
32: 0x79c25ee0584b - rustc_query_impl[280aa44c48291896]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[280aa44c48291896]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2a025faa3cb08f3a]::query::erase::Erased<[u8; 0usize]>>
33: 0x79c25fc39fe0 - rustc_query_system[842ae891ac65c311]::query::plumbing::try_execute_query::<rustc_query_impl[280aa44c48291896]::DynamicConfig<rustc_query_system[842ae891ac65c311]::query::caches::SingleCache<rustc_middle[2a025faa3cb08f3a]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[280aa44c48291896]::plumbing::QueryCtxt, false>
34: 0x79c25fc39c36 - rustc_query_impl[280aa44c48291896]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
35: 0x79c25feb38a3 - rustc_interface[62b49246b63c578b]::passes::create_and_enter_global_ctxt::<core[da588fff69c04809]::option::Option<rustc_interface[62b49246b63c578b]::queries::Linker>, rustc_driver_impl[78e3243580736ecc]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
36: 0x79c25ff221fe - rustc_interface[62b49246b63c578b]::interface::run_compiler::<(), rustc_driver_impl[78e3243580736ecc]::run_compiler::{closure#0}>::{closure#1}
37: 0x79c25fe0d9f8 - std[1ae240f8297d0d6c]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[62b49246b63c578b]::util::run_in_thread_with_globals<rustc_interface[62b49246b63c578b]::util::run_in_thread_pool_with_globals<rustc_interface[62b49246b63c578b]::interface::run_compiler<(), rustc_driver_impl[78e3243580736ecc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
38: 0x79c25fe0d6dc - <<std[1ae240f8297d0d6c]::thread::Builder>::spawn_unchecked_<rustc_interface[62b49246b63c578b]::util::run_in_thread_with_globals<rustc_interface[62b49246b63c578b]::util::run_in_thread_pool_with_globals<rustc_interface[62b49246b63c578b]::interface::run_compiler<(), rustc_driver_impl[78e3243580736ecc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[da588fff69c04809]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
39: 0x79c25fe13c4d - std::sys::pal::unix::thread::Thread::new::thread_start::h1cdad654c1f80c84
40: 0x79c25988aaa4 - <unknown>
41: 0x79c259917a34 - clone
42: 0x0 - <unknown>
error: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml
note: please make sure that you have updated to the latest nightly
note: please attach the file at `/playground/rustc-ice-2025-09-12T14_44_26-25.txt` to your bug report
note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
note: Clippy version: clippy 0.1.91 (5eda692e73 2025-09-11)
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️