about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-02-05 17:44:37 +0000
committerbors <bors@rust-lang.org>2022-02-05 17:44:37 +0000
commit68b44986de6a8c9e844afa55693a24f0d4a0978e (patch)
treefa2e21087e2a10dfada3a1879a5132ed789cf5be /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent29cc0d8e595f93cd0bd8341dd034c847f3a7746f (diff)
parent144b4a59c7a3d18a0dd2c4316061672d00516ea3 (diff)
downloadrust-68b44986de6a8c9e844afa55693a24f0d4a0978e.tar.gz
rust-68b44986de6a8c9e844afa55693a24f0d4a0978e.zip
Auto merge of #8365 - Alexendoo:explicit-write-suggestion, r=camsteffen
Add `explicit_write` suggestions for `write!`s with format args

changelog: Add [`explicit_write`] suggestions for `write!`s with format args

Fixes #4542

```rust
writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();
```

Now suggests:

```
error: use of `writeln!(stderr(), ...).unwrap()`
  --> $DIR/explicit_write.rs:36:9
   |
LL |         writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("macro arg {}", one!())`
```

---------

r? `@camsteffen` (again, sorry 😛) for the `FormatArgsExpn` change

Before this change `inputs_span` returned a span pointing to just `1` in

```rust
macro_rules! one {
    () => { 1 };
}

`writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();`
```

And the `source_callsite` of that span didn't include the format string, it was just `one!()`
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions