-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Cow
in {D,Subd}iagnosticMessage
.
#111748
Conversation
Some changes occurred in src/tools/clippy cc @rust-lang/clippy The Miri subtree was changed cc @rust-lang/miri
|
This comment has been minimized.
This comment has been minimized.
6e4f480
to
6f545b4
Compare
This comment has been minimized.
This comment has been minimized.
Do I understand it right, that since we need to store diagnostics, having (i.e. I want to make sure we don't exclude anything by requiring |
I guess you could say that. I.e. currently we convert any |
☔ The latest upstream changes (presumably #111778) made this pull request unmergeable. Please resolve the merge conflicts. |
6f545b4
to
c0e83a0
Compare
I have rebased and addressed @RalfJung's comment. |
This comment has been minimized.
This comment has been minimized.
c0e83a0
to
a146c39
Compare
a146c39
to
104f104
Compare
@WaffleLapkin: what's the status here, are we good to proceed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure this is a good idea, since some call cites got marginally more complex, but it's probably fine.
r=me with the nit
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.
104f104
to
781111e
Compare
@bors r=WaffleLapkin |
☀️ Test successful - checks-actions |
Finished benchmarking commit (70e04bd): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 642.999s -> 643.87s (0.14%) |
Perf changes are all for secondary benchmarks. The small wins and small losses balance out. @rustbot label: +perf-regression-triaged |
lifetimes for those slices changed to 'static
Each of
{D,Subd}iagnosticMessage::{Str,Eager}
has a comment:This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging.
This requires changing the
impl<'a> From<&'a str>
impls toimpl From<&'static str>
, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just&str
. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths.Note that I was lazy within Clippy, using
to_string
in a few places to preserve the existing string imprecision. I could have usedimpl Into<{D,Subd}iagnosticMessage>
in various places as is done in the compiler, but that would have required changes to many call sites (mostly changing&format("...")
toformat!("...")
) which didn't seem worthwhile.r? @WaffleLapkin