one type is more general than the other: note: expected reference `&_` found reference `&_` (note: the lifetime requirement is introduced here: [arrow points at nothing])
Open
Nobody has claimed this yet.
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
fn main() {
let outputs_rgb: &mut [[u8; 12]] = &mut [];
fn gaming(_: &[u8; 12]) -> &[u8] {
unimplemented!()
}
outputs_rgb.sort_unstable_by_key(gaming);
}
Current output
error[E0308]: mismatched types
--> test.rs:6:5
|
6 | outputs_rgb.sort_unstable_by_key(gaming);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected reference `&_`
found reference `&_`
note: the lifetime requirement is introduced here
--> D:\Users\nabijaczleweli\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib/rustlib/src/rust\library\core\src\slice\mod.rs:3029:25
|
3029 | F: FnMut(&T) -> K,
| ^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
Desired output
idk. literally anything else i think lol
Rust Version
rustc 1.84.1 (e71f9a9a9 2025-01-27)
binary: rustc
commit-hash: e71f9a9a98b0faf423844bf0ba7438f29dc27d58
commit-date: 2025-01-27
host: x86_64-pc-windows-gnu
release: 1.84.1
LLVM version: 19.1.5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the example with rustc 1.84.1 and inspect the lifetime requirement reported at rustlib/src/rust/library/core/src/slice/mod.rs:3029. Trace how this requirement reaches the E0308 diagnostic and determine what clearer explanation can be produced. Done means the same code reports an understandable diagnostic, covered by an appropriate compiler diagnostic test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100