]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #103828 - cassaundra:fix-format-args-span2, r=cjgillot
authorbors <bors@rust-lang.org>
Mon, 26 Dec 2022 12:03:47 +0000 (12:03 +0000)
committerbors <bors@rust-lang.org>
Mon, 26 Dec 2022 12:03:47 +0000 (12:03 +0000)
Fix incorrect span when using byte-escaped rbrace

Fix #103826, a format args span issue introduced in #102214.

The current solution for tracking skipped characters made it so that certain situations were ambiguous enough that the original span couldn't be worked out later. This PR improves on the original solution by keeping track of groups of skipped characters using a map, and fixes the previous bug. See an example of this ambiguity in the [previous PR's discussion](https://github.com/rust-lang/rust/pull/102214#issuecomment-1258711015).

1  2 
compiler/rustc_parse_format/src/lib.rs

index 9cbe04c1288effe53ad31e764541f49ef032a23a,28bd84b9a6d69f47ac25f81b3f68331558841a54..ab0463045faf998ddf7868ff189ba0600a24e42a
@@@ -905,12 -936,8 +936,12 @@@ fn find_width_map_from_snippet
              _ => {}
          }
      }
-     (skips, true)
+     (width_mappings, true)
  }
  
 +// Assert a reasonable size for `Piece`
 +#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
 +rustc_data_structures::static_assert_size!(Piece<'_>, 16);
 +
  #[cfg(test)]
  mod tests;