I randomly noticed that self.ptr of core::slice::Iter may never be null (also because of unconditionally calling from_raw_parts), but it's not contained in NonNull<T>, so it isn't optimized.
I double checked for compiler internal Voodoo and it confirms the lack of optimization.
I was thinking about fixing it just for fun, but it occurred to me that the current code uses assume at several places and maybe it'd be a good idea to rather add assume into NonNull::as_ptr to clean it up? Not sure, so I'm asking. (Also maybe add assume to <[T]>::as_ptr(), but that's a different topic.)
I randomly noticed that
self.ptrofcore::slice::Itermay never be null (also because of unconditionally callingfrom_raw_parts), but it's not contained inNonNull<T>, so it isn't optimized.I double checked for compiler internal Voodoo and it confirms the lack of optimization.
I was thinking about fixing it just for fun, but it occurred to me that the current code uses
assumeat several places and maybe it'd be a good idea to rather addassumeintoNonNull::as_ptrto clean it up? Not sure, so I'm asking. (Also maybe add assume to<[T]>::as_ptr(), but that's a different topic.)