Rollup merge of #94746 - notriddle:notriddle/method-rustc-on-unimplemented, r=davidtwco
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:
commit
e7281d08de
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,
|
||||
|
@ -204,6 +204,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