about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
diff options
context:
space:
mode:
authorChayim Refael Friedman <chayimfr@gmail.com>2023-05-15 21:08:45 +0300
committerChayim Refael Friedman <chayimfr@gmail.com>2023-05-15 21:16:35 +0300
commit83930ecdea7eee3191316770071cc6e5019a8e3e (patch)
treee7de6eddeb1aea5438bb12170a5f77589ba77bc7 /compiler/rustc_trait_selection/src/traits
parent4d941cd9812891af3b83dd4de64aa7d8ee99641a (diff)
downloadrust-83930ecdea7eee3191316770071cc6e5019a8e3e.tar.gz
rust-83930ecdea7eee3191316770071cc6e5019a8e3e.zip
Give better error when collecting into `&[T]`
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs
index 88525e1b720..10bd027b684 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs
@@ -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) {