diff options
| author | bors <bors@rust-lang.org> | 2024-04-01 14:10:40 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-01 14:10:40 +0000 |
| commit | c2681f2338c2fbeaeb87cda1c19bc7e9cd95f2f4 (patch) | |
| tree | 7826cfc3453cc41e138defdbd3c7fc75b2d3bbb1 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | cb87a574fd5d70293531856619a05403c13ca74f (diff) | |
| parent | 91f514cc8360b369a7fe5f6108aae025b22a38db (diff) | |
| download | rust-c2681f2338c2fbeaeb87cda1c19bc7e9cd95f2f4.tar.gz rust-c2681f2338c2fbeaeb87cda1c19bc7e9cd95f2f4.zip | |
Auto merge of #12453 - y21:span_lint_into_diag, r=blyxyas
accept `String` in `span_lint*` functions directly to avoid unnecessary clones context: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Accepting.20.60Into.3C.7BSub.7DdiagMessage.3E.60.20in.20.60span_lint*.60.20functions/near/425703273 tldr: the `span_lint*` functions now accept both `String`s, which are then reused and not recloned like before, and also `&'static str`, in which case it [doesn't need to allocate](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_error_messages/lib.rs.html#359). Previously, it accepted `&str` and would always call `.to_string()`, which is worse in any case: it allocates for `&'static str` and forces a clone even if the caller already has a `String`. --------- This PR has a massive diff, but the only interesting change is in the first commit, which changes the message/help/note parameter in the `span_lint*` functions to not take a `&str`, but an `impl Into<DiagMessage>`. The second commit changes all of the errors that now occur: - `&format!(...)` cannot be passed to `span_lint` anymore. Instead, we now simply pass `format!()` directly. - `Into<DiagMessage>` can be `&'static str`, but not any `&str`. So this requires changing a bunch of other `&str` to `&'static str` at call sites as well. - Added [`Sugg::into_string`](https://github.com/y21/rust-clippy/blob/9fc88bc2851fbb287d89f65b78fb67af504f8362/clippy_utils/src/sugg.rs#L362), which, as opposed to `Sugg::to_string`, can take advantage of the fact that it takes ownership and is able to reuse the `String` changelog: none
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
