1
Fork 0

Give better error when collecting into &[T]

This commit is contained in:
Chayim Refael Friedman 2023-05-15 21:08:45 +03:00
parent 4d941cd981
commit 83930ecdea
4 changed files with 35 additions and 1 deletions

View file

@ -306,6 +306,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}
}
}
// `&[{integral}]` - `FromIterator` needs that.
if let ty::Ref(_, ref_ty, rustc_ast::Mutability::Not) = self_ty.kind()
&& let ty::Slice(sty) = ref_ty.kind()
&& sty.is_integral()
{
flags.push((sym::_Self, Some("&[{integral}]".to_owned())));
}
});
if let Ok(Some(command)) = OnUnimplementedDirective::of_item(self.tcx, def_id) {