Skip to content
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

Avoid &format("...") calls in error message code. #111633

Merged
merged 2 commits into from
May 18, 2023

Commits on May 16, 2023

  1. Remove Session::span_err_or_warn.

    It's unused.
    nnethercote committed May 16, 2023
    Configuration menu
    Copy the full SHA
    87a2bc0 View commit details
    Browse the repository at this point in the history
  2. Avoid &format("...") calls in error message code.

    Error message all end up passing into a function as an `impl
    Into<{D,Subd}iagnosticMessage>`. If an error message is creatd as
    `&format("...")` that means we allocate a string (in the `format!`
    call), then take a reference, and then clone (allocating again) the
    reference to produce the `{D,Subd}iagnosticMessage`, which is silly.
    
    This commit removes the leading `&` from a lot of these cases. This
    means the original `String` is moved into the
    `{D,Subd}iagnosticMessage`, avoiding the double allocations. This
    requires changing some function argument types from `&str` to `String`
    (when all arguments are `String`) or `impl
    Into<{D,Subd}iagnosticMessage>` (when some arguments are `String` and
    some are `&str`).
    nnethercote committed May 16, 2023
    Configuration menu
    Copy the full SHA
    01e33a3 View commit details
    Browse the repository at this point in the history