about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/coverage/debug.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-09-07 11:03:01 +0000
committerbors <bors@rust-lang.org>2023-09-07 11:03:01 +0000
commit415ba21c3b78125cf583ca0ef7a318a8f347a282 (patch)
tree40ffa0543580506cece3ca130d99d544c37c28d6 /compiler/rustc_mir_transform/src/coverage/debug.rs
parent69fcbfdac06d2ccf24c1c0bcaaf2e44895f45c7b (diff)
parent51206323a100b2b2e2b94b0f65078eb9523e524d (diff)
downloadrust-415ba21c3b78125cf583ca0ef7a318a8f347a282.tar.gz
rust-415ba21c3b78125cf583ca0ef7a318a8f347a282.zip
Auto merge of #11451 - y21:issue11408, r=xFrednet
[`slow_vector_initialization`]: use the source span of vec![] macro and fix another FP

Fixes #11408

<details>
<summary>Also fixes a FP when the vec initializer comes from a macro other than `vec![]`</summary>

```rs
macro_rules! x {
  () => { vec![] }
}
fn f() {
  let mut v = x!();
  v.resize(10, 0);
}
```
This shouldn't warn. The `x!` macro might be doing other things, so just replacing `x!()` with `vec![0; 10]` is not always an option.
</details>

I added some test cases for macro expansions, however I don't think there's a way to write a test for that specific warning that appeared in the linked issue. As far as I understand, that happens when the rust-src rustup component isn't installed (so the stdlib source is unavailable) and the span points to the `vec![]` *expansion*, instead of the `vec![]` that the user wrote.

changelog: [`slow_vector_initialization`]: use the source span of `vec![]` macro
changelog: [`slow_vector_initialization`]: only warn on `vec![]` expansions and allow other macros
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/debug.rs')
0 files changed, 0 insertions, 0 deletions