External Publication
Visit Post

Stop including string content in index panics?

Rust Internals [Unofficial] March 10, 2026
Source

ConradIrwin:

currently we see: "begin <= end (4 <= 3) when slicing test. I'd like this to become "byte index range starts before end (4..3)"

Hmm, this is particularly gratuitous right now:

byte index 1000 is out of bounds of aseirughaoirughaoerghaoerghaorvlijesr;oibgfhs;eroignvs;eorigjhvas;loijhvsoeruifpsioreuyhfgvosliueryhvglaiueyrhvfgliuhrlukvzyhrvlkusrdyhvlkzuyrsvhlkuyhfgbrlixuyvlikzurhfclsvkurdygvhskrerghaierughaslierughaseirughaergiuhaeriuhager

Echoing the whole string seems clearly wrong and unnecessary, so at least this one I think we should just do. Maybe make a PR for that part and we can nominate for libs/libs-api discussion? (Feel free to r? @scottmcm.)

ConradIrwin:

"byte index 1 is not a char boundary; it is inside 'ã' (bytes 0..2) of ãchoo. I'd like this to become "byte index 1 is not at a utf-8 character boundary; the character spans from indexes 0..2)"

The single USV , however, does seem particularly useful as friendliness to the developer, especially the new developer not yet used to how rust does indexing, so I'd be more reticent to remove the "inside 'ã'" part. (Removing the "of ãchoo" part seems obvious, like the previous case.)

How much of a problem does the single USV cause? My instinct is that that wouldn't trigger the same GDPR-and-similar problems the full string could...

Discussion in the ATmosphere

Loading comments...