Bogus suggestion on I::Item vs &I::Item mismatch #112104
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
Item = &Item
obviously wouldn't work, the compiler should not suggest that. The proper fix here is to convert the firstOption<I::Item>
to anOption<&I::Item>
by calling.as_ref()
on it.Other cases
No response
Anything else?
This is reduced from a real example where I was trying to check that the iterator emits the expected series of items:
The text was updated successfully, but these errors were encountered: