{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreiedffs7xrzakfr4wa6iccke2cmlo2gdobm57xw5umyr3dnkmbj7ti",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mgqn3h27fl72"
  },
  "path": "/t/stop-including-string-content-in-index-panics/24067#post_1",
  "publishedAt": "2026-03-10T16:53:51.000Z",
  "site": "https://internals.rust-lang.org",
  "tags": [
    "https://zed.dev"
  ],
  "textContent": "HI Rust!\n\nAt Zed (https://zed.dev) we track panics in a centralized system so that we can identify and fix problems.\n\nA major cause of panics at Zed is indexing into strings erroneously (we do a _lot_ of string manipulation); usually due to bad utf8 offset handling, or occasionally just off by one or out-of-bounds.\n\nThe problem is that `String` when it panics includes a small fragment of the string. This can be useful locally for debugging, but for centralized panic tracking, we'd really like to not handle this stuff.\n\nIs there appetite to either:\n\n  * Add a flag to the standard library to suppress this.\n  * Change the default panic messages to not include content.\n\n\n\nFor example\n\n  * currently we see: \"begin <= end (4 <= 3) when slicing `test`. I'd like this to become \"byte index range starts before end (4..3)\"\n  * \"byte index 2458645928158 is out of bounds of `test`\". I'd like this to become \"byte index 2458645928158 is out of bounds for string of length 4\"\n  * \"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)\"\n\n\n\nThe alternative we can explore is trying to replace the strings on the way through the panic handler (or forbid indexing into a string - doesn't seem tenable); but I'd rather push this down to the standard library.",
  "title": "Stop including string content in index panics?"
}