Skip to content

Fix rust-latest pipeline job failure due to uninlined-format-args errors from clippy 1.67

Narayanan Iyer requested to merge nars1/YDBRust:clippy_error into master

Background

  • The rust-latest pipeline job started failing in the pipeline as follows (below is from https://gitlab.com/YottaDB/Lang/YDBRust/-/jobs/3669536209).

    error: variables can be used directly in the `format!` string
      --> build.rs:28:5
       |
    28 |     println!("cargo:rust-link-search={}", library_path);
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
       = note: `-D clippy::uninlined-format-args` implied by `-D clippy::all`
    help: change this to
       |
    28 -     println!("cargo:rust-link-search={}", library_path);
    28 +     println!("cargo:rust-link-search={library_path}");
       |
    error: could not compile `yottadb` due to previous error

Issue

  • clippy 1.67 was released on Jan 26, 2023.

  • https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-167 says the following.

    Moved uninlined_format_args to style (Now warn-by-default) #9865
  • Because of this, pre-existing code in build.rs started being called out by clippy for an error from clippy 1.67 (which gets used only in the rust-latest pipeline job) onwards.

Fix

  • I originally tried to go with what it suggested. That is, made the following change to build.rs.

    -     println!("cargo:rust-link-search={}", library_path);
    +     println!("cargo:rust-link-search={library_path}");
  • But the rust-compat pipeline job started failing with the following error.

    error: there is no argument named `library_path`
      --> build.rs:28:38
       |
    28 |     println!("cargo:rust-link-search={library_path}");
       |                                      ^^^^^^^^^^^^^^

    This job runs with rust 1.47.

  • I was not sure how else to fix it so rust 1.47 and rust 1.67 will both be fine with it.

  • Therefore, decided to allow uninlined_format_args to not be warned by default. The changes are in .gitlab-ci.yml in the rust-latest job to add a --allow clippy:uninlined-format-args as part of the cargo clippy command.

Merge request reports