diagnostics: use rustc_on_unimplemented to recommend [].iter()
To make this work, the `#[rustc_on_unimplemented]` data needs to be used to report method resolution errors, which is most of what this commit does. Fixes #94581
This commit is contained in:
parent
d137c3a7bd
commit
32d7f8145a
11 changed files with 258 additions and 162 deletions
|
@ -11,7 +11,7 @@ use std::iter;
|
|||
|
||||
use super::InferCtxtPrivExt;
|
||||
|
||||
crate trait InferCtxtExt<'tcx> {
|
||||
pub trait InferCtxtExt<'tcx> {
|
||||
/*private*/
|
||||
fn impl_similar_to(
|
||||
&self,
|
||||
|
@ -202,6 +202,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
flags.push((sym::_Self, Some("{integral}".to_owned())));
|
||||
}
|
||||
|
||||
if self_ty.is_array_slice() {
|
||||
flags.push((sym::_Self, Some("&[]".to_owned())));
|
||||
}
|
||||
|
||||
if let ty::Array(aty, len) = self_ty.kind() {
|
||||
flags.push((sym::_Self, Some("[]".to_owned())));
|
||||
flags.push((sym::_Self, Some(format!("[{}]", aty))));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue